当前位置: 首页>>代码示例>>PHP>>正文


PHP CSocNetFeaturesPerms::GetOperationPerm方法代码示例

本文整理汇总了PHP中CSocNetFeaturesPerms::GetOperationPerm方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetFeaturesPerms::GetOperationPerm方法的具体用法?PHP CSocNetFeaturesPerms::GetOperationPerm怎么用?PHP CSocNetFeaturesPerms::GetOperationPerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSocNetFeaturesPerms的用法示例。


在下文中一共展示了CSocNetFeaturesPerms::GetOperationPerm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SetForSonet

 function SetForSonet($logID, $entity_type, $entity_id, $feature, $operation, $bNew = false)
 {
     $bFlag = true;
     if (!$bNew) {
         $rsRights = CSocNetLogRights::GetList(array(), array("LOG_ID" => $logID));
         if ($arRights = $rsRights->Fetch()) {
             $bFlag = false;
         }
     }
     if ($bFlag) {
         $bExtranet = false;
         $perm = CSocNetFeaturesPerms::GetOperationPerm($entity_type, $entity_id, $feature, $operation);
         if ($perm) {
             if (CModule::IncludeModule("extranet") && ($extranet_site_id = CExtranet::GetExtranetSiteID())) {
                 $arLogSites = array();
                 $rsLogSite = CSocNetLog::GetSite($logID);
                 while ($arLogSite = $rsLogSite->Fetch()) {
                     $arLogSites[] = $arLogSite["LID"];
                 }
                 if (in_array($extranet_site_id, $arLogSites)) {
                     $bExtranet = true;
                 }
             }
             if ($bExtranet) {
                 if ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_OWNER) {
                     CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER));
                 } elseif ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_MODERATOR) {
                     CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_MODERATOR));
                 } elseif ($entity_type == SONET_ENTITY_GROUP && in_array($perm, array(SONET_ROLES_USER, SONET_ROLES_AUTHORIZED, SONET_ROLES_ALL))) {
                     CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_MODERATOR, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_USER));
                 } elseif ($entity_type == SONET_ENTITY_USER && $perm == SONET_RELATIONS_TYPE_NONE) {
                     CSocNetLogRights::Add($logID, array("SA", "U" . $entity_id));
                 } elseif ($entity_type == SONET_ENTITY_USER && in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS, SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_AUTHORIZED, SONET_RELATIONS_TYPE_ALL))) {
                     $arCode = array("SA");
                     $arLog = CSocNetLog::GetByID($logID);
                     if ($arLog) {
                         $dbUsersInGroup = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $arLog["USER_ID"], "<=ROLE" => SONET_ROLES_USER, "GROUP_SITE_ID" => $extranet_site_id, "GROUP_ACTIVE" => "Y"), false, false, array("ID", "GROUP_ID"));
                         while ($arUsersInGroup = $dbUsersInGroup->Fetch()) {
                             if (!in_array("S" . SONET_ENTITY_GROUP . $arUsersInGroup["GROUP_ID"] . "_" . SONET_ROLES_USER, $arCode)) {
                                 $arCode = array_merge($arCode, array("S" . SONET_ENTITY_GROUP . $arUsersInGroup["GROUP_ID"] . "_" . SONET_ROLES_OWNER, "S" . SONET_ENTITY_GROUP . $arUsersInGroup["GROUP_ID"] . "_" . SONET_ROLES_MODERATOR, "S" . SONET_ENTITY_GROUP . $arUsersInGroup["GROUP_ID"] . "_" . SONET_ROLES_USER));
                             }
                         }
                         CSocNetLogRights::Add($logID, $arCode);
                     }
                 }
             } else {
                 if ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_OWNER) {
                     CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER));
                 } elseif ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_MODERATOR) {
                     CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_MODERATOR));
                 } elseif ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_USER) {
                     CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_MODERATOR, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_USER));
                 } elseif ($entity_type == SONET_ENTITY_USER && in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS, SONET_RELATIONS_TYPE_FRIENDS2))) {
                     $arCodes = array("SA", "U" . $entity_id, "S" . $entity_type . $entity_id . "_" . SONET_RELATIONS_TYPE_FRIENDS);
                     if ($perm == SONET_RELATIONS_TYPE_FRIENDS2) {
                         $arCodes[] = "S" . $entity_type . $entity_id . "_" . SONET_RELATIONS_TYPE_FRIENDS2;
                     }
                     CSocNetLogRights::Add($logID, $arCodes);
                 } elseif ($entity_type == SONET_ENTITY_USER && $perm == SONET_RELATIONS_TYPE_NONE) {
                     CSocNetLogRights::Add($logID, array("SA", "U" . $entity_id));
                 } elseif ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_AUTHORIZED) {
                     CSocNetLogRights::Add($logID, array("SA", "S" . $entity_type . $entity_id, "AU"));
                 } elseif ($entity_type == SONET_ENTITY_USER && $perm == SONET_RELATIONS_TYPE_AUTHORIZED) {
                     CSocNetLogRights::Add($logID, array("SA", "AU"));
                 } elseif ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_ALL) {
                     CSocNetLogRights::Add($logID, array("SA", "S" . $entity_type . $entity_id, "G2"));
                 } elseif ($entity_type == SONET_ENTITY_USER && $perm == SONET_RELATIONS_TYPE_ALL) {
                     CSocNetLogRights::Add($logID, array("SA", "G2"));
                 }
             }
         }
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:73,代码来源:log_rights.php

