function doAddWorkspaceAction() { @($name = DevblocksPlatform::importGPC($_REQUEST['name'], 'string', '')); @($source = DevblocksPlatform::importGPC($_REQUEST['source'], 'string', '')); @($workspace = DevblocksPlatform::importGPC($_REQUEST['workspace'], 'string', '')); @($new_workspace = DevblocksPlatform::importGPC($_REQUEST['new_workspace'], 'string', '')); $active_worker = CerberusApplication::getActiveWorker(); $visit = CerberusApplication::getVisit(); // Source extension exists if (null != ($source_manifest = DevblocksPlatform::getExtension($source, false))) { // Class exists if (null != @($class = $source_manifest->params['view_class'])) { if (empty($name)) { $name = $source_manifest->name; } // New workspace if (!empty($new_workspace)) { $workspace = $new_workspace; } if (empty($workspace)) { $workspace = 'New Workspace'; } $view = new $class(); /* @var $view C4_AbstractView */ // Build the list model $list = new Model_WorkerWorkspaceListView(); $list->title = $name; $list->columns = $view->view_columns; $list->params = $view->params; $list->num_rows = 5; // Add the worklist $fields = array(DAO_WorkerWorkspaceList::WORKER_ID => $active_worker->id, DAO_WorkerWorkspaceList::LIST_POS => 1, DAO_WorkerWorkspaceList::LIST_VIEW => serialize($list), DAO_WorkerWorkspaceList::WORKSPACE => $workspace, DAO_WorkerWorkspaceList::SOURCE_EXTENSION => $source_manifest->id); DAO_WorkerWorkspaceList::create($fields); // Select the new tab $visit->set(CerberusVisit::KEY_HOME_SELECTED_TAB, 'w_' . $workspace); } } DevblocksPlatform::redirect(new DevblocksHttpResponse(array('home'))); }
function viewDoCopyAction() { $translate = DevblocksPlatform::getTranslationService(); $active_worker = CerberusApplication::getActiveWorker(); $visit = CerberusApplication::getVisit(); @($view_id = DevblocksPlatform::importGPC($_POST['view_id'], 'string')); $view = C4_AbstractViewLoader::getView($view_id); @($list_title = DevblocksPlatform::importGPC($_POST['list_title'], 'string', '')); @($workspace = DevblocksPlatform::importGPC($_POST['workspace'], 'string', '')); @($new_workspace = DevblocksPlatform::importGPC($_POST['new_workspace'], 'string', '')); if (empty($workspace) && empty($new_workspace)) { $new_workspace = $translate->_('mail.workspaces.new'); } if (empty($list_title)) { $list_title = $translate->_('mail.workspaces.new_list'); } $workspace_name = !empty($new_workspace) ? $new_workspace : $workspace; // Find the proper workspace source based on the class of the view $source_manifests = DevblocksPlatform::getExtensions(Extension_WorkspaceSource::EXTENSION_POINT, false); $source_manifest = null; if (is_array($source_manifests)) { foreach ($source_manifests as $mft) { if (is_a($view, $mft->params['view_class'])) { $source_manifest = $mft; break; } } } if (!is_null($source_manifest)) { // View params inside the list for quick render overload $list_view = new Model_WorkerWorkspaceListView(); $list_view->title = $list_title; $list_view->num_rows = $view->renderLimit; $list_view->columns = $view->view_columns; $list_view->params = $view->params; $list_view->sort_by = $view->renderSortBy; $list_view->sort_asc = $view->renderSortAsc; // Save the new worklist $fields = array(DAO_WorkerWorkspaceList::WORKER_ID => $active_worker->id, DAO_WorkerWorkspaceList::WORKSPACE => $workspace_name, DAO_WorkerWorkspaceList::SOURCE_EXTENSION => $source_manifest->id, DAO_WorkerWorkspaceList::LIST_VIEW => serialize($list_view), DAO_WorkerWorkspaceList::LIST_POS => 99); $list_id = DAO_WorkerWorkspaceList::create($fields); } // Select the workspace tab $visit->set(CerberusVisit::KEY_HOME_SELECTED_TAB, 'w_' . $workspace_name); DevblocksPlatform::redirect(new DevblocksHttpResponse(array('home'))); }