Ejemplo n.º 1
0
 function CanPerformOperation($fromUserID, $toUserID, $operation, $bCurrentUserIsAdmin = false)
 {
     global $arSocNetUserOperations;
     $fromUserID = IntVal($fromUserID);
     $toUserID = IntVal($toUserID);
     if ($toUserID <= 0) {
         return false;
     }
     $operation = StrToLower(Trim($operation));
     if (!array_key_exists($operation, $arSocNetUserOperations)) {
         return false;
     }
     // use no profile private permission restrictions at the extranet site
     if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
         return true;
     }
     if ($bCurrentUserIsAdmin) {
         return true;
     }
     if ($fromUserID == $toUserID) {
         return true;
     }
     $usersRelation = CSocNetUserRelations::GetRelation($fromUserID, $toUserID);
     if ($usersRelation == SONET_RELATIONS_BAN && !IsModuleInstalled("im")) {
         return false;
     }
     $toUserOperationPerms = CSocNetUserPerms::GetOperationPerms($toUserID, $operation);
     if ($toUserOperationPerms == SONET_RELATIONS_TYPE_NONE) {
         return false;
     }
     if ($toUserOperationPerms == SONET_RELATIONS_TYPE_ALL) {
         return true;
     }
     if ($toUserOperationPerms == SONET_RELATIONS_TYPE_AUTHORIZED) {
         if ($fromUserID > 0) {
             return true;
         } else {
             return false;
         }
     }
     if ($toUserOperationPerms == SONET_RELATIONS_TYPE_FRIENDS) {
         if (CSocNetUserRelations::IsFriends($fromUserID, $toUserID)) {
             return true;
         } else {
             return false;
         }
     }
     if ($toUserOperationPerms == SONET_RELATIONS_TYPE_FRIENDS2) {
         if (CSocNetUserRelations::IsFriends2($fromUserID, $toUserID)) {
             return true;
         } elseif (CSocNetUserRelations::IsFriends($fromUserID, $toUserID)) {
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 function GetListEx($arOrder = array("SORT" => "ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array(), $nameTemplate = false, $bShowLogin = true, $bShowTooltip = false, $arTooltipParams = false)
 {
     global $USER;
     $iblockId = COption::GetOptionInt("intranet", "iblock_tasks", 0);
     if ($iblockId <= 0) {
         return false;
     }
     $arFilter["IBLOCK_ID"] = $iblockId;
     $arFilter["SHOW_NEW"] = "Y";
     if (count($arSelectFields) > 0) {
         if (!in_array("IBLOCK_SECTION_ID", $arSelectFields)) {
             $arSelectFields[] = "IBLOCK_SECTION_ID";
         }
         if (!in_array("ID", $arSelectFields)) {
             $arSelectFields[] = "ID";
         }
         if (!in_array("IBLOCK_ID", $arSelectFields)) {
             $arSelectFields[] = "IBLOCK_ID";
         }
         if (!in_array("CREATED_BY", $arSelectFields)) {
             $arSelectFields[] = "CREATED_BY";
         }
     }
     $arResultList = array();
     $arCache = array();
     $isInSecurity = CModule::IncludeModule("security");
     //$hFileTmp = fopen($_SERVER["DOCUMENT_ROOT"]."/+++++++.+++", "a");  // DUMPING
     //fwrite($hFileTmp, "GetList:\n".print_r(array($arOrder, $arFilter, $arGroupBy, $arNavStartParams, $arSelectFields), true)."\n");
     //fclose($hFileTmp);
     $dbTasksList = CIBlockElement::GetList($arOrder, $arFilter, $arGroupBy, $arNavStartParams, $arSelectFields);
     while ($obTask = $dbTasksList->GetNextElement()) {
         $arResult = array();
         $arFields = $obTask->GetFields();
         foreach ($arFields as $fieldKey => $fieldValue) {
             if (substr($fieldKey, 0, 1) == "~") {
                 continue;
             }
             $arResult[$fieldKey] = $fieldValue;
             if (in_array($fieldKey, array("MODIFIED_BY", "CREATED_BY"))) {
                 $arResult[$fieldKey . "_PRINTABLE"] = CIntranetTasks::PrepareUserForPrint($fieldValue, $nameTemplate, $bShowLogin, $bShowTooltip, $arTooltipParams);
             } elseif ($fieldKey == "DETAIL_TEXT") {
                 if ($isInSecurity) {
                     $filter = new CSecurityFilter();
                     $arResult["DETAIL_TEXT_PRINTABLE"] = $filter->TestXSS($arFields["~DETAIL_TEXT"]);
                     $arResult["DETAIL_TEXT"] = $arResult["DETAIL_TEXT_PRINTABLE"];
                 } else {
                     $arResult["DETAIL_TEXT_PRINTABLE"] = nl2br($arFields["DETAIL_TEXT"]);
                     $arResult["DETAIL_TEXT"] = $arFields["DETAIL_TEXT"];
                 }
             } else {
                 $arResult[$fieldKey . "_PRINTABLE"] = $fieldValue;
             }
         }
         $arProperties = $obTask->GetProperties();
         foreach ($arProperties as $propertyKey => $propertyValue) {
             $arResult["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"];
             if (strtoupper($propertyKey) == "TASKCOMPLETE") {
                 $ps = intval($propertyValue["VALUE"]);
                 if ($ps > 100) {
                     $ps = 100;
                 } elseif ($ps < 0) {
                     $ps = 0;
                 }
                 $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = '<div class="task-complete-bar-out" title="' . GetMessage("INTASK_L_TASKCOMPLETE", array("#PRC#" => IntVal($propertyValue["VALUE"]))) . '">';
                 if ($ps > 0) {
                     $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] .= '<div class="task-complete-bar-in" style="width:' . $ps . '%;"><div class="empty"></div></div>';
                 }
                 $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] .= '</div>';
             } elseif (strlen($propertyValue["USER_TYPE"]) > 0) {
                 if ($propertyValue["USER_TYPE"] == "UserID") {
                     $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = CIntranetTasks::PrepareUserForPrint($propertyValue["VALUE"], $nameTemplate, $bShowLogin, $bShowTooltip, $arTooltipParams);
                 } else {
                     $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = $propertyValue["VALUE"];
                 }
             } elseif ($arField["PROPERTY_TYPE"] == "G") {
                 $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = array();
                 $vx = CIntranetTasks::PrepareSectionForPrint($propertyValue["VALUE"], $propertyValue["LINK_IBLOCK_ID"]);
                 foreach ($vx as $vx1 => $vx2) {
                     $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$vx1] = $vx2["NAME"];
                 }
             } elseif ($propertyValue["PROPERTY_TYPE"] == "L") {
                 $arResult["PROPERTY_" . $propertyKey] = array();
                 $arPropertyValue = $propertyValue["VALUE"];
                 $arPropertyKey = $propertyValue["VALUE_ENUM_ID"];
                 if (!is_array($arPropertyValue)) {
                     $arPropertyValue = array($arPropertyValue);
                     $arPropertyKey = array($arPropertyKey);
                 }
                 for ($i = 0, $cnt = count($arPropertyValue); $i < $cnt; $i++) {
                     $arResult["PROPERTY_" . $propertyKey][$arPropertyKey[$i]] = $arPropertyValue[$i];
                 }
                 $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = $arResult["PROPERTY_" . $propertyKey];
             } elseif ($propertyValue["PROPERTY_TYPE"] == "S" && $propertyValue["ROW_COUNT"] > 1) {
                 if (is_array($propertyValue["VALUE"])) {
                     $arResult["PROPERTY_" . $propertyKey] = array();
                     $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = array();
                     if ($isInSecurity) {
                         foreach ($propertyValue["~VALUE"] as $k => $v) {
                             $filter = new CSecurityFilter();
                             $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$k] = $filter->TestXSS($v);
                             $arResult["PROPERTY_" . $propertyKey][$k] = $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$k];
                         }
                     } else {
                         foreach ($propertyValue["VALUE"] as $k => $v) {
                             $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$k] = nl2br($v);
                             $arResult["PROPERTY_" . $propertyKey][$k] = $v;
                         }
                     }
                 } else {
                     if ($isInSecurity) {
                         $filter = new CSecurityFilter();
                         $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = $filter->TestXSS($propertyValue["~VALUE"]);
                         $arResult["PROPERTY_" . $propertyKey] = $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"];
                     } else {
                         $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = nl2br($propertyValue["VALUE"]);
                         $arResult["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"];
                     }
                 }
             }
         }
         $arResult["ROOT_SECTION_ID"] = 0;
         $arResult["IBLOCK_SECTION_ID_PRINTABLE"] = array();
         $v = CIntranetTasks::PrepareSectionForPrint($arResult["IBLOCK_SECTION_ID"]);
         foreach ($v as $k1 => $v1) {
             if ($arResult["ROOT_SECTION_ID"] == 0) {
                 $arResult["ROOT_SECTION_ID"] = $k1;
                 $taskType = $v1["XML_ID"] == "users_tasks" ? "user" : "group";
                 $ownerId = $taskType == "user" ? $arResult["PROPERTY_TaskAssignedTo"] : $v1["XML_ID"];
             } else {
                 $arResult["IBLOCK_SECTION_ID_PRINTABLE"][$k1] = $v1["NAME"];
             }
         }
         if (!array_key_exists($taskType . "_" . $ownerId, $arCache)) {
             $arCurrentUserGroups = array();
             if ($taskType == "group") {
                 $arCurrentUserGroups[] = SONET_ROLES_ALL;
                 if ($GLOBALS["USER"]->IsAuthorized()) {
                     $arCurrentUserGroups[] = SONET_ROLES_AUTHORIZED;
                 }
                 $r = CSocNetUserToGroup::GetUserRole($USER->GetID(), $ownerId);
                 if (strlen($r) > 0) {
                     $arCurrentUserGroups[] = $r;
                 }
             } else {
                 $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_ALL;
                 if ($GLOBALS["USER"]->IsAuthorized()) {
                     $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_AUTHORIZED;
                 }
                 if (CSocNetUserRelations::IsFriends($USER->GetID(), $ownerId)) {
                     $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_FRIENDS;
                 } elseif (CSocNetUserRelations::IsFriends2($USER->GetID(), $ownerId)) {
                     $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_FRIENDS2;
                 }
             }
             $arCache[$taskType . "_" . $ownerId] = $arCurrentUserGroups;
         }
         $arCurrentUserGroups = $arCache[$taskType . "_" . $ownerId];
         if ($USER->GetID() == $arResult["CREATED_BY"]) {
             $arCurrentUserGroups[] = "author";
         }
         if ($USER->GetID() == $arResult["PROPERTY_TaskAssignedTo"]) {
             $arCurrentUserGroups[] = "responsible";
         }
         if (is_array($arResult["PROPERTY_TaskTrackers"]) && in_array($USER->GetID(), $arResult["PROPERTY_TaskTrackers"])) {
             $arCurrentUserGroups[] = "trackers";
         }
         $arResult["DocumentState"] = array();
         $arDocumentStates = CBPDocument::GetDocumentStates(array("intranet", "CIntranetTasksDocument", "x" . $iblockId), array("intranet", "CIntranetTasksDocument", $arResult["ID"]));
         $kk = array_keys($arDocumentStates);
         foreach ($kk as $k) {
             $arResult["DocumentState"] = $arDocumentStates[$k];
             $arResult["DocumentState"]["AllowableEvents"] = CBPDocument::GetAllowableEvents($GLOBALS["USER"]->GetID(), $arCurrentUserGroups, $arDocumentStates[$k]);
         }
         $arResult["TaskType"] = $taskType;
         $arResult["OwnerId"] = $ownerId;
         $arResult["CurrentUserCanViewTask"] = CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_READ_DOCUMENT, $GLOBALS["USER"]->GetID(), $arResult["ID"], array("TaskType" => $taskType, "OwnerId" => $ownerId, "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
         $arResult["CurrentUserCanCommentTask"] = CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_COMMENT_DOCUMENT, $GLOBALS["USER"]->GetID(), $arResult["ID"], array("TaskType" => $taskType, "OwnerId" => $ownerId, "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
         $arResult["CurrentUserCanDeleteTask"] = CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_DELETE_DOCUMENT, $GLOBALS["USER"]->GetID(), $arResult["ID"], array("TaskType" => $taskType, "OwnerId" => $ownerId, "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
         $arResult["CurrentUserCanWriteTask"] = CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_WRITE_DOCUMENT, $GLOBALS["USER"]->GetID(), $arResult["ID"], array("TaskType" => $taskType, "OwnerId" => $ownerId, "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
         //$hFileTmp = fopen($_SERVER["DOCUMENT_ROOT"]."/+++++++.+++", "a");  // DUMPING
         //fwrite($hFileTmp, "arResult:\n".print_r($arResult, true)."\n");
         //fclose($hFileTmp);
         $arResultList[] = $arResult;
     }
     $dbTasksList1 = new CDBResult();
     $dbTasksList1->InitFromArray($arResultList);
     return array($dbTasksList1, $dbTasksList);
 }
 function CanPerformOperation($userID, $type, $id, $feature, $operation, $bCurrentUserIsAdmin = false)
 {
     global $arSocNetFeaturesSettings, $arSocNetAllowedEntityTypes;
     $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) {
         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 (COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y") {
                         $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 {
                         $arReturn[$arGroupTmp["ID"]] = false;
                         continue;
                     }
                 }
             }
             return $arReturn;
         } else {
             $group_id = IntVal($id);
             if ($featureOperationPerms == false) {
                 return false;
             }
             $userRoleInGroup = CSocNetUserToGroup::GetUserRole($userID, $id);
             if ($userRoleInGroup == SONET_ROLES_BAN) {
                 return false;
             }
             $arGroupTmp = CSocNetGroup::GetByID($id);
             if ($arGroupTmp["CLOSED"] == "Y" && !in_array($operation, $arSocNetFeaturesSettings[$feature]["minoperation"])) {
                 if (COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y") {
                     return false;
                 } else {
                     $featureOperationPerms = SONET_ROLES_OWNER;
                 }
             }
             if ($bCurrentUserIsAdmin) {
                 return true;
             }
             if ($featureOperationPerms == SONET_ROLES_ALL) {
                 if ($arGroupTmp["VISIBLE"] == "N") {
                     $featureOperationPerms = SONET_ROLES_USER;
                 } else {
                     return true;
                 }
             }
             if ($featureOperationPerms == SONET_ROLES_AUTHORIZED) {
                 if ($userID > 0) {
                     return true;
                 } else {
                     return false;
                 }
             }
             if ($userRoleInGroup == false) {
                 return false;
             }
             if ($featureOperationPerms == SONET_ROLES_MODERATOR) {
                 if ($userRoleInGroup == SONET_ROLES_MODERATOR || $userRoleInGroup == SONET_ROLES_OWNER) {
                     return true;
                 } else {
                     return false;
                 }
             } elseif ($featureOperationPerms == SONET_ROLES_USER) {
                 if ($userRoleInGroup == SONET_ROLES_MODERATOR || $userRoleInGroup == SONET_ROLES_OWNER || $userRoleInGroup == SONET_ROLES_USER) {
                     return true;
                 } else {
                     return false;
                 }
             } elseif ($featureOperationPerms == SONET_ROLES_OWNER) {
                 if ($userRoleInGroup == SONET_ROLES_OWNER) {
                     return true;
                 } else {
                     return false;
                 }
             }
         }
     } else {
         if (is_array($id)) {
             foreach ($id as $entity_id) {
                 if ($featureOperationPerms[$entity_id] == false) {
                     $arReturn[$entity_id] = false;
                     continue;
                 }
                 $usersRelation = CSocNetUserRelations::GetRelation($userID, $entity_id);
                 if ($type == SONET_ENTITY_USER && $userID == $entity_id) {
                     $arReturn[$entity_id] = true;
                     continue;
                 }
                 if ($bCurrentUserIsAdmin) {
                     $arReturn[$entity_id] = true;
                     continue;
                 }
                 if ($userID == $entity_id) {
                     $arReturn[$entity_id] = true;
                     continue;
                 }
                 if ($usersRelation == SONET_RELATIONS_BAN) {
                     if (!IsModuleInstalled("im")) {
                         $arReturn[$entity_id] = false;
                         continue;
                     }
                 }
                 if ($featureOperationPerms[$entity_id] == SONET_RELATIONS_TYPE_NONE) {
                     $arReturn[$entity_id] = false;
                     continue;
                 }
                 if ($featureOperationPerms[$entity_id] == SONET_RELATIONS_TYPE_ALL) {
                     $arReturn[$entity_id] = true;
                     continue;
                 }
                 if ($featureOperationPerms[$entity_id] == SONET_RELATIONS_TYPE_AUTHORIZED) {
                     if ($userID > 0) {
                         $arReturn[$entity_id] = true;
                     } else {
                         $arReturn[$entity_id] = false;
                     }
                     continue;
                 }
                 if ($featureOperationPerms[$entity_id] == SONET_RELATIONS_TYPE_FRIENDS) {
                     if (CSocNetUserRelations::IsFriends($userID, $entity_id)) {
                         $arReturn[$entity_id] = true;
                         continue;
                     } else {
                         $arReturn[$entity_id] = false;
                         continue;
                     }
                 }
                 if ($featureOperationPerms[$entity_id] == SONET_RELATIONS_TYPE_FRIENDS2) {
                     if (CSocNetUserRelations::IsFriends($userID, $entity_id)) {
                         $arReturn[$entity_id] = true;
                         continue;
                     } elseif (CSocNetUserRelations::IsFriends2($userID, $entity_id)) {
                         $arReturn[$entity_id] = true;
                         continue;
                     } else {
                         $arReturn[$entity_id] = false;
                         continue;
                     }
                 }
             }
             return $arReturn;
         } else {
             if ($featureOperationPerms == false) {
                 return false;
             }
             if ($type == SONET_ENTITY_USER && $userID == $id) {
                 return true;
             }
             if ($bCurrentUserIsAdmin) {
                 return true;
             }
             if ($userID == $id) {
                 return true;
             }
             $usersRelation = CSocNetUserRelations::GetRelation($userID, $id);
             if ($usersRelation == SONET_RELATIONS_BAN && !IsModuleInstalled("im")) {
                 return false;
             }
             if ($featureOperationPerms == SONET_RELATIONS_TYPE_NONE) {
                 return false;
             }
             if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
                 return true;
             }
             if ($featureOperationPerms == SONET_RELATIONS_TYPE_AUTHORIZED) {
                 if ($userID > 0) {
                     return true;
                 } else {
                     return false;
                 }
             }
             if ($featureOperationPerms == SONET_RELATIONS_TYPE_FRIENDS) {
                 if (CSocNetUserRelations::IsFriends($userID, $id)) {
                     return true;
                 } else {
                     return false;
                 }
             }
             if ($featureOperationPerms == SONET_RELATIONS_TYPE_FRIENDS2) {
                 if (CSocNetUserRelations::IsFriends($userID, $id)) {
                     return true;
                 } elseif (CSocNetUserRelations::IsFriends2($userID, $id)) {
                     return true;
                 } else {
                     return false;
                 }
             }
         }
     }
     return false;
 }
