コード例 #1
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
function prepareUserData($user)
{
    $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);
        }
    }
    return $user;
}
コード例 #2
0
ファイル: avatar.php プロジェクト: DarneoStudio/bitrix
 public static function getSrc($avatarId, $width = 21, $height = 21)
 {
     static $cache = array();
     if (empty($avatarId)) {
         return null;
     }
     $avatarId = (int) $avatarId;
     $key = $avatarId . " {$width} {$height}";
     if (!isset($cache[$key])) {
         $src = false;
         if ($avatarId > 0) {
             /** @noinspection PhpDynamicAsStaticMethodCallInspection */
             $imageFile = \CFile::getFileArray($avatarId);
             if ($imageFile !== false) {
                 /** @noinspection PhpDynamicAsStaticMethodCallInspection */
                 $fileTmp = \CFile::resizeImageGet($imageFile, array("width" => $width, "height" => $height), BX_RESIZE_IMAGE_EXACT, false);
                 $src = $fileTmp["src"];
             }
             $cache[$key] = $src;
         }
     }
     return $cache[$key];
 }
コード例 #3
0
ファイル: bizprocdocument.php プロジェクト: Satariall/izurit
 /**
  * @param string $documentId - document id.
  * @return array - document fields array.
  */
 public function GetDocument($documentId)
 {
     $documentId = intval($documentId);
     if ($documentId <= 0) {
         throw new CBPArgumentNullException("documentId");
     }
     $result = null;
     $dbDocumentList = CIBlockElement::getList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"));
     if ($objDocument = $dbDocumentList->getNextElement(false, true)) {
         $fields = $objDocument->getFields();
         $properties = $objDocument->getProperties();
         foreach ($fields as $fieldKey => $fieldValue) {
             if (substr($fieldKey, 0, 1) == "~") {
                 continue;
             }
             $result[$fieldKey] = $fieldValue;
             if (in_array($fieldKey, array("MODIFIED_BY", "CREATED_BY"))) {
                 $result[$fieldKey] = "user_" . $fieldValue;
                 $result[$fieldKey . "_PRINTABLE"] = $fields[$fieldKey == "MODIFIED_BY" ? "USER_NAME" : "CREATED_USER_NAME"];
             } elseif (in_array($fieldKey, array("PREVIEW_TEXT", "DETAIL_TEXT"))) {
                 if ($fields[$fieldKey . "_TYPE"] == "html") {
                     $result[$fieldKey] = HTMLToTxt($fields["~" . $fieldKey]);
                 }
             }
         }
         foreach ($properties as $propertyKey => $propertyValue) {
             if (strlen($propertyValue["USER_TYPE"]) > 0) {
                 if ($propertyValue["USER_TYPE"] == "UserID" || $propertyValue["USER_TYPE"] == "employee" && COption::getOptionString("bizproc", "employee_compatible_mode", "N") != "Y") {
                     $propertyValueArray = $propertyValue["VALUE"];
                     $propertyKeyArray = isset($propertyValue["VALUE_ENUM_ID"]) ? $propertyValue["VALUE_ENUM_ID"] : $propertyValue["PROPERTY_VALUE_ID"];
                     if (!is_array($propertyValueArray)) {
                         $userQuery = CUser::getByID($propertyValueArray);
                         if ($userArray = $userQuery->getNext()) {
                             $result["PROPERTY_" . $propertyKey] = "user_" . intval($propertyValueArray);
                             $result["PROPERTY_" . $propertyKey . "_PRINTABLE"] = "(" . $userArray["LOGIN"] . ")" . (strlen($userArray["NAME"]) > 0 || strlen($userArray["LAST_NAME"]) > 0 ? " " : "") . $userArray["NAME"] . (strlen($userArray["NAME"]) > 0 && strlen($userArray["LAST_NAME"]) > 0 ? " " : "") . $userArray["LAST_NAME"];
                         }
                     } else {
                         for ($i = 0, $cnt = count($propertyValueArray); $i < $cnt; $i++) {
                             $userQuery = CUser::getByID($propertyValueArray[$i]);
                             if ($userArray = $userQuery->getNext()) {
                                 $result["PROPERTY_" . $propertyKey][$propertyKeyArray[$i]] = "user_" . intval($propertyValueArray[$i]);
                                 $result["PROPERTY_" . $propertyKey . "_PRINTABLE"][$propertyKeyArray[$i]] = "(" . $userArray["LOGIN"] . ")" . (strlen($userArray["NAME"]) > 0 || strlen($userArray["LAST_NAME"]) > 0 ? " " : "") . $userArray["NAME"] . (strlen($userArray["NAME"]) > 0 && strlen($userArray["LAST_NAME"]) > 0 ? " " : "") . $userArray["LAST_NAME"];
                             }
                         }
                     }
                 } else {
                     $result["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"];
                 }
             } elseif ($propertyValue["PROPERTY_TYPE"] == "L") {
                 $propertyValueArray = $propertyValue["VALUE"];
                 $propertyKeyArray = $propertyValue["VALUE_XML_ID"];
                 if (!is_array($propertyValueArray)) {
                     $propertyValueArray = array($propertyValueArray);
                     $propertyKeyArray = array($propertyKeyArray);
                 }
                 for ($i = 0, $cnt = count($propertyValueArray); $i < $cnt; $i++) {
                     $result["PROPERTY_" . $propertyKey][$propertyKeyArray[$i]] = $propertyValueArray[$i];
                 }
             } elseif ($propertyValue["PROPERTY_TYPE"] == "F") {
                 $propertyValueArray = $propertyValue["VALUE"];
                 if (!is_array($propertyValueArray)) {
                     $propertyValueArray = array($propertyValueArray);
                 }
                 foreach ($propertyValueArray as $v) {
                     $userArray = CFile::getFileArray($v);
                     if ($userArray) {
                         $result["PROPERTY_" . $propertyKey][intval($v)] = $userArray["SRC"];
                         $result["PROPERTY_" . $propertyKey . "_printable"][intval($v)] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($userArray["FILE_NAME"]) . "&i=" . $v . "&h=" . md5($userArray["SUBDIR"]) . "]" . htmlspecialcharsbx($userArray["ORIGINAL_NAME"]) . "[/url]";
                     }
                 }
             } else {
                 $result["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"];
             }
         }
         $documentFields = static::getDocumentFields(static::getDocumentType($documentId));
         foreach ($documentFields as $fieldKey => $field) {
             if (!array_key_exists($fieldKey, $result)) {
                 $result[$fieldKey] = null;
             }
         }
     }
     return $result;
 }
