Ejemplo n.º 1
0
 public static function initialize_search()
 {
     $defaults = array('autocomplete' => false);
     $providers = array();
     $siteconfig = org_openpsa_core_siteconfig::get_instance();
     $configured_providers = self::get_config_value('search_providers');
     $user_id = false;
     if (!midcom::get('auth')->admin) {
         $user_id = midcom::get('auth')->acl->get_user_id();
     }
     foreach ($configured_providers as $component => $config) {
         if (!is_array($config)) {
             $config = array('route' => $config);
         }
         $config = array_merge($defaults, $config);
         if ($config['autocomplete'] === true) {
             midcom_helper_datamanager2_widget_autocomplete::add_head_elements();
         }
         $node_url = $siteconfig->get_node_full_url($component);
         if ($node_url && (!$user_id || midcom::get('auth')->acl->can_do_byguid('midgard:read', $siteconfig->get_node_guid($component), 'midcom_db_topic', $user_id))) {
             $providers[] = array('helptext' => midcom::get('i18n')->get_string('search title', $component), 'url' => $node_url . $config['route'], 'identifier' => $component, 'autocomplete' => $config['autocomplete']);
         }
     }
     midcom::get('head')->add_jquery_state_script('org_openpsa_layout.initialize_search
     (
         ' . json_encode($providers) . ',
         "' . midgard_admin_asgard_plugin::get_preference('openpsa2_search_provider') . '"
     );');
 }
Ejemplo n.º 2
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_today($handler_id, array $args, array &$data)
 {
     $this->user = midcom::get('auth')->user->get_storage();
     if ($handler_id == 'today') {
         $data['requested_time'] = date('Y-m-d');
     } else {
         // TODO: Check format as YYYY-MM-DD via regexp
         $data['requested_time'] = $args[0];
     }
     $this->_master->calculate_day($data['requested_time']);
     $this->_populate_toolbar();
     $data['title'] = strftime($data['requested_time']);
     midcom::get('head')->set_pagetitle($data['title']);
     // Add the JS file for workingon widget
     midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . "/jQuery/jquery.epiclock.min.js");
     midcom_helper_datamanager2_widget_autocomplete::add_head_elements();
     midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . "/org.openpsa.mypage/mypage.js");
     $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.mypage/mypage.css");
     $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.core/list.css");
     //needed js/css-files for jqgrid
     org_openpsa_widgets_grid::add_head_elements();
     //set the start-constraints for journal-entries
     $time_span = 7 * 24 * 60 * 60;
     //7 days
     $this->_request_data['journal_constraints'] = array(array('property' => 'metadata.creator', 'operator' => '=', 'value' => midcom::get('auth')->user->guid), array('property' => 'followUp', 'operator' => '<', 'value' => $this->_request_data['day_start'] + $time_span), array('property' => 'followUp', 'operator' => '>', 'value' => 0), array('property' => 'closed', 'operator' => '=', 'value' => false));
 }
Ejemplo n.º 3
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_list($handler_id, array $args, array &$data)
 {
     midcom::get()->skip_page_style = true;
     if ($handler_id == 'mycontacts_xml') {
         midcom::get('auth')->require_valid_user('basic');
         midcom::get('cache')->content->content_type("text/xml; charset=UTF-8");
         midcom::get()->header("Content-type: text/xml; charset=UTF-8");
     } else {
         midcom::get('auth')->require_valid_user();
         $data['widget_config'] = midcom_helper_datamanager2_widget_autocomplete::get_widget_config('contact');
         $data['widget_config']['id_field'] = 'guid';
     }
     $mycontacts = new org_openpsa_contacts_mycontacts();
     $data['mycontacts'] = $mycontacts->list_members();
 }
Ejemplo n.º 4
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_view($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     // Set the "now working on" status
     $data['workingon'] = new org_openpsa_mypage_workingon();
     midcom::get()->skip_page_style = true;
     $task_conf = midcom_helper_datamanager2_widget_autocomplete::get_widget_config('task');
     $task_conf['id_field'] = 'guid';
     $task_conf['constraints'][] = array('field' => 'status', 'op' => '<', 'value' => org_openpsa_projects_task_status_dba::COMPLETED);
     $data['widget_config'] = $task_conf;
     // List work hours this week
     $siteconfig = org_openpsa_core_siteconfig::get_instance();
     $data['expenses_url'] = $siteconfig->get_node_full_url('org.openpsa.expenses');
     $data['requested_time'] = date('Y-m-d');
     $this->_master->calculate_day($data['requested_time']);
     $this->_list_work_hours();
 }
