當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ilTree::lookupOwner方法代碼示例

本文整理匯總了PHP中ilTree::lookupOwner方法的典型用法代碼示例。如果您正苦於以下問題:PHP ilTree::lookupOwner方法的具體用法?PHP ilTree::lookupOwner怎麽用?PHP ilTree::lookupOwner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ilTree的用法示例。


在下文中一共展示了ilTree::lookupOwner方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkAccessOfUser

 /**
  * check access for an object
  *
  * @param	ilTree		$a_tree
  * @param	integer		$a_user_id
  * @param	string		$a_permission
  * @param	string		$a_cmd
  * @param	int			$a_node_id
  * @param	string		$a_type (optional)
  * @return	bool
  */
 public function checkAccessOfUser(ilTree $a_tree, $a_user_id, $a_permission, $a_cmd, $a_node_id, $a_type = "")
 {
     global $rbacreview, $ilUser;
     // :TODO: create permission for parent node with type ?!
     // tree root is read-only
     if ($a_permission == "write") {
         if ($a_tree->readRootId() == $a_node_id) {
             return false;
         }
     }
     // node owner has all rights
     if ($a_tree->lookupOwner($a_node_id) == $a_user_id) {
         return true;
     }
     // other users can only read
     if ($a_permission == "read" || $a_permission == "visible") {
         // get all objects with explicit permission
         $objects = $this->getPermissions($a_node_id);
         if ($objects) {
             // check if given user is member of object or has role
             foreach ($objects as $obj_id) {
                 switch ($obj_id) {
                     case ilWorkspaceAccessGUI::PERMISSION_ALL:
                         return true;
                     case ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD:
                         // check against input kept in session
                         if (self::getSharedNodePassword($a_node_id) == self::getSharedSessionPassword($a_node_id) || $a_permission == "visible") {
                             return true;
                         }
                         break;
                     case ilWorkspaceAccessGUI::PERMISSION_REGISTERED:
                         if ($ilUser->getId() != ANONYMOUS_USER_ID) {
                             return true;
                         }
                         break;
                     default:
                         switch (ilObject::_lookupType($obj_id)) {
                             case "grp":
                                 // member of group?
                                 if (ilGroupParticipants::_getInstanceByObjId($obj_id)->isAssigned($a_user_id)) {
                                     return true;
                                 }
                                 break;
                             case "crs":
                                 // member of course?
                                 if (ilCourseParticipants::_getInstanceByObjId($obj_id)->isAssigned($a_user_id)) {
                                     return true;
                                 }
                                 break;
                             case "role":
                                 // has role?
                                 if ($rbacreview->isAssigned($a_user_id, $obj_id)) {
                                     return true;
                                 }
                                 break;
                             case "usr":
                                 // direct assignment
                                 if ($a_user_id == $obj_id) {
                                     return true;
                                 }
                                 break;
                         }
                         break;
                 }
             }
         }
     }
     return false;
 }
開發者ID:Walid-Synakene,項目名稱:ilias,代碼行數:80,代碼來源:class.ilWorkspaceAccessHandler.php


注:本文中的ilTree::lookupOwner方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。