示例2: GroupERights

 static function GroupERights($iblockID)
 {
     if (CIBlock::GetArrayByID($iblockID, "RIGHTS_MODE") === "E") {
         return;
     }
     $arGroups = self::GetGroups($iblockID);
     foreach ($arGroups as $groupID => $group) {
         foreach (self::$ops as $op => $opTrans) {
             $arGroups[$groupID]["Operations"][$op] = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $groupID, 'files', $op);
         }
     }
     $arTasks = CWebDavIblock::GetTasks();
     // set e rights
     $arFields = array('RIGHTS_MODE' => 'E', 'GROUP_ID' => array());
     $ib = new CIBlock();
     $res = $ib->Update($iblockID, $arFields);
     $ibr = new CIBlockRights($iblockID);
     $rights = array();
     $rights['n0'] = array('GROUP_CODE' => 'G1', 'DO_CLEAN' => 'Y', 'TASK_ID' => $arTasks['X']);
     // admins
     $rights['n1'] = array('GROUP_CODE' => 'G2', 'DO_CLEAN' => 'Y', 'TASK_ID' => $arTasks['D']);
     // nobody
     $ibr->SetRights($rights);
     foreach ($arGroups as $groupID => $group) {
         $sectionID = $group['SECTION'];
         $ibrs = new CIBlockSectionRights($iblockID, $sectionID);
         $rights = array();
         $i = 0;
         foreach ($group["Operations"] as $op => $subj) {
             //			  'Operations' =>
             //				array
             //				  'view' => string 'A' (length=1)
             //				  'write_limited' => string 'Z' (length=1)
             //				  'bizproc' => null
             //				  'write' => string 'Z' (length=1)
             //
             //			A>Только владелец группы
             //			E>Владелец группы и модераторы группы
             //			K>Все члены группы
             //			L>Авторизованные пользователи
             //			N>Все посетители
             if ($subj) {
                 if ($subj == "N") {
                     $sSubj = "G2";
                 } elseif ($subj == "L") {
                     $sSubj = "AU";
                 } else {
                     $sSubj = "SG{$groupID}_{$subj}";
                 }
                 $rights[$sSubj] = $arTasks[self::$ops[$op]];
                 if (self::$ops[$op] == 'E') {
                     $rights["CR"] = $arTasks['W'];
                 }
             }
         }
         $rights["SG{$groupID}_A"] = $arTasks["X"];
         // admin of group
         $arRights = array();
         $i = 0;
         foreach ($rights as $subj => $task) {
             $arRights['n' . $i++] = array('GROUP_CODE' => $subj, 'TASK_ID' => $task, 'DO_CLEAN' => 'NOT');
         }
         $ibrs->SetRights($arRights);
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:65,代码来源:iblocksocnet.php

示例3: GetSocNetUserPerms


//.........这里部分代码省略.........
				}
				$BLOG_POST["UAC_CACHE_".$userId] = $arEntities;
			}

			if(!empty($arEntities["DR"]) && !empty($arPerms["DR"]))
			{
				foreach($arPerms["DR"] as $id => $val)
				{
					if(isset($arEntities["DR"]["DR".$id]))
					{
						$perms = BLOG_PERMS_READ;
						break;
					}
				}
			}
			if((!empty($arPerms["U"][$userId]) && in_array("US".$userId, $arPerms["U"][$userId])) || ($authorId >0 && $userId == $authorId)) // if author
				$perms = BLOG_PERMS_FULL;
			else
			{
				if($authorId <= 0)
				{
					foreach($arPerms["U"] as $id => $p)
					{
						if(in_array("US".$id, $p))
						{
							$authorId = $id;
							break;
						}
					}
				}

				if(!empty($arPerms["U"][$userId]) || (!empty($arPerms["U"][$authorId]) && in_array("US".$authorId, $arPerms["U"][$authorId])) || $perms == BLOG_PERMS_READ)
				{
					if (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "write_comment"))
						$perms = BLOG_PERMS_WRITE;
					elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "premoderate_comment"))
						$perms = BLOG_PERMS_PREMODERATE;
					elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "view_comment"))
						$perms = BLOG_PERMS_READ;
				}
			}

			if($perms <= BLOG_PERMS_FULL)
			{
				$arGroupsId = Array();

				if(!empty($arPerms["SG"]))
				{
					foreach($arPerms["SG"] as $gid => $val)
					{
						//if(!empty($arEntities["SG"][$gid]))
						$arGroupsId[] = $gid;
					}
					$operation = Array("full_comment", "moderate_comment", "write_comment", "premoderate_comment");
					if($perms < BLOG_PERMS_READ)
						$operation[] = "view_comment";
				}

				if(!empty($arGroupsId))
				{
					foreach($operation as $v)
					{
						if($perms <= BLOG_PERMS_READ)
						{
							$f = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arGroupsId, "blog", $v);
							if(!empty($f))
							{
								foreach($f as $gid => $val)
								{
									if((!empty($arEntities["SG"][$gid]) && in_array($val, $arEntities["SG"][$gid])) || $val == SONET_ROLES_ALL || ($userId > 0 && $val == SONET_ROLES_AUTHORIZED))
									{
										switch($v)
										{
											case "full_comment":
												$perms = BLOG_PERMS_FULL;
												break;
											case "moderate_comment":
												$perms = BLOG_PERMS_MODERATE;
												break;
											case "write_comment":
												$perms = BLOG_PERMS_WRITE;
												break;
											case "premoderate_comment":
												$perms = BLOG_PERMS_PREMODERATE;
												break;
											case "view_comment":
												$perms = BLOG_PERMS_READ;
												break;
										}
									}
								}
							}
						}
					}
				}
			}
		}

		return $perms;
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:101,代码来源:blog_comment.php