コード例 #4
0
ファイル: automatic.php プロジェクト: Satariall/izurit
 public static function convertNewServiceToOld($service, $sid = false)
 {
     if (!isset($service["CONFIG"]["MAIN"]["SID"])) {
         return false;
     }
     self::initHandlers();
     $handlers = self::getRegisteredHandlers("SID");
     if ($sid !== false) {
         $service["SID"] = $sid;
     } else {
         $service["SID"] = $service["CONFIG"]["MAIN"]["SID"];
     }
     $service["TAX_RATE"] = $service["CONFIG"]["MAIN"]["MARGIN_VALUE"];
     //todo: %, CURRENCY
     $service["INSTALLED"] = 'Y';
     $service["BASE_CURRENCY"] = $service["CURRENCY"];
     $service["SETTINGS"] = $service["CONFIG"]["MAIN"]["OLD_SETTINGS"];
     $service["HANDLER"] = $handlers[$service["SID"]]["HANDLER"];
     if (intval($service["LOGOTIP"]) > 0) {
         $service["LOGOTIP"] = \CFile::getFileArray($service["LOGOTIP"]);
     }
     $siteId = false;
     if (isset($service["ID"]) && intval($service["ID"]) > 0) {
         $restrictions = \Bitrix\Sale\Delivery\Services\Manager::getRestrictionsByDeliveryId($service["ID"]);
         foreach ($restrictions as $restriction) {
             if ($restriction["CLASS_NAME"] == '\\Bitrix\\Sale\\Delivery\\Restrictions\\BySite' && !empty($restriction["PARAMS"]["SITE_ID"])) {
                 if (is_array($restriction["PARAMS"]["SITE_ID"])) {
                     reset($restriction["PARAMS"]["SITE_ID"]);
                     $siteId = current($restriction["PARAMS"]["SITE_ID"]);
                 } else {
                     $siteId = $restriction["PARAMS"]["SITE_ID"];
                 }
                 break;
             }
         }
     }
     if (!$siteId) {
         $siteId = Helper::getDefaultSiteId();
     }
     $service["CONFIG"] = self::createConfig($handlers[$service["SID"]], $service["SETTINGS"], $siteId);
     $service["SETTINGS"] = unserialize($service["SETTINGS"]);
     $service["PROFILES"] = array();
     if (isset($service["ID"]) && intval($service["ID"]) > 0) {
         foreach (Manager::getByParentId($service["ID"]) as $profile) {
             $profileId = $profile["CONFIG"]["MAIN"]["PROFILE_ID"];
             $profileParams = array("TITLE" => $profile["NAME"], "DESCRIPTION" => $profile["DESCRIPTION"], "TAX_RATE" => $service["CONFIG"]["MAIN"]["MARGIN_VALUE"], "ACTIVE" => $profile["ACTIVE"]);
             $restrictions = Manager::getRestrictionsByDeliveryId($profile["ID"]);
             foreach ($restrictions as $restriction) {
                 switch ($restriction["CLASS_NAME"]) {
                     case '\\Bitrix\\Sale\\Delivery\\Restrictions\\ByWeight':
                         $profileParams["RESTRICTIONS_WEIGHT"] = array($restriction["PARAMS"]["MIN_WEIGHT"], $restriction["PARAMS"]["MAX_WEIGHT"]);
                         break;
                     case '\\Bitrix\\Sale\\Delivery\\Restrictions\\ByPrice':
                         $profileParams["RESTRICTIONS_SUM"] = array($restriction["PARAMS"]["MIN_PRICE"], $restriction["PARAMS"]["MAX_PRICE"]);
                         break;
                     case '\\Bitrix\\Sale\\Delivery\\Restrictions\\ByDimensions':
                         $profileParams["RESTRICTIONS_DIMENSIONS"] = array($restriction["PARAMS"]["LENGTH"], $restriction["PARAMS"]["WIDTH"], $restriction["PARAMS"]["HEIGHT"]);
                         $profileParams["RESTRICTIONS_MAX_SIZE"] = $restriction["PARAMS"]["MAX_DIMENSION"];
                         $profileParams["RESTRICTIONS_DIMENSIONS_SUM"] = $restriction["PARAMS"]["MAX_DIMENSIONS_SUM"];
                         break;
                     default:
                         break;
                 }
             }
             $service["PROFILES"][$profileId] = $profileParams;
         }
     }
     unset($service["CODE"]);
     if (strlen($service["SID"]) > 0 && isset($handlers[$service["SID"]])) {
         $result = array_merge($handlers[$service["SID"]], $service);
     } else {
         $result = $service;
     }
     return $result;
 }
