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 = PortSensorApplication::getActiveWorker();
     $visit = PortSensorApplication::getVisit();
     $worklists = DAO_Worklist::getWhere(sprintf("%s = %s", DAO_Worklist::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_Worklist::delete($id);
                 Ps_AbstractViewLoader::deleteView('cust_' . $id);
                 // free up a little memory
             } else {
                 if (!isset($worklists[$id])) {
                     continue;
                 }
                 $list_view = $worklists[$id]->view;
                 // 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 = Ps_AbstractViewLoader::getView('cust_' . $id);
                     $view->name = $list_view->title;
                     Ps_AbstractViewLoader::setView('cust_' . $id, $view);
                 }
                 DAO_Worklist::update($id, array(DAO_Worklist::VIEW_POS => @intval($pos[$idx]), DAO_Worklist::VIEW_SERIALIZED => serialize($list_view)));
             }
         }
     }
     // Rename workspace
     if (!empty($rename_workspace)) {
         $fields = array(DAO_Worklist::WORKSPACE => $rename_workspace);
         DAO_Worklist::updateWhere($fields, sprintf("%s = %s AND %s = %d", DAO_Worklist::WORKSPACE, $db->qstr($workspace), DAO_Worklist::WORKER_ID, $active_worker->id));
         $workspace = $rename_workspace;
     }
     // Change active tab
     $visit->set(PortSensorVisit::KEY_HOME_SELECTED_TAB, 'w_' . $workspace);
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('home')));
 }