コード例 #1
0
ファイル: IzapObject.php プロジェクト: socialweb/PiGo
 /**
  *  save the entity and updates the metadata
  * adds  the entity to the river
  * @global  $CONFIG
  * @param boolean $validate
  * @param array $options more information useful to save the entity
  * @return boolean
  */
 public function save($validate = true, $options = array())
 {
     global $CONFIG;
     if ($this->_guid && !$this->canEdit()) {
         $this->error_code = self::ERROR_CAN_EDIT;
         return false;
     }
     if ($validate) {
         $validated = $this->_post->form_validated && $this->validate();
     } else {
         $validated = true;
     }
     $river_action = $this->isNewRecord() ? 'created' : 'updated';
     if ($validated && parent::save()) {
         if ($options['river'] !== false) {
             $view = "river/{$this->getType()}/{$this->getSubtype()}/{$river_action}";
             if (!elgg_view_exists($view)) {
                 $view = "river/{$this->getType()}/{$this->getSubtype()}/default";
                 if (!elgg_view_exists($view)) {
                     $view = "river/{$this->getType()}/default";
                 }
             }
             add_to_river($view, $river_action, elgg_get_logged_in_user_guid(), $this->guid);
         }
         // save some more info, so that we can use them for easy processing
         $this->slug = elgg_get_friendly_title($this->title);
         $this->owner_username = IzapBase::getOwnerUsername($this);
         $this->owner_name = IzapBase::getOwnerName($this);
         $this->container_username = IzapBase::getContainerUsername($this);
         $this->container_name = IzapBase::getContainerName($this);
         return true;
     }
     return false;
 }