Exemplo n.º 1
0
 function doEditWorkspaceAction()
 {
     @($workspace = DevblocksPlatform::importGPC($_POST['workspace'], 'string', ''));
     @($rename_workspace = DevblocksPlatform::importGPC($_POST['rename_workspace'], 'string', ''));
     @($ids = DevblocksPlatform::importGPC($_POST['ids'], 'array', array()));
     @($names = DevblocksPlatform::importGPC($_POST['names'], 'array', array()));
     @($pos = DevblocksPlatform::importGPC($_POST['pos'], 'array', array()));
     @($deletes = DevblocksPlatform::importGPC($_POST['deletes'], 'array', array()));
     $db = DevblocksPlatform::getDatabaseService();
     $active_worker = CerberusApplication::getActiveWorker();
     $visit = CerberusApplication::getVisit();
     $worklists = DAO_WorkerWorkspaceList::getWhere(sprintf("%s = %s", DAO_WorkerWorkspaceList::WORKSPACE, $db->qstr($workspace)));
     // Reorder worklists, rename lists, delete lists, on workspace
     if (is_array($ids) && !empty($ids)) {
         foreach ($ids as $idx => $id) {
             if (false !== array_search($id, $deletes)) {
                 DAO_WorkerWorkspaceList::delete($id);
                 C4_AbstractViewLoader::deleteView('cust_' . $id);
                 // free up a little memory
             } else {
                 if (!isset($worklists[$id])) {
                     continue;
                 }
                 $list_view = $worklists[$id]->list_view;
                 /* @var $list_view Model_WorkerWorkspaceListView */
                 // If the name changed
                 if (isset($names[$idx]) && 0 != strcmp($list_view->title, $names[$idx])) {
                     $list_view->title = $names[$idx];
                     // Save the view in the session
                     $view = C4_AbstractViewLoader::getView('', 'cust_' . $id);
                     $view->name = $list_view->title;
                     C4_AbstractViewLoader::setView('cust_' . $id, $view);
                 }
                 DAO_WorkerWorkspaceList::update($id, array(DAO_WorkerWorkspaceList::LIST_POS => @intval($pos[$idx]), DAO_WorkerWorkspaceList::LIST_VIEW => serialize($list_view)));
             }
         }
     }
     // Rename workspace
     if (!empty($rename_workspace)) {
         $fields = array(DAO_WorkerWorkspaceList::WORKSPACE => $rename_workspace);
         DAO_WorkerWorkspaceList::updateWhere($fields, sprintf("%s = %s AND %s = %d", DAO_WorkerWorkspaceList::WORKSPACE, $db->qstr($workspace), DAO_WorkerWorkspaceList::WORKER_ID, $active_worker->id));
         $workspace = $rename_workspace;
     }
     // Change active tab
     $visit->set(CerberusVisit::KEY_HOME_SELECTED_TAB, 'w_' . $workspace);
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('home')));
 }