/** * Gets the owner mail account * @return MailAccount */ function getAccount() { if (is_null($this->account)) { $this->account = MailAccounts::instance()->getAccountById($this->getAccountId()); } //if return $this->account; }
function getAccountById($account_id) { if(isset($this) && instance_of($this, 'MailAccounts')) { if (!isset($this->accounts_cache[$account_id])) { $this->accounts_cache[$account_id] = $this->findById($account_id); } return array_var($this->accounts_cache, $account_id); } else { return MailAccounts::instance()->getAccountById($account_id); } }
function mail_on_page_load() { //check if have outbox mails $usu = logged_user(); $accounts = MailAccounts::instance()->getMailAccountsByUser($usu); $account_ids = array(); foreach ($accounts as $acc) { $account_ids[] = $acc->getId(); } if (count($account_ids) == 0) { return; } $accounts_sql = " AND account_id IN (" . implode(',', $account_ids) . ")"; $user_pg_ids = $usu->getPermissionGroupIds(); if (count($user_pg_ids) == 0) { return; } $permissions_sql = " AND EXISTS (SELECT sh.group_id FROM " . TABLE_PREFIX . "sharing_table sh WHERE sh.object_id=o.id AND sh.group_id IN (" . implode(',', $user_pg_ids) . "))"; $conditions = array("conditions" => array("`state` >= 200 AND (`state`%2 = 0) AND `archived_on`=0 AND `trashed_on`=0 {$accounts_sql} {$permissions_sql} AND `created_by_id` =" . $usu->getId())); $outbox_mails = MailContents::findAll($conditions); if ($outbox_mails != null) { if (count($outbox_mails) >= 1) { $arguments = array("conditions" => array("`context` LIKE 'mails_in_outbox%' AND `contact_id` = " . $usu->getId() . ";")); $exist_reminder = ObjectReminders::find($arguments); if (!(count($exist_reminder) > 0)) { $reminder = new ObjectReminder(); $minutes = 0; $reminder->setMinutesBefore($minutes); $reminder->setType("reminder_popup"); $reminder->setContext("mails_in_outbox " . count($outbox_mails)); $reminder->setObject($usu); $reminder->setUserId($usu->getId()); $reminder->setDate(DateTimeValueLib::now()); $reminder->save(); } } } }
/** * Return manager instance * * @access protected * @param void * @return MailAccounts */ function manager() { if (!$this->manager instanceof MailAccounts) { $this->manager = MailAccounts::instance(); } return $this->manager; }
/** * Return manager instance * * @access protected * @param void * @return MailAccounts */ function manager() { if(!($this->manager instanceof MailAccounts)) $this->manager = MailAccounts::instance(); return $this->manager; } // manager
/** * 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, 'MailAccounts')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return MailAccounts::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& MailAccounts::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }