示例#1
0
 public function executeComponent()
 {
     if (!empty($this->arParams['ERROR'])) {
         ShowError(array_shift($this->arParams['ERROR']));
         return;
     }
     $this->arResult['USER_ID'] = $this->arParams['USER_ID'];
     $this->arResult['GRID_ID'] = 'lists_processes';
     $selectFields = array('ID', 'IBLOCK_TYPE_ID', 'IBLOCK_ID', 'NAME');
     $gridOptions = new CGridOptions($this->arResult['GRID_ID']);
     $gridColumns = $gridOptions->getVisibleColumns();
     $gridSort = $gridOptions->getSorting(array('sort' => array('ID' => 'desc')));
     $this->arResult['HEADERS'] = array(array("id" => "ID", "name" => "ID", "default" => false, "sort" => "ID"), array('id' => 'DOCUMENT_NAME', 'name' => Loc::getMessage('CC_BLL_DOCUMENT_NAME'), 'default' => true, 'sort' => 'DOCUMENT_NAME'), array('id' => 'COMMENTS', 'name' => Loc::getMessage('CC_BLL_COMMENTS'), 'default' => true, 'sort' => '', 'hideName' => true, 'iconCls' => 'bp-comments-icon'), array('id' => 'WORKFLOW_PROGRESS', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_PROGRESS'), 'default' => true, 'sort' => ''), array('id' => 'WORKFLOW_STATE', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_STATE'), 'default' => false, 'sort' => ''));
     $this->arResult['FILTER'] = array(array("id" => "NAME", "name" => GetMessage("BPATL_NAME"), "type" => "string"), array('id' => 'TIMESTAMP_X', 'name' => Loc::getMessage('CC_BLL_MODIFIED'), 'type' => 'date'), array('id' => 'DATE_CREATE', 'name' => Loc::getMessage('CC_BLL_CREATED'), 'type' => 'date', 'default' => true));
     $gridFilter = $gridOptions->getFilter($this->arResult['FILTER']);
     foreach ($gridFilter as $key => $value) {
         if (substr($key, -5) == "_from") {
             $op = ">=";
             $newKey = substr($key, 0, -5);
         } elseif (substr($key, -3) == "_to") {
             $op = "<=";
             $newKey = substr($key, 0, -3);
             if (in_array($newKey, array("TIMESTAMP_X", 'DATE_CREATE'))) {
                 if (!preg_match("/\\d\\d:\\d\\d:\\d\\d\$/", $value)) {
                     $value .= " 23:59:59";
                 }
             }
         } else {
             $op = "";
             $newKey = $key;
         }
         $filter[$op . $newKey] = $value;
     }
     $this->arResult['SORT'] = $gridSort['sort'];
     $useComments = (bool) CModule::includeModule("forum");
     $workflows = array();
     $this->arResult['DATA'] = array();
     $this->arResult["COMMENTS_COUNT"] = array();
     $filter['CREATED_BY'] = $this->arParams['USER_ID'];
     $iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id");
     $filter['IBLOCK_TYPE'] = $iblockTypeId;
     $filter['CHECK_PERMISSIONS'] = $this->arParams['LIST_PERM'] >= CListPermissions::CAN_READ ? "N" : "Y";
     $elementObject = CIBlockElement::getList($gridSort['sort'], $filter, false, $gridOptions->getNavParams(), $selectFields);
     $documentState = true;
     $path = rtrim(SITE_DIR, '/');
     while ($element = $elementObject->fetch()) {
         $documentState = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($iblockTypeId, $element['IBLOCK_ID']), BizprocDocument::getDocumentComplexId($iblockTypeId, $element['ID']));
         $this->arResult['DATA'][$element['ID']]['ID'] = $element['ID'];
         $this->arResult['DATA'][$element['ID']]['DOCUMENT_NAME'] = $element['NAME'];
         $this->arResult['DATA'][$element['ID']]['DOCUMENT_URL'] = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $element["IBLOCK_ID"] . '&element_id=' . $element['ID'];
         if (!empty($documentState)) {
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = true;
             $documentState = current($documentState);
             $this->arResult['DATA'][$element['ID']]['WORKFLOW_ID'] = $documentState['ID'];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_NAME"] = $documentState["TEMPLATE_NAME"];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STATE"] = $documentState["STATE_TITLE"];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED"] = FormatDateFromDB($documentState["STARTED_FORMATTED"]);
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = "";
             if (intval($documentState["STARTED_BY"]) > 0) {
                 $dbUserTmp = CUser::getByID($documentState["STARTED_BY"]);
                 $arUserTmp = $dbUserTmp->fetch();
                 $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = CUser::FormatName($this->arParams["NAME_TEMPLATE"], $arUserTmp, true);
                 $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] .= " [" . $documentState["STARTED_BY"] . "]";
             }
             $this->arResult['DATA'][$element['ID']]['MODULE_ID'] = $documentState["DOCUMENT_ID"][0];
             $this->arResult['DATA'][$element['ID']]['ENTITY'] = $documentState["DOCUMENT_ID"][1];
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_ID'] = $documentState["DOCUMENT_ID"][2];
         } else {
             $documentState = false;
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = false;
         }
     }
     foreach ($this->arResult['DATA'] as $data) {
         if ($documentState) {
             if ($useComments) {
                 $workflows[] = 'WF_' . $data['WORKFLOW_ID'];
             }
         }
         $actions = array();
         if (strlen($data["DOCUMENT_URL"]) > 0) {
             $actions[] = array('ICONCLASS' => '', 'DEFAULT' => false, 'TEXT' => Loc::getMessage('CC_BLL_C_DOCUMENT'), 'ONCLICK' => 'window.open("' . $data["DOCUMENT_URL"] . '");');
         }
         $this->arResult['RECORDS'][] = array('data' => $data, 'actions' => $actions);
     }
     if ($useComments && $documentState) {
         $workflows = array_unique($workflows);
         if ($workflows) {
             $iterator = CForumTopic::getList(array(), array("@XML_ID" => $workflows));
             while ($row = $iterator->fetch()) {
                 $this->arResult["COMMENTS_COUNT"][$row['XML_ID']] = $row['POSTS'];
             }
         }
     }
     $this->arResult['COUNTERS'] = array('all' => 0);
     $this->arResult["ROWS_COUNT"] = $elementObject->selectedRowsCount();
     $this->arResult["NAV_RESULT"] = $elementObject;
     if ($this->arParams['SET_TITLE'] == 'Y') {
         $this->getApplication()->setTitle(Loc::getMessage('CC_BLL_TITLE'));
     }
     $this->includeComponentTemplate();
 }
