/** * Checks isOk() and, in case of failure (e.g., there is no more data * from the DB), nulls out $this->currentItem. * * If the function isOk() returns TRUE, nothing is changed. * * @return bool TRUE if the current item is valid, FALSE otherwise */ public function valid() { if (!$this->currentItem || !$this->currentItem->isOk()) { $this->currentItem = NULL; return FALSE; } return TRUE; }
/** * 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; }
/** * Retrieves the topic from the DB and returns it as an object. * * In case of an error, the return value will be NULL. * * @return tx_seminars_seminar the topic object (will be NULL if an error * has occured) */ private function retrieveTopic() { $result = NULL; // Check whether this event has an topic set. if ($this->hasRecordPropertyInteger('topic')) { if (tx_seminars_OldModel_Abstract::recordExists($this->getRecordPropertyInteger('topic'), 'tx_seminars_seminars')) { /** @var tx_seminars_seminar $result */ $result = t3lib_div::makeInstance('tx_seminars_seminar', $this->getRecordPropertyInteger('topic')); } } return $result; }
/** * Writes this record to the DB and adds any needed m:n records. * * This function actually calls the same method in the parent class * (which saves the record to the DB) and then adds any necessary m:n relations. * * The UID of the parent page must be set in $this->recordData['pid']. * (otherwise the record will be created in the root page). * * @return bool TRUE if everything went OK, FALSE otherwise */ public function commitToDb() { $this->fillEmptyDefaultFields(); if (!parent::commitToDb()) { return FALSE; } $this->recordData['uid'] = $GLOBALS['TYPO3_DB']->sql_insert_id(); if ($this->hasUid()) { $this->createMmRecords('tx_seminars_attendances_lodgings_mm', $this->lodgings); $this->createMmRecords('tx_seminars_attendances_foods_mm', $this->foods); $this->createMmRecords('tx_seminars_attendances_checkboxes_mm', $this->checkboxes); } /** @var t3lib_refindex $referenceIndex */ $referenceIndex = t3lib_div::makeInstance('t3lib_refindex'); $referenceIndex->updateRefIndexTable('tx_seminars_attendances', $this->getUid()); return TRUE; }
/** * Removes the given registration (if it exists and if it belongs to the * currently logged-in FE user). * * @param int $uid the UID of the registration that should be removed * @param tslib_pibase $plugin a live plugin object * * @return void */ public function removeRegistration($uid, tslib_pibase $plugin) { if (!tx_seminars_OldModel_Abstract::recordExists($uid, 'tx_seminars_attendances')) { return; } $this->registration = t3lib_div::makeInstance('tx_seminars_registration', $plugin->cObj, tx_oelib_db::select('*', 'tx_seminars_attendances', 'uid = ' . $uid . tx_oelib_db::enableFields('tx_seminars_attendances'))); if ($this->registration->getUser() !== $this->getFeUserUid()) { return; } /** @var $user tx_seminars_Model_FrontEndUser */ $user = tx_oelib_FrontEndLoginManager::getInstance()->getLoggedInUser('tx_seminars_Mapper_FrontEndUser'); foreach ($this->getHooks() as $hook) { if (method_exists($hook, 'seminarRegistrationRemoved')) { $hook->seminarRegistrationRemoved($this->registration, $user); } } tx_oelib_db::update('tx_seminars_attendances', 'uid = ' . $uid, array('hidden' => 1, 'tstamp' => $GLOBALS['SIM_EXEC_TIME'])); $this->notifyAttendee($this->registration, $plugin, 'confirmationOnUnregistration'); $this->notifyOrganizers($this->registration, 'notificationOnUnregistration'); $this->fillVacancies($plugin); }
/** * Checks whether the currently logged in BE-User has access to the given * event and its registrations. * * Stores the type of the error in $this->errorType * * @param int $eventUid * the event to check the access for, must be >= 0 but not necessarily point to an existing event * * @return bool TRUE if the event record exists and the BE-User has * access to the registrations belonging to the event, * FALSE otherwise */ private function hasAccessToEventAndItsRegistrations($eventUid) { $result = FALSE; if (!tx_seminars_OldModel_Abstract::recordExists($eventUid, 'tx_seminars_seminars')) { $this->errorType = self::NOT_FOUND; } elseif (!$this->canAccessListOfRegistrations($eventUid)) { $this->errorType = self::ACCESS_DENIED; } else { $result = TRUE; } return $result; }
/** * Checks whether the currently logged-in FE user (if any) belongs to the * FE group that is allowed to enter and edit event records in the FE. * This group can be set using plugin.tx_seminars.eventEditorFeGroupID. * * It also is checked whether that event record exists and the logged-in * FE user is the owner or is editing a new record. * * @return string locallang key of an error message, will be an empty string if access was granted */ private function checkAccess() { if (!tx_oelib_FrontEndLoginManager::getInstance()->isLoggedIn()) { return 'message_notLoggedIn'; } $objectUid = $this->getObjectUid(); if ($objectUid > 0 && !tx_seminars_OldModel_Abstract::recordExists($objectUid, 'tx_seminars_seminars', TRUE)) { return 'message_wrongSeminarNumber'; } if ($objectUid > 0) { /** @var tx_seminars_seminar $seminar */ $seminar = t3lib_div::makeInstance('tx_seminars_seminar', $this->getObjectUid(), FALSE, TRUE); $isUserVip = $seminar->isUserVip($this->getFeUserUid(), $this->getConfValueInteger('defaultEventVipsFeGroupID')); $isUserOwner = $seminar->isOwnerFeUser(); $mayManagersEditTheirEvents = $this->getConfValueBoolean('mayManagersEditTheirEvents', 's_listView'); $hasAccess = $isUserOwner || $mayManagersEditTheirEvents && $isUserVip; } else { $eventEditorGroupUid = $this->getConfValueInteger('eventEditorFeGroupID', 's_fe_editing'); $hasAccess = $eventEditorGroupUid !== 0 && self::getLoggedInUser()->hasGroupMembership($eventEditorGroupUid); } return $hasAccess ? '' : 'message_noAccessToEventEditor'; }
/** * Adds m:n records that are referenced by this record. * * Before this function may be called, $this->recordData['uid'] must be set * correctly. * * @param string $mmTable the name of the m:n table, having the fields uid_local, uid_foreign and sorting, must not be empty * @param int[] $references array of uids of records from the foreign table to which we should create references, may be empty * * @return int the number of created m:n records */ public function createMmRecords($mmTable, array $references) { return parent::createMmRecords($mmTable, $references); }