function __callStatic($name, $arguments) { switch ($name) { case 'OnBeforeIBlockElementAdd': $action = 'Add'; break; case 'OnBeforeIBlockElementDelete': $action = 'Delete'; break; case 'OnBeforeIBlockElementUpdate': $action = 'Edit'; break; default: return; break; } $arFields = $arguments[0]; if (!is_array($arFields)) { CModule::IncludeModule('iblock'); $res = CIBlockElement::GetByID($arFields); if ($ar_res = $res->GetNext()) { $arFields = $ar_res; } } switch ($arFields["IBLOCK_ID"]) { case PROJECTS_IBLOCK_ID: $enitity = 'Project'; break; case TASKS_IBLOCK_ID: $enitity = 'Task'; break; default: return; break; } $method = 'hasRigthsTo' . $action . $enitity; global $USER, $APPLICATION; if (method_exists($USER, $method)) { if (!$USER->{$method}($arFields)) { $APPLICATION->throwException("У вас недостаточно прав на эту операцию"); return false; } elseif ($action == 'Delete') { $log = new CrmLog(); $log->delete($arFields['ID']); } } }
public function getMyEvents($limit) { $limit = intval($limit); if (!$limit) { $limit = 20; } if (self::$cache) { return self::$cache; } $userId = CUser::GetID(); $query = "SELECT * FROM `crmlog` WHERE `TO_USER` = {$userId} ORDER BY VIEW ASC , ID DESC LIMIT {$limit} ;"; global $DB; $res = $DB->Query($query); $result = $this->collectEventsToArr($res, true); self::$cache = $result; return $result; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $log = new CrmLog(); $arParams['ID'] = intval($arParams['ID']); $arParams['USER_ID'] = intval($arParams['USER_ID']); if ($arParams['ID']) { $log->view($arParams['ID']); } if (!$arParams['USER_ID']) { $arResult['EVENTS'] = $log->getMyEvents(); $arResult['NEW'] = $log->getNewCnt(); } else { $arResult['EVENTS'] = $log->getUserEvents($arParams['USER_ID']); } foreach ($arResult['EVENTS'] as $event) { $items[] = $event["ITEM_ID"]; $users[] = $event['FROM_USER']; } $arResult['USERS'] = BitrixHelper::getUsersArrByIds($users); if (count($items)) { CModule::IncludeModule('iblock'); $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => TASKS_IBLOCK_ID, 'ID' => $items), false, false, array("ID", "IBLOCK_ID", "PROPERTY_PROJECT.DETAIL_PICTURE")); while ($task = $res->GetNext()) { if ($task["PROPERTY_PROJECT_DETAIL_PICTURE"]) { $arr[$task['ID']] = CFile::ResizeImageGet($task["PROPERTY_PROJECT_DETAIL_PICTURE"], array('width' => 45, 'height' => 45), BX_RESIZE_IMAGE_PROPORTIONAL_ALT, true); } } if (count($arr)) {
ShowError('Не передан обязательный параметр'); return; } } if (!$USER->hasRightsToViewTask($arParams["ID"])) { ShowError('У Вас нет прав на просмотр этой задачи'); return; } if (!$arParams['DATE_FORMAT']) { $arParams['DATE_FORMAT'] = 'j F в H:i'; } if (!$arParams['DATE_TIME_FORMAT']) { $arParams['DATE_TIME_FORMAT'] = 'j M в H:i:s'; } CModule::IncludeModule('iblock'); $logger = new CrmLog('task'); /* project */ $arSelect = array("ID", "IBLOCK_ID", "NAME", "DETAIL_PAGE_URL", "CREATED_BY", "DETAIL_PICTURE"); $arFilter = array("IBLOCK_ID" => PROJECTS_IBLOCK_ID, 'ID' => $arParams['PROJECT']); $userFilter = $USER->GetViewProjectsFilter(); $arFilter = array_merge($userFilter, $arFilter); $res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect); if ($ob = $res->GetNextElement()) { $arFields = $ob->GetFields(); $arProps = $ob->GetProperties(); if ($arFields['DETAIL_PICTURE']) { $arFields['DETAIL_PICTURE'] = CFile::ResizeImageGet($arFields['DETAIL_PICTURE'], array('width' => 60, 'height' => 50), BX_RESIZE_IMAGE_PROPORTIONAL_ALT, true); } $arResult['CUSTOMERS_IDS'] = $arProps['CUSTOMER']['VALUE'] ? $arProps['CUSTOMER']['VALUE'] : array(); $arResult['PROGRAMERS_IDS'] = $arProps['PROGRAMMER']['VALUE'] ? $arProps['PROGRAMMER']['VALUE'] : array(); $arResult['PROJECT'] = $arFields;
if ($arParams["PROJECT"] && !$USER->hasRightsToViewProject($arParams["PROJECT"])) { ShowError('У Вас нет прав на просмотр этого проекта'); return; } CPageOption::SetOptionString("main", "nav_page_in_session", "N"); if (!$arParams['DATE_FORMAT']) { $arParams['DATE_FORMAT'] = 'j F Y'; } if (!$arParams['DATE_TIME_FORMAT']) { $arParams['DATE_TIME_FORMAT'] = 'j M в H:i'; } if ($arParams["COUNT"] <= 0) { $arParams["COUNT"] = 30; } CModule::IncludeModule('iblock'); $logger = new CrmLog(); /* projects */ $arSelect = array("ID", "IBLOCK_ID", "NAME", "DETAIL_PAGE_URL", "PROPERTY_*", "DETAIL_PICTURE"); $arFilter = array("IBLOCK_ID" => PROJECTS_IBLOCK_ID); $userFilter = $USER->GetViewProjectsFilter(); $arFilter = array_merge($userFilter, $arFilter); $res = CIBlockElement::GetList(array(), $arFilter, false, array('nTopCount' => 500), $arSelect); while ($ob = $res->GetNextElement()) { $arFields = $ob->GetFields(); $arProps = $ob->GetProperties(); if ($arParams["PROJECT"] && $arParams["PROJECT"] == $arFields['ID']) { $arResult['CUSTOMERS_IDS'] = $arProps['CUSTOMER']['VALUE']; $arResult['PROGRAMERS_IDS'] = $arProps['PROGRAMMER']['VALUE']; } foreach (array('PROGRAMMER', 'CUSTOMER') as $propCode) { foreach ($arProps[$propCode]['VALUE'] as $userid) {
$name = trim($_REQUEST['name']); $description = trim($_REQUEST['description']); foreach ($_FILES['attach'] as $code => $values) { foreach ($values as $key => $value) { if ($_FILES['attach']["tmp_name"][$key]) { $arFiles[$key][$code] = $value; } } } $priority = validatePriority($_REQUEST['priority']); $programmer = $_REQUEST['PROGRAMMER']; $customer = $_REQUEST['CUSTOMER'] ? $_REQUEST['CUSTOMER'] : CUser::GetID(); $arProjectArray = array("PROPERTY_VALUES" => array('PROGRAMMER' => $programmer, 'PROJECT' => $arParams["PROJECT"], 'FILES' => $arFiles, 'PRIORITY' => $priority, 'CUSTOMER' => $customer), "MODIFIED_BY" => $USER->GetID(), "IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => TASKS_IBLOCK_ID, "NAME" => $name, "DETAIL_TEXT" => $description); if ($newTaskId = $el->Add($arProjectArray)) { ToolTip::Add('Задача "' . $name . '" добавлена'); $logger = new CrmLog('task'); $logger->add(array($programmer, $customer), $newTaskId, 'add', $description); LocalRedirect(TASKS_LIST_URL . $arParams["PROJECT"] . '/'); } else { $arResult['ERROR'] = $el->LAST_ERROR; } } $arSelect = array("ID", "IBLOCK_ID", "NAME", "DETAIL_PAGE_URL", "PROPERTY_*"); $arFilter = array("IBLOCK_ID" => PROJECTS_IBLOCK_ID, 'ID' => $arParams["PROJECT"]); $userFilter = $USER->GetViewProjectsFilter(); $arFilter = array_merge($userFilter, $arFilter); $res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect); if ($ob = $res->GetNextElement()) { $arFields = $ob->GetFields(); $arProps = $ob->GetProperties(); if ($arProps['PROGRAMMER']['VALUE']) {