예제 #1
2
 /**
  * Gets our attached files as an array of arrays with the elements "name"
  * and "size" of the attached file.
  *
  * The displayed file name is relative to the tx_seminars upload directory
  * and is linked to the actual file's URL.
  *
  * The file size will have, depending on the file size, one of the following
  * units appended: K for Kilobytes, M for Megabytes and G for Gigabytes.
  *
  * The returned array will be sorted like the files are sorted in the back-
  * end form.
  *
  * If this event is an event date, this function will return both the
  * topic's file and the date's files (in that order).
  *
  * Note: This functions' return values already are htmlspecialchared.
  *
  * @param tslib_pibase $plugin a tslib_pibase object for a live page
  *
  * @return array[] an array of arrays with the elements "name" and
  *               "size" of the attached file, will be empty if
  *               there are no attached files
  */
 public function getAttachedFiles(tslib_pibase $plugin)
 {
     if (!$this->hasAttachedFiles()) {
         return array();
     }
     if ($this->isTopicOkay()) {
         $filesFromTopic = $this->topic->getAttachedFiles($plugin);
     } else {
         $filesFromTopic = array();
     }
     $result = $filesFromTopic;
     $uploadFolderPath = PATH_site . 'uploads/tx_seminars/';
     $uploadFolderUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 'uploads/tx_seminars/';
     $attachedFiles = t3lib_div::trimExplode(',', $this->getRecordPropertyString('attached_files'), TRUE);
     foreach ($attachedFiles as $attachedFile) {
         $matches = array();
         preg_match('/\\.(\\w+)$/', basename($attachedFile), $matches);
         $result[] = array('name' => $plugin->cObj->typoLink(htmlspecialchars(basename($attachedFile)), array('parameter' => $uploadFolderUrl . $attachedFile)), 'type' => htmlspecialchars(isset($matches[1]) ? $matches[1] : 'none'), 'size' => t3lib_div::formatSize(filesize($uploadFolderPath . $attachedFile)));
     }
     return $result;
 }
예제 #2
0
 /**
  * Gets the CSS classes (space-separated) for the Vacancies TD.
  *
  * @param tx_seminars_seminar $seminar the current seminar object
  *
  * @return string class attribute value filled with a list a space-separated CSS classes
  */
 public function getVacanciesClasses(tx_seminars_seminar $seminar)
 {
     if (!$seminar->needsRegistration() || !$seminar->hasDate() && !$this->configGetter->getConfValueBoolean('allowRegistrationForEventsWithoutDate')) {
         return '';
     }
     $classes = array();
     if ($seminar->hasDate() && $seminar->hasStarted()) {
         $classes[] = 'event-begin-date-over';
     }
     if ($seminar->hasVacancies()) {
         $classes[] = 'vacancies-available';
         if ($seminar->hasUnlimitedVacancies()) {
             $classes[] = 'vacancies-unlimited';
         } else {
             $classes[] = 'vacancies-' . $seminar->getVacancies();
         }
     } else {
         $classes[] = 'vacancies-0';
         if ($seminar->hasRegistrationQueue()) {
             $classes[] = 'has-registration-queue';
         }
     }
     // We add this class in addition to the number of vacancies so that
     // user stylesheets still can use the number of vacancies even for
     // events for which the registration deadline is over.
     if ($seminar->hasDate() && $seminar->isRegistrationDeadlineOver()) {
         $classes[] = 'registration-deadline-over';
     }
     $prefixedClasses = array_map(array($this, 'pi_getClassName'), $classes);
     return ' ' . implode(' ', $prefixedClasses);
 }
