示例#1
0
 /**
  * @param $action
  * @param $arFields
  * @return bool
  */
 protected function checkFields($action, &$arFields)
 {
     global $DB;
     if (($action == 'ADD' || isset($arFields["DOC_TYPE"])) && strlen($arFields["DOC_TYPE"]) <= 0 && !isset(self::$types[$arFields["DOC_TYPE"]])) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("CAT_DOC_WRONG_TYPE"));
         return false;
     }
     if (($action == 'ADD' || isset($arFields["SITE_ID"])) && strlen($arFields["SITE_ID"]) <= 0) {
         return false;
     }
     if (isset($arFields["STATUS"]) && $arFields["STATUS"] === 'Y') {
         $arFields['~DATE_STATUS'] = $DB->GetNowFunction();
     }
     if (isset($arFields["DATE_DOCUMENT"]) && !CDataBase::IsDate($arFields["DATE_DOCUMENT"])) {
         unset($arFields["DATE_DOCUMENT"]);
         $arFields['~DATE_DOCUMENT'] = $DB->GetNowFunction();
     }
     return true;
 }
示例#2
0
 /**
  * @param $action
  * @param $arFields
  * @return bool
  */
 protected function checkFields($action, &$arFields)
 {
     global $DB;
     global $APPLICATION;
     if (($action == 'ADD' || isset($arFields["DOC_TYPE"])) && strlen($arFields["DOC_TYPE"]) <= 0 && !isset(self::$types[$arFields["DOC_TYPE"]])) {
         $APPLICATION->ThrowException(GetMessage("CAT_DOC_WRONG_TYPE"));
         return false;
     }
     if (($action == 'ADD' || isset($arFields["SITE_ID"])) && strlen($arFields["SITE_ID"]) <= 0) {
         $APPLICATION->ThrowException(GetMessage("CAT_DOC_WRONG_SITE_ID"));
         return false;
     }
     if ($action == 'ADD' || array_key_exists('STATUS', $arFields)) {
         $arFields['STATUS'] = 'Y' == $arFields['STATUS'] ? 'Y' : 'N';
     }
     if (isset($arFields["STATUS"])) {
         $arFields['~DATE_STATUS'] = $DB->GetNowFunction();
     }
     if (isset($arFields["DATE_DOCUMENT"]) && !CDataBase::IsDate($arFields["DATE_DOCUMENT"])) {
         unset($arFields["DATE_DOCUMENT"]);
         $arFields['~DATE_DOCUMENT'] = $DB->GetNowFunction();
     }
     return true;
 }