本文整理汇总了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();
}