예제 #1
0
function CheckFields()
{
    global $ID, $NAME, $SID, $C_TYPE, $arrSITE, $DB;
    $str = "";
    $arMsg = array();
    if (strlen(trim($NAME)) <= 0) {
        //$str .= GetMessage("SUP_FORGOT_NAME")."<br>";
        $arMsg[] = array("id" => "NAME", "text" => GetMessage("SUP_FORGOT_NAME"));
    }
    if (preg_match("/[^A-Za-z_0-9]/", $SID)) {
        //$str .= GetMessage("SUP_INCORRECT_SID")."<br>";
        $arMsg[] = array("id" => "SID", "text" => GetMessage("SUP_INCORRECT_SID"));
    } elseif (strlen($SID) > 0 && is_array($arrSITE) && count($arrSITE) > 0) {
        $arFilter = array("ID" => "~" . $ID, "TYPE" => $C_TYPE, "SID" => $SID, "SITE" => $arrSITE);
        $z = CTicketDictionary::GetList($v1, $v2, $arFilter, $v3);
        if ($zr = $z->Fetch()) {
            $s = str_replace("#TYPE#", CTicketDictionary::GetTypeNameByID($str_C_TYPE), GetMessage("SUP_SID_ALREADY_IN_USE"));
            $s = str_replace("#LANG#", strlen($zr['LID']) > 0 ? $zr['LID'] : strtolower($zr['SITE_ID']), $s);
            $s = str_replace("#RECORD_ID#", $zr["ID"], $s);
            //$str .= $s."<br>";
            $arMsg[] = array("id" => "SID", "text" => $s);
        }
    }
    if (!empty($arMsg)) {
        $e = new CAdminException($arMsg);
        $GLOBALS["APPLICATION"]->ThrowException($e);
        return false;
    }
    return true;
}
예제 #2
0
 function CheckFields($arFields, $id = false)
 {
     $arMsg = array();
     if ($id === false && !(array_key_exists('NAME', $arFields) && strlen($arFields['NAME']) > 0)) {
         $arMsg[] = array("id" => "NAME", "text" => GetMessage("SUP_FORGOT_NAME"));
     }
     if ($id !== false) {
         $rs = CTicketDictionary::GetByID($id);
         if (!$rs->Fetch()) {
             $arMsg[] = array("id" => "ID", "text" => GetMessage("SUP_UNKNOWN_ID", array('#ID#' => $id)));
         }
     }
     if (array_key_exists('SID', $arFields) && preg_match("#[^A-Za-z_0-9]#", $arFields['SID'])) {
         $arMsg[] = array("id" => "SID", "text" => GetMessage("SUP_INCORRECT_SID"));
     } elseif (strlen($arFields['SID']) > 0 && array_key_exists('arrSITE', $arFields) && is_array($arFields['arrSITE']) && count($arFields['arrSITE']) > 0) {
         $arFilter = array("TYPE" => $arFields['C_TYPE'], "SID" => $arFields['SID'], "SITE" => $arFields['arrSITE']);
         if (intval($id) > 0) {
             $arFilter['ID'] = '~' . intval($id);
         }
         $z = CTicketDictionary::GetList($v1, $v2, $arFilter, $v3);
         if ($zr = $z->Fetch()) {
             $arMsg[] = array("id" => "SID", "text" => GetMessage('SUP_SID_ALREADY_IN_USE', array('#TYPE#' => CTicketDictionary::GetTypeNameByID($arFields['C_TYPE']), '#LANG#' => strlen($zr['LID']) > 0 ? $zr['LID'] : $zr['SITE_ID'], '#RECORD_ID#' => $zr['ID'])));
         }
     }
     if (count($arMsg) > 0) {
         $e = new CAdminException($arMsg);
         $GLOBALS['APPLICATION']->ThrowException($e);
         return false;
     }
     return true;
 }