Esempio n. 1
0
 if (!check_bitrix_sessid()) {
     $arError[] = array("id" => "BAD_SESSID", "text" => GetMessage("F_ERR_SESS_FINISH"));
 } elseif (!in_array($action, array("update", "save", "delete", "remove"))) {
     $arError[] = array("id" => "BAD_ACTION", "text" => GetMessage("F_ERR_ACTION"));
 } else {
     switch ($action) {
         case "update":
             $db_res = CForumPMFolder::GetByID($arParams["FID"]);
             $_REQUEST["FOLDER_TITLE"] = trim($_REQUEST["FOLDER_TITLE"]);
             if (empty($_REQUEST["FOLDER_TITLE"])) {
                 $arError[] = array("id" => "empty_data", "text" => GetMessage("PM_NOT_FOLDER_TITLE"));
             } elseif (!($db_res && ($res = $db_res->GetNext()))) {
                 $arError[] = array("id" => "bad_fid", "text" => GetMessage("PM_NOT_FOLDER"));
             } elseif (!CForumPMFolder::CheckPermissions($arParams["FID"])) {
                 $arError[] = array("id" => "bad_permission", "text" => GetMessage("PM_NOT_RIGHT"));
             } elseif (!CForumPMFolder::Update($arParams["FID"], array("TITLE" => $_REQUEST["FOLDER_TITLE"]))) {
                 $str = "";
                 $err = $APPLICATION->GetException();
                 if ($err) {
                     $str = $err->GetString();
                 }
                 $arError[] = array("id" => "not_updated", "text" => $str);
             }
             break;
         case "save":
             $_REQUEST["FOLDER_TITLE"] = trim($_REQUEST["FOLDER_TITLE"]);
             if (empty($_REQUEST["FOLDER_TITLE"])) {
                 $arError[] = array("id" => "empty_data", "text" => GetMessage("PM_NOT_FOLDER_TITLE"));
             } elseif (!CForumPMFolder::Add($_REQUEST["FOLDER_TITLE"])) {
                 $str = "";
                 $err = $APPLICATION->GetException();
Esempio n. 2
0
     default:
         $strNote = "";
         break;
 }
 //***********************************/input***********************************
 $APPLICATION->ResetException();
 $APPLICATION->ThrowException(" ");
 //***********************************action/**********************************
 switch ($action) {
     case "update":
         $res = CForumPMFolder::GetList(array(), array("ID" => $id));
         if (!($resFolder = $res->GetNext())) {
             $APPLICATION->ThrowException(GetMessage("PM_NOT_FOLDER"));
         } else {
             if (CForumPMFolder::CheckPermissions($id)) {
                 if (CForumPMFolder::Update($id, array("TITLE" => $FOLDER_TITLE))) {
                     LocalRedirect("pm_folder.php?res=saved");
                 }
             } else {
                 $APPLICATION->ThrowException(GetMessage("PM_NOT_RIGHT"));
             }
         }
         break;
     case "save":
         if ($_SERVER['REQUEST_METHOD'] == "POST" && strLen($FOLDER_TITLE) > 0) {
             if (CForumPMFolder::Add($FOLDER_TITLE)) {
                 LocalRedirect("pm_folder.php?res=create");
             }
         } else {
             $APPLICATION->ThrowException(GetMessage("PM_NOT_FOLDER_TITLE"));
         }