Example #1
0
 function ChangeSocNetPermission($entity_type, $entity_id, $operation)
 {
     global $DB;
     $entity_id = IntVal($entity_id);
     $perms = CBlogPost::GetSocnetGroups($entity_type, $entity_id, $operation);
     $type = "U";
     $type2 = "US";
     if ($entity_type == "G") {
         $type = $type2 = "SG";
     }
     $DB->Query("DELETE FROM b_blog_socnet_rights \n\t\t\t\t\tWHERE \n\t\t\t\t\t\tENTITY_TYPE = '" . $type . "'\n\t\t\t\t\t\tAND ENTITY_ID = " . $entity_id . "\n\t\t\t\t\t\tAND ENTITY <> '" . $type2 . $entity_id . "'\n\t\t\t\t\t\tAND ENTITY <> '" . $type . $entity_id . "'\n\t\t\t\t\t\t", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     foreach ($perms as $val) {
         $DB->Query("INSERT INTO b_blog_socnet_rights (POST_ID, ENTITY_TYPE, ENTITY_ID, ENTITY) \n\t\t\t\t\t\tSELECT SR.POST_ID, SR.ENTITY_TYPE, SR.ENTITY_ID, '" . $DB->ForSql($val) . "' FROM b_blog_socnet_rights SR\n\t\t\t\t\t\tWHERE SR.ENTITY = '" . $type2 . $entity_id . "'", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
 }
Example #2
0
 function SetFeaturePermissions($entity_type, $entity_id, $feature, $operation, $new_perm)
 {
     if (substr($operation, 0, 4) == "view") {
         if (CModule::IncludeModule('search')) {
             global $arSonetFeaturesPermsCache;
             unset($arSonetFeaturesPermsCache[$entity_type . "_" . $entity_id]);
             $arGroups = CSocNetSearch::GetSearchGroups($entity_type, $entity_id, $feature, $operation);
             $arParams = CSocNetSearch::GetSearchParams($entity_type, $entity_id, $feature, $operation);
             CSearch::ChangePermission(false, $arGroups, false, false, false, false, $arParams);
         }
     }
     if ($feature == "blog" && in_array($operation, array("view_post", "view_comment")) && CModule::IncludeModule('blog')) {
         if ($operation == "view_post") {
             CBlogPost::ChangeSocNetPermission($entity_type, $entity_id, $operation);
         }
         if ($operation == "view_post") {
             $arPost = CBlogPost::GetSocNetPostsPerms($entity_type, $entity_id);
             foreach ($arPost as $id => $perms) {
                 CSearch::ChangePermission("blog", $perms["PERMS"], "P" . $id);
             }
         } else {
             $arTmpCache = array();
             $arPost = CBlogPost::GetSocNetPostsPerms($entity_type, $entity_id);
             $dbComment = CBlogComment::GetSocNetPostsPerms($entity_type, $entity_id);
             while ($arComment = $dbComment->Fetch()) {
                 if (!empty($arPost[$arComment["POST_ID"]])) {
                     if (empty($arPost[$arComment["POST_ID"]]["PERMS_CALC"])) {
                         $arPost[$arComment["POST_ID"]]["PERMS_CALC"] = array();
                         if (is_array($arPost[$arComment["POST_ID"]]["PERMS_FULL"]) && !empty($arPost[$arComment["POST_ID"]]["PERMS_FULL"])) {
                             foreach ($arPost[$arComment["POST_ID"]]["PERMS_FULL"] as $e => $v) {
                                 if (in_array($v["TYPE"], array("SG", "U"))) {
                                     $type = $v["TYPE"] == "SG" ? "G" : "U";
                                     if (array_key_exists($type . $v["ID"], $arTmpCache)) {
                                         $spt = $arTmpCache[$type . $v["ID"]];
                                     } else {
                                         $spt = CBlogPost::GetSocnetGroups($type, $v["ID"], "view_comment");
                                         $arTmpCache[$type . $v["ID"]] = $spt;
                                     }
                                     foreach ($spt as $vv) {
                                         if (!in_array($vv, $arPost[$arComment["POST_ID"]]["PERMS_CALC"])) {
                                             $arPost[$arComment["POST_ID"]]["PERMS_CALC"][] = $vv;
                                         }
                                     }
                                 } else {
                                     $arPost[$arComment["POST_ID"]]["PERMS_CALC"][] = $e;
                                 }
                             }
                         }
                     }
                     CSearch::ChangePermission("blog", $arPost[$arComment["POST_ID"]]["PERMS_CALC"], "C" . $arComment["ID"]);
                 }
             }
         }
     }
 }
Example #3
0
	public static function GetSocNetCommentPerms($postID = 0)
	{
		$postID = IntVal($postID);
		if($postID <= 0)
			return false;

		$arSp = Array();
		$sp = CBlogPost::GetSocnetPerms($postID);
		if(is_array($sp) && !empty($sp))
		{
			foreach($sp as $et => $v)
			{
				foreach($v as $eid => $tv)
				{
					if($et == "U" && in_array($et.$eid, $tv))
					{
						$arSp[] = $et.$eid;
					}
					elseif(in_array($et, Array("U", "SG")))
					{
						$spt = CBlogPost::GetSocnetGroups(($et == "SG" ? "G" : "U"), $eid, "view_comment");
						foreach($spt as $vv)
						{
							if(!in_array($vv, $arSp))
								$arSp[] = $vv;
						}
					}
					else
					{
						$arSp[] = $et.$eid;
					}
				}
			}
		}
		return $arSp;
	}