/** * Returns Mailbox which is associated with object * * @param void * @return IncomingMailbox */ function getMailbox() { if ($this->mailbox === null) { $this->mailbox = IncomingMailboxes::findById($this->getMailboxId()); } // if return $this->mailbox; }
/** * Construct incoming mail administration controller * * @param Request $request * @return IncomingMailAdminController */ function __construct($request) { parent::__construct($request); require_once ANGIE_PATH . '/classes/mailboxmanager/init.php'; if (!extension_loaded('imap')) { $this->wireframe->addPageMessage(lang('<b>IMAP extension not installed</b> - IMAP extension is required for activeCollab to be able to connect to POP3/IMAP servers'), PAGE_MESSAGE_ERROR); } // if $mailbox_id = $this->request->getId('mailbox_id'); if ($mailbox_id) { $this->active_mailbox = IncomingMailboxes::findById($mailbox_id); } // if if (!instance_of($this->active_mailbox, 'IncomingMailbox')) { $this->active_mailbox = new IncomingMailbox(); } // if $this->smarty->assign(array('active_mailbox' => $this->active_mailbox, 'add_new_mailbox_url' => assemble_url('incoming_mail_admin_add_mailbox'))); $this->wireframe->addBreadCrumb(lang('Incoming Mail'), assemble_url('incoming_mail_admin')); $this->wireframe->addPageAction(lang('New Mailbox'), assemble_url('incoming_mail_admin_add_mailbox')); }
/** * Use $incoming_mail as a base for creating ProjectObject * * @param IncomingMail $incoming_mail * @return integer */ function importPendingEmail(&$incoming_mail, $skip_permission_checking = false, $is_report = false) { $mailbox = IncomingMailboxes::findById($incoming_mail->getIncomingMailboxId()); if ($is_report) { $incoming_mail->setState(INCOMING_MAIL_STATUS_REPORT_EMAIL); $incoming_mail->save(); return new Error(incoming_mail_module_get_status_description(INCOMING_MAIL_STATUS_REPORT_EMAIL)); } // if $project = $incoming_mail->getProject(); if (!instance_of($project, 'Project')) { // project does not exists $incoming_mail->setState(INCOMING_MAIL_STATUS_PROJECT_DOES_NOT_EXISTS); $incoming_mail_save = $incoming_mail->save(); return new Error(incoming_mail_module_get_status_description(INCOMING_MAIL_STATUS_PROJECT_DOES_NOT_EXISTS)); } // if $user = $incoming_mail->getCreatedBy(); if (!$skip_permission_checking) { // check additional permissions if (instance_of($user, 'User')) { // if it's registered user // if object type is not comment and all users cannot create objects and current user cant create object if ($incoming_mail->getObjectType() != 'comment' && !$mailbox->getAcceptAllRegistered() && !ProjectObject::canAdd($user, $project, $incoming_mail->getObjectType())) { $incoming_mail->setState(INCOMING_MAIL_STATUS_USER_CANNOT_CREATE_OBJECT); $incoming_mail_save = $incoming_mail->save(); return new Error(incoming_mail_module_get_status_description(INCOMING_MAIL_STATUS_USER_CANNOT_CREATE_OBJECT)); } // if } else { // if it's anonymous user // if mailbox does not accept anonymous users if (!$mailbox->getAcceptAnonymous()) { $incoming_mail->setState(INCOMING_MAIL_STATUS_ANONYMOUS_NOT_ALLOWED); $incoming_mail_save = $incoming_mail->save(); return new Error(incoming_mail_module_get_status_description(INCOMING_MAIL_STATUS_ANONYMOUS_NOT_ALLOWED)); } // if } // if } // if // create new object instance dependable of object type switch ($incoming_mail->getObjectType()) { case 'discussion': $import =& IncomingMailImporter::importPendingEmailAsDiscussion($incoming_mail, $project, $user); break; case 'ticket': $import =& IncomingMailImporter::importPendingEmailAsTicket($incoming_mail, $project, $user); break; case 'comment': //$pos = strpos($incoming_mail->getSubject(), '{ID'); //if ($pos!==false){ $parent_id = $incoming_mail->getParentId(); if (!empty($parent_id)) { $import =& IncomingMailImporter::importPendingEmailAsComment($incoming_mail, $project, $user, $mailbox); } else { $import =& IncomingMailImporter::importPendingEmailAsTicket($incoming_mail, $project, $user); } break; //BOF:mod 20120809 //BOF:mod 20120809 case 'task': //BOF:mod 20120820 /* //EOF:mod 20120820 $import = & IncomingMailImporter::importPendingEmailToTaskList($incoming_mail, $project, $user); //BOF:mod 20120820 */ $page_id = IncomingMailImporter::getPageId($incoming_mail, $project, $user); $attachments = $incoming_mail->getAttachments(); $comment = null; if (strpos($incoming_mail->getSubject(), '}') !== false || strlen(strip_tags($incoming_mail->getBody())) > 150 || count($attachments)) { $import =& IncomingMailImporter::importPendingEmailAsComment($incoming_mail, $project, $user, $mailbox, $page_id); } else { $import =& IncomingMailImporter::importPendingEmailToTaskList($incoming_mail, $project, $user, $page_id, null); } //BOF:mod 20120820 break; //EOF:mod 20120809 } // switch return $import; }