本文整理汇总了PHP中CTask::GetOperations方法的典型用法代码示例。如果您正苦于以下问题:PHP CTask::GetOperations方法的具体用法?PHP CTask::GetOperations怎么用?PHP CTask::GetOperations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTask
的用法示例。
在下文中一共展示了CTask::GetOperations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetOperations
function GetOperations()
{
global $USER;
static $arOp;
static $arUsers;
$userGroups = $USER->GetUserGroupArray();
$key = implode('-', $userGroups);
if (!is_array($arOp)) {
$arOp = array();
}
if (!is_array($arOp[$key])) {
$res = CSticker::GetAccessPermissions();
$arOp[$key] = array();
$bDefaultTask = false;
$count = 0;
foreach ($res as $group_id => $task_id) {
if (in_array($group_id, $userGroups)) {
$arOp[$key] = array_merge($arOp[$key], CTask::GetOperations($task_id, true));
$count++;
}
}
if ($count < count($userGroups)) {
$defaultAccess = COption::GetOptionString('fileman', 'stickers_default_access', false);
if ($defaultAccess !== false) {
$arOp[$key] = array_merge($arOp[$key], CTask::GetOperations($defaultAccess, true));
}
}
}
return $arOp[$key];
}
示例2: GetOperations
public static function GetOperations($collectionId, $menu = false)
{
global $USER;
static $oCollections;
static $arOp;
$userGroups = $USER->GetUserGroupArray();
$key = $collectionId . '|' . implode('-', $userGroups);
if (!is_array($arOp[$key])) {
if (!is_array($arOp)) {
$arOp = array();
}
if (!is_array($oCollections)) {
$res = CMedialib::GetCollectionTree(array('menu' => $menu));
$oCollections = $res['Collections'];
}
$userGroups = $USER->GetUserGroupArray();
$res = CMedialib::GetAccessPermissionsArray($collectionId, $oCollections);
$arOp[$key] = array();
foreach ($res as $group_id => $task_id) {
if (in_array($group_id, $userGroups)) {
$arOp[$key] = array_merge($arOp[$key], CTask::GetOperations($task_id, true));
}
}
}
return $arOp[$key];
}
示例3: CanUserOperateDocumentType
function CanUserOperateDocumentType($operation, $userId, $documentType, $arParameters = array())
{
$documentType = trim($documentType);
if (strlen($documentType) <= 0) {
return false;
}
$arParameters["IBlockId"] = intval(substr($documentType, strlen("iblock_")));
if (!array_key_exists("IBlockRightsMode", $arParameters)) {
$arParameters["IBlockRightsMode"] = CIBlock::GetArrayByID($arParameters["IBlockId"], "RIGHTS_MODE");
}
if ($arParameters["IBlockRightsMode"] === "E") {
if ($operation === CBPCanUserOperateOperation::CreateWorkflow) {
return CIBlockRights::UserHasRightTo($arParameters["IBlockId"], $arParameters["IBlockId"], "iblock_rights_edit");
} elseif ($operation === CBPCanUserOperateOperation::WriteDocument) {
return CIBlockRights::UserHasRightTo($arParameters["IBlockId"], $arParameters["IBlockId"], "section_element_bind");
} elseif ($operation === CBPCanUserOperateOperation::ViewWorkflow || $operation === CBPCanUserOperateOperation::StartWorkflow) {
if (!array_key_exists("WorkflowId", $arParameters)) {
return false;
}
if ($operation === CBPCanUserOperateOperation::ViewWorkflow && !CIBlockRights::UserHasRightTo($arParameters["IBlockId"], $arParameters["IBlockId"], "element_read")) {
return false;
}
if ($operation === CBPCanUserOperateOperation::StartWorkflow && !CIBlockRights::UserHasRightTo($arParameters["IBlockId"], $arParameters["IBlockId"], "section_element_bind")) {
return false;
}
$userId = intval($userId);
if (!array_key_exists("AllUserGroups", $arParameters)) {
if (!array_key_exists("UserGroups", $arParameters)) {
$arParameters["UserGroups"] = CUser::GetUserGroup($userId);
}
$arParameters["AllUserGroups"] = $arParameters["UserGroups"];
$arParameters["AllUserGroups"][] = "Author";
}
if (!array_key_exists("DocumentStates", $arParameters)) {
if ($operation === CBPCanUserOperateOperation::StartWorkflow) {
$arParameters["DocumentStates"] = CBPWorkflowTemplateLoader::GetDocumentTypeStates(array("iblock", "CIBlockDocument", "iblock_" . $arParameters["IBlockId"]));
} else {
$arParameters["DocumentStates"] = CBPDocument::GetDocumentStates(array("iblock", "CIBlockDocument", "iblock_" . $arParameters["IBlockId"]), null);
}
}
if (array_key_exists($arParameters["WorkflowId"], $arParameters["DocumentStates"])) {
$arParameters["DocumentStates"] = array($arParameters["WorkflowId"] => $arParameters["DocumentStates"][$arParameters["WorkflowId"]]);
} else {
return false;
}
$arAllowableOperations = CBPDocument::GetAllowableOperations($userId, $arParameters["AllUserGroups"], $arParameters["DocumentStates"]);
if (!is_array($arAllowableOperations)) {
return false;
}
if ($operation === CBPCanUserOperateOperation::ViewWorkflow && in_array("read", $arAllowableOperations) || $operation === CBPCanUserOperateOperation::StartWorkflow && in_array("write", $arAllowableOperations)) {
return true;
}
$chop = $operation === CBPCanUserOperateOperation::ViewWorkflow ? "element_read" : "section_element_bind";
foreach ($arAllowableOperations as $op) {
$ar = CTask::GetOperations($op, true);
if (in_array($chop, $ar)) {
return true;
}
}
}
return false;
}
if (!array_key_exists("IBlockPermission", $arParameters)) {
if (CModule::IncludeModule('lists')) {
$arParameters["IBlockPermission"] = CLists::GetIBlockPermission($arParameters["IBlockId"], $userId);
} else {
$arParameters["IBlockPermission"] = CIBlock::GetPermission($arParameters["IBlockId"], $userId);
}
}
if ($arParameters["IBlockPermission"] <= "R") {
return false;
} elseif ($arParameters["IBlockPermission"] >= "W") {
return true;
}
$userId = intval($userId);
if (!array_key_exists("AllUserGroups", $arParameters)) {
if (!array_key_exists("UserGroups", $arParameters)) {
$arParameters["UserGroups"] = CUser::GetUserGroup($userId);
}
$arParameters["AllUserGroups"] = $arParameters["UserGroups"];
$arParameters["AllUserGroups"][] = "Author";
}
if (!array_key_exists("DocumentStates", $arParameters)) {
$arParameters["DocumentStates"] = CBPDocument::GetDocumentStates(array("iblock", "CIBlockDocument", "iblock_" . $arParameters["IBlockId"]), null);
}
if (array_key_exists("WorkflowId", $arParameters)) {
if (array_key_exists($arParameters["WorkflowId"], $arParameters["DocumentStates"])) {
$arParameters["DocumentStates"] = array($arParameters["WorkflowId"] => $arParameters["DocumentStates"][$arParameters["WorkflowId"]]);
} else {
return false;
}
}
$arAllowableOperations = CBPDocument::GetAllowableOperations($userId, $arParameters["AllUserGroups"], $arParameters["DocumentStates"]);
if (!is_array($arAllowableOperations)) {
return false;
}
$r = false;
switch ($operation) {
case CBPCanUserOperateOperation::ViewWorkflow:
$r = in_array("read", $arAllowableOperations);
//.........这里部分代码省略.........
示例4:
</tr>
<?php
$tabControl->BeginNextTab();
?>
<tr>
<td colspan="2" align="center">
<table border="0" cellpadding="5" cellspacing="0" align="center">
<tr>
<td width="10%" align="center"> </td>
<td width="90%"> </td>
</tr>
<?php
if (isset($_POST['OPERATION_ID'])) {
$arTaskOperations = $_POST['OPERATION_ID'];
} else {
$arTaskOperations = CTask::GetOperations($ID);
}
$ind = -1;
foreach ($arOperations as $name => $arOperation) {
$ind++;
?>
<tr id="operation_row_<?php
echo $ind;
?>
"
<?php
echo $arOperation["MODULE_ID"] != $str_MODULE_ID || $arOperation["BINDING"] != $str_BINDING ? 'style="display: none"' : '';
?>
>
<td align="right" style="padding: 0 10px 0 10px">
<input type="checkbox" name="OPERATION_ID[]" id="OPERATION_ID_<?php
示例5: SelectBoxFromArray
</b></td>
<td width="50%">
<script>var arSubordTasks = [];</script>
<?
$arTasksInModule = CTask::GetTasksInModules(true,$module_id,'module');
$nID = COperation::GetIDByName('edit_subordinate_users');
$arTasks = $arTasksInModule['main'];
echo SelectBoxFromArray("GROUP_DEFAULT_TASK", $arTasks, htmlspecialcharsbx($GROUP_DEFAULT_TASK));
$show_subord = false;
$arTaskIds = $arTasks['reference_id'];
$arSubordTasks = Array();
$l = count($arTaskIds);
for ($i=0;$i<$l;$i++)
{
$arOpInTask = CTask::GetOperations($arTaskIds[$i]);
if (in_array($nID,$arOpInTask))
{
$arSubordTasks[] = $arTaskIds[$i];
?><script>
arSubordTasks.push(<?php
echo $arTaskIds[$i];
?>
);
</script><?
}
}
?>
<script>
var taskSelectOnchange = function(select)
示例6: GetFileOperations
function GetFileOperations($arPath, $arGroups = false)
{
global $APPLICATION;
$ar = $APPLICATION->GetFileAccessPermission($arPath, $arGroups, true);
$arFileOperations = array();
for ($i = 0, $len = count($ar); $i < $len; $i++) {
$arFileOperations = array_merge($arFileOperations, CTask::GetOperations($ar[$i], true));
}
$arFileOperations = array_values(array_unique($arFileOperations));
return $arFileOperations;
}
示例7: foreach
} else {
//2) protect groups with iblock_% operations
$arOperations = CTask::GetOperations($arRight['TASK_ID'], true);
foreach ($arOperations as $operation) {
if (preg_match("/^iblock_(?!admin)/", $operation)) {
unset($arResult["RIGHTS"][$RIGHT_ID]);
$arResult["SELECTED"][$arRight["GROUP_CODE"]] = true;
break;
}
}
}
}
$arResult["TASKS"] = CIBlockRights::GetRightsList();
foreach ($arResult["TASKS"] as $TASK_ID => $label) {
//2) protect tasks with iblock_% operations
$arOperations = CTask::GetOperations($TASK_ID, true);
foreach ($arOperations as $operation) {
if (preg_match("/^iblock_(?!admin)/", $operation)) {
unset($arResult["TASKS"][$TASK_ID]);
break;
}
}
}
}
$arResult["VARS_FROM_FORM"] = $bVarsFromForm;
$arResult["FORM_DATA"] = array();
foreach ($data as $key => $value) {
$arResult["FORM_DATA"]["~" . $key] = $value;
if (is_array($value)) {
foreach ($value as $key1 => $value1) {
if (is_array($value1)) {
示例8: GeneratePHPInstall
public static function GeneratePHPInstall($arValues)
{
$str = '';
$arDefValues = $arValues["default"]["options"];
$arInfo = CControllerGroupSettings::GetData();
if(isset($arValues["default"]["modules"]))
{
$vArr = '';
foreach($arInfo as $module_id=>$arProp)
{
if($module_id == 'main')
continue;
if(in_array($module_id, $arValues["default"]["modules"]))
$vArr .= '"'.$module_id.'"=>"Y", ';
else
$vArr .= '"'.$module_id.'"=>"N", ';
}
$str .= 'CControllerClient::SetModules(Array('.$vArr.'));'."\r\n";
}
else
$str .= 'CControllerClient::RestoreModules();'."\r\n";
foreach($arInfo as $mname=>$arProp)
{
if(!is_array($arProp["options"]) || count($arProp["options"])<=0)
continue;
$arOptions = $arProp["options"];
foreach($arOptions as $id=>$arOptionParams)
{
if(isset($arDefValues[$mname][$id]))
$str .= 'CControllerClient::SetOptionString("'.EscapePHPString($mname).'", "'.EscapePHPString($id).'", "'.EscapePHPString($arDefValues[$mname][$id]).'");'."\r\n";
elseif(substr($id, 0, 2)!='__')
$str .= 'CControllerClient::RestoreOption("'.EscapePHPString($mname).'", "'.EscapePHPString($id).'");'."\r\n";
}
}
$arSecurity = $arValues["default"]["security"];
if($arSecurity["limit_admin"] == "Y")
$str .= 'CControllerClient::SetOptionString("main", "~controller_limited_admin", "Y");'."\r\n";
else
$str .= 'CControllerClient::SetOptionString("main", "~controller_limited_admin", "N");'."\r\n";
$subordinate_id = COperation::GetIDByName('edit_subordinate_users');
$arGroups = Array();
$arUniqTasks = Array();
if(is_array($arSecurity["groups"]))
{
foreach($arSecurity["groups"] as $group_id=>$arPermissions)
{
$arDefinedPermissions = Array();
$arUnDefinedPermissions = Array();
$bSubOrdGroups = false;
foreach($arInfo as $module_id=>$arProp)
{
if(isset($arPermissions[$module_id]))
{
$arDefinedPermissions[$module_id] = $arPermissions[$module_id];
$task_id = $arPermissions[$module_id];
if(strlen($task_id)>1 && (!is_array($arUniqTasks[$module_id]) || !in_array($task_id, $arUniqTasks[$module_id])))
{
$arUniqTasks[$module_id][] = $task_id;
$dbr_task = CTask::GetList(Array(), Array('NAME'=>$task_id, 'MODULE_ID'=>$module_id, "BINDING" => 'module'));
if($ar_task = $dbr_task->Fetch())
{
if($module_id == 'main' || $ar_task['SYS']!='Y')
{
$arOperations = CTask::GetOperations($ar_task["ID"], true);
if($ar_task['SYS']!='Y')
{
$str .= 'CControllerClient::SetTaskSecurity('.CControllerGroupSettings::__PHPToString($task_id).', '.CControllerGroupSettings::__PHPToString($module_id).', '.CControllerGroupSettings::__PHPToString($arOperations).', '.CControllerGroupSettings::__PHPToString($ar_task["LETTER"]).');'."\r\n";
}
if($module_id == 'main' && in_array('edit_subordinate_users', $arOperations))
{
$bSubOrdGroups = true;
}
}
}
}
}
else
$arUnDefinedPermissions[] = $module_id;
}
$str .= 'CControllerClient::RestoreGroupSecurity('.CControllerGroupSettings::__PHPToString($group_id).', '.CControllerGroupSettings::__PHPToString($arUnDefinedPermissions).');'."\r\n";
if($bSubOrdGroups)
{
$arSGroupsTmp = preg_split("/[\r\n,;]+/", $arSecurity["subord_groups"][$group_id]);
$arSGroups = array();
foreach($arSGroupsTmp as $sGroupTmp)
{
$sGroupTmp = trim($sGroupTmp);
if ($sGroupTmp != '')
//.........这里部分代码省略.........
示例9: GetOperations
public static function GetOperations($sectId, $userId = false)
{
global $USER;
if (!$userId) {
$userId = intVal($USER->GetId());
}
$arCodes = array();
$rCodes = CAccess::GetUserCodes($userId);
while ($code = $rCodes->Fetch()) {
$arCodes[] = $code['ACCESS_CODE'];
}
if (!in_array('G2', $arCodes)) {
$arCodes[] = 'G2';
}
$key = $sectId . '|' . implode(',', $arCodes);
if (self::$bClearOperationCache || !is_array(self::$arOp[$key])) {
if (!isset(self::$Permissions[$sectId])) {
self::GetArrayPermissions(array($sectId));
}
$perms = self::$Permissions[$sectId];
self::$arOp[$key] = array();
if (is_array($perms)) {
foreach ($perms as $code => $taskId) {
if (in_array($code, $arCodes)) {
self::$arOp[$key] = array_merge(self::$arOp[$key], CTask::GetOperations($taskId, true));
}
}
}
}
return self::$arOp[$key];
}
示例10: MergeRights
public static function MergeRights($IBLOCK_TYPE_ID, $DB, $POST)
{
$arResult = array();
//1) Put into result protected from changes rights
$arListsPerm = CLists::GetPermission($IBLOCK_TYPE_ID);
foreach ($DB as $RIGHT_ID => $arRight) {
//1) protect groups from module settings
if (preg_match("/^G(\\d)\$/", $arRight["GROUP_CODE"], $match) && is_array($arListsPerm) && in_array($match[1], $arListsPerm)) {
$arResult[$RIGHT_ID] = $arRight;
} else {
//2) protect groups with iblock_% operations
$arOperations = CTask::GetOperations($arRight['TASK_ID'], true);
foreach ($arOperations as $operation) {
if (preg_match("/^iblock_(?!admin)/", $operation)) {
$arResult[$RIGHT_ID] = $arRight;
break;
}
}
}
}
//2) Leave in POST only safe rights
foreach ($POST as $RIGHT_ID => $arRight) {
//1) protect groups from module settings
if (preg_match("/^G(\\d)\$/", $arRight["GROUP_CODE"], $match) && is_array($arListsPerm) && in_array($match[1], $arListsPerm)) {
unset($POST[$RIGHT_ID]);
} else {
//2) protect groups with iblock_% operations
$arOperations = CTask::GetOperations($arRight['TASK_ID'], true);
foreach ($arOperations as $operation) {
if (preg_match("/^iblock_(?!admin)/", $operation)) {
unset($POST[$RIGHT_ID]);
break;
}
}
}
}
//3) Join POST to result
foreach ($POST as $RIGHT_ID => $arRight) {
foreach ($arResult as $RIGHT_ID2 => $arRight2) {
if ($arRight["GROUP_CODE"] == $arRight2["GROUP_CODE"]) {
unset($arResult[$RIGHT_ID2]);
}
}
$arResult[$RIGHT_ID] = $arRight;
}
return $arResult;
}
示例11: _update
public static function _update($RIGHT_ID, $GROUP_CODE, $bInherit, $TASK_ID)
{
global $DB;
$RIGHT_ID = intval($RIGHT_ID);
$arOperations = CTask::GetOperations($TASK_ID, /*$return_names=*/true);
$strUpdate = $DB->PrepareUpdate("b_iblock_right", array(
//"GROUP_CODE" => $GROUP_CODE,
"DO_INHERIT" => $bInherit? "Y": "N",
"TASK_ID" => $TASK_ID,
"OP_SREAD" => in_array("section_read", $arOperations)? "Y": "N",
"OP_EREAD" => in_array("element_read", $arOperations)? "Y": "N",
));
$DB->Query("UPDATE b_iblock_right SET ".$strUpdate." WHERE ID = ".$RIGHT_ID);
}
示例12: GetReaders
static function GetReaders($ID, $iblockID = null)
{
static $arValidTasks = null;
static $readersCache = array();
$arReaders = array();
$ID = (int) $ID;
if ($ID <= 0) {
return $arReaders;
}
if (isset($readersCache[$ID])) {
return $readersCache[$ID];
}
if ($arValidTasks == null) {
$arTasks = CWebDavIblock::GetTasks();
$arValidTasks = array();
foreach ($arTasks as $taskLetter => $taskID) {
$arOperations = CTask::GetOperations($taskID, true);
if (array_search('element_read', $arOperations) !== false) {
$arValidTasks[$taskID] = true;
}
}
}
if ($iblockID === null) {
$rElement = CIBlockElement::GetList(array(), array('ID' => $ID, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'));
if ($rElement && ($arElement = $rElement->Fetch())) {
$iblockID = $arElement['IBLOCK_ID'];
}
}
$iblockID = (int) $iblockID;
if ($iblockID <= 0) {
return $arReaders;
}
$bSocNet = CModule::IncludeModule('socialnetwork');
if (CIBlock::GetArrayByID($iblockID, "RIGHTS_MODE") === "E") {
$ibRights = new CIBlockElementRights($iblockID, $ID);
$arRights = $ibRights->GetRights();
foreach ($arRights as $rightID => $arRight) {
if (isset($arValidTasks[$arRight['TASK_ID']])) {
$arReaders[] = $arRight['GROUP_CODE'];
if ($bSocNet && preg_match('/^SG(\\d+)_[' . SONET_ROLES_OWNER . SONET_ROLES_MODERATOR . SONET_ROLES_USER . ']$/', $arRight['GROUP_CODE'], $matches)) {
$arReaders[] = "SG" . $matches[1];
}
}
}
} else {
$gr_res = CIBlock::GetGroupPermissions($iblockID);
foreach ($gr_res as $group_id => $perm) {
if ($perm >= 'R') {
$arReaders[] = 'G' . $group_id;
}
}
}
$readersCache[$ID] = array_unique($arReaders);
return $readersCache[$ID];
}
示例13: GetOperations
public static function GetOperations($xmlId, $userId = false)
{
if ($userId === false) {
$userId = CCalendar::GetCurUserId();
}
$arCodes = array();
$rCodes = CAccess::GetUserCodes($userId);
while ($code = $rCodes->Fetch()) {
$arCodes[] = $code['ACCESS_CODE'];
}
if (!in_array('G2', $arCodes)) {
$arCodes[] = 'G2';
}
$key = $xmlId . '|' . implode(',', $arCodes);
if (!is_array(self::$arOp[$key])) {
if (!isset(self::$Permissions[$xmlId])) {
self::GetArrayPermissions(array($xmlId));
}
$perms = self::$Permissions[$xmlId];
self::$arOp[$key] = array();
if (is_array($perms)) {
foreach ($perms as $code => $taskId) {
if (in_array($code, $arCodes)) {
self::$arOp[$key] = array_merge(self::$arOp[$key], CTask::GetOperations($taskId, true));
}
}
}
}
return self::$arOp[$key];
}
示例14: IncludeModuleLangFile
}
IncludeModuleLangFile(__FILE__);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/controller/include.php";
$err_mess = "File: " . __FILE__ . "<br>Line: ";
$arThirdSettings = CControllerGroupSettings::Get3rdPartyOptions();
$subordinate_id = COperation::GetIDByName('edit_subordinate_users');
$arMainSubordinateTask = array();
$db_task = CTask::GetList(array("MODULE_ID" => "asc", "LETTER" => "asc"), array("BINDING" => 'module'));
while ($ar_task = $db_task->GetNext()) {
if (!isset($arTasksModules[$ar_task['MODULE_ID']])) {
$arTasksModules[$ar_task['MODULE_ID']] = array("reference" => array(), "reference_id" => array());
}
$arTasksModules[$ar_task['MODULE_ID']]["reference"][] = '[' . ($ar_task['LETTER'] ? $ar_task['LETTER'] : '..') . '] ' . CTask::GetLangTitle($ar_task['NAME']);
$arTasksModules[$ar_task['MODULE_ID']]["reference_id"][] = $ar_task['NAME'];
if ($ar_task['MODULE_ID'] == 'main') {
$arOpInTask = CTask::GetOperations($ar_task['ID']);
if (in_array($subordinate_id, $arOpInTask)) {
$arMainSubordinateTask[] = $ar_task['NAME'];
}
}
}
if ($REQUEST_METHOD == "POST" && $COUNTER_UPDATE_PERIOD_TYPE != '' && (strlen($save) > 0 || strlen($apply) > 0) && $MOD_RIGHT >= "W") {
if ($COUNTER_UPDATE_PERIOD_TYPE == 'H') {
$COUNTER_UPDATE_PERIOD = $COUNTER_UPDATE_PERIOD * 60;
} elseif ($COUNTER_UPDATE_PERIOD_TYPE == 'D') {
$COUNTER_UPDATE_PERIOD = $COUNTER_UPDATE_PERIOD * 60 * 24;
} elseif ($COUNTER_UPDATE_PERIOD_TYPE == 'W') {
$COUNTER_UPDATE_PERIOD = $COUNTER_UPDATE_PERIOD * 60 * 24 * 7;
} elseif ($COUNTER_UPDATE_PERIOD_TYPE == 'N') {
$COUNTER_UPDATE_PERIOD = $COUNTER_UPDATE_PERIOD * 60 * 24 * 30;
}
示例15: SetMove
public static function SetMove($DOCUMENT_ID, $STATUS_ID, $OLD_STATUS_ID, $LOG_ID)
{
$err_mess = CAllWorkflow::err_mess() . "<br>Function: SetMove<br>Line: ";
global $DB, $USER, $APPLICATION;
$DOCUMENT_ID = intval($DOCUMENT_ID);
$STATUS_ID = intval($STATUS_ID);
$OLD_STATUS_ID = intval($OLD_STATUS_ID);
$LOG_ID = intval($LOG_ID);
$arFields = array("TIMESTAMP_X" => $DB->GetNowFunction(), "DOCUMENT_ID" => $DOCUMENT_ID, "OLD_STATUS_ID" => $OLD_STATUS_ID, "STATUS_ID" => $STATUS_ID, "LOG_ID" => $LOG_ID, "USER_ID" => intval($USER->GetID()));
$DB->Insert("b_workflow_move", $arFields, $err_mess . __LINE__);
if ($STATUS_ID != $OLD_STATUS_ID) {
CTimeZone::Disable();
$d = CWorkflow::GetByID($DOCUMENT_ID);
CTimeZone::Enable();
if ($dr = $d->Fetch()) {
$STATUS_ID = $dr["STATUS_ID"];
// document creator
$ENTERED_BY_USER_ID = $dr["ENTERED_BY"];
// gather email of the workflow admins
$WORKFLOW_ADMIN_GROUP_ID = COption::GetOptionInt("workflow", "WORKFLOW_ADMIN_GROUP_ID", 0);
$strSql = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tU.ID,\n\t\t\t\t\t\tU.EMAIL\n\t\t\t\t\tFROM\n\t\t\t\t\t\tb_user U,\n\t\t\t\t\t\tb_user_group UG\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tUG.GROUP_ID = {$WORKFLOW_ADMIN_GROUP_ID}\n\t\t\t\t\t\tand U.ID = UG.USER_ID\n\t\t\t\t\t\tand U.ACTIVE = 'Y'\n\t\t\t\t";
$a = $DB->Query($strSql, false, $err_mess . __LINE__);
$arAdmin = array();
while ($ar = $a->Fetch()) {
$arAdmin[$ar["ID"]] = $ar["EMAIL"];
}
// gather email for BCC
$arBCC = array();
// gather all who changed doc in its current status
$strSql = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tUSER_ID\n\t\t\t\t\tFROM\n\t\t\t\t\t\tb_workflow_move\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tDOCUMENT_ID = {$DOCUMENT_ID}\n\t\t\t\t\t\tand OLD_STATUS_ID = {$STATUS_ID}\n\t\t\t\t";
$z = $DB->Query($strSql, false, $err_mess . __LINE__);
while ($zr = $z->Fetch()) {
$arBCC[$zr["EMAIL"]] = $zr["EMAIL"];
}
// gather all editors
// in case status have notifier flag
$strSql = "\n\t\t\t\t\tSELECT DISTINCT\n\t\t\t\t\t\tUG.USER_ID\n\t\t\t\t\t\t,U.EMAIL\n\t\t\t\t\tFROM\n\t\t\t\t\t\tb_workflow_status S,\n\t\t\t\t\t\tb_workflow_status2group SG,\n\t\t\t\t\t\tb_user U,\n\t\t\t\t\t\tb_user_group UG\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tS.ID = {$STATUS_ID}\n\t\t\t\t\t\tand S.NOTIFY = 'Y'\n\t\t\t\t\t\tand SG.STATUS_ID = S.ID\n\t\t\t\t\t\tand SG.PERMISSION_TYPE = '2'\n\t\t\t\t\t\tand UG.GROUP_ID = SG.GROUP_ID\n\t\t\t\t\t\tand U.ID = UG.USER_ID\n\t\t\t\t\t\tand U.ACTIVE = 'Y'\n\t\t\t\t";
$z = $DB->Query($strSql, false, $err_mess . __LINE__);
while ($zr = $z->Fetch()) {
if (!array_key_exists($zr["EMAIL"], $arBCC)) {
$grp = array();
$rs = $USER->GetUserGroupList($zr["USER_ID"]);
while ($ar = $rs->Fetch()) {
$grp[] = $ar["GROUP_ID"];
}
$arTasks = $APPLICATION->GetFileAccessPermission($dr["FILENAME"], $grp, true);
foreach ($arTasks as $task_id) {
$arOps = CTask::GetOperations($task_id, true);
if (in_array("fm_edit_in_workflow", $arOps)) {
$arBCC[$zr["EMAIL"]] = $zr["EMAIL"];
break;
}
}
}
}
unset($arBCC[$dr["EUSER_EMAIL"]]);
if (array_key_exists($dr["ENTERED_BY"], $arAdmin)) {
$dr["EUSER_NAME"] .= " (Admin)";
}
// it is not new doc
if ($OLD_STATUS_ID > 0) {
if (array_key_exists($dr["MODIFIED_BY"], $arAdmin)) {
$dr["MUSER_NAME"] .= " (Admin)";
}
$q = CWorkflowStatus::GetByID($OLD_STATUS_ID);
$qr = $q->Fetch();
// send change notification
$arEventFields = array("ID" => $dr["ID"], "ADMIN_EMAIL" => implode(",", $arAdmin), "BCC" => implode(",", $arBCC), "PREV_STATUS_ID" => $OLD_STATUS_ID, "PREV_STATUS_TITLE" => $qr["TITLE"], "STATUS_ID" => $dr["STATUS_ID"], "STATUS_TITLE" => $dr["STATUS_TITLE"], "DATE_ENTER" => $dr["DATE_ENTER"], "ENTERED_BY_ID" => $dr["ENTERED_BY"], "ENTERED_BY_NAME" => $dr["EUSER_NAME"], "ENTERED_BY_EMAIL" => $dr["EUSER_EMAIL"], "DATE_MODIFY" => $dr["DATE_MODIFY"], "MODIFIED_BY_ID" => $dr["MODIFIED_BY"], "MODIFIED_BY_NAME" => $dr["MUSER_NAME"], "FILENAME" => $dr["FILENAME"], "SITE_ID" => $dr["SITE_ID"], "TITLE" => $dr["TITLE"], "BODY_HTML" => $dr["BODY_TYPE"] == "html" ? $dr["BODY"] : TxtToHtml($dr["BODY"]), "BODY_TEXT" => $dr["BODY_TYPE"] == "text" ? $dr["BODY"] : HtmlToTxt($dr["BODY"]), "BODY" => $dr["BODY"], "BODY_TYPE" => $dr["BODY_TYPE"], "COMMENTS" => $dr["COMMENTS"]);
CEvent::Send("WF_STATUS_CHANGE", $dr["SITE_ID"], $arEventFields);
} else {
// it was new one
$arEventFields = array("ID" => $dr["ID"], "ADMIN_EMAIL" => implode(",", $arAdmin), "BCC" => implode(",", $arBCC), "STATUS_ID" => $dr["STATUS_ID"], "STATUS_TITLE" => $dr["STATUS_TITLE"], "DATE_ENTER" => $dr["DATE_ENTER"], "ENTERED_BY_ID" => $dr["ENTERED_BY"], "ENTERED_BY_NAME" => $dr["EUSER_NAME"], "ENTERED_BY_EMAIL" => $dr["EUSER_EMAIL"], "FILENAME" => $dr["FILENAME"], "SITE_ID" => $dr["SITE_ID"], "TITLE" => $dr["TITLE"], "BODY_HTML" => $dr["BODY_TYPE"] == "html" ? $dr["BODY"] : TxtToHtml($dr["BODY"]), "BODY_TEXT" => $dr["BODY_TYPE"] == "text" ? $dr["BODY"] : HtmlToTxt($dr["BODY"]), "BODY" => $dr["BODY"], "BODY_TYPE" => $dr["BODY_TYPE"], "COMMENTS" => $dr["COMMENTS"]);
CEvent::Send("WF_NEW_DOCUMENT", $dr["SITE_ID"], $arEventFields);
}
}
}
}