/** * @param array $params * @return bool */ public function update($params = array()) { // if not user id then we should not be doing anything here if (empty($params['user_id'])) { return false; } $this->user_id = $params['user_id']; // check for a previous avatar otherwise set the default $this->image = $params['current_avatar']; if (empty($this->image)) { $this->image = URL_FULL . 'framework/modules/users/assets/images/avatar_not_found.jpg'; } if (!empty($_FILES['avatar']['tmp_name'])) { // if the user uploaded a new avatar lets save it! $info = expFile::getImageInfo($_FILES['avatar']['tmp_name']); if ($info['is_image']) { // figure out the mime type and set the file extension and name $extinfo = explode('/', $info['mime']); $extension = $extinfo[1]; $avatar_name = $this->user_id . '.' . $extension; // save the file to the filesystem $file = expFile::fileUpload('avatar', true, false, $avatar_name, 'files/avatars/'); //save the file to the database $this->image = $file->url; $this->use_gravatar = false; // if we uploaded a file, we don't want to use gravatar } } elseif (!empty($params['use_gravatar'])) { // if the user chose gravatar, create the link and save it! $this->use_gravatar = $params['use_gravatar']; $emailMD5 = md5(strtolower(trim(user::getEmailById($params['user_id'])))); $this->image = "http://www.gravatar.com/avatar/" . $emailMD5 . ".jpg"; } parent::update(); }
public function update($params = array()) { if (is_array($params['config'])) { $params['config'] = serialize($params['config']); } parent::update($params); }
public function __construct($params = null, $get_assoc = true, $get_attached = true) { global $db; parent::__construct($params, $get_assoc, $get_attached); $this->timesImplemented = $db->countObjects('optiongroup', 'optiongroup_master_id=' . $this->id); if (!empty($this->id)) { usort($this->option_master, array("optiongroup_master", "sortOptions")); } }
public function __construct($params = array(), $get_assoc = false, $get_attached = false) { parent::__construct($params, $get_assoc, $get_attached); // if this object is empty we'll treat it like a top level' if (empty($this->id)) { global $db; $this->lft = $db->min($this->table, 'lft'); $this->rgt = $db->max($this->table, 'rgt'); } }
public function __construct($params = null, $get_assoc = false, $get_attached = false) { global $db; if (is_array($params) || is_numeric($params)) { parent::__construct($params, $get_assoc, $get_attached); } else { $id = $db->selectValue($this->table, 'id', "name='" . $params . "' OR code='" . $params . "'"); parent::__construct($id); } }
public function __construct($params = null, $get_assoc = true, $get_attached = true) { parent::__construct($params, $get_assoc, $get_attached); // set the calculator if (!empty($this->calculator_name)) { $this->calculator = new $this->calculator_name(); } // grab the config data for this calculator $this->configdata = empty($this->config) ? array() : unserialize($this->config); }
public function __construct($params = null, $get_assoc = false, $get_attached = false) { global $db; parent::__construct($params, $get_assoc, $get_attached); if (!empty($this->state) && $this->state > 0) { $stateObj = $db->selectObject('geo_region', 'id=' . $this->state); $this->statename = $stateObj->name; $this->state_code = $stateObj->code; } }
public function __construct($params = null, $get_assoc = true, $get_attached = true) { parent::__construct($params, $get_assoc, $get_attached); if (!empty($this->publish)) { $this->publish_date = $this->publish; } elseif (!empty($this->edited_at)) { $this->publish_date = $this->edited_at; } elseif (!empty($this->created_at)) { $this->publish_date = $this->created_at; } }
public function __construct($params = null, $get_assoc = true, $get_attached = true) { parent::__construct($params, $get_assoc, $get_attached); // grab the config data for this calculator $this->configdata = empty($this->config) ? array() : unserialize($this->config); if (file_exists(BASE . 'framework/modules/ecommerce/shippingcalculators/icons/' . $this->classname . '.gif')) { $this->icon = PATH_RELATIVE . 'framework/modules/ecommerce/shippingcalculators/icons/' . $this->classname . '.gif'; } else { $this->icon = PATH_RELATIVE . 'framework/modules/ecommerce/shippingcalculators/icons/default.png'; } }
public function __construct($params = null, $get_assoc = false, $get_attached = false) { global $db; if (is_array($params) || is_numeric($params)) { parent::__construct($params, $get_assoc, $get_attached); } else { if (is_numeric($params)) { echo "true dude<Br>"; } $id = $db->selectValue($this->table, 'id', "name='" . $params . "' OR iso_code_2letter='" . $params . "' OR iso_code_3letter='" . $params . "'"); parent::__construct($id, $get_assoc, $get_attached); } }
public function __construct($params = null, $get_assoc = true, $get_attached = true) { global $db; parent::__construct($params, $get_assoc, $get_attached); $this->timesImplemented = $db->countObjects('optiongroup', 'optiongroup_master_id=' . $this->id); //sort the options based on the master sort order if (!empty($this->id)) { foreach ($this->option as &$opt) { $om = new option_master($opt->option_master_id); $opt->rank = $om->rank; } usort($this->option, array("optiongroup_master", "sortOptions")); } }
public function update($params = array()) { //FJD: FIXME: this is here because expRecord throughs an error in the build function when trying to run //strip slashes on an array. Should probably figure out a way to tell Exp if a field is supposed to be //serialized, and then we can handle it all in expRecord. $params['group_ids'] = serialize($params['group_ids']); $this->startdate = datetimecontrol::parseData('startdate', $params); $this->startdate_time = datetimecontrol::parseData('startdate_time', $params) + $this->startdate; $this->enddate = datetimecontrol::parseData('enddate', $params); $this->enddate_time = datetimecontrol::parseData('enddate_time', $params) + $this->enddate; // eDebug($_POST); //eDebug($params); //eDebug($this, true); parent::update($params); }
public function save($overrideUsername = false) { global $db; if (empty($_POST['is_admin'])) { $this->is_admin = 0; } if (empty($_POST['is_acting_admin'])) { $this->is_acting_admin = 0; } // if someone is trying to make this user an admin, lets make sure they have permission to do so. $this->checkAdminFlags(); // if the site is configured to use the email addy as the username we need to force the // the email address into the username field. if (USER_REGISTRATION_USE_EMAIL == 1 && !empty($this->email) && $overrideUsername == false) { $this->username = $this->email; } parent::save(); }
public function save() { global $db; if (isset($_POST['section'])) { // manipulate section & location_data to correct values $hlpsection = $db->selectObject('sectionref', 'module = "helpController" AND source = "' . $_POST['section'] . '"'); $this->section = $hlpsection->section; $loc = null; $loc->mod = 'help'; $loc->src = $_POST['section']; $loc->int = ''; $this->location_data = serialize($loc); } // circumvent the re-ranking problem // $oldrank = $this->rank; // if (empty($this->rank)) unset($this->rank); parent::save(true); // if (!empty($oldrank)) $this->rank = $oldrank; // parent::save(); }
function __construct($params = null, $get_assoc = true, $get_attached = true) { parent::__construct($params, $get_assoc, $get_attached); //check to see if this is a completed order and if so, add the items and shipping info if (!empty($this->purchased)) { // final the cart totals //$this->calculateGrandTotal(); foreach ($this->orderitem as $items) { if ($items->product->requiresShipping) { $this->shipping_required = true; } if ($items->product->requiresBilling) { $this->billing_required = true; } } //$this->shipping_total = 0; foreach ($this->getShippingMethods() as $smid) { $this->shippingmethods[$smid] = new shippingmethod($smid); $this->shippingmethods[$smid]->orderitem = $this->getOrderitemsByShippingmethod($smid); $requiresShipping = false; foreach ($this->shippingmethods[$smid]->orderitem as $oi) { if ($oi->product->requiresShipping) { $requiresShipping = true; } } /*if ($requiresShipping == true) { $this->shipping_total += $this->shippingmethods[$smid]->shipping_cost; } */ } // grab our tax zones $this->taxzones = taxclass::getCartTaxZones($this); /*$this->total = $this->getCartTotal(); $this->calculateTax(); $this->grand_total = $this->total + $this->tax + $this->shipping_total;*/ //$this->calculateGrandTotal(); if (isset($this->order_status_changes)) { usort($this->order_status_changes, array("order", "sortStatuses")); } } }
function __construct($params = array(), $get_assoc = true, $get_attached = false) { global $db, $user; if (!empty($params['id']) || is_numeric($params)) { parent::__construct($params, $get_assoc, $get_attached); $prodtype = $this->product_type; $this->product = new $prodtype($this->product_id, false, true); } elseif (isset($params['product_id']) && isset($params['product_type'])) { // see if this is an existing item in the cart if (isset($params['orderid'])) { $order = new order($params['orderid']); } else { $order = order::getUserCart(); } //adding lookup on price to acocomdate quantity discounts $where = 'orders_id=' . $order->id . ' AND product_id=' . $params['product_id'] . ' AND products_price=' . $params['products_price'] . " AND product_type='" . $params['product_type'] . "'"; $where .= empty($params['options']) ? '' : " AND options='" . $params['options'] . "'"; $where .= empty($params['user_input_fields']) ? '' : " AND user_input_fields='" . $params['user_input_fields'] . "'"; $item = $db->selectObject($this->table, $where); $this->product = new $params['product_type']($params['product_id'], false, true); if (empty($item)) { parent::__construct(array('orders_id' => $order->id, 'user_id' => $user->id, 'product_id' => $this->product->id, 'product_type' => $params['product_type'], 'products_name' => $this->product->title, 'products_price' => $this->product->getBasePrice()), $get_assoc, $get_attached); } else { parent::__construct($item->id, $get_assoc, $get_attached); //$this->quantity = $this->product->incrementQuantity($this->quantity); } } else { parent::__construct(null, $get_assoc, $get_attached); } if (isset($this->options)) { $this->opts = expUnserialize($this->options); } if (!empty($this->user_input_fields)) { //$this->user_input_fields = expUnserialize($this->user_input_fields); } }
public function update($params = array()) { // eDebug($params, true); parent::update($params); }
public function __construct($params = null, $get_assoc = false, $get_attached = false) { parent::__construct($params, $get_assoc, $get_attached); }
public function __construct($params = array(), $get_assoc = true, $get_attached = true) { global $db; parent::__construct($params, $get_assoc, $get_attached); }
public function beforeSave() { $this->module = expModules::getControllerName($this->module); parent::beforeSave(); }
public function __construct($params = null, $get_assoc = true, $get_attached = true) { global $db; parent::__construct($params, $get_assoc, $get_attached); $this->timesImplemented = $db->countObjects('option', 'enable=1 AND option_master_id=' . $this->id); }
/** * Class constructor to create a File Class either from a database * record or from the File System. * * Class will either: a) load an existing File Record * b) modify an existing File Record * c) create a new File Record * * This will also handle any File System handling that is needed: copy, * move, create, delete, read and write. * * @access public * * @uses expRecord::__construct * * @PHPUnit Not Defined * * @param mixed $params - If an INT is given, this assumes that it needs to * load an existing File Record. * - If an ARRAY is given, this assumes that the elements * of the array are values to the File table that need * to be modified or other processing. * - If NULL is given, an empty File Object is created * * @param bool $get_assoc * @param bool $get_attached * @return \expFile Object@throws void * */ public function __construct($params = array(), $get_assoc = false, $get_attached = false) { // Set 'directory' as the default FILE location // This will be redefined if a FILE record is loaded // or a path is given to the Class //eDebug($params,true); $this->directory = UPLOAD_DIRECTORY_RELATIVE; // This will pull properties for class properties based upon // expRecord table definition parent::__construct($params, $get_assoc, $get_attached); // If the 'directory' is the same as the default path then a given, // or derived, filename can be added to pathing settings //if ( $this->directory == UPLOAD_DIRECTORY_RELATIVE ) { if (!stristr($this->directory, BASE)) { // Place system level web root $this->url = URL_FULL . $this->directory . $this->filename; // Place system level OS root $this->path = BASE . $this->directory . $this->filename; // Place system OS relative path $this->path_relative = PATH_RELATIVE . $this->directory . $this->filename; } else { // Otherwise, the URL is not set since we can't use it, nether is // RELATIVE, as 'directory' must be an absolute path in this instance // Place system level OS root $relpath = str_replace(BASE, '', $this->directory); $this->path = $this->directory . $this->filename; $this->url = URL_FULL . $relpath . $this->filename; $this->path_relative = $relpath . $this->filename; } // If a file location was given, not derived from the database, // basic file information is needed if (empty($this->id) && !empty($this->filename)) { // File info $_fileInfo = self::getImageInfo($this->path); // Assign info back to class $this->is_image = $_fileInfo['is_image']; $this->filesize = $_fileInfo['fileSize']; if ($_fileInfo['is_image']) { $this->mimetype = $_fileInfo['mime']; $this->image_width = $_fileInfo[0]; $this->image_height = $_fileInfo[1]; } } }
public function update($params = array()) { global $db; //Get the product $product = $db->selectObject('product', 'id =' . $params['id']); //Get product files $product->expFile = $this->getProductFiles($params['id']); // eDebug($product, true); $tab_loaded = $params['tab_loaded']; //check if we're saving a newly copied product and if we create children also $originalId = isset($params['original_id']) && isset($params['copy_children']) ? $params['original_id'] : 0; $originalModel = isset($params['original_model']) && isset($params['copy_children']) ? $params['original_model'] : 0; if (!empty($product->parent_id)) { $product->sef_url = ''; } //if child, set sef_url to nada //Tabs with not directly being saved in the product table and need some special operations $tab_exceptions = array('categories', 'options', 'related', 'userinput', 'extrafields', 'model', 'notes'); foreach ($tab_loaded as $tab_key => $tab_item) { if (!in_array($tab_key, $tab_exceptions)) { foreach ($params[$tab_key] as $key => $item) { $product->{$key} = $item; } } } if (isset($tab_loaded['images'])) { $product->expFile = $params['expFile']; } if ($params['shipping']['required_shipping_calculator_id'] > 0) { $product->required_shipping_method = $params['required_shipping_methods'][$params['shipping']['required_shipping_calculator_id']]; } if (isset($tab_loaded['categories'])) { $this->saveCategories($params['storeCategory'], null, $params['id'], $this->classname); } if (isset($tab_loaded['options'])) { //Option Group Tab if (!empty($params['optiongroups'])) { foreach ($params['optiongroups'] as $title => $group) { if (isset($this->params['original_id']) && $params['original_id'] != 0) { $group['id'] = ''; } //for copying products $optiongroup = new optiongroup($group); $optiongroup->product_id = $product->id; $optiongroup->save(); foreach ($params['optiongroups'][$title]['options'] as $opt_title => $opt) { if (isset($params['original_id']) && $params['original_id'] != 0) { $opt['id'] = ''; } //for copying products $opt['product_id'] = $product->id; $opt['is_default'] = false; $opt['title'] = $opt_title; $opt['optiongroup_id'] = $optiongroup->id; if (isset($params['defaults'][$title]) && $params['defaults'][$title] == $opt['title']) { $opt['is_default'] = true; } $option = new option($opt); $option->save(); } } } } if (isset($tab_loaded['related'])) { //Related Products Tab if (!empty($tab_loaded['related']) && (empty($originalId) || !empty($params['copy_related']))) { $relprods = $db->selectObjects('crosssellItem_product', "product_id=" . $product->id); $db->delete('crosssellItem_product', 'product_id=' . $product->id); foreach ($params['relatedProducts'] as $key => $prodid) { $ptype = new product($prodid); $tmp->product_id = $product->id; $tmp->crosssellItem_id = $prodid; $tmp->product_type = $ptype->product_type; $db->insertObject($tmp, 'crosssellItem_product'); if (isset($params['relateBothWays'][$prodid])) { $tmp->crosssellItem_id = $product->id; $tmp->product_id = $prodid; $tmp->product_type = $ptype->product_type; $db->insertObject($tmp, 'crosssellItem_product'); } } } } if (isset($tab_loaded['userinput'])) { //User Input fields Tab if (isset($params['user_input_use']) && is_array($params['user_input_use'])) { foreach ($params['user_input_use'] as $ukey => $ufield) { $user_input_fields[] = array('use' => $params['user_input_use'][$ukey], 'name' => $params['user_input_name'][$ukey], 'is_required' => $params['user_input_is_required'][$ukey], 'min_length' => $params['user_input_min_length'][$ukey], 'max_length' => $params['user_input_max_length'][$ukey], 'description' => $params['user_input_description'][$ukey]); } $product->user_input_fields = serialize($user_input_fields); } else { $product->user_input_fields = serialize(array()); } } if (isset($tab_loaded['extrafields'])) { //Extra Field Tab foreach ($params['extra_fields_name'] as $xkey => $xfield) { if (!empty($xfield)) { $extra_fields[] = array('name' => $xfield, 'value' => $params['extra_fields_value'][$xkey]); } } if (is_array($extra_fields)) { $product->extra_fields = serialize($extra_fields); } else { unset($product->extra_fields); } } //Adjusting Children Products if (!empty($originalId) && !empty($this->params['copy_children'])) { $origProd = new $product_type($originalId); $children = $origProd->find('all', 'parent_id=' . $originalId); foreach ($children as $child) { unset($child->id); $child->parent_id = $product->id; $child->title = $product->title; $child->sef_url = ''; if (isset($this->params['adjust_child_price']) && isset($this->params['new_child_price']) && is_numeric($this->params['new_child_price'])) { $child->base_price = $this->params['new_child_price']; } if (!empty($originalModel)) { $child->model = str_ireplace($originalModel, $product->model, $child->model); } $child->save(); } } //Check if we are copying and not just editing product if (isset($params['original_id'])) { // eDebug($product->id, true); unset($product->id); unset($product->sef_url); $product->original_id = $params['original_id']; // eDebug($product, true); } parent::update($product); }