예제 #1
0
 /**
  * Update all attributes after an update.
  *
  * @param Doctrine_Event $event Event.
  *
  * @return void
  */
 public function postUpdate(Doctrine_Event $event)
 {
     $data = $event->getInvoker();
     if (!isset($data['__ATTRIBUTES__'])) {
         return;
     }
     $tableName = $this->getTableNameFromEvent($event);
     $idColumn = $this->getIdColumnFromEvent($event);
     $dataForObjectUtil = array();
     $dataForObjectUtil[$idColumn] = $data[$idColumn];
     $dataForObjectUtil['__ATTRIBUTES__'] = $data['__ATTRIBUTES__'];
     if ($dataForObjectUtil['__ATTRIBUTES__'] instanceof ArrayObject) {
         $dataForObjectUtil['__ATTRIBUTES__'] = $dataForObjectUtil['__ATTRIBUTES__']->getArrayCopy();
     }
     ObjectUtil::storeObjectAttributes($dataForObjectUtil, $tableName, $idColumn, true);
 }
예제 #2
0
파일: DBUtil.php 프로젝트: rmaiwald/core
 /**
  * Post-processing after this object has beens saved.
  *
  * This routine is responsible for writing the 'extra' data (attributes, categories,
  * and meta data) to the database and the optionally creating an
  * entry in the object-log table.
  *
  * @param mixed   $object  The object wehave just saved.
  * @param string  $table   The treated table reference.
  * @param integer $idfield The id column for the object/table combination.
  * @param boolean $update  Whether or not this was an update (default=false, signifies operation was an insert).
  *
  * @return mixed The object.
  * @deprecated
  * @see    CategorisableListener, AttributableListener, MetaDataListener, LoggableListener
  * @throws Exception If invalid idfield received.
  */
 private static function _savePostProcess($object, $table, $idfield, $update = false)
 {
     $tables = self::getTables();
     $enableAllServices = isset($tables["{$table}_db_extra_enable_all"]) && $tables["{$table}_db_extra_enable_all"];
     if (!$idfield) {
         throw new Exception(__f('Invalid idfield received', $table));
     }
     if (($enableAllServices || isset($tables["{$table}_db_extra_enable_categorization"]) && $tables["{$table}_db_extra_enable_categorization"]) && System::getVar('Z_CONFIG_USE_OBJECT_CATEGORIZATION') && strcmp($table, 'categories_') !== 0 && strcmp($table, 'objectdata_attributes') !== 0 && strcmp($table, 'objectdata_log') !== 0 && ModUtil::available('ZikulaCategoriesModule')) {
         ObjectUtil::storeObjectCategories($object, $table, $idfield, $update);
     }
     if (($enableAllServices || isset($tables["{$table}_db_extra_enable_attribution"]) && $tables["{$table}_db_extra_enable_attribution"] || System::getVar('Z_CONFIG_USE_OBJECT_ATTRIBUTION')) && strcmp($table, 'objectdata_attributes') !== 0 && strcmp($table, 'objectdata_log') !== 0) {
         ObjectUtil::storeObjectAttributes($object, $table, $idfield, $update);
     }
     if (($enableAllServices || isset($tables["{$table}_db_extra_enable_meta"]) && $tables["{$table}_db_extra_enable_meta"] || System::getVar('Z_CONFIG_USE_OBJECT_META')) && $table != 'objectdata_attributes' && $table != 'objectdata_meta' && $table != 'objectdata_log') {
         ObjectUtil::updateObjectMetaData($object, $table, $idfield);
     }
     if (($enableAllServices || isset($tables["{$table}_db_extra_enable_logging"]) && $tables["{$table}_db_extra_enable_logging"]) && System::getVar('Z_CONFIG_USE_OBJECT_LOGGING') && strcmp($table, 'objectdata_log') !== 0) {
         $oldObj = self::selectObjectByID($table, $object[$idfield], $idfield);
         $log = new ObjectData_Log();
         $log['object_type'] = $table;
         $log['object_id'] = $object[$idfield];
         $log['op'] = $update ? 'U' : 'I';
         if ($update) {
             $log['diff'] = serialize(ObjectUtil::diffExtended($oldObj, $object, $idfield));
         } else {
             $log['diff'] = serialize($object);
         }
         $log->save();
     }
     return $object;
 }