/**
  * Checks whether the UID provided as the second argument when starting the
  * CLI script actually exists in the "pages" table. If the page UID is
  * valid, defines this UID as the one where to take the configuration from,
  * otherwise throws an exception.
  *
  * @throws InvalidArgumentException if no page UID or an invalid UID was provided
  *
  * @return void
  */
 public function setConfigurationPage()
 {
     if (!isset($_SERVER['argv'][1])) {
         throw new InvalidArgumentException('Please provide the UID for the page with the configuration for the CLI module.', 1333292959);
     }
     $uid = (int) $_SERVER['argv'][1];
     if ($uid == 0 || tx_oelib_db::selectSingle('COUNT(*) AS number', 'pages', 'uid = ' . $uid) != array('number' => 1)) {
         throw new InvalidArgumentException('The provided UID for the page with the configuration was ' . $_SERVER['argv'][1] . ', which was not found to be a UID of an existing page. Please provide the UID of an existing page.', 1333292966);
     }
     tx_oelib_PageFinder::getInstance()->setPageUid($uid);
 }
 /**
  * The constructor.
  *
  * @param int $registrationUid UID of the registration record, must be > 0
  */
 public function __construct($registrationUid = 0)
 {
     if ($registrationUid > 0) {
         $dbResult = tx_oelib_db::select('*', $this->tableName, 'uid = ' . $registrationUid);
     } else {
         $dbResult = FALSE;
     }
     $contentObject = new tslib_cObj();
     $contentObject->start(array());
     parent::__construct($contentObject, $dbResult);
 }
Пример #3
0
 public function testCreateFromDbResult()
 {
     $dbResult = tx_oelib_db::select('*', 'tx_seminars_test', 'uid = ' . $this->fixtureUid);
     $test = new tx_seminars_tests_fixtures_OldModel_Testing(0, $dbResult);
     self::assertTrue($test->isOk());
 }
Пример #4
0
 /**
  * Returns the places associated with this event.
  *
  * @return Tx_Oelib_List with the models for the places of this event, will be empty if this event has no places
  */
 public function getPlaces()
 {
     if (!$this->hasPlace()) {
         /** @var Tx_Oelib_List $list */
         $list = t3lib_div::makeInstance('tx_oelib_List');
         return $list;
     }
     $places = tx_oelib_db::selectMultiple('uid, title, address, zip, city, country, homepage, directions', 'tx_seminars_sites, tx_seminars_seminars_place_mm', 'uid_local = ' . $this->getUid() . ' AND uid = uid_foreign' . tx_oelib_db::enableFields('tx_seminars_sites'));
     /** @var tx_seminars_Mapper_Place $mapper */
     $mapper = t3lib_div::makeInstance('tx_seminars_Mapper_Place');
     return $mapper->getListOfModels($places);
 }
 /**
  * Gets a LF-separated list of the titles of records referenced by this record.
  *
  * @param string $foreignTable the name of the foreign table (must not be empty), must have the fields uid and title
  * @param string $mmTable the name of the m:m table, having the fields uid_local, uid_foreign and sorting, must not be empty
  *
  * @return string the titles of the referenced records separated by LF,
  *                might be empty if no records are referenced
  */
 private function getMmRecords($foreignTable, $mmTable)
 {
     $result = '';
     $dbResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery('title, sorting', $foreignTable . ', ' . $mmTable, 'uid_local = ' . $this->getUid() . ' AND uid_foreign = uid' . tx_oelib_db::enableFields($foreignTable), '', 'sorting');
     if ($dbResult) {
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($dbResult)) {
             if ($result !== '') {
                 $result .= LF;
             }
             $result .= $row['title'];
         }
     }
     return $result;
 }
Пример #6
0
    /**
     * Limits the bag to registrations to which a non-deleted FE user record
     * exists.
     *
     * @return void
     */
    public function limitToExistingUsers()
    {
        $this->whereClauseParts['existingUsers'] = 'EXISTS (
			SELECT * FROM fe_users WHERE ' . ' fe_users.uid = tx_seminars_attendances.user' . tx_oelib_db::enableFields('fe_users') . ')';
    }
