Example #1
0
 /**
  *
  */
 public function parseResource()
 {
     $configuration = $this->getConfiguration();
     if (!ExtensionManagementUtility::isLoaded('phpexcel_library')) {
         throw new \Exception('phpexcel_library is not loaded', 12367812368);
     }
     $filename = GeneralUtility::getFileAbsFileName($this->filepath);
     GeneralUtility::makeInstanceService('phpexcel');
     $objReader = \PHPExcel_IOFactory::createReaderForFile($filename);
     $objReader->setReadDataOnly(true);
     $objPHPExcel = $objReader->load($filename);
     if ($configuration['sheet'] >= 0) {
         $objWorksheet = $objPHPExcel->getSheet($configuration['sheet']);
     } else {
         $objWorksheet = $objPHPExcel->getActiveSheet();
     }
     $highestRow = $objWorksheet->getHighestRow();
     $highestColumn = $objWorksheet->getHighestColumn();
     $highestColumnIndex = \PHPExcel_Cell::columnIndexFromString($highestColumn);
     for ($row = 1 + $configuration['skipRows']; $row <= $highestRow; ++$row) {
         $rowRecord = [];
         for ($col = 0; $col <= $highestColumnIndex; ++$col) {
             $rowRecord[] = trim($objWorksheet->getCellByColumnAndRow($col, $row)->getValue());
         }
         $this->content[] = $rowRecord;
     }
 }
Example #2
0
 /**
  * Example:
  * require_once ('class.tx_cal_api.php');
  * $calAPI = new Api($this->cObj, &$conf);
  * $event = $calAPI->findEvent('2','tx_cal_phpicalendar');
  */
 function tx_cal_api_with(&$cObj, &$conf)
 {
     $this->cObj =& $cObj;
     $this->conf =& $conf;
     if (!$GLOBALS['TCA']) {
         $GLOBALS['TSFE']->includeTCA();
     }
     $this->conf['useInternalCaching'] = 1;
     $this->conf['cachingEngine'] = 'cachingFramework';
     $this->conf['writeCachingInfoToDevlog'] = 0;
     $GLOBALS['TSFE']->settingLocale();
     $this->controller = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\Controller');
     $this->controller->cObj =& $this->cObj;
     $this->controller->conf =& $this->conf;
     $this->controller->setWeekStartDay();
     $this->controller->cleanPiVarParam($this->piVars);
     $this->controller->clearPiVarParams();
     $this->controller->getParamsFromSession();
     $this->controller->initCaching();
     $this->controller->initConfigs();
     \TYPO3\CMS\Cal\Controller\Controller::initRegistry($this->controller);
     $this->rightsObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'rightscontroller');
     $this->rightsObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService('cal_rights_model', 'rights');
     $this->rightsObj->setDefaultSaveToPage();
     $this->modelObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'modelcontroller');
     $this->modelObj = new \TYPO3\CMS\Cal\Controller\ModelController();
     $this->viewObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'viewcontroller');
     $this->viewObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\ViewController');
     /*
      * $this->rightsObj = &\TYPO3\CMS\Cal\Utility\Registry::Registry('basic','rightscontroller'); $this->modelObj = &\TYPO3\CMS\Cal\Utility\Registry::Registry('basic','modelcontroller'); $this->viewObj = &\TYPO3\CMS\Cal\Utility\Registry::Registry('basic','viewcontroller');
      */
     return $this;
 }
Example #3
0
 public static function &getEventService()
 {
     $key = 'tx_cal_phpicalendar';
     $serviceChain = '';
     /* Loop over all services providign the specified service type and subtype */
     while (is_object($eventService = GeneralUtility::makeInstanceService('cal_event_model', 'event', $serviceChain))) {
         $serviceChain .= ',' . $eventService->getServiceKey();
         /* If the key of the current service matches what we're looking for, return the object */
         if ($key == $eventService->getServiceKey()) {
             return $eventService;
         }
     }
 }
 /**
  * General initialization
  * 
  * @see \TYPO3\CMS\Extbase\Mvc\Controller\ActionController::initializeAction()
  */
 public function initializeAction()
 {
     // Instanciating the lucene index service
     /* @var $indexerService \Tollwerk\TwLucenesearch\Service\Lucene */
     try {
         $this->_indexService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService('index', 'lucene');
         // Else: if no index exists ...
     } catch (\Exception $e) {
         $this->_indexException = $e;
     }
     $this->_pageUid = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'));
     $config = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
     $indexer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tollwerk\\TwLucenesearch\\Utility\\Indexer');
     $this->_pageConfig = $indexer::indexConfigTS($config['config.']);
 }
Example #5
0
    function remind(&$event, $eventMonitor)
    {
        $this->startMailer();
        switch ($eventMonitor['tablenames']) {
            case 'fe_users':
                $feUserRec = BackendUtility::getRecord('fe_users', $eventMonitor['uid_foreign']);
                $this->process($event, $feUserRec['email'], $eventMonitor['tablenames'] . '_' . $feUserRec['uid']);
                break;
            case 'fe_groups':
                $subType = 'getGroupsFE';
                $groups = array();
                $serviceObj = null;
                $serviceObj = GeneralUtility::makeInstanceService('auth', $subType);
                if ($serviceObj == null) {
                    return;
                }
                $serviceObj->getSubGroups($eventMonitor['uid_foreign'], '', $groups);
                $select = 'DISTINCT fe_users.email';
                $table = 'fe_groups, fe_users';
                $where = 'fe_groups.uid IN (' . implode(',', $groups) . ') 
						AND FIND_IN_SET(fe_groups.uid, fe_users.usergroup)
						AND fe_users.email != \'\' 
						AND fe_groups.deleted = 0 
						AND fe_groups.hidden = 0 
						AND fe_users.disable = 0
						AND fe_users.deleted = 0';
                $result2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where);
                while ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result2)) {
                    $this->process($event, $row2['email'], $eventMonitor['tablenames'] . '_' . $row2['uid']);
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($result2);
                break;
            case 'tx_cal_unknown_users':
                $feUserRec = BackendUtility::getRecord('tx_cal_unknown_users', $eventMonitor['uid_foreign']);
                $this->process($event, $feUserRec['email'], $eventMonitor['tablenames'] . '_' . $feUserRec['uid']);
                break;
        }
    }
 /**
  * Looks up the latitude and longitude of a specified address. Cache tables
  * are searched first, followed by external service lookups.
  *
  * @param	string		The street address.
  * @param	string		The city name.
  * @param	string		The state name.
  * @param	string		This ZIP code.
  * @param	string		The country name.
  * @param	string		The optional API key to use in the lookup.
  * @param	boolean		Force a new lookup for address.
  * @return	array		Lat/long array for specified address.  Null if lookup fails.
  */
 static function lookupWithCallback($street, $city, $state, $zip, $country, $key = '', $forceLookup = false, &$pObj)
 {
     /* Do some basic normalization on the address */
     self::normalizeAddress($street, $city, $state, $zip, $country);
     /* If we have enough address information, try to geocode. If not, return null. */
     if (self::isEmptyAddress($street, $city, $state, $zip, $country)) {
         $latlong = null;
     } else {
         /* Look up the address in the cache table. */
         $latlong = self::find($street, $city, $state, $zip, $country);
         /* Didn't find a cached match */
         if (is_null($latlong)) {
             /* Intiate service chain to find lat/long */
             $serviceChain = '';
             while (is_object($lookupObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService('geocode', '', $serviceChain))) {
                 $serviceChain .= ',' . $lookupObj->getServiceKey();
                 $latlong = $lookupObj->lookup($street, $city, $state, $zip, $country, $key);
                 if (method_exists($pObj, 'callback_lookupThroughGeocodeService')) {
                     $pObj->callback_lookupThroughGeocodeService();
                 }
                 /* If we found a match, quit. Otherwise proceed to next best service */
                 if ($latlong) {
                     break;
                 }
             }
             /* Insert the lat/long into the cache.  */
             self::insert($street, $city, $state, $zip, $country, $latlong['lat'], $latlong['long']);
             $latlong['lat'] = trim($latlong['lat'], '0');
             $latlong['long'] = trim($latlong['long'], '0');
         }
         /* Return the lat/long, either from cache table for from fresh lookup */
         if ($latlong['lat'] == 0 and $latlong['long'] == 0) {
             $latlong = null;
         }
     }
     return $latlong;
 }
 /**
  * @test
  */
 public function detectsSwedishLanguage()
 {
     $service = GeneralUtility::makeInstanceService('textLang');
     $service->setInputFile($this->testDocumentsPath . 'sv.test', 'txt');
     $service->process();
     $language = $service->getOutput();
     $this->assertEquals('sv', $language);
 }