示例4: PostIntoBuzzAsBlog

 public static function PostIntoBuzzAsBlog($userTwit, $arSiteId = array(), $userLogin = '')
 {
     global $DB;
     if (!CModule::IncludeModule("blog")) {
         return;
     }
     $arParams = array();
     if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME') && $userLogin != '') {
         if ($arUserTwit = unserialize(base64_decode($userTwit))) {
             $userTwit = $arUserTwit;
         }
         if ($arSiteIdCheck = unserialize(base64_decode($arSiteId))) {
             $arSiteId = $arSiteIdCheck;
         }
         $dbUser = CUser::GetByLogin($userLogin);
         if ($arUser = $dbUser->Fetch()) {
             $arParams["USER_ID"] = $arUser["ID"];
         }
     } else {
         $arParams["USER_ID"] = $userTwit['kp_user_id'];
     }
     if (isset($arSiteId[$userTwit['kp_user_id']])) {
         $siteId = $arSiteId[$userTwit['kp_user_id']];
     }
     if (strlen($siteId) <= 0) {
         $siteId = SITE_ID;
     }
     if (isset($userTwit['text'])) {
         $arParams["GROUP_ID"] = COption::GetOptionString("socialnetwork", "userbloggroup_id", false, $siteId);
         $arParams["PATH_TO_BLOG"] = COption::GetOptionString("socialnetwork", "userblogpost_page", false, $siteId);
         $arParams["PATH_TO_SMILE"] = COption::GetOptionString("socialnetwork", "smile_page", false, $siteId);
         $arParams["NAME_TEMPLATE"] = COption::GetOptionString("main", "TOOLTIP_NAME_TEMPLATE", false, $siteId);
         $arParams["SHOW_LOGIN"] = 'Y';
         $arParams["PATH_TO_POST"] = $arParams["PATH_TO_BLOG"];
         $arFilterblg = array("ACTIVE" => "Y", "USE_SOCNET" => "Y", "GROUP_ID" => $arParams["GROUP_ID"], "GROUP_SITE_ID" => $siteId, "OWNER_ID" => $arParams["USER_ID"]);
         $groupId = is_array($arParams["GROUP_ID"]) ? IntVal($arParams["GROUP_ID"][0]) : IntVal($arParams["GROUP_ID"]);
         if (isset($GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]]) && !empty($GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]])) {
             $arBlog = $GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]];
         } else {
             $dbBl = CBlog::GetList(array(), $arFilterblg);
             $arBlog = $dbBl->Fetch();
             if (!$arBlog && IsModuleInstalled("intranet")) {
                 $arBlog = CBlog::GetByOwnerID($arParams["USER_ID"]);
             }
             $GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]] = $arBlog;
         }
         $arResult["Blog"] = $arBlog;
         if (empty($arBlog)) {
             if (!empty($arParams["GROUP_ID"])) {
                 $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => is_array($arParams["GROUP_ID"]) ? IntVal($arParams["GROUP_ID"][0]) : IntVal($arParams["GROUP_ID"]), "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P"));
                 $bRights = false;
                 $rsUser = CUser::GetByID($arParams["USER_ID"]);
                 $arUser = $rsUser->Fetch();
                 if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) {
                     $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"];
                 } else {
                     $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"];
                 }
                 $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . SITE_ID;
                 $arFields["OWNER_ID"] = $arParams["USER_ID"];
                 $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]);
                 if ($urlCheck != $arFields["URL"]) {
                     $arFields["URL"] = "u" . $arParams["USER_ID"] . "-blog-" . SITE_ID;
                 }
                 if (CBlog::GetByUrl($arFields["URL"])) {
                     $uind = 0;
                     do {
                         $uind++;
                         $arFields["URL"] = $arFields["URL"] . $uind;
                     } while (CBlog::GetByUrl($arFields["URL"]));
                 }
                 $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $arFields["OWNER_ID"], "blog", "view_post");
                 if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
                     $bRights = true;
                 }
                 $arFields["PATH"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arFields["URL"], "user_id" => $arFields["OWNER_ID"], "group_id" => $arFields["SOCNET_GROUP_ID"]));
                 $blogID = CBlog::Add($arFields);
                 if ($bRights) {
                     CBlog::AddSocnetRead($blogID);
                 }
                 $arBlog = CBlog::GetByID($blogID, $arParams["GROUP_ID"]);
             }
         }
         //	$DATE_PUBLISH = "";
         //	if(strlen($_POST["DATE_PUBLISH_DEF"]) > 0)
         //		$DATE_PUBLISH = $_POST["DATE_PUBLISH_DEF"];
         //	elseif (strlen($_POST["DATE_PUBLISH"])<=0)
         $DATE_PUBLISH = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL");
         //	else
         //		$DATE_PUBLISH = $_POST["DATE_PUBLISH"];
         $arFields = array("DETAIL_TEXT" => $userTwit['text'], "DETAIL_TEXT_TYPE" => "text", "DATE_PUBLISH" => $DATE_PUBLISH, "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "PATH" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => "#post_id#", "user_id" => $arBlog["OWNER_ID"])), "URL" => $arBlog["URL"], "SOURCE_TYPE" => "twitter");
         $arFields["PERMS_POST"] = array();
         $arFields["PERMS_COMMENT"] = array();
         $arFields["MICRO"] = "N";
         if (strlen($arFields["TITLE"]) <= 0) {
             $arFields["MICRO"] = "Y";
             $arFields["TITLE"] = trim(blogTextParser::killAllTags($arFields["DETAIL_TEXT"]));
             if (strlen($arFields["TITLE"]) <= 0) {
                 $arFields["TITLE"] = GetMessage("BLOG_EMPTY_TITLE_PLACEHOLDER");
             }
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:authmanager.php

示例5: RegisterLiveFeedEvent

 private static function RegisterLiveFeedEvent(&$arFields)
 {
     $ID = isset($arFields['ID']) ? intval($arFields['ID']) : 0;
     if ($ID <= 0) {
         $arFields['ERROR'] = 'Could not find activity ID.';
         return false;
     }
     $ownerTypeID = isset($arFields['OWNER_TYPE_ID']) ? intval($arFields['OWNER_TYPE_ID']) : CCrmOwnerType::Undefined;
     if (!CCrmOwnerType::IsDefined($ownerTypeID)) {
         $arFields['ERROR'] = 'Could not find owner type ID.';
         return false;
     }
     $ownerID = isset($arFields['OWNER_ID']) ? intval($arFields['OWNER_ID']) : 0;
     if ($ownerID <= 0) {
         $arFields['ERROR'] = 'Could not find owner ID.';
         return false;
     }
     $arOwners = array(array("OWNER_TYPE_ID" => $ownerTypeID, "OWNER_ID" => $ownerID));
     $authorID = isset($arFields['AUTHOR_ID']) ? intval($arFields['AUTHOR_ID']) : 0;
     $editorID = isset($arFields['EDITOR_ID']) ? intval($arFields['EDITOR_ID']) : 0;
     $userID = $authorID > 0 ? $authorID : $editorID;
     if ($userID <= 0) {
         $userID = CCrmSecurityHelper::GetCurrentUserID();
     }
     // Params are not assigned - we will use current activity only.
     $liveFeedFields = array('ENTITY_TYPE_ID' => CCrmOwnerType::Activity, 'ENTITY_ID' => $ID, 'USER_ID' => $userID, 'MESSAGE' => '', 'TITLE' => '');
     $bindings = isset($arFields['BINDINGS']) && is_array($arFields['BINDINGS']) ? $arFields['BINDINGS'] : array();
     if (!empty($bindings)) {
         $liveFeedFields['PARENTS'] = $bindings;
         $liveFeedFields['PARENT_OPTIONS'] = array('ENTITY_TYPE_ID_KEY' => 'OWNER_TYPE_ID', 'ENTITY_ID_KEY' => 'OWNER_ID');
         $ownerInfoOptions = array('ENTITY_TYPE_ID_KEY' => 'OWNER_TYPE_ID', 'ENTITY_ID_KEY' => 'OWNER_ID', 'ADDITIONAL_DATA' => array('LEVEL' => 2));
         $additionalParents = array();
         foreach ($bindings as &$binding) {
             $ownerTypeID = isset($binding['OWNER_TYPE_ID']) ? intval($binding['OWNER_TYPE_ID']) : CCrmOwnerType::Undefined;
             $ownerID = isset($binding['OWNER_ID']) ? intval($binding['OWNER_ID']) : 0;
             if ($ownerTypeID != CCrmOwnerType::Undefined && $ownerID > 0) {
                 $arOwners[] = array("OWNER_TYPE_ID" => $ownerTypeID, "OWNER_ID" => $ownerID);
             }
             if ($ownerTypeID === CCrmOwnerType::Contact && $ownerID > 0) {
                 $owners = array();
                 if (CCrmOwnerType::TryGetOwnerInfos(CCrmOwnerType::Contact, $ownerID, $owners, $ownerInfoOptions)) {
                     $additionalParents = array_merge($additionalParents, $owners);
                 }
             }
         }
         unset($binding);
         if (!empty($additionalParents)) {
             $liveFeedFields['PARENTS'] = array_merge($bindings, $additionalParents);
         }
         $arOwners = array_unique($arOwners);
     }
     self::PrepareStorageElementIDs($arFields);
     $arStorageElementID = $arFields["STORAGE_ELEMENT_IDS"];
     if (!empty($arStorageElementID)) {
         if ($arFields["STORAGE_TYPE_ID"] == StorageType::WebDav) {
             $liveFeedFields["UF_SONET_LOG_DOC"] = $arStorageElementID;
         } else {
             if ($arFields["STORAGE_TYPE_ID"] == StorageType::Disk) {
                 $liveFeedFields["UF_SONET_LOG_DOC"] = array();
                 //We have to add prefix Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX to file ID
                 foreach ($arStorageElementID as $elementID) {
                     $liveFeedFields["UF_SONET_LOG_DOC"][] = "n{$elementID}";
                 }
             } else {
                 $liveFeedFields["UF_SONET_LOG_FILE"] = $arStorageElementID;
             }
         }
     }
     if ($arFields['TYPE_ID'] == CCrmActivityType::Task && isset($arFields["ASSOCIATED_ENTITY_ID"]) && intval($arFields["ASSOCIATED_ENTITY_ID"]) > 0 && CModule::IncludeModule("tasks")) {
         $dbTask = CTasks::GetByID($arFields["ASSOCIATED_ENTITY_ID"], false);
         if ($arTask = $dbTask->Fetch()) {
             $ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("TASKS_TASK", "UF_TASK_WEBDAV_FILES", $arTask["ID"], LANGUAGE_ID);
             if ($ufDocID) {
                 $liveFeedFields["UF_SONET_LOG_DOC"] = $ufDocID;
             }
         }
     }
     $bConvert = false;
     if ($arTask) {
         $rsLog = CSocNetLog::GetList(array(), array("EVENT_ID" => "tasks", "SOURCE_ID" => $arTask["ID"]), array("ID"));
         if ($arLog = $rsLog->Fetch()) {
             $eventID = CCrmLiveFeed::ConvertTasksLogEvent(array("LOG_ID" => $arLog["ID"], "ACTIVITY_ID" => $ID));
             $bConvert = true;
         }
     }
     if (!$bConvert) {
         $eventID = CCrmLiveFeed::CreateLogEvent($liveFeedFields, CCrmLiveFeedEvent::Add);
     }
     if (!(is_int($eventID) && $eventID > 0) && isset($liveFeedFields['ERROR'])) {
         $arFields['ERROR'] = $liveFeedFields['ERROR'];
     } else {
         if ($arTask) {
             $arTaskParticipant = CTaskNotifications::GetRecipientsIDs($arTask, false);
             $arSocnetRights = CTaskNotifications::__UserIDs2Rights($arTaskParticipant);
             if (isset($arTask['GROUP_ID']) && intval($arTask['GROUP_ID']) > 0) {
                 $perm = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arTask['GROUP_ID'], "tasks", "view");
                 $arSocnetRights = array_merge($arSocnetRights, array('SG' . $arTask['GROUP_ID'], 'SG' . $arTask['GROUP_ID'] . '_' . $perm));
             }
             CSocNetLogRights::DeleteByLogID($eventID);
             CSocNetLogRights::Add($eventID, $arSocnetRights);
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:crm_activity.php

示例6: createBlog

 private function createBlog($userId, $blogGroupId, $siteId)
 {
     global $DB;
     $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $blogGroupId, "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P"));
     $bRights = false;
     $rsUser = CUser::GetByID($userId);
     $arUser = $rsUser->Fetch();
     if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) {
         $arFields["NAME"] = GetMessage("SNBPA_BLOG_NAME") . " " . $arUser["LOGIN"];
     } else {
         $arFields["NAME"] = GetMessage("SNBPA_BLOG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"];
     }
     $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . $siteId;
     $arFields["OWNER_ID"] = $userId;
     $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]);
     if ($urlCheck != $arFields["URL"]) {
         $arFields["URL"] = "u" . $userId . "-blog-" . $siteId;
     }
     if (CBlog::GetByUrl($arFields["URL"])) {
         $uind = 0;
         do {
             $uind++;
             $arFields["URL"] = $arFields["URL"] . $uind;
         } while (CBlog::GetByUrl($arFields["URL"]));
     }
     $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $arFields["OWNER_ID"], "blog", "view_post");
     if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
         $bRights = true;
     }
     $blogID = CBlog::Add($arFields);
     BXClearCache(true, "/blog/form/blog/");
     if ($bRights) {
         CBlog::AddSocnetRead($blogID);
     }
     return CBlog::GetByID($blogID, $blogGroupId);
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:36,代码来源:socnetblogpostactivity.php

