Beispiel #1
0
 protected function processActionSetLiveFeed()
 {
     $this->checkRequiredPostParams(array('iblockId', 'checked'));
     $this->iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id");
     $this->checkPermission();
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $this->iblockId = intval($this->request->getPost('iblockId'));
     if ($this->request->getPost('checked') == 'true') {
         $checked = 1;
     } else {
         $checked = 0;
     }
     CLists::setLiveFeed($checked, $this->iblockId);
     $this->sendJsonSuccessResponse();
 }
Beispiel #2
0
 protected function processActionCompleteWorkflow()
 {
     $this->checkRequiredPostParams(array('workflowId', 'iblockTypeId', 'elementId', 'iblockId', 'sectionId', 'socnetGroupId', 'action'));
     $this->fillDataForCheckPermission();
     $this->checkPermission();
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $workflowId = $this->request->getPost('workflowId');
     $this->elementId = $this->request->getPost('elementId');
     $listError = CLists::completeWorkflow($workflowId, $this->iblockTypeId, $this->elementId, $this->iblockId, $this->request->getPost('action'));
     if (!empty($listError)) {
         $this->errorCollection->add(array(new Error($listError)));
     }
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $this->sendJsonSuccessResponse(array('message' => Loc::getMessage('LISTS_MESSAGE_SUCCESS')));
 }
Beispiel #3
0
 protected function processActionShowProcesses()
 {
     $this->iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id");
     $this->checkPermission();
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $siteDir = '/';
     $siteId = true;
     if ($this->request->getPost('siteDir')) {
         $siteDir = $this->request->getPost('siteDir');
     }
     if ($this->request->getPost('siteId')) {
         $siteId = $this->request->getPost('siteId');
     }
     $path = rtrim($siteDir, '/');
     $listData = array();
     $lists = CIBlock::getList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y", "TYPE" => $this->iblockTypeId, "SITE_ID" => $siteId));
     while ($list = $lists->fetch()) {
         if (CLists::getLiveFeed($list['ID'])) {
             $listData[$list['ID']]['name'] = $list['NAME'];
             $listData[$list['ID']]['url'] = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $list["ID"] . '&element_id=0';
             if ($list['PICTURE'] > 0) {
                 $imageFile = CFile::GetFileArray($list['PICTURE']);
                 if ($imageFile !== false) {
                     $imageFile = CFile::ResizeImageGet($imageFile, array("width" => 36, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false);
                     $listData[$list['ID']]['picture'] = '<img src="' . $imageFile["src"] . '" width="19" height="16" border="0" />';
                 }
             } else {
                 $listData[$list['ID']]['picture'] = '<img src="/bitrix/images/lists/default.png" width="19" height="16" border="0" />';
             }
         }
     }
     if (!empty($listData)) {
         $this->sendJsonSuccessResponse(array('lists' => $listData));
     } else {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_NOT_PROCESSES'))));
         $this->sendJsonErrorResponse();
     }
 }
Beispiel #4
0
 protected function getIblockData()
 {
     $this->arResult['LIST_DATA'] = array();
     $lists = CIBlock::getList(array("SORT" => "ASC", "NAME" => "ASC"), array('ACTIVE' => 'Y', 'ID' => $this->arResult['IBLOCK_ID']));
     while ($list = $lists->fetch()) {
         if (CLists::getLiveFeed($list['ID'])) {
             $this->arResult['LIST_DATA']['ID'] = $list['ID'];
             $this->arResult['LIST_DATA']['NAME'] = $list['NAME'];
             $this->arResult['LIST_DATA']['DESCRIPTION'] = $list['DESCRIPTION'];
             $this->arResult['LIST_DATA']['CODE'] = $list['CODE'];
             if ($list['PICTURE'] > 0) {
                 $imageFile = CFile::GetFileArray($list['PICTURE']);
                 if ($imageFile !== false) {
                     $this->arResult['LIST_DATA']['PICTURE'] = '<img src="' . $imageFile["SRC"] . '" width="36" height="30" border="0" />';
                     $this->arResult['LIST_DATA']['PICTURE_SMALL'] = '<img src="' . $imageFile["SRC"] . '" width="19" height="16" border="0" />';
                 }
             } else {
                 $this->arResult['LIST_DATA']['PICTURE'] = "<img src=\"/bitrix/images/lists/default.png\" width=\"36\" height=\"30\" border=\"0\" />";
                 $this->arResult['LIST_DATA']['PICTURE_SMALL'] = "<img src=\"/bitrix/images/lists/default.png\" width=\"19\" height=\"16\" border=\"0\" />";
             }
         }
     }
 }
Beispiel #5
0
    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;
    }