Example #8
0
 /**
  * Draws the month view
  *  @param		$page	string		The page template
  *  @param		$offset	integer		The month offset. Default = +0
  *  @param		$type	integer		The date of the event
  *	@return		string		The HTML output.
  */
 function _draw_month($page, $offset = '+0', $type)
 {
     $viewTarget = $this->conf['view.']['monthLinkTarget'];
     $monthTemplate = $this->cObj->getSubpart($page, '###MONTH_TEMPLATE###');
     if ($monthTemplate != '') {
         $loop_wd = $this->cObj->getSubpart($monthTemplate, '###LOOPWEEKDAY###');
         $t_month = $this->cObj->getSubpart($monthTemplate, '###SWITCHMONTHDAY###');
         $startweek = $this->cObj->getSubpart($monthTemplate, '###LOOPMONTHWEEKS_DAYS###');
         $endweek = $this->cObj->getSubpart($monthTemplate, '###LOOPMONTHDAYS_WEEKS###');
         $weeknum = $this->cObj->getSubpart($monthTemplate, '###LOOPWEEK_NUMS###');
         $corner = $this->cObj->getSubpart($monthTemplate, '###CORNER###');
         /* 11.12.2008 Franz:
          * why is there a limitation that only MEDIUM calendar sheets can have absolute offsets and vice versa?
          * I'm commenting this out and make it more flexible.
          */
         #if ($type != 'medium') {  // old one
         if (preg_match('![+|-][0-9]{1,2}!is', $offset)) {
             // new one
             $fake_getdate_time = new \TYPO3\CMS\Cal\Model\CalDate();
             $fake_getdate_time->copy($this->controller->getDateTimeObject);
             $fake_getdate_time->setDay(15);
             if (intval($offset) < 0) {
                 $fake_getdate_time->subtractSeconds(abs(intval($offset)) * 2592000);
             } else {
                 $fake_getdate_time->addSeconds(intval($offset) * 2592000);
             }
         } else {
             $fake_getdate_time = new \TYPO3\CMS\Cal\Model\CalDate();
             $fake_getdate_time->copy($this->controller->getDateTimeObject);
             $fake_getdate_time->setDay(15);
             $fake_getdate_time->setMonth($offset);
         }
         $minical_month = $fake_getdate_time->getMonth();
         $minical_year = $fake_getdate_time->getYear();
         $today = new \TYPO3\CMS\Cal\Model\CalDate();
         $month_title = $fake_getdate_time->format($this->conf['view.'][$viewTarget . '.']['dateFormatMonth']);
         $this->initLocalCObject();
         $this->local_cObj->setCurrentVal($month_title);
         $this->local_cObj->data['view'] = $viewTarget;
         $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $fake_getdate_time->format('%Y%m%d'), 'view' => $viewTarget, $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewPid']);
         $month_title = $this->local_cObj->cObjGetSingle($this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewLink'], $this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewLink.']);
         $month_date = $fake_getdate_time->format('%Y%m%d');
         $view_array = array();
         if (!$this->viewarray) {
             $this->eventArray = array();
             if (!empty($this->master_array)) {
                 // use array keys for the loop in order to be able to use referenced events instead of copies and save some memory
                 $masterArrayKeys = array_keys($this->master_array);
                 foreach ($masterArrayKeys as $dateKey) {
                     $dateArray =& $this->master_array[$dateKey];
                     $dateArrayKeys = array_keys($dateArray);
                     foreach ($dateArrayKeys as $timeKey) {
                         $arrayOfEvents =& $dateArray[$timeKey];
                         $eventKeys = array_keys($arrayOfEvents);
                         foreach ($eventKeys as $eventKey) {
                             $event =& $arrayOfEvents[$eventKey];
                             $eventReferenceKey = $dateKey . '_' . $event->getType() . '_' . $event->getUid() . '_' . $event->getStart()->format('%Y%m%d%H%M%S');
                             $this->eventArray[$eventReferenceKey] =& $event;
                             $starttime = new \TYPO3\CMS\Cal\Model\CalDate();
                             $starttime->copy($event->getStart());
                             $endtime = new \TYPO3\CMS\Cal\Model\CalDate();
                             $endtime->copy($event->getEnd());
                             if ($timeKey == '-1') {
                                 $endtime->addSeconds(1);
                                 // needed to let allday events show up
                             }
                             $j = new \TYPO3\CMS\Cal\Model\CalDate();
                             $j->copy($starttime);
                             $j->setHour(0);
                             $j->setMinute(0);
                             $j->setSecond(0);
                             for (; $j->before($endtime); $j->addSeconds(60 * 60 * 24)) {
                                 $view_array[$j->format('%Y%m%d')]['000000'][count($view_array[$j->format('%Y%m%d')]['000000'])] = $eventReferenceKey;
                             }
                         }
                     }
                 }
             }
             $this->viewarray =& $view_array;
         }
         $monthTemplate = str_replace('###MONTH_TITLE###', $month_title, $monthTemplate);
         $langtype = $this->conf['view.']['month.']['weekdayFormat' . ucwords($type) . 'Month'];
         $typeSize = intval($this->conf['view.']['month.']['weekdayLength' . ucwords($type) . 'Month']);
         $dateOfWeek = Calc::beginOfWeek(15, $fake_getdate_time->getMonth(), $fake_getdate_time->getYear());
         $start_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000');
         // backwardscompatibility with old templates
         if (!empty($corner)) {
             $weekday_loop .= str_replace('###ADDITIONAL_CLASSES###', $this->conf['view.']['month.']['monthCornerStyle'], $corner);
         } else {
             $weekday_loop .= sprintf($weeknum, $this->conf['view.']['month.']['monthCornerStyle'], '');
         }
         for ($i = 0; $i < 7; $i++) {
             $weekday = $start_day->format($langtype);
             $weekdayLong = $start_day->format('%A');
             if ($typeSize) {
                 $weekday = $this->cs_convert->substr(\TYPO3\CMS\Cal\Utility\Functions::getCharset(), $weekday, 0, $typeSize);
             }
             $start_day->addSeconds(86400);
             $additionalClasses = trim(sprintf($this->conf['view.']['month.']['monthDayOfWeekStyle'], $start_day->format('%w')));
             $markerArray = array('###WEEKDAY###' => $weekday, '###WEEKDAY_LONG###' => $weekdayLong, '###ADDITIONAL_CLASSES###' => ' ' . $additionalClasses, '###CLASSES###' => !empty($additionalClasses) ? ' class="' . $additionalClasses . '" ' : '');
             $weekday_loop .= strtr($loop_wd, $markerArray);
         }
         $weekday_loop .= $endweek;
         $dateOfWeek = Calc::beginOfWeek(1, $fake_getdate_time->getMonth(), $fake_getdate_time->getYear());
         $endOfMonth = $this->controller->getListViewTime('monthend', $start_day);
         $start_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000');
         $start_day->setTZbyID('UTC');
         $i = 0;
         $whole_month = TRUE;
         $isAllowedToCreateEvent = $this->rightsObj->isAllowedToCreateEvent();
         $createOffset = intval($this->conf['rights.']['create.']['event.']['timeOffset']) * 60;
         $getdate = new \TYPO3\CMS\Cal\Model\CalDate($this->conf['getdate']);
         $getdate->setTZbyID('UTC');
         $startWeekTime = \TYPO3\CMS\Cal\Controller\Calendar::calculateStartWeekTime($getdate);
         $endWeekTime = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndWeekTime($getdate);
         $formattedWeekStartTime = $startWeekTime->format('%Y%m%d');
         $formattedWeekEndTime = $endWeekTime->format('%Y%m%d');
         do {
             $daylink = new \TYPO3\CMS\Cal\Model\CalDate();
             $daylink->copy($start_day);
             $formatedGetdate = $daylink->format('%Y%m%d');
             $formatedDayDate = $daylink->format($this->conf['view.']['month.']['dateFormatDay']);
             $isCurrentWeek = false;
             $isSelectedWeek = false;
             if ($formatedGetdate >= $formattedWeekStartTime && $formatedGetdate <= $formattedWeekEndTime) {
                 $isSelectedWeek = true;
             }
             if ($start_day->format('%Y%U') == $today->format('%Y%U')) {
                 $isCurrentWeek = true;
             }
             if ($i == 0 && !empty($weeknum)) {
                 $start_day->addSeconds(86400);
                 $num = $numPlain = $start_day->getWeekOfYear();
                 $hasEvent = false;
                 $start_day->subtractSeconds(86400);
                 for ($j = 0; $j < 7; $j++) {
                     if (is_array($this->viewarray[$start_day->format('%Y%m%d')]) || $isAllowedToCreateEvent) {
                         $hasEvent = true;
                         break;
                     }
                     $start_day->addSeconds(86400);
                 }
                 $start_day->copy($daylink);
                 $weekLinkViewTarget = $this->conf['view.']['weekLinkTarget'];
                 if (($this->rightsObj->isViewEnabled($weekLinkViewTarget) || $this->conf['view.'][$weekLinkViewTarget . '.'][$weekLinkViewTarget . 'ViewPid']) && $hasEvent) {
                     $this->initLocalCObject();
                     $this->local_cObj->setCurrentVal($num);
                     $this->local_cObj->data['view'] = $weekLinkViewTarget;
                     $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $formatedGetdate, 'view' => $weekLinkViewTarget, $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$weekLinkViewTarget . '.'][$weekLinkViewTarget . 'ViewPid']);
                     $num = $this->local_cObj->cObjGetSingle($this->conf['view.'][$weekLinkViewTarget . '.'][$weekLinkViewTarget . 'ViewLink'], $this->conf['view.'][$weekLinkViewTarget . '.'][$weekLinkViewTarget . 'ViewLink.']);
                 }
                 $className = array();
                 if ($isSelectedWeek && !empty($this->conf['view.']['month.']['monthSelectedWeekStyle'])) {
                     $className[] = $this->conf['view.']['month.']['monthSelectedWeekStyle'];
                 }
                 if ($isCurrentWeek && !empty($this->conf['view.']['month.']['monthCurrentWeekStyle'])) {
                     $className[] = $this->conf['view.']['month.']['monthCurrentWeekStyle'];
                 }
                 if ($hasEvent && !empty($this->conf['view.']['month.']['monthWeekWithEventStyle'])) {
                     $className[] = $this->conf['view.']['month.']['monthWeekWithEventStyle'];
                 }
                 $weekClasses = trim(implode(' ', $className));
                 $markerArray = array('###ADDITIONAL_CLASSES###' => $weekClasses ? ' ' . $weekClasses : '', '###CLASSES###' => $weekClasses ? ' class="' . $weekClasses . '" ' : '', '###WEEKNUM###' => $num, '###WEEKNUM_PLAIN###' => $numPlain);
                 $middle .= strtr($startweek, $markerArray);
                 // we do this sprintf all only for backwards compatibility with old templates
                 $middle .= strtr(sprintf($weeknum, $markerArray['###ADDITIONAL_CLASSES###'], $num), $markerArray);
             }
             $i++;
             $switch = array('###ALLDAY###' => '');
             $check_month = $start_day->getMonth();
             $switch['###LINK###'] = $this->getCreateEventLink('month', '', $start_day, $createOffset, $isAllowedToCreateEvent, '', '', $this->conf['view.']['day.']['dayStart']);
             $style = array();
             $dayLinkViewTarget = $this->conf['view.']['dayLinkTarget'];
             if (($this->rightsObj->isViewEnabled($dayLinkViewTarget) || $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']) && ($this->viewarray[$formatedGetdate] || $isAllowedToCreateEvent)) {
                 $this->initLocalCObject();
                 $this->local_cObj->setCurrentVal($formatedDayDate);
                 $this->local_cObj->data['view'] = $dayLinkViewTarget;
                 $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $formatedGetdate, 'view' => $dayLinkViewTarget, $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']);
                 $switch['###LINK###'] .= $this->local_cObj->cObjGetSingle($this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink.']);
                 if ($switch['###LINK###'] === '') {
                     $switch['###LINK###'] .= $formatedDayDate;
                 }
                 $switch['###LINK###'] = $this->cObj->stdWrap($switch['###LINK###'], $this->conf['view.']['month.'][$type . 'Link_stdWrap.']);
             } else {
                 $switch['###LINK###'] .= $formatedDayDate;
             }
             // add a css class if the current day has a event - regardless if linked or not
             if ($this->viewarray[$formatedGetdate]) {
                 $style[] = $this->conf['view.']['month.']['eventDayStyle'];
             }
             $style[] = $this->conf['view.']['month.']['month' . ucfirst($type) . 'Style'];
             if ($check_month != $minical_month) {
                 $style[] = $this->conf['view.']['month.']['monthOffStyle'];
             }
             if ($start_day->format('%w') == 0 || $start_day->format('%w') == 6) {
                 $style[] = $this->conf['view.']['month.']['monthDayWeekendStyle'];
             }
             if ($isSelectedWeek) {
                 $style[] = $this->conf['view.']['month.']['monthDaySelectedWeekStyle'];
             }
             if ($formatedGetdate == $this->conf['getdate']) {
                 $style[] = $this->conf['view.']['month.']['monthSelectedStyle'];
             }
             if ($isCurrentWeek) {
                 $style[] = $this->conf['view.']['month.']['monthDayCurrentWeekStyle'];
             }
             if ($formatedGetdate == $today->format('%Y%m%d')) {
                 $style[] = $this->conf['view.']['month.']['monthTodayStyle'];
             }
             if ($this->conf['view.']['month.']['monthDayOfWeekStyle']) {
                 $style[] = sprintf($this->conf['view.']['month.']['monthDayOfWeekStyle'], $start_day->format('%w'));
             }
             //clean up empty styles (code beautify)
             foreach ($style as $key => $classname) {
                 if ($classname == '') {
                     unset($style[$key]);
                 }
             }
             // Adds hook for processing of extra month day style markers
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tx_cal_controller']['extraMonthDayStyleMarkerHook'])) {
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tx_cal_controller']['extraMonthDayStyleMarkerHook'] as $_classRef) {
                     $_procObj =& GeneralUtility::getUserObj($_classRef);
                     if (is_object($_procObj) && method_exists($_procObj, 'extraMonthDayStyleMarkerProcessor')) {
                         $_procObj->extraMonthDayStyleMarkerProcessor($this, $daylink, $switch, $type, $style);
                     }
                 }
             }
             $classesDay = implode(' ', $style);
             $markerArray = array('###STYLE###' => $classesDay, '###ADDITIONAL_CLASSES###' => $classesDay ? ' ' . $classesDay : '', '###CLASSES###' => $classesDay ? ' class="' . $classesDay . '" ' : '', '###DAY_ID###' => $formatedGetdate);
             $temp = strtr($t_month, $markerArray);
             $wraped = array();
             if ($this->viewarray[$formatedGetdate] && preg_match('!\\###EVENT\\###!is', $t_month)) {
                 foreach ($this->viewarray[$formatedGetdate] as $cal_time => $event_times) {
                     foreach ($event_times as $uid => $eventId) {
                         if ($type == 'large') {
                             $switch['###EVENT###'] .= $this->eventArray[$eventId]->renderEventForMonth();
                         } else {
                             if ($type == 'medium') {
                                 $switch['###EVENT###'] .= $this->eventArray[$eventId]->renderEventForYear();
                             } else {
                                 if ($type == 'small') {
                                     $switch['###EVENT###'] .= $this->eventArray[$eventId]->renderEventForMiniMonth();
                                 }
                             }
                         }
                     }
                 }
             }
             if (!isset($switch['###EVENT###'])) {
                 $this->initLocalCObject();
                 $switch['###EVENT###'] = $this->local_cObj->cObjGetSingle($this->conf['view.'][$viewTarget . '.']['event.']['noEventFound'], $this->conf['view.'][$viewTarget . '.']['event.']['noEventFound.']);
             }
             if (!isset($switch['###ALLDAY###'])) {
                 $this->initLocalCObject();
                 $switch['###ALLDAY###'] = $this->local_cObj->cObjGetSingle($this->conf['view.'][$viewTarget . '.']['event.']['noEventFound'], $this->conf['view.'][$viewTarget . '.']['event.']['noEventFound.']);
             }
             // Adds hook for processing of extra month day markers
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tx_cal_controller']['extraMonthDayMarkerHook'])) {
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tx_cal_controller']['extraMonthDayMarkerHook'] as $_classRef) {
                     $_procObj =& GeneralUtility::getUserObj($_classRef);
                     if (is_object($_procObj) && method_exists($_procObj, 'extraMonthDayMarkerProcessor')) {
                         $switch = $_procObj->extraMonthDayMarkerProcessor($this, $daylink, $switch, $type);
                     }
                 }
             }
             $middle .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $switch, array(), $wraped);
             $start_day->addSeconds(86400);
             // 60 * 60 *24 -> strtotime('+1 day', $start_day);
             if ($i == 7) {
                 $i = 0;
                 $middle .= $endweek;
                 $checkagain = $start_day->getMonth();
                 if ($checkagain != $minical_month) {
                     $whole_month = FALSE;
                 }
             }
         } while ($whole_month == TRUE);
         $rems['###LOOPWEEKDAY###'] = $weekday_loop;
         $rems['###LOOPMONTHWEEKS###'] = $middle;
         $rems['###LOOPMONTHWEEKS_DAYS###'] = '';
         $rems['###LOOPWEEK_NUMS###'] = '';
         $rems['###CORNER###'] = '';
         $monthTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($monthTemplate, array(), $rems, array());
         $monthTemplate .= $ajaxEvents;
         $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), array('###MONTH_TEMPLATE###' => $monthTemplate), array());
     }
     $listTemplate = $this->cObj->getSubpart($page, '###LIST###');
     if ($listTemplate != '') {
         $tx_cal_listview =& GeneralUtility::makeInstanceService('cal_view', 'list', 'list');
         $starttime = gmmktime(0, 0, 0, $this_month, 1, $this_year);
         $endtime = gmmktime(0, 0, 0, $this_month + 1, 1, $this_year);
         $rems['###LIST###'] = $tx_cal_listview->drawList($this->master_array, $listTemplate, $starttime, $endtime);
     }
     $return = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, array());
     if ($this->rightsObj->isViewEnabled($viewTarget) || $this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewPid']) {
         $this->initLocalCObject();
         $this->local_cObj->setCurrentVal($month_title);
         $this->local_cObj->data['view'] = $viewTarget;
         $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $month_date, 'view' => $viewTarget, $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewPid']);
         $month_link = $this->local_cObj->cObjGetSingle($this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewLink'], $this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewLink.']);
     } else {
         $month_link = $month_title;
     }
     $return = str_replace('###MONTH_LINK###', $month_link, $return);
     return $return;
 }