Пример #7
0
 /**
  * Creates a list of places with all places that are assigned to at least
  * one event.
  *
  * The list of places is stored in the member variable $this->places.
  *
  * Before this function is called, it must be assured that the seminar bag
  * is not empty.
  *
  * @return void
  */
 private function collectPlaces()
 {
     if ($this->seminarBag->isEmpty()) {
         throw new BadMethodCallException('The seminar bag must not be empty when calling this function.', 1333293276);
     }
     if ($this->places) {
         return;
     }
     $dataOfPlaces = tx_oelib_db::selectMultiple('tx_seminars_sites.*', 'tx_seminars_sites, tx_seminars_seminars_place_mm', 'tx_seminars_sites.uid = tx_seminars_seminars_place_mm.uid_foreign ' . 'AND tx_seminars_seminars_place_mm.uid_local IN (' . $this->seminarBag->getUids() . ')');
     /** @var tx_seminars_Mapper_Place $mapper */
     $mapper = tx_oelib_MapperRegistry::get('tx_seminars_Mapper_Place');
     $this->places = $mapper->getListOfModels($dataOfPlaces);
 }
Пример #8
0
 /**
  * Creates a registration in $this->registration from the database record
  * with the UID specified in the parameter $registrationUid.
  * If the registration cannot be created, $this->registration will be NULL,
  * and this function will return FALSE.
  *
  * @param int $registrationUid a registration UID
  *
  * @return bool TRUE if the registration UID is valid and the object has been created, FALSE otherwise
  */
 public function createRegistration($registrationUid)
 {
     $result = FALSE;
     if (tx_seminars_OldModel_Abstract::recordExists($registrationUid, 'tx_seminars_attendances')) {
         $dbResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_seminars_attendances', 'tx_seminars_attendances.uid = ' . $registrationUid . tx_oelib_db::enableFields('tx_seminars_attendances'));
         $this->registration = t3lib_div::makeInstance('tx_seminars_registration', $this->cObj, $dbResult);
         if ($dbResult !== FALSE) {
             $GLOBALS['TYPO3_DB']->sql_free_result($dbResult);
         }
         $result = $this->registration->isOk();
         if (!$result) {
             $this->registration = NULL;
         }
     } else {
         $this->registration = NULL;
     }
     return $result;
 }
 /**
  * Gets our place as plain text (just the name).
  * Returns a localized string "will be announced" if the time slot has no
  * place set.
  *
  * @return string our places or a localized string "will be announced" if this timeslot has no place assigned
  *
  * @throws tx_oelib_Exception_Database
  * @throws tx_oelib_Exception_NotFound
  */
 public function getPlaceShort()
 {
     if (!$this->hasPlace()) {
         return $this->translate('message_willBeAnnounced');
     }
     $dbResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery('title', 'tx_seminars_sites', 'uid=' . $this->getPlace() . tx_oelib_db::enableFields('tx_seminars_sites'));
     if (!$dbResult) {
         throw new tx_oelib_Exception_Database();
     }
     $dbResultRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($dbResult);
     $GLOBALS['TYPO3_DB']->sql_free_result($dbResult);
     if (!$dbResultRow) {
         throw new tx_oelib_Exception_NotFound('The related place with the UID ' . $this->getPlace() . ' could not be found in the DB.', 1333291925);
     }
     return $dbResultRow['title'];
 }
Пример #10
0
 /**
  * Returns the next upcoming event.
  *
  * @return tx_seminars_Model_Event the next upcoming event
  *
  * @throws tx_oelib_Exception_NotFound
  */
 public function findNextUpcoming()
 {
     $whereClause = $this->getUniversalWhereClause() . ' AND cancelled <> ' . tx_seminars_seminar::STATUS_CANCELED . ' AND object_type <> ' . tx_seminars_Model_Event::TYPE_TOPIC . ' AND begin_date > ' . $GLOBALS['SIM_ACCESS_TIME'];
     try {
         $row = tx_oelib_db::selectSingle($this->columns, $this->tableName, $whereClause, '', 'begin_date ASC');
     } catch (tx_oelib_Exception_EmptyQueryResult $exception) {
         throw new tx_oelib_Exception_NotFound();
     }
     return $this->getModel($row);
 }