예제 #3
0
파일: Event.php 프로젝트: kurtkk/seminars
 /**
  * Limits the bag to date event records of the same topic as the event
  * given in the first parameter $event.
  *
  * @param tx_seminars_seminar $event the date or topic object to find other dates of the same topic for
  *
  * @return void
  */
 public function limitToOtherDatesForTopic(tx_seminars_seminar $event)
 {
     if (!$event->isEventDate() && !$event->isEventTopic()) {
         throw new InvalidArgumentException('The first parameter $event must be either a date or a topic record.', 1333292764);
     }
     $this->whereClauseParts['other_dates'] = '(' . 'tx_seminars_seminars.topic = ' . $event->getTopicUid() . ' AND object_type = ' . tx_seminars_Model_Event::TYPE_DATE . ' AND uid <> ' . $event->getUid() . ')';
 }
예제 #4
0
 /**
  * Creates a link to the registrations page, showing the attendees for the
  * given event UID.
  *
  * @param tx_seminars_seminar $event
  *        the event to show the registrations for, must be >= 0
  *
  * @return string the URL to the registrations tab with the registration for
  *                the current event, will not be empty
  */
 private function createEventRegistrationsLink(tx_seminars_seminar $event)
 {
     $pageData = $this->page->getPageData();
     $url = t3lib_BEfunc::getModuleUrl(self::MODULE_NAME, array('id' => $pageData['uid'], 'subModule' => '2', 'eventUid' => $event->getUid()));
     return '<a href="' . htmlspecialchars($url) . '">' . $GLOBALS['LANG']->getLL('label_show_event_registrations') . '</a>';
 }
 /**
  * Sets this registration's data if this registration is newly created instead of from a DB query.
  *
  * This function must be called directly after construction or this object will not be usable.
  *
  * @param tx_seminars_seminar $seminar the seminar object (that's the seminar we would like to register for)
  * @param int $userUid UID of the FE user who wants to sign up
  * @param array $registrationData associative array with the registration data the user has just entered, may be empty
  *
  * @return void
  */
 public function setRegistrationData(tx_seminars_seminar $seminar, $userUid, array $registrationData)
 {
     $this->seminar = $seminar;
     $this->recordData = array();
     $this->recordData['seminar'] = $seminar->getUid();
     $this->recordData['user'] = $userUid;
     $this->recordData['registration_queue'] = !$seminar->hasVacancies() ? 1 : 0;
     $seats = (int) $registrationData['seats'];
     if ($seats < 1) {
         $seats = 1;
     }
     $this->recordData['seats'] = $seats;
     $this->recordData['registered_themselves'] = $registrationData['registered_themselves'] ? 1 : 0;
     $availablePrices = $seminar->getAvailablePrices();
     // If no (available) price is selected, use the first price by default.
     $selectedPrice = isset($registrationData['price']) && $seminar->isPriceAvailable($registrationData['price']) ? $registrationData['price'] : key($availablePrices);
     $this->recordData['price'] = $availablePrices[$selectedPrice]['caption'];
     $this->recordData['total_price'] = $seats * $availablePrices[$selectedPrice]['amount'];
     $this->recordData['attendees_names'] = $registrationData['attendees_names'];
     $this->recordData['kids'] = $registrationData['kids'];
     $methodOfPayment = $registrationData['method_of_payment'];
     // Auto-select the only payment method if no payment method has been
     // selected, there actually is anything to pay and only one payment
     // method is provided.
     if (!$methodOfPayment && $this->recordData['total_price'] > 0.0 && $seminar->getNumberOfPaymentMethods() == 1) {
         $rows = tx_oelib_db::selectMultiple('uid', 'tx_seminars_payment_methods, tx_seminars_seminars_payment_methods_mm', 'tx_seminars_payment_methods.uid = tx_seminars_seminars_payment_methods_mm.uid_foreign ' . 'AND tx_seminars_seminars_payment_methods_mm.uid_local = ' . $seminar->getTopicUid() . tx_oelib_db::enableFields('tx_seminars_payment_methods'), '', 'tx_seminars_seminars_payment_methods_mm.sorting');
         $methodOfPayment = $rows[0]['uid'];
     }
     $this->recordData['method_of_payment'] = $methodOfPayment;
     $this->recordData['account_number'] = $registrationData['account_number'];
     $this->recordData['bank_code'] = $registrationData['bank_code'];
     $this->recordData['bank_name'] = $registrationData['bank_name'];
     $this->recordData['account_owner'] = $registrationData['account_owner'];
     $this->recordData['company'] = $registrationData['company'];
     $this->recordData['gender'] = $registrationData['gender'];
     $this->recordData['name'] = $registrationData['name'];
     $this->recordData['address'] = $registrationData['address'];
     $this->recordData['zip'] = $registrationData['zip'];
     $this->recordData['city'] = $registrationData['city'];
     $this->recordData['country'] = $registrationData['country'];
     $this->recordData['telephone'] = $registrationData['telephone'];
     $this->recordData['email'] = $registrationData['email'];
     $this->lodgings = isset($registrationData['lodgings']) && is_array($registrationData['lodgings']) ? $registrationData['lodgings'] : array();
     $this->recordData['lodgings'] = count($this->lodgings);
     $this->foods = isset($registrationData['foods']) && is_array($registrationData['foods']) ? $registrationData['foods'] : array();
     $this->recordData['foods'] = count($this->foods);
     $this->checkboxes = isset($registrationData['checkboxes']) && is_array($registrationData['checkboxes']) ? $registrationData['checkboxes'] : array();
     $this->recordData['checkboxes'] = count($this->checkboxes);
     $this->recordData['interests'] = $registrationData['interests'];
     $this->recordData['expectations'] = $registrationData['expectations'];
     $this->recordData['background_knowledge'] = $registrationData['background_knowledge'];
     $this->recordData['accommodation'] = $registrationData['accommodation'];
     $this->recordData['food'] = $registrationData['food'];
     $this->recordData['known_from'] = $registrationData['known_from'];
     $this->recordData['notes'] = $registrationData['notes'];
     $this->recordData['pid'] = $this->seminar->hasAttendancesPid() ? $this->seminar->getAttendancesPid() : $this->getConfValueInteger('attendancesPID');
     $this->processAdditionalRegistrationData($registrationData);
     if ($this->isOk()) {
         // Stores the user data in $this->userData.
         $this->retrieveUserData();
         $this->createTitle();
     }
 }
 /**
  * Returns the unregistration notice for the notification mails.
  *
  * @param tx_seminars_seminar $event the event to get the unregistration deadline from
  *
  * @return string the unregistration notice with the event's unregistration deadline, will not be empty
  */
 protected function getUnregistrationNotice(tx_seminars_seminar $event)
 {
     $unregistrationDeadline = $event->getUnregistrationDeadlineFromModelAndConfiguration();
     return sprintf($this->translate('email_unregistrationNotice'), strftime($this->getConfValueString('dateFormatYMD'), $unregistrationDeadline));
 }
 /**
  * Sets a string element of the record data array (and trims it).
  *
  * @param string $key key of the element to set (must be non-empty)
  * @param string $value the value that will be written into the element
  *
  * @return void
  */
 public function setRecordPropertyString($key, $value)
 {
     parent::setRecordPropertyString($key, $value);
 }
 /**
  * Creates an e-mail introduction with the given event's title, date and
  * time prepended with the given introduction string.
  *
  * @param string $introductionBegin
  *        the start of the introduction, must not be empty and contain %s as
  *        place to fill the title of the event in
  * @param tx_seminars_seminar $event the event the introduction is for
  *
  * @return string the introduction with the event's title and if available
  *                date and time, will not be empty
  */
 public function createIntroduction($introductionBegin, tx_seminars_seminar $event)
 {
     $result = sprintf($introductionBegin, $event->getTitle());
     if (!$event->hasDate()) {
         return $result;
     }
     $result .= ' ' . sprintf($this->translator->translate('email_eventDate'), $event->getDate('-'));
     if ($event->hasTime() && !$event->hasTimeslots()) {
         $timeToLabel = $this->translator->translate('email_timeTo');
         $time = $event->getTime(' ' . $timeToLabel . ' ');
         $label = ' ' . (!$event->isOpenEnded() ? $this->translator->translate('email_timeFrom') : $this->translator->translate('email_timeAt'));
         $result .= sprintf($label, $time);
     }
     return $result;
 }
