Esempio n. 1
0
 function CanUserDeleteMessage($MID, $arUserGroups, $iUserID = 0, $ExternalPermission = false)
 {
     $MID = intVal($MID);
     $arMessage = CForumMessage::GetByIDEx($MID, array("GET_FORUM_INFO" => "Y", "GET_TOPIC_INFO" => "N", "FILTER" => "N"));
     $arForum = $arMessage["FORUM_INFO"];
     if ($arMessage) {
         $FID = intVal($arMessage["FORUM_ID"]);
         if (!CForumUser::IsLocked($iUserID)) {
             $strPerms = $ExternalPermission == false ? CForumNew::GetUserPermission($arForum["ID"], $arUserGroups) : $ExternalPermission;
         } else {
             $strPerms = CForumNew::GetPermissionUserDefault($arForum["ID"], $arUserGroups);
         }
         if ($strPerms >= "Y") {
             return true;
         } elseif ($arForum["ACTIVE"] != "Y") {
             return false;
         }
         return $strPerms >= "U" ? true : false;
     }
     return false;
 }
Esempio n. 2
0
function ForumCurrUserPermissions($FID)
{
    static $arCache = array();
    if (!isset($arCache[$FID])) {
        if ($GLOBALS["USER"]->IsAdmin() || $GLOBALS["APPLICATION"]->GetGroupRight("forum") >= "W") {
            $result = "Y";
        } else {
            $strPerms = CForumNew::GetUserPermission($FID, $GLOBALS["USER"]->GetUserGroupArray());
            if ($strPerms <= "E") {
                $result = $strPerms;
            } elseif (CForumUser::IsLocked($GLOBALS["USER"]->GetID())) {
                $strPerms = CForumNew::GetPermissionUserDefault($GLOBALS["USER"]->GetID());
                $result = $strPerms >= "E" ? $strPerms : "E";
            } else {
                $result = $strPerms;
            }
        }
        $arCache[$FID] = $result;
    }
    return $arCache[$FID];
}
Esempio n. 3
0
function ForumCurrUserPermissions($FID, $arAddParams = array())
{
    static $arCache = array();
    $arAddParams = is_array($arAddParams) ? $arAddParams : array();
    $arAddParams["PERMISSION"] = !!$arAddParams["PERMISSION"] ? $arAddParams["PERMISSION"] : '';
    if (!isset($arCache[$FID . $arAddParams["PERMISSION"]])) {
        if (CForumUser::IsAdmin()) {
            $result = "Y";
        } else {
            $strPerms = !!$arAddParams["PERMISSION"] ? $arAddParams["PERMISSION"] : CForumNew::GetUserPermission($FID, $GLOBALS["USER"]->GetUserGroupArray());
            if ($strPerms <= "E") {
                $result = $strPerms;
            } elseif (CForumUser::IsLocked($GLOBALS["USER"]->GetID())) {
                $strPerms = CForumNew::GetPermissionUserDefault($GLOBALS["USER"]->GetID());
                $result = $strPerms >= "E" ? $strPerms : "E";
            } else {
                $result = $strPerms;
            }
        }
        $arCache[$FID . $arAddParams["PERMISSION"]] = $result;
    }
    return $arCache[$FID . $arAddParams["PERMISSION"]];
}
Esempio n. 4
0
 function CanUserEditForum($FID, $arUserGroups, $iUserID = 0, $ExternalPermission = false)
 {
     $FID = intVal($FID);
     $arUserGroups = !is_array($arUserGroups) ? array($arUserGroups) : $arUserGroups;
     if ($ExternalPermission === false && CForumUser::IsAdmin($arUserGroups)) {
         return true;
     } elseif (!CForumUser::IsLocked($iUserID)) {
         $strPerms = $ExternalPermission == false ? CForumNew::GetUserPermission($FID, $arUserGroups) : $ExternalPermission;
     } else {
         $strPerms = CForumNew::GetPermissionUserDefault($FID);
     }
     if ($strPerms >= "Y") {
         return true;
     }
     $arForum = CForumNew::GetByID($FID);
     if (!is_array($arForum) || $arForum["ACTIVE"] != "Y") {
         return false;
     }
     return $strPerms < "U" ? false : true;
 }
