Exemplo n.º 1
0
 public static function Add($arFields)
 {
     global $DB;
     $DB->Query("SELECT * FROM `" . self::$table . "` WHERE `ID` = '" . sSql($arFields["ID"]) . "'");
     if ($DB->numRows()) {
         return false;
     } else {
         $arFieldsTable_1 = array();
         $arFieldsTable_2 = array();
         $tbl_1 = array("ID", "SORT");
         $tbl_2 = array("CATALOG_TYPE_ID", "SID", "NAME", "SECTION_NAME", "ELEMENT_NAME");
         $arFieldsTable_2["CATALOG_TYPE_ID"] = $arFields["ID"];
         foreach ($arFields as $key => $value) {
             if (in_array($key, $tbl_1)) {
                 $arFieldsTable_1[$key] = $value;
             }
             if (in_array($key, $tbl_2)) {
                 $arFieldsTable_2[$key] = $value;
             }
         }
         $sql1 = addSql(self::$table, $arFieldsTable_1);
         $sql2 = addSql(self::$table_lang, $arFieldsTable_2);
         if ($DB->Query($sql1) and $DB->Query($sql2)) {
             return true;
         } else {
             dbError($DB->Error());
             return false;
         }
     }
 }
Exemplo n.º 2
0
 public static function Add($arFields)
 {
     global $DB;
     $DB->Query("SELECT * FROM `" . self::$table . "` WHERE `SID` = '" . sSql($arFields["SID"]) . "'");
     if ($DB->numRows()) {
         return false;
     } else {
         $sql = addSql(self::$table, $arFields);
         if ($DB->Query($sql)) {
             return true;
         } else {
             dbError($DB->Error());
             return false;
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Добавление элемента
  * @param array $arFields
  * @return int $lastID
  */
 public static function Add($arFields)
 {
     global $DB, $USER;
     unset($arFields["ID"]);
     Event::Run('catalog', 'OnBeforeCatalogSectionAdd', $arFields);
     $arProps = $arFields["PROPERTIES"];
     unset($arFields["PROPERTIES"]);
     $arFields['DATE_CREATE'] = date("Y-m-d H:i:s");
     $arFields['TIMESTAMP_X'] = date("Y-m-d H:i:s");
     $arFields['CREATED_BY'] = empty($arFields['CREATED_BY']) ? $USER->GetID() : $arFields['CREATED_BY'];
     $sql = addSql(self::$table, $arFields);
     if ($DB->Query($sql)) {
         self::$lastID = $DB->LastID();
         /*if(!empty($arProps)) {
         			$arPropFields = Array();
         			foreach($arProps as $propCODE => $propValue) {
         				if(is_numeric($propCODE)) {
         					$propID = intVal($propCODE);
         				} else {
         					$propID = self::GetPropIDByCODE($propCODE);
         				}
         				$arPropFields = Array(
         					"CATALOG_PROPERTY_ID" => intVal($propID),
         					"CATALOG_ELEMENT_ID" => self::$lastID,
         					"VALUE" => $propValue,
         					//"VALUE_TYPE",
         					//"VALUE_ENUM",
         					//"DESCRIPTION" => "",
         				);
         				$sqlProps = addSql(self::$table_props_values, $arPropFields);
         				$DB->Query($sqlProps);
         			}
         		}*/
         Event::Run('catalog', 'OnAfterCatalogSectionAdd', $arFields);
         return self::$lastID;
     } else {
         dbError($DB->Error());
         return false;
     }
 }
Exemplo n.º 4
0
 public function SaveFile($arFile = array(), $arFields = array())
 {
     global $DB;
     $arFileFields = array();
     $arFields['MODULE_ID'] = empty($arFields['MODULE_ID']) ? 'main' : $arFields['MODULE_ID'];
     $arUpload = self::UploadFile($arFile, $arFields['MODULE_ID']);
     if ($arUpload['STATUS'] == 'SUCCESS') {
         $arFileFields['FILE_NAME'] = $arUpload['NAME'];
         $arFileInfo = self::GetFileType($arUpload['PATH']);
         $arFileFields['TIMESTAMP_X'] = date("Y-m-d H:i:s");
         $arFileFields['MODULE_ID'] = $arFields['MODULE_ID'];
         if ($arFileInfo['TYPE'] == 'IMAGE') {
             $arFileFields['HEIGHT'] = $arFileInfo['PROPS']['height'];
             $arFileFields['WIDTH'] = $arFileInfo['PROPS']['width'];
         }
         $arFileFields['FILE_SIZE'] = $arFile['size'];
         $arFileFields['CONTENT_TYPE'] = $arFile['type'];
         //$arFileFields['SUBDIR']			=	'';
         $arFileFields['ORIGINAL_NAME'] = $arFile['name'];
         $arFileFields['DESCRIPTION'] = empty($arFields['DESCRIPTION']) ? '' : $arFields['DESCRIPTION'];
         $sql = addSql(self::$file_db, $arFileFields);
         if ($DB->Query($sql)) {
             $newID = $DB->LastID();
             if ($newID > 0) {
                 return $newID;
             } else {
                 return false;
             }
         }
     } else {
         return $arUpload['RESULT'];
     }
 }
Exemplo n.º 5
0
 public static function Add($arFields)
 {
     //d($arFields);
     global $DB, $USER;
     unset($arFields["ID"]);
     Event::Run('catalog', 'OnBeforeCatalogElementAdd', $arFields);
     if (!isset($arFields["CATALOG_ID"]) || intval($arFields["CATALOG_ID"]) == 0) {
         dbError("Не указан идентификатор каталога!");
         return false;
     }
     $arProps = $arFields["PROPERTIES"];
     unset($arFields["PROPERTIES"]);
     $arFields['DATE_CREATE'] = date("Y-m-d H:i:s");
     $arFields['TIMESTAMP_X'] = date("Y-m-d H:i:s");
     $arFields['CREATED_BY'] = empty($arFields['CREATED_BY']) ? $USER->GetID() : $arFields['CREATED_BY'];
     if (is_array($arFields['PREVIEW_PICTURE']) and !empty($arFields['PREVIEW_PICTURE'])) {
         if ($arFields['PREVIEW_PICTURE']['tmp_name'] != '') {
             $fileID = File::SaveFile($arFields['PREVIEW_PICTURE'], array('MODULE_ID' => 'catalog'));
             unset($arFields['PREVIEW_PICTURE']);
             $arFields['PREVIEW_PICTURE'] = $fileID;
         }
     }
     if (is_array($arFields['DETAIL_PICTURE']) and !empty($arFields['DETAIL_PICTURE'])) {
         if ($arFields['DETAIL_PICTURE']['tmp_name'] != '') {
             $fileID = File::SaveFile($arFields['DETAIL_PICTURE'], array('MODULE_ID' => 'catalog'));
             unset($arFields['DETAIL_PICTURE']);
             $arFields['DETAIL_PICTURE'] = $fileID;
         }
     }
     $sql = addSql(self::$table, $arFields);
     if ($DB->Query($sql)) {
         self::$lastID = $DB->LastID();
         if (!empty($arProps)) {
             $arPropFields = array();
             foreach ($arProps as $propCODE => $propValue) {
                 if (is_numeric($propCODE)) {
                     $propID = intVal($propCODE);
                 } else {
                     $propID = self::GetPropIDByCODE($propCODE);
                 }
                 $arPropFields = array("CATALOG_PROPERTY_ID" => intVal($propID), "CATALOG_ELEMENT_ID" => self::$lastID, "VALUE" => $propValue);
                 if (is_array($propValue) and !empty($propValue)) {
                     if ($propValue['tmp_name'] != '') {
                         $fileID = File::SaveFile($propValue, array('MODULE_ID' => 'catalog'));
                         if (intVal($fileID) > 0) {
                             $arPropFields['VALUE'] = $fileID;
                             $arPropFields['VALUE_TYPE'] = 'file';
                             $sqlProps = addSql(self::$table_props_values, $arPropFields);
                             $DB->Query($sqlProps);
                         }
                     } else {
                         foreach ($propValue as $propVal) {
                             if (is_array($propVal)) {
                                 if ($propVal['tmp_name'] != '') {
                                     $fileID = File::SaveFile($propVal, array('MODULE_ID' => 'catalog'));
                                     if (intVal($fileID) > 0) {
                                         $arPropFields['VALUE'] = $fileID;
                                         $arPropFields['VALUE_TYPE'] = 'file';
                                         $sqlProps = addSql(self::$table_props_values, $arPropFields);
                                         $DB->Query($sqlProps);
                                     }
                                 }
                             } else {
                                 if ($propVal != '') {
                                     $arPropFields['VALUE'] = $propVal;
                                     $sqlProps = addSql(self::$table_props_values, $arPropFields);
                                     $DB->Query($sqlProps);
                                 }
                             }
                         }
                     }
                 } else {
                     if (!empty($propValue)) {
                         $sqlProps = addSql(self::$table_props_values, $arPropFields);
                         $DB->Query($sqlProps);
                     }
                 }
             }
         }
         Event::Run('catalog', 'OnAfterCatalogElementAdd', $arFields);
         return self::$lastID;
     } else {
         dbError($DB->Error());
         return false;
     }
 }
Exemplo n.º 6
0
            fclose($fp);
            echo $content;
            die;
        }
    } else {
        $content = $result['MerchantOrderNo'] . ': ERROR_1';
        echo $content;
        fwrite($fp, $content . "\n");
        // 修改訂單狀態 && 新增歷史紀錄 (Only Credit or WebAtm)
        if (in_array($result['PaymentType'], array('CREDIT', 'WEBATM'))) {
            $today = time();
            // 修改訂單狀態
            $update_sql = updateSql($result['MerchantOrderNo'], $pay2go_configs['Pay2goMPG_fail_status_id'], $today, $config->dbprefix);
            mysql_query($update_sql);
            // 新增歷史紀錄
            $insert_sql = addSql($result, $pay2go_configs['Pay2goMPG_fail_status_id'], $today, $config->dbprefix);
            mysql_query($insert_sql);
        }
        fclose($fp);
        die;
    }
} else {
    fwrite($fp, $result['MerchantOrderNo'] . ": DataError\n");
}
fclose($fp);
die;
/**
 * 更新語法
 * 
 * @param string $order_id      更新資料
 * @param string $update_status 更新狀態
Exemplo n.º 7
0
 /**
  * Добавить пользователя в группу
  * @global object $DB
  * @param int $USER_ID
  * @param int $GROUP_ID
  * @param [date $FROM]
  * @param [date $TO]
  * @return bool
  */
 public function AddGroup($USER_ID, $GROUP_ID, $FROM = false, $TO = false)
 {
     $DB = App::DB();
     if ($this->InGroup($USER_ID, $GROUP_ID)) {
         return false;
     }
     $arGroup = array("USER_ID" => intVal($USER_ID), "GROUP_ID" => intVal($GROUP_ID));
     if ($FROM) {
         $arGroup["DATE_ACTIVE_FROM"] = $FROM;
     }
     if ($TO) {
         $arGroup["DATE_ACTIVE_TO"] = $TO;
     }
     $sql = addSql('b_user_group', $arGroup);
     if ($DB->Query($sql)) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 8
0
 public static function Update($ID, $arFields)
 {
     global $DB;
     Event::Run('catalog', 'OnBeforeCatalogUpdate', $arFields);
     $DB->Query("SELECT * FROM `" . self::$table . "` WHERE `ID` = '" . intVal($ID) . "'");
     if (!$DB->numRows()) {
         return false;
     } else {
         $arProps = $arFields["PROPERTIES"];
         unset($arFields["PROPERTIES"]);
         $arFields['TIMESTAMP_X'] = date("Y-m-d H:i:s");
         $sql = updSql(self::$table, $arFields) . " WHERE `ID` = '" . intVal($ID) . "';";
         if ($DB->Query($sql)) {
             // Свойства каталога
             if (!empty($arProps)) {
                 foreach ($arProps as $arProp) {
                     if (!empty($arProp["NAME"])) {
                         if (!empty($arProp["ID"])) {
                             if (!empty($arProp["VALUES"]) and !empty($arProp["ID"])) {
                                 foreach ($arPropValues as $arValue) {
                                     self::updatePropertyEnum($arProp["ID"], $arValue);
                                 }
                             }
                             unset($arProp["VALUES"]);
                             $propID = $arProp["ID"];
                             unset($arProp["ID"]);
                             $sql = updSql(self::$table_props, $arProp) . " WHERE `ID` = '" . intVal($propID) . "';";
                             $DB->Query($sql);
                         } else {
                             $arValues = array();
                             $arValues = $arProp["VALUES"];
                             unset($arProp["ID"]);
                             unset($arProp["VALUES"]);
                             $arProp["CATALOG_ID"] = intVal($ID);
                             $sql = addSql(self::$table_props, $arProp);
                             $DB->Query($sql);
                             $propId = $DB->LastID();
                             if (!empty($arValues)) {
                                 foreach ($arValues as $arValue) {
                                     self::createPropertyEnum($propId, $arValue);
                                 }
                             }
                         }
                     }
                 }
             }
             Event::Run('catalog', 'OnAfterCatalogUpdate', $arFields);
             return true;
         } else {
             dbError($DB->Error());
             return false;
         }
     }
 }