Example #9
0
    function notify(&$newEventDataArray, $forceDeletionMode = 0)
    {
        $event = $this->modelObj->findEvent($newEventDataArray['uid'], 'tx_cal_phpicalendar', $this->conf['pidList'], true, true, false, true, true);
        if (is_object($event)) {
            $this->startMailer();
            $select = 'fe_users.*';
            $table = 'fe_users, tx_cal_fe_user_event_monitor_mm, tx_cal_event';
            $where = 'fe_users.uid = tx_cal_fe_user_event_monitor_mm.uid_foreign AND  tx_cal_fe_user_event_monitor_mm.uid_local = tx_cal_event.uid AND tx_cal_event.deleted = ' . intval($newEventDataArray['deleted']) . ' AND tx_cal_event.uid = ' . $newEventDataArray['uid'];
            $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where);
            while ($row1 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                if ($row1['email'] != '' && GeneralUtility::validEmail($row1['email'])) {
                    if ($newEventDataArray['deleted'] + $forceDeletionMode > 0) {
                        $template = $this->conf['view.']['event.']['notify.']['fe_users_' . $row1['uid'] . '.']['onDeleteTemplate'];
                        if (!$template) {
                            $template = $this->conf['view.']['event.']['notify.']['all.']['onDeleteTemplate'];
                        }
                        $titleText = $this->conf['view.']['event.']['notify.']['fe_users_' . $row1['uid'] . '.']['onDeleteEmailTitle'];
                        if (!$titleText) {
                            $titleText = $this->conf['view.']['event.']['notify.']['all.']['onDeleteEmailTitle'];
                        }
                    } else {
                        $template = $this->conf['view.']['event.']['notify.']['fe_users_' . $row1['uid'] . '.']['onCreateTemplate'];
                        if (!$template) {
                            $template = $this->conf['view.']['event.']['notify.']['all.']['onCreateTemplate'];
                        }
                        $titleText = $this->conf['view.']['event.']['notify.']['fe_users_' . $row1['uid'] . '.']['onCreateEmailTitle'];
                        if (!$titleText) {
                            $titleText = $this->conf['view.']['event.']['notify.']['all.']['onCreateEmailTitle'];
                        }
                    }
                    $unsubscribeLink = $this->baseUrl . $this->controller->pi_getPageLink($this->conf['view.']['event.']['notify.']['subscriptionViewPid'], '', array('tx_cal_controller[view]' => 'subscription', 'tx_cal_controller[email]' => $row1['email'], 'tx_cal_controller[uid]' => $event->getUid(), 'tx_cal_controller[monitor]' => 'stop', 'tx_cal_controller[sid]' => md5($event->getUid() . $row1['email'] . $row1['crdate'])));
                    $this->sendNotification($event, $row1['email'], $template, $titleText, $unsubscribeLink);
                }
            }
            $GLOBALS['TYPO3_DB']->sql_free_result($result);
            $select = 'tx_cal_unknown_users.*';
            $table = 'tx_cal_unknown_users, tx_cal_fe_user_event_monitor_mm, tx_cal_event';
            $where = 'tx_cal_unknown_users.uid = tx_cal_fe_user_event_monitor_mm.uid_foreign AND  tx_cal_fe_user_event_monitor_mm.uid_local = tx_cal_event.uid AND tx_cal_event.uid = ' . $event->getUid();
            $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where);
            while ($row1 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                if ($row1['email'] != '' && GeneralUtility::validEmail($row1['email'])) {
                    $template = $this->conf['view.']['event.']['notify.']['all.']['onCreateTemplate'];
                    $titleText = $this->conf['view.']['event.']['notify.']['all.']['onCreateEmailTitle'];
                    if ($newEventDataArray['deleted'] + $forceDeletionMode > 0) {
                        $template = $this->conf['view.']['event.']['notify.']['all.']['onDeleteTemplate'];
                        $titleText = $this->conf['view.']['event.']['notify.']['all.']['onDeleteEmailTitle'];
                    }
                    $unsubscribeLink = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->controller->pi_getPageLink($this->conf['view.']['event.']['notify.']['subscriptionViewPid'], '', array('tx_cal_controller[view]' => 'subscription', 'tx_cal_controller[email]' => $row1['email'], 'tx_cal_controller[uid]' => $event->getUid(), 'tx_cal_controller[monitor]' => 'stop', 'tx_cal_controller[sid]' => md5($event->getUid() . $row1['email'] . $row1['crdate'])));
                    $this->sendNotification($event, $row1['email'], $template, $titleText, $unsubscribeLink);
                }
            }
            $GLOBALS['TYPO3_DB']->sql_free_result($result);
            foreach ($event->getCategories() as $category) {
                foreach ($category->getNotificationEmails() as $emailAddress) {
                    if ($emailAddress != '' && GeneralUtility::validEmail($emailAddress)) {
                        if ($newEventDataArray['deleted'] + $forceDeletionMode > 0) {
                            $template = $this->conf['view.']['event.']['notify.'][$category->getUid() . '.']['onDeleteTemplate'];
                            if (!$template) {
                                $template = $this->conf['view.']['event.']['notify.']['all.']['onDeleteTemplate'];
                            }
                            $titleText = $this->conf['view.']['event.']['notify.'][$category->getUid() . '.']['onDeleteEmailTitle'];
                            if (!$titleText) {
                                $titleText = $this->conf['view.']['event.']['notify.']['all.']['onDeleteEmailTitle'];
                            }
                        } else {
                            $template = $this->conf['view.']['event.']['notify.'][$category->getUid() . '.']['onCreateTemplate'];
                            if (!$template) {
                                $template = $this->conf['view.']['event.']['notify.']['all.']['onCreateTemplate'];
                            }
                            $titleText = $this->conf['view.']['event.']['notify.'][$category->getUid() . '.']['onCreateEmailTitle'];
                            if (!$titleText) {
                                $titleText = $this->conf['view.']['event.']['notify.']['all.']['onCreateEmailTitle'];
                            }
                        }
                        $unsubscribeLink = '';
                        $this->sendNotification($event, $emailAddress, $template, $titleText, $unsubscribeLink);
                    }
                }
            }
            $subType = 'getGroupsFE';
            $groups = array();
            $serviceObj = null;
            $serviceObj = GeneralUtility::makeInstanceService('auth', $subType);
            if ($serviceObj == null) {
                return;
            }
            $select = 'tx_cal_fe_user_event_monitor_mm.uid_local';
            $table = 'tx_cal_fe_user_event_monitor_mm';
            $where = 'tx_cal_fe_user_event_monitor_mm.uid_foreign = ' . $event->getUid() . ' AND tx_cal_fe_user_event_monitor_mm.tablenames = "fe_groups"';
            $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where);
            while ($row1 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                $serviceObj->getSubGroups($row1['uid_local'], '', $groups);
                $select = 'DISTINCT fe_users.email';
                $table = 'fe_groups, fe_users';
                $where = 'fe_groups.uid IN (' . implode(',', $groups) . ') 
						AND FIND_IN_SET(fe_groups.uid, fe_users.usergroup)
						AND fe_users.email != \'\' 
						AND fe_groups.deleted = 0 
						AND fe_groups.hidden = 0 
						AND fe_users.disable = 0
						AND fe_users.deleted = 0';
                $result2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where);
                while ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result2)) {
                    if ($row2['email'] != '' && GeneralUtility::validEmail($row2['email'])) {
                        if ($newEventDataArray['deleted'] + $forceDeletionMode > 0) {
                            $template = $this->conf['view.']['event.']['notify.']['fe_groups_' . $row2['uid'] . '.']['onDeleteTemplate'];
                            if (!$template) {
                                $template = $this->conf['view.']['event.']['notify.']['all.']['onDeleteTemplate'];
                            }
                            $titleText = $this->conf['view.']['event.']['notify.']['fe_groups_' . $row2['uid'] . '.']['onDeleteEmailTitle'];
                            if (!$titleText) {
                                $titleText = $this->conf['view.']['event.']['notify.']['all.']['onDeleteEmailTitle'];
                            }
                        } else {
                            $template = $this->conf['view.']['event.']['notify.']['fe_groups_' . $row2['uid'] . '.']['onCreateTemplate'];
                            if (!$template) {
                                $template = $this->conf['view.']['event.']['notify.']['all.']['onCreateTemplate'];
                            }
                            $titleText = $this->conf['view.']['event.']['notify.']['fe_groups_' . $row2['uid'] . '.']['onCreateEmailTitle'];
                            if (!$titleText) {
                                $titleText = $this->conf['view.']['event.']['notify.']['all.']['onCreateEmailTitle'];
                            }
                        }
                        $unsubscribeLink = $this->baseUrl . $this->controller->pi_getPageLink($this->conf['view.']['event.']['notify.']['subscriptionViewPid'], '', array('tx_cal_controller[view]' => 'subscription', 'tx_cal_controller[email]' => $row2['email'], 'tx_cal_controller[uid]' => $event->getUid(), 'tx_cal_controller[monitor]' => 'stop', 'tx_cal_controller[sid]' => md5($event->getUid() . $row2['email'] . $row2['crdate'])));
                        $this->sendNotification($event, $row2['email'], $template, $titleText, $unsubscribeLink);
                    }
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($result2);
            }
            $GLOBALS['TYPO3_DB']->sql_free_result($result);
        }
    }
 /**
  * Autocomplete feature
  *
  * @param \string $searchterm		Search terms
  * @return \string					JSON encoded autocomplete suggestions
  */
 public function autocompleteAction($searchterm = '')
 {
     $this->response->setHeader('Content-Type', 'application/json; charset=utf-8');
     $this->response->sendHeaders();
     // Instanciating the lucene index service
     /* @var $indexerService \Tollwerk\TwLucenesearch\Service\Lucene */
     $indexerService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService('index', 'lucene');
     $suggestions = $indexerService instanceof \TYPO3\CMS\Core\Service\AbstractService ? $indexerService->autocomplete($searchterm) : array();
     return json_encode($suggestions);
 }