示例7: GetSocNetUserPerms

 function GetSocNetUserPerms($postId = 0, $authorId = 0)
 {
     global $APPLICATION, $USER, $AR_BLOG_PERMS;
     $userId = IntVal($USER->GetID());
     $postId = IntVal($postId);
     $authorId = IntVal($authorId);
     if ($postId <= 0) {
         return false;
     }
     $perms = BLOG_PERMS_DENY;
     $blogModulePermissions = $APPLICATION->GetGroupRight("blog");
     if ($authorId > 0 && $userId == $authorId) {
         $perms = BLOG_PERMS_FULL;
     } elseif ($blogModulePermissions >= "W" || CSocNetUser::IsCurrentUserModuleAdmin()) {
         end($AR_BLOG_PERMS);
         $perms = key($AR_BLOG_PERMS);
         reset($AR_BLOG_PERMS);
     }
     if ($perms <= BLOG_PERMS_DENY) {
         $arPerms = CBlogPost::GetSocNetPerms($postId);
         $arEntities = array();
         if (!empty(CBlogPost::$arUACCache[$userId])) {
             $arEntities = CBlogPost::$arUACCache[$userId];
         } else {
             $arCodes = CAccess::GetUserCodesArray($userId);
             foreach ($arCodes as $code) {
                 if (preg_match('/^DR([0-9]+)/', $code, $match) || preg_match('/^D([0-9]+)/', $code, $match) || preg_match('/^IU([0-9]+)/', $code, $match)) {
                     $arEntities["DR"][$code] = $code;
                 } elseif (preg_match('/^SG([0-9]+)_([A-Z])/', $code, $match)) {
                     $arEntities["SG"][$match[1]][$match[2]] = $match[2];
                 }
             }
             CBlogPost::$arUACCache[$userId] = $arEntities;
         }
         if (!empty($arEntities["DR"]) && !empty($arPerms["DR"])) {
             foreach ($arPerms["DR"] as $id => $val) {
                 if (isset($arEntities["DR"]["DR" . $id])) {
                     $perms = BLOG_PERMS_READ;
                     break;
                 }
             }
         }
         if (!empty($arPerms["U"][$userId]) && in_array("US" . $userId, $arPerms["U"][$userId]) || $authorId > 0 && $userId == $authorId) {
             // if author
             $perms = BLOG_PERMS_FULL;
         } else {
             if ($authorId <= 0) {
                 foreach ($arPerms["U"] as $id => $p) {
                     if (in_array("US" . $id, $p)) {
                         $authorId = $id;
                         break;
                     }
                 }
             }
             if (!empty($arPerms["U"][$userId]) || !empty($arPerms["U"][$authorId]) && in_array("US" . $authorId, $arPerms["U"][$authorId]) || $perms == BLOG_PERMS_READ) {
                 if (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "write_comment")) {
                     $perms = BLOG_PERMS_WRITE;
                 } elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "premoderate_comment")) {
                     $perms = BLOG_PERMS_PREMODERATE;
                 } elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "view_comment")) {
                     $perms = BLOG_PERMS_READ;
                 }
             }
         }
         if ($perms <= BLOG_PERMS_FULL) {
             $arGroupsId = array();
             if (!empty($arPerms["SG"])) {
                 foreach ($arPerms["SG"] as $gid => $val) {
                     //if(!empty($arEntities["SG"][$gid]))
                     $arGroupsId[] = $gid;
                 }
                 $operation = array("full_comment", "moderate_comment", "write_comment", "premoderate_comment");
                 if ($perms < BLOG_PERMS_READ) {
                     $operation[] = "view_comment";
                 }
             }
             if (!empty($arGroupsId)) {
                 foreach ($operation as $v) {
                     if ($perms <= BLOG_PERMS_READ) {
                         $f = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arGroupsId, "blog", $v);
                         if (!empty($f)) {
                             foreach ($f as $gid => $val) {
                                 if (!empty($arEntities["SG"][$gid]) && in_array($val, $arEntities["SG"][$gid]) || $val == SONET_ROLES_ALL || $userId > 0 && $val == SONET_ROLES_AUTHORIZED) {
                                     switch ($v) {
                                         case "full_comment":
                                             $perms = BLOG_PERMS_FULL;
                                             break;
                                         case "moderate_comment":
                                             $perms = BLOG_PERMS_MODERATE;
                                             break;
                                         case "write_comment":
                                             $perms = BLOG_PERMS_WRITE;
                                             break;
                                         case "premoderate_comment":
                                             $perms = BLOG_PERMS_PREMODERATE;
                                             break;
                                         case "view_comment":
                                             $perms = BLOG_PERMS_READ;
                                             break;
                                     }
//.........这里部分代码省略.........
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:blog_comment.php

示例8: array

            $cacheSoNet->StartDataCache($arParams["CACHE_TIME"], $cache_idSoNet, $cache_pathSoNet);
        }
        $arAvBlog = array();
        $arFilterTmp = array("ACTIVE" => "Y", "GROUP_SITE_ID" => SITE_ID);
        if (IntVal($arParams["GROUP_ID"]) > 0) {
            $arFilterTmp["GROUP_ID"] = $arParams["GROUP_ID"];
        }
        $dbBlog = CBlog::GetList(array(), $arFilterTmp);
        while ($arBlog = $dbBlog->Fetch()) {
            if (IntVal($arBlog["SOCNET_GROUP_ID"]) > 0) {
                $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arBlog["SOCNET_GROUP_ID"], "blog", "view_post");
                if ($featureOperationPerms == SONET_ROLES_ALL) {
                    $arAvBlog[] = $arBlog["ID"];
                }
            } else {
                $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $arBlog["OWNER_ID"], "blog", "view_post");
                if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
                    $arAvBlog[] = $arBlog["ID"];
                }
            }
        }
        if ($arParams["CACHE_TIME"] > 0) {
            $cacheSoNet->EndDataCache(array("templateCachedData" => $this->GetTemplateCachedData(), "arAvBlog" => $arAvBlog));
        }
    }
}
//-------------------
$cache = new CPHPCache();
$cache_id = "blog_rss_sonet_out_" . serialize($arParams);
$cache_path = "/" . SITE_ID . "/blog/rss_sonet/" . strtolower($arResult["TYPE"]) . "/";
$APPLICATION->RestartBuffer();
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:component.php

