示例#1
0
文件: view.php 项目: nemein/openpsa
 /**
  * Day view
  *
  * @param String $handler_id    Name of the request handler
  * @param array $args           Variable arguments
  * @param array &$data          Public request data, passed by reference
  */
 public function _handler_day($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     $this->_generate_date($args);
     // Instantiate calendar widget
     $this->_calendar = new org_openpsa_widgets_calendar(date('Y', $this->_selected_time), date('m', $this->_selected_time), date('d', $this->_selected_time));
     $this->_calendar->type = org_openpsa_widgets_calendar::DAY;
     // Slots are 2 hours long
     $this->_calendar->calendar_slot_length = $this->_config->get('day_slot_length') * 60;
     $this->_calendar->start_hour = $this->_config->get('day_start_time');
     $this->_calendar->end_hour = $this->_config->get('day_end_time');
     $this->_calendar->column_width = 60;
     $this->_populate_toolbar('day');
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'month/' . $this->_get_datestring() . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('month view'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/properties.png'));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'week/' . $this->_get_datestring() . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('week view'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/properties.png'));
     // Clicking a free slot should bring up 'new event' dialogue
     $nap = new midcom_helper_nav();
     $this_node = $nap->get_node($nap->get_current_node());
     if ($this->_root_event->can_do('midgard:create')) {
         $this->_calendar->reservation_div_options = array('onclick' => org_openpsa_calendar_interface::calendar_editevent_js('__GUID__', $this_node));
     }
     $this->_calendar->free_div_options = array('onclick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node, '__START__', '__RESOURCE__'));
     // Populate contacts
     $this->_populate_calendar_contacts($this->_calendar->get_day_start(), $this->_calendar->get_day_end());
     $this->_request_data['calendar'] =& $this->_calendar;
     // Set the breadcrumb
     $this->add_breadcrumb('year/' . date('Y-01-01', $this->_selected_time) . '/', strftime('%Y', $this->_selected_time));
     $this->add_breadcrumb('month/' . date('Y-m-01', $this->_selected_time) . '/', strftime('%B', $this->_selected_time));
     $this->add_breadcrumb('day/' . date('Y-m-d', $this->_selected_time) . '/', strftime('%x', $this->_selected_time));
     midcom::get('head')->set_pagetitle(strftime("%x", $this->_selected_time));
 }
示例#2
0
 public static function create_root_event()
 {
     midcom::get('auth')->request_sudo();
     $event = new midcom_db_event();
     $event->up = 0;
     $event->title = '__org_openpsa_calendar';
     //Fill in dummy dates to get around date range error
     $event->start = time();
     $event->end = time() + 1;
     $ret = $event->create();
     midcom::get('auth')->drop_sudo();
     if (!$ret) {
         debug_add('Failed to create OpenPSA root event, reason ' . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
         throw new midcom_error('Failed to create the root event');
     }
     $siteconfig = org_openpsa_core_siteconfig::get_instance();
     $topic_guid = $siteconfig->get_node_guid('org.openpsa.calendar');
     if ($topic_guid) {
         $topic = new midcom_db_topic($topic_guid);
         $topic->set_parameter('org.openpsa.calendar', 'calendar_root_event', $event->guid);
     }
     return $event;
 }
示例#3
0
 public function testHandler_new_event()
 {
     midcom::get('auth')->request_sudo('org.openpsa.calendar');
     $data = $this->run_handler('org.openpsa.calendar', array('event', 'new'));
     $this->assertEquals('new_event', $data['handler_id']);
     $title = __CLASS__ . '::' . __FUNCTION__ . microtime();
     $formdata = array('title' => $title, 'start_date' => '2009-10-11', 'start_hours' => '10', 'start_minutes' => '15', 'end_date' => '2009-10-11', 'end_hours' => '14', 'end_minutes' => '15');
     $this->set_dm2_formdata($data['controller'], $formdata);
     $data = $this->run_handler('org.openpsa.calendar', array('event', 'new'));
     $this->assertEquals(array(), $data['controller']->formmanager->form->_errors, 'Form validation failed');
     $this->assertEquals('new_event', $data['handler_id']);
     $qb = midcom_db_event::new_query_builder();
     $qb->add_constraint('title', '=', $title);
     $results = $qb->execute();
     $this->register_objects($results);
     $this->assertEquals(1, sizeof($results));
     $this->assertEquals('2009-10-11 10:15:01', date('Y-m-d h:i:s', $results[0]->start));
     midcom::get('auth')->drop_sudo();
 }