Ejemplo n.º 1
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     global $DB, $arSocNetAllowedInitiatePerms, $arSocNetAllowedSpamPerms;
     if ($ACTION != "ADD" && IntVal($ID) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException("System error 870164", "ERROR");
         return false;
     }
     if ($ID === 0 && !is_set($arFields, "SITE_ID") || is_set($arFields, "SITE_ID") && (is_array($arFields["SITE_ID"]) && count($arFields["SITE_ID"]) <= 0 || !is_array($arFields["SITE_ID"]) && strlen($arFields["SITE_ID"]) <= 0)) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GG_EMPTY_SITE_ID"), "EMPTY_SITE_ID");
         return false;
     } elseif (is_set($arFields, "SITE_ID")) {
         if (!is_array($arFields["SITE_ID"])) {
             $arFields["SITE_ID"] = array($arFields["SITE_ID"]);
         }
         foreach ($arFields["SITE_ID"] as $v) {
             $r = CSite::GetByID($v);
             if (!$r->Fetch()) {
                 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $v, GetMessage("SONET_GG_ERROR_NO_SITE")), "ERROR_NO_SITE");
                 return false;
             }
         }
     }
     if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_NAME"), "EMPTY_NAME");
         return false;
     }
     if (is_set($arFields, "DATE_CREATE") && !$DB->IsDate($arFields["DATE_CREATE"], false, LANG, "FULL")) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_DATE_CREATE"), "EMPTY_DATE_CREATE");
         return false;
     }
     if (is_set($arFields, "DATE_UPDATE") && !$DB->IsDate($arFields["DATE_UPDATE"], false, LANG, "FULL")) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_DATE_UPDATE"), "EMPTY_DATE_UPDATE");
         return false;
     }
     if (is_set($arFields, "DATE_ACTIVITY") && !$DB->IsDate($arFields["DATE_ACTIVITY"], false, LANG, "FULL")) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_DATE_ACTIVITY"), "EMPTY_DATE_ACTIVITY");
         return false;
     }
     if ((is_set($arFields, "OWNER_ID") || $ACTION == "ADD") && IntVal($arFields["OWNER_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_OWNER_ID"), "EMPTY_OWNER_ID");
         return false;
     } elseif (is_set($arFields, "OWNER_ID")) {
         $dbResult = CUser::GetByID($arFields["OWNER_ID"]);
         if (!$dbResult->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_ERROR_NO_OWNER_ID"), "ERROR_NO_OWNER_ID");
             return false;
         }
     }
     if ((is_set($arFields, "SUBJECT_ID") || $ACTION == "ADD") && IntVal($arFields["SUBJECT_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_SUBJECT_ID"), "EMPTY_SUBJECT_ID");
         return false;
     } elseif (is_set($arFields, "SUBJECT_ID")) {
         $arResult = CSocNetGroupSubject::GetByID($arFields["SUBJECT_ID"]);
         if ($arResult == false) {
             $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_ERROR_NO_SUBJECT_ID"), "ERROR_NO_SUBJECT_ID");
             return false;
         }
     }
     if ((is_set($arFields, "ACTIVE") || $ACTION == "ADD") && $arFields["ACTIVE"] != "Y" && $arFields["ACTIVE"] != "N") {
         $arFields["ACTIVE"] = "Y";
     }
     if ((is_set($arFields, "VISIBLE") || $ACTION == "ADD") && $arFields["VISIBLE"] != "Y" && $arFields["VISIBLE"] != "N") {
         $arFields["VISIBLE"] = "Y";
     }
     if ((is_set($arFields, "OPENED") || $ACTION == "ADD") && $arFields["OPENED"] != "Y" && $arFields["OPENED"] != "N") {
         $arFields["OPENED"] = "N";
     }
     if ((is_set($arFields, "CLOSED") || $ACTION == "ADD") && $arFields["CLOSED"] != "Y" && $arFields["CLOSED"] != "N") {
         $arFields["CLOSED"] = "N";
     }
     if ((is_set($arFields, "INITIATE_PERMS") || $ACTION == "ADD") && strlen($arFields["INITIATE_PERMS"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UG_EMPTY_INITIATE_PERMS"), "EMPTY_INITIATE_PERMS");
         return false;
     } elseif (is_set($arFields, "INITIATE_PERMS") && !in_array($arFields["INITIATE_PERMS"], $arSocNetAllowedInitiatePerms)) {
         $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["INITIATE_PERMS"], GetMessage("SONET_UG_ERROR_NO_INITIATE_PERMS")), "ERROR_NO_INITIATE_PERMS");
         return false;
     }
     if ((is_set($arFields, "SPAM_PERMS") || $ACTION == "ADD") && strlen($arFields["SPAM_PERMS"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UG_EMPTY_SPAM_PERMS"), "EMPTY_SPAM_PERMS");
         return false;
     } elseif (is_set($arFields, "SPAM_PERMS") && !in_array($arFields["SPAM_PERMS"], $arSocNetAllowedSpamPerms)) {
         $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["SPAM_PERMS"], GetMessage("SONET_UG_ERROR_NO_SPAM_PERMS")), "ERROR_NO_SPAM_PERMS");
         return false;
     }
     if (is_set($arFields, "IMAGE_ID") && strlen($arFields["IMAGE_ID"]["name"]) <= 0 && (strlen($arFields["IMAGE_ID"]["del"]) <= 0 || $arFields["IMAGE_ID"]["del"] != "Y")) {
         unset($arFields["IMAGE_ID"]);
     }
     if (is_set($arFields, "IMAGE_ID")) {
         $arResult = CFile::CheckImageFile($arFields["IMAGE_ID"], 0, 0, 0);
         if (strlen($arResult) > 0) {
             $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GP_ERROR_IMAGE_ID") . ": " . $arResult, "ERROR_IMAGE_ID");
             return false;
         }
     }
     if (!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("SONET_GROUP", $ID, $arFields)) {
         return false;
     }
     return True;
 }