Example #11
0
 function findAllObjects($key, $type, $pidList, $functionTobeCalled = '', $paramsToBePassedOn = '')
 {
     /* No key provided so return all X */
     $serviceName = 'cal_' . $key . '_model';
     $objects = array();
     if ($type == '') {
         $serviceChain = '';
         /* Iterate over all classes providing the cal_X_model service */
         while (is_object($service =& GeneralUtility::makeInstanceService($serviceName, $key, $serviceChain))) {
             if ($functionTobeCalled) {
                 if (method_exists($service, $functionTobeCalled)) {
                     $objects[$service->getServiceKey()] = $service->{$functionTobeCalled}($paramsToBePassedOn);
                 }
             } else {
                 $objects[$service->getServiceKey()] = $service->findAll($pidList);
             }
             $serviceChain .= ',' . $service->getServiceKey();
         }
     } else {
         /* Gets the model for the provided service key */
         $service =& $this->getServiceObjByKey($serviceName, $key, $type);
         /* Look up a objects with a specific ID inside the model */
         if ($functionTobeCalled) {
             if (method_exists($service, $functionTobeCalled)) {
                 $objects[$type] = $service->{$functionTobeCalled}($paramsToBePassedOn);
             }
         } else {
             $objects[$type] = $service->findAll($pidList);
         }
     }
     return $objects;
 }
Example #12
0
 /**
  * Helper function to return a service object with the given type, subtype, and serviceKey
  *
  * @param
  *        	string	The type of the service.
  * @param
  *        	string	The subtype of the service.
  * @param
  *        	string	The serviceKey.
  * @return object service object.
  */
 function getServiceObjByKey($type, $subtype = '', $key)
 {
     $serviceChain = '';
     /* Loop over all services providign the specified service type and subtype */
     while (is_object($obj =& \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService($type, $subtype, $serviceChain))) {
         $serviceChain .= ',' . $obj->getServiceKey();
         return $obj;
     }
     return;
 }