Ejemplo n.º 4
0
         $arCurrentUserGroups[] = SONET_ROLES_ALL;
         if ($GLOBALS["USER"]->IsAuthorized()) {
             $arCurrentUserGroups[] = SONET_ROLES_AUTHORIZED;
         }
         $r = CSocNetUserToGroup::GetUserRole($USER->GetID(), $arTaskTmp["OwnerId"]);
         if (strlen($r) > 0) {
             $arCurrentUserGroups[] = $r;
         }
     } else {
         $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_ALL;
         if ($GLOBALS["USER"]->IsAuthorized()) {
             $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_AUTHORIZED;
         }
         if (CSocNetUserRelations::IsFriends($USER->GetID(), $arTaskTmp["ownerId"])) {
             $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_FRIENDS;
         } elseif (CSocNetUserRelations::IsFriends2($USER->GetID(), $arTaskTmp["ownerId"])) {
             $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_FRIENDS2;
         }
     }
     if ($USER->GetID() == $arTaskTmp["CREATED_BY"]) {
         $arCurrentUserGroups[] = "author";
     }
     if ($USER->GetID() == $arTaskTmp["PROPERTY_TaskAssignedTo"]) {
         $arCurrentUserGroups[] = "responsible";
     }
     if (is_array($arTaskTmp["PROPERTY_TaskTrackers"]) && in_array($USER->GetID(), $arTaskTmp["PROPERTY_TaskTrackers"])) {
         $arCurrentUserGroups[] = "trackers";
     }
 }
 if (count($arErrorsTmp) <= 0) {
     $iblockElementObject = new CIBlockElement();