public function sync(RM_Store_Object $object) { $oid = "" . $object; $props = $object->props(); $info = isset($this->_objCache[$oid]) ? $this->_objCache[$oid] : array(); $info['.'] = $object; foreach ($this->_mediator->meta->keyList() as $key) { # remove old bindings if (isset($info[$key])) { unset($this->_keyCache[$key][$info[$key]]); } # calc hash $id = $this->_mediator->meta->keyIdByHash($key, $props); # update bindings $info[$key] = $id; if ($id) { if (isset($this->_keyCache[$key][$id])) { throw new RM_Base_Exception_BadUsage("Integrity constraint violation. class=" . get_class($object) . ", key={$key}, id={$id}. Object #{$oid} conflicts with object #" . $this->_keyCache[$key][$id]); } $this->_keyCache[$key][$id] = $object; } } $this->_objCache[$oid] = $info; return $object; }
public function __set($name, $value) { if ($name == 'status_id' && $value != $this->status_id) { $this->_clearStrategy(); } return parent::__set($name, $value); }
public function __get($name) { if ($name == 'params') { throw new RM_Base_Exception_Internal("Unable to get `params' value directly. Use `getParams()' method instead."); } return parent::__get($name); }
/** * Enter description here... * * @return bool */ public function delete() { if (count($this->getPresentsList()) > 0) { throw new RM_Base_Exception_BadUsage(__METHOD__ . ': you want delete not empty category'); } return parent::delete(); }
public function save() { if ($this->_saving) { $this->_saving = 0; return TRUE; } $this->_saving = 1; if (!$this->shop_type) { $this->shop_type = 11; } parent::save(); $shop = $this->shop(); if (!$shop->type_id || $shop->type_id == 11) { $shop->type_id = $this->shop_type; } if (!$shop->name || $shop->unnamed()) { $shop->name = $this->name; } if (!$shop->street || $shop->noStreet()) { $shop->street = $this->street; } if (!$shop->bld || $shop->noBld()) { $shop->bld = $this->bld; } $shop->save(); }
public function delete() { if ($this->_mapper->canDeleteTradeCenter($this)) { parent::delete(); } else { throw new Exception("Unable to delete tradeCenter " . $this->name . " due shops linked to it."); } }
public function save() { $this->mdate = M('Date')->dbDateTime(); if ($this->version == $this->_propInitial('version')) { $this->subversion++; } return parent::save(); }
public function save() { if (!parent::save()) { return FALSE; } $this->updateQueueStatus(); return TRUE; }
/** * Saves account (count data implements) * * @return bool */ public function save() { if (!$this->cdate) { $this->cdate = M('Date')->dbDateTime(); } $this->mdate = M('Date')->dbDateTime(); $this->_prepare(); return parent::save(); }
public function delete() { if ($this->_mapper->shopTypeDeleteCheck($this)) { $this->_mapper->deleteSettings('type', $this->id()); parent::delete(); } else { throw new Exception("Unable to delete shop type `" . $this->name . "' due shops linked to it."); } }
public function delete() { if (!$this->canDelete()) { $res = M('Base')->result(); $res->error('family_is_not_empty'); throw new RM_Validator_Exception($res); } parent::delete(); }
public function delete() { if (!$this->_mapper->canDeleteCatalogueEntry($this)) { $res = M('Base')->result(); $res->error('have_childs'); throw new RM_Validator_Exception($res); } parent::delete(); }
/** * Constructor. Accepts following arguments: * guidType required string Guid-type for this class. * guidTypeProp optional string Name of "guid-type" property. Default is "guid_type" * * If you decide NOT TO PASS some of required object - reimplement dependent methods * * @param args hash Arguments * @return */ public function __construct($args) { parent::__construct($args); if (!$this->_guidTypeProp) { $this->_guidTypeProp = 'guid_type'; } if ($this->_guidType and isset($this->_props[$this->_guidTypeProp])) { $this->{$this->_guidTypeProp} = $this->_guidType; } }
public function save() { if (!isset($this->_props['owner_id'])) { $this->_props['owner_id'] = -1; } if (!isset($this->_props['parent_id'])) { $this->_props['parent_id'] = 0; } return parent::save(); }
public function delete() { if (($this->city_id != me()->city_id || !$this->city_id) && !me()->isUserInGroup('federal-news')) { $this->_permissionDenied(); } if ($this->city_id == me()->city_id && !me()->isUserInGroup('regional-news')) { $this->_permissionDenied(); } parent::delete(); }
/** * Description... * * @return void **/ public function save() { if (!$this->cdate) { $this->cdate = M('Date')->dbDateTime(); } if (!$this->moderated) { $this->moderated = 0; } $this->mdate = M('Date')->dbDateTime(); parent::save(); }
public function save() { if (!parent::save()) { return FALSE; } // var_dump($this->stack()); foreach ($this->stack() as $id => $object) { $this->_mapper->setDependency($this, $object); } return TRUE; }
/** * @see RM_Store_Object::delete */ public function delete() { if (count($this->_mapper->getCompositeListForScript($this)) > 0) { throw new RM_Validator_Exception(M('Base')->error('has_depended_composite')); } parent::delete(); if (!isNull($this->_map)) { $this->_mapper->deleteMap($this); } return TRUE; }
/** * Delete mail & all related objects. * * @return bool true - success * false - failed (use $ob->validator()->getErrors() method to get errors) */ public function delete() { $rs = $this->getAttachmentList(); if (!parent::delete()) { return false; } foreach ($rs as $ob) { $ob->delete(); } return true; }
/** * Delete type & all related objects. * * @return bool true - success * false - failed (use $ob->validator()->getErrors() method to get errors) */ public function delete() { $rs1 = $this->getTemplateList(); $rs2 = $this->getVariableList(); if (!parent::delete()) { return false; } // delete templates foreach ($rs1 as $ob) { $ob->delete(); } // delete variables foreach ($rs2 as $ob) { $ob->delete(); } return true; }
/** * Saves this object * * @return bool **/ public function save() { if ($this->_existsInDb) { $this->CoderID = me()->id(); $this->CodedDate = M('Tools')->date()->dbDateTime(); } elseif (!$this->CoderID) { $this->CoderID = 0; } $this->is_food = (int) $this->is_food; // validate barcode entities foreach ($this->_mapper->related_entities() as $entity_type => $field_name) { if (!(int) $this->{$field_name}) { $this->{$field_name} = M('Barcode')->getEmptyEntity($entity_type)->id(); } } // validate GPC entitites specified for this barcode foreach (M('Gpc')->entities() as $gpc_entity) { if ($this->{$gpc_entity . '_id'} && isNull($this->{'get' . ucfirst($gpc_entity)}())) { $this->{$gpc_entity . '_id'} = NULL; } } if (!($this->complete > 0)) { $this->complete = 0; } $this->_validateAttributes(); // save last state data for barcodes control report $dataInitial = $this->_propsInitial; if ($result = parent::save()) { $this->cleanFlavours(); if (isset($this->_props['CoderId'])) { $this->_addToBarcodeControl($dataInitial); } } return $result; }
public function __construct($args) { parent::__construct($args); $this->_setStrategy(); }
/** * Saves this object * * @return bool **/ public function save() { $this->getResult()->clearRelatedResultSteps($this->getStep()); return parent::save(); }
/** * Saves this object * * @return bool **/ public function save() { $this->mdate = M('Date')->dbDateTime(); $this->getResult()->clearRelatedResultAnswers($this->getQuestion()); return parent::save(); }
/** * Enter description here... * * @return void */ public function delete() { if (!$this->canDelete()) { throw new RM_Base_Exception_BadUsage(__METHOD__ . ' you can\'t delete this order. Please use `canDelete()` method to check '); } M('Points')->deletePresentOrder(array('user_id' => $this->user_id, 'present_id' => $this->present_id, 'price' => $this->getPresent()->price, 'quantity' => $this->quantity)); foreach ($this->_items as $obOrderItem) { $obOrderItem->delete(); } return parent::delete(); }
protected function _saveObjectHelper($insert, RM_Store_Object $object, RM_Validator_iValidator $validator = NULL) { if (isNull($validator)) { $validator = $object->validator(); } if (!isNull($validator) && !$validator->check($object->props())) { return FALSE; } $meta = $this->_mediator->meta; $fields = array(); $allFields = array(); $props = $object->props(); foreach ($meta->propList() as $prop) { $allFields[$meta->dbField($prop)] = $props[$prop]; if ($insert or $props[$prop] !== $object->_propInitial($prop)) { $field = $meta->dbQuoted($prop); $fields[$insert ? $field : "{$field} = ?"] = $props[$prop]; } } if (!$fields) { return FALSE; } if ($insert) { $binds = $fields; $query = "INSERT INTO {$this->_table}(" . join(',', array_keys($fields)) . ") VALUES(" . sqlBinds($fields) . ")"; } else { list($where, $wbinds) = $this->_getDbWhere($object); $binds = array_merge($fields, $wbinds); $query = "UPDATE {$this->_table} SET " . join(',', array_keys($fields)) . " WHERE {$where}"; } $this->_dbh->exec($query, array_values($binds)); if (!isNull($this->_tableHistory)) { $obHistory = M('Store')->history(); if ($obHistory->_closeStamp() || $object->isChildren()) { list($where, $wbinds) = $this->_getDbWhere($object); $query = "UPDATE {$this->_tableHistory} SET stamp_close = " . $obHistory->getStamp() . ", last_state = 0 WHERE " . $where . " AND last_state = 1"; $this->_dbh->exec($query, $wbinds); } $binds = array_merge(array('stamp_open' => $obHistory->getStamp(), 'stamp_close' => $obHistory->getFarFuture(), 'last_state' => 1), $allFields); $query = "REPLACE INTO {$this->_tableHistory}( " . join(',', array_keys($binds)) . ") VALUES(" . sqlBinds($binds) . ")"; $this->_dbh->exec($query, array_values($binds)); $obHistory->register($object, $insert ? RM_Store_History::OBJECT_CREATE : RM_Store_History::OBJECT_EDIT); } if ($this->_autoId and !$object->{$this->_autoId}) { $object->{$this->_autoId} = $this->_dbh->lastInsertID(); $allFields[$meta->dbField($this->_autoId)] = $object->{$this->_autoId}; } if ($this->_cacheNs) { $this->cacheUpdate($object, $allFields); } return TRUE; }
/** * Saves this object * * @return bool **/ public function save() { if (!$this->_existsInDb()) { $this->id = mb_strtolower($this->id, mb_detect_encoding($this->id)); } return parent::save(); }
/** * Deletes this object * * @return bool **/ public function delete() { $this->clearResultAnswers(); return parent::delete(); }
/** * Deletes this object * * @return bool **/ public function delete() { $this->_canDelete(); return parent::delete(); }
/** * Safe update of object by data array * * @param RM_Store_Object $object * @param array $data */ function updateObjectByArray(RM_Store_Object $object, array $data) { foreach (array_keys($object->props()) as $property) { if ($property == 'id') { continue; } // чтоб случайно id не подменить if (isset($data[$property])) { $object->{$property} = $data[$property]; } } }