コード例 #5
0
ファイル: utils.php プロジェクト: mrdeadmouse/u136006
 /**
  * @param $fields
  * @param $params
  * @param $siteId
  * @return string|null
  */
 public static function createAvatar($fields, $params = array(), $siteId = SITE_ID)
 {
     if (!isset($params['AVATAR_SIZE'])) {
         $params['AVATAR_SIZE'] = 30;
     }
     if (CModule::IncludeModule('socialnetwork')) {
         return CSocNetLogTools::FormatEvent_CreateAvatar($fields, $params, '', $siteId);
     }
     static $cachedAvatars = array();
     if (intval($fields['PERSONAL_PHOTO']) > 0) {
         if (empty($cachedAvatars[$params['AVATAR_SIZE']][$fields['PERSONAL_PHOTO']])) {
             $imageFile = CFile::getFileArray($fields['PERSONAL_PHOTO']);
             if ($imageFile !== false) {
                 $file = CFile::resizeImageGet($imageFile, array("width" => $params['AVATAR_SIZE'], "height" => $params['AVATAR_SIZE']), BX_RESIZE_IMAGE_EXACT, false);
                 $avatarPath = $file['src'];
                 $cachedAvatars[$params['AVATAR_SIZE']][$fields['PERSONAL_PHOTO']] = $avatarPath;
             }
         }
     }
     return empty($cachedAvatars[$params['AVATAR_SIZE']][$fields['PERSONAL_PHOTO']]) ? null : $cachedAvatars[$params['AVATAR_SIZE']][$fields['PERSONAL_PHOTO']];
 }
