示例#1
0
文件: DBUtil.php 项目: rmaiwald/core
 /**
  * Post-processing after this object has beens deleted.
  *
  * This routine is responsible for deleting the 'extra' data (attributes, categories,
  * and meta data) from 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.
  *
  * @deprecated
  * @see    CategorisableListener, AttributableListener, MetaDataListener, LoggableListener
  * @return void
  */
 private static function _deletePostProcess($object, $table, $idfield)
 {
     $tables = self::getTables();
     $enableAllServices = isset($tables["{$table}_db_extra_enable_all"]) && $tables["{$table}_db_extra_enable_all"];
     if (($enableAllServices || isset($tables["{$table}_db_extra_enable_categorization"]) && $tables["{$table}_db_extra_enable_categorization"]) && System::getVar('Z_CONFIG_USE_OBJECT_CATEGORIZATION') && $table != 'categories_' && $table != 'objectdata_attributes' && $table != 'objectdata_log' && ModUtil::available('ZikulaCategoriesModule')) {
         ObjectUtil::deleteObjectCategories($object, $table, $idfield);
     }
     if ((isset($tables["{$table}_db_extra_enable_all"]) && $tables["{$table}_db_extra_enable_all"] || isset($tables["{$table}_db_extra_enable_attribution"]) && $tables["{$table}_db_extra_enable_attribution"] || System::getVar('Z_CONFIG_USE_OBJECT_ATTRIBUTION')) && $table != 'objectdata_attributes' && $table != 'objectdata_log') {
         ObjectUtil::deleteObjectAttributes($object, $table, $idfield);
     }
     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::deleteObjectMetaData($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) {
         $log = new ObjectData_Log();
         $log['object_type'] = $table;
         $log['object_id'] = $object[$idfield];
         $log['op'] = 'D';
         $log['diff'] = serialize($object);
         $log->save();
     }
 }
示例#2
0
 /**
  * Delete all attribtes after an delete.
  *
  * @param Doctrine_Event $event Event.
  *
  * @return void
  */
 public function postDelete(Doctrine_Event $event)
 {
     $data = $event->getInvoker();
     if (!isset($data['__META__'])) {
         return;
     }
     $tableName = $this->getTableNameFromEvent($event);
     $idColumn = $this->getIdColumnFromEvent($event);
     // determine meta id
     if (isset($data['__META__']['id'])) {
         $metaId = $data['__META__']['id'];
     } else {
         $dataForObjectUtil = array();
         $dataForObjectUtil[$idColumn] = $data[$idColumn];
         $dataForObjectUtil['__META__'] = $data['__META__'];
         if ($dataForObjectUtil['__META__'] instanceof ArrayObject) {
             $dataForObjectUtil['__META__'] = $dataForObjectUtil['__META__']->getArrayCopy();
         }
         $meta = ObjectUtil::retrieveObjectMetaData($dataForObjectUtil, $tableName, $idColumn);
         $metaId = $meta['id'];
     }
     $dataForObjectUtil = array();
     $dataForObjectUtil[$idColumn] = $data[$idColumn];
     $dataForObjectUtil['__META__'] = $data['__META__'];
     $dataForObjectUtil['__META__']['id'] = $metaId;
     $dataForObjectUtil['__META__']['obj_id'] = $data[$idColumn];
     if ($dataForObjectUtil['__META__'] instanceof ArrayObject) {
         $dataForObjectUtil['__META__'] = $dataForObjectUtil['__META__']->getArrayCopy();
     }
     ObjectUtil::deleteObjectMetaData($dataForObjectUtil, $tableName, $idColumn);
 }