Example #13
0
 protected function getTemplateSubpartMarker(&$template, &$sims, &$rems, &$wrapped)
 {
     preg_match_all('!\\<\\!--[a-zA-Z0-9 ]*###([A-Z0-9_-|]*)\\###[a-zA-Z0-9 ]*-->!is', $template, $match);
     $allMarkers = array_unique($match[1]);
     foreach ($allMarkers as $marker) {
         switch ($marker) {
             case 'FORM_START':
                 $this->getFormStartMarker($template, $sims, $rems, $wrapped);
                 break;
             case 'FORM_END':
                 $this->getFormEndMarker($template, $sims, $rems, $wrapped);
                 break;
             default:
                 if (preg_match('/MODULE__([A-Z0-9_-])*/', $marker)) {
                     $module = GeneralUtility::makeInstanceService(substr($marker, 8), 'module');
                     if (is_object($module)) {
                         $rems['###' . $marker . '###'] = $module->start($this);
                     }
                 }
                 break;
         }
     }
 }
Example #14
0
    function processDatamap_preProcessFieldArray(&$incomingFieldArray, $table, $id, &$tce)
    {
        /**
         * Demo code for using TCE to do custom validation of form elements.
         * The record is still
         * saved but a bad combination of start date and end date will generate an error message.
         */
        /*
         * if($table == 'tx_cal_event') { $startTimestamp = $incomingFieldArray['start_date'] + $incomingFieldArray['start_time']; $endTimestamp = $incomingFieldArray['end_date'] + $incomingFieldArray['end_time']; if ($startTimestamp > $endTimestamp) { $tce->log('tx_cal_event', 2, $id, 0, 1, "Event end (".BackendUtility::datetime($endTimestamp).") is earlier than event start (".BackendUtility::datetime($startTimestamp).").", 1); } }
         */
        /* preview events on eventViewPid on "save and preview" calls. but only if it's a regular event and the user is in live workspace */
        if ($table == 'tx_cal_event' && isset($GLOBALS['_POST']['_savedokview_x']) && !$incomingFieldArray['type'] && !$GLOBALS['BE_USER']->workspace) {
            $pagesTSConfig = BackendUtility::getPagesTSconfig($GLOBALS['_POST']['popViewId']);
            if ($pagesTSConfig['options.']['tx_cal_controller.']['eventViewPid']) {
                $GLOBALS['_POST']['popViewId_addParams'] = ($incomingFieldArray['sys_language_uid'] > 0 ? '&L=' . $incomingFieldArray['sys_language_uid'] : '') . '&no_cache=1&tx_cal_controller[view]=event&tx_cal_controller[type]=tx_cal_phpicalendar&tx_cal_controller[uid]=' . $id;
                $GLOBALS['_POST']['popViewId'] = $pagesTSConfig['options.']['tx_cal_controller.']['eventViewPid'];
            }
        }
        if ($table == 'tx_cal_event' || $table == "tx_cal_exeption_event") {
            $event = BackendUtility::getRecord($table, $id);
            if (intval($event['start_date']) == 0) {
                return;
            }
            /**
             * If we have an event, check if a start and end time have been sent.
             * If both are 0, then its an all day event.
             */
            if (array_key_exists('start_time', $incomingFieldArray) && array_key_exists('end_time', $incomingFieldArray) && $incomingFieldArray['start_time'] == 0 && $incomingFieldArray['end_time'] == 0) {
                $incomingFieldArray['allday'] = 1;
            }
            /**
             * If the recurring frequency has changed and recurrence rules are not
             * already set, preset a reasonable value based on event start date/time.
             * 
             * @todo Default date calculations do not take any timezone information into account.
             */
            if ($incomingFieldArray['freq'] != $event['freq']) {
                $date = $this->convertBackendDateToPear($incomingFieldArray['start_date']);
                $date->addSeconds($incomingFieldArray['start_time']);
                $dayArray = TceMainProcessdatamap::getWeekdayOccurrence($date);
                /* If we're on the 4th occurrence or later, let's assume we want the last occurrence */
                if ($dayArray[0] >= 4) {
                    $dayArray[0] = -1;
                }
                switch ($incomingFieldArray['freq']) {
                    case 'week':
                        /* Default Value = Day of the week when event starts. */
                        if (!$incomingFieldArray['byday'] && !$event['byday']) {
                            $incomingFieldArray['byday'] = strtolower($date->getDayName(true, 2));
                        }
                        break;
                    case 'month':
                        /* Default Value = Day of the week and weekday occurrence when event starts */
                        if (!$incomingFieldArray['byday'] && !$event['byday']) {
                            $incomingFieldArray['byday'] = $dayArray[0] . strtolower(substr($dayArray[1], 0, 2));
                        }
                        break;
                    case 'year':
                        /* Default Value = Day of the month and month when event starts */
                        if (!$incomingFieldArray['bymonthday'] && !$event['bymonthday']) {
                            $incomingFieldArray['bymonthday'] = $date->getDay();
                        }
                        if (!$incomingFieldArray['bymonth'] && !$event['bymonth']) {
                            $incomingFieldArray['bymonth'] = $date->getMonth();
                        }
                        break;
                }
            }
        }
        if ($table == 'tx_cal_category' && array_key_exists('calendar_id', $incomingFieldArray) && !strstr($id, 'NEW')) {
            $category = BackendUtility::getRecord('tx_cal_category', $id);
            if ($incomingFieldArray['calendar_id'] != $category['calendar_id']) {
                $incomingFieldArray['parent_category'] = 0;
            }
        }
        /* If an existing calendar is updated */
        if ($table == 'tx_cal_calendar' && array_key_exists('type', $incomingFieldArray) && !strstr($id, 'NEW')) {
            /* Get the calendar info from the db */
            $calendar = BackendUtility::getRecord('tx_cal_calendar', $id);
            $service = new \TYPO3\CMS\Cal\Service\ICalendarService();
            // Here we have to check if the calendar belongs to the type
            // problem with case 2 & 3 -> what to do with events of type database? delete them without warning? keep them and assign them to a default category?
            switch ($incomingFieldArray['type']) {
                case 0:
                    /* Standard */
                    /* Delete any temporary events previously associated with this calendar */
                    if ($calendar['type'] != 0) {
                        $service->deleteTemporaryEvents($id);
                        $service->deleteSchedulerTask($id);
                        $calendar['schedulerId'] = 0;
                        /** @var \TYPO3\CMS\Cal\Utility\RecurrenceGenerator $rgc */
                        $rgc = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Utility\\RecurrenceGenerator');
                        $rgc->cleanIndexTableOfCalendarUid($id);
                    }
                    break;
                case 1:
                    /* External URL or ICS file */
                /* External URL or ICS file */
                case 2:
                    /* ICS File */
                    $this->processICS($calendar, $incomingFieldArray, $service);
                    break;
            }
        }
        if ($table == 'tx_cal_exception_event_group' && !strstr($id, 'NEW')) {
            $exceptionEvent = BackendUtility::getRecord('tx_cal_exception_event_group', $id);
            /* If we're in a workspace, don't notify anyone about the event */
            if ($exceptionEvent['pid'] > 0 && !$GLOBALS['BE_USER']->workspace) {
                /* Check Page TSConfig for a preview page that we should use */
                $pageTSConf = BackendUtility::getPagesTSconfig($exceptionEvent['pid']);
                if ($pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin']) {
                    $pageIDForPlugin = $pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin'];
                } else {
                    $pageIDForPlugin = $exceptionEvent['pid'];
                }
                $page = BackendUtility::getRecord('pages', intval($pageIDForPlugin), "doktype");
                if ($page['doktype'] != 254) {
                    $tx_cal_api = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\Api');
                    $tx_cal_api = $tx_cal_api->tx_cal_api_without($pageIDForPlugin);
                    /** @var \TYPO3\CMS\Cal\Utility\RecurrenceGenerator $rgc */
                    $rgc = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Utility\\RecurrenceGenerator');
                    $rgc->cleanIndexTableOfExceptionGroupUid($id);
                }
            }
        }
        if ($table == 'tx_cal_attendee') {
            $incomingFieldArray['fe_user_id'] = str_replace(array(',', 'fe_users_'), array('', ''), $incomingFieldArray['fe_user_id']);
            $incomingFieldArray['fe_group_id'] = str_replace(array(',', 'fe_groups_'), array('', ''), $incomingFieldArray['fe_group_id']);
            if ($incomingFieldArray['fe_group_id'] > 0) {
                $subType = 'getGroupsFE';
                $groups = array(0);
                $serviceObj = null;
                $serviceObj = GeneralUtility::makeInstanceService('auth', $subType);
                if ($serviceObj == null) {
                    return;
                }
                $serviceObj->getSubGroups($incomingFieldArray['fe_group_id'], '', $groups);
                unset($incomingFieldArray['fe_group_id']);
                $select = 'DISTINCT fe_users.*';
                $table = 'fe_groups, fe_users';
                $where = 'fe_groups.uid IN (' . implode(',', $groups) . ') 
						AND FIND_IN_SET(fe_groups.uid, fe_users.usergroup)
						AND fe_users.email != \'\' 
						AND fe_groups.deleted = 0 
						AND fe_groups.hidden = 0 
						AND fe_users.disable = 0
						AND fe_users.deleted = 0';
                $result2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where);
                $attendeeUids = array();
                while ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result2)) {
                    $incomingFieldArray['fe_user_id'] = $row2['fe_users.uid'];
                    $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_cal_attendee', $incomingFieldArray);
                    if (FALSE === $result) {
                        throw new \RuntimeException('Could not write attendee record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458136);
                    }
                    $attendeeUids[] = $GLOBALS['TYPO3_DB']->sql_insert_id();
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($result2);
                // $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_cal_event', $incomingFieldArray);
                foreach ($tce->datamap['tx_cal_event'] as $eventUid => $eventArray) {
                    $eventArray['attendee'] = array_unique(array_merge(GeneralUtility::trimExplode(',', $eventArray['attendee'], 1), $attendeeUids));
                }
            }
            unset($incomingFieldArray['fe_group_id']);
        }
    }
 /**
  * @test
  */
 public function extractsTextFromTxtFile()
 {
     $service = GeneralUtility::makeInstanceService('textExtract', 'txt');
     $service->setInputFile($this->testDocumentsPath . 'testTXT.txt', 'txt');
     $service->process();
     $expectedText = 'Test';
     $extractedText = $service->getOutput();
     $this->assertContains($expectedText, $extractedText);
 }
 /**
  * Highlighting of terms within a text
  * 
  * @param string $text											Text
  * @param string|\Zend_Search_Lucene_Search_Query $search		Terms to be highlighted (string or lucene search query)
  * @param int $crop												Max. number of characters length
  * @param string $append		 								Suffix in case of text being cropped at the end
  * @param string $prepend		 								Prefix in case of text being cropped at the beginning
  * @param string $field			 								Lucene document field to be used (if the search terms have to be found retroactively)
  * @return string												Text with highlighting
  * @see http://www.mail-archive.com/fw-general@lists.zend.com/msg09013.html
  */
 public function render($text = null, $search = null, $crop = null, $append = ' ...', $prepend = ' ... ', $field = 'bodytext')
 {
     $text = trim(strlen(trim($text)) ? $text : $this->renderChildren());
     $terms = array();
     // If there is a reasonable text given
     if (strlen($text)) {
         // If a list with search terms have been given ...
         if (is_array($search)) {
             $terms = $search;
             usort($terms, array($this, 'sortByLengthDesc'));
             // Else: If query hits have been given ...
         } elseif ($search instanceof \Tollwerk\TwLucenesearch\Domain\Model\QueryHits) {
             $terms = (array) $search->getHighlight($field);
             usort($terms, array($this, 'sortByLengthDesc'));
             // Else: If a lucene search query or a literal search term has been given
         } elseif ($search instanceof \Zend_Search_Lucene_Search_Query || strlen($search)) {
             // Instanciation of the lucene index service
             /* @var $indexerService \Tollwerk\TwLucenesearch\Service\Lucene */
             $indexerService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService('index', 'lucene');
             if ($indexerService instanceof \TYPO3\CMS\Core\Service\AbstractService) {
                 // Converting search term to lucene search query if necessary
                 if (!$search instanceof \Zend_Search_Lucene_Search_Query) {
                     $search = $indexerService->query($search);
                 }
                 // If there is a valid lucene search query available
                 if ($search instanceof \Zend_Search_Lucene_Search_Query) {
                     $searchHash = md5("{$search}");
                     if (!array_key_exists($searchHash, self::$_queryTermCache)) {
                         self::$_queryTermCache[$searchHash] = array();
                         foreach ($indexerService->getQueryTerms($search) as $termField => $fieldTerms) {
                             usort($fieldTerms, array($this, 'sortByLengthDesc'));
                             self::$_queryTermCache[$searchHash][$termField] = $fieldTerms;
                         }
                     }
                     $terms = self::$_queryTermCache[$searchHash];
                     $field = trim($field);
                     $terms = strlen($field) && array_key_exists($field, $terms) ? $terms[$field] : array();
                 }
             }
         }
     }
     // Check if the text has to be cropped ...
     $crop = $crop !== null && intval($crop) && strlen($text) > $crop ? intval($crop) : false;
     // If the text is more than 33% too long and highlighting has to be applied: Cropping also at the beginning of the text
     if ($crop && strlen($text) / $crop > 1.5 && count($terms)) {
         // Find the first highlighting in the text ...
         $firstHighlight = $this->firstMatch($terms, $text);
         // If there is at least one highlighting ...
         if ($firstHighlight !== false) {
             $beforeHighlight = strrev(trim(substr($text, 0, $firstHighlight)));
             // Keep the last 3 words before the highlighting ...
             $words = preg_split("%\\s+%", $beforeHighlight, 4);
             if (count($words) > 3) {
                 $beforeHighlight = strrev(implode(' ', array_slice($words, 0, 3)));
                 $text = $prepend . $beforeHighlight . ' ' . substr($text, $firstHighlight);
             }
         }
     }
     // If there are search terms to be highlighted in the text ...
     if (count($terms)) {
         $text = $this->highlight($terms, $text, $crop);
     }
     // If the text has to be cropped ...
     if ($crop) {
         if (TYPO3_MODE === 'BE') {
             $this->simulateFrontendEnvironment();
         }
         $respectHtml = true;
         $text = $respectHtml ? $this->contentObject->cropHTML($text, $crop . '|' . $append . '|1') : $this->contentObject->crop($text, $crop . '|' . $append . '|1');
         if (TYPO3_MODE === 'BE') {
             $this->resetFrontendEnvironment();
         }
     }
     return $text;
 }
 /**
  * Indexing the current frontend page
  * 
  * @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $fe			Frontend engine
  * @return void
  */
 protected function _indexTSFE(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $fe)
 {
     $this->_debug = (bool) $GLOBALS['TYPO3_CONF_VARS']['EXT']['extParams']['tw_lucenesearch']['debug'];
     // Debug switch: Output indexing contents only
     if ($this->_debug && array_key_exists('index_content_only', $_GET) && intval($_GET['index_content_only'])) {
         ob_end_clean();
         header('Content-Type: text/plain');
         die($this->_getPageBodytext($fe));
     }
     // If requested: Set the page title
     if (self::$_setPageTitle) {
         // If the page title has already been set ...
         if (preg_match("%\\<title(\\s+[^\\>]*)?\\>[^\\<]*\\<\\/title\\>%", $fe->content, $pageTitle)) {
             $fe->content = str_replace($pageTitle[0], '<title' . $pageTitle[1] . '>' . $fe->page['title'] . '</title>', $fe->content);
             // Else ...
         } else {
             $fe->content = preg_replace("%\\<head[^\\>]*\\>%", "\$0<title>" . $fe->page['title'] . '</title>', $fe->content);
         }
     }
     // If the current page should be indexed
     if (!intval($fe->page['no_search']) && self::indexConfig($fe, 'enable')) {
         // Instanciate the lucene index service
         /* @var $indexerService \Tollwerk\TwLucenesearch\Service\Lucene */
         $indexerService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService('index', 'lucene');
         if ($indexerService instanceof \TYPO3\CMS\Core\Service\AbstractService) {
             // Construct unique page reference
             $reference = $this->_getPageReference($fe);
             // Retrieve timestamp of the current page
             $timestamp = $this->_getPageTimestamp($fe);
             // Try to fetch a predecessor of the current page from the index
             $hit = null;
             $document = $indexerService->get(self::documentUid(strval($fe->id), self::PAGE, $reference), $hit);
             // If there exists a predecessor ...
             if ($document instanceof \Zend_Search_Lucene_Document) {
                 // If a timestamp could be retrieved for the current page and there have been no changes: Stop
                 if ((!$this->_debug || !array_key_exists('index_force_reindex', $_GET) || !intval($_GET['index_force_reindex'])) && $timestamp && $timestamp <= intval($document->getField('timestamp')->value)) {
                     return;
                     // Else: Deletion of the predecessor
                 } else {
                     $indexerService->delete($hit);
                 }
             }
             // Instanciate the index document
             $this->_csObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter');
             $bodytext = $this->_getPageBodytext($fe);
             $document = $this->_createDocument(array('type' => self::PAGE, 'id' => strval($fe->id), 'language' => strval($fe->lang), 'reference' => $reference, 'rootline' => implode(' ', $this->_getRootLine($fe)), 'title' => $this->_getPageTitle($fe), 'abstract' => $this->_getPageAbstract($fe, $bodytext), 'keywords' => $this->_getPageKeywords($fe), 'bodytext' => $bodytext, 'timestamp' => $timestamp));
             $indexerService->add($document);
         }
     }
 }
