/** * Returns true if the current user can delete the event $event. * * @param TimeIt_Model_EventDate $eventDate Event. * * @return boolean */ public static function canDeleteEvent(TimeIt_Model_EventDate $eventDate) { $event = $eventDate['Event']; // get group names if ($event['group'] == 'all') { $groupName = array('all'); // group irrelevant } else { $groupNames = array(); foreach (explode(',', $event['group']) as $grpId) { $groupObj = UserUtil::getPNGroup((int) $grpId); $groupNames[] = $groupObj['name']; } $groupName = $groupNames; } // get calendar $calendar = $eventDate['Calendar']; // check permissions if (!SecurityUtil::checkPermission('TimeIt::', '::', ACCESS_DELETE)) { if (!SecurityUtil::checkPermission('TimeIt:Calendar:', $calendar['id'] . '::', ACCESS_DELETE)) { $access = false; foreach ($groupName as $name) { if (SecurityUtil::checkPermission('TimeIt:Group:', $name . '::', ACCESS_DELETE)) { $access = true; } } if (!$access) { if ($calendar != null && $calendar['userCanEditHisEvents'] && $event['cr_uid'] == UserUtil::getVar('uid')) { return true; } else { return false; } } } } return true; }
/** * 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; }