コード例 #6
0
 /**
  * @param string $documentId - document id.
  * @return array - document fields array.
  */
 public function GetDocument($documentId)
 {
     $documentId = intval($documentId);
     if ($documentId <= 0) {
         throw new CBPArgumentNullException("documentId");
     }
     $result = null;
     $dbDocumentList = CIBlockElement::getList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"));
     if ($objDocument = $dbDocumentList->getNextElement(false, true)) {
         $fields = $objDocument->getFields();
         $properties = $objDocument->getProperties();
         foreach ($fields as $fieldKey => $fieldValue) {
             if (substr($fieldKey, 0, 1) == "~") {
                 continue;
             }
             $result[$fieldKey] = $fieldValue;
             if (in_array($fieldKey, array("MODIFIED_BY", "CREATED_BY"))) {
                 $result[$fieldKey] = "user_" . $fieldValue;
                 $result[$fieldKey . "_PRINTABLE"] = $fields[$fieldKey == "MODIFIED_BY" ? "USER_NAME" : "CREATED_USER_NAME"];
             } elseif (in_array($fieldKey, array("PREVIEW_TEXT", "DETAIL_TEXT"))) {
                 if ($fields[$fieldKey . "_TYPE"] == "html") {
                     $result[$fieldKey] = HTMLToTxt($fields["~" . $fieldKey]);
                 }
             }
         }
         foreach ($properties as $propertyKey => $propertyValue) {
             if (strlen($propertyValue["USER_TYPE"]) > 0) {
                 if ($propertyValue["USER_TYPE"] == "UserID" || $propertyValue["USER_TYPE"] == "employee" && COption::getOptionString("bizproc", "employee_compatible_mode", "N") != "Y") {
                     if (!is_array($propertyValue["VALUE"])) {
                         $propertyValue["VALUE"] = array($propertyValue["VALUE"]);
                     }
                     $listUsers = implode(' | ', $propertyValue["VALUE"]);
                     $userQuery = CUser::getList($by = 'ID', $order = 'ASC', array('ID' => $listUsers), array('FIELDS' => array('ID', 'LOGIN', 'NAME', 'LAST_NAME')));
                     while ($user = $userQuery->fetch()) {
                         $result["PROPERTY_" . $propertyKey][$user['ID']] = "user_" . intval($user['ID']);
                         $result["PROPERTY_" . $propertyKey . "_PRINTABLE"][$user['ID']] = "(" . $user["LOGIN"] . ")" . (strlen($user["NAME"]) > 0 || strlen($user["LAST_NAME"]) > 0 ? " " : "") . $user["NAME"] . (strlen($user["NAME"]) > 0 && strlen($user["LAST_NAME"]) > 0 ? " " : "") . $user["LAST_NAME"];
                     }
                 } elseif ($propertyValue["USER_TYPE"] == "DiskFile") {
                     if (is_array($propertyValue["VALUE"])) {
                         if ($propertyValue["MULTIPLE"] == "Y") {
                             $propertyValue["VALUE"] = current($propertyValue["VALUE"]);
                         }
                         foreach ($propertyValue["VALUE"] as $attachedId) {
                             $userType = \CIBlockProperty::getUserType($propertyValue['USER_TYPE']);
                             $fileId = null;
                             if (array_key_exists('GetObjectId', $userType)) {
                                 $fileId = call_user_func_array($userType['GetObjectId'], array($attachedId));
                             }
                             if (!$fileId) {
                                 continue;
                             }
                             $printableUrl = '';
                             if (array_key_exists('GetUrlAttachedFileElement', $userType)) {
                                 $printableUrl = call_user_func_array($userType['GetUrlAttachedFileElement'], array($documentId, $fileId));
                             }
                             $result["PROPERTY_" . $propertyKey][$attachedId] = $fileId;
                             $result["PROPERTY_" . $propertyKey . "_PRINTABLE"][$attachedId] = $printableUrl;
                         }
                     } else {
                         continue;
                     }
                 } else {
                     $result["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"];
                 }
             } elseif ($propertyValue["PROPERTY_TYPE"] == "L") {
                 $propertyValueArray = $propertyValue["VALUE"];
                 $propertyKeyArray = $propertyValue["VALUE_XML_ID"];
                 if (!is_array($propertyValueArray)) {
                     $propertyValueArray = array($propertyValueArray);
                     $propertyKeyArray = array($propertyKeyArray);
                 }
                 for ($i = 0, $cnt = count($propertyValueArray); $i < $cnt; $i++) {
                     $result["PROPERTY_" . $propertyKey][$propertyKeyArray[$i]] = $propertyValueArray[$i];
                 }
             } elseif ($propertyValue["PROPERTY_TYPE"] == "F") {
                 $propertyValueArray = $propertyValue["VALUE"];
                 if (!is_array($propertyValueArray)) {
                     $propertyValueArray = array($propertyValueArray);
                 }
                 foreach ($propertyValueArray as $v) {
                     $userArray = CFile::getFileArray($v);
                     if ($userArray) {
                         $result["PROPERTY_" . $propertyKey][intval($v)] = $userArray["SRC"];
                         $result["PROPERTY_" . $propertyKey . "_printable"][intval($v)] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . urlencode($userArray["FILE_NAME"]) . "&i=" . $v . "&h=" . md5($userArray["SUBDIR"]) . "]" . htmlspecialcharsbx($userArray["ORIGINAL_NAME"]) . "[/url]";
                     }
                 }
             } else {
                 $result["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"];
             }
         }
         $documentFields = static::getDocumentFields(static::getDocumentType($documentId));
         foreach ($documentFields as $fieldKey => $field) {
             if (!array_key_exists($fieldKey, $result)) {
                 $result[$fieldKey] = null;
             }
         }
     }
     return $result;
 }
