Example #1
0
 /**
  * function update
  * Updates an existing comment in the posts table
  */
 public function update()
 {
     $result = parent::updateRecord(DB::table('link_traffic'), array('id' => $this->id));
     $this->fields = array_merge($this->fields, $this->newfields);
     $this->newfields = array();
     return $result;
 }
Example #2
0
 /**
  * function update
  * Updates an existing tag in the tags table
  */
 public function update()
 {
     $allow = true;
     $allow = Plugins::filter('tag_update_allow', $allow, $this);
     if (!$allow) {
         return;
     }
     Plugins::act('tag_update_before', $this);
     // Call setslug() only when tag slug is changed
     if (isset($this->newfields['tag_slug']) && $this->newfields['tag_slug'] != '') {
         if ($this->fields['tag_slug'] != $this->newfields['tag_slug']) {
             $this->setslug();
         }
     }
     // invoke plugins for all fields which have been changed
     // For example, a plugin action "tag_update_slug" would be
     // triggered if the tag has a new slug value
     foreach ($this->newfields as $fieldname => $value) {
         Plugins::act('tag_update_' . $fieldname, $this, $this->fields[$fieldname], $value);
     }
     $result = parent::updateRecord(DB::table('tags'), array('id' => $this->id));
     $this->fields = array_merge($this->fields, $this->newfields);
     $this->newfields = array();
     Plugins::act('tag_update_after', $this);
     return $result;
 }
Example #3
0
	/**
	 * function update
	 * Updates an existing post in the posts table
	 * @param bool $minor Indicates if this is a major or minor update
	 */
	public function update( $minor = true )
	{
		$this->modified = HabariDateTime::date_create();
		if ( ! $minor && $this->status != Post::status( 'draft' ) ) {
			$this->updated = $this->modified;
		}

		if ( isset( $this->fields['guid'] ) ) {
			unset( $this->newfields['guid'] );
		}
		
		if ( $this->pubdate->int > HabariDateTime::date_create()->int && $this->status == Post::status( 'published' ) ) {
			$this->status = Post::status( 'scheduled' );
		}

		$allow = true;
		$allow = Plugins::filter( 'post_update_allow', $allow, $this );
		if ( ! $allow ) {
			return;
		}
		Plugins::act( 'post_update_before', $this );

		// Call setslug() only when post slug is changed
		if ( isset( $this->newfields['slug'] ) ) {
			if ( $this->fields['slug'] != $this->newfields['slug'] ) {
				$this->setslug();
			}
		}

		// invoke plugins for all fields which have been changed
		// For example, a plugin action "post_update_status" would be
		// triggered if the post has a new status value
		foreach ( $this->newfields as $fieldname => $value ) {
			Plugins::act( 'post_update_' . $fieldname, $this, $this->fields[$fieldname], $value );
		}

		// invoke plugins for status changes
		if ( isset( $this->newfields['status'] ) && $this->fields['status'] != $this->newfields['status'] ) {
			Plugins::act( 'post_status_' . self::status_name( $this->newfields['status'] ), $this, $this->fields['status'] );
		}

		$result = parent::updateRecord( DB::table( 'posts' ), array( 'id' => $this->id ) );

		//scheduled post
		if ( $this->fields['status'] == Post::status( 'scheduled' ) || $this->status == Post::status( 'scheduled' ) ) {
			Posts::update_scheduled_posts_cronjob();
		}

		$this->fields = array_merge( $this->fields, $this->newfields );
		$this->newfields = array();
		$this->save_tags();
		$this->info->commit();
		Plugins::act( 'post_update_after', $this );
		return $result;
	}
Example #4
0
 /**
  * Updates an existing comment in the comments table
  * @return boolean True on success, false if not
  */
 public function update()
 {
     $allow = true;
     $allow = Plugins::filter('comment_update_allow', $allow, $this);
     if (!$allow) {
         return false;
     }
     Plugins::act('comment_update_before', $this);
     // invoke plugins for all fields which have been updated
     foreach ($this->newfields as $fieldname => $value) {
         Plugins::act('comment_update_' . $fieldname, $this, $this->fields[$fieldname], $value);
     }
     $result = parent::updateRecord(DB::table('comments'), array('id' => $this->id));
     $this->fields = array_merge($this->fields, $this->newfields);
     $this->newfields = array();
     $this->info->commit();
     Plugins::act('comment_update_after', $this);
     return $result;
 }
Example #5
0
 /**
  * Updates an existing rule in the rewrite_rules table
  */
 public function update()
 {
     return parent::updateRecord(DB::table('rewrite_rules'), array('rule_id' => $this->rule_id));
 }
Example #6
0
 /**
  * Updates an existing cron job to the crontab table.
  *
  * @see QueryRecord::updateRecord()
  * @return CronJob The updated cron job, or false if failed.
  */
 public function update()
 {
     return parent::updateRecord(DB::table('crontab'), array('cron_id' => $this->cron_id));
 }
Example #7
0
	/**
	 * function update
	 * Updates an existing term in the terms table
	 */
	public function update()
	{
		// Let plugins disallow and act before we write to the database
		$allow = true;
		$allow = Plugins::filter( 'term_update_allow', $allow, $this );
		if ( !$allow ) {
			return;
		}
		Plugins::act( 'term_update_before', $this );

		// Call setslug() only when term is changed
		if ( isset( $this->newfields[ 'term' ] ) && $this->newfields[ 'term' ] != '' ) {
			if ( $this->fields[ 'term' ] != $this->newfields[ 'term' ] ) {
				$this->setslug();
			}
		}

		$result = parent::updateRecord( '{terms}', array( 'id' => $this->id ) );
		$this->fields = array_merge( $this->fields, $this->newfields );

		$this->info->commit();
		
		// Let plugins act after we write to the database
		Plugins::act( 'term_update_after', $this );

		return $result;
	}
