protected function initDiskPath() { if ($this->record['fileCategory'] == 'image') { $request = CoreServices2::getRequest(); $width = $request->getFromGet('width'); $height = $request->getFromGet('height'); $ignoreProportions = $request->getFromGet('ignoreProportions'); $crop = $request->getFromGet('crop'); $backgroundColor = $request->getFromGet('backgroundColor'); $keepSmall = $request->getFromGet('keepSmall'); } $files = CoreServices2::getFiles(); if (empty($width) && empty($height)) { $this->diskPath = $files->getDiskPath($this->record['fileBaseName'], $this->record['fileExtension']); } else { $options = array('width' => $width, 'height' => $height, 'ignoreProportions' => $ignoreProportions, 'crop' => $crop, 'backgroundColor' => $backgroundColor, 'keepSmall' => $keepSmall); $this->diskPath = $files->getResizedImageDiskPath($this->record['fileBaseName'], $this->record['fileExtension'], $options); if (!is_file($this->diskPath)) { $files->resizeImage($this->diskPath, $this->record['fileBaseName'], $this->record['fileExtension'], $options); } } if (!is_file($this->diskPath)) { $this->error(3); } }
protected function setSpecialRecordFieldsBeforeSave() { $companyId = CoreServices2::getRequest()->getFromGet('comp'); if (empty($this->record['id'])) { $this->record['companyId'] = $companyId; } }
protected function initRecord() { $passwordChangeCode = CoreServices2::getRequest()->getFromRequest('cc'); if (empty($passwordChangeCode)) { return; } $this->record = $this->dao->getActiveUserByPasswordChangeCode($passwordChangeCode); }
protected function getViewParam() { $view = CoreServices2::getRequest()->getFromPost('view'); if (empty($view)) { $view = CoreServices2::getRequest()->getFromGet('view'); } return $view; }
public function initSubpage() { $this->subpage = $this->subpageDAO->getRecordById(CoreServices2::getRequest()->getFromGet('id')); $modules = CoreServices2::getModules(); if ($this->subpage['subpageModule'] != $modules->getControllerModule() || $this->subpage['subpageMode'] != $modules->getControllerMode() || $this->subpage['subpageState'] != 'visible') { $this->layout->handleInvalidAddress(); } }
protected function prepareAdditionalData() { parent::prepareAdditionalData(); if (!empty($this->currentUser['id'])) { if (CoreServices2::getRequest()->getFromGet('logout') == 1) { CoreServices2::getAccess()->logout(); $this->redirectToHomePage(); } } }
protected function logAction($action) { $logRecord = $this->logDAO->getRecordTemplate(); $logRecord['adminId'] = CoreServices2::getAccess()->getCurrentUserId(); $logRecord['recordType'] = $this->recordType; $logRecord['recordId'] = CoreServices2::getAccess()->getCurrentUserId(); $logRecord['logTime'] = CoreUtils::getDateTime(); $logRecord['logIP'] = CoreServices2::getRequest()->getRealIP(); $logRecord['logOperation'] = $action; $this->logDAO->save($logRecord); }
public function prepareData() { parent::prepareData(); $this->wellId = CoreServices2::getRequest()->getFromPost('wellId'); $this->wellType = CoreServices2::getRequest()->getFromPost('wellType'); $this->wellPoints = CoreServices2::getRequest()->getFromPost('wellPoints'); $this->messageManager = new CoreFormValidationMessageContainer(); CoreServices2::getDB()->transactionStart(); if (!$this->hasUserPermissionsForRecord()) { $this->messageManager->addMessage('fileDeleteErrorNoPermission'); return; } $pointsData = json_decode($this->wellPoints); foreach ($pointsData as $key => $pointData) { if ($pointData == "") { return false; } $keyValue = explode("_", $key); if ($keyValue[1] != "rowOrder") { $wellPoints[$keyValue[2]][$keyValue[1]] = $pointData; } else { $pointsOrder = explode(',', $pointData); } } // find old points connectet with welll $well3dDAO = new Well3DPointDAO(); $oldPoints = $well3dDAO->getWellPointsByWellId($this->wellId); // delete old points if (!empty($oldPoints)) { foreach ($oldPoints as $point) { $well3dDAO->delete($point); } } $pointsCounter = 1; foreach ($pointsOrder as $order) { // save new points into table $recordTemplate = $well3dDAO->getRecordTemplate(); $recordTemplate['wellId'] = $this->wellId; $recordTemplate['number'] = $pointsCounter; $recordTemplate['X'] = $wellPoints[$order]['X']; $recordTemplate['Y'] = $wellPoints[$order]['Y']; $recordTemplate['Z'] = $wellPoints[$order]['Z']; $recordTemplate['LP'] = $wellPoints[$order]['LP']; $recordTemplate['alfa'] = $wellPoints[$order]['alfa']; $recordTemplate['beta'] = $wellPoints[$order]['beta']; $well3dDAO->save($recordTemplate); $pointsCounter++; } CoreServices2::getDB()->transactionCommit(); }
protected function assignErrorValue() { $error = null; if (!empty($this->loginErrorMessageContainer) && $this->loginErrorMessageContainer->isAnyErrorMessage()) { $messages = $this->loginErrorMessageContainer->getMessages(); if (!empty($messages['']['messages'][0]) && $messages['']['messages'][0] == 'userAccountTemporarilyBlocked') { $error = 'userAccountTemporarilyBlocked'; } else { $error = 'defaultLoginErrorMessage'; } } elseif (CoreServices2::getRequest()->getFromGet('error')) { $error = 'defaultLoginErrorMessage'; } CoreServices2::getDisplay()->assign('error', $error); }
protected function getCommonOptions(&$record) { // Parametr version jest przekazywany po to, żeby w przypadku zmiany pliku dyskowego // przypisanego do tego samego rekordu nie byĹ‚ pobierany plik z cache'a, tylko ĹĽeby // nastepowaĹ‚o faktyczne odwoĹ‚anie do serwera. // Ten parametr w ogĂłle nie jest obsĹ‚ugiwany przez FileHushvizStaticController, bo ten // kontroler i tak zawsze zwrĂłci po prostu aktualnÄ… wersjÄ™ pliku. $options = array('_m', 'FileHushviz', '_o', 'Static', 'id', $record['id'], 'version', strtotime($record['fileUpdateTime'])); $logic = new FileHushvizLogic(); if ($logic->isProtectedFile($record)) { $view = CoreServices2::getRequest()->getSessionName() == 'CMSSession' ? 'c' : 'w'; $options[] = 'view'; $options[] = $view; } return $options; }
protected function initTmpRecord() { $tmpId = CoreServices::get('request')->getFromRequest('_tmpId'); if (!empty($tmpId)) { $this->tmpRecord = $this->tmpRecordDAO->getRecordById($tmpId); if (empty($this->tmpRecord['id'])) { CoreServices2::getDB()->transactionCommit(); CoreUtils::redirect($this->getListPageAddress()); } } else { $this->tmpRecord = $this->tmpRecordDAO->getRecordTemplate(); $this->tmpRecord['recordType'] = $this->getRecordType(); $this->tmpRecord['_tmpRecordCreateTime'] = CoreUtils::getDateTime(); $this->tmpRecord['_tmpRecordSessionId'] = CoreServices2::getRequest()->getSessionId(); $this->tmpRecordDAO->save($this->tmpRecord); } }
public function __construct() { $this->currentUser = CoreServices2::getRequest()->getFromSession('currentUser'); }
protected function setSpecialRecordFieldsBeforeSave() { $siteId = CoreServices2::getRequest()->getFromGet('site'); //print_r($this->record); if (empty($this->record['id'])) { $this->record['siteId'] = $siteId; } }
protected function initFileRecord() { $this->fileRecord = $this->fileDAO->getRecordById(CoreServices2::getRequest()->getFromRequest('id')); }
protected function handleLoginForm() { if (!empty($this->currentUser['id'])) { if (CoreServices2::getRequest()->getFromGet('logout') == 1) { CoreServices2::getAccess()->logout(); $this->redirectToHomePage(); } } else { $currentPage = CoreServices2::getUrl()->getCurrentExactAddress(); $this->loginForm = new CoreForm('post', CoreServices2::getUrl()->getCurrentExactAddress(), 'loginForm'); $this->createLoginFormFields(); if ($this->loginForm->isSubmitted()) { //$this->addLoginFormValidators(); CoreServices2::getAccess()->logout(); $this->loginForm->setFieldValuesFromRequest(); $this->loginErrorMessageContainer = $this->loginForm->getValidationResults(); if (!$this->loginErrorMessageContainer->isAnyErrorMessage()) { $this->loginAndReload(); } } } }
protected function isForDeletion(&$tmpRecord) { return !CoreServices2::getRequest()->isActiveSession($tmpRecord['_tmpRecordSessionId']); }
public function assignDisplayVariables() { parent::assignDisplayVariables(); $display = CoreServices2::getDisplay(); $display->assign('newParentUrl', CoreServices2::getRequest()->getFromGet('url')); }
public function isCurrentUserAllowed(&$record, $updateDownloadObject) { CoreUtils::checkConstraint($record['id']); CoreUtils::checkConstraint($record['recordId']); $recordId = $record['id']; if (!$this->isProtectedFile($record)) { return true; } $this->freeModelsOfTheMonth[$record['recordId']] = false; $this->setMessage($recordId, false); $this->setErrorMessage($recordId, false); $sessionName = CoreServices2::getRequest()->getSessionName(); if (empty($sessionName)) { $this->setErrorMessage($recordId, 'emptySessionDownloadError'); return false; } $currentUser = CoreServices2::getAccess()->getCurrentUserData(); if (empty($currentUser['id'])) { $this->setErrorMessage($recordId, 'noUserDownloadError'); return false; } if ($sessionName == 'CMSSession') { return $this->isAdminAllowed($record); } $year = date("Y"); $month = date("n"); $modelOfTheMonthDAO = new ModelOfTheMonthDAO(); $modelOfTheMonthInfoRecord = $modelOfTheMonthDAO->getFreeModelOfTheMonth($year, $month); if (!empty($modelOfTheMonthInfoRecord['modelId']) && $modelOfTheMonthInfoRecord['modelId'] == $record['recordId']) { $this->freeModelsOfTheMonth[$record['recordId']] = true; if (!empty($updateDownloadObject)) { $downloadDAO = new DownloadDAO(); $downloadRecord = $downloadDAO->getRecordTemplate(); $modelDAO = new ModelDAO(); $modelRecord = $modelDAO->getRecordById($modelOfTheMonthInfoRecord['modelId']); CoreUtils::checkConstraint(!empty($modelRecord['id'])); $downloadRecord['userId'] = $currentUser['id']; $downloadRecord['modelId'] = $modelRecord['id']; $downloadRecord['fileId'] = $record['id']; $downloadRecord['downloadStartTime'] = CoreUtils::getDateTime(); $downloadRecord['downloadAttempts'] = 0; $downloadRecord['downloadCreditsCost'] = 0; $downloadRecord['downloadModelName'] = $modelRecord['modelName']; $downloadRecord['downloadFileTypeName'] = $record['modelFileTypeName']; $downloadRecord['downloadPaid'] = 0; $downloadRecord['downloadFree'] = 1; $downloadDAO->save($downloadRecord); } return true; } $downloadLogic = new DownloadLogic(); if (!empty($updateDownloadObject)) { $result = $downloadLogic->checkAndUpdateDownloadObject($currentUser['id'], $record); } else { $result = $downloadLogic->checkDownloadObject($currentUser['id'], $record); } if (!$result) { $this->setErrorMessage($recordId, $downloadLogic->getErrorMessage()); } else { $this->setMessage($recordId, $downloadLogic->getMessage()); } return $result; }
protected function setFilterFormFieldsFromUrlOrFilterValues() { $betweenFields = array(); foreach ($this->filterForm->getFields() as $fieldName => $field) { $fieldNameParts = explode('_', $fieldName); if (count($fieldNameParts) == 2 && ($fieldNameParts[1] == 'min' || $fieldNameParts[1] == 'max')) { $betweenFields[$fieldNameParts[0]] = $this->filter[$fieldNameParts[0]]->getValue(); } else { if (array_key_exists($fieldName, $this->filter)) { // try to get param value from the url - handy for preinitializing filtered list with some filter values passed in url $requestParamValue = CoreServices2::getRequest()->getFromGet($fieldName); if (!empty($requestParamValue)) { $this->filter[$fieldName]->setValue($requestParamValue); $field->setValue($requestParamValue); } else { $field->setValue($this->filter[$fieldName]->getValue()); } } } } foreach ($betweenFields as $filteredFieldName => $filter) { $values = array(); foreach ($filter as $key => $val) { $values[$key] = $val; $this->filterForm->getField($filteredFieldName . '_' . $key)->setValue($val); } } }
public function modifyFieldNamesForVLF($vlfName, $index) { parent::modifyFieldNamesForVLF($vlfName, $index); $this->idFieldName = CoreServices2::getRequest()->composeFormFieldName(array($vlfName, $index, $this->idFieldName)); }
protected function logAction($action) { $recordType = $this->getRecordType(); if (!empty($recordType) && !empty($this->record['id'])) { $logRecord = $this->logDAO->getRecordTemplate(); $logRecord['adminId'] = CoreServices2::getAccess()->getCurrentUserId(); $logRecord['recordType'] = $recordType; // $this->recordOldValues['id'] może być puste, $this->record['id'] nie może. $logRecord['recordId'] = $this->record['id']; $logRecord['logTime'] = CoreUtils::getDateTime(); $logRecord['logIP'] = CoreServices2::getRequest()->getRealIP(); switch ($action) { case 'Save': case 'ChangeWithdrawDate': if (empty($this->recordOldValues['id'])) { $logRecord['logOperation'] = 'create'; } else { $logRecord['logOperation'] = 'modify'; } $logRecord['recordId'] = $this->record['id']; break; case 'DeleteAll': $logRecord['logOperation'] = 'delete'; break; default: $logRecord['logOperation'] = strtolower($action); break; } $this->logDAO->save($logRecord); } }
public function isSubmitted() { if (is_null($this->submitted)) { if (!CoreServices2::getRequest()->isNotEmptyRequest($this->httpMethod)) { $this->submitted = False; } else { $this->fields[$this->tokenFieldName]->setValueFromRequest($this->httpMethod); $tokenSubmitted = $this->fields[$this->tokenFieldName]->getValue(); if ($this->httpMethod == 'post') { // Reset token, so it's possible to send this form again $this->fields[$this->tokenFieldName]->setValue($this->tokenManager->createToken()); $this->submitted = $this->tokenManager->isValidToken($tokenSubmitted); } else { // Ignore token value; check only if form was sent. $this->submitted = !is_null($tokenSubmitted); } } } return $this->submitted; }