Exemple #1
0
 /**
  * Enter description here...
  *
  * @param array $headers
  * @return array (group_id,address)
  */
 private static function findDestination($headers)
 {
     static $routing = null;
     $settings = CerberusSettings::getInstance();
     // [TODO] Should this cache be at the class level?
     if (is_null($routing)) {
         $routing = DAO_Mail::getMailboxRouting();
     }
     $destinations = self::getDestinations($headers);
     if (is_array($destinations)) {
         foreach ($destinations as $address) {
             // Test each pattern successively
             foreach ($routing as $route) {
                 /* @var $route Model_MailRoute */
                 $pattern = sprintf("/^%s\$/i", str_replace(array('*', '+'), array('.*?', '\\+'), $route->pattern));
                 if (preg_match($pattern, $address)) {
                     return array($route->team_id, $address);
                 }
             }
         }
     }
     // Check if we have a default mailbox configured before returning NULL.
     if (null != ($default_team = DAO_Group::getDefaultGroup())) {
         return array($default_team->id, '');
     }
     return null;
     // bounce
 }
Exemple #2
0
 function ajaxGetRoutingAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     $worker = CerberusApplication::getActiveWorker();
     if (!$worker || !$worker->is_superuser) {
         echo $translate->_('common.access_denied');
         return;
     }
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->cache_lifetime = "0";
     $tpl->assign('path', $this->_TPL_PATH);
     $routing = DAO_Mail::getMailboxRouting();
     $tpl->assign('routing', $routing);
     $teams = DAO_Group::getAll();
     $tpl->assign('teams', $teams);
     $tpl->display('file:' . $this->_TPL_PATH . 'configuration/tabs/mail/mail_routing.tpl');
 }