本文整理匯總了PHP中CSocNetFeaturesPerms::currentUserCanPerformOperation方法的典型用法代碼示例。如果您正苦於以下問題:PHP CSocNetFeaturesPerms::currentUserCanPerformOperation方法的具體用法?PHP CSocNetFeaturesPerms::currentUserCanPerformOperation怎麽用?PHP CSocNetFeaturesPerms::currentUserCanPerformOperation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CSocNetFeaturesPerms
的用法示例。
在下文中一共展示了CSocNetFeaturesPerms::currentUserCanPerformOperation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: move
/**
*
* Moves the source task before/after the target task;
* @param array $data
* @return false|array
*/
public function move($data)
{
global $USER;
if (!$USER->isAuthorized()) {
$this->errors->add("AUTH_REQUIRED", Loc::getMessage("TASKS_SORTING_AUTH_REQUIRED"));
return false;
}
$sourceId = isset($data["sourceId"]) ? intval($data["sourceId"]) : 0;
$targetId = isset($data["targetId"]) ? intval($data["targetId"]) : 0;
$before = isset($data["before"]) && ($data["before"] === true || $data["before"] === "true") ? true : false;
$newGroupId = isset($data["newGroupId"]) ? intval($data["newGroupId"]) : null;
$newParentId = isset($data["newParentId"]) ? intval($data["newParentId"]) : null;
$currentGroupId = isset($data["currentGroupId"]) ? intval($data["currentGroupId"]) : 0;
$userId = $USER->getId();
if ($sourceId === $targetId || $sourceId < 1) {
return array();
}
$sourceTask = new \CTaskItem($sourceId, $userId);
if (!$sourceTask->checkCanRead()) {
$this->errors->add("SOURCE_TASK_NOT_FOUND", Loc::getMessage("TASKS_SORTING_WRONG_SOURCE_TASK"));
return false;
}
if ($currentGroupId) {
$group = \CSocNetGroup::getByID($currentGroupId);
$canEdit = \CSocNetFeaturesPerms::currentUserCanPerformOperation(SONET_ENTITY_GROUP, $currentGroupId, "tasks", "edit_tasks");
if (!$group || !$canEdit) {
$this->errors->add("GROUP_PERMS_NOT_FOUND", Loc::getMessage("TASKS_SORTING_WRONG_GROUP_PERMISSIONS"));
return false;
}
}
/*
GROUP_ID and PARENT_ID could be changed after drag&drop manipulations.
Target task is not required. Example: We want to move Task 1 after Project. In this case a target task is undefined.
Task 1
Project (without tasks)
*/
$newTaskData = array();
if ($newGroupId !== null) {
$newTaskData["GROUP_ID"] = $newGroupId;
}
if ($newParentId !== null) {
$newTaskData["PARENT_ID"] = $newParentId;
}
if (count($newTaskData)) {
$sourceTask->update($newTaskData);
}
//But it's required for sorting
if ($targetId < 1) {
return array();
}
$targetTask = new \CTaskItem($targetId, $userId);
if (!$targetTask->checkCanRead()) {
$this->errors->add("TARGET_TASK_NOT_FOUND", Loc::getMessage("TASKS_SORTING_WRONG_TARGET_TASK"));
return false;
}
SortingTable::setSorting($userId, $currentGroupId, $sourceId, $targetId, $before);
return array();
}