/** * Get configuration * * @param string $passkey * @param string $confkey * @return string */ private function _getConfig($confkey) { $conf = Configuration::LoadByKey($confkey); if (!$conf) { return self::NOT_FOUND; } return $conf->key_value; }
public function actionDatabaseUpgrade($online = 50, $total = 100, $tag = '') { Yii::log("Checking db to see if we're current", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); $oXML = $this->isDatabaseCurrent(); if ($oXML->schema == 'current') { echo json_encode(array('result' => "success", 'makeline' => $total, 'tag' => $tag, 'total' => $total)); return; } //If we're here, we have something to do switch ($oXML->changetype) { case 'yii': //Don't do anything here, it was already done by the framework break; case 'run_task': $this->runTask($oXML->schema); break; case 'add_column': $elements = explode(".", $oXML->elementname); $res = Yii::app()->db->createCommand("SHOW COLUMNS FROM " . $elements[0] . " WHERE Field='" . $elements[1] . "'")->execute(); if (!$res) { Yii::app()->db->createCommand($oXML->sqlstatement)->execute(); } break; case 'drop_column': $elements = explode(".", $oXML->elementname); $res = Yii::app()->db->createCommand("SHOW COLUMNS FROM " . $elements[0] . " WHERE Field='" . $elements[1] . "'")->execute(); if ($res) { Yii::app()->db->createCommand($oXML->sqlstatement)->execute(); } break; case 'add_configuration_key': $objKey = Configuration::LoadByKey($oXML->elementname); if (!$objKey) { Yii::app()->db->createCommand($oXML->sqlstatement)->execute(); } break; default: Yii::app()->db->createCommand($oXML->sqlstatement)->execute(); } $oXML = $this->isDatabaseCurrent(true); if ($oXML->schema == "current") { echo json_encode(array('result' => "success", 'makeline' => $total, 'tag' => $tag, 'total' => $total)); return; } else { $tag .= " " . $oXML->schema; $makeline = $online + 5; if ($makeline >= $total) { $makeline -= 5; } //keep it from artificially ending echo json_encode(array('result' => "success", 'makeline' => $makeline, 'tag' => $tag, 'total' => $total)); } }
/** * Get configuration * * @param string $passkey * @param string $confkey * @return string */ public function get_config($passkey, $confkey) { if (!$this->check_passkey($passkey)) { return self::FAIL_AUTH; } $conf = Configuration::LoadByKey($confkey); if (!$conf) { return self::NOT_FOUND; } return $conf->Value; }
/** * 29 Cleanup details, config options that have changed, NULL where we had 0's, etc. * @return string */ protected function actionUpdateConfiguration() { //Migrate our header image to the new folder $objConfig = Configuration::LoadByKey('HEADER_IMAGE'); $objConfig->key_value = str_replace("/photos/", "/images/header/", $objConfig->key_value); $objConfig->save(); $objConfig = Configuration::LoadByKey('PRODUCT_SORT_FIELD'); $objConfig->key_value = str_replace("Name", "title", $objConfig->key_value); $objConfig->key_value = str_replace("Rowid", "id", $objConfig->key_value); $objConfig->key_value = str_replace("Modified", "modified", $objConfig->key_value); $objConfig->key_value = str_replace("Code", "code", $objConfig->key_value); $objConfig->key_value = str_replace("InventoryTotal", "inventory_total", $objConfig->key_value); $objConfig->key_value = str_replace("DescriptionShort", "description_short", $objConfig->key_value); $objConfig->key_value = str_replace("WebKeyword1", "title", $objConfig->key_value); $objConfig->key_value = str_replace("WebKeyword2", "title", $objConfig->key_value); $objConfig->key_value = str_replace("WebKeyword3", "title", $objConfig->key_value); $objConfig->save(); //What we're gonna do right here is go back.... way back... return array('result' => "success", 'makeline' => 50, 'tag' => 'Migrating Database', 'total' => 50); }
public function SetIdStr() { $strQueryFormat = 'SELECT COUNT(id) FROM xlsws_cart WHERE ' . '`id_str` = "%s" AND `id` != "%s";'; if (!$this->id_str) { $this->id_str = Cart::GetCartNextIdStr(); } $strQuery = sprintf($strQueryFormat, $this->id_str, $this->id); while (Yii::app()->db->createCommand($strQuery)->queryScalar() != '0') { $this->id_str++; $strQuery = sprintf($strQueryFormat, $this->id_str, $this->id); } try { $this->Save(); } catch (Exception $objExc) { Yii::log('Failed to save cart with : ' . $objExc, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); } $objConf = Configuration::LoadByKey('NEXT_ORDER_ID'); $objConf->key_value = intval(preg_replace("/[^0-9]/", "", $this->id_str)) + 1; $objConf->save(); }
function _xls_insert_conf($key, $title, $value, $helperText, $configType, $options, $sortOrder = NULL, $templateSpecific = 0) { $conf = Configuration::LoadByKey($key); if (!$conf) { $conf = new Configuration(); } $conf->key_name = $key; $conf->title = $title; $conf->key_value = $value; $conf->helper_text = $helperText; $conf->configuration_type_id = $configType; $conf->options = $options; $query = <<<EOS \t\tSELECT IFNULL(MAX(sortOrder),0)+1 \t\tFROM xlsws_configuration \t\tWHERE configuration_type_id = '{$configType}'; EOS; if (!$sortOrder) { $sortOrder = Configuration::model()->findBySql($query); } $conf->sort_order = $sortOrder; $conf->template_specific = $templateSpecific; $conf->created = new CDbExpression('NOW()'); $conf->modified = new CDbExpression('NOW()'); if (!$conf->save()) { print_r($conf->getErrors()); } }