public function updateObject($values = null)
 {
     $oldSlug = $this->getObject()->slug;
     $object = parent::updateObject($values);
     // Check for cascading operations
     if ($this->getValue('cascade_archived') || $this->getValue('cascade_view_is_secure')) {
         $q = Doctrine::getTable('aPage')->createQuery()->update()->where('lft > ? and rgt < ?', array($object->getLft(), $object->getRgt()));
         if ($this->getValue('cascade_archived')) {
             $q->set('archived', '?', $object->getArchived());
         }
         if ($this->getValue('cascade_view_is_secure')) {
             $q->set('view_is_secure', '?', $object->getViewIsSecure());
         }
         $q->execute();
     }
     // On manual change of slug, set up a redirect from the old slug,
     // and notify child pages so they can update their slugs if they are
     // not already deliberately different
     if ($object->slug !== $oldSlug) {
         Doctrine::getTable('aRedirect')->update($oldSlug, $object);
         $children = $object->getChildren();
         foreach ($children as $child) {
             $child->updateParentSlug($oldSlug, $object->slug);
         }
     }
     if (isset($object->engine) && !strlen($object->engine)) {
         // Store it as null for plain ol' executeShow page templating
         $object->engine = null;
     }
     $this->savePrivileges($object, 'edit', 'editors');
     $this->savePrivileges($object, 'manage', 'managers');
     // Has to be done on shutdown so it comes after the in-memory cache of
     // sfFileCache copies itself back to disk, which otherwise overwrites
     // our attempt to invalidate the routing cache [groan]
     register_shutdown_function(array($this, 'invalidateRoutingCache'));
     return $object;
 }
Exemplo n.º 2
0
 /**
  * Privileges are saved after the object itself to avoid chicken and egg problems
  * if the page is new
  * @param mixed $con
  * @return mixed
  */
 public function save($con = null)
 {
     $object = parent::save($con);
     $this->saveIndividualViewPrivileges($object);
     $this->saveGroupViewPrivileges($object);
     $this->saveIndividualEditPrivileges($object);
     $this->saveGroupEditPrivileges($object);
     // Update meta-description on Page
     // This involves creating a slot so it has to happen last
     if ($this->getValue('real_meta_description') != '') {
         $object->setMetaDescription(htmlentities($this->getValue('real_meta_description'), ENT_COMPAT, 'UTF-8'));
     }
     $this->getObject()->setTitle(htmlentities($this->getValue('realtitle'), ENT_COMPAT, 'UTF-8'));
     return $object;
 }
Exemplo n.º 3
0
 /**
  * DOCUMENT ME
  * @param mixed $con
  */
 protected function doSave($con = null)
 {
     $this->updateCategoriesList(isset($this->values['categories_list_add']) ? $this->values['categories_list_add'] : array());
     parent::doSave($con);
 }
Exemplo n.º 4
0
 public function updateObject($values = null)
 {
     $object = parent::updateObject($values);
     // Check for cascading operations
     if ($this->getValue('cascade_archived') || $this->getValue('cascade_view_is_secure')) {
         $q = Doctrine::getTable('aPage')->createQuery()->update()->where('lft > ? and rgt < ?', array($object->getLft(), $object->getRgt()));
         if ($this->getValue('cascade_archived')) {
             $q->set('archived', '?', $object->getArchived());
         }
         if ($this->getValue('cascade_view_is_secure')) {
             $q->set('view_is_secure', '?', $object->getViewIsSecure());
         }
         $q->execute();
     }
     // This part isn't validation, it's just normalization.
     $slug = $object->slug;
     $slug = trim($slug);
     $slug = preg_replace("/\\/+/", "/", $slug);
     $slug = preg_match("/^(\\/.*?)\\/*\$/", $slug, $matches);
     $object->slug = $matches[1];
     if (isset($object->engine) && !strlen($object->engine)) {
         // Store it as null for plain ol' executeShow page templating
         $object->engine = null;
     }
     $this->savePrivileges($object, 'edit', 'editors');
     $this->savePrivileges($object, 'manage', 'managers');
     // Has to be done on shutdown so it comes after the in-memory cache of
     // sfFileCache copies itself back to disk, which otherwise overwrites
     // our attempt to invalidate the routing cache [groan]
     register_shutdown_function(array($this, 'invalidateRoutingCache'));
 }