Ejemplo n.º 2
0
        } else {
            $arResult["ERROR_MESSAGE"] = GetMessage("SONET_C24_EMPTY");
        }
    } else {
        $arResult["ERROR_MESSAGE"] = GetMessage("SONET_C24_ERROR") . $obSearch->error;
    }
} else {
    $arNavParams = array("nPageSize" => $arParams["ITEMS_COUNT"], "bDescPageNumbering" => false);
    $arNavigation = CDBResult::GetNavParams($arNavParams);
    $arFilterTmp = array("SITE_ID" => SITE_ID, "ACTIVE" => "Y");
    if (!CSocNetUser::IsCurrentUserModuleAdmin()) {
        $arFilterTmp["CHECK_PERMISSIONS"] = $GLOBALS["USER"]->GetID();
    }
    if ($arParams["SUBJECT_ID"] > 0) {
        $arFilterTmp["SUBJECT_ID"] = $arParams["SUBJECT_ID"];
        $arCurrentSubject = CSocNetGroupSubject::GetByID($arParams["SUBJECT_ID"]);
        if ($arCurrentSubject && $arParams["SET_TITLE"] == "Y") {
            $APPLICATION->SetTitle($arCurrentSubject["NAME"]);
        }
    }
    if ($arParams["SUBJECT_ID"] == -1) {
        $arFilterTmp["CLOSED"] = "Y";
        if ($arParams["SET_TITLE"] == "Y") {
            $APPLICATION->SetTitle(GetMessage("SONET_C24_PAGE_TITLE_ARCHIVE"));
        }
    } else {
        $arFilterTmp["CLOSED"] = "N";
    }
    if (strlen($arResult["~q"]) > 0) {
        $arFilterTmp["~NAME"] = "%" . $arResult["~q"] . "%";
    }
Ejemplo n.º 3
0
    } else {
        $bVarsFromForm = true;
    }
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/socialnetwork/prolog.php";
if ($ID > 0) {
    $APPLICATION->SetTitle(GetMessage("SONETE_UPDATING"));
} else {
    $APPLICATION->SetTitle(GetMessage("SONETE_ADDING"));
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
ClearVars("str_");
$str_SORT = "100";
$arSubjectSites = array();
if ($ID > 0) {
    $arSubject = CSocNetGroupSubject::GetByID($ID);
    if (!$arSubject) {
        if ($socialnetworkModulePermissions < "W") {
            $errorMessage .= GetMessage("SONETE_NO_PERMS2ADD") . ". ";
        }
        $ID = 0;
    } else {
        $str_NAME = $arSubject["NAME"];
        $str_SORT = $arSubject["SORT"];
        $rsSubjectSite = CSocNetGroupSubject::GetSite($ID);
        while ($arSubjectSite = $rsSubjectSite->Fetch()) {
            $arSubjectSites[] = $arSubjectSite["LID"];
        }
    }
}
if ($bVarsFromForm) {
Ejemplo n.º 4
0
    if ($_REQUEST['action_target'] == 'selected') {
        $arID = array();
        $dbResultList = CSocNetGroupSubject::GetList(array($by => $order), $arFilter, false, false, array("ID"));
        while ($arResult = $dbResultList->Fetch()) {
            $arID[] = $arResult['ID'];
        }
    }
    foreach ($arID as $ID) {
        if (strlen($ID) <= 0) {
            continue;
        }
        switch ($_REQUEST['action']) {
            case "delete":
                @set_time_limit(0);
                $DB->StartTransaction();
                $arBlogSubjectTmp = CSocNetGroupSubject::GetByID($ID);
                if (!CSocNetGroupSubject::Delete($ID)) {
                    $DB->Rollback();
                    if ($ex = $APPLICATION->GetException()) {
                        $lAdmin->AddGroupError($ex->GetString(), $ID);
                    } else {
                        $lAdmin->AddGroupError(GetMessage("SONET_DELETE_ERROR"), $ID);
                    }
                }
                //BXClearCache(True, "/".$arBlogSubjectTmp["SITE_ID"]."/socialnetwork/");
                $DB->Commit();
                break;
        }
    }
}
$dbResultList = CSocNetGroupSubject::GetList(array($by => $order), $arFilter, false, false, array("ID", "SITE_ID", "NAME", "SORT"));