Exemplo n.º 1
0
 public function save(&$element)
 {
     if (!isset($element->pack_params)) {
         $element->pack_params = null;
     }
     $unserializedParams = $element->pack_params;
     $element->pack_params = serialize($element->pack_params);
     $ret = parent::save($element);
     $element->pack_params = $unserializedParams;
     return $ret;
 }
Exemplo n.º 2
0
 public function save(&$element, $reorder = true)
 {
     $status = parent::save($element);
     if ($status && empty($element->consumer_id)) {
         $element->consumer_id = $status;
         if ($reorder) {
             $orderClass = hikaserial::get('helper.order');
             $orderClass->pkey = 'consumer_id';
             $orderClass->table = 'consumer';
             $orderClass->groupMap = 'consumer_type';
             $orderClass->groupVal = $element->consumer_type;
             $orderClass->orderingMap = 'consumer_ordering';
             $orderClass->reOrder();
         }
     }
     return $status;
 }
Exemplo n.º 3
0
 public function save(&$element)
 {
     if (!is_array($element)) {
         return parent::save($element);
     }
     $struct = array();
     $first = reset($element);
     $query = 'INSERT IGNORE INTO ' . hikaserial::table('history') . ' (';
     $sep = '';
     foreach (get_object_vars($first) as $k => $v) {
         if (is_array($v) || is_object($v) || $v === null || $k[0] == '_') {
             continue;
         }
         if (!HIKASHOP_J30) {
             $query .= $sep . $this->db->nameQuote($k);
         } else {
             $query .= $sep . $this->db->quoteName($k);
         }
         $struct[] = $k;
         $sep = ',';
     }
     $query .= ') VALUES ';
     $sep = '';
     foreach ($element as $el) {
         if ($el === false) {
             continue;
         }
         $query .= $sep . '(';
         $sep2 = '';
         foreach ($struct as $k) {
             $value = $el->{$k};
             if (!HIKASHOP_J25) {
                 $query .= $sep2 . ($this->db->isQuoted($k) ? $this->db->Quote($value) : (int) $value);
             } else {
                 $query .= $sep2 . $this->db->Quote($value);
             }
             $sep2 = ',';
         }
         $query .= ')';
         $sep = ',';
     }
     $this->db->setQuery($query);
     $this->db->query();
     return true;
 }
Exemplo n.º 4
0
 public function unassign($serial_id, $type = 'all')
 {
     $ret = false;
     if (empty($serial_id)) {
         return $ret;
     }
     $app = JFactory::getApplication();
     if (!$app->isAdmin()) {
         $user_id = hikaserial::loadUser();
         if ($serial->serial_user_id != $user_id) {
             return false;
         }
     }
     $save = false;
     $serial = $this->get($serial_id);
     $newSerial = new stdClass();
     $newSerial->serial_id = $serial_id;
     if ($type == 'all' || $type == 'order') {
         $newSerial->serial_assign_date = 0;
         $newSerial->serial_order_id = 0;
         $save = true;
     }
     if ($type == 'all' || $type == 'user') {
         if (empty($serial->serial_order_id) || isset($newSerial->serial_order_id)) {
             $newSerial->serial_user_id = 0;
             $newSerial->serial_assign_date = 0;
             $save = true;
         }
     }
     if ($type == 'all') {
         $newSerial->serial_extra_data = array();
     }
     JPluginHelper::importPlugin('hikashop');
     JPluginHelper::importPlugin('hikaserial');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeSerialUnassign', array($serial, $type, &$newSerial, &$save));
     if ($save) {
         if (!empty($newSerial->serial_extradata) && !is_string($newSerial->serial_extradata)) {
             $newSerial->serial_extradata = serialize($newSerial->serial_extradata);
         }
         $ret = parent::save($newSerial);
     }
     return $ret;
 }
Exemplo n.º 5
0
 public function save(&$element)
 {
     if (!empty($element->params)) {
         if (!HIKASHOP_J16) {
             $params = '';
             foreach ($element->params as $key => $val) {
                 $params .= $key . '=' . $val . "\n";
             }
             $element->params = rtrim($params);
         } else {
             $handler = JRegistryFormat::getInstance('JSON');
             $element->params = $handler->objectToString($element->params);
         }
     }
     return parent::save($element);
 }