/**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return MessageSubscriptions 
  */
 function manager()
 {
     if (!$this->manager instanceof MessageSubscriptions) {
         $this->manager = MessageSubscriptions::instance();
     }
     return $this->manager;
 }
Beispiel #2
0
 /**
 * Delete this object
 *
 * @param void
 * @return boolean
 */
 function delete() {
   if ($this->isAccountOwner()) {
     return false;
   } // if
   
   ProjectUsers::clearByUser($this);
   MessageSubscriptions::clearByUser($this);
   return parent::delete();
 } // delete
 /**
  * Clear all message subscriptions
  *
  * @param void
  * @return boolean
  */
 function clearSubscriptions()
 {
     return MessageSubscriptions::clearByMessage($this);
 }
 /**
  * Delete this object
  *
  * @param void
  * @return boolean
  */
 function delete()
 {
     if ($this->isAccountOwner()) {
         return false;
     }
     // if
     if ($this->isTaggable()) {
         $this->clearTags();
     }
     // if
     // TODO check all things that need to be deleted
     // ticket subscriptions
     // message subscriptions
     // project-user association
     $this->deleteAvatar();
     $this->clearImValues();
     if ($this->hasUserAccount()) {
         ProjectUsers::clearByUser($this->getUserAccount());
         MessageSubscriptions::clearByUser($this->getUserAccount());
         $this->getUserAccount()->delete();
     }
     // if
     return parent::delete();
 }
 /**
  * This function will return paginated result. Result is an array where first element is 
  * array of returned object and second populated pagination object that can be used for 
  * obtaining and rendering pagination data using various helpers.
  * 
  * Items and pagination array vars are indexed with 0 for items and 1 for pagination
  * because you can't use associative indexing with list() construct
  *
  * @access public
  * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
  * @param integer $items_per_page Number of items per page
  * @param integer $current_page Current page number
  * @return array
  */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
 {
     if (isset($this) && instance_of($this, 'MessageSubscriptions')) {
         return parent::paginate($arguments, $items_per_page, $current_page);
     } else {
         return MessageSubscriptions::instance()->paginate($arguments, $items_per_page, $current_page);
         //$instance =& MessageSubscriptions::instance();
         //return $instance->paginate($arguments, $items_per_page, $current_page);
     }
     // if
 }
 /**
  * Clear subscriptions by user
  *
  * @param User $user
  * @return boolean
  */
 static function clearByUser(User $user)
 {
     return MessageSubscriptions::delete('`user_id` = ' . DB::escape($user->getId()));
 }