예제 #1
0
 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;
 }
예제 #2
0
 public function __set($name, $value)
 {
     if ($name == 'status_id' && $value != $this->status_id) {
         $this->_clearStrategy();
     }
     return parent::__set($name, $value);
 }
예제 #3
0
 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);
 }
예제 #4
0
 /**
  * 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();
 }
예제 #5
0
파일: Link.class.php 프로젝트: evilgeny/bob
 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();
 }
예제 #6
0
 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.");
     }
 }
예제 #7
0
 public function save()
 {
     $this->mdate = M('Date')->dbDateTime();
     if ($this->version == $this->_propInitial('version')) {
         $this->subversion++;
     }
     return parent::save();
 }
예제 #8
0
 public function save()
 {
     if (!parent::save()) {
         return FALSE;
     }
     $this->updateQueueStatus();
     return TRUE;
 }
예제 #9
0
 /**
  * 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();
 }
예제 #10
0
파일: Type.class.php 프로젝트: evilgeny/bob
 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.");
     }
 }
예제 #11
0
 public function delete()
 {
     if (!$this->canDelete()) {
         $res = M('Base')->result();
         $res->error('family_is_not_empty');
         throw new RM_Validator_Exception($res);
     }
     parent::delete();
 }
예제 #12
0
 public function delete()
 {
     if (!$this->_mapper->canDeleteCatalogueEntry($this)) {
         $res = M('Base')->result();
         $res->error('have_childs');
         throw new RM_Validator_Exception($res);
     }
     parent::delete();
 }
예제 #13
0
파일: Guid.class.php 프로젝트: evilgeny/bob
 /**
  *	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;
     }
 }
예제 #14
0
 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();
 }
예제 #15
0
 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();
 }
예제 #16
0
 /**
  *	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();
 }
예제 #17
0
 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;
 }
예제 #18
0
 /**
  * @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;
 }
예제 #19
0
파일: Mail.class.php 프로젝트: evilgeny/bob
 /**
  *	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;
 }
예제 #20
0
파일: Type.class.php 프로젝트: evilgeny/bob
 /**
  *	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;
 }
예제 #21
0
 /**
  *	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;
 }
예제 #22
0
 public function __construct($args)
 {
     parent::__construct($args);
     $this->_setStrategy();
 }
예제 #23
0
파일: Step.class.php 프로젝트: evilgeny/bob
 /**
  * Saves this object
  *
  * @return	bool
  **/
 public function save()
 {
     $this->getResult()->clearRelatedResultSteps($this->getStep());
     return parent::save();
 }
예제 #24
0
 /**
  * Saves this object
  *
  * @return	bool
  **/
 public function save()
 {
     $this->mdate = M('Date')->dbDateTime();
     $this->getResult()->clearRelatedResultAnswers($this->getQuestion());
     return parent::save();
 }
예제 #25
0
 /**
  * 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();
 }
예제 #26
0
 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;
 }
예제 #27
0
 /**
  * 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();
 }
예제 #28
0
 /**
  * Deletes this object
  *
  * @return	bool
  **/
 public function delete()
 {
     $this->clearResultAnswers();
     return parent::delete();
 }
예제 #29
0
 /**
  * Deletes this object
  *
  * @return	bool
  **/
 public function delete()
 {
     $this->_canDelete();
     return parent::delete();
 }
예제 #30
0
파일: shortcuts.php 프로젝트: evilgeny/bob
/**
 * 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];
        }
    }
}