Ejemplo n.º 5
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();
     midcom_helper_datamanager2_widget_autocomplete::add_head_elements();
     $data['tree'] = $this->_master->get_group_tree();
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'person/create/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create person'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_person-new.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_contacts_person_dba')));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'group/create/organization/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create organization'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_people-new.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_contacts_group_dba')));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'group/create/group/', MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get('group')), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_people-new.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_contacts_group_dba')));
     $p_merger = new org_openpsa_contacts_duplicates_merge('person');
     if ($p_merger->merge_needed()) {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'duplicates/person/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('merge persons'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/repair.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard:update', null, 'org_openpsa_contacts_person_dba')));
     }
     if ($this->_topic->can_do('midgard:update') && $this->_topic->can_do('midcom:component_config')) {
         $this->_node_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'config/', MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('component configuration'), MIDCOM_TOOLBAR_HELPTEXT => $this->_l10n_midcom->get('component configuration helptext'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_folder-properties.png'));
     }
     midcom::get('head')->set_pagetitle($this->_l10n->get("my contacts"));
 }
Ejemplo n.º 6
0
 /**
  * Special helper for adding the supported operations from read into the toolbar.
  *
  * @param mixed $handler_id The ID of the handler.
  */
 private function _populate_read_toolbar($handler_id)
 {
     if (!$this->_object->can_do('midgard:update')) {
         return;
     }
     if ($this->_object->status == org_openpsa_projects_task_status_dba::CLOSED) {
         // TODO: Make POST request
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "task/{$this->_object->guid}/reopen/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('reopen'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/folder-expanded.png'));
     } else {
         if ($this->_object->status_type == 'ongoing') {
             // TODO: Make POST request
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "task/{$this->_object->guid}/complete/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('mark completed'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/new_task.png'));
         }
     }
     $siteconfig = org_openpsa_core_siteconfig::get_instance();
     $expenses_url = $siteconfig->get_node_full_url('org.openpsa.expenses');
     if ($expenses_url) {
         midcom_helper_datamanager2_widget_autocomplete::add_head_elements();
         org_openpsa_widgets_grid::add_head_elements();
         if ($this->_object->status < org_openpsa_projects_task_status_dba::CLOSED) {
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $expenses_url . "hours/create/hour_report/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get('hour report')), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_new-event.png'));
         }
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $expenses_url . "hours/task/all/{$this->_object->guid}", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('hour reports'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/scheduled_and_shown.png', MIDCOM_TOOLBAR_ACCESSKEY => 'h'));
     }
     org_openpsa_relatedto_plugin::add_button($this->_view_toolbar, $this->_object->guid);
 }
Ejemplo n.º 7
0
 public function get_results()
 {
     $qb = $this->_prepare_qb();
     $results = $qb->execute();
     if ($results === false || !is_array($results)) {
         throw new midcom_error('Error when executing QB');
     }
     $items = array();
     foreach ($results as $object) {
         $item = array('id' => $object->{$this->_request['id_field']}, 'label' => midcom_helper_datamanager2_widget_autocomplete::create_item_label($object, $this->_request['result_headers'], $this->_request['get_label_for']));
         if (!empty($this->_request['categorize_by_parent_label'])) {
             $item['category'] = '';
             if ($parent = $object->get_parent()) {
                 $item['category'] = $parent->get_label();
             }
         }
         $item['value'] = $item['label'];
         $items[] = $item;
     }
     usort($items, array('midcom_helper_datamanager2_widget_autocomplete', 'sort_items'));
     return $items;
 }
Ejemplo n.º 8
0
 /**
  * Set options array for JS, to show the right choosers
  */
 private function _prepare_batch_options()
 {
     $task_conf = midcom_helper_datamanager2_widget_autocomplete::get_widget_config('task');
     //Make sure we have the needed constants
     midcom::get('componentloader')->load('org.openpsa.projects');
     $task_conf['constraints'][] = array('field' => 'orgOpenpsaObtype', 'op' => '=', 'value' => ORG_OPENPSA_OBTYPE_TASK);
     $invoice_conf = midcom_helper_datamanager2_widget_autocomplete::get_widget_config('invoice');
     $options = array('none' => array('label' => midcom::get('i18n')->get_string("choose action", "midcom.admin.user")), 'change_task' => array('label' => $this->_l10n->get('change_task'), 'widget_config' => $task_conf), 'change_invoice' => array('label' => $this->_l10n->get('change_invoice'), 'widget_config' => $invoice_conf));
     return $options;
 }