コード例 #1
0
ファイル: config.php プロジェクト: Hildy/cerb5
 function saveTeamAction()
 {
     $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', 'workflow')));
         return;
     }
     @($id = DevblocksPlatform::importGPC($_POST['id']));
     @($name = DevblocksPlatform::importGPC($_POST['name']));
     @($delete = DevblocksPlatform::importGPC($_POST['delete_box']));
     @($delete_move_id = DevblocksPlatform::importGPC($_POST['delete_move_id'], 'integer', 0));
     if (empty($name)) {
         $name = "No Name";
     }
     if (!empty($id) && !empty($delete)) {
         if (!empty($delete_move_id)) {
             $fields = array(DAO_Ticket::TEAM_ID => $delete_move_id);
             $where = sprintf("%s=%d", DAO_Ticket::TEAM_ID, $id);
             DAO_Ticket::updateWhere($fields, $where);
             DAO_Group::deleteTeam($id);
         }
     } elseif (!empty($id)) {
         $fields = array(DAO_Group::TEAM_NAME => $name);
         DAO_Group::updateTeam($id, $fields);
     } else {
         $fields = array(DAO_Group::TEAM_NAME => $name);
         $id = DAO_Group::createTeam($fields);
     }
     @($worker_ids = DevblocksPlatform::importGPC($_POST['worker_ids'], 'array', array()));
     @($worker_levels = DevblocksPlatform::importGPC($_POST['worker_levels'], 'array', array()));
     @($members = DAO_Group::getTeamMembers($id));
     if (is_array($worker_ids) && !empty($worker_ids)) {
         foreach ($worker_ids as $idx => $worker_id) {
             @($level = $worker_levels[$idx]);
             if (isset($members[$worker_id]) && empty($level)) {
                 DAO_Group::unsetTeamMember($id, $worker_id);
             } elseif (!empty($level)) {
                 // member|manager
                 DAO_Group::setTeamMember($id, $worker_id, 1 == $level ? false : true);
             }
         }
     }
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'groups')));
 }