本文整理匯總了PHP中CUtils::arrayRemove方法的典型用法代碼示例。如果您正苦於以下問題:PHP CUtils::arrayRemove方法的具體用法?PHP CUtils::arrayRemove怎麽用?PHP CUtils::arrayRemove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CUtils
的用法示例。
在下文中一共展示了CUtils::arrayRemove方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handlerSetPermission
/**
*
* 列舉共享信息
*
* @since 1.1.0
*/
public function handlerSetPermission()
{
$this->_file = UserFile::model()->findByAttributes(array('id' => $this->_id, 'is_deleted' => 0));
if (is_null($this->_file)) {
throw new ApiException('Not Found');
}
//判斷此用戶是否有 分配 權限
$file_path = $this->_file["file_path"];
$hasPermissionAllot = Yii::app()->privilege->hasPermission($file_path, MPrivilege::PERMISSION_GRANT);
if (!$hasPermissionAllot) {
$this->result["msg"] = Yii::t('front_common', 'Can not grant permission');
throw new ApiException('Can not grant permission');
}
//
// 將逗號分割的id組裝成數組
//
if (!empty($this->_slaves)) {
$this->_slaves = array_slice(explode(',', $this->_slaves), 0);
} else {
$this->_slaves = array();
}
$this->_permissions = array_slice(explode(',', $this->_permissions), 0);
$tmpUser = $this->_slaves;
//查詢出此路徑下的直接權限的所有用戶
$privileges = MUserPrivilege::model()->findAll('file_path=:file_path', array(':file_path' => $this->_file["file_path"]));
$currentUser = MUserManager::getInstance()->getCurrentUser();
foreach ($privileges as $pri) {
//分配權限時如果權限表中的權限的所有者是自己, 則不進行處理
if ($pri["user_id"] == $currentUser["id"]) {
continue;
}
//如果此用戶不存在則進行添加權限,已經存在則進行修改權限,否則進行刪除權限操作
if (in_array($pri["user_id"], $tmpUser)) {
$newPermission = $this->getUserPermission($this->_slaves, $pri["user_id"]);
//進行是否事件生成判斷
$this->updatePrivelegeEvent($pri, $newPermission);
//更新權限
Yii::app()->privilege->updatedPrivilege($pri["user_id"], $this->_file["file_path"], $newPermission);
$tmpUser = CUtils::arrayRemove($tmpUser, $pri["user_id"]);
} else {
$pri->delete();
$this->deletePrivelegeEvent($pri["user_id"], $pri["file_path"], unserialize($pri["permission"]));
}
}
//創建權限
foreach ($tmpUser as $index => $userId) {
$permission = $this->getUserPermission($this->_slaves, $userId);
$this->createPrivelegeEvent($userId, $this->_file["file_path"], $permission);
Yii::app()->privilege->createPrivilege($userId, $this->_file["file_path"], $permission);
}
}