Example #8
0
 /**
  * Update this block in the database
  *
  * @return boolean True on success
  */
 public function update()
 {
     $allow = true;
     $allow = Plugins::filter('block_update_allow', $allow, $this);
     if (!$allow) {
         return;
     }
     Plugins::act('block_update_before', $this);
     $this->data = serialize($this->data_values);
     $result = parent::updateRecord(DB::table('blocks'), array('id' => $this->id));
     $this->fields = array_merge($this->fields, $this->newfields);
     $this->newfields = array();
     Plugins::act('block_update_after', $this);
     return $result;
 }
Example #9
0
 /**
  * Updates an existing user in the users table
  */
 public function update()
 {
     $allow = true;
     $allow = Plugins::filter('user_update_allow', $allow, $this);
     if (!$allow) {
         return;
     }
     Plugins::act('user_update_before', $this);
     $this->info->commit();
     $result = parent::updateRecord(DB::table('users'), array('id' => $this->id));
     Plugins::act('user_update_after', $this);
     return $result;
 }
Example #10
0
 /**
  * function update
  * Updates an existing vocabulary in the vocabularies table
  */
 public function update()
 {
     // Don't allow duplicate vocabularies
     if (isset($this->newfields['name']) && Vocabulary::exists($this->newfields['name'])) {
         return false;
     }
     // Let plugins disallow and act before we write to the database
     $allow = true;
     $allow = Plugins::filter('vocabulary_update_allow', $allow, $this);
     if (!$allow) {
         return;
     }
     Plugins::act('vocabulary_update_before', $this);
     if (isset($this->newfields['features'])) {
         $this->newfields['features'] = serialize($this->newfields['features']);
     }
     if (isset($this->fields['features'])) {
         $this->fields['features'] = serialize($this->fields['features']);
     }
     $result = parent::updateRecord('{vocabularies}', array('id' => $this->id));
     $this->fields = array_merge($this->fields, $this->newfields);
     $this->newfields = array();
     if (isset($this->fields['features'])) {
         $this->fields['features'] = unserialize($this->fields['features']);
     }
     // Let plugins act after we write to the database
     Plugins::act('vocabulary_update_after', $this);
     return $result;
 }
Example #11
0
 /**
  * Updates an existing post in the posts table
  * @param bool $minor Indicates if this is a major or minor update
  * @return bool True on success
  */
 public function update($minor = true)
 {
     if ($this->id == 0) {
         return $this->insert() !== false;
     }
     $this->modified = DateTime::create();
     if (!$minor && $this->status != Post::status('draft')) {
         $this->updated = $this->modified;
     }
     if (isset($this->fields['guid'])) {
         unset($this->newfields['guid']);
     }
     // if the date is in the future and we are trying to publish the post, actually schedule it for posting later
     if ($this->pubdate > DateTime::create() && $this->status == Post::status('published')) {
         $this->status = Post::status('scheduled');
     } else {
         if ($this->pubdate <= DateTime::create() && $this->status == Post::status('scheduled')) {
             $this->status = Post::status('published');
         }
     }
     $allow = true;
     $allow = Plugins::filter('post_update_allow', $allow, $this);
     if (!$allow) {
         return false;
     }
     Plugins::act('post_update_before', $this);
     $this->newfields = Plugins::filter('post_update_change', $this->newfields, $this, $this->fields);
     // Call setslug() only when post slug is changed
     if (isset($this->newfields['slug'])) {
         if ($this->fields['slug'] != $this->newfields['slug']) {
             $this->setslug();
         }
     }
     // If content has changed, update cached_content with prerendered content
     if (isset($this->newfields['content']) && $this->fields['content'] != $this->newfields['content']) {
         $this->newfields['cached_content'] = Plugins::filter('post_prerender_content', $this->newfields['content'], $this);
     }
     // invoke plugins for all fields which have been changed
     // For example, a plugin action "post_update_status" would be
     // triggered if the post has a new status value
     $change_date = DateTime::create()->sql;
     foreach ($this->newfields as $fieldname => $value) {
         Plugins::act('post_update_' . $fieldname, $this, $this->fields[$fieldname], $value);
         if ($this->fields[$fieldname] != $value) {
             DB::insert('{revisions}', array('post_id' => $this->fields['id'], 'change_field' => $fieldname, 'old_value' => $this->fields[$fieldname], 'user_id' => User::identify()->id, 'change_date' => $change_date));
         }
     }
     // invoke plugins for status changes
     if (isset($this->newfields['status']) && $this->fields['status'] != $this->newfields['status']) {
         Plugins::act('post_status_' . self::status_name($this->newfields['status']), $this, $this->fields['status']);
     }
     $result = parent::updateRecord('posts', array('id' => $this->id), post::get_schema_map());
     //scheduled post
     if ($this->fields['status'] == Post::status('scheduled') || $this->status == Post::status('scheduled')) {
         Posts::update_scheduled_posts_cronjob();
     }
     $this->fields = array_merge($this->fields, $this->newfields);
     $this->newfields = array();
     $this->save_tags();
     $this->info->commit();
     Plugins::act('post_update_after', $this);
     return $result;
 }