Ejemplo n.º 1
0
 public function deleteRowNavigation($signal, Centurion_Db_Table_Row_Abstract $sender)
 {
     if (null !== $sender->getProxy() && get_class($sender->getProxy()) == self::CMS_FLATPAGE_ROW) {
         $sender->getProxy()->delete();
     }
     return;
     $navigationTable = Centurion_Db::getSingleton('core/navigation');
     list($contentType, ) = Centurion_Db::getSingleton('core/contentType')->getOrCreate(array('name' => self::CMS_FLATPAGE_ROW));
     if ($sender->proxy_model === $contentType->id && $sender->proxy !== null) {
         $row = $navigationTable->createRow(array('proxy_model' => $contentType->id, 'proxy_pk' => $sender->id, 'label' => $sender->label, 'is_visible' => 0));
         $node = $navigationTable->fetchRow(array('class=?' => 'unactived'));
         $row->insertAt($node, Core_Traits_Mptt_Model_DbTable::POSITION_LAST_CHILD, true);
     }
 }
Ejemplo n.º 2
0
 /**
  * We remove the file on the adapter before removing it in DB.
  *
  * @return int
  */
 public function delete()
 {
     if (!empty($this->adapter)) {
         $staticAdapter = Media_Model_Adapter::factory($this->adapter, unserialize($this->params));
         $staticAdapter->delete($this->dest);
     }
     return parent::delete();
 }
Ejemplo n.º 3
0
 public function save()
 {
     $current = $this->getTable()->getReferenceMap($this->_getExtend());
     if (isset($this->{$current['columns']}) && $this->pk !== $this->{$current['columns']}) {
         foreach ($this->_data as $key => &$value) {
             if (!$this->_isExtendable($key) || $value != $this->{$this->_getExtend()}->{$key}) {
                 continue;
             }
             $value = null;
         }
     }
     return parent::save();
 }
Ejemplo n.º 4
0
 /**
  * @param null|array $values
  * @return Centurion_Db_Table_Row_Abstract|null
  */
 public function saveInstance($values = null)
 {
     if ($values === null) {
         $values = $this->getValues();
     }
     $values = $this->_saveReferenceSubForms($this->_processValues($values));
     if (!$this->hasInstance()) {
         $this->_isNew = true;
         $this->_instance = $this->getModel()->createRow();
     } else {
         $this->_instance->setReadOnly(false);
     }
     $this->_instance->setFromArray($values);
     $this->_preSave();
     Centurion_Signal::factory('pre_save')->send($this);
     $this->_instance->save();
     $this->_saveManyDependentTables();
     $this->_postSave($this->_isNew);
     Centurion_Signal::factory('post_save')->send($this);
     return $this->_instance;
 }
Ejemplo n.º 5
0
 public function signalRow($signal, Centurion_Db_Table_Row_Abstract $row)
 {
     $pk = is_string($row->pk) || is_int($row->pk) ? $row->pk : md5(serialize($row->pk));
     $tag = sprintf('__%s__%s', $row->getTable()->info(Centurion_Db_Table_Abstract::NAME), $pk);
     $this->cleanCacheAsynchronous(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array($tag));
     $tag = sprintf('__%s', $row->getTable()->info(Centurion_Db_Table_Abstract::NAME));
     $this->cleanCacheAsynchronous(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array($tag));
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * Allows pre-delete logic to be applied to row.
  * Subclasses may override this method.
  *
  * @return void
  */
 protected function _delete()
 {
     if ($this->can_be_deleted == '0') {
         throw new Centurion_Db_Table_Row_Exception('This row can not be deleted');
     }
     parent::_delete();
 }
Ejemplo n.º 7
0
 public function __construct($config)
 {
     $this->_specialGets['translations_remaining'] = 'getTranslationsRemaining';
     parent::__construct($config);
 }
Ejemplo n.º 8
0
 /**
  * Set $instance as the proxy instance of the current row.
  *
  * @param Centurion_Db_Table_Row_Abstract $instance
  * @return Centurion_Db_Table_Row_Abstract
  */
 public function _setProxy(Centurion_Db_Table_Row_Abstract $instance)
 {
     list($contentTypeRow, ) = Centurion_Db::getSingleton('core/contentType')->getOrCreate(array('name' => get_class($instance->getTable())));
     $this->proxy_content_type_id = $contentTypeRow->id;
     $this->proxy_pk = $instance->id;
 }
Ejemplo n.º 9
0
 public function delete()
 {
     if ($this->file_id !== null && $this->getTable()->select(true)->where('file_id=?', $this->file_id)->count() == 1) {
         unlink(Centurion_Config_Manager::get('media.uploads_dir') . DIRECTORY_SEPARATOR . $this->local_filename);
     }
     parent::delete();
 }
Ejemplo n.º 10
0
 /**
  * Set belong for the query.
  * @param Centurion_Db_Table_Row_Abstract $object
  * @return Media_Model_DbTable_Select_File
  */
 public function belong($object)
 {
     $contentType = get_class($object->getTable());
     $this->where('belong_model = ?', $contentType)->where('belong_pk = ?', $object->pk);
     return $this;
 }
Ejemplo n.º 11
0
 /**
  * @param Centurion_Db_Table_Row_Abstract $row
  * @param string $key
  * @param $effect
  * @return bool
  */
 public function isValidKey($row, $key, $effect)
 {
     $lifetime = Centurion_Config_Manager::get('media.key_lifetime');
     list($lifetimeValue, $lifetimeUnit) = sscanf($lifetime, '%d%s');
     $lifetimeUnit = strtolower($lifetimeUnit);
     $date = new Zend_Date();
     switch ($lifetimeUnit) {
         case 'j':
             $date->setHour(0);
         case 'h':
             $date->setMinute(0);
         case 'm':
         default:
             $date->setSecond(0);
     }
     for ($i = 0; $i < $lifetimeValue; $i++) {
         if ($key === $row->getTemporaryKey($effect, $date)) {
             return true;
         }
         switch ($lifetimeUnit) {
             case 'j':
                 $date->subDay(1);
                 break;
             case 'h':
                 $date->subHour(1);
                 break;
             case 'm':
             default:
                 $date->subMinute(1);
                 break;
         }
     }
     return false;
 }
Ejemplo n.º 12
0
 /**
  * @return int
  */
 public function delete()
 {
     if ($this->delete_original == '1') {
         if ($this->file_id !== null && $this->getTable()->select(true)->where('file_id=?', $this->file_id)->count() == 1) {
             unlink($this->getFullLocalPath());
         }
     }
     return parent::delete();
 }