From: <man...@us...> - 2009-07-22 13:49:52
|
Revision: 20303 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=20303&view=rev Author: mangapower Date: 2009-07-22 13:49:50 +0000 (Wed, 22 Jul 2009) Log Message: ----------- [MOD] Modified get_object_perms_for_group: now it's called get_object_perms_for_user and seeks the perms related to a object for a single user Modified Paths: -------------- branches/experimental/ws/lib/workspaces/wslib.php branches/experimental/ws/templates/tiki-user_ws.tpl branches/experimental/ws/templates/tiki-workspaces-index.tpl branches/experimental/ws/tiki-user_ws.php branches/experimental/ws/tiki-workspaces-index.php Modified: branches/experimental/ws/lib/workspaces/wslib.php =================================================================== --- branches/experimental/ws/lib/workspaces/wslib.php 2009-07-22 13:13:37 UTC (rev 20302) +++ branches/experimental/ws/lib/workspaces/wslib.php 2009-07-22 13:49:50 UTC (rev 20303) @@ -843,6 +843,30 @@ return $objectPermsGroup; } + + /** Get the stored perms for a object for a specific user + * + * @param $objId The object you want to check + * @param $objectType The type of the object + * @param $user The name of the user + * @return An array with the objects perms related to a object for a user + */ + public function get_object_perms_for_user ($objId, $objectType, $user) + { + $objectId = md5($objectType . strtolower($objId)); + $query = "select distinct t3.`permName` from `users_objectpermissions` t3, `users_usergroups` t2, `users_users` t1 + where t1.`login` = ? + and (t1.`userId` = t2.`userId`) + and (t2.`groupName` = t3.`groupName`) + and t3.`objectId`=? + and t3.`objectType`=?"; + $bindvars = array($user, $objectId, $objectType); + $result = $this->query($query,$bindvars); + while ($res = $result->fetchRow()) + $objectPermsUser[] = $res["permName"]; + + return $objectPermsUser; + } /** List the objects stored in a workspace for a specific user * @@ -859,25 +883,13 @@ foreach ($listWSObjects as $object) { - $objectType = $object["type"]; - $objId = $object["itemId"]; - $viewPerm = parent::get_needed_perm($objectType, "view"); - - $groups = $userlib->get_user_groups($user); - - $notFoundViewPerm = true; - foreach ($groups as $groupName) - { - if ($notFoundViewPerm) - { - $objectPermsGroup = $this->get_object_perms_for_group ($objId, $objectType, $groupName); - if (in_array($viewPerm,$objectPermsGroup)) - { - $listWSObjectsUser[] = $object; - $notFoundViewPerm = false; - } - } - } + $objectType = $object["type"]; + $objId = $object["itemId"]; + $viewPerm = parent::get_needed_perm($objectType, "view"); + + $objectPermsUser = $this->get_object_perms_for_user ($objId, $objectType, $user); + if (in_array($viewPerm,$objectPermsUser)) + $listWSObjectsUser[] = $object; } return $listWSObjectsUser; Modified: branches/experimental/ws/templates/tiki-user_ws.tpl =================================================================== --- branches/experimental/ws/templates/tiki-user_ws.tpl 2009-07-22 13:13:37 UTC (rev 20302) +++ branches/experimental/ws/templates/tiki-user_ws.tpl 2009-07-22 13:49:50 UTC (rev 20303) @@ -2,28 +2,13 @@ <table> <tr> - <th>Name</th> - <th>Description</th> - <th>Path</th> -</tr> -{foreach from=$listWS item=data} - <tr> - <td><a href = {$data.href}>{$data.name}</a></td> - <td>{$data.description}</td> - <td>{$data.wspath}</td> - </tr> -{/foreach} -</table> - -<table> -<tr> <th>Object Name</th> <th>Type</th> <th>Description</th> </tr> {foreach from=$resources item=data} <tr> - <td><a>{$data.name}</a></td> + <td><a href = {$data.href}>{$data.name}</a></td> <td>{$data.type}</td> <td>{$data.description}</td> </tr> Modified: branches/experimental/ws/templates/tiki-workspaces-index.tpl =================================================================== --- branches/experimental/ws/templates/tiki-workspaces-index.tpl 2009-07-22 13:13:37 UTC (rev 20302) +++ branches/experimental/ws/templates/tiki-workspaces-index.tpl 2009-07-22 13:49:50 UTC (rev 20303) @@ -16,8 +16,22 @@ <ul><li>You want to get started quickly<br /> </li><li>You don't feel like learning the Admin Panel right away<br /> </li><li>You want to quickly test out some of Tiki's Features<br /> -</li></ul> -<br /> --> +</li> +</ul> + <br /> --><table> +<tr> + <th>Name</th> + <th>Description</th> + <th>Path</th> +</tr> +{foreach from=$listWS item=data} + <tr> + <td><a href = {$data.href}>{$data.name}</a></td> + <td>{$data.description}</td> + <td>{$data.wspath}</td> + </tr> +{/foreach} +</table> </td><td valign="top" width="40%" > <br /> Modified: branches/experimental/ws/tiki-user_ws.php =================================================================== --- branches/experimental/ws/tiki-user_ws.php 2009-07-22 13:13:37 UTC (rev 20302) +++ branches/experimental/ws/tiki-user_ws.php 2009-07-22 13:49:50 UTC (rev 20303) @@ -1,14 +1,11 @@ <?php -include_once('tiki-setup.php'); +require_once('tiki-setup.php'); require_once('lib/workspaces/wslib.php'); $value = $user." WorkSpaces"; $smarty->assign('userWS_title', $value); -$listWS = $wslib->list_ws_that_user_have_access ($user, 25, 0); -$smarty->assign('listWS',$listWS); - if ( isset($_REQUEST['showWS'])) { $ws_id = $_REQUEST['showWS']; Modified: branches/experimental/ws/tiki-workspaces-index.php =================================================================== --- branches/experimental/ws/tiki-workspaces-index.php 2009-07-22 13:13:37 UTC (rev 20302) +++ branches/experimental/ws/tiki-workspaces-index.php 2009-07-22 13:49:50 UTC (rev 20303) @@ -10,12 +10,16 @@ //Basic import require_once 'tiki-setup.php'; +require_once('lib/workspaces/wslib.php'); //Rest of Imports //Assign the title to the template $smarty->assign('headtitle', tra('Workspaces Home')); +$listWS = $wslib->list_ws_that_user_have_access ($user, 25, 0); +$smarty->assign('listWS',$listWS); + // Display the template $smarty->assign('mid', 'tiki-workspaces-index.tpl'); $smarty->display("tiki.tpl"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |