Ejemplo 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')));
 }
Ejemplo n.º 2
0
 function viewSaveCustomizeAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     @($id = DevblocksPlatform::importGPC($_REQUEST['id']));
     @($columns = DevblocksPlatform::importGPC($_REQUEST['columns'], 'array', array()));
     @($num_rows = DevblocksPlatform::importGPC($_REQUEST['num_rows'], 'integer', 10));
     $num_rows = max($num_rows, 1);
     // make 1 the minimum
     $view = Ps_AbstractViewLoader::getView($id);
     $view->doCustomize($columns, $num_rows);
     $active_worker = PortSensorApplication::getActiveWorker();
     // Conditional Persist
     if (substr($id, 0, 5) == "cust_") {
         // custom workspace
         $list_view_id = intval(substr($id, 5));
         // Special custom view fields
         @($title = DevblocksPlatform::importGPC($_REQUEST['title'], 'string', $translate->_('views.new_list')));
         $view->name = $title;
         // Persist Object
         $list_view = new Model_WorklistView();
         $list_view->title = $title;
         $list_view->columns = $view->view_columns;
         $list_view->num_rows = $view->renderLimit;
         $list_view->params = $view->params;
         $list_view->sort_by = $view->renderSortBy;
         $list_view->sort_asc = $view->renderSortAsc;
         DAO_Worklist::update($list_view_id, array(DAO_Worklist::VIEW_SERIALIZED => serialize($list_view)));
     } else {
         $prefs = new Ps_AbstractViewModel();
         $prefs->class_name = get_class($view);
         $prefs->view_columns = $view->view_columns;
         $prefs->renderLimit = $view->renderLimit;
         $prefs->renderSortBy = $view->renderSortBy;
         $prefs->renderSortAsc = $view->renderSortAsc;
         DAO_WorkerPref::set($active_worker->id, 'view' . $view->id, serialize($prefs));
     }
     Ps_AbstractViewLoader::setView($id, $view);
     $view->render();
 }