Beispiel #6
0
	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);
				break;
			case CBPCanUserOperateOperation::StartWorkflow:
				$r = in_array("write", $arAllowableOperations);
				break;
			case CBPCanUserOperateOperation::CreateWorkflow:
				$r = in_array("write", $arAllowableOperations);
				break;
			case CBPCanUserOperateOperation::WriteDocument:
				$r = in_array("write", $arAllowableOperations);
				break;
			case CBPCanUserOperateOperation::ReadDocument:
				$r = false;
				break;
			default:
				$r = false;
		}

		return $r;
	}
Beispiel #7
0
 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;
 }
Beispiel #8
0
    $data["LIST_TEXT_VALUES"] = '';
} else {
    //New one
    $data["ID"] = "";
    $data["SORT"] = 500;
    $data["NAME"] = GetMessage("CC_BLFE_FIELD_NAME_DEFAULT");
    $data["IS_REQUIRED"] = "N";
    $data["MULTIPLE"] = "N";
    list($data["TYPE"], $temp) = each($arResult["TYPES"]);
    reset($arResult["TYPES"]);
    $arResult["LIST"] = false;
    $data["LIST_TEXT_VALUES"] = '';
    $arResult["LIST_DEF"] = false;
}
if (preg_match("/^(G|G:|E|E:)/", $data["TYPE"])) {
    $arResult["LINK_IBLOCKS"] = CLists::GetIBlocks($arParams["~IBLOCK_TYPE_ID"], !$arParams["CAN_EDIT"], $arParams["~SOCNET_GROUP_ID"]);
    if (substr($data["TYPE"], 0, 1) == "G") {
        unset($arResult["LINK_IBLOCKS"][$arResult["IBLOCK_ID"]]);
    }
}
$arResult["FORM_DATA"] = array();
foreach ($data as $key => $value) {
    $arResult["FORM_DATA"]["~" . $key] = $value;
    if (is_array($value)) {
        foreach ($value as $key1 => $value1) {
            $value[$key1] = htmlspecialcharsbx($value1);
        }
        $arResult["FORM_DATA"][$key] = $value;
    } else {
        $arResult["FORM_DATA"][$key] = htmlspecialcharsbx($value);
    }
Beispiel #9
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("lists") || !CModule::IncludeModule("iblock")) {
    return;
}
CLists::SetPermission('lists', array(1, WIZARD_PORTAL_ADMINISTRATION_GROUP));
CLists::SetPermission('bitrix_processes', array(1, WIZARD_PORTAL_ADMINISTRATION_GROUP));
COption::SetOptionString("lists", "turnProcessesOn", "Y");
COption::SetOptionString("lists", "livefeed_url", "/services/processes/");
COption::SetOptionString("lists", "livefeed_iblock_type_id", "bitrix_processes");
\Bitrix\Lists\Importer::installProcesses(LANGUAGE_ID);
COption::SetOptionString("lists", "socnet_iblock_type_id", "lists_socnet");
CLists::EnableSocnet(true);
Beispiel #10
0
     $permissions['new'] = GetMessage("CC_BLL_TITLE_NEW_LIST");
     $permissions['market'] = GetMessage("CC_BLL_TITLE_MARKETPLACE_NEW");
     $permissions['settings'] = GetMessage("CC_BLL_TITLE_SETTINGS");
     $admin = true;
 } elseif ($listsPerm >= CListPermissions::CAN_READ) {
     $permissions['market'] = GetMessage("CC_BLL_TITLE_MARKETPLACE_NEW");
     $permissions['settings'] = GetMessage("CC_BLL_TITLE_SETTINGS");
 }
 $listData = array();
 $siteId = true;
 if ($_POST['siteId']) {
     $siteId = $_POST['siteId'];
 }
 $lists = CIBlock::getList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y", "TYPE" => COption::GetOptionString("lists", "livefeed_iblock_type_id"), 'SITE_ID' => $siteId));
 while ($list = $lists->fetch()) {
     if (CLists::getLiveFeed($list['ID'])) {
         $listData[$list['ID']]['ID'] = $list['ID'];
         $shortName = substr($list['NAME'], 0, 50);
         if ($shortName == $list['NAME']) {
             $listData[$list['ID']]['NAME'] = $list['NAME'];
         } else {
             $listData[$list['ID']]['NAME'] = $shortName . '...';
         }
         $listData[$list['ID']]['DESCRIPTION'] = $list['DESCRIPTION'];
         $listData[$list['ID']]['CODE'] = $list['CODE'];
         if ($list['PICTURE'] > 0) {
             $imageFile = CFile::GetFileArray($list['PICTURE']);
             if ($imageFile !== false) {
                 $listData[$list['ID']]['PICTURE'] = '<img src="' . $imageFile["SRC"] . '" width="36" height="30" border="0" />';
                 $listData[$list['ID']]['PICTURE_SMALL'] = '<img src="' . $imageFile["SRC"] . '" width="19" height="16" border="0" />';
             }
Beispiel #11
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("lists")) {
    return;
}
include dirname(__FILE__) . "/../iblock/lists-clients.php";
CLists::SetPermission('lists', array(1));
Beispiel #12
0
 public static function OnSharepointCheckAccess($iblock_id)
 {
     global $USER;
     $arIBlock = CIBlock::GetArrayByID($iblock_id);
     if ($arIBlock) {
         //Check if iblock is list
         $arListsPerm = CLists::GetPermission($arIBlock["IBLOCK_TYPE_ID"]);
         if (count($arListsPerm)) {
             //User groups
             $arUserGroups = $USER->GetUserGroupArray();
             //One of lists admins
             if (count(array_intersect($arListsPerm, $arUserGroups))) {
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
Beispiel #13
0
 function installDemoData()
 {
     if (!CModule::IncludeModule("iblock")) {
         return;
     }
     $currentPermissions = CLists::GetPermission();
     unset($currentPermissions["bitrix_processes"]);
     unset($currentPermissions["lists"]);
     $socnet_iblock_type_id = COption::GetOptionString("lists", "socnet_iblock_type_id");
     $isSocnetInstalled = IsModuleInstalled('socialnetwork');
     $arTypes = array();
     if (empty($currentPermissions)) {
         $arTypes[] = array("ID" => "lists", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 80, "LANG" => array());
         $arTypes[] = array("ID" => "bitrix_processes", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 90, "LANG" => array());
     }
     if ($isSocnetInstalled && strlen($socnet_iblock_type_id) <= 0) {
         $arTypes[] = array("ID" => "lists_socnet", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 83, "LANG" => array());
     }
     $arLanguages = array();
     if (!empty($arTypes)) {
         $rsLanguage = CLanguage::GetList($by, $order, array());
         while ($arLanguage = $rsLanguage->Fetch()) {
             $arLanguages[] = $arLanguage["LID"];
         }
     }
     foreach ($arTypes as $arType) {
         $dbType = CIBlockType::GetList(array(), array("=ID" => $arType["ID"]));
         if (!$dbType->Fetch()) {
             foreach ($arLanguages as $languageID) {
                 IncludeModuleLangFile(__FILE__, $languageID);
                 $code = strtoupper($arType["ID"]);
                 $arType["LANG"][$languageID]["NAME"] = GetMessage($code . "_TYPE_NAME");
                 $arType["LANG"][$languageID]["ELEMENT_NAME"] = GetMessage($code . "_ELEMENT_NAME");
                 if ($arType["SECTIONS"] == "Y") {
                     $arType["LANG"][$languageID]["SECTION_NAME"] = GetMessage($code . "_SECTION_NAME");
                 }
             }
             $iblockType = new CIBlockType();
             $iblockType->Add($arType);
         }
     }
     if (empty($currentPermissions)) {
         CLists::SetPermission('lists', array(1));
         CLists::SetPermission('bitrix_processes', array(1));
     }
     $defaultSiteId = CSite::GetDefSite();
     $siteObject = CSite::GetByID($defaultSiteId);
     $site = $siteObject->fetch();
     $defaultLang = $site ? $site['LANGUAGE_ID'] : 'en';
     if ($defaultLang == 'ua') {
         $defaultLang = 'ru';
     }
     \Bitrix\Lists\Importer::installProcesses($defaultLang);
     if (IsModuleInstalled("bitrix24")) {
         \Bitrix\Main\Config\Option::set("lists", "livefeed_url", "/company/processes/");
     } else {
         \Bitrix\Main\Config\Option::set("lists", "livefeed_url", "/services/processes/");
     }
     if ($isSocnetInstalled && strlen($socnet_iblock_type_id) <= 0) {
         COption::SetOptionString("lists", "socnet_iblock_type_id", "lists_socnet");
         CLists::EnableSocnet(true);
     }
 }
     } elseif (($ID <= 0 || $bCopy) && !CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, 0, "iblock_admin_display")) {
         $bBadBlock = true;
     } elseif (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit")) {
         $bBadBlock = false;
     } elseif ($bWorkflow && ($WF == "Y" || $view == "Y")) {
         $bBadBlock = false;
     } elseif ($bBizproc) {
         $bBadBlock = false;
     } elseif (($ID <= 0 || $bCopy) && CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, 0, "section_element_bind")) {
         $bBadBlock = false;
     }
     //This is temporary permissions check
     //will b removed ASAP
     if ($bBadBlock && CModule::IncludeModule('lists')) {
         //Find out if there is some groups to edit lists (so it's lists)
         $arListsPerm = CLists::GetPermission($arIBlock["IBLOCK_TYPE_ID"]);
         if (count($arListsPerm)) {
             if (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_read")) {
                 $bBadBlock = false;
             } else {
                 //Check permissions for add or edit iblock
                 $arUserGroups = $USER->GetUserGroupArray();
                 if (count(array_intersect($arListsPerm, $arUserGroups))) {
                     $bBadBlock = false;
                 }
             }
         }
     }
 }
 if ($bBadBlock) {
     $error = new _CIBlockError(1, "BAD_IBLOCK", GetMessage("IBLOCK_BAD_IBLOCK"));
Beispiel #15
0
 public static function Add($iblock_id, $arFields)
 {
     if ($iblock_id > 0) {
         $property_id = intval($arFields["ID"]);
         if ($property_id > 0) {
             return new CListPropertyField($iblock_id, "PROPERTY_" . $property_id, $arFields["NAME"], $arFields["SORT"]);
         } else {
             $arFields["IBLOCK_ID"] = $iblock_id;
             if (strpos($arFields["TYPE"], ":") !== false) {
                 list($arFields["PROPERTY_TYPE"], $arFields["USER_TYPE"]) = explode(":", $arFields["TYPE"]);
             } else {
                 $arFields["PROPERTY_TYPE"] = $arFields["TYPE"];
             }
             $arFields["MULTIPLE_CNT"] = 1;
             $arFields["CHECK_PERMISSIONS"] = "N";
             $arFields["CODE"] = $arFields["CODE"] ? $arFields["CODE"] : CLists::generateMnemonicCode();
             $obProperty = new CIBlockProperty();
             $res = $obProperty->Add($arFields);
             if ($res) {
                 self::resetPropertyArrayCache();
                 if ($arFields["PROPERTY_TYPE"] == "L" && is_array($arFields["LIST"])) {
                     CList::UpdatePropertyList($res, $arFields["LIST"]);
                 }
                 return new CListPropertyField($iblock_id, "PROPERTY_" . $res, $arFields["NAME"], $arFields["SORT"]);
             }
         }
     }
     return null;
 }
Beispiel #16
0
 public static function migrateList($id)
 {
     $id = intval($id);
     if ($id <= 0) {
         throw new Main\ArgumentNullException("id");
     }
     $db = \CIBlock::GetList(array(), array("ID" => $id, "IBLOCK_TYPE_ID" => "lists", "CHECK_PERMISSIONS" => "N"));
     $iblock = $db->Fetch();
     if (!$iblock) {
         throw new Main\ArgumentOutOfRangeException("id");
     }
     $iblockType = static::getIBlockType();
     $ob = new \CIBlock();
     $res = $ob->Update($id, array("IBLOCK_TYPE_ID" => $iblockType));
     if ($res) {
         \CLists::setLiveFeed(1, $id);
     }
     \CBPDocument::MigrateDocumentType(array("lists", 'Bitrix\\Lists\\BizprocDocumentLists', "iblock_" . $id), array("lists", "BizprocDocument", "iblock_" . $id));
 }
Beispiel #17
0
         $arResult["HIGHLIGHT"] = array("groups" => array("disabled" => true));
     }
 } else {
     if ($arParams["SOCNET_GROUP_ID"]) {
         $arResult["HIGHLIGHT"] = array("socnetgroup" => array("group_id" => $arParams["SOCNET_GROUP_ID"]));
     } else {
         $arResult["HIGHLIGHT"] = null;
     }
 }
 if ($arResult["ELEMENT_ID"]) {
     $obRights = new CIBlockElementRights($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"]);
 } else {
     $obRights = new CIBlockSectionRights($arResult["IBLOCK_ID"], intval($data["IBLOCK_SECTION_ID"]));
 }
 $arResult["RIGHTS"] = $obRights->GetRights(array("parents" => array($data["IBLOCK_SECTION_ID"])));
 $arListsPerm = CLists::GetPermission($arParams["~IBLOCK_TYPE_ID"]);
 foreach ($arResult["RIGHTS"] as $RIGHT_ID => $arRight) {
     //1) protect groups from module settings
     $match = array();
     if (preg_match("/^G(\\d)\$/", $arRight["GROUP_CODE"], $match) && is_array($arListsPerm) && in_array($match[1], $arListsPerm)) {
         unset($arResult["RIGHTS"][$RIGHT_ID]);
         $arResult["SELECTED"][$arRight["GROUP_CODE"]] = true;
     } 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;
             }
Beispiel #18
0
	function installDemoData()
	{
		if(!CModule::IncludeModule("iblock"))
			return;

		$currentPermissions = CLists::GetPermission();
		$socnet_iblock_type_id = COption::GetOptionString("lists", "socnet_iblock_type_id");
		$isSocnetInstalled = IsModuleInstalled('socialnetwork');

		$arTypes = array();
		if (empty($currentPermissions))
		{
			$arTypes[] = array(
				"ID" => "lists",
				"SECTIONS" => "Y",
				"IN_RSS" => "N",
				"SORT" => 80,
				"LANG" => array(),
			);
		}

		if ($isSocnetInstalled && strlen($socnet_iblock_type_id) <= 0)
		{
			$arTypes[] = array(
				"ID" => "lists_socnet",
				"SECTIONS" => "Y",
				"IN_RSS" => "N",
				"SORT" => 83,
				"LANG" => array(),
			);
		}

		$arLanguages = array();
		if (!empty($arTypes))
		{
			$rsLanguage = CLanguage::GetList($by, $order, array());
			while ($arLanguage = $rsLanguage->Fetch())
			{
				$arLanguages[] = $arLanguage["LID"];
			}
		}

		foreach ($arTypes as $arType)
		{
			$dbType = CIBlockType::GetList(array(), array("=ID" => $arType["ID"]));
			if (!$dbType->Fetch())
			{
				foreach($arLanguages as $languageID)
				{
					IncludeModuleLangFile(__FILE__, $languageID);
					$code = strtoupper($arType["ID"]);
					$arType["LANG"][$languageID]["NAME"] = GetMessage($code."_TYPE_NAME");
					$arType["LANG"][$languageID]["ELEMENT_NAME"] = GetMessage($code."_ELEMENT_NAME");
					if ($arType["SECTIONS"] == "Y")
						$arType["LANG"][$languageID]["SECTION_NAME"] = GetMessage($code."_SECTION_NAME");
				}
				$iblockType = new CIBlockType;
				$iblockType->Add($arType);
			}
		}

		if (empty($currentPermissions))
		{
			CLists::SetPermission('lists', array(1));
		}

		if ($isSocnetInstalled && strlen($socnet_iblock_type_id) <= 0)
		{
			COption::SetOptionString("lists", "socnet_iblock_type_id", "lists_socnet");
			CLists::EnableSocnet(true);
		}
	}
Beispiel #19
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("lists")) {
    return;
}
$strSelectedType = $arCurrentValues["IBLOCK_TYPE_ID"];
$arTypes = array();
$rsTypes = CLists::GetIBlockTypes();
while ($ar = $rsTypes->Fetch()) {
    $arTypes[$ar["IBLOCK_TYPE_ID"]] = "[" . $ar["IBLOCK_TYPE_ID"] . "] " . $ar["NAME"];
    if (!$strSelectedType) {
        $strSelectedType = $ar["IBLOCK_TYPE_ID"];
    }
}
$arIBlocks = array();
$rsIBlocks = CIBlock::GetList(array("sort" => "asc"), array("TYPE" => $strSelectedType, "ACTIVE" => "Y"));
while ($ar = $rsIBlocks->Fetch()) {
    $arIBlocks[$ar["ID"]] = "[" . $ar["ID"] . "] " . $ar["NAME"];
}
$arComponentParameters = array("GROUPS" => array(), "PARAMETERS" => array("IBLOCK_TYPE_ID" => array("PARENT" => "DATA_SOURCE", "NAME" => GetMessage("CP_BLFE_IBLOCK_TYPE_ID"), "TYPE" => "LIST", "VALUES" => $arTypes, "DEFAULT" => "lists"), "IBLOCK_ID" => array("PARENT" => "DATA_SOURCE", "NAME" => GetMessage("CP_BLFE_IBLOCK_ID"), "TYPE" => "LIST", "VALUES" => $arIBlocks, "ADDITIONAL_VALUES" => "Y", "DEFAULT" => '={$_REQUEST["list_id"]}'), "FIELD_ID" => array("PARENT" => "DATA_SOURCE", "NAME" => GetMessage("CP_BLFE_FIELD_ID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["field_id"]}'), "LISTS_URL" => CListsParameters::GetPathTemplateParam("LISTS", "LISTS_URL", GetMessage("CP_BLFE_LISTS_URL"), "lists.lists.php", "URL_TEMPLATES"), "LIST_URL" => CListsParameters::GetPathTemplateParam("LIST", "LIST_URL", GetMessage("CP_BLFE_LIST_URL"), "lists.list.php?list_id=#list_id#", "URL_TEMPLATES"), "LIST_EDIT_URL" => CListsParameters::GetPathTemplateParam("LIST", "LIST_EDIT_URL", GetMessage("CP_BLFE_LIST_EDIT_URL"), "lists.list.edit.php?list_id=#list_id#", "URL_TEMPLATES"), "LIST_FIELDS_URL" => CListsParameters::GetPathTemplateParam("LIST", "LIST_FIELDS_URL", GetMessage("CP_BLFE_LIST_FIELDS_URL"), "lists.fields.php?list_id=#list_id#", "URL_TEMPLATES"), "LIST_FIELD_EDIT_URL" => CListsParameters::GetPathTemplateParam("LIST", "LIST_FIELD_EDIT_URL", GetMessage("CP_BLFE_LIST_FIELD_EDIT_URL"), "lists.field.edit.php?list_id=#list_id#&field_id=#field_id#", "URL_TEMPLATES"), "CACHE_TIME" => array("DEFAULT" => 3600)));
Beispiel #20
0
    ?>
		<tr>
			<td colspan="2" style="border:none">
			<input type="button" value="<?php 
    echo GetMessage("LISTS_OPTIONS_ADD_RIGHT");
    ?>
" onClick="addNewTableRow('tblRIGHTS', /right\[(n)([0-9]*)\]/g, 2)">
			</td>
		</tr>
		</table>
		</td>
	</tr>
	<?php 
    if (IsModuleInstalled('socialnetwork')) {
        $socnet_iblock_type_id = COption::GetOptionString("lists", "socnet_iblock_type_id");
        $socnet_enable = CLists::IsEnabledSocnet();
        $tabControl->BeginNextTab();
        ?>
	<tr>
		<td width="40%"><?php 
        echo GetMessage("LISTS_OPTIONS_SOCNET_ENABLE");
        ?>
:</td>
		<td width="60%"><input type="checkbox" name="socnet_enable" <?php 
        if ($socnet_enable) {
            echo "checked";
        }
        ?>
 value="Y"></td>
	</tr>
	<tr>
Beispiel #21
0
 function CanUserOperateDocumentType($operation, $userId, $documentType, $parameters = array())
 {
     $documentType = trim($documentType);
     if (strlen($documentType) <= 0) {
         return false;
     }
     $parameters["IBlockId"] = intval(substr($documentType, strlen("iblock_")));
     $parameters['sectionId'] = !empty($parameters['sectionId']) ? (int) $parameters['sectionId'] : 0;
     if (!array_key_exists("IBlockRightsMode", $parameters)) {
         $parameters["IBlockRightsMode"] = CIBlock::getArrayByID($parameters["IBlockId"], "RIGHTS_MODE");
     }
     if ($parameters["IBlockRightsMode"] === "E") {
         if ($operation === CBPCanUserOperateOperation::CreateWorkflow) {
             return CIBlockRights::userHasRightTo($parameters["IBlockId"], $parameters["IBlockId"], "iblock_rights_edit");
         } elseif ($operation === CBPCanUserOperateOperation::WriteDocument) {
             return CIBlockSectionRights::userHasRightTo($parameters["IBlockId"], $parameters["sectionId"], "section_element_bind");
         } elseif ($operation === CBPCanUserOperateOperation::ViewWorkflow || $operation === CBPCanUserOperateOperation::StartWorkflow) {
             if (!array_key_exists("WorkflowId", $parameters)) {
                 return false;
             }
             if ($operation === CBPCanUserOperateOperation::ViewWorkflow) {
                 return CIBlockRights::userHasRightTo($parameters["IBlockId"], 0, "element_read");
             }
             if ($operation === CBPCanUserOperateOperation::StartWorkflow) {
                 return CIBlockSectionRights::userHasRightTo($parameters["IBlockId"], $parameters['sectionId'], "section_element_bind");
             }
             $userId = intval($userId);
             if (!array_key_exists("AllUserGroups", $parameters)) {
                 if (!array_key_exists("UserGroups", $parameters)) {
                     $parameters["UserGroups"] = CUser::getUserGroup($userId);
                 }
                 $parameters["AllUserGroups"] = $parameters["UserGroups"];
                 $parameters["AllUserGroups"][] = "Author";
             }
             if (!array_key_exists("DocumentStates", $parameters)) {
                 if ($operation === CBPCanUserOperateOperation::StartWorkflow) {
                     $parameters["DocumentStates"] = CBPWorkflowTemplateLoader::getDocumentTypeStates(array("lists", get_called_class(), "iblock_" . $parameters["IBlockId"]));
                 } else {
                     $parameters["DocumentStates"] = CBPDocument::getDocumentStates(array("lists", get_called_class(), "iblock_" . $parameters["IBlockId"]), null);
                 }
             }
             if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"])) {
                 $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]);
             } else {
                 return false;
             }
             $allowableOperations = CBPDocument::getAllowableOperations($userId, $parameters["AllUserGroups"], $parameters["DocumentStates"], true);
             if (!is_array($allowableOperations)) {
                 return false;
             }
             if ($operation === CBPCanUserOperateOperation::ViewWorkflow && in_array("read", $allowableOperations) || $operation === CBPCanUserOperateOperation::StartWorkflow && in_array("write", $allowableOperations)) {
                 return true;
             }
             $chop = $operation === CBPCanUserOperateOperation::ViewWorkflow ? "element_read" : "section_element_bind";
             $tasks = self::getRightsTasks();
             foreach ($allowableOperations as $op) {
                 if (isset($tasks[$op])) {
                     $op = $tasks[$op]['ID'];
                 }
                 $ar = CTask::getOperations($op, true);
                 if (in_array($chop, $ar)) {
                     return true;
                 }
             }
         }
         return false;
     }
     if (!array_key_exists("IBlockPermission", $parameters)) {
         if (CModule::includeModule('lists')) {
             $parameters["IBlockPermission"] = CLists::getIBlockPermission($parameters["IBlockId"], $userId);
         } else {
             $parameters["IBlockPermission"] = CIBlock::getPermission($parameters["IBlockId"], $userId);
         }
     }
     if ($parameters["IBlockPermission"] <= "R") {
         return false;
     } elseif ($parameters["IBlockPermission"] >= "W") {
         return true;
     }
     $userId = intval($userId);
     if (!array_key_exists("AllUserGroups", $parameters)) {
         if (!array_key_exists("UserGroups", $parameters)) {
             $parameters["UserGroups"] = CUser::getUserGroup($userId);
         }
         $parameters["AllUserGroups"] = $parameters["UserGroups"];
         $parameters["AllUserGroups"][] = "Author";
     }
     if (!array_key_exists("DocumentStates", $parameters)) {
         $parameters["DocumentStates"] = CBPDocument::getDocumentStates(array("lists", get_called_class(), "iblock_" . $parameters["IBlockId"]), null);
     }
     if (array_key_exists("WorkflowId", $parameters)) {
         if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"])) {
             $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]);
         } else {
             return false;
         }
     }
     $allowableOperations = CBPDocument::getAllowableOperations($userId, $parameters["AllUserGroups"], $parameters["DocumentStates"]);
     if (!is_array($allowableOperations)) {
         return false;
     }
     $r = false;
     switch ($operation) {
         case CBPCanUserOperateOperation::ViewWorkflow:
             $r = in_array("read", $allowableOperations);
             break;
         case CBPCanUserOperateOperation::StartWorkflow:
             $r = in_array("write", $allowableOperations);
             break;
         case CBPCanUserOperateOperation::CreateWorkflow:
             $r = in_array("write", $allowableOperations);
             break;
         case CBPCanUserOperateOperation::WriteDocument:
             $r = in_array("write", $allowableOperations);
             break;
         case CBPCanUserOperateOperation::ReadDocument:
             $r = false;
             break;
         default:
             $r = false;
     }
     return $r;
 }