示例#2
0
/**
 * @var $arParams array
 * @var $arResult array
 * @var $this CBitrixComponent
 * @var $APPLICATION CMain
 * @var $USER CUser
 */
if (!CModule::IncludeModule('voximplant')) {
    return;
}
$arResult = array("GRID_ID" => $this->__name, "USERS" => array());
$gridOptions = new CGridOptions($arResult['GRID_ID']);
$arSort = $gridOptions->getSorting(array('sort' => array('ID' => 'ASC'), 'vars' => array('by' => 'by', 'order' => 'order')));
$arSortArg = each($arSort['sort']);
$arFilter = array('ACTIVE' => 'Y', '!UF_DEPARTMENT' => false);
$arParams = array('FIELDS' => array('ID', 'LOGIN', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PERSONAL_PHOTO', 'WORK_POSITION'), 'SELECT' => array("UF_PHONE_INNER", "UF_VI_BACKPHONE", "UF_VI_PHONE"), 'NAV_PARAMS' => $gridOptions->getNavParams(array('nPageSize' => 20)));
if ($_REQUEST['act'] == 'search' && !empty($_REQUEST['FILTER'])) {
    $arFilter["NAME"] = $arResult['FILTER'] = $_REQUEST['FILTER'];
}
$dbUsers = CUser::GetList($arSortArg['key'], $arSortArg['value'], $arFilter, $arParams);
while ($user = $dbUsers->fetch()) {
    $arResult['USERS'][$user["ID"]] = prepareUserData($user);
}
if ($_REQUEST['act'] == 'search' && !empty($_REQUEST['FILTER'])) {
    $arFilter = array("UF_PHONE_INNER" => $_REQUEST['FILTER'], 'ACTIVE' => 'Y');
    $dbUsers = CUser::GetList($arSortArg['key'], $arSortArg['value'], $arFilter, $arParams);
    while ($user = $dbUsers->fetch()) {
        $arResult['USERS'][$user["ID"]] = prepareUserData($user);
    }
}
function prepareUserData($user)
示例#3
0
    private function executeManagePage()
    {
        global $USER, $APPLICATION;
        $APPLICATION->setTitle(GetMessage('INTR_MAIL_MANAGE_PAGE_TITLE'));
        CJSCore::Init(array('admin_interface'));
        if (!$USER->isAdmin() && !$USER->canDoOperation('bitrix24_config')) {
            $APPLICATION->AuthForm(GetMessage('ACCESS_DENIED'));
            return;
        }
        $this->arParams['SERVICES'] = array();
        $services = CIntranetMailSetupHelper::getMailServices();
        foreach ($services as $service) {
            if ($service['type'] == 'controller') {
                $crDomains = CControllerClient::ExecuteEvent('OnMailControllerGetDomains', array());
                if (!empty($crDomains['result']) && is_array($crDomains['result'])) {
                    $service['domains'] = $crDomains['result'];
                    $service['users'] = array();
                    foreach ($service['domains'] as $domain) {
                        $service['users'][$domain] = array();
                    }
                    $crUsers = CControllerClient::ExecuteEvent('OnMailControllerGetUsers', array());
                    if (!empty($crUsers['result']) && is_array($crUsers['result'])) {
                        foreach ($crUsers['result'] as $email) {
                            list($login, $domain) = explode('@', $email, 2);
                            if (isset($service['users'][$domain])) {
                                $service['users'][$domain][] = $login;
                            }
                        }
                        $dbMailboxes = CMailbox::getList(array('TIMESTAMP_X' => 'ASC'), array('ACTIVE' => 'Y', '!USER_ID' => 0, 'SERVICE_ID' => $service['id']));
                        while ($mailbox = $dbMailboxes->fetch()) {
                            list($login, $domain) = explode('@', $mailbox['LOGIN'], 2);
                            if (!empty($service['users'][$domain]) && ($key = array_search($login, $service['users'][$domain])) !== false) {
                                array_splice($service['users'][$domain], $key, 1);
                            }
                        }
                    }
                    $this->arParams['SERVICES'][] = $service;
                }
            }
            if (in_array($service['type'], array('domain', 'crdomain'))) {
                $result = self::checkDomainStatus(array('type' => $service['type'], 'domain' => $service['server'], 'token' => $service['token']), $error);
                if (!empty($result['stage']) && $result['stage'] == 'added') {
                    $service['domains'] = array($service['server']);
                    $service['users'] = array($service['server'] => array());
                    if ($service['type'] == 'domain') {
                        $users = CMailDomain2::getDomainUsers($service['token'], $service['server'], $error);
                        if (!empty($users) && is_array($users)) {
                            $service['users'][$service['server']] = $users;
                        }
                    } else {
                        if ($service['type'] == 'crdomain') {
                            $crUsers = CControllerClient::ExecuteEvent('OnMailControllerGetMemberUsers', array('DOMAIN' => $service['server']));
                            if (!empty($crUsers['result']) && is_array($crUsers['result'])) {
                                $service['users'][$service['server']] = $crUsers['result'];
                            }
                        }
                    }
                    $dbMailboxes = CMailbox::getList(array('TIMESTAMP_X' => 'ASC'), array('ACTIVE' => 'Y', '!USER_ID' => 0, 'SERVICE_ID' => $service['id']));
                    while ($mailbox = $dbMailboxes->fetch()) {
                        list($login, $domain) = explode('@', $mailbox['LOGIN'], 2);
                        if (!empty($service['users'][$domain]) && ($key = array_search($login, $service['users'][$domain])) !== false) {
                            array_splice($service['users'][$domain], $key, 1);
                        }
                    }
                    $this->arParams['SERVICES'][] = $service;
                }
            }
        }
        $this->arResult['GRID_ID'] = 'manage_domain_grid';
        $gridOptions = new CGridOptions($this->arResult['GRID_ID']);
        $arSort = $gridOptions->getSorting(array('sort' => array('ID' => 'ASC'), 'vars' => array('by' => 'by', 'order' => 'order')));
        $arNav = $gridOptions->getNavParams(array('nPageSize' => 50));
        $arSortArg = each($arSort['sort']);
        $arFilter = array('ACTIVE' => 'Y', '!UF_DEPARTMENT' => false);
        if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'search' && !empty($_REQUEST['FILTER'])) {
            $this->arResult['FILTER'] = $_REQUEST['FILTER'];
            $userIds = array();
            $dbMailboxes = CMailbox::getList(array('TIMESTAMP_X' => 'ASC'), array('LID' => SITE_ID, 'ACTIVE' => 'Y', '!USER_ID' => 0, 'LOGIN' => $_REQUEST['FILTER']));
            while ($mailbox = $dbMailboxes->fetch()) {
                if (in_array($mailbox['SERVER_TYPE'], array('imap', 'controller', 'domain'))) {
                    $userIds[] = $mailbox['USER_ID'];
                }
            }
            $arFilter['ID'] = empty($userIds) ? 0 : join('|', $userIds);
        }
        $dbUsers = CUser::GetList($arSortArg['key'], $arSortArg['value'], $arFilter, array('FIELDS' => array('ID', 'LOGIN', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PERSONAL_PHOTO', 'WORK_POSITION')));
        $dbUsers->navStart($arNav['nPageSize']);
        $arRows = array();
        while ($user = $dbUsers->fetch()) {
            $user['DETAIL_URL'] = COption::getOptionString('intranet', 'search_user_url', '/user/#ID#/');
            $user['DETAIL_URL'] = str_replace(array('#ID#', '#USER_ID#'), array($user['ID'], $user['ID']), $user['DETAIL_URL']);
            $user['PHOTO_THUMB'] = '<img src="/bitrix/components/bitrix/main.user.link/templates/.default/images/nopic_30x30.gif" border="0" alt="" width="32" height="32">';
            if (intval($user['PERSONAL_PHOTO']) > 0) {
                $imageFile = CFile::getFileArray($user['PERSONAL_PHOTO']);
                if ($imageFile !== false) {
                    $arFileTmp = CFile::resizeImageGet($imageFile, array('width' => 42, 'height' => 42), BX_RESIZE_IMAGE_EXACT, false);
                    $user['PHOTO_THUMB'] = CFile::showImage($arFileTmp['src'], 32, 32);
                }
            }
            $anchor_id = RandString(8);
            $arCols = array('NAME' => '<table id="user_' . $user['ID'] . '" style="border-collapse: collapse; border: none; ">
					<tr>
						<td style="border: none !important; padding: 0px !important; ">
							<div style="width: 32px; height: 32px; margin:2px; padding: 2px; box-shadow:0 0 2px 1px rgba(0, 0, 0, 0.1);">
								<a href="' . $user['DETAIL_URL'] . '">' . $user['PHOTO_THUMB'] . '</a>
							</div>
						</td>
						<td style="border: none !important; padding: 0px 0px 0px 7px !important; vertical-align: top; ">
							<a href="' . $user['DETAIL_URL'] . '"><b>' . CUser::formatName(CSite::getNameFormat(), $user, true, true) . '</b></a><br>
							' . htmlspecialcharsbx($user['WORK_POSITION']) . '
						</td>
					</tr>
				</table>', 'EMAIL' => '', 'ADD' => '', 'DELETE' => '');
            if ($mailbox = CIntranetMailSetupHelper::getUserMailbox($user['ID'])) {
                switch ($mailbox['SERVER_TYPE']) {
                    case 'imap':
                        $arCols['EMAIL'] = $mailbox['LOGIN'];
                        if (strpos($mailbox['LOGIN'], '@') === false) {
                            $arCols['EMAIL'] .= '<br><span style="font-weight: normal; ">imap://' . $mailbox['SERVER'] . ':' . $mailbox['PORT'] . '</span>';
                        }
                        $arCols['ADD'] = '<a href="#" onclick="mb.create(' . $user['ID'] . '); return false; ">' . GetMessage('INTR_MAIL_MANAGE_CHANGE') . '</a>';
                        break;
                    case 'controller':
                    case 'domain':
                    case 'crdomain':
                        $arCols['EMAIL'] = $mailbox['LOGIN'];
                        $arCols['ADD'] = '<a href="#" onclick="mb.create(' . $user['ID'] . '); return false; ">' . GetMessage('INTR_MAIL_MANAGE_CHANGE') . '</a><br><a href="#" onclick="mb.changePassword(' . $user['ID'] . '); return false; ">' . GetMessage('INTR_MAIL_MANAGE_PASSWORD') . '</a>';
                        $arCols['DELETE'] = '<a href="#" onclick="mb.remove(' . $user['ID'] . '); return false; ">' . GetMessage('INTR_MAIL_MANAGE_DELETE') . '</a>';
                        break;
                }
            } else {
                $arCols['ADD'] = '<a href="#" onclick="mb.create(' . $user['ID'] . '); return false; ">' . GetMessage('INTR_MAIL_MANAGE_CREATE') . '</a>';
            }
            if (empty($this->arParams['SERVICES'])) {
                $arCols['ADD'] = '';
                $arCols['DELETE'] = '';
            }
            $arCols['EMAIL'] = '<span id="email_' . $user['ID'] . '" style="font-weight: bold; white-space: nowrap; ">' . $arCols['EMAIL'] . '</span>';
            $arCols['ADD'] = '<span id="create_' . $user['ID'] . '" style="white-space: nowrap; ">' . $arCols['ADD'] . '</span>';
            $arCols['DELETE'] = '<span id="delete_' . $user['ID'] . '" style="white-space: nowrap; ">' . $arCols['DELETE'] . '</span>';
            $arRows[$user['ID']] = array('data' => $user, 'columns' => $arCols);
        }
        $this->arResult['ROWS'] = $arRows;
        $this->arResult['ROWS_COUNT'] = $dbUsers->selectedRowsCount();
        $this->arResult['NAV_OBJECT'] = $dbUsers;
        $this->arResult['NAV_OBJECT']->bShowAll = false;
        $this->includeComponentTemplate('manage');
    }