public function updateWithPIVars(&$piVars) { $modelObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'modelController'); $cObj =& $this->controller->cObj; $startDateIsSet = false; $endDateIsSet = false; $customFieldArray = array(); if ($this->conf['view'] == 'create_event' || $this->conf['view'] == 'edit_event') { $customFieldArray = GeneralUtility::trimExplode(',', $this->conf['rights.'][$this->conf['view'] == 'create_event' ? 'create.' : 'edit.']['event.']['additionalFields'], 1); } else { if ($this->conf['view'] == 'confirm_event') { if ($this->row['uid'] > 0) { $customFieldArray = GeneralUtility::trimExplode(',', $this->conf['rights.']['edit.']['event.']['additionalFields'], 1); } else { $customFieldArray = GeneralUtility::trimExplode(',', $this->conf['rights.']['create.']['event.']['additionalFields'], 1); } } } if ($piVars['formCheck'] == '1') { $this->setAllday(false); } foreach ($piVars as $key => $value) { switch ($key) { case 'hidden': $this->setHidden($value); unset($piVars['hidden']); break; case 'calendar_id': $this->setCalendarUid(intval($piVars['calendar_id'])); unset($piVars['calendar_id']); break; case 'category': case 'category_ids': $this->setCategories(array()); $categories = array(); $confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cal']); $categoryService =& $modelObj->getServiceObjByKey('cal_category_model', 'category', $confArr['categoryService']); $categoryService->getCategoryArray($this->conf['pidList'], $categories); $piVarsCaregoryArray = explode(',', \TYPO3\CMS\Cal\Controller\Controller::convertLinkVarArrayToList($piVars[$key])); if (!empty($piVarsCaregoryArray)) { foreach ($piVarsCaregoryArray as $categoryId) { $this->addCategory($categories[0][0][$categoryId]); } } unset($piVars['category']); unset($piVars['category_ids']); break; case 'allday_checkbox': case 'allday': if (intval($piVars[$key]) == 1) { $this->setAllday(true); } else { if (strlen($piVars[$key]) > 0) { $this->setAllday(false); } } break; case 'start_date': case 'start_time': $start = new \TYPO3\CMS\Cal\Model\CalDate($piVars['start_date'] . '000000'); $start->addSeconds($piVars['start_time']); $this->setStart($start); unset($piVars['start_date']); unset($piVars['start_time']); break; case 'startdate': case 'starttime': case 'startminutes': $start = new \TYPO3\CMS\Cal\Model\CalDate(\TYPO3\CMS\Cal\Utility\Functions::getYmdFromDateString($this->conf, strip_tags($piVars['startdate'] ? $piVars['startdate'] : $piVars['getdate'])) . '000000'); if (strlen($piVars['starttime']) == 4) { $tempArray = array(); preg_match('/([0-9]{2})([0-9]{2})/', $piVars['starttime'], $tempArray); $start->setHour(intval($tempArray[1])); $start->setMinute(intval($tempArray[2])); } else { $start->setHour(intval($piVars['starttime'])); $start->setMinute(intval($piVars['startminutes'])); } $start->setSecond(0); $start->setTZbyId('UTC'); $this->setStart($start); unset($piVars['startdate']); unset($piVars['starttime']); unset($piVars['startminutes']); $startDateIsSet = true; break; case 'end_date': case 'end_time': $end = new \TYPO3\CMS\Cal\Model\CalDate($piVars['end_date'] . '000000'); $end->addSeconds($piVars['end_time']); $this->setEnd($end); unset($piVars['end_date']); unset($piVars['end_time']); break; case 'enddate': case 'endtime': case 'endminutes': $end = new \TYPO3\CMS\Cal\Model\CalDate(\TYPO3\CMS\Cal\Utility\Functions::getYmdFromDateString($this->conf, strip_tags($piVars['enddate'] ? $piVars['enddate'] : $piVars['getdate'])) . '000000'); if (strlen($piVars['endtime']) == 4) { $tempArray = array(); preg_match('/([0-9]{2})([0-9]{2})/', $piVars['endtime'], $tempArray); $end->setHour(intval($tempArray[1])); $end->setMinute(intval($tempArray[2])); } else { $end->setHour(intval($piVars['endtime'])); $end->setMinute(intval($piVars['endminutes'])); } $end->setSecond(0); $end->setTzById('UTC'); $this->setEnd($end); unset($piVars['enddate']); unset($piVars['endtime']); unset($piVars['endminutes']); $endDateIsSet = true; break; case 'organizer': $this->setOrganizer(strip_tags($piVars['organizer'])); unset($piVars['organizer']); break; case 'location': $this->setLocation(strip_tags($piVars['location'])); unset($piVars['location']); break; case 'cal_organizer': $this->setOrganizerId(intval($piVars['cal_organizer'])); unset($piVars['cal_organizer']); break; case 'cal_location': $this->setLocationId(intval($piVars['cal_location'])); unset($piVars['cal_location']); break; case 'title': $this->setTitle(strip_tags($piVars['title'])); unset($piVars['title']); break; case 'description': $this->setDescription($cObj->removeBadHTML($piVars['description'], array())); unset($piVars['description']); unset($piVars['_TRANSFORM_description']); break; case 'teaser': $this->setTeaser($cObj->removeBadHTML($piVars['teaser'], array())); unset($piVars['teaser']); break; case 'image': if (is_array($piVars['image'])) { foreach ($piVars['image'] as $image) { $this->addImage(strip_tags($image)); } } break; case 'attachment': $this->setAttachment(array()); if (is_array($piVars['attachment'])) { foreach ($piVars['attachment'] as $attachment) { $this->addAttachment(strip_tags($attachment)); } } break; case 'frequency_id': $valueArray = array('none', 'day', 'week', 'month', 'year'); $this->setFreq(in_array($piVars['frequency_id'], $valueArray) ? $piVars['frequency_id'] : 'none'); unset($piVars['frequency_id']); break; case 'by_day': if (is_array($piVars['by_day'])) { $this->setByDay(strtolower(strip_tags(implode(',', $piVars['by_day'])))); } else { $this->setByDay(strtolower(strip_tags($piVars['by_day']))); } unset($piVars['by_day']); break; case 'by_monthday': $this->setByMonthDay(strtolower(strip_tags($piVars['by_monthday']))); unset($piVars['by_monthday']); break; case 'by_month': $this->setByMonth(strtolower(strip_tags($piVars['by_month']))); unset($piVars['by_month']); break; case 'until': if ($piVars['until'] != 0) { $until = new \TYPO3\CMS\Cal\Model\CalDate(\TYPO3\CMS\Cal\Utility\Functions::getYmdFromDateString($this->conf, strip_tags($piVars['until'])) . '000000'); } else { $until = new \TYPO3\CMS\Cal\Model\CalDate('00000000000000'); } $until->setTzById('UTC'); $this->setUntil($until); unset($piVars['until']); break; case 'count': $this->setCount(intval($piVars['count'])); unset($piVars['count']); break; case 'interval': $this->setInterval(intval($piVars['interval'])); unset($piVars['interval']); break; case 'rdate': $this->setRdate(strtolower(strip_tags($piVars['rdate']))); unset($piVars['rdate']); break; case 'rdate_type': $this->setRdateType(strtolower(strip_tags($piVars['rdate_type']))); unset($piVars['rdate_type']); break; case 'exception_ids': $this->setExceptionSingleIds(array()); $this->setExceptionGroupIds(array()); foreach (GeneralUtility::trimExplode(',', $piVars['exception_ids'], 1) as $valueInner) { preg_match('/(^[a-z])_([0-9]+)/', $valueInner, $idname); if ($idname[1] == 'u') { $this->addExceptionSingleId($idname[2]); } else { if ($idname[1] == 'g') { $this->addExceptionGroupId($idname[2]); } } } break; case 'shared': case 'shared_ids': $this->setSharedGroups(array()); $this->setSharedUsers(array()); $values = $piVars[$key]; if (!is_array($piVars[$key])) { $values = GeneralUtility::trimExplode(',', $piVars[$key], 1); } foreach ($values as $entry) { preg_match('/(^[a-z])_([0-9]+)/', $entry, $idname); if ($idname[1] == 'u') { $this->addSharedUser($idname[2]); } else { if ($idname[1] == 'g') { $this->addSharedGroup($idname[2]); } } } break; case 'event_type': $this->setEventType(intval($piVars['event_type'])); unset($piVars['event_type']); break; case 'attendee': $attendeeIndex = array(); $attendeeServices = $this->getAttendees(); $emptyAttendeeArray = array(); $this->setAttendees($emptyAttendeeArray); $attendeeServiceKeys = array_keys($attendeeServices); foreach ($attendeeServiceKeys as $serviceKey) { $attendeeKeys = array_keys($attendeeServices[$serviceKey]); foreach ($attendeeKeys as $attendeeKey) { $attendeeIndex[$serviceKey . '_' . ($attendeeServices[$serviceKey][$attendeeKey]->getFeUserId() ? $attendeeServices[$serviceKey][$attendeeKey]->getFeUserId() : $attendeeServices[$serviceKey][$attendeeKey]->getEmail())] =& $attendeeServices[$serviceKey][$attendeeKey]; } } $servKey = 'tx_cal_attendee'; $newAttendeeArray = array($servKey => array()); $values = $piVars[$key]; if (!is_array($piVars[$key])) { $values = GeneralUtility::trimExplode(',', $piVars[$key], 1); } $attendance = $piVars['attendance']; if (!is_array($piVars['attendance'])) { $attendanceTemp = GeneralUtility::trimExplode(',', $piVars['attendance'], 1); $attendance = array(); $i = 0; foreach ($values as $entry) { $attendance[$entry] = $attendanceTemp[$i]; $i++; } } foreach ($values as $entry) { preg_match('/(^[emailu]+)_([^*]+)/', $entry, $idname); if (is_object($attendeeIndex[$serviceKey . '_' . $idname[2]])) { // Attendee has been already assigned -> updating attendance $attendeeIndex[$serviceKey . '_' . $idname[2]]->setAttendance($attendance[$entry]); $this->addAttendee($attendeeIndex[$serviceKey . '_' . $idname[2]]); } else { $initRow = array(); $attendee = new \TYPO3\CMS\Cal\Model\AttendeeModel($initRow, 'cal_attendee_model'); if ($idname[1] == 'u') { $attendee->setFeUserId($idname[2]); $attendee->setAttendance($attendance[$entry]); } else { if ($idname[1] == 'email') { $attendee->setEmail($idname[2]); $attendee->setAttendance('OPT-PARTICIPANT'); } } $this->addAttendee($attendee); } } foreach (GeneralUtility::trimExplode(',', $piVars['attendee_external'], 1) as $emailAddress) { if (is_object($attendeeIndex[$serviceKey . '_' . $emailAddress])) { // Attendee has been already assigned -> updating attendance $attendeeIndex[$serviceKey . '_' . $emailAddress]->setAttendance($attendance[$entry]); $this->addAttendee($attendeeIndex[$serviceKey . '_' . $emailAddress]); } else { $initRow = array(); $attendee = new \TYPO3\CMS\Cal\Model\AttendeeModel($initRow, 'cal_attendee_model'); $attendee->setEmail($emailAddress); $attendee->setAttendance('OPT-PARTICIPANT'); $this->addAttendee($attendee); } } unset($piVars['attendee']); unset($piVars['attendance']); break; case 'sendout_invitation': $this->setSendoutInvitation($piVars['sendout_invitation'] == 1); unset($piVars['sendout_invitation']); break; default: if (in_array($key, $customFieldArray)) { $this->row[$key] = $value; } } } if ($this->getEventType() != \TYPO3\CMS\Cal\Model\Model::EVENT_TYPE_MEETING) { $newAttendeeArray = array(); $this->setAttendees($newAttendeeArray); } if ($this->conf['rights.']['create.']['event.']['fields.']['dynamicStarttimeOffset']) { $now = new \TYPO3\CMS\Cal\Model\CalDate(); $now->addSeconds(intval($this->conf['rights.']['create.']['event.']['fields.']['dynamicStarttimeOffset'])); if (is_object($start)) { $start->setHour($now->getHour()); $start->setMinute($now->getMinute()); $this->setStart($start); } } if (!$startDateIsSet && $piVars['mygetdate']) { $startDay = strip_tags($piVars['mygetdate']); $startHour = '00'; $startMinutes = '00'; if ($piVars['gettime']) { $startHour = substr(strip_tags($piVars['gettime']), 0, 2); $startMinutes = substr(strip_tags($piVars['gettime']), 2, 2); } $start = new \TYPO3\CMS\Cal\Model\CalDate($startDay . ' ' . $startHour . ':' . $startMinutes . ':00'); $start->setTzById('UTC'); $this->setStart($start); } if (!$endDateIsSet && $piVars['mygetdate']) { $end = new \TYPO3\CMS\Cal\Model\CalDate(); $end->copy($start); $end->addSeconds($this->conf['view.']['event.']['event.']['defaultEventLength']); $this->setEnd($end); } }
/** * * @return string|unknown */ public function searchAll() { $type = $this->conf['type']; $pidList = $this->conf['pidList']; $hookObjectsArr = $this->getHookObjectsArray('drawSearchAllClass'); if (intval($this->piVars['start_day']) == 0) { $starttime = $this->getListViewTime($this->conf['view.']['search.']['defaultValues.']['start_day']); } else { $starttime = new \TYPO3\CMS\Cal\Model\CalDate(intval($this->piVars['start_day']) . '000000'); } if (intval($this->piVars['end_day']) == 0) { $endtime = $this->getListViewTime($this->conf['view.']['search.']['defaultValues.']['end_day']); } else { $endtime = new \TYPO3\CMS\Cal\Model\CalDate(intval($this->piVars['end_day']) . '000000'); } $searchword = strip_tags($this->piVars['query']); if ($searchword == '') { $searchword = $this->cObj->stdWrap($this->conf['view.']['search.']['defaultValues.']['query'], $this->conf['view.']['search.']['event.']['defaultValues.']['query.']); } $endtime->addSeconds(86399); /* Get the boundaries for allowed search dates */ $minStarttime = new \TYPO3\CMS\Cal\Model\CalDate(intval($this->conf['view.']['search.']['startRange']) . '000000'); $maxEndtime = new \TYPO3\CMS\Cal\Model\CalDate(intval($this->conf['view.']['search.']['endRange']) . '000000'); /* Check starttime against boundaries */ if ($starttime->before($minStarttime)) { $starttime->copy($minStarttime); } if ($starttime->after($maxEndtime)) { $starttime->copy($maxEndtime); } /* Check endtime against boundaries */ if ($endtime->before($minStarttime)) { $endtime->copy($minStarttime); } if ($endtime->after($maxEndtime)) { $endtime->copy($maxEndtime); } /* Check endtime against starttime */ if ($endtime->before($starttime)) { $endtime->copy($starttime); } $locationIds = strip_tags(Controller::convertLinkVarArrayToList($this->piVars['location_ids'])); $organizerIds = strip_tags(Controller::convertLinkVarArrayToList($this->piVars['organizer_ids'])); $modelObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'modelcontroller'); $list = array(); if ($this->piVars['query'] && ($this->piVars['submit'] || !$this->conf['view.']['search.']['startSearchAfterSubmit'])) { $list['phpicalendar_event'] = $modelObj->searchEvents($type, $pidList, $starttime, $endtime, $searchword, $locationIds, $organizerIds); $list['location'] = $modelObj->searchLocation($type, $pidList, $searchword); $list['organizer'] = $modelObj->searchOrganizer($type, $pidList, $searchword); } // Hook: preSearchAllRendering if (is_array($hookObjectsArr)) { foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'preSearchAllRendering')) { $hookObj->preSearchAllRendering($list, $this); } } } if ($this->conf['view.']['enableAjax']) { $ajaxStringArray = array(); foreach ($list as $location) { $ajaxStringArray[] = '{' . $this->getEventAjaxString($location) . '}'; } return '[' . implode(',', $ajaxStringArray) . ']'; } $viewObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'viewcontroller'); $drawnList = $viewObj->drawSearchAllResult($list, $starttime, $endtime, $searchword, $locationIds, $organizerIds); // Hook: postSearchAllRendering if (is_array($hookObjectsArr)) { foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'postSearchAllRendering')) { $hookObj->postSearchAllRendering($drawnList, $list, $this); } } } return $drawnList; }