Example #18
0
 /**
  * 
  */
 public function initConfigs()
 {
     // If an event record has been added through Insert Records, set some defaults.
     if ($this->conf['displayCurrentRecord']) {
         $data =& $this->cObj->data;
         $this->conf['pidList'] = $data['pid'];
         $this->conf['view.']['allowedViews'] = 'event';
         $this->conf['getdate'] = $this->conf['_DEFAULT_PI_VARS.']['getdate'] = $data['start_date'];
         $this->conf['uid'] = $this->conf['_DEFAULT_PI_VARS.']['uid'] = $data['uid'];
         $this->conf['type'] = $this->conf['_DEFAULT_PI_VARS.']['type'] = 'tx_cal_phpicalendar';
         $this->conf['view'] = $this->conf['_DEFAULT_PI_VARS.']['view'] = 'event';
     }
     if (!$this->conf['dontListenToPiVars']) {
         $this->pi_setPiVarDefaults();
         // Set default piVars from TS
     }
     // Jan 18032006 start
     if ($this->cObj->data['pi_flexform']) {
         $this->pi_initPIflexForm();
         // Init and get the flexform data of the plugin
         $piFlexForm = $this->cObj->data['pi_flexform'];
         $this->updateConfWithFlexform($piFlexForm);
     }
     // apply stdWrap to pages and pidList
     $this->conf['pages'] = $this->cObj->stdWrap($this->conf['pages'], $this->conf['pages.']);
     $this->conf['pidList'] = $this->cObj->stdWrap($this->conf['pidList'], $this->conf['pidList.']);
     Controller::updateIfNotEmpty($this->conf['pages'], $this->cObj->data['pages']);
     // don't use "updateIfNotEmpty" here, as the default value of "recursive" is 0 and thus not empty and will always override TS settings.
     if ($this->cObj->data['recursive']) {
         $this->conf['recursive'] = $this->cObj->data['recursive'];
     }
     $this->conf['pidList'] = $this->pi_getPidList($this->conf['pages'] . ',' . $this->conf['pidList'], $this->conf['recursive']);
     if (!$this->conf['pidList'] || $this->conf['pidList'] == '') {
         $this->error = true;
         return '<b>Calendar error: please configure the pidList (calendar plugin -> startingpoints or plugin.tx_cal_controller.pidList or for ics in constants)</b>';
     }
     if ($this->conf['language']) {
         $this->LLkey = $this->conf['language'];
     }
     $tempScriptRelPath = $this->scriptRelPath;
     $this->scriptRelPath = $this->locallangPath;
     $this->pi_loadLL();
     $this->scriptRelPath = $tempScriptRelPath;
     $this->conf['cache'] = 1;
     $GLOBALS['TSFE']->addCacheTags(array('cal'));
     $location = Controller::convertLinkVarArrayToList($this->piVars['location_ids']);
     if ($this->piVars['view'] == $this->piVars['lastview']) {
         unset($this->piVars['lastview']);
     }
     if ($this->piVars['getdate'] == '') {
         $this->conf['getdate'] = date('Ymd');
     } else {
         $this->conf['getdate'] = intval($this->piVars['getdate']);
     }
     if ($this->piVars['jumpto']) {
         $dp = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\DateParser');
         $dp->parse($this->piVars['jumpto'], $this->conf['dateParserConf.']);
         $newGetdate = $dp->getDateObjectFromStack();
         $this->conf['getdate'] = $newGetdate->format('%Y%m%d');
         unset($this->piVars['getdate']);
         unset($this->piVars['jumpto']);
     }
     // date and strtotime should be ok here
     if ($this->conf['getdate'] <= date('Ymd', strtotime($this->conf['view.']['startLinkRange'])) || $this->conf['getdate'] >= date('Ymd', strtotime($this->conf['view.']['endLinkRange']))) {
         // Set additional META-Tag for google et al
         $GLOBALS['TSFE']->additionalHeaderData['cal'] = '<meta name="robots" content="index,nofollow" />';
         // Set / override no_search for current page-object
         $GLOBALS['TSFE']->page['no_search'] = 0;
     }
     if (!$this->conf['dontListenToPiVars']) {
         $this->conf['view'] = htmlspecialchars(strip_tags($this->piVars['view']));
         $this->conf['lastview'] = htmlspecialchars(strip_tags($this->piVars['lastview']));
         $this->conf['uid'] = intval($this->piVars['uid']);
         $this->conf['type'] = htmlspecialchars(strip_tags($this->piVars['type']));
         $this->conf['monitor'] = htmlspecialchars(strip_tags($this->piVars['monitor']));
         $this->conf['gettime'] = intval($this->piVars['gettime']);
         $this->conf['postview'] = intval($this->piVars['postview']);
         $this->conf['page_id'] = intval($this->piVars['page_id']);
         $this->conf['option'] = htmlspecialchars(strip_tags($this->piVars['option']));
         $this->conf['switch_calendar'] = intval($this->piVars['switch_calendar']);
         $this->conf['location'] = $location;
         $this->conf['preview'] = intval($this->piVars['preview']);
     }
     if (!is_array($this->conf['view.']['allowedViews'])) {
         $this->conf['view.']['allowedViews'] = array_unique(GeneralUtility::trimExplode(',', str_replace('~', ',', $this->conf['view.']['allowedViews'])));
     }
     // only merge customViews if not empty. Otherwhise the array with allowedViews will have empty entries which will end up in wrong behavior in the rightsServies, which is checking for the number of allowed views.
     if (!empty($this->conf['view.']['customViews'])) {
         $this->conf['view.']['allowedViews'] = array_unique(array_merge($this->conf['view.']['allowedViews'], GeneralUtility::trimExplode(',', $this->conf['view.']['customViews'], 1)));
     }
     $allowedViewsByViewPid = $this->getAllowedViewsByViewPid();
     $this->conf['view.']['allowedViewsToLinkTo'] = array_unique(array_merge($this->conf['view.']['allowedViews'], $allowedViewsByViewPid));
     // change by Franz: if there is no view parameter given (empty), fall back to the first allowed view
     // This is necessary when you're not passing the viewParameter within the URL and like to handle the correct views based on seperate pages for each view.
     if (!$this->conf['view'] && $this->conf['view.']['allowedViews'][0]) {
         $this->conf['view'] = $this->conf['view.']['allowedViews'][0];
     }
     $this->getDateTimeObject = new \TYPO3\CMS\Cal\Model\CalDate($this->conf['getdate'] . '000000');
     if ($this->getDateTimeObject->month > 12) {
         $this->getDateTimeObject->month = 12;
     } else {
         if ($this->getDateTimeObject->month < 1) {
             $this->getDateTimeObject->month = 1;
         }
     }
     while (!\TYPO3\CMS\Cal\Model\Pear\Date\Calc::isValidDate($this->getDateTimeObject->day, $this->getDateTimeObject->month, $this->getDateTimeObject->year)) {
         if ($this->getDateTimeObject->day > 28) {
             $this->getDateTimeObject->day--;
         } else {
             if ($this->getDateTimeObject->day < 1) {
                 $this->getDateTimeObject->day = 1;
             }
         }
     }
     $this->getDateTimeObject->setTZbyId('UTC');
     $this->conf['day'] = $this->getDateTimeObject->getDay();
     $this->conf['month'] = $this->getDateTimeObject->getMonth();
     $this->conf['year'] = $this->getDateTimeObject->getYear();
     Controller::initRegistry($this);
     $rightsObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'rightscontroller');
     $rightsObj = GeneralUtility::makeInstanceService('cal_rights_model', 'rights');
     $rightsObj->setDefaultSaveToPage();
     $modelObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'modelcontroller');
     $modelObj = new \TYPO3\CMS\Cal\Controller\ModelController();
     $viewObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'viewcontroller');
     $viewObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\ViewController');
     $this->checkCalendarAndCategory();
     $this->conf['view'] = $rightsObj->checkView($this->conf['view']);
     $this->pointerName = $this->conf['view.']['list.']['pageBrowser.']['pointer'] ? $this->conf['view.']['list.']['pageBrowser.']['pointer'] : $this->pointerName;
     // links to files will be rendered with an absolute path
     if (in_array($this->conf['view'], array('ics', 'rss', 'singl_ics'))) {
         $GLOBALS['TSFE']->absRefPrefix = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
     }
     $hookObjectsArr = $this->getHookObjectsArray('controllerClass');
     // Hook: configuration
     foreach ($hookObjectsArr as $hookObj) {
         if (method_exists($hookObj, 'configuration')) {
             $hookObj->configuration($this);
         }
     }
 }
 /**
  * Get the Value Description for this test
  * @see caretaker/trunk/classes/nodes/tx_caretaker_AbstractNode#getValueDescription()
  */
 public function getValueDescription()
 {
     $test_service = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService('caretaker_test_service', $this->testServiceType);
     if ($test_service) {
         return $test_service->getValueDescription();
     } else {
         return 'unknown service ' . $this->testServiceType;
     }
 }
 /**
  * @test
  */
 public function extractsMetaDataFromZipFile()
 {
     $service = GeneralUtility::makeInstanceService('metaExtract', 'zip');
     $service->setInputFile($this->testDocumentsPath . 'test-documents.zip', 'zip');
     $service->process();
     $metaData = $service->getOutput();
     $this->assertEquals('application/zip', $metaData['Content-Type']);
     $this->assertEquals('test-documents.zip', $metaData['resourceName']);
 }