コード例 #7
0
ファイル: livefeed.php プロジェクト: DarneoStudio/bitrix
    public static function setMessageLiveFeed($users, $elementId, $workflowId, $flagCompleteProcess)
    {
        $elementId = intval($elementId);
        $elementObject = CIBlockElement::getList(array(), array('ID' => $elementId), false, false, array('ID', 'CREATED_BY', 'IBLOCK_NAME', 'NAME', 'IBLOCK_ID', 'LANG_DIR'));
        $element = $elementObject->fetch();
        if (!CLists::getLiveFeed($element["IBLOCK_ID"])) {
            return false;
        }
        $params = serialize(array("ELEMENT_NAME" => $element['NAME']));
        $element['NAME'] = preg_replace_callback('#^[^\\[\\]]+?\\[(\\d+)\\]#i', function ($matches) {
            $userId = $matches[1];
            $db = CUser::GetByID($userId);
            if ($ar = $db->GetNext()) {
                $ix = randString(5);
                return '<a class="feed-post-user-name" id="bp_' . $userId . '_' . $ix . '" href="/company/personal/user/' . $userId . '/"
						bx-post-author-id="' . $userId . '">' . CUser::FormatName(CSite::GetNameFormat(false), $ar, false, false) . '</a>
						<script type="text/javascript">if (BX.tooltip) BX.tooltip(\'' . $userId . '\', "bp_' . $userId . '_' . $ix . '", "");</script>';
            }
            return $matches[0];
        }, $element['NAME']);
        $path = rtrim($element['LANG_DIR'], '/');
        $urlElement = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $element["IBLOCK_ID"] . '&element_id=' . $elementId;
        $createdBy = $element['CREATED_BY'];
        if (!Loader::includeModule('socialnetwork') || $createdBy <= 0) {
            return false;
        }
        $sourceId = CBPStateService::getWorkflowIntegerId($workflowId);
        $logId = 0;
        $userObject = CUser::getByID($createdBy);
        $siteId = array();
        $siteObject = CSite::getList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
        while ($site = $siteObject->fetch()) {
            $siteId[] = $site['LID'];
        }
        if ($userObject->fetch()) {
            global $DB;
            $soFields = array('ENTITY_TYPE' => SONET_LISTS_NEW_POST_ENTITY, 'EVENT_ID' => 'lists_new_element', 'ENTITY_ID' => 1, '=LOG_UPDATE' => $DB->currentTimeFunction(), 'SOURCE_ID' => $sourceId, 'USER_ID' => $createdBy, 'MODULE_ID' => 'lists', 'TITLE_TEMPLATE' => $urlElement, 'TITLE' => $element['IBLOCK_NAME'], 'PARAMS' => $params, 'MESSAGE' => $workflowId, 'CALLBACK_FUNC' => false, 'SITE_ID' => $siteId, 'ENABLE_COMMENTS' => 'Y', 'RATING_TYPE_ID' => 'LISTS_NEW_ELEMENT', 'RATING_ENTITY_ID' => $sourceId, 'URL' => '#SITE_DIR#' . COption::GetOptionString('socialnetwork', 'user_page', false, SITE_ID) . 'log/');
            $logObject = CSocNetLog::getList(array(), array('ENTITY_TYPE' => $soFields['ENTITY_TYPE'], 'ENTITY_ID' => $soFields['ENTITY_ID'], 'EVENT_ID' => $soFields['EVENT_ID'], 'SOURCE_ID' => $soFields['SOURCE_ID']));
            $iblockPicture = CIBlock::getArrayByID($element['IBLOCK_ID'], 'PICTURE');
            $imageFile = CFile::getFileArray($iblockPicture);
            if ($imageFile !== false) {
                $imageFile = CFile::ResizeImageGet($imageFile, array("width" => 36, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false);
            }
            if (empty($imageFile['src'])) {
                $imageFile['src'] = '/bitrix/images/lists/default.png';
            }
            $soFields['TEXT_MESSAGE'] = '
				<span class="bp-title-desc">
					<span class="bp-title-desc-icon">
						<img src="' . $imageFile['src'] . '" width="36" height="30" border="0" />
					</span>
					' . $element['NAME'] . '
				</span>
			';
            if ($log = $logObject->fetch()) {
                if (intval($log['ID']) > 0) {
                    if (empty($users)) {
                        CSocNetLog::update($log['ID'], $soFields);
                    } else {
                        $activeUsers = CBPTaskService::getWorkflowParticipants($workflowId);
                        $rights = self::getRights($activeUsers, $log['ID'], $createdBy, 'post');
                        $usersRight = self::getUserIdForRight($rights);
                        self::setSocnetFollow($usersRight, $log['ID'], 'Y', true);
                        /* Recipients tasks bp */
                        CSocNetLog::update($log['ID'], $soFields);
                        /* Increment the counter for participants */
                        CSocNetLogRights::deleteByLogID($log['ID']);
                        $rightsCounter = self::getRights($users, $log['ID'], $createdBy, 'counter');
                        CSocNetLogRights::add($log['ID'], $rightsCounter, false, false);
                        CSocNetLog::counterIncrement($log['ID'], $soFields['EVENT_ID'], false, 'L', false);
                        /* Return previous state rights */
                        CSocNetLogRights::deleteByLogID($log['ID']);
                        CSocNetLogRights::add($log['ID'], $rights, false, false);
                        self::setSocnetFollow($users, $log['ID'], 'Y');
                        self::setSocnetFollow($users, $log['ID'], 'N');
                    }
                    /* Completion of the process for the author */
                    if ($flagCompleteProcess) {
                        $activeUsers = CBPTaskService::getWorkflowParticipants($workflowId);
                        $rights = self::getRights($activeUsers, $log['ID'], $createdBy, 'post');
                        $usersRight = self::getUserIdForRight($rights);
                        /* Increment the counter for author */
                        $users[] = $createdBy;
                        CSocNetLogRights::deleteByLogID($log['ID']);
                        $rightsCounter = self::getRights($users, $log['ID'], $createdBy, 'counter');
                        CSocNetLogRights::add($log['ID'], $rightsCounter, false, false);
                        CSocNetLog::counterIncrement($log['ID'], $soFields['EVENT_ID'], false, 'L', false);
                        /* Return previous state rights */
                        CSocNetLogRights::deleteByLogID($log['ID']);
                        CSocNetLogRights::add($log['ID'], $rights, false, false);
                        self::setSocnetFollow($users, $log['ID'], 'Y');
                        self::setSocnetFollow($usersRight, $log['ID'], 'N');
                    }
                }
            } else {
                $activeUsers = CBPTaskService::getWorkflowParticipants($workflowId);
                $soFields['=LOG_DATE'] = $DB->currentTimeFunction();
                $logId = CSocNetLog::add($soFields, false);
                if (intval($logId) > 0) {
                    $rights = self::getRights($activeUsers, $logId, $createdBy, 'post');
                    CSocNetLogRights::add($logId, $rights, false, false);
                    $usersRight = self::getUserIdForRight($rights);
                    self::setSocnetFollow($usersRight, $logId, 'N');
                }
                CSocNetLog::counterIncrement($logId, $soFields['EVENT_ID'], false, 'L', false);
            }
        }
        return $logId;
    }
コード例 #8
0
ファイル: CDev.php プロジェクト: Hawkart/megatv
 public static function getSections($filter, $sort = array(), $cnt = false, $select = array())
 {
     CModule::includeModule('iblock');
     $sections = array();
     $rsSections = CIBlockSection::getList($sort, $filter, $cnt, $select);
     while ($section = $rsSections->GetNext()) {
         if (!empty($section['PICTURE'])) {
             $section['PICTURE'] = CFile::getFileArray($section['PICTURE']);
         }
         if (!empty($section['DETAIL_PICTURE'])) {
             $section['DETAIL_PICTURE'] = CFile::getFileArray($section['DETAIL_PICTURE']);
         }
         $sections[$section['ID']] = $section;
     }
     return $sections;
 }
コード例 #9
0
ファイル: orderbasket.php プロジェクト: DarneoStudio/bitrix
 protected static function getPropsParams($iblockId)
 {
     $arRes = array();
     $bUseHLIblock = \Bitrix\Main\Loader::includeModule('highloadblock');
     $rsProps = \CIBlockProperty::getList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $iblockId, 'ACTIVE' => 'Y'));
     while ($arProp = $rsProps->fetch()) {
         if ($arProp['PROPERTY_TYPE'] == 'L' || $arProp['PROPERTY_TYPE'] == 'E' || $arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
             if ($arProp['XML_ID'] == 'CML2_LINK') {
                 continue;
             }
             $arValues = array();
             if ($arProp['PROPERTY_TYPE'] == 'L') {
                 $arValues = array();
                 $rsPropEnums = \CIBlockProperty::getPropertyEnum($arProp['ID']);
                 while ($arEnum = $rsPropEnums->fetch()) {
                     $arValues[$arEnum['VALUE']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['VALUE'], 'PICT' => false);
                 }
             } elseif ($arProp['PROPERTY_TYPE'] == 'E') {
                 $rsPropEnums = \CIBlockElement::getList(array('SORT' => 'ASC'), array('IBLOCK_ID' => $arProp['LINK_IBLOCK_ID'], 'ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'PREVIEW_PICTURE'));
                 while ($arEnum = $rsPropEnums->Fetch()) {
                     $arEnum['PREVIEW_PICTURE'] = \CFile::getFileArray($arEnum['PREVIEW_PICTURE']);
                     if (!is_array($arEnum['PREVIEW_PICTURE'])) {
                         $arEnum['PREVIEW_PICTURE'] = false;
                     }
                     if ($arEnum['PREVIEW_PICTURE'] !== false) {
                         $productImg = \CFile::resizeImageGet($arEnum['PREVIEW_PICTURE'], array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                         $arEnum['PREVIEW_PICTURE']['SRC'] = $productImg['src'];
                     }
                     $arValues[$arEnum['NAME']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['NAME'], 'SORT' => $arEnum['SORT'], 'PICT' => $arEnum['PREVIEW_PICTURE']);
                 }
             } elseif ($arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
                 if ($bUseHLIblock) {
                     $hlblock = HL\HighloadBlockTable::getList(array("filter" => array("TABLE_NAME" => $arProp["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch();
                     if ($hlblock) {
                         $entity = HL\HighloadBlockTable::compileEntity($hlblock);
                         $entity_data_class = $entity->getDataClass();
                         $rsData = $entity_data_class::getList();
                         while ($arData = $rsData->fetch()) {
                             $arValues[$arData['UF_XML_ID']] = array('ID' => $arData['ID'], 'NAME' => $arData['UF_NAME'], 'SORT' => $arData['UF_SORT'], 'FILE' => $arData['UF_FILE'], 'PICT' => '', 'XML_ID' => $arData['UF_XML_ID']);
                         }
                     }
                 }
             }
             if (!empty($arValues) && is_array($arValues)) {
                 $arRes[$arProp['ID']] = array('ID' => $arProp['ID'], 'CODE' => $arProp['CODE'], 'NAME' => $arProp['NAME'], 'TYPE' => $arProp['PROPERTY_TYPE'], 'ORDER' => array_keys($arValues), 'VALUES' => $arValues, 'SORT' => $arProp['SORT']);
             }
         }
         if ($arProp['PROPERTY_TYPE'] == "S" && is_array($arRes[$arProp['ID']]['VALUES'])) {
             foreach ($arRes[$arProp['ID']]['VALUES'] as $id => $value) {
                 $arTmpFile = \CFile::getFileArray($value["FILE"]);
                 $tmpImg = \CFile::resizeImageGet($arTmpFile, array('width' => 20, 'height' => 20), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                 $arRes[$arProp['ID']]['VALUES'][$id]['PICT'] = $tmpImg['src'];
             }
         }
     }
     return $arRes;
 }
コード例 #10
0
 private function getUserPictureSrc($photoId, $width = 21, $height = 21)
 {
     static $cache = array();
     $photoId = (int) $photoId;
     $key = $photoId . " {$width} {$height}";
     if (isset($cache[$key])) {
         $src = $cache[$key];
     } else {
         $src = false;
         if ($photoId > 0) {
             $imageFile = \CFile::getFileArray($photoId);
             if ($imageFile !== false) {
                 $fileTmp = \CFile::resizeImageGet($imageFile, array("width" => $width, "height" => $height), BX_RESIZE_IMAGE_EXACT, false);
                 $src = $fileTmp["src"];
             }
             $cache[$key] = $src;
         }
     }
     return $src;
 }
コード例 #11
0
ファイル: mailservices.php プロジェクト: webgksupport/alpina
 public static function getIconSrc($serviceName, $iconId = null)
 {
     if ($iconId) {
         $icon = \CFile::getFileArray($iconId);
         return $icon['SRC'];
     } else {
         $icons = array('bitrix24' => '/bitrix/images/mail/mailservice-icon/' . Localization\Loc::getMessage('mail_mailservice_bitrix24_icon'), 'gmail' => '/bitrix/images/mail/mailservice-icon/post-gmail-icon.png', 'icloud' => '/bitrix/images/mail/mailservice-icon/post-icloud-icon.png', 'outlook.com' => '/bitrix/images/mail/mailservice-icon/post-outlook-icon.png', 'office365' => '/bitrix/images/mail/mailservice-icon/post-office360-icon.png', 'yahoo' => '/bitrix/images/mail/mailservice-icon/post-yahoo-icon.png', 'aol' => '/bitrix/images/mail/mailservice-icon/post-aol-icon.png', 'yandex' => '/bitrix/images/mail/mailservice-icon/post-yandex-icon.png', 'mail.ru' => '/bitrix/images/mail/mailservice-icon/post-mail-icon.png', 'ukr.net' => '/bitrix/images/mail/mailservice-icon/post-ukrnet-icon.png', 'exchange' => '/bitrix/images/mail/mailservice-icon/post-exchange-icon.png', 'other' => '/bitrix/images/mail/mailservice-icon/post-imap-icon.png');
         if ($icons[$serviceName]) {
             return $icons[$serviceName];
         }
     }
 }
コード例 #12
0
ファイル: file.php プロジェクト: mrdeadmouse/u136006
 /**
  * Restores file from the version.
  *
  * The method is similar with (@see Bitrix\Disk\File::addVersion()).
  *
  * @param Version $version Version which need to restore.
  * @param int $createdBy Id of user.
  * @return bool
  */
 public function restoreFromVersion(Version $version, $createdBy)
 {
     $this->errorCollection->clear();
     if ($version->getObjectId() != $this->id) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_MODEL_ERROR_COULD_NOT_RESTORE_FROM_ANOTHER_OBJECT'), self::ERROR_COULD_NOT_RESTORE_FROM_OBJECT)));
         return false;
     }
     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
     $forkFileId = \CFile::copyFile($version->getFileId(), true);
     if (!$forkFileId) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_MODEL_ERROR_COULD_NOT_COPY_FILE'), self::ERROR_COULD_NOT_COPY_FILE)));
         return false;
     }
     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
     if ($this->addVersion(\CFile::getFileArray($forkFileId), $createdBy, true) === null) {
         return false;
     }
     return true;
 }
コード例 #13
0
ファイル: class.php プロジェクト: mrdeadmouse/u136006
    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');
    }
コード例 #14
0
ファイル: diskstorage.php プロジェクト: DarneoStudio/bitrix
 /**
  * @param         $name
  * @param         $targetElementId
  * @param TmpFile $tmpFile
  * @param array   $data
  * @return array|bool
  * @throws AccessDeniedException
  */
 public function updateFile($name, $targetElementId, TmpFile $tmpFile, array $data = array())
 {
     /** @var File $file */
     $file = File::loadById($targetElementId);
     if (!$file) {
         $this->errorCollection->add(array(new Error("Could not " . __METHOD__ . " by id {$targetElementId}", 11154)));
         $tmpFile->delete();
         return false;
     }
     if (!$file->canUpdate($this->storage->getCurrentUserSecurityContext())) {
         $tmpFile->delete();
         throw new AccessDeniedException();
     }
     /** @var array $fileArray */
     if ($tmpFile->isCloud() && $tmpFile->getContentType()) {
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         $fileId = \CFile::saveFile(array('name' => $tmpFile->getFilename(), 'tmp_name' => $tmpFile->getAbsolutePath(), 'type' => $tmpFile->getContentType()), Driver::INTERNAL_MODULE_ID, true, true);
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         $fileArray = \CFile::getFileArray($fileId);
         if (!$fileArray) {
             $this->errorCollection->add(array(new Error("Could not " . __METHOD__ . " getFileArray", 1115541)));
             $tmpFile->delete();
             return false;
         }
         if (!empty($data['originalTimestamp'])) {
             $fileArray['UPDATE_TIME'] = DateTime::createFromTimestamp($this->convertFromExternalVersion($data['originalTimestamp']));
         }
         if ($file->addVersion($fileArray, $this->getUser()->getId())) {
             $tmpFile->delete();
             $this->loadFormattedFolderTreeAndBreadcrumbs();
             return $this->formatFileToResponse($file);
         } else {
             \CFile::delete($fileId);
         }
     } else {
         $fileArray = \CFile::makeFileArray($tmpFile->getAbsolutePath());
         if (!$fileArray) {
             $this->errorCollection->add(array(new Error("Could not " . __METHOD__ . " MakeFileArray", 11155)));
             $tmpFile->delete();
             return false;
         }
         if (!empty($data['originalTimestamp'])) {
             $fileArray['UPDATE_TIME'] = DateTime::createFromTimestamp($this->convertFromExternalVersion($data['originalTimestamp']));
         }
         if ($file->uploadVersion($fileArray, $this->getUser()->getId())) {
             $tmpFile->delete();
             $this->loadFormattedFolderTreeAndBreadcrumbs();
             return $this->formatFileToResponse($file);
         }
     }
     $this->errorCollection->add(array(new Error("Could not " . __METHOD__ . ", uploadVersion", 11156)));
     $this->errorCollection->add($file->getErrors());
     $tmpFile->delete();
     return false;
 }