Поддержка серверов

CTimeManUser::_GetSettings: метод Битрикс

Постоянная ссылка: http://bxapi.ru/src/?id=184475

//    CTimeManUser::_GetSettings()
//    /bitrix/modules/timeman/classes/general/timeman_user.php:986

    protected function _GetSettings()
    {
        global $USER_FIELD_MANAGER;

        $arRes = [];

        $arRes = $this->_GetPersonalSettings();
        if ($arRes)
        {
            if ($arRes['UF_TIMEMAN'] === 'N')
            {
                return ['UF_TIMEMAN' => false];
            }

            $cnt = 0;
            if ($arRes['UF_TIMEMAN'] !== 'Y')
            {
                $cnt++;
            }
            foreach ($arRes as $fld => $value)
            {
                if (!$arRes[$fld] || $arRes[$fld] == '00:00')
                {
                    $cnt++;
                }
            }

            if ($cnt > 0)
            {
                if (is_array($this->UF_DEPARTMENT) && count($this->UF_DEPARTMENT) > 0)
                {
                    $allSet = [
                        'UF_TIMEMAN' => $arRes['UF_TIMEMAN'] ? $arRes['UF_TIMEMAN'] : false,
                        'UF_TM_MAX_START' => 86401,
                        'UF_TM_MIN_FINISH' => false,
                        'UF_TM_MIN_DURATION' => false,
                        'UF_TM_REPORT_REQ' => false,
                        'UF_REPORT_PERIOD' => $arRes['UF_REPORT_PERIOD'],
                        'UF_TM_REPORT_DATE' => $arRes['UF_TM_REPORT_DATE'],
                        'UF_TM_TIME' => $arRes['UF_TM_TIME'],
                        'UF_TM_DAY' => $arRes['UF_TM_DAY'],
                        'UF_TM_REPORT_TPL' => [],
                        'UF_TM_FREE' => false,
                        'UF_TM_ALLOWED_DELTA' => -1,
                    ];

                    foreach ($this->UF_DEPARTMENT as $dpt)
                    {
                        $dptSet = CTimeMan::GetSectionSettings($dpt);

                        if ($allSet['UF_TIMEMAN'] !== 'Y' && $dptSet['UF_TIMEMAN'])
                        {
                            $allSet['UF_TIMEMAN'] = $dptSet['UF_TIMEMAN'];
                        }
                        if ($dptSet['UF_TM_MAX_START'])
                        {
                            $allSet['UF_TM_MAX_START'] = min($dptSet['UF_TM_MAX_START'], $allSet['UF_TM_MAX_START']);
                        }

                        $allSet['UF_TM_MAX_START'] = min($dptSet['UF_TM_MAX_START'], $allSet['UF_TM_MAX_START']);
                        $allSet['UF_TM_MIN_FINISH'] = max($dptSet['UF_TM_MIN_FINISH'], $allSet['UF_TM_MIN_FINISH']);
                        $allSet['UF_TM_MIN_DURATION'] = max($dptSet['UF_TM_MIN_DURATION'], $allSet['UF_TM_MIN_DURATION']);

                        if ($dptSet['UF_TM_REPORT_REQ'])
                        {
                            $allSet['UF_TM_REPORT_REQ'] = $dptSet['UF_TM_REPORT_REQ'];
                        }

                        if ((!is_array($allSet['UF_TM_REPORT_TPL']) || count($allSet['UF_TM_REPORT_TPL']) <= 0) && $dptSet['UF_TM_REPORT_TPL'])
                        {
                            $allSet['UF_TM_REPORT_TPL'] = $dptSet['UF_TM_REPORT_TPL'];
                        }

                        if ($dptSet['UF_TM_FREE'])
                        {
                            $allSet['UF_TM_FREE'] = $dptSet['UF_TM_FREE'];
                        }

                        if ($dptSet['UF_TM_ALLOWED_DELTA'])
                        {
                            if ($allSet['UF_TM_ALLOWED_DELTA'] == -1 || $dptSet['UF_TM_ALLOWED_DELTA'] < $allSet['UF_TM_ALLOWED_DELTA'])
                            {
                                $allSet['UF_TM_ALLOWED_DELTA'] = $dptSet['UF_TM_ALLOWED_DELTA'];
                            }
                        }
                    }

                    //report fields
                    $allSet["UF_REPORT_PERIOD"] = (!$allSet["UF_REPORT_PERIOD"] && $dptSet["UF_REPORT_PERIOD"]) ? $dptSet["UF_REPORT_PERIOD"] : $allSet["UF_REPORT_PERIOD"];
                    $allSet["UF_TM_TIME"] = (!$allSet["UF_TM_TIME"] && $dptSet["UF_TM_TIME"]) ? $dptSet["UF_TM_TIME"] : $allSet["UF_TM_TIME"];
                    $allSet["UF_TM_DAY"] = (!$allSet["UF_TM_DAY"] && $dptSet["UF_TM_DAY"]) ? $dptSet["UF_TM_DAY"] : $allSet["UF_TM_DAY"];
                    $allSet["UF_TM_REPORT_DATE"] = (!$allSet["UF_TM_REPORT_DATE"] && $dptSet["UF_TM_REPORT_DATE"]) ? $dptSet["UF_TM_REPORT_DATE"] : $allSet["UF_TM_REPORT_DATE"];

                    if ($arRes['UF_TM_ALLOWED_DELTA'] === '0')
                    {
                        unset($allSet['UF_TM_ALLOWED_DELTA']);
                    }
                    foreach ($allSet as $key => $value)
                    {
                        if (!$arRes[$key] || $arRes[$key] === '00:00')
                        {
                            $arRes[$key] = $value;
                        }
                    }

                    if ($arRes['UF_TIMEMAN'] === 'N')
                    {
                        return ($arRes = ['UF_TIMEMAN' => false]);
                    }
                }
                elseif ($arRes['UF_TIMEMAN'] !== 'Y')
                {
                    // if user is not attached to company structure tm can be allowed only in his own profile
                    return ($arRes = ['UF_TIMEMAN' => false]);
                }
            } //if ($cnt > 0)

            $arRes['UF_TIMEMAN'] = true; // it can be only Y|null at this moment
            $arRes['UF_TM_MAX_START'] = $arRes['UF_TM_MAX_START'];
            $arRes['UF_TM_MAX_START'] = $arRes['UF_TM_MAX_START'] > 0
                ? $arRes['UF_TM_MAX_START']
                : COption::GetOptionInt('timeman', 'workday_max_start', 33300);
            $arRes['UF_TM_MIN_FINISH'] = $arRes['UF_TM_MIN_FINISH'];
            $arRes['UF_TM_MIN_FINISH'] = $arRes['UF_TM_MIN_FINISH'] > 0
                ? $arRes['UF_TM_MIN_FINISH']
                : COption::GetOptionInt('timeman', 'workday_min_finish', 63900);
            $arRes['UF_TM_MIN_DURATION'] = $arRes['UF_TM_MIN_DURATION'];
            $arRes['UF_TM_MIN_DURATION'] = $arRes['UF_TM_MIN_DURATION'] > 0
                ? $arRes['UF_TM_MIN_DURATION']
                : COption::GetOptionInt('timeman', 'workday_min_duration', 28800);
            $arRes['UF_TM_REPORT_REQ'] = $arRes['UF_TM_REPORT_REQ']
                ? $arRes['UF_TM_REPORT_REQ']
                : COption::GetOptionString('timeman', 'workday_report_required', 'A');
            $arRes['UF_TM_REPORT_TPL'] = $arRes['UF_TM_REPORT_TPL']
                ? $arRes['UF_TM_REPORT_TPL']
                : [];
            $arRes['UF_TM_FREE'] = $arRes['UF_TM_FREE']
                ? $arRes['UF_TM_FREE'] == 'Y'
                : false;
            $arRes['UF_TM_ALLOWED_DELTA'] = $arRes['UF_TM_ALLOWED_DELTA'] > -1
                ? $arRes['UF_TM_ALLOWED_DELTA']
                : COption::GetOptionInt('timeman', 'workday_allowed_delta', '900');
        }
        else
        {
            return ['UF_TIMEMAN' => false];
        }

        return $arRes;
    }

Блог разработчика

9 Августа 2016 ResizeImageGet и простой водяной знак налету

Сегодня поговорим о том как проще всего воткнуть водяной знак на картинки в Битрикс. Например, на все изображения каталога.

21 Июля 2016 Добавление вкладки в CRM коробки Битрикс24

В этом посте я покажу, как легко и просто добавить вкладку в сущность CRM. И не просто добавить, а вывести там свой контент.

21 Июля 2016 Как просто обращаться из коробки Битрикс24 на сайт на базе Битрикс

К примеру вам хочется внутренним скриптом дернуть с сайта-магазина информацию, которая там, в свою очередь, закрыта некоторыми правами. Например, админскими. Можно конечно мутить свой REST, или иной формат общения, но проще всего воспользоваться штатным инструментом:

Текст сообщения*
Загрузить изображение