Example #21
0
 /**
  * Substract the wanted Articles from stock. If you have more than one stock
  * which is handled to more than one Service please implement the Service due
  * to Reference on $wantedArticles so you can reduce this amount steplike.
  *
  * @param int $wantedArticles Amount of Articles which should reduced from stock
  * @param string $subType Sub type like file extensions or similar. Defined
  * 		by the service.
  * @param array $serviceChain List of service keys which should be exluded in
  * 		the search for a service. Array or comma list.
  *
  * @return bool Describes the result of going through the chains
  */
 public function reduceStock($wantedArticles = 0, $subType = '', array $serviceChain = array())
 {
     $counter = 0;
     while (is_object($serviceObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService('stockHandling', $subType, $serviceChain))) {
         $serviceChain .= ',' . $serviceObj->getServiceKey();
         if (method_exists($serviceObj, 'reduceStock')) {
             $serviceObj->reduceStock($wantedArticles, $this);
         }
     }
     if ($counter == 0) {
         return FALSE;
     }
     return TRUE;
 }
 /**
  * Processes Login data submitted by a form or params depending on the
  * passwordTransmissionStrategy
  *
  * @param array $loginData Login data array
  * @param string $passwordTransmissionStrategy Alternative passwordTransmissionStrategy. Used when authentication services wants to override the default.
  * @return array
  * @internal
  * @todo Define visibility
  */
 public function processLoginData($loginData, $passwordTransmissionStrategy = '')
 {
     $loginSecurityLevel = $GLOBALS['TYPO3_CONF_VARS'][$this->loginType]['loginSecurityLevel'] ? trim($GLOBALS['TYPO3_CONF_VARS'][$this->loginType]['loginSecurityLevel']) : 'normal';
     $passwordTransmissionStrategy = $passwordTransmissionStrategy ?: $loginSecurityLevel;
     if ($this->writeDevLog) {
         GeneralUtility::devLog('Login data before processing: ' . GeneralUtility::arrayToLogString($loginData), 'TYPO3\\CMS\\Core\\Authentication\\AbstractUserAuthentication');
     }
     $serviceChain = '';
     $subType = 'processLoginData' . $this->loginType;
     $authInfo = $this->getAuthInfoArray();
     $isLoginDataProcessed = FALSE;
     $processedLoginData = $loginData;
     while (is_object($serviceObject = GeneralUtility::makeInstanceService('auth', $subType, $serviceChain))) {
         $serviceChain .= ',' . $serviceObject->getServiceKey();
         $serviceObject->initAuth($subType, $loginData, $authInfo, $this);
         $serviceResult = $serviceObject->processLoginData($processedLoginData, $passwordTransmissionStrategy);
         if (!empty($serviceResult)) {
             $isLoginDataProcessed = TRUE;
             // If the service returns >=200 then no more processing is needed
             if ((int) $serviceResult >= 200) {
                 unset($serviceObject);
                 break;
             }
         }
         unset($serviceObject);
     }
     if ($isLoginDataProcessed) {
         $loginData = $processedLoginData;
         if ($this->writeDevLog) {
             GeneralUtility::devLog('Processed login data: ' . GeneralUtility::arrayToLogString($processedLoginData), 'TYPO3\\CMS\\Core\\Authentication\\AbstractUserAuthentication');
         }
     }
     return $loginData;
 }
