public function prepareData() { parent::prepareData(); $this->form = new CoreForm('post'); $this->createFormFields(); $this->errorMessageContainer = new CoreFormValidationMessageContainer(); if (CoreServices::get('request')->isSetGet('logout')) { $this->logAction('logout'); CoreServices::get('access')->logout(); $this->currentUser = null; } elseif ($this->form->isSubmitted()) { $this->addFormValidators(); CoreServices::get('access')->logout(); $this->currentUser = null; $this->form->setFieldValuesFromRequest(); $this->errorMessageContainer = $this->form->getValidationResults(); if (!$this->errorMessageContainer->isAnyErrorMessage()) { CoreServices::get('access')->login($this->form->getField('adminName')->getValue(), $this->form->getField('password')->getValue(), $this->errorMessageContainer); $this->logAction('login'); } } if (!$this->form->isSubmitted() || !$this->errorMessageContainer->isAnyErrorMessage()) { $adminId = CoreServices::get('access')->getCurrentUserId(); if ($adminId) { $this->currentUser = CoreServices::get('access')->getCurrentUserData(); $redirectAddress = $this->getFirstAccessiblePage(); if ($redirectAddress == CoreServices::get('url')->getCurrentPageUrl()) { $this->errorMessageContainer->addMessage('youHaveNoPermissions'); } else { CoreUtils::redirect($redirectAddress); } } } }
protected function checkUserPermissionsForRecord() { if ($this->currentUser['adminRole'] < $this->adminRoles['adminRoleSuperadmin'] && $this->currentUser['id'] != $this->record['id']) { CoreServices2::getDB()->transactionCommit(); CoreUtils::redirect($this->getListPageAddress()); } }
public function prepareData() { parent::prepareData(); if (CoreServices2::getRequest()->getFromGet('_sm')) { $this->successMessage = 1; return; } $this->dao = new UserDAO(); $this->initRecord(); $this->initForm(); $this->createFormFields(); if (empty($this->record['id'])) { // @TODO: własciwie w tym wypadku powinno sie przejść z powrotem do pierwszego // formularza i rozpocząć całą procedurę od nowa $this->errorMessageContainer = new CoreFormValidationMessageContainer(); $this->errorMessageContainer->addMessage('errorInvalidCode'); return; } if ($this->form->isSubmitted()) { $this->addFormValidators(); $this->form->setFieldValuesFromRequest(); $this->handleRequest(); } else { $this->setFormFieldValuesFromRecord(); } if (!empty($this->redirectAddress)) { CoreUtils::redirect($this->redirectAddress); } }
protected function initRecord() { parent::initRecord(); if (empty($this->record['id']) || $this->record['subpageModule'] != 'Subpage' || $this->record['subpageMode'] != 'Website') { CoreUtils::redirect($this->getListPageAddress()); } }
/** * Teoretycznie jest to odporne na thickboxy. */ protected function checkHTTPS() { $httpsOn = CoreServices2::getUrl()->isHTTPSOn(); $httpsRequired = CoreConfig::get('Environment', 'httpsForWebsite'); if ($httpsRequired && !$httpsOn) { CoreUtils::redirect(CoreServices2::getUrl()->getCurrentExactAddress('https')); } if (!$httpsRequired && $httpsOn) { CoreUtils::redirect(CoreServices2::getUrl()->getCurrentExactAddress('http')); } }
protected function redirectToPage($url, $layoutType) { switch ($layoutType) { case 'standard': CoreUtils::redirect(CoreServices2::getUrl()->createAddress('_m', 'Helper', '_o', 'WebsiteThickboxParentRedirect', 'url', $url)); case 'thickbox': CoreUtils::redirect($url); default: throw new CoreException('Invalid layout type ' . $layoutType); } }
public function prepareData() { if (!$this->isCLI()) { CoreUtils::redirect(CoreServices::get('url')->createAddress()); } $this->garbageCollector = new TmpRecordGarbageCollector(); try { $this->garbageCollector->clean(); } catch (Exception $e) { $this->reportError($e->getMessage()); } }
public function prepareData() { $this->checkHTTPS(); $this->adminRoles = array_flip(CoreConfig::get('Data', 'adminRoles')); $this->currentUser = CoreServices::get('access')->getCurrentUserData(); if (!$this->isControllerUsagePermitted()) { CoreUtils::redirect($this->getNoPermissionsAddress()); } $this->initDAO(); $this->initLayout(); $this->initCompany(); $this->initProject(); }
public function prepareData() { parent::prepareData(); $this->initDAO(); $this->initSearchForm(); if ($this->searchForm->isSubmitted()) { $this->searchForm->setFieldValuesFromRequest(); } $this->initRecordList(); $this->initDeletionForm(); if ($this->deletionForm->isSubmitted()) { $this->deletionForm->setFieldValuesFromRequest(); $this->handleDeleteRequest(); CoreUtils::redirect(CoreServices::get('url')->getCurrentPageUrl('_sm', 'MassDelete')); } }
protected function initRecord() { $id = CoreServices::get('request')->getFromRequest('id'); if (!empty($id)) { $this->record = $this->dao->getRecordById($id); if (!$this->record['id']) { CoreServices::get('db')->transactionCommit(); CoreUtils::redirect($this->getListPageAddress()); } } else { CoreUtils::redirect(CoreServices2::getUrl()->createAddress('_m', 'Settings', '_o', 'CMSList')); } $this->initMultiselectRelations(); $this->recordOldValues = $this->record; // clone! $this->checkUserPermissionsForRecord(); }
protected function checkHTTPS() { $httpsOn = CoreServices2::getUrl()->isHTTPSOn(); if ($this->getSessionName() == 'CMSSession') { $httpsRequired = CoreConfig::get('Environment', 'httpsForCMS'); } elseif ($this->getSessionName() == 'WebsiteSession') { $httpsRequired = CoreConfig::get('Environment', 'httpsForWebsite'); } else { $httpsRequired = False; // i tak nie ma sesji! } if ($httpsRequired && !$httpsOn) { CoreUtils::redirect(CoreServices::get('url')->getCurrentExactAddress('https')); } if (!$httpsRequired && $httpsOn) { CoreUtils::redirect(CoreServices::get('url')->getCurrentExactAddress('http')); } }
public function prepareData() { parent::prepareData(); $this->dao = new UserDAO(); if (CoreServices::get('request')->getFromGet('_sm')) { $this->successMessage = 1; return; } $this->initForm(); $this->createFormFields(); if ($this->form->isSubmitted()) { $this->addFormValidators(); $this->form->setFieldValuesFromRequest(); $this->handleRequest(); } if (!is_null($this->redirectAddress)) { CoreUtils::redirect($this->redirectAddress); } }
public function prepareData() { parent::prepareData(); $this->initDAO(); $this->form = new CoreForm('post'); if ($this->form->isSubmitted()) { CoreServices::get('db')->transactionStart(); $this->initRecordList(); $this->initActions(); $this->createFormFields(); $this->addFormValidators(); $this->form->setFieldValuesFromRequest(); $this->handleRequest(); CoreServices::get('db')->transactionCommit(); } else { $this->initRecordList(); $this->initActions(); $this->createFormFields(); } if (!is_null($this->redirectAddress)) { CoreUtils::redirect($this->redirectAddress); } }
protected function redirectToPage($url, $layoutType) { switch ($layoutType) { case 'standard': CoreUtils::redirect($url); case 'thickbox': throw new CoreException('Can\'t redirect from standard layout to thickbox.'); default: throw new CoreException('Unknown layout type ' . $layoutType); } }
protected function initRecord() { if ($this->hasSWFUpload()) { $id = CoreServices::get('request')->getFromRequest('id'); if (!empty($id)) { $this->record = $this->dao->getRecordById($id); if (empty($this->record['id'])) { CoreServices::get('db')->transactionCommit(); CoreUtils::redirect($this->getListPageAddress()); } } else { $this->record = $this->dao->getRecordTemplate(); $this->initTmpRecord(); } $this->initMultiselectRelations(); $this->recordOldValues = $this->record; // clone! $this->checkUserPermissionsForRecord(); } else { parent::initRecord(); } }