Пример #11
0
 /**
  * @test
  */
 public function createRegistrationCallsSeminarRegistrationCreatedHook()
 {
     $this->createAndLoginFrontEndUser();
     $hookClass = uniqid('tx_registrationHook');
     $hook = $this->getMock($hookClass, array('seminarRegistrationCreated'));
     // We cannot test for the expected parameters because the registration
     // instance does not exist yet at this point.
     $hook->expects(self::once())->method('seminarRegistrationCreated');
     $GLOBALS['T3_VAR']['getUserObj'][$hookClass] = $hook;
     $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['seminars']['registration'][$hookClass] = $hookClass;
     $plugin = new tx_seminars_FrontEnd_DefaultController();
     $plugin->cObj = $GLOBALS['TSFE']->cObj;
     $fixture = $this->getMock('tx_seminars_registrationmanager', array('notifyAttendee', 'notifyOrganizers', 'sendAdditionalNotification', 'setRegistrationData'));
     $fixture->createRegistration($this->seminar, array(), $plugin);
     $uid = $fixture->getRegistration()->getUid();
     tx_oelib_db::delete('tx_seminars_attendances', 'uid = ' . $uid);
 }
Пример #12
0
 /**
  * Retrieves the number of objects this bag would hold if the LIMIT part of
  * the query would not have been used.
  *
  * @return int the total number of objects in this bag without any
  *                 limit, may be zero
  */
 public function countWithoutLimit()
 {
     if ($this->hasCountWithoutLimit) {
         return $this->countWithoutLimit;
     }
     $dbResultRow = tx_oelib_db::selectSingle('COUNT(*) AS number ', $this->dbTableName . $this->additionalTableNames, $this->queryParameters . $this->enabledFieldsQuery);
     $this->countWithoutLimit = $dbResultRow['number'];
     $this->hasCountWithoutLimit = TRUE;
     return $this->countWithoutLimit;
 }
Пример #13
0
 /**
  * Retrieves a record from the database.
  *
  * The record is retrieved from $this->tableName. Therefore $this->tableName
  * has to be set before calling this method.
  *
  * @param int $uid the UID of the record to retrieve from the DB
  * @param bool $allowHiddenRecords whether to allow hidden records
  *
  * @return resource MySQL result pointer (of SELECT query) object, will be FALSE if the UID is invalid
  */
 protected function retrieveRecord($uid, $allowHiddenRecords = FALSE)
 {
     if (!self::recordExists($uid, $this->tableName, $allowHiddenRecords)) {
         return FALSE;
     }
     return $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->tableName, 'uid=' . (int) $uid . tx_oelib_db::enableFields($this->tableName, $allowHiddenRecords), '', '', '1');
 }
Пример #14
0
 public function testCreateFromDbResult()
 {
     $dbResult = tx_oelib_db::select('*', 'tx_seminars_categories', 'uid = ' . $this->fixtureUid);
     $this->fixture = new tx_seminars_OldModel_Category(0, $dbResult);
     self::assertTrue($this->fixture->isOk());
 }
Пример #15
0
 /**
  * Provides data items for the list of available payment methods.
  *
  * @param array[] $items array that contains any pre-filled data (may be empty, unused)
  *
  * @return array[] items from the payment methods table as an array
  *               with the keys "caption" (for the title) and "value" (for the uid)
  */
 public function populateListPaymentMethods(array $items)
 {
     if (!$this->getSeminar()->hasPaymentMethods()) {
         return array();
     }
     $rows = tx_oelib_db::selectMultiple('uid, title', '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=' . $this->getSeminar()->getTopicUid() . tx_oelib_db::enableFields('tx_seminars_payment_methods'));
     $result = array();
     foreach ($rows as $row) {
         $result[] = array('caption' => $row['title'], 'value' => $row['uid']);
     }
     return $result;
 }