Example #23
0
 protected function getMarker(&$template, &$sims, &$rems, &$wrapped, $view = '', $base = 'view')
 {
     $conf =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'conf');
     if ($view == '' && $base == 'view') {
         $view = !empty($conf['alternateRenderingView']) && is_array($conf[$base . '.'][$conf['alternateRenderingView'] . '.']) ? $conf['alternateRenderingView'] : $conf['view'];
     }
     preg_match_all('!\\<\\!--[a-zA-Z0-9 ]*###([A-Z0-9_-|]*)\\###[a-zA-Z0-9 ]*-->!is', $template, $match);
     $allMarkers = array_unique($match[1]);
     foreach ($allMarkers as $marker) {
         switch ($marker) {
             default:
                 if (preg_match('/MODULE__([A-Z0-9_-])*/', $marker)) {
                     $module = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService(substr($marker, 8), 'module');
                     if (is_object($module)) {
                         $rems['###' . $marker . '###'] = $module->start($this);
                     }
                 }
                 $funcFromMarker = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($marker)))) . 'Marker';
                 if (method_exists($this, $funcFromMarker)) {
                     $this->{$funcFromMarker}($template, $sims, $rems, $wrapped, $view);
                 }
                 break;
         }
     }
     preg_match_all('!\\###([A-Z0-9_-|]*)\\###!is', $template, $match);
     $allSingleMarkers = array_unique($match[1]);
     $allSingleMarkers = array_diff($allSingleMarkers, $allMarkers);
     foreach ($allSingleMarkers as $marker) {
         switch ($marker) {
             case 'ACTIONURL':
             case 'L_ENTER_EMAIL':
             case 'L_CAPTCHA_TEXT':
             case 'CAPTCHA_SRC':
             case 'IMG_PATH':
                 // do nothing
                 break;
             default:
                 if (preg_match('/.*_LABEL$/', $marker) || preg_match('/^L_.*/', $marker)) {
                     continue;
                 }
                 $funcFromMarker = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($marker)))) . 'Marker';
                 if (method_exists($this, $funcFromMarker)) {
                     $this->{$funcFromMarker}($template, $sims, $rems, $wrapped, $view);
                 } else {
                     if (preg_match('/MODULE__([A-Z0-9_-|])*/', $marker)) {
                         $tmp = explode('___', substr($marker, 8));
                         $modules[$tmp[0]][] = $tmp[1];
                     } else {
                         if ($conf[$base . '.'][$view . '.'][strtolower($marker)]) {
                             $current = '';
                             // first, try to fill $current with a method of the model matching the markers name
                             $functionName = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($marker))));
                             if (method_exists($this, $functionName)) {
                                 $tmp = $this->{$functionName}();
                                 if (!is_object($tmp) && !is_array($tmp)) {
                                     $current = $tmp;
                                 }
                                 unset($tmp);
                             }
                             $cObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'local_cobj');
                             $cObj->setCurrentVal($current);
                             $sims['###' . $marker . '###'] = $cObj->cObjGetSingle($conf[$base . '.'][$view . '.'][strtolower($marker)], $conf[$base . '.'][$view . '.'][strtolower($marker) . '.']);
                         }
                     }
                 }
                 break;
         }
     }
     // se alternativ way of MODULE__MARKER
     // yntax: ###MODULE__MODULENAME___MODULEMARKER###
     // ollect them, call each Modul, retrieve Array of Markers and replace them
     // his allows to spread the Module-Markers over complete template instead of one time
     // lso work with old way of MODULE__-Marker
     if (is_array($modules)) {
         // ODULE-MARKER FOUND
         foreach ($modules as $themodule => $markerArray) {
             $module = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService($themodule, 'module');
             if (is_object($module)) {
                 if ($markerArray[0] == '') {
                     $sims['###MODULE__' . $themodule . '###'] = $module->start($this);
                     // ld way
                 } else {
                     $moduleMarker = $module->start($this);
                     // get Markerarray from Module
                     foreach ($moduleMarker as $key => $val) {
                         $sims['###MODULE__' . $themodule . '___' . $key . '###'] = $val;
                     }
                 }
             }
         }
     }
     $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_base_model', 'searchForObjectMarker', 'model');
     // Hook: postSearchForObjectMarker
     foreach ($hookObjectsArr as $hookObj) {
         if (method_exists($hookObj, 'postSearchForObjectMarker')) {
             $hookObj->postSearchForObjectMarker($this, $template, $sims, $rems, $wrapped, $view);
         }
     }
 }
 /**
  * Will select all fe_groups records that the current fe_user is member of
  * and which groups are also allowed in the current domain.
  * It also accumulates the TSconfig for the fe_user/fe_groups in ->TSdataArray
  *
  * @return integer Returns the number of usergroups for the frontend users (if the internal user record exists and the usergroup field contains a value)
  * @todo Define visibility
  */
 public function fetchGroupData()
 {
     $this->TSdataArray = array();
     $this->userTS = array();
     $this->userTSUpdated = FALSE;
     $this->groupData = array('title' => array(), 'uid' => array(), 'pid' => array());
     // Setting default configuration:
     $this->TSdataArray[] = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultUserTSconfig'];
     // Get the info data for auth services
     $authInfo = $this->getAuthInfoArray();
     if ($this->writeDevLog) {
         if (is_array($this->user)) {
             GeneralUtility::devLog('Get usergroups for user: '******'TYPO3\\CMS\\Frontend\\Authentication\\FrontendUserAuthentication');
         } else {
             GeneralUtility::devLog('Get usergroups for "anonymous" user', 'TYPO3\\CMS\\Frontend\\Authentication\\FrontendUserAuthentication');
         }
     }
     $groupDataArr = array();
     // Use 'auth' service to find the groups for the user
     $serviceChain = '';
     $subType = 'getGroups' . $this->loginType;
     while (is_object($serviceObj = GeneralUtility::makeInstanceService('auth', $subType, $serviceChain))) {
         $serviceChain .= ',' . $serviceObj->getServiceKey();
         $serviceObj->initAuth($subType, array(), $authInfo, $this);
         $groupData = $serviceObj->getGroups($this->user, $groupDataArr);
         if (is_array($groupData) && count($groupData)) {
             // Keys in $groupData should be unique ids of the groups (like "uid") so this function will override groups.
             $groupDataArr = GeneralUtility::array_merge($groupDataArr, $groupData);
         }
         unset($serviceObj);
     }
     if ($this->writeDevLog && $serviceChain) {
         GeneralUtility::devLog($subType . ' auth services called: ' . $serviceChain, 'TYPO3\\CMS\\Frontend\\Authentication\\FrontendUserAuthentication');
     }
     if ($this->writeDevLog && !count($groupDataArr)) {
         GeneralUtility::devLog('No usergroups found by services', 'TYPO3\\CMS\\Frontend\\Authentication\\FrontendUserAuthentication');
     }
     if ($this->writeDevLog && count($groupDataArr)) {
         GeneralUtility::devLog(count($groupDataArr) . ' usergroup records found by services', 'TYPO3\\CMS\\Frontend\\Authentication\\FrontendUserAuthentication');
     }
     // Use 'auth' service to check the usergroups if they are really valid
     foreach ($groupDataArr as $groupData) {
         // By default a group is valid
         $validGroup = TRUE;
         $serviceChain = '';
         $subType = 'authGroups' . $this->loginType;
         while (is_object($serviceObj = GeneralUtility::makeInstanceService('auth', $subType, $serviceChain))) {
             $serviceChain .= ',' . $serviceObj->getServiceKey();
             $serviceObj->initAuth($subType, array(), $authInfo, $this);
             if (!$serviceObj->authGroup($this->user, $groupData)) {
                 $validGroup = FALSE;
                 if ($this->writeDevLog) {
                     GeneralUtility::devLog($subType . ' auth service did not auth group: ' . GeneralUtility::arrayToLogString($groupData, 'uid,title'), 'TYPO3\\CMS\\Frontend\\Authentication\\FrontendUserAuthentication', 2);
                 }
                 break;
             }
             unset($serviceObj);
         }
         unset($serviceObj);
         if ($validGroup && (string) $groupData['uid'] !== '') {
             $this->groupData['title'][$groupData['uid']] = $groupData['title'];
             $this->groupData['uid'][$groupData['uid']] = $groupData['uid'];
             $this->groupData['pid'][$groupData['uid']] = $groupData['pid'];
             $this->groupData['TSconfig'][$groupData['uid']] = $groupData['TSconfig'];
         }
     }
     if (count($this->groupData) && count($this->groupData['TSconfig'])) {
         // TSconfig: collect it in the order it was collected
         foreach ($this->groupData['TSconfig'] as $TSdata) {
             $this->TSdataArray[] = $TSdata;
         }
         $this->TSdataArray[] = $this->user['TSconfig'];
         // Sort information
         ksort($this->groupData['title']);
         ksort($this->groupData['uid']);
         ksort($this->groupData['pid']);
     }
     return count($this->groupData['uid']) ?: 0;
 }