Example #1
0
	/**
	 * Delete a UserGroup
	 */
	public function delete()
	{
		$allow = true;
		// plugins have the opportunity to prevent deletion
		$allow = Plugins::filter( 'usergroup_delete_allow', $allow, $this );
		if ( ! $allow ) {
			return;
		}

		$name = $this->name;
		Plugins::act( 'usergroup_delete_before', $this );
		// remove all this group's permissions
		$results = DB::query( 'DELETE FROM {group_token_permissions} WHERE group_id=?', array( $this->id ) );
		// remove all this group's members
		$results = DB::query( 'DELETE FROM {users_groups} WHERE group_id=?', array( $this->id ) );
		// remove this group
		$result = parent::deleteRecord( DB::table( 'groups' ), array( 'id' => $this->id ) );
		Plugins::act( 'usergroup_delete_after', $this );
		EventLog::log( _t( 'User Group %s: Group deleted.', array( $name ) ), 'notice', 'user', 'habari' );
		return $result;
	}
Example #2
0
 /**
  * function delete
  * Deletes an existing tag and all relations to it (e.g. a post2tag relationship)
  */
 public function delete()
 {
     $allow = true;
     $allow = Plugins::filter('tag_delete_allow', $allow, $this);
     if (!$allow) {
         return;
     }
     // invoke plugins
     Plugins::act('tag_delete_before', $this);
     // Delete all tag2post records associated with this tag
     $sql = "DELETE FROM {tag2post} WHERE tag_id = ?";
     DB::query($sql, array($this->id));
     // Delete the parent tags record
     $result = parent::deleteRecord(DB::table('tags'), array('id' => $this->id));
     EventLog::log(sprintf(_t('Tag %1$s (%2$s) deleted.'), $this->id, $this->tag_text), 'info', 'content', 'habari');
     Plugins::act('tag_delete_after', $this);
     return $result;
 }
Example #3
0
 /**
  * Deletes this comment
  * @return boolean True on success, false if not
  */
 public function delete()
 {
     $allow = true;
     $allow = Plugins::filter('comment_delete_allow', $allow, $this);
     if (!$allow) {
         return false;
     }
     Plugins::act('comment_delete_before', $this);
     // Delete all info records associated with this comment
     $this->info->delete_all();
     $result = parent::deleteRecord(DB::table('comments'), array('id' => $this->id));
     Plugins::act('comment_delete_after', $this);
     return $result;
 }
Example #4
0
	/**
	 * function delete
	 * Deletes an existing post
	 */
	public function delete()
	{
		$allow = true;
		$allow = Plugins::filter( 'post_delete_allow', $allow, $this );
		if ( ! $allow ) {
			return;
		}
		// invoke plugins
		Plugins::act( 'post_delete_before', $this );

		// delete all the tags associated with this post
		Tags::save_associations( new Terms(), $this->id );

		// Delete all comments associated with this post
		if ( $this->comments->count() > 0 ) {
			$this->comments->delete();
		}
		// Delete all info records associated with this post
			$this->info->delete_all();
		// Delete all post_tokens associated with this post
		$this->delete_tokens();

		$result = parent::deleteRecord( DB::table( 'posts' ), array( 'slug'=>$this->slug ) );
		EventLog::log( sprintf( _t( 'Post %1$s (%2$s) deleted.' ), $this->id, $this->slug ), 'info', 'content', 'habari' );

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

		// invoke plugins on the after_post_delete action
		Plugins::act( 'post_delete_after', $this );
		return $result;
	}
Example #5
0
 /**
  * Deletes an existing cron job.
  *
  * @see QueryRecord::deleteRecord()
  * @return bool If the delete was successful
  */
 public function delete()
 {
     return parent::deleteRecord(DB::table('crontab'), array('cron_id' => $this->cron_id));
 }
Example #6
0
 /**
  * Deletes an existing rule
  */
 public function delete()
 {
     return parent::deleteRecord(DB::table('rewrite_rules'), array('rule_id' => $this->rule_id));
 }
Example #7
0
 /**
  * Delete this block
  *
  */
 public function delete()
 {
     // Let plugins disallow and act before we write to the database
     $allow = true;
     $allow = Plugins::filter('block_delete_allow', $allow, $this);
     if (!$allow) {
         return false;
     }
     Plugins::act('block_delete_before', $this);
     $result = parent::deleteRecord('{blocks}', array('id' => $this->id));
     EventLog::log(sprintf(_t('Block %1$s (%2$s) deleted.'), $this->id, $this->title), 'info', 'content', 'habari');
     // Let plugins act after we write to the database
     Plugins::act('block_delete_after', $this);
     return $result;
 }
