本文整理匯總了PHP中CUtils::getUserFromPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP CUtils::getUserFromPath方法的具體用法?PHP CUtils::getUserFromPath怎麽用?PHP CUtils::getUserFromPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CUtils
的用法示例。
在下文中一共展示了CUtils::getUserFromPath方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: invoke
/**
*
* 調用入口
* @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;
}
示例2: checkPrivilegeUser
/**
*
* 獲取一個用戶對一個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;
}
示例3: createPrivelegeEvent
/**
*
* 添加事件
*
* @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);
}
}