Beispiel #22
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$defaultImg = "<img src=\"/bitrix/images/lists/nopic_list_150.png\" width=\"36\" height=\"30\" border=\"0\" alt=\"\" />";
if ($arParams["IBLOCK_TYPE_ID"] == COption::GetOptionString("lists", "livefeed_iblock_type_id")) {
    $defaultImg = "<img src=\"/bitrix/images/lists/default.png\" width=\"36\" height=\"30\" border=\"0\" alt=\"\" />";
}
foreach ($arResult["ITEMS"] as $key => $item) {
    if ($item["PICTURE"] > 0) {
        $imageFile = CFile::GetFileArray($item["PICTURE"]);
        if ($imageFile !== false) {
            $imageFile = CFile::ResizeImageGet($imageFile, array("width" => 36, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false);
            $arResult["ITEMS"][$key]["IMAGE"] = '<img src="' . $imageFile["src"] . '" width="36" height="30" border="0" />';
        }
    }
    if (!$arResult["ITEMS"][$key]["IMAGE"]) {
        $arResult["ITEMS"][$key]["IMAGE"] = $defaultImg;
    }
    if ($arParams["IBLOCK_TYPE_ID"] == COption::GetOptionString("lists", "livefeed_iblock_type_id")) {
        $arResult["ITEMS"][$key]["SHOW_LIVE_FEED"] = CLists::getLiveFeed($item['ID']);
    }
}