示例9: array_key_exists

        if (!array_key_exists($feature, $arFeaturesTmp) || !array_key_exists("FEATURE_NAME", $arFeaturesTmp[$feature]) || strlen($arFeaturesTmp[$feature]["FEATURE_NAME"]) <= 0) {
            $arFeaturesTmp[$feature]["FEATURE_NAME"] = $arCustomFeatures["Title"][$feature];
        }
        if (!array_key_exists($feature, $arFeaturesTmp) || !array_key_exists("ACTIVE", $arFeaturesTmp[$feature]) || $arFeaturesTmp[$feature]["ACTIVE"] != "N") {
            $arFeaturesTmp[$feature]["ACTIVE"] = "Y";
        }
        $arFeaturesTmp[$feature]["URL"] = array_key_exists("Urls", $arParams["arResult"]) && array_key_exists($feature, $arParams["arResult"]["Urls"]) && strlen($arParams["arResult"]["Urls"][$feature]) > 0 ? $arParams["arResult"]["Urls"][$feature] : $arCustomFeatures["Urls"][$feature];
        $arFeaturesTmp[$feature]["NOPARAMS"] = true;
        if (array_key_exists("AllowSettings", $arCustomFeatures) && array_key_exists($feature, $arCustomFeatures["AllowSettings"]) && $arCustomFeatures["AllowSettings"][$feature]) {
            $arFeaturesTmp[$feature]["ALLOW_SETTINGS"] = true;
        }
    }
    $arResult["ALL_FEATURES"][$feature] = array("FeatureName" => $arFeaturesTmp[$feature]["FEATURE_NAME"] ? $arFeaturesTmp[$feature]["FEATURE_NAME"] : GetMessage("SONET_SM_" . $arParams["ENTITY_TYPE"] . "_" . strtoupper($feature)), "Active" => array_key_exists($feature, $arFeaturesTmp) ? $arFeaturesTmp[$feature]["ACTIVE"] == "Y" : true, "Operations" => array(), "NOPARAMS" => $arFeaturesTmp[$feature]["NOPARAMS"], "Url" => strlen($arFeaturesTmp[$feature]["URL"]) > 0 ? $arFeaturesTmp[$feature]["URL"] : $arParams["arResult"]["Urls"][$feature], "ALLOW_SETTINGS" => array_key_exists($feature, $arFeaturesTmp) && array_key_exists("ALLOW_SETTINGS", $arFeaturesTmp[$feature]) && $arFeaturesTmp[$feature]["ALLOW_SETTINGS"] ? $arFeaturesTmp[$feature]["ALLOW_SETTINGS"] : false);
    if (array_key_exists("operations", $arFeature)) {
        foreach ($arFeature["operations"] as $op => $arOp) {
            $arResult["ALL_FEATURES"][$feature]["Operations"][$op] = CSocNetFeaturesPerms::GetOperationPerm($arParams["ENTITY_TYPE"], $arParams["ENTITY_ID"], $feature, $op);
        }
    }
}
if ($arParams["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
    $arResult["ALL_FEATURES"]["users"] = array("FeatureName" => $arParams["UsersName"], "Active" => true, "Operations" => array(), "NOPARAMS" => true, "Url" => $arParams["arResult"]["Urls"]["GroupUsers"]);
}
if ($arParams["ENTITY_TYPE"] == "M") {
    $arResult["ALL_FEATURES"]["messages_users"] = array("FeatureName" => GetMessage("SONET_SM_M_USERS"), "Active" => true, "Operations" => array(), "NOPARAMS" => true, "Url" => $arParams["arResult"]["Urls"]["MessagesUsers"]);
    $arResult["ALL_FEATURES"]["messages_input"] = array("FeatureName" => GetMessage("SONET_SM_M_INPUT"), "Active" => true, "Operations" => array(), "NOPARAMS" => true, "Url" => $arParams["arResult"]["Urls"]["MessagesInput"]);
    $arResult["ALL_FEATURES"]["messages_output"] = array("FeatureName" => GetMessage("SONET_SM_M_OUTPUT"), "Active" => true, "Operations" => array(), "NOPARAMS" => true, "Url" => $arParams["arResult"]["Urls"]["MessagesOutput"]);
    $arResult["ALL_FEATURES"]["user_ban"] = array("FeatureName" => GetMessage("SONET_SM_M_BAN"), "Active" => true, "Operations" => array(), "NOPARAMS" => true, "Url" => $arParams["arResult"]["Urls"]["UserBan"]);
    if (array_key_exists("arResult", $arParams) && is_array($arParams["arResult"]) && array_key_exists("Urls", $arParams["arResult"]) && is_array($arParams["arResult"]["Urls"]) && array_key_exists("BizProc", $arParams["arResult"]["Urls"])) {
        $arResult["ALL_FEATURES"]["bizproc"] = array("FeatureName" => GetMessage("SONET_SM_M_BIZPROC"), "Active" => true, "Operations" => array(), "NOPARAMS" => true, "Url" => $arParams["arResult"]["Urls"]["BizProc"]);
    }
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例10: CanPerformOperation

 function CanPerformOperation($userID, $type, $id, $feature, $operation, $bCurrentUserIsAdmin = false)
 {
     global $arSocNetAllowedEntityTypes;
     $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
     $userID = IntVal($userID);
     if (is_array($id) && count($id) <= 0 || !is_array($id) && $id <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GF_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
         return false;
     }
     $type = Trim($type);
     if (StrLen($type) <= 0 || !in_array($type, $arSocNetAllowedEntityTypes)) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_TYPE"), "ERROR_EMPTY_TYPE");
         return false;
     }
     $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm($type, $id, $feature, $operation);
     if ($type == SONET_ENTITY_GROUP) {
         $bWorkWithClosedGroups = COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") == "Y";
         if (is_array($id)) {
             $arGroupToGet = array();
             foreach ($id as $group_id) {
                 if ($featureOperationPerms[$group_id] == false) {
                     $arReturn[$group_id] = false;
                 } else {
                     $arGroupToGet[] = $group_id;
                 }
             }
             $userRoleInGroup = CSocNetUserToGroup::GetUserRole($userID, $arGroupToGet);
             $arGroupToGet = array();
             if (is_array($userRoleInGroup)) {
                 foreach ($userRoleInGroup as $group_id => $role) {
                     if ($userRoleInGroup[$group_id] == SONET_ROLES_BAN) {
                         $arReturn[$group_id] = false;
                     } else {
                         $arGroupToGet[] = $group_id;
                     }
                 }
             }
             if (is_array($arGroupToGet) && count($arGroupToGet) <= 0 || !is_array($arGroupToGet) && intval($arGroupToGet) <= 0) {
                 $arReturn = array();
                 foreach ($id as $group_id) {
                     $arReturn[$group_id] = false;
                 }
                 return $arReturn;
             }
             $resGroupTmp = CSocNetGroup::GetList(array("ID" => "ASC"), array("ID" => $arGroupToGet));
             while ($arGroupTmp = $resGroupTmp->Fetch()) {
                 if ($arGroupTmp["CLOSED"] == "Y" && !in_array($operation, $arSocNetFeaturesSettings[$feature]["minoperation"])) {
                     if (!$bWorkWithClosedGroups) {
                         $arReturn[$arGroupTmp["ID"]] = false;
                         continue;
                     } else {
                         $featureOperationPerms[$arGroupTmp["ID"]] = SONET_ROLES_OWNER;
                     }
                 }
                 if ($bCurrentUserIsAdmin) {
                     $arReturn[$arGroupTmp["ID"]] = true;
                     continue;
                 }
                 if ($featureOperationPerms[$arGroupTmp["ID"]] == SONET_ROLES_ALL) {
                     if ($arGroupTmp["VISIBLE"] == "N") {
                         $featureOperationPerms[$arGroupTmp["ID"]] = SONET_ROLES_USER;
                     } else {
                         $arReturn[$arGroupTmp["ID"]] = true;
                         continue;
                     }
                 }
                 if ($featureOperationPerms[$arGroupTmp["ID"]] == SONET_ROLES_AUTHORIZED) {
                     if ($userID > 0) {
                         $arReturn[$arGroupTmp["ID"]] = true;
                         continue;
                     } else {
                         $arReturn[$arGroupTmp["ID"]] = false;
                         continue;
                     }
                 }
                 if ($userRoleInGroup[$arGroupTmp["ID"]] == false) {
                     $arReturn[$arGroupTmp["ID"]] = false;
                     continue;
                 }
                 if ($featureOperationPerms[$arGroupTmp["ID"]] == SONET_ROLES_MODERATOR) {
                     if ($userRoleInGroup[$arGroupTmp["ID"]] == SONET_ROLES_MODERATOR || $userRoleInGroup[$arGroupTmp["ID"]] == SONET_ROLES_OWNER) {
                         $arReturn[$arGroupTmp["ID"]] = true;
                         continue;
                     } else {
                         $arReturn[$arGroupTmp["ID"]] = false;
                         continue;
                     }
                 } elseif ($featureOperationPerms[$arGroupTmp["ID"]] == SONET_ROLES_USER) {
                     if ($userRoleInGroup[$arGroupTmp["ID"]] == SONET_ROLES_MODERATOR || $userRoleInGroup[$arGroupTmp["ID"]] == SONET_ROLES_OWNER || $userRoleInGroup[$arGroupTmp["ID"]] == SONET_ROLES_USER) {
                         $arReturn[$arGroupTmp["ID"]] = true;
                         continue;
                     } else {
                         $arReturn[$arGroupTmp["ID"]] = false;
                         continue;
                     }
                 } elseif ($featureOperationPerms[$arGroupTmp["ID"]] == SONET_ROLES_OWNER) {
                     if ($userRoleInGroup[$arGroupTmp["ID"]] == SONET_ROLES_OWNER) {
                         $arReturn[$arGroupTmp["ID"]] = true;
                         continue;
                     } else {
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:group_features_perms.php

示例11: ConvertEntity

 public static function ConvertEntity($ownerType, $ownerId, $sectionId, $iblockId, $createdBy)
 {
     $eventsCount = 0;
     $sectCount = 0;
     $bs = new CIBlockSection();
     $ent_id = "IBLOCK_" . $iblockId . "_SECTION";
     $result = array('eventsCount' => 0, 'sectCount' => 0);
     $bSetAccessFromCalendar = true;
     $Access = array('G2' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_denied'));
     // CONVERT ACCESS:
     if ($ownerType == 'user') {
         if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $ownerId, "calendar")) {
             return $result;
         }
         // Read
         $read = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ownerId, "calendar", 'view');
         $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view');
         if ($read == 'A') {
             // All users
             $Access['G2'] = $taskId;
         } elseif ($read == 'C') {
             // All autorized
             $Access['AU'] = $taskId;
         } elseif ($read == 'M' || $read == 'E') {
             // Friends
             $Access['SU' . $ownerId . '_F'] = $taskId;
         } elseif ($bSetAccessFromCalendar) {
             $bSetAccessFromCalendar = false;
         }
         // Write - will override read access
         $write = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ownerId, "calendar", 'write');
         $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_edit');
         if ($write == 'A') {
             // All users
             $Access['G2'] = $taskId;
         } elseif ($write == 'C') {
             // All autorized
             $Access['AU'] = $taskId;
         } elseif ($write == 'M' || $write == 'E') {
             // Friends
             $Access['SU' . $ownerId . '_F'] = $taskId;
         }
     } elseif ($ownerType == 'group') {
         if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $ownerId, "calendar")) {
             return $result;
         }
         // Read
         $read = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $ownerId, "calendar", 'view');
         $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view');
         if ($read == 'A') {
             // Group owner
             $Access['SG' . $ownerId . '_A'] = $taskId;
         } elseif ($read == 'E') {
             // Group moderator
             $Access['SG' . $ownerId . '_E'] = $taskId;
         } elseif ($read == 'K') {
             // User
             $Access['SG' . $ownerId . '_K'] = $taskId;
         } elseif ($read == 'L') {
             // Authorized
             $Access['AU'] = $taskId;
         } elseif ($read == 'N') {
             // Authorized
             $Access['G2'] = $taskId;
         }
         // Write - will override read access
         $write = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $ownerId, "calendar", 'write');
         $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_edit');
         if ($write == 'A') {
             // Group owner
             $Access['SG' . $ownerId . '_A'] = $taskId;
         } elseif ($write == 'E') {
             // Group moderator
             $Access['SG' . $ownerId . '_E'] = $taskId;
         } elseif ($write == 'K') {
             // User
             $Access['SG' . $ownerId . '_K'] = $taskId;
         } elseif ($write == 'L') {
             // Authorized
             $Access['AU'] = $taskId;
         } elseif ($write == 'N') {
             // Authorized
             $Access['G2'] = $taskId;
         }
     } else {
         $arGroupPerm = CIBlock::GetGroupPermissions($iblockId);
         $taskByLetter = array('D' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_denied'), 'R' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view'), 'W' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_edit'), 'X' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_access'));
         foreach ($arGroupPerm as $groupId => $letter) {
             $Access['G' . $groupId] = $taskByLetter[$letter];
         }
     }
     // 1. Fetch sections
     $arUserSections = CEventCalendar::GetCalendarList(array($iblockId, $sectionId, 0, $ownerType));
     $calendarIndex = array();
     foreach ($arUserSections as $section) {
         $arUF = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields($ent_id, $section['ID']);
         if (isset($arUF["UF_CAL_CONVERTED"]) && strlen($arUF["UF_CAL_CONVERTED"]['VALUE']) > 0) {
             continue;
         }
         $SectionAccess = array();
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:calendar_convert.php

示例12: Entity2UserAdd

 function Entity2UserAdd($entityType, $entityID, $userID, $role)
 {
     global $APPLICATION, $DB, $arSocNetAllowedEntityTypes;
     $CacheRelatedUsers = array();
     $entityType = trim($entityType);
     if (!in_array($entityType, $arSocNetAllowedEntityTypes)) {
         $APPLICATION->ThrowException(GetMessage("SONET_EUV_INCORRECT_ENTITY_TYPE"), "ERROR_INCORRECT_ENTITY_TYPE");
         return false;
     }
     $entityID = IntVal($entityID);
     if ($entityID <= 0) {
         $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
         return false;
     }
     $userID = IntVal($userID);
     if ($userID <= 0) {
         $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_USER_ID"), "ERROR_EMPTY_USER_ID");
         return false;
     }
     if (is_array($role)) {
         if (count($role) <= 0) {
             $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_ROLE"), "ERROR_EMPTY_ROLE");
             return false;
         }
     } else {
         $role = trim($role);
         if (strlen($role) <= 0) {
             $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_ROLE"), "ERROR_EMPTY_ROLE");
             return false;
         }
         $role = array($role);
     }
     if (!CSocNetEventUserView::IsEntityEmpty($entityType, $entityID)) {
         $arEvents = array();
         $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
         foreach ($arSocNetLogEvents as $event_tmp_id => $arLogEventTmp) {
             if (!array_key_exists("ENTITIES", $arLogEventTmp) || !array_key_exists($entityType, $arLogEventTmp["ENTITIES"])) {
                 continue;
             }
             if (array_key_exists("NO_SET", $arLogEventTmp) && $arLogEventTmp["NO_SET"]) {
                 continue;
             }
             $arEvents[] = $event_tmp_id;
             if (array_key_exists("COMMENT_EVENT", $arLogEventTmp) && is_array($arLogEventTmp["COMMENT_EVENT"]) && array_key_exists("EVENT_ID", $arLogEventTmp["COMMENT_EVENT"]) && strlen($arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"]) > 0) {
                 $arEvents[] = $arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"];
             }
         }
         $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedEntityTypes();
         foreach ($arSocNetFeaturesSettings as $feature => $arFeature) {
             if (!array_key_exists("subscribe_events", $arFeature)) {
                 continue;
             }
             foreach ($arFeature["subscribe_events"] as $event_id_tmp => $arEventIDTmp) {
                 if (array_key_exists("NO_SET", $arEventIDTmp) && $arEventIDTmp["NO_SET"]) {
                     continue;
                 }
                 if (!array_key_exists("OPERATION", $arEventIDTmp) || strlen($arEventIDTmp["OPERATION"]) <= 0) {
                     continue;
                 }
                 $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm($entityType, $entityID, $feature, $arEventIDTmp["OPERATION"]);
                 if (in_array($featureOperationPerms, $role)) {
                     $arEvents[] = $event_id_tmp;
                 }
                 if (array_key_exists("COMMENT_EVENT", $arEventIDTmp) && is_array($arEventIDTmp["COMMENT_EVENT"]) && array_key_exists("EVENT_ID", $arEventIDTmp["COMMENT_EVENT"]) && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"]) && strlen($arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"]) > 0 && strlen($arEventIDTmp["COMMENT_EVENT"]["OPERATION"]) > 0 && $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"] != $event_id_tmp) {
                     $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm($entityType, $entityID, $feature, $arEventIDTmp["COMMENT_EVENT"]["OPERATION"]);
                     if (in_array($featureOperationPerms, $role)) {
                         $arEvents[] = $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"];
                     }
                 }
             }
         }
         $arEvents = array_unique($arEvents);
         foreach ($arEvents as $event) {
             $arFieldsEUV = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $entityID, "EVENT_ID" => $event, "USER_ID" => $userID, "USER_ANONYMOUS" => "N");
             CSocNetEventUserView::Add($arFieldsEUV);
         }
     } elseif ($entityType == SONET_ENTITY_GROUP) {
         CSocNetEventUserView::SetGroup($entityID, true);
     } elseif ($entityType == SONET_ENTITY_USER) {
         CSocNetEventUserView::SetUser($entityID, false, false, true);
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:82,代码来源:event_user_view.php

示例13: array

                     $arResult["Features"][$feature] = array("FeatureName" => $arFeaturesTmp[$feature]["FEATURE_NAME"], "Active" => array_key_exists($feature, $arFeaturesTmp) ? $arFeaturesTmp[$feature]["ACTIVE"] == "Y" : true, "Operations" => array());
                     if ($feature == 'files') {
                         $arResult["Features"][$feature]['note'] = GetMessage("SONET_WEBDAV_RIGHS_NOTE");
                         continue;
                     }
                     if ($feature == 'calendar' && (!IsModuleInstalled("intranet") || COption::GetOptionString("intranet", "calendar_2", "N") == "Y") && CModule::IncludeModule("calendar")) {
                         $arResult["Features"][$feature]['note'] = GetMessage('SONET_CALENDAR_ACCESS_NOTE');
                         continue;
                     }
                     if ($feature == "blog" && $arParams["PAGE_ID"] != "group_features") {
                         $arResult["Features"][$feature]["Active"] = true;
                     }
                     if (is_array($arFeature["operations"])) {
                         foreach ($arFeature["operations"] as $op => $arOp) {
                             if (!($feature == "blog" && !array_key_exists(SONET_ENTITY_USER, $arOp))) {
                                 $arResult["Features"][$feature]["Operations"][$op] = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $arResult["User"]["ID"], $feature, $op);
                             }
                         }
                     }
                 }
             } else {
                 $arResult["FatalError"] = GetMessage("SONET_C3_PERMS") . ".";
             }
         } else {
             $arResult["FatalError"] = GetMessage("SONET_P_USER_NO_USER") . ".";
         }
     }
 }
 if (StrLen($arResult["FatalError"]) <= 0) {
     $arResult["Urls"]["User"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arParams["USER_ID"]));
     $arResult["Urls"]["Group"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP"], array("group_id" => $arParams["GROUP_ID"]));
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:component.php

示例14: GetSocNetPostPerms


//.........这里部分代码省略.........
     if ($perms <= BLOG_PERMS_DENY) {
         $arPerms = CBlogPost::GetSocNetPerms($postId);
         $arEntities = array();
         if (isset($GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId]) && !empty($GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId])) {
             $arEntities = $GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId];
         } else {
             $arCodes = CAccess::GetUserCodesArray($userId);
             foreach ($arCodes as $code) {
                 if (preg_match('/^DR([0-9]+)/', $code, $match) || preg_match('/^D([0-9]+)/', $code, $match) || preg_match('/^IU([0-9]+)/', $code, $match)) {
                     $arEntities["DR"][$code] = $code;
                 } elseif (preg_match('/^SG([0-9]+)_([A-Z])/', $code, $match)) {
                     $arEntities["SG"][$match[1]][$match[2]] = $match[2];
                 }
             }
             $GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId] = $arEntities;
         }
         foreach ($arPerms as $t => $val) {
             foreach ($val as $id => $p) {
                 if (!is_array($p)) {
                     $p = array();
                 }
                 if ($userId > 0 && $t == "U" && $userId == $id) {
                     $perms = BLOG_PERMS_READ;
                     if (in_array("US" . $userId, $p)) {
                         // if author
                         $perms = BLOG_PERMS_FULL;
                     }
                     break;
                 }
                 if (in_array("G2", $p)) {
                     $perms = BLOG_PERMS_READ;
                     break;
                 }
                 if ($userId > 0 && in_array("AU", $p)) {
                     $perms = BLOG_PERMS_READ;
                     break;
                 }
                 if ($t == "SG") {
                     if (!empty($arEntities["SG"][$id])) {
                         foreach ($arEntities["SG"][$id] as $gr) {
                             if (in_array("SG" . $id . "_" . $gr, $p)) {
                                 $perms = BLOG_PERMS_READ;
                                 break;
                             }
                         }
                     }
                 }
                 if ($t == "DR" && !empty($arEntities["DR"])) {
                     if (in_array("DR" . $id, $arEntities["DR"])) {
                         $perms = BLOG_PERMS_READ;
                         break;
                     }
                 }
             }
             if ($perms > BLOG_PERMS_DENY) {
                 break;
             }
         }
         if ($bNeedFull && $perms <= BLOG_PERMS_FULL) {
             $arGroupsId = array();
             if (!empty($arPerms["SG"])) {
                 foreach ($arPerms["SG"] as $gid => $val) {
                     if (!empty($arEntities["SG"][$gid])) {
                         $arGroupsId[] = $gid;
                     }
                 }
             }
             $operation = array("full_post", "moderate_post", "write_post", "premoderate_post");
             if (!empty($arGroupsId)) {
                 foreach ($operation as $v) {
                     if ($perms <= BLOG_PERMS_READ) {
                         $f = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arGroupsId, "blog", $v);
                         if (!empty($f)) {
                             foreach ($f as $gid => $val) {
                                 if (in_array($val, $arEntities["SG"][$gid])) {
                                     switch ($v) {
                                         case "full_post":
                                             $perms = BLOG_PERMS_FULL;
                                             break;
                                         case "moderate_post":
                                             $perms = BLOG_PERMS_MODERATE;
                                             break;
                                         case "write_post":
                                             $perms = BLOG_PERMS_WRITE;
                                             break;
                                         case "premoderate_post":
                                             $perms = BLOG_PERMS_PREMODERATE;
                                             break;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $GLOBALS["BLOG_BP_SOCNETPOSTPERMS"][$cId] = $perms;
     return $perms;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:blog_post.php

示例15: SetSoNetFeatureIndexSearch

 function SetSoNetFeatureIndexSearch($ID, $arFields)
 {
     if (CModule::IncludeModule("socialnetwork")) {
         $feature = CSocNetFeatures::GetByID($ID);
         if ($feature["FEATURE"] == "blog") {
             if (IntVal($feature["ENTITY_ID"]) > 0) {
                 $bRights = false;
                 $arFilter = array("USE_SOCNET" => "Y");
                 if ($feature["ENTITY_TYPE"] == "U") {
                     $arFilter["OWNER_ID"] = $feature["ENTITY_ID"];
                     $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $feature["ENTITY_ID"], "blog", "view_post");
                     if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
                         $bRights = true;
                     }
                 } else {
                     $arFilter["SOCNET_GROUP_ID"] = $feature["ENTITY_ID"];
                     $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $feature["ENTITY_ID"], "blog", "view_post");
                     if ($featureOperationPerms == SONET_ROLES_ALL) {
                         $bRights = true;
                     }
                 }
                 $dbBlog = CBlog::GetList(array(), $arFilter, false, array("nTopCount" => 1), array("ID", "SOCNET_GROUP_ID"));
                 if ($arBlog = $dbBlog->Fetch()) {
                     if (intval($arBlog["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule("socialnetwork") && method_exists("CSocNetGroup", "GetSite")) {
                         $arSites = array();
                         $rsGroupSite = CSocNetGroup::GetSite($arBlog["SOCNET_GROUP_ID"]);
                         while ($arGroupSite = $rsGroupSite->Fetch()) {
                             $arSites[] = $arGroupSite["LID"];
                         }
                     } else {
                         $arSites = array(SITE_ID);
                     }
                     foreach ($arSites as $site_id_tmp) {
                         BXClearCache(True, "/" . $site_id_tmp . "/blog/sonet/");
                     }
                     if ($arFields["ACTIVE"] == "N") {
                         CBlog::DeleteSocnetRead($arBlog["ID"]);
                     } else {
                         if ($bRights) {
                             CBlog::AddSocnetRead($arBlog["ID"]);
                         } else {
                             CBlog::DeleteSocnetRead($arBlog["ID"]);
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:49,代码来源:blog_search.php


注:本文中的CSocNetFeaturesPerms::GetOperationPerm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。