Exemple #1
0
 /**
  * 
  * 调用入口
  * @param unknown_type $action
  * 
  * @since 1.1.0
  */
 public function invoke($action)
 {
     if (!empty($this->file_id)) {
         $this->file = UserFile::model()->findByAttributes(array('id' => $this->file_id, 'is_deleted' => 0));
         if (!empty($this->file)) {
             $this->master = CUtils::getUserFromPath($this->file["file_path"]);
         }
     }
     switch ($action) {
         case self::ACTION_SEARCH:
             $retval = $this->handlerSeach();
             break;
         case self::ACTION_LIST_FRIENDS:
             $retval = $this->handlerList();
         default:
             break;
     }
     return $retval;
 }
Exemple #2
0
 /**
  *
  * 获取一个用户对一个path的权限
  * @param unknown_type $user_id
  * @param unknown_type $file_path
  *
  * @since 1.0.7
  */
 public function checkPrivilegeUser($user_id, $file_path)
 {
     $this->file_path = $file_path;
     //判断文件是否是属于自己的,如果是自己的则拥有所有权限
     $owner_user_id = CUtils::getUserFromPath($file_path);
     if ($owner_user_id == $user_id) {
         return $this->hasAllPermission();
     }
     //检测用户是否有权限
     $permission = $this->checkPrivilegeUserSelf($user_id, $file_path);
     if ($permission) {
         $this->permission = $permission;
         return $permission;
     }
     //添加hook为用户增加额外的文件的权限
     $curPrivileges = array("file_path" => $file_path, "permission" => $permission);
     $retPri = $curPrivileges;
     $permission = $retPri["permission"];
     if ($permission) {
         $this->permission = $permission;
         return $permission;
     }
     //如果检测不到用户的权限,则获取默认权限
     $permission = $this->getFilePrivilegeDefault($file_path);
     $this->permission = $permission;
     return $permission;
 }
 /**
  *
  * 添加事件
  *
  * @since 1.0.7
  */
 public function createPrivelegeEvent($user_id, $file_path, $permission)
 {
     //如果是自己则排除
     $own_user_id = CUtils::getUserFromPath($file_path);
     if ($own_user_id == $user_id) {
         return;
     }
     //默认的权限
     $defaultPermission = Yii::app()->privilege->getFilePrivilegeDefault($file_path);
     $file_path = '/' . $user_id . CUtils::removeUserFromPath($file_path);
     $content = $file_path;
     if ($permission[MPrivilege::RESOURCE_READ] && !$defaultPermission[MPrivilege::RESOURCE_READ]) {
         //当默认权限为不能读,现在变更为能读
         $this->createEvent($user_id, MConst::CAN_READ, $file_path, $content);
     } elseif (!$permission[MPrivilege::RESOURCE_READ] && $defaultPermission[MPrivilege::RESOURCE_READ]) {
         //当默认权限为能读  现在变更为不能读
         $this->createEvent($user_id, MConst::CAN_NOT_READ, $file_path, $content);
     }
 }