Пример #16
0
 /**
  * Limits the bag to events which have a price higher or equal to the given
  * minimum price.
  *
  * @param int $minimumPrice
  *                the minimum price an event is allowed to cost, must
  *                be >= 0
  *
  * @return void
  */
 public function limitToMinimumPrice($minimumPrice)
 {
     if ($minimumPrice == 0) {
         return;
     }
     $now = $GLOBALS['SIM_EXEC_TIME'];
     $whereClause = '(object_type = ' . tx_seminars_Model_Event::TYPE_TOPIC . ' OR ' . 'object_type = ' . tx_seminars_Model_Event::TYPE_COMPLETE . ') AND (' . '(deadline_early_bird < ' . $now . ' ' . 'AND (price_regular >= ' . $minimumPrice . ' ' . 'OR price_special >= ' . $minimumPrice . ')' . ') OR (deadline_early_bird > ' . $now . ' ' . 'AND ((' . '(price_regular_early = 0 ' . 'AND price_regular >= ' . $minimumPrice . ') ' . 'OR (price_special_early = 0 ' . 'AND price_special >= ' . $minimumPrice . ')) ' . 'OR (price_regular_early >= ' . $minimumPrice . ' ' . 'OR price_special_early >= ' . $minimumPrice . ') ' . ')) ' . 'OR price_regular_board >= ' . $minimumPrice . ' ' . 'OR price_special_board >= ' . $minimumPrice . ') ' . tx_oelib_db::enableFields('tx_seminars_seminars');
     $foundUids = implode(',', tx_oelib_db::selectColumnForMultiple('uid', 'tx_seminars_seminars', $whereClause));
     if ($foundUids == '') {
         $this->whereClauseParts['maximumPrice'] = '(0 = 1)';
     } else {
         $this->whereClauseParts['maximumPrice'] = '((object_type = ' . tx_seminars_Model_Event::TYPE_COMPLETE . ' ' . 'AND tx_seminars_seminars.uid IN (' . $foundUids . ')) OR ' . '(object_type = ' . tx_seminars_Model_Event::TYPE_DATE . ' AND ' . 'topic IN (' . $foundUids . ')))';
     }
 }
Пример #17
0
 /**
  * Sets the PIDs of the system folders that contain the records.
  *
  * @param string $sourcePagePids
  *        comma-separated list of PIDs of the system folders with the records;
  *        must not be empty; need not be safeguarded against SQL injection
  * @param int $recursionDepth
  *        recursion depth, must be >= 0
  *
  * @return void
  */
 public function setSourcePages($sourcePagePids, $recursionDepth = 0)
 {
     if (!preg_match('/^([\\d+,] *)*\\d+$/', $sourcePagePids)) {
         unset($this->whereClauseParts['pages']);
         return;
     }
     $recursivePidList = tx_oelib_db::createRecursivePageList($sourcePagePids, $recursionDepth);
     $this->whereClauseParts['pages'] = $this->tableName . '.pid IN (' . $recursivePidList . ')';
 }
 /**
  * Fills vacancies created through a unregistration with attendees from the registration queue.
  *
  * @param tslib_pibase $plugin live plugin object
  *
  * @return void
  */
 private function fillVacancies(tslib_pibase $plugin)
 {
     $seminar = $this->registration->getSeminarObject();
     $seminar->calculateStatistics();
     if (!$seminar->hasVacancies()) {
         return;
     }
     $vacancies = $seminar->getVacancies();
     /** @var tx_seminars_BagBuilder_Registration $registrationBagBuilder */
     $registrationBagBuilder = t3lib_div::makeInstance('tx_seminars_BagBuilder_Registration');
     $registrationBagBuilder->limitToEvent($seminar->getUid());
     $registrationBagBuilder->limitToOnQueue();
     $registrationBagBuilder->limitToSeatsAtMost($vacancies);
     $bag = $registrationBagBuilder->build();
     /** @var tx_seminars_registration $registration */
     foreach ($bag as $registration) {
         if ($vacancies <= 0) {
             break;
         }
         if ($registration->getSeats() <= $vacancies) {
             tx_oelib_db::update('tx_seminars_attendances', 'uid = ' . $registration->getUid(), array('registration_queue' => 0));
             $vacancies -= $registration->getSeats();
             $user = $registration->getFrontEndUser();
             foreach ($this->getHooks() as $hook) {
                 if (method_exists($hook, 'seminarRegistrationMovedFromQueue')) {
                     $hook->seminarRegistrationMovedFromQueue($registration, $user);
                 }
             }
             $this->notifyAttendee($registration, $plugin, 'confirmationOnQueueUpdate');
             $this->notifyOrganizers($registration, 'notificationOnQueueUpdate');
             if ($this->getConfValueBoolean('sendAdditionalNotificationEmails')) {
                 $this->sendAdditionalNotification($registration);
             }
         }
     }
 }
 /**
  * Checks whether plugin.tx_seminars.currency is not empty and a valid ISO
  * 4217 alpha 3.
  *
  * @return void
  */
 public function checkCurrency()
 {
     $this->checkIfSingleInSetNotEmpty('currency', FALSE, '', 'The specified currency setting is either empty or not a valid ' . 'ISO 4217 alpha 3 code. Please correct the value of <strong>' . $this->getTSSetupPath() . 'currency</strong>.', tx_oelib_db::selectColumnForMultiple('cu_iso_3', 'static_currencies'));
 }
 /**
  * Returns the items of the given table for the flexforms.
  *
  * The table to retrieve the items for must have a title column.
  *
  * The given configuration array must apply to the following convention:
  * - the sub-arrays "config", "row" and "items" must exist
  * - "config" must have an element "itemTable" with a valid table name of a
  *   table which has a title column
  * - "row" must have an item "pid" with the current page ID
  *
  * @param array[] $configuration the flexforms configuration
  *
  * @return array[] the modified flexforms configuration including the items available for selection
  */
 public function getEntriesFromGeneralStoragePage(array $configuration)
 {
     $whereClause = '1 = 1';
     $table = $configuration['config']['itemTable'];
     if (tx_oelib_configurationProxy::getInstance('seminars')->getAsBoolean('useStoragePid')) {
         $rootlinePages = t3lib_befunc::BEgetRootLine($configuration['row']['pid']);
         foreach ($rootlinePages as $page) {
             $storagePid = (int) $page['storage_pid'];
             if ($storagePid > 0) {
                 $whereClause = '(' . $table . '.pid = ' . $storagePid . ')';
                 break;
             }
         }
     }
     $items = tx_oelib_db::selectMultiple('uid,title', $table, $whereClause . tx_oelib_db::enableFields($table), '', 'title ASC');
     $configuration['items'] = array();
     foreach ($items as $item) {
         $configuration['items'][] = array(0 => $item['title'], 1 => $item['uid'], 2 => $GLOBALS['TCA'][$table]['ctrl']['iconfile']);
     }
     return $configuration;
 }
