Esempio n. 1
0
 function saveRoutingAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     $worker = CerberusApplication::getActiveWorker();
     if (!$worker || !$worker->is_superuser) {
         echo $translate->_('common.access_denied');
         return;
     }
     if (DEMO_MODE) {
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'mail')));
         return;
     }
     @($deletes = DevblocksPlatform::importGPC($_REQUEST['deletes'], 'array', array()));
     @($sticky_ids = DevblocksPlatform::importGPC($_REQUEST['sticky_ids'], 'array', array()));
     @($sticky_order = DevblocksPlatform::importGPC($_REQUEST['sticky_order'], 'array', array()));
     @($active_worker = CerberusApplication::getActiveWorker());
     if (!$active_worker->is_superuser) {
         return;
     }
     // Deletes
     if (!empty($deletes)) {
         DAO_MailToGroupRule::delete($deletes);
     }
     // Reordering
     if (is_array($sticky_ids) && is_array($sticky_order)) {
         foreach ($sticky_ids as $idx => $id) {
             @($order = intval($sticky_order[$idx]));
             DAO_MailToGroupRule::update($id, array(DAO_MailToGroupRule::STICKY_ORDER => $order));
         }
     }
     // Default group
     @($default_group_id = DevblocksPlatform::importGPC($_REQUEST['default_group_id'], 'integer', '0'));
     DAO_Group::setDefaultGroup($default_group_id);
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'parser')));
 }
Esempio n. 2
0
 function saveRoutingAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     $worker = CerberusApplication::getActiveWorker();
     if (!$worker || !$worker->is_superuser) {
         echo $translate->_('common.access_denied');
         return;
     }
     if (DEMO_MODE) {
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'mail')));
         return;
     }
     @($positions = DevblocksPlatform::importGPC($_POST['positions'], 'array'));
     @($route_ids = DevblocksPlatform::importGPC($_POST['route_ids'], 'array'));
     @($route_team_id = DevblocksPlatform::importGPC($_POST['route_team_id'], 'array'));
     @($route_pattern = DevblocksPlatform::importGPC($_POST['route_pattern'], 'array'));
     @($default_team_id = DevblocksPlatform::importGPC($_POST['default_team_id'], 'integer', 0));
     @($add_pattern = DevblocksPlatform::importGPC($_POST['add_pattern'], 'array'));
     @($add_team_id = DevblocksPlatform::importGPC($_POST['add_team_id'], 'array'));
     @($route_remove = DevblocksPlatform::importGPC($_POST['route_remove'], 'array'));
     // Rule reordering
     if (is_array($route_ids) && is_array($positions)) {
         foreach ($route_ids as $idx => $route_id) {
             $pos = $positions[$idx];
             $pattern = $route_pattern[$idx];
             $team_id = $route_team_id[$idx];
             if (empty($pattern)) {
                 $route_remove[] = $route_id;
                 continue;
             }
             $fields = array(DAO_Mail::ROUTING_POS => $pos, DAO_Mail::ROUTING_PATTERN => $pattern, DAO_Mail::ROUTING_TEAM_ID => $team_id);
             DAO_Mail::updateMailboxRouting($route_id, $fields);
         }
     }
     // Add rules
     if (is_array($add_pattern)) {
         foreach ($add_pattern as $k => $v) {
             if (empty($v)) {
                 continue;
             }
             $team_id = $add_team_id[$k];
             $fields = array(DAO_Mail::ROUTING_PATTERN => $v, DAO_Mail::ROUTING_TEAM_ID => $team_id);
             $route_id = DAO_Mail::createMailboxRouting($fields);
         }
     }
     // Removals
     if (is_array($route_remove)) {
         foreach ($route_remove as $remove_id) {
             DAO_Mail::deleteMailboxRouting($remove_id);
         }
     }
     // Default team
     DAO_Group::setDefaultGroup($default_team_id);
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'parser')));
 }