Example #1
0
 /**
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_frontpage($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'project/new/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("create project"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/new-dir.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_projects_project')));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'task/new/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("create task"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/new_task.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_projects_task_dba')));
     // List current projects, sort by customer
     $data['customers'] = array();
     $project_qb = org_openpsa_projects_project::new_query_builder();
     $project_qb->add_constraint('status', '<', org_openpsa_projects_task_status_dba::CLOSED);
     $project_qb->add_order('customer.official');
     $project_qb->add_order('end');
     $projects = $project_qb->execute();
     foreach ($projects as $project) {
         if (!isset($data['customers'][$project->customer])) {
             $data['customers'][$project->customer] = array();
         }
         $data['customers'][$project->customer][] = $project;
     }
     // Projects without customer have to be queried separately, see #97
     $nocustomer_qb = org_openpsa_projects_project::new_query_builder();
     $nocustomer_qb->add_constraint('status', '<', org_openpsa_projects_task_status_dba::CLOSED);
     $nocustomer_qb->add_constraint('customer', '=', 0);
     $nocustomer_qb->add_order('end');
     if ($nocustomer_qb->count() > 0) {
         $data['customers'][0] = $nocustomer_qb->execute();
     }
     $closed_qb = org_openpsa_projects_project::new_query_builder();
     $closed_qb->add_constraint('status', '=', org_openpsa_projects_task_status_dba::CLOSED);
     $data['closed_count'] = $closed_qb->count();
     $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.core/list.css");
     midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/org.openpsa.projects/frontpage.js');
     midcom::get('head')->set_pagetitle($this->_l10n->get('current projects'));
 }
Example #2
0
 public function testCRUD()
 {
     midcom::get('auth')->request_sudo('org.openpsa.projects');
     $project = new org_openpsa_projects_project();
     $stat = $project->create();
     $this->assertTrue($stat);
     $this->register_object($project);
     $project->refresh();
     $this->assertEquals('Project #' . $project->id, $project->title);
     $project->title = 'Test Project';
     $stat = $project->update();
     $this->assertTrue($stat);
     $this->assertEquals('Test Project', $project->title);
     $stat = $project->delete();
     $this->assertTrue($stat);
     midcom::get('auth')->drop_sudo();
 }
Example #3
0
 /**
  * Helper function for listing tasks user can see
  */
 static function projects($add_all = false)
 {
     //Only query once per request
     static $cache = null;
     if (is_null($cache)) {
         $cache = array();
         if ($add_all) {
             //TODO: Localization
             $cache['all'] = 'all';
         }
         $qb = org_openpsa_projects_project::new_query_builder();
         $qb->add_order('title');
         $ret = $qb->execute();
         if (count($ret) > 0) {
             foreach ($ret as $task) {
                 $cache[$task->guid] = $task->title;
             }
         }
     }
     return $cache;
 }
Example #4
0
 /**
  * This is what Datamanager calls to actually create a project
  */
 function &dm2_create_callback(&$controller)
 {
     $project = new org_openpsa_projects_project();
     if (!$project->create()) {
         debug_print_r('We operated on this object:', $project);
         throw new midcom_error("Failed to create a new project. Error: " . midcom_connection::get_error_string());
     }
     $this->_object = new org_openpsa_projects_project($project->id);
     return $this->_object;
 }
Example #5
0
 /**
  * Prepare the indexer client
  */
 public function _on_reindex($topic, $config, &$indexer)
 {
     $qb_tasks = org_openpsa_projects_task_dba::new_query_builder();
     $schemadb_tasks = midcom_helper_datamanager2_schema::load_database($config->get('schemadb_task'));
     $qb_projects = org_openpsa_projects_project::new_query_builder();
     $schemadb_projects = midcom_helper_datamanager2_schema::load_database($config->get('schemadb_project'));
     $indexer = new org_openpsa_projects_midcom_indexer($topic, $indexer);
     $indexer->add_query('tasks', $qb_tasks, $schemadb_tasks);
     $indexer->add_query('projects', $qb_projects, $schemadb_projects);
     return $indexer;
 }
Example #6
0
 private function _list_all_projects()
 {
     // List *all* projects
     $this->_request_data['project_list_results']['all'] = array();
     $qb = org_openpsa_projects_project::new_query_builder();
     $ret = $qb->execute();
     if (count($ret) > 0) {
         foreach ($ret as $project) {
             $this->_request_data['project_list_results']['all'][$project->guid] = $project;
         }
     }
 }