예제 #9
0
 /**
  * Retrieves data from an object and returns that data as an array of values. The individual values are already wrapped in
  * double quotes, with the contents having all quotes escaped.
  *
  * @param tx_seminars_seminar $event object that will deliver the data
  *
  * @return string[] the data for the keys provided in $keys (may be empty)
  */
 protected function createCsvColumnsForEvent(tx_seminars_seminar $event)
 {
     $csvLines = array();
     foreach ($this->getFieldKeys() as $key) {
         $csvLines[] = $this->escapeFieldForCsv($event->getEventData($key));
     }
     return $csvLines;
 }
 /**
  * Checks whether the CSV file should be added to the e-mail.
  *
  * @param tx_seminars_seminar $event the event to send the e-mail for
  *
  * @return bool TRUE if the CSV file should be added, FALSE otherwise
  */
 private function shouldCsvFileBeAdded(tx_seminars_seminar $event)
 {
     return tx_oelib_ConfigurationRegistry::get('plugin.tx_seminars')->getAsBoolean('addRegistrationCsvToOrganizerReminderMail') && $event->getAttendances() > 0;
 }
예제 #11
0
 /**
  * @test
  */
 public function getAttachedFilesForDateWithFileAndTopicWithFileReturnsFilesFromTopicAndThenDate()
 {
     $this->createPi1();
     $topicDummyFile = $this->testingFramework->createDummyFile();
     $topicDummyFileName = $this->testingFramework->getPathRelativeToUploadDirectory($topicDummyFile);
     $topicRecordUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('object_type' => tx_seminars_Model_Event::TYPE_TOPIC, 'attached_files' => $topicDummyFileName));
     $dateDummyFile = $this->testingFramework->createDummyFile();
     $dateDummyFileName = $this->testingFramework->getPathRelativeToUploadDirectory($dateDummyFile);
     $dateRecordUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('object_type' => tx_seminars_Model_Event::TYPE_DATE, 'attached_files' => $dateDummyFileName, 'topic' => $topicRecordUid));
     $eventDate = new tx_seminars_seminar($dateRecordUid);
     $attachedFiles = $eventDate->getAttachedFiles($this->pi1);
     self::assertContains($topicDummyFileName, $attachedFiles[0]['name']);
     self::assertContains($dateDummyFileName, $attachedFiles[1]['name']);
 }
 /**
  * Creates an e-mail introduction with the given event's title, date and
  * time prepended with the given introduction string.
  *
  * @param string $introductionBegin
  *        the start of the introduction, must not be empty and contain %s as
  *        place to fill the title of the event in
  * @param tx_seminars_seminar $event the event the introduction is for
  *
  * @return string the introduction with the event's title and if available date and time, will not be empty
  *
  * @throws \InvalidArgumentException
  */
 public function createIntroduction($introductionBegin, tx_seminars_seminar $event)
 {
     if ($introductionBegin === '') {
         throw new \InvalidArgumentException('$introductionBegin must not be empty.', 1440109640);
     }
     $result = sprintf($introductionBegin, $event->getTitle());
     if (!$event->hasDate()) {
         return $result;
     }
     $result .= ' ' . sprintf($this->translator->translate('email_eventDate'), $event->getDate('-'));
     if ($event->hasTime() && !$event->hasTimeslots()) {
         $timeToLabelWithPlaceholders = $this->translator->translate('email_timeTo');
         $time = $event->getTime(' ' . $timeToLabelWithPlaceholders . ' ');
         $label = ' ' . (!$event->isOpenEnded() ? $this->translator->translate('email_timeFrom') : $this->translator->translate('email_timeAt'));
         $result .= sprintf($label, $time);
     }
     return $result;
 }