예제 #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;
 }