Example #1
0
 /**
  * Formats an event.
  *
  * @param array $args Event.
  *
  * @return array
  * @throws InvalidArgumentException In case of invalid parameters.
  */
 function getEventPreformat($args)
 {
     if (!isset($args['obj']) || empty($args['obj'])) {
         throw new InvalidArgumentException('$obj arg not set');
     }
     $obj =& $args['obj'];
     //process text format
     if (substr($obj['text'], 0, 11) == "#plaintext#") {
         $obj['text'] = substr_replace($obj['text'], "", 0, 11);
         $obj['text'] = nl2br($obj['text']);
     }
     // hooks
     if (!isset($args['noHooks']) || $args['noHooks'] == false) {
         $obj['text'] = ModUtil::callHooks('item', 'transform', '', array($obj['text']));
         $obj['text'] = $obj['text'][0];
     }
     // repeats
     if ($obj['repeatType'] == 2) {
         $temp = explode(' ', $obj['repeatSpec']);
         $obj['repeat21'] = $temp[0];
         $obj['repeat22'] = $temp[1];
     }
     // split duration
     $obj['allDayDur'] = explode(',', $obj['allDayDur']);
     TimeIt_Util::convertAlldayStartToLocalTime($obj);
     // set username
     $obj['cr_name'] = UserUtil::getVar('uname', (int) $obj['cr_uid']);
     $obj['cr_datetime'] = DateUtil::getDatetime(strtotime($obj['cr_date']), "datetimebrief");
     // set group name
     if ($obj['group'] == 'all') {
         $obj['group_name'] = 'all';
     } else {
         $groupNames = array();
         foreach (explode(',', $obj['group']) as $grpId) {
             $groupObj = UserUtil::getPNGroup((int) $grpId);
             $groupNames[] = $groupObj['name'];
         }
         $obj['group_name'] = $groupNames;
     }
     return $obj;
 }
Example #2
0
 /**
  * Displays all available events.
  *
  * @return string HTML Code
  */
 public function view()
 {
     // check object type
     $objectType = FormUtil::getPassedValue('ot', 'event', 'GET');
     $this->throwNotFoundUnless(in_array($objectType, TimeIt_Util::getObjectTypes('view')), $this->__f('Unkown object type %s.', DataUtil::formatForDisplay($objectType)));
     // load filter
     $filter = TimeIt_Filter_Container::getFilterFormGETPOST($objectType);
     $this->view->assign('modvars', ModUtil::getVar('TimeIt'));
     // vars
     $tpl = null;
     $theme = null;
     $domain = $this->serviceManager->getService('timeit.manager.' . $objectType);
     // load the data
     if ($objectType == 'event') {
         $calendarId = (int) FormUtil::getPassedValue('cid', ModUtil::getVar('TimeIt', 'defaultCalendar'), 'GETPOST');
         $calendar = $this->serviceManager->getService('timeit.manager.calendar')->getObject($calendarId);
         $this->throwNotFoundIf(empty($calendar), $this->__f('Calendar [%s] not found.', $calendarId));
         $year = (int) FormUtil::getPassedValue('year', date("Y"), 'GETPOST');
         $month = (int) FormUtil::getPassedValue('month', date("n"), 'GETPOST');
         $day = (int) FormUtil::getPassedValue('day', date("j"), 'GETPOST');
         $tpl = FormUtil::getPassedValue('viewType', FormUtil::getPassedValue('viewtype', $calendar['config']['defaultView'], 'GETPOST'), 'GETPOST');
         $firstDayOfWeek = (int) FormUtil::getPassedValue('firstDayOfWeek', -1, 'GETPOST');
         $theme = FormUtil::getPassedValue('template', $calendar['config']['defaultTemplate'], 'GETPOST');
         // backward compatibility
         if ($theme == 'default') {
             $theme = 'table';
         }
         // check for a valid $tpl
         if ($tpl != 'year' && $tpl != 'month' && $tpl != 'week' && $tpl != 'day') {
             $tpl = $calendar['config']['defaultView'];
         }
         $tpl = 'month';
         $theme = 'table';
         $this->view->assign('template', $theme);
         $this->view->assign('viewed_day', $day);
         $this->view->assign('viewed_month', $month);
         $this->view->assign('viewed_year', $year);
         $this->view->assign('viewType', $tpl);
         $this->view->assign('calendar', $calendar);
         $this->view->assign('viewed_date', DateUtil::getDatetime(mktime(0, 0, 0, $month, $day, $year), DATEONLYFORMAT_FIXED));
         $this->view->assign('date_today', DateUtil::getDatetime(null, DATEONLYFORMAT_FIXED));
         $this->view->assign('month_startDate', DateUtil::getDatetime(mktime(0, 0, 0, $month, 1, $year), DATEONLYFORMAT_FIXED));
         $this->view->assign('month_endDate', DateUtil::getDatetime(mktime(0, 0, 0, $month, DateUtil::getDaysInMonth($month, $year), $year), DATEONLYFORMAT_FIXED));
         $this->view->assign('filter_obj_url', $filter->toURL());
         $this->view->assign('firstDayOfWeek', $firstDayOfWeek);
         $this->view->assign('selectedCats', array());
         $categories = CategoryRegistryUtil::getRegisteredModuleCategories('TimeIt', 'TimeIt_events');
         foreach ($categories as $property => $cid) {
             $cat = CategoryUtil::getCategoryByID($cid);
             if (isset($cat['__ATTRIBUTES__']['calendarid']) && !empty($cat['__ATTRIBUTES__']['calendarid'])) {
                 if ($cat['__ATTRIBUTES__']['calendarid'] != $calendar['id']) {
                     unset($categories[$property]);
                 }
             }
         }
         $this->view->assign('categories', $categories);
         // load event data
         switch ($tpl) {
             case 'year':
                 $objectData = $domain->getYearEvents($year, $calendar['id'], $firstDayOfWeek);
                 break;
             case 'month':
                 $objectData = $domain->getMonthEvents($year, $month, $day, $calendar['id'], $firstDayOfWeek, $filter);
                 break;
             case 'week':
                 $objectData = $domain->getWeekEvents($year, $month, $day, $calendar['id'], $filter);
                 break;
             case 'day':
                 $objectData = $domain->getDayEvents($year, $month, $day, $calendar['id'], $filter);
                 break;
         }
     }
     // assign the data
     $this->view->assign('objectArray', $objectData);
     // render the html
     return $this->_renderTemplate($this->view, $objectType, 'user', 'view', $theme, $tpl, 'table');
 }