Example #8
0
	/**
	 * Delete an existing term
	 */
	public function delete()
	{
		// Let plugins disallow and act before we write to the database
		$allow = true;
		$allow = Plugins::filter( 'term_delete_allow', $allow, $this );
		if ( !$allow ) {
			return false;
		}
		Plugins::act( 'term_delete_before', $this );

		// Delete all info records associated with this comment
		$this->info->delete_all();

		DB::query( 'DELETE FROM {object_terms} WHERE term_id = :id', array( 'id' => $this->id ) );

		$result = parent::deleteRecord( '{terms}', array( 'id'=>$this->id ) );
		EventLog::log( sprintf( _t( 'Term %1$s (%2$s) deleted.' ), $this->id, $this->term_display ), 'info', 'content', 'habari' );

		// Let plugins act after we write to the database
		Plugins::act( 'term_delete_after', $this );
		return $result;
	}
Example #9
0
 /**
  * Delete a user account
  */
 public function delete()
 {
     $allow = true;
     $allow = Plugins::filter('user_delete_allow', $allow, $this);
     if (!$allow) {
         return;
     }
     Plugins::act('user_delete_before', $this);
     if (isset($this->info)) {
         $this->info->delete_all();
     }
     // remove all this user's permissions
     DB::query('DELETE FROM {user_token_permissions} WHERE user_id=?', array($this->id));
     // remove user from any groups
     DB::query('DELETE FROM {users_groups} WHERE user_id=?', array($this->id));
     EventLog::log(sprintf(_t('User deleted: %s'), $this->username), 'info', 'default', 'habari');
     $result = parent::deleteRecord(DB::table('users'), array('id' => $this->id));
     Plugins::act('user_delete_after', $this);
     return $result;
 }
Example #10
0
 /**
  * Delete an existing vocabulary
  */
 public function delete()
 {
     // Let plugins disallow and act before we write to the database
     $allow = true;
     $allow = Plugins::filter('vocabulary_delete_allow', $allow, $this);
     if (!$allow) {
         return;
     }
     Plugins::act('vocabulary_delete_before', $this);
     // Get the ids for all this vocabulary's terms
     $ids = DB::get_column('SELECT id FROM {terms} WHERE vocabulary_id = ?', array($this->id));
     // Delete the records from object_terms for those ids (if there were any)
     if (count($ids)) {
         $placeholder = Utils::placeholder_string(count($ids));
         DB::query("DELETE FROM {object_terms} WHERE term_id IN ({$placeholder})", $ids);
     }
     // Delete this vocabulary's terms
     DB::delete('{terms}', array('vocabulary_id' => $this->id));
     // Finally, delete the vocabulary
     $result = parent::deleteRecord('{vocabularies}', array('id' => $this->id));
     EventLog::log(_t('Vocabulary %1$s (%2$s) deleted.', array($this->id, $this->name)), 'info', 'content', 'habari');
     // Let plugins act after we write to the database
     Plugins::act('vocabulary_delete_after', $this);
     return $result;
 }
Example #11
0
	/**
	 * function delete
	 * Deletes this logentry
	 */
	public function delete()
	{
		$allow = true;
		$allow = Plugins::filter( 'logentry_delete_allow', $allow, $this );
		if ( ! $allow ) {
			return;
		}
		Plugins::act( 'logentry_delete_before', $this );
		return parent::deleteRecord( DB::table( 'log' ), array( 'id'=>$this->id ) );
		Plugins::act( 'logentry_delete_after', $this );
	}
Example #12
0
 /**
  * function delete
  * Deletes this comment
  */
 public function delete()
 {
     return parent::deleteRecord(DB::table('link_traffic'), array('id' => $this->id));
 }
Example #13
0
 /**
  * Deletes this logentry
  */
 public function delete()
 {
     $allow = true;
     $allow = Plugins::filter('logentry_delete_allow', $allow, $this);
     $result = false;
     if ($allow) {
         Plugins::act('logentry_delete_before', $this);
         $result = parent::deleteRecord(DB::table('log'), array('id' => $this->id));
         Plugins::act('logentry_delete_after', $this);
     }
     return $result;
 }