Esempio n. 5
0
 function CanUserDeleteTopicMessage($TID, $arUserGroups, $iUserID = 0, $ExternalPermission = false)
 {
     $TID = intVal($TID);
     $arTopic = CForumTopic::GetByID($TID);
     if ($arTopic) {
         if ($ExternalPermission === false && (in_array(1, $arUserGroups) || $GLOBALS["APPLICATION"]->GetGroupRight("forum", $arUserGroups) >= "W")) {
             return true;
         }
         if (!CForumUser::IsLocked($iUserID)) {
             $strPerms = $ExternalPermission == false ? CForumNew::GetUserPermission($arTopic["FORUM_ID"], $arUserGroups) : $ExternalPermission;
         } else {
             $strPerms = CForumNew::GetPermissionUserDefault($arTopic["FORUM_ID"]);
         }
         if ($strPerms >= "Y") {
             return true;
         } elseif ($strPerms < "U") {
             return false;
         }
         $arForum = CForumNew::GetByID($arTopic["FORUM_ID"]);
         return $arForum["ACTIVE"] == "Y" ? true : false;
     }
     return false;
 }
Esempio n. 6
0
 function CanUserDeleteTopicMessage($TID, $arUserGroups, $iUserID = 0, $ExternalPermission = false)
 {
     $TID = intVal($TID);
     $arTopic = CForumTopic::GetByID($TID);
     if ($arTopic) {
         if ($ExternalPermission === false && CForumUser::IsAdmin($arUserGroups)) {
             return true;
         }
         if (!CForumUser::IsLocked($iUserID)) {
             $strPerms = $ExternalPermission == false ? CForumNew::GetUserPermission($arTopic["FORUM_ID"], $arUserGroups) : $ExternalPermission;
         } else {
             $strPerms = CForumNew::GetPermissionUserDefault($arTopic["FORUM_ID"]);
         }
         if ($strPerms >= "Y") {
             return true;
         } elseif ($strPerms < "U") {
             return false;
         }
         $arForum = CForumNew::GetByID($arTopic["FORUM_ID"]);
         return $arForum["ACTIVE"] == "Y" ? true : false;
     }
     return false;
 }
Esempio n. 7
0
	public static function CanUserEditForum($FID, $arUserGroups, $iUserID = 0, $ExternalPermission = false)
	{
		$FID = intVal($FID);
		$arUserGroups = (!is_array($arUserGroups) ? array($arUserGroups) : $arUserGroups);
		if ($ExternalPermission === false && (in_array(1, $arUserGroups) || $GLOBALS["APPLICATION"]->GetGroupRight("forum", $arUserGroups) >= "W")):
			return true;
		elseif (!CForumUser::IsLocked($iUserID)):
			$strPerms = ($ExternalPermission == false ? CForumNew::GetUserPermission($FID, $arUserGroups) : $ExternalPermission);
		else:
			$strPerms = CForumNew::GetPermissionUserDefault($FID);
		endif;
		if ($strPerms >= "Y"):
			return true;
		endif;
		$arForum = CForumNew::GetByID($FID);
		if (!is_array($arForum) || $arForum["ACTIVE"] != "Y"):
			return false;
		endif;
		return ($strPerms < "U" ? false : true);
	}
Esempio n. 8
0
 public function initPermission()
 {
     if (!array_key_exists($this->forum["ID"], self::$permissions)) {
         if (\CForumUser::IsAdmin($this->getUser()->getGroups())) {
             $result = "Y";
         } else {
             if ($this->forum["ACTIVE"] != "Y") {
                 $result = "A";
             } else {
                 if (\CForumUser::IsLocked($this->getUser()->getID())) {
                     $result = \CForumNew::GetPermissionUserDefault($this->forum["ID"]);
                 } else {
                     $result = \CForumNew::GetUserPermission($this->forum["ID"], $GLOBALS["USER"]->GetUserGroupArray());
                 }
             }
         }
         self::$permissions[$this->forum["ID"]] = $result;
     }
     $this->permission = self::$permissions[$this->forum["ID"]];
     $this->rights = array();
     return $this;
 }