Пример #21
0
 /**
  * Updates the "registrations" field of the event records.
  *
  * @return string information about the status of the update process, will not be empty
  *
  * @throws tx_oelib_Exception_Database
  */
 private function updateRegistrationsField()
 {
     $query = 'UPDATE tx_seminars_seminars SET registrations = ' . '(SELECT COUNT(*) FROM tx_seminars_attendances' . ' WHERE seminar = tx_seminars_seminars.uid ' . tx_oelib_db::enableFields('tx_seminars_attendances') . ')' . ' WHERE registrations = 0 AND EXISTS (' . 'SELECT * FROM tx_seminars_attendances' . ' WHERE seminar = tx_seminars_seminars.uid ' . tx_oelib_db::enableFields('tx_seminars_attendances') . ')';
     if (!$GLOBALS['TYPO3_DB']->sql_query($query)) {
         throw new tx_oelib_Exception_Database();
     }
     return '<h2>Updating the events.registrations field.</h2>' . '<p>Updating ' . $GLOBALS['TYPO3_DB']->sql_affected_rows() . ' event records.</p>';
 }
Пример #22
0
 /**
  * Gets our skills as a plain text list (just the skill names).
  *
  * @return string our skills list (or an empty string if there are no
  *                skills for this speaker or there is an error)
  */
 public function getSkillsShort()
 {
     if (!$this->hasSkills()) {
         return '';
     }
     $dbResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery('title', 'tx_seminars_skills, tx_seminars_speakers_skills_mm', 'uid_local = ' . $this->getUid() . ' AND uid = uid_foreign' . tx_oelib_db::enableFields('tx_seminars_skills'), '', 'sorting ASC');
     if (!$dbResult) {
         return '';
     }
     $result = array();
     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($dbResult)) {
         $result[] = $row['title'];
     }
     return implode(', ', $result);
 }