/** * @param Modification $mod * @return void */ private function applyModification(Modification $mod) { // First get the map for this modification $map = $mod->getMap(); // Get the selected setting $setting = $mod->getSetting(); // Get all ranges and iterate through them $ranges = $map->getRanges(); foreach ($ranges as $range) { // Define start and end of the range $rangeStart = hexdec($range->getStart()); $rangeEnd = hexdec($range->getEnd()); // Iterate through every single position within the range for ($offset = $rangeStart; $offset <= $rangeEnd; $offset++) { // Hex represantation of our decimal offset $hexOffset = str_pad(dechex($offset), 5, '0', STR_PAD_LEFT); // Seek to offset position fseek($this->_patchedFile, $offset); // Check if the setting contains a value for this position if ($setting->hasValueAtOffset($hexOffset)) { $value = $setting->getValue($hexOffset); fwrite($this->_patchedFile, pack('H*', $value->getValue())); continue; } // Setting does not contain a value for this position, so // we'll write the value of the original file from this position fseek($this->_originalFile, $offset); fwrite($this->_patchedFile, fread($this->_originalFile, 1)); } } }
function ShowModifications(&$p, $db_table, $db_id) { global $database; $m_mod = new Modification($database); $m_auth = new Auth($database); $mods = $m_mod->byTableID($db_table, $db_id); if (!false_or_null($mods)) { $data = array(); foreach ($mods as $mod) { $user = $m_auth->Get($mod['r_Auth']); $what = ''; $w = json_decode($mod['What'], true); foreach ($w as $dataset) { foreach ($dataset as $table => $change) { $what .= $table . ' #' . $change['I'] . '\'s ' . $change['F'] . (isset($change['E']) ? ' » ' . $change['E'] : ''); } } $data[] = array($user['username'], $what, $mod['Message'], human_datetime(intval($mod['Timestamp']))); } $table = new TableHelper(array('table' => "table wide", 'thead' => "tablehead", 'th' => "tablehead", 'td' => "tablecell", 'headings' => array('Who', 'What', ' ', 'When'), 'data' => $data)); $p->HTML('<div class="formgroup">'); $p->HTML('<h4>Recent Activity</h4>'); $p->Table($table); $p->HTML('</div>'); } }
public function insertNewModif($bdd, $change_id, $table_name, $author_id) { $newModif = new Modification(); $date = date("Y-m-d"); $newModif->setDate($date); $newModif->setChange_id($change_id); $newModif->setTable_name($table_name); $newModif->setAuthor_id($author_id); $addmodif = $bdd->prepare("INSERT INTO modification(date, change_id, table_name, author_id) " . "values (:date, :change, :table, :author)"); $addmodif->execute(array(":date" => $newModif->date, ":change" => $newModif->change_id, ":table" => $newModif->table_name, ":author" => $newModif->author_id)); }
public function applyModificationTaxRate(Modification $mod) { if ($mod->SubTotalModifier) { $order = $mod->Order(); // Orders shipped within New Zealand have tax applied if ($order && $order->exists() && $order->ShippingCountryCode == 'NZ') { $mod->XeroTaxType = 'OUTPUT2'; $mod->XeroTaxRate = 15.0; } else { $mod->XeroTaxType = 'NONE'; $mod->XeroTaxRate = 0.0; } $mod->write(); } }
public function onBeforeWrite() { parent::onBeforeWrite(); if (!$this->Currency) { $this->Currency = ShopConfig::current_shop_config()->BaseCurrency; } }
/** * Отображения списка модификаций модели */ public function actionModifications($mark, $model) { if (Yii::app()->request->isAjaxRequest) { $data = Modification::getModifications($mark, $model); $this->renderPartial('modifications', array('data' => $data, 'mark' => $mark, 'model' => $model)); Yii::app()->end(); } }
public function afterDelete() { # Проверка и очистка связей $modifications = Modification::model()->findAll('model_id=:model_id', array(':model_id' => $this->id)); if (count($modifications) > 0) { foreach ($modifications as $modification) { $modification->delete(); } } return parent::afterDelete(); }
public function run() { Yii::import($this->import); $id = Yii::app()->request->getParam('id', 0); if ($id <= 0) { echo '{}'; } else { $data = CHtml::listData(Modification::model()->findAll(array('condition' => 'model_id=' . $id, 'order' => 'title')), 'id', 'title'); $data[0] = ''; ksort($data); echo CJavaScript::jsonEncode($data); } }
if (!Session::logged_in()) { Page::Redirect('login'); } plog("New page!"); $p = new Page(); if (!$p->ajax) { $p->HTML('header.html', array("###MENU###" => Dropdown_menu($p))); } $p->title = "Your Website"; $p->CSS("main.css"); $p->Jquery(); $getpost = getpost(); $p->HTML('<BR>'); global $auth_database; plog("Get mods!"); $m = new Modification($auth_database); $mods = $m->All('ORDER BY Timestamp DESC'); $m_auth = new Auth($auth_database); if (!false_or_null($mods)) { $datatemp = array(); foreach ($mods as $mod) { $user = $m_auth->Get($mod['r_Auth']); if (!isset($datatemp[$user['username']])) { $datatemp[$user['username']] = 1; } else { $datatemp[$user['username']] += 1; } } $datapoints = array(); foreach ($datatemp as $username => $events) { $datapoints[] = array("value" => $events, "color" => "#FFAAAA", "highlight" => "5AD3D1", "label" => $username);
public function updateNote($bdd, $nid, $namenote, $satutnote) { $getname = $bdd->prepare("UPDATE `note_frais` SET `name`= :name, `statut_id`= :statut WHERE id= :nid"); $getname->execute(array(":name" => $namenote, ":statut" => $satutnote, ":nid" => $nid)); $table_name = "note_frais"; $user = unserialize($_SESSION['user']); $author_id = $user->getId(); Modification::insertNewModif($bdd, $nid, $table_name, $author_id); }
protected function saveChar($model) { if (!($brand = Brand::model()->find('alias=:alias', array(':alias' => $model->brand_alias)))) { $brand = new Brand(); } $brand->title = $model->brand; $brand->alias = $model->brand_alias; $brand->save(); if (!empty($brand->errors)) { d('brand ' . $brand->title); d($brand->errors); } if (!($car = Car::model()->find('alias=:alias', array(':alias' => $model->model_alias)))) { $car = new Car(); } $car->brand_id = $brand->id; $car->title = $model->model; $car->alias = $model->model_alias; $car->manufacture_start = $model->modificationManufactureStart . '0101'; $car->manufacture_end = $model->modificationManufactureEnd ? $model->modificationManufactureEnd . '0101' : null; $car->save(); if (!empty($car->errors)) { d('model ' . $car->title); d($car->errors); } if (!($mod = Modification::model()->find('alias=:alias', array(':alias' => $model->mod_alias)))) { $mod = new Modification(); } $mod->model_id = $car->id; $mod->title = $model->mod; $mod->alias = $model->mod_alias; $mod->manufacture_start = $model->modificationManufactureStart . '0101'; $mod->manufacture_end = $model->modificationManufactureEnd ? $model->modificationManufactureEnd . '0101' : null; $mod->save(); if (!empty($mod->errors)) { d('mod ' . $mod->title); d($mod->errors); } if (!($char = Characteristic::model()->find('modification_id=:mod_id', array(':mod_id' => $mod->id)))) { $char = new Characteristic(); } $char->attributes = $model->char->attributes; $char->modification_id = $mod->id; $char->save(); if (!empty($char->errors)) { d('char ' . $mod->title); d($char->errors); d($model->url); } }
/** * @return string[] the resource loader modules needed by this component */ public function getResourceLoaderModules() { $modules = parent::getResourceLoaderModules(); $modules[] = 'skin.chameleon.jquery-sticky'; return $modules; }
} $s = basename($s); $s = explode(".", $s); $s = $s[0]; return $s; } global $auth_database; $m_sess = new Session($auth_database); global $session; if ($m_sess->LoggedOut($session)) { echo '0'; die; } $sessions = $m_sess->ActiveUsers(); $m_auth = new Auth($auth_database); $mod_model = new Modification($auth_database); $result = array(); $was = array(); foreach ($sessions as $s) { if (!$m_sess->LoggedOut($s)) { $activity = ' '; $activity .= get_url_map($s['last_url'], $url_map); if (matches($activity, 'request_login.php')) { continue; } $a = $m_auth->Get($s['r_Auth']); if (false_or_null($a)) { continue; } $found = FALSE; foreach ($was as $u) {
plog("New page!"); $p = new Page(); if (!$p->ajax) { $p->HTML('header.html', array("###MENU###" => Dropdown_menu($p))); } $p->title = "Your Website"; $p->CSS("main.css"); $p->Jquery(); $getpost = getpost(); $p->HTML('<BR>'); $p->HTML('groundrules.html'); ///// Show recent activity // Show edit activity global $auth_database; plog("Get mods!"); $m = new Modification($auth_database); $mods = $m->Select(' Timestamp > ' . strtotime('-1 days') . ' ORDER BY Timestamp DESC'); $m_auth = new Auth($auth_database); if (!false_or_null($mods)) { $data = array(); foreach ($mods as $mod) { $user = $m_auth->Get($mod['r_Auth']); $what = ''; $w = json_decode($mod['What'], true); foreach ($w as $dataset) { foreach ($dataset as $table => $change) { $edit = strtolower($table) . ".edit"; if ($edit == "catalogcategory.edit") { $edit = "category.edit"; } else { if ($edit == "catalogexport.edit") {
</label><br /> <?php echo CHtml::dropDownList(get_class($model) . '[brand_id]', '', array()); ?> <img src='/images/loader.gif' class='loader' style='display: none;'> </div> <?php if ($options['select'] != 'Brand') { ?> <div id='<?php echo $this->id; ?> _model' style='display: none;'> <label for='model_id'><?php echo Modification::model()->getAttributeLabel('model_id'); ?> </label><br /> <?php echo CHtml::dropDownList(get_class($model) . '[model_id]', '', array()); ?> <img src='/images/loader.gif' class='loader' style='display: none;'> </div> <?php } ?> <?php if ($options['select'] != 'Brand' && $options['select'] != 'Car') { ?>
public function testNew() { $this->assertSame('new', $this->change->getNew()); }
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria = new CDbCriteria(); $criteria->compare('id', $this->id); if (Yii::app()->request->isAjaxRequest) { if ($model = Yii::app()->request->getParam('Characteristic', false)) { $a = CHtml::listData(Modification::model()->findAll('title like :title', array(':title' => '%' . $model['modificationTitle'] . '%')), 'id', 'id'); if (count($a) > 0) { $criteria->compare('modification_id', $a); } elseif ($modification['modificationTitle']) { $criteria->compare('modification_id', 0); } else { $criteria->compare('modification_id', array()); } $criteria->compare('modification_id', $a); $this->modificationTitle = $model['modificationTitle']; $a = Car::model()->findAll('title like :title', array(':title' => '%' . $model['modelTitle'] . '%')); $tmp = array(); foreach ($a as $m) { if (count($m->modifications) > 0) { foreach ($m->modifications as $t) { $tmp[$t->id] = $t->id; } } } $a = $tmp; if (count($a) > 0) { $criteria->compare('modification_id', $a); } elseif ($modification['modelTitle']) { $criteria->compare('modification_id', 0); } else { $criteria->compare('modification_id', array()); } $criteria->compare('modification_id', $a); $this->modelTitle = $model['modelTitle']; $a = Brand::model()->findAll('title like :title', array(':title' => '%' . $model['brandTitle'] . '%')); $tmp = array(); foreach ($a as $b) { if (count($b->models) > 0) { foreach ($b->models as $m) { if (count($m->modifications) > 0) { foreach ($m->modifications as $t) { $tmp[$t->id] = $t->id; } } } } } $a = $tmp; if (count($a) > 0) { $criteria->compare('modification_id', $a); } elseif ($modification['brandTitle']) { $criteria->compare('modification_id', 0); } else { $criteria->compare('modification_id', array()); } $criteria->compare('modification_id', $a); $this->brandTitle = $model['brandTitle']; } } $criteria->compare('fuel_capacity', $this->fuel_capacity); $criteria->compare('body', $this->body, true); $criteria->compare('doors', $this->doors); $criteria->compare('seats', $this->seats, true); $criteria->compare('weight', $this->weight); $criteria->compare('weight_loaded', $this->weight_loaded); $criteria->compare('top_speed_at', $this->top_speed_at); $criteria->compare('acceleration_at', $this->acceleration_at); $criteria->compare('top_speed_mt', $this->top_speed_mt); $criteria->compare('acceleration_mt', $this->acceleration_mt); $criteria->compare('turn_radius', $this->turn_radius); $criteria->compare('trunk_capacity', $this->trunk_capacity, true); $criteria->compare('length', $this->length); $criteria->compare('width', $this->width); $criteria->compare('height', $this->height); $criteria->compare('track_front', $this->tyres_front); $criteria->compare('track_rear', $this->tyres_front); $criteria->compare('track_front', $this->disks_front); $criteria->compare('track_rear', $this->disks_front); $criteria->compare('wheelbase', $this->wheelbase); $criteria->compare('engine_type', $this->engine_type, true); $criteria->compare('volume', $this->volume); $criteria->compare('displacement', $this->displacement, true); $criteria->compare('cylinders', $this->cylinders, true); $criteria->compare('valves', $this->valves); $criteria->compare('max_power', $this->max_power); $criteria->compare('max_power_rpm', $this->max_power_rpm, true); $criteria->compare('max_torque', $this->max_torque); $criteria->compare('max_torque_rpm', $this->max_torque_rpm, true); $criteria->compare('transmission_at', $this->transmission_at, true); $criteria->compare('gears_at', $this->gears_at, true); $criteria->compare('transmission_mt', $this->transmission_mt, true); $criteria->compare('gears_mt', $this->gears_mt, true); $criteria->compare('drive', $this->drive, true); $criteria->compare('suspension_front', $this->suspension_front, true); $criteria->compare('suspension_rear', $this->suspension_rear, true); $criteria->compare('tyres_front', $this->tyres_front, true); $criteria->compare('tyres_rear', $this->tyres_rear, true); $criteria->compare('brakes_front', $this->brakes_front, true); $criteria->compare('brakes_rear', $this->brakes_rear, true); $criteria->compare('fuel_consumption_urban_at', $this->fuel_consumption_urban_at); $criteria->compare('fuel_consumption_country_at', $this->fuel_consumption_country_at); $criteria->compare('fuel_consumption_combined_at', $this->fuel_consumption_combined_at); $criteria->compare('fuel_consumption_urban_mt', $this->fuel_consumption_urban_mt); $criteria->compare('fuel_consumption_country_mt', $this->fuel_consumption_country_mt); $criteria->compare('fuel_consumption_combined_mt', $this->fuel_consumption_combined_mt); $criteria->compare('fuel_type', $this->fuel_type, true); return new CActiveDataProvider('Characteristic', array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->params['linesPerPage']))); }
static function logMerge(Doctrine_Record $r) { $mod = new Modification(); $mod->object_model = get_class($r); $mod->object_id = $r->id; $mod->object_name = $r->getName(); $mod->user_id = LsVersionableListener::getUserId(); $mod->is_merge = true; $mod->save(); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Modification::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Add modifider to an {@link Order} . * * @see Modifier_Interface::addToOrder() * @param Order $order * @param Mixed $value */ public function addToOrder($order, $value) { $modification = new Modification(); $modification->ModifierClass = get_class($this); $modification->ModifierOptionID = $value; $modification->Amount = $this->Amount($order, $value); $modification->Description = $this->Description($order, $value); $modification->OrderID = $order->ID; $modification->write(); }
/** * Save modifiers for this Order at the checkout process. * * @param Array $data */ public function updateModifications(array $data) { //Remove existing Modifications $existingModifications = $this->Modifications(); foreach ($existingModifications as $modification) { $modification->delete(); } $this->updateTotal(); $mods = Modification::get_all(); foreach ($mods as $modification) { $class = get_class($modification); $value = isset($data['Modifiers'][$class]) ? Convert::raw2sql($data['Modifiers'][$class]) : null; $modification->add($this, $value); $this->updateTotal(); } return $this; }
public function upDateFrais($bdd) { $req = $bdd->prepare("UPDATE frais SET image = :image, date = :date, description = :description, " . "montant = :montant, devise_id = :devise_id, note_id = :note_id, categorie_id = :categorie_id " . "WHERE id = :id"); $req->execute(array(':image' => $this->image, ':date' => $this->date, ':description' => $this->description, ':montant' => $this->montant, ':devise_id' => $this->devise, ':note_id' => $this->note, ':categorie_id' => $this->categorie, ':id' => $this->id)); $req->closeCursor(); $table_name = "frais"; $user = unserialize($_SESSION['user']); $author_id = $user->getId(); $nid = $this->id; Modification::insertNewModif($bdd, $nid, $table_name, $author_id); }
public function editUserByAdmin($bdd, $CloneUser) { $req = $bdd->prepare("UPDATE user SET name = :name, login = :login, password = :password, mail = :mail, role_id = :role_id, devise_id = :devise_id WHERE id = :id"); $req->execute(array(':name' => $CloneUser->getname(), ':login' => $CloneUser->getLogin(), ':password' => $CloneUser->getPassword(), ':mail' => $CloneUser->getEmail(), 'role_id' => $CloneUser->getRole(), ':devise_id' => $CloneUser->getDevise(), ':id' => $this->id)); $table_name = "user"; $user = unserialize($_SESSION['user']); $author_id = $user->getId(); $nid = $this->id; Modification::insertNewModif($bdd, $nid, $table_name, $author_id); }
define('VERSION', '2.0'); // Configuration if (is_file('config.php')) { require_once('config.php'); } // Install if (!defined('DIR_APPLICATION')) { header('Location: install/index.php'); exit; } // Modification require_once(DIR_SYSTEM . 'engine/modification.php'); $modification = new Modification(); // Startup require_once($modification->getFile(DIR_SYSTEM . 'startup.php')); // Application require_once($modification->getFile(DIR_SYSTEM . 'library/customer.php')); require_once($modification->getFile(DIR_SYSTEM . 'library/affiliate.php')); require_once($modification->getFile(DIR_SYSTEM . 'library/currency.php')); require_once($modification->getFile(DIR_SYSTEM . 'library/tax.php')); require_once($modification->getFile(DIR_SYSTEM . 'library/weight.php')); require_once($modification->getFile(DIR_SYSTEM . 'library/length.php')); require_once($modification->getFile(DIR_SYSTEM . 'library/cart.php')); // Registry $registry = new Registry();
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = Modification::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }
<?php // Version define('VERSION', '2.0'); // Configuration if (is_file('config.php')) { require_once 'config.php'; } // Install if (!defined('DIR_APPLICATION')) { header('Location: ../install/index.php'); exit; } // Modification require_once DIR_SYSTEM . 'engine/modification.php'; $modification = new Modification(); // Startup require_once $modification->getFile(DIR_SYSTEM . 'startup.php'); // Application require_once $modification->getFile(DIR_SYSTEM . 'library/currency.php'); require_once $modification->getFile(DIR_SYSTEM . 'library/user.php'); require_once $modification->getFile(DIR_SYSTEM . 'library/weight.php'); require_once $modification->getFile(DIR_SYSTEM . 'library/length.php'); // Registry $registry = new Registry(); // Modification $registry->set('modification', $modification); // Config $config = new Config(); $registry->set('config', $config); // Database
/** * Set the currency code that this site uses for Order Modifications * * @param string $currency 3 letter ISO 4217 currency code e.g. "NZD" */ public static function set_currency($currency) { self::$currency = $currency; }