Exemplo n.º 1
0
 /**
  * Contructor
  *
  */
 public function __construct()
 {
     // get settings
     $config = new RM_Config();
     $this->_enabled = $config->getValue('rm_config_recaptcha_enabled');
     $this->_useSSL = $config->getValue('rm_config_recaptcha_ssl');
     $this->_publickey = $config->getValue('rm_config_recaptcha_publickey');
     $this->_privatekey = $config->getValue('rm_config_recaptcha_privatekey');
 }
Exemplo n.º 2
0
 function testemailJsonAction()
 {
     //TODO: all this code below is a temp code - we need to delete is later
     //and create new one in EmailNotification module
     $email = $this->_getParam('email');
     if ($email === null) {
         return array('data' => array('success' => false));
     }
     $configModel = new RM_Config();
     $mail = new Zend_Mail('UTF-8');
     $mail->addTo($email);
     $mail->setFrom($configModel->getValue('rm_config_email_settings_mailfrom'), $configModel->getValue('rm_config_email_settings_fromname'));
     $mail->setBodyText($this->_translate->_('Admin.Config.Edit', 'TestEmailMessage'));
     $mail->setSubject($this->_translate->_('Admin.Config.Edit', 'TestEmailSubject'));
     $emailType = $configModel->getValue('rm_config_email_settings_mailer');
     try {
         if ($emailType == 'PHP') {
             $mail->send();
         } else {
             $smtpConfig = array('auth' => 'Login', 'username' => $configModel->getValue('rm_config_email_settings_smtpuser'), 'password' => $configModel->getValue('rm_config_email_settings_smtppass'), 'port' => $configModel->getValue('rm_config_email_settings_smtpport'));
             if ($configModel->getValue('rm_config_email_settings_smtpsecure') != "") {
                 $smtpConfig['ssl'] = strtolower($configModel->getValue('rm_config_email_settings_smtpsecure'));
             }
             $mail->send(new Zend_Mail_Transport_Smtp($configModel->getValue('rm_config_email_settings_smtphost'), $smtpConfig));
         }
     } catch (Zend_Mail_Exception $e) {
         return array('data' => array('success' => false, 'error' => $e->getMessage()));
     }
     return array('data' => array('success' => true));
 }
Exemplo n.º 3
0
 /**
  * Get the plugins CSS and combine these
  */
 public function getPluginCSS()
 {
     $cacheDir = RM_Environment::getConnector()->getRootPath() . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . 'userdata' . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR . 'css';
     if (is_dir($cacheDir) == false) {
         $rmConfig = new RM_Config();
         $chmodOctal = intval($rmConfig->getValue('rm_config_chmod_value'), 8);
         mkdir($cacheDir, $chmodOctal);
     }
     $cachedCSS = file_exists($cacheDir . DIRECTORY_SEPARATOR . "plugins.css");
     if (!$cachedCSS) {
         $newfileContents = "";
         $pluginsDAO = new RM_Plugins();
         $plugins = $pluginsDAO->fetchAllEnabled();
         $config = new RM_plugin_Config();
         foreach ($plugins as $plugin) {
             $files = RM_plugin_Manager::getCssFiles($plugin->name);
             foreach ($files as $file) {
                 // read in the css and change the relative paths then add to a cached css file that we will load
                 $fileContents = file_get_contents(RM_Environment::getConnector()->getRootURL() . "RM/userdata/plugins/" . $plugin->name . "/" . RM_Module_Config::CSS . '/' . $file);
                 $search = "/url\\(([^\\)]*)\\)/";
                 $replace = "url(../../../userdata/plugins/" . $plugin->name . "/images/\$1)";
                 $newfileContents .= preg_replace($search, $replace, $fileContents);
             }
         }
         $this->_saveCachedCSS($newfileContents, $cacheDir . DIRECTORY_SEPARATOR . "plugins.css");
     }
     // return the cached CSS url so it can be included
     return RM_Environment::getConnector()->getRootURL() . "RM/userdata/temp/css/plugins.css";
 }
Exemplo n.º 4
0
 /**
  * this logs to the sytem log the application load time
  * NOTE: this code runs once at boot time so it is the ideal place to implecate
  * things that need a run-once at startup
  *
  * @return array that will be encoded to JSON
  */
 public function logloadingtimeJsonAction()
 {
     RM_Log::toLog('Admin end loading time: ' . $this->_getParam('time'), RM_Log::INFO);
     // update load status
     $model = new RM_System();
     $data = $model->setRunStatus(1);
     // check for new modules or plugins
     $extensions = RM_Environment::getInstance()->getOutOfDateExtensions();
     // make a string of modules that have updates available
     $moduleNames = false;
     if (!empty($extensions['modules'])) {
         foreach ($extensions['modules'] as $module) {
             $moduleNames[] = $module;
         }
         $moduleNames = implode(",", $moduleNames);
     }
     // make a string of plugins that have updates available
     $pluginNames = false;
     if (!empty($extensions['plugins'])) {
         foreach ($extensions['plugins'] as $plugins) {
             $pluginsNames[] = $plugins;
         }
         $pluginsNames = implode(",", $pluginsNames);
     }
     $config = new RM_Config();
     $licenceKey = false;
     if ($config->getValue('rm_config_licensekey') !== "") {
         $licenceKey = true;
     }
     return array('data' => array('success' => true, 'moduleupdates' => $moduleNames, 'pluginupdates' => $pluginNames, 'licensekey' => $licenceKey));
 }
Exemplo n.º 5
0
 public function autoupgradeJsonAction()
 {
     $json = new stdClass();
     $json->success = 1;
     $json->msg = array();
     $config = new RM_Config();
     $licenseKey = $config->getValue('rm_config_licensekey');
     if ($licenseKey == "") {
         $json->success = 0;
         $json->msg[] = "License Key Not Entered";
         return array('data' => $json);
     }
     $ids = $this->_getParam('ids', array());
     $manager = new RM_Module_Manager($this->_translate);
     try {
         $dao = new RM_Modules();
         foreach ($ids as $id) {
             $row = $dao->find($id)->current();
             $manager->autoUpgrade($row, $json);
         }
     } catch (Exception $e) {
         $json->success = 0;
         $json->msg[] = $e->getMessage();
     }
     return array('data' => $json);
 }
Exemplo n.º 6
0
 /**
  * Returns extra HTML for a summary reservation page to present current system
  *
  * @abstract
  * @param RM_Reservation_Details $detail
  * @return string HTML code to paste
  */
 public function getSummary(RM_Reservation_Details $detail)
 {
     $model = new RM_Extras();
     $extras = $model->getByUnit($detail->getUnit());
     if (0 == $extras->count()) {
         return "";
     }
     // tax
     $taxSystem = RM_Environment::getInstance()->getTaxSystem();
     $taxes = $taxSystem->getAllTaxes($detail->getUnit());
     $request = RM_Environment::getConnector()->getRequestHTTP();
     $request->setControllerName('Extras');
     $request->setActionName('summary');
     $controller = new RM_User_ExtrasController($request, new Zend_Controller_Response_Http());
     $controller->setFrontController(Zend_Controller_Front::getInstance());
     $controller->view->unit = $detail->getUnit();
     $config = new RM_Config();
     $controller->view->currencySymbol = $config->getValue('rm_config_currency_symbol');
     $translate = RM_Environment::getInstance()->getTranslation();
     $extraTypes = array('day' => $translate->_('User.Extras.Type', 'Day'), 'percentage' => $translate->_('User.Extras.Type', 'Percentage'), 'single' => $translate->_('User.Extras.Type', 'Single'));
     $viewExtras = array();
     foreach ($extras as $extra) {
         $extraTotal = RM_Environment::getInstance()->roundPrice($extra->calculateBy($detail->getTotal(), $detail->getPeriod()->getSeconds()));
         // calculate the tax due on the extra...
         $taxTotal = 0;
         foreach ($taxes as $tax) {
             $taxTotal = $taxTotal + $tax->calculate($extraTotal, $detail);
         }
         //            $extraTotal = $extraTotal + $taxTotal;
         $viewExtras[] = array('id' => $extra->id, 'name' => $extra->getName(), 'type' => $extraTypes[$extra->type], 'value' => $extraTotal, 'tax' => $taxTotal, 'max' => $extra->max, 'min' => $extra->min);
     }
     $controller->view->extras = $viewExtras;
     return $controller->view->render('Extras/summary.phtml');
 }
Exemplo n.º 7
0
 /**
  * Create  folder for media files
  *
  * @param int $unitID - unit primary key value
  * @return bool success or failure;
  */
 function createFolder()
 {
     // get config values
     $rmConfig = new RM_Config();
     $chmodOctal = intval($rmConfig->getValue('rm_config_chmod_value'), 8);
     $folder = $this->getFolder();
     return mkdir($folder, $chmodOctal, true);
 }
Exemplo n.º 8
0
 public function postDispatch()
 {
     parent::postDispatch();
     $config = new RM_Config();
     if ($config->getValue('rm_config_show_poweredby_logo') === '1') {
         $this->writePoweredByIcon();
     }
 }
Exemplo n.º 9
0
 protected function _getUpgradeURL($extensionName)
 {
     $config = new RM_Config();
     $licenseKey = $config->getValue('rm_config_licensekey');
     if ($licenseKey == "") {
         return false;
     }
     $sourceFile = RM_Environment::getInstance()->getDistroURL() . "d.php?d=" . base64_encode('{"d": "' . $_SERVER['SERVER_NAME'] . '", "l": "' . $licenseKey . '", "v":"0", "p": "' . $extensionName . '", "qt": "validate"}');
     return $sourceFile;
 }
Exemplo n.º 10
0
 protected function _init()
 {
     $this->_period = RM_Reservation_Period::getDefault();
     if ($this->_criteria->start_datetime && $this->_criteria->end_datetime) {
         $this->_isDefaultPeriod = false;
         $this->_period = new RM_Reservation_Period(new RM_Date(strtotime($this->_criteria->start_datetime)), new RM_Date(strtotime($this->_criteria->end_datetime)));
     }
     $this->_persons = new RM_Reservation_Persons(array("adults" => $this->_criteria->adults, "children" => $this->_criteria->children, "infants" => $this->_criteria->infants));
     $config = new RM_Config();
     $this->_showPriceWithTax = (bool) $config->getValue('rm_config_prices_with_tax');
     if ($this->_showPriceWithTax) {
         $this->_taxSystem = RM_Environment::getInstance()->getTaxSystem();
     }
 }
Exemplo n.º 11
0
 /**
  * IMPORTANT side effect. This method will automatically authenticate using to CMS if
  * enable_cms_integration is on in config.
  *
  * @param Zend_Request_Interface $request
  * @return bool
  */
 function validate($request)
 {
     $result = true;
     //We check username for alphanumeric
     $username = $request->getParam('username', null);
     $validatorChain = new RM_Validate('Username');
     $usernameResult = $validatorChain->addValidator(new Zend_Validate_Alnum())->isValid($username);
     if (!$usernameResult) {
         $this->_errors = $validatorChain->getErrors();
         $result = false;
     }
     //We check password for alphanumeric
     $password = $request->getParam('password', null);
     $validatorChain = new RM_Validate('Password');
     $passwordResult = $validatorChain->addValidator(new Zend_Validate_Alnum())->isValid($password);
     if (!$passwordResult) {
         $this->_errors = array_merge($this->_errors, $validatorChain->getErrors());
         $result = false;
     }
     $config = new RM_Config();
     $isCmsAuthentication = $config->getValue('rm_config_enable_cms_integration');
     if ($isCmsAuthentication) {
         $authenticationResult = RM_Environment::getConnector()->authenticate($request->getParam('username'), $request->getParam('password'));
         if ($authenticationResult !== true) {
             if (is_object($authenticationResult)) {
                 $this->_errors[] = $authenticationResult->getMessage();
             } else {
                 $this->_errors[] = 'UserNotFound';
             }
             $result = false;
         }
     } else {
         $userModel = new RM_Users();
         $user = $userModel->getBy($request->getParam('username'));
         if ($user === null) {
             $this->_errors[] = 'UserNotFound';
             $result = false;
         }
         //Finally we tries to find existing user in database with the same username/password
         $userModel = new RM_Users();
         $user = $userModel->getBy($request->getParam('username'), $request->getParam('password'));
         if ($user === null) {
             $this->_errors[] = 'WrongPassword';
             $result = false;
         }
     }
     return $result;
 }
Exemplo n.º 12
0
 /**
  * @see system/libs/Zend/Controller/Zend_Controller_Action#preDispatch()
  */
 public function preDispatch()
 {
     $this->view->setTranslate(RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN));
     $this->_translate = RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN);
     $this->view->setRouter($this->getFrontController()->getRouter());
     $config = new RM_Config();
     $this->view->guiDateFormat = $config->getJSDateformat();
     $this->view->GUIMaximisedState = $config->getValue("rm_config_admin_gui_maximised");
     $this->view->mysqlDateFormat = RM_Config::MYSQL_DATEFORMAT;
     $this->view->phpDateFormat = RM_Config::PHP_DATEFORMAT;
     $this->view->calStartDay = $config->getValue("rm_config_calendar_startday");
     $this->view->CMSIntegration = $config->getValue("rm_config_enable_cms_integration");
     $this->view->enableUserGroups = $config->getValue("rm_config_enable_user_groups");
     $this->view->enableUnitsOnTreeMenu = $config->getValue("rm_config_enable_units_on_treemenu");
     $this->view->reservationsListBufferSize = $config->getValue("rm_config_reservations_list_buffersize");
     $this->view->editorType = $config->getValue("rm_config_editor");
 }
Exemplo n.º 13
0
 /**
  * Create and return new user row from information from reguest.
  * This method is not saving row objcet into database.
  *
  * @param Zend_Request_Interface $request
  * @param int $groupID [optional] default RM_UserGroups::REGULAR
  * @param bool $resmania - if true force system to create resmania user instead of cms user
  */
 function createNewUser($request, $groupID = RM_UserGroups::REGULAR, $resmania = false)
 {
     $fields = $this->_getFieldsByGroup($groupID);
     $notRequestFields = array('group_id', 'cms_id');
     $data = array();
     $data['group_id'] = $groupID;
     foreach ($fields as $field) {
         if ($field->view_new == '1' && in_array($field->column_name, $notRequestFields) === false) {
             $data[$field->column_name] = $request->getParam($field->column_name);
         }
     }
     $config = new RM_Config();
     if ($config->getValue('rm_config_enable_cms_user_creation') && $resmania == false) {
         $connectorObj =& RM_Environment::getConnector();
         $users = $connectorObj->getUsersModel();
         $userInfo = $users->createRow($data);
     } else {
         $userInfo = $this->createRow($data);
     }
     return $userInfo;
 }
Exemplo n.º 14
0
 public function listJsonAction()
 {
     $offset = $this->_getParam('start', null);
     $count = $this->_getParam('limit', null);
     $sort = $this->_getParam('sort', 'id');
     $direction = $this->_getParam('dir', 'ASC');
     $query = $this->_getParam('query', null);
     $filters = $this->_getParam('filter', array());
     if ($query !== null) {
         $chunks = explode(',', $query);
         foreach ($chunks as $chunk) {
             $chunk = trim($chunk);
             if ($chunk == "") {
                 continue;
             }
             $filter = array('type' => 'string', 'value' => trim($chunk));
             $filters[] = array('field' => 'rm_users.first_name', 'data' => $filter);
             $filters[] = array('field' => 'rm_users.last_name', 'data' => $filter);
         }
     }
     $group = "";
     $configModel = new RM_Config();
     $userGroupsEnabled = $configModel->getValue('rm_config_enable_user_groups');
     if ($userGroupsEnabled) {
         $group = RM_UserGroups::REGULAR;
     }
     $order = $sort . ' ' . $direction;
     $dao = new RM_Users();
     $total = $dao->getAll($group, $order, null, null, $filters, RM_Users::FILTER_TYPE_OR)->count();
     $users = $dao->getAll($group, $order, $count, $offset, $filters, RM_Users::FILTER_TYPE_OR)->toArray();
     // title replacement from Int to string
     $users = $dao->userTitles($users, str_replace(chr(39), chr(34), $this->_translate->_('Common.JSON', 'Titles')));
     // type replacement from int to string
     $users = $dao->userTypes($users, str_replace(chr(39), chr(34), $this->_translate->_('Common.JSON', 'Types')));
     $json = new stdClass();
     $json->total = $total;
     $json->data = $users;
     return array("data" => $json);
 }
Exemplo n.º 15
0
 /**
  * Copy folder recursive (with all sub folders and files)
  *
  * @params string $source - the source folder
  * @params string $destination - the destination folder
  * @params array $skipSources - [optional][default=array()] array of relative paths (from RM root) of
  * files and folders that need to be skipped while copy process
  * @return bool
  */
 public function recursivecopy($source, $destination, &$skipSources = array())
 {
     $return = true;
     $rmConfig = new RM_Config();
     $chmodOctal = intval($rmConfig->getValue('rm_config_chmod_value'), 8);
     $dir = dir($source);
     while (false !== ($entry = $dir->read())) {
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         $fullPathDestination = $destination . DIRECTORY_SEPARATOR . $entry;
         $skipped = false;
         foreach ($skipSources as $skipSource) {
             if (strpos($fullPathDestination, $skipSource) !== false) {
                 $skipped = true;
                 break;
             }
         }
         if ($skipped) {
             continue;
         }
         $fullPathEntry = $source . DIRECTORY_SEPARATOR . $entry;
         if (is_file($fullPathEntry)) {
             $return &= copy($fullPathEntry, $fullPathDestination);
         } elseif (is_link($fullPathEntry)) {
             $return &= symlink(readlink($fullPathEntry), $fullPathDestination);
         } elseif (is_dir($fullPathEntry)) {
             if (!is_dir($fullPathDestination)) {
                 $return &= mkdir($fullPathDestination);
                 chmod($fullPathDestination, $chmodOctal);
                 // allows deletion via ftp
             }
             // Deep copy directories using recursion
             $return &= $this->recursivecopy($fullPathEntry, $fullPathDestination, $skipSources);
         }
     }
     $dir->close();
     return $return;
 }
Exemplo n.º 16
0
 /**
  * This method will send email to related recipient (depending on various options)
  *
  * @param  $message
  * @return void
  */
 protected function _send($message)
 {
     switch ($this->_emailNotification->destination) {
         case RM_EmailNotifications::REGULAR_USER:
             $user = $this->_eventData->getUser();
             $this->_doSend($message, $user->email);
             break;
         case RM_EmailNotifications::ADMINISTRATOR:
             $configModel = new RM_Config();
             $adminEmail = $configModel->getValue('rm_config_administrator_email');
             $this->_doSend($message, $adminEmail);
             break;
     }
 }
Exemplo n.º 17
0
 public function toString()
 {
     $config = new RM_Config();
     return $config->getValue('rm_config_currency_symbol') . $this->_discount->amount;
 }
Exemplo n.º 18
0
 /**
  * This method should check if user is already loginned into CMS and if
  * we have linked user in the Resmania we need to set this user object to RM_Reservation_Manager class.
  *
  * @return bool
  */
 public function initUser()
 {
     $config = new RM_Config();
     if ($this->_module == 'admin' && (int) $config->getValue('rm_config_enable_user_groups') === 0) {
         return;
     }
     $user = RM_Reservation_Manager::getInstance()->getUser();
     if ($user !== null) {
         return;
     }
     if ($config->getValue('rm_config_enable_cms_integration')) {
         $cmsUser = RM_Environment::getConnector()->getUser();
         if ($cmsUser->isGuest()) {
             return;
         }
         $user = $cmsUser->findResmaniaUser();
         if ($user == null) {
             $user = $cmsUser->convertToResmaniaUser();
         }
         RM_Reservation_Manager::getInstance()->setUser($user);
     }
 }
Exemplo n.º 19
0
 /**
  * Method for price calculation for the reservation edit page
  */
 public function getpriceJsonAction()
 {
     $unit_id = $this->_getParam('unit_id');
     $periods = $this->_getParam('periods');
     $persons = $this->_getParam('persons');
     $otherinfo = $this->_getParam('otherinfo', array());
     // format the other info data
     $otherinfoArray = Zend_Json::decode($otherinfo);
     $unitModel = new RM_Units();
     $priceSystem = RM_Environment::getInstance()->getPriceSystem();
     $jsonDetails = array();
     $unit = $unitModel->get($unit_id);
     $currentUnit = $unit;
     // save this information for later
     // group handling (only used when the groups is enabled)
     $templateUnitID = $unit->isTemplateUnit();
     if ($templateUnitID !== null) {
         if ($templateUnitID !== (int) $unit_id) {
             // if it's not the main template unit then switch to the main template
             // unit to get the price information
             $unit = $unitModel->get($templateUnitID);
         }
     }
     $jsonUnit = new stdclass();
     $jsonUnit->name = $currentUnit->name;
     $jsonUnit->id = $currentUnit->id;
     $periodArray = Zend_Json::decode($periods);
     $personArray = Zend_Json::decode($persons);
     $jsonPeriod = new stdclass();
     $config = new RM_Config();
     $jsonPeriod->start = $config->convertDates($periodArray['start'], RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT);
     $jsonPeriod->end = $config->convertDates($periodArray['end'], RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT);
     $json = new stdclass();
     $json->unit = $jsonUnit;
     $json->period = $jsonPeriod;
     $json->otherinfo = $otherinfoArray[0];
     $persons = new RM_Reservation_Persons($personArray);
     $information = new RM_Prices_Information($unit, new RM_Reservation_Period(new RM_Date(strtotime($periodArray['start'])), new RM_Date(strtotime($periodArray['end']))), $persons, $otherinfoArray[0]);
     $jsonResponce = new stdClass();
     try {
         $totalPrice = $priceSystem->getTotalUnitPrice($information);
         $jsonResponce->success = true;
     } catch (RM_Exception $e) {
         $totalPrice = 0;
         $jsonResponce->error = $e->getMessage();
         $jsonResponce->success = false;
     }
     $config = new RM_Config();
     $currencySymbol = $config->getValue('rm_config_currency_symbol');
     $json->price = $currencySymbol . $totalPrice;
     $jsonDetails[] = $json;
     $jsonResponce->details = $jsonDetails;
     return array('data' => $jsonResponce);
 }
Exemplo n.º 20
0
 /**
  * Method to get a string representation of this object
  *
  * @param RM_Taxes_Row $taxRow
  * @param float $amount
  */
 public function toString(RM_Taxes_Row $taxRow)
 {
     $config = new RM_Config();
     return $config->getValue('rm_config_currency_symbol') . $taxRow->amount;
 }
Exemplo n.º 21
0
 /**
  * Action for validating user details form parameters.
  *
  * If some of the parameters are invalid this method will redirect user to previous page with error
  * text messages about every wrong parameter.
  * If all user detail information is valid this method will save user information into global
  * reservation manager object and will redirect user to the next step of the reservation process.
  */
 function detailsvalidateAction()
 {
     $this->_withoutView();
     $user = RM_Reservation_Manager::getInstance()->getUser();
     if ($user == null || $user->isGuest()) {
         $userModel = new RM_Users();
         // validate reCaptcha
         $config = new RM_Config();
         $useReCaptcha = $config->getValue('rm_config_recaptcha_enabled');
         if ($useReCaptcha) {
             $reCaptcha = new RM_Captcha_Recaptcha();
             if (!$reCaptcha->validate()) {
                 RM_Reservation_Manager::getInstance()->resetFormErrors('userdetails')->setFormErrors('userdetails', RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_ERRORS)->_('RM.User.Creation', 'CaptchaIncorrect'))->save();
                 $user = $userModel->createNewUser($this->getRequest(), RM_UserGroups::REGULAR, true);
                 RM_Reservation_Manager::getInstance()->setUser($user);
                 $this->_redirect('User', 'userdetails');
             }
         }
         try {
             $user = $userModel->createNewUser($this->getRequest());
         } catch (RM_Exception $e) {
             RM_Reservation_Manager::getInstance()->resetFormErrors('userdetails')->setFormErrors('userdetails', RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_ERRORS)->_('RM.User.Creation', $e->getMessage()))->save();
             $user = $userModel->createNewUser($this->getRequest(), RM_UserGroups::REGULAR, true);
             RM_Reservation_Manager::getInstance()->setUser($user);
             $this->_redirect('User', 'userdetails');
         }
     }
     //Save user object in global reservation manager object
     RM_Reservation_Manager::getInstance()->setUser($user);
     $this->_fireUserCreationEvent();
     $formModel = new RM_Forms();
     $form = $formModel->find('userdetails')->current();
     $valid = $form->validate($this->getRequest());
     if ($valid) {
         RM_Reservation_Manager::getInstance()->resetFormErrors('userdetails')->save();
         //TODO: add code for getting next stage controller/action from admin preferences
         $controller = 'Reservations';
         $action = 'summary';
         $this->_redirect($controller, $action);
     } else {
         RM_Reservation_Manager::getInstance()->setFormErrors('userdetails', $form->getErrors())->save();
         $this->_redirect('User', 'userdetails');
     }
 }
Exemplo n.º 22
0
 static function getDefaultOrder()
 {
     $config = new RM_Config();
     return $config->getValue('rm_config_unit_list_order');
 }
Exemplo n.º 23
0
 public function editJsonAction()
 {
     $json = new stdClass();
     $id = $this->_getParam('id');
     $iso = $this->_getParam('iso', RM_Environment::getInstance()->getLocale());
     $unitModel = new RM_Units();
     $unit = $unitModel->get($id, $iso);
     $config = new RM_UnitConfig();
     $fields = $config->getEditFormByUnit($unit);
     $config = new RM_Config();
     // view_preferences_1 provides non html editors, just raw editors
     foreach ($fields as $field) {
         if ($config->getValue('rm_config_editor') == "text" && $field->view_preferences_1 !== "") {
             $jsonFields[] = $field->view_preferences_1;
         } else {
             $jsonFields[] = $field->view_preferences;
         }
     }
     $reservationModel = new RM_Reservations();
     $reservations = $reservationModel->fetchAllByUnit($unit);
     $jsonReservations = array();
     /*
      * the reservation information required to add events to the calendar must include
      * the start and end date but also the unit color.
      */
     foreach ($reservations as $reservation) {
         $jsonReservation = new stdClass();
         $jsonReservation->start_date = $config->convertDates($reservation->start_datetime, RM_Config::MYSQL_DATEFORMAT, RM_Config::MYSQL_DATEFORMAT_SHORT);
         $jsonReservation->end_date = $config->convertDates($reservation->end_datetime, RM_Config::MYSQL_DATEFORMAT, RM_Config::MYSQL_DATEFORMAT_SHORT);
         $jsonReservation->color = $unit->color;
         // unit color
         $jsonReservations[] = $jsonReservation;
     }
     $priceSystems = RM_Environment::getInstance()->getPriceSystem()->getAllPriceSystems();
     $jsonPriceSystems = array();
     foreach ($priceSystems as $system) {
         $jsonPriceSystems[] = $system->name;
     }
     $priceSystem = RM_Environment::getInstance()->getPriceSystem()->getRealPriceSystem($unit);
     // group handling (only used when the groups is enabled)
     $isGroupTemplate = 0;
     if ($unit->isTemplateUnit() === (int) $unit->id) {
         $isGroupTemplate = 1;
     } elseif ($unit->isTemplateUnit() === null || $unit->isTemplateUnit() === 0) {
         // if this unit is not in a group then we set the isGroupTemplate true
         // as this is really the same as a template for the GUI
         $isGroupTemplate = 1;
     }
     $json = "{ unit : " . Zend_Json::encode($unitModel->convertToGUI($unit->toArray())) . ", isgrouptemplate: '" . $isGroupTemplate . "', fields : [" . implode(',', $jsonFields) . "], periods: " . Zend_Json::encode($jsonReservations) . ", language: '" . $iso . "', price: '" . $priceSystem->name . "', prices: " . Zend_Json::encode($jsonPriceSystems) . "}";
     return array('data' => $json, 'encoded' => true);
 }
Exemplo n.º 24
0
 /**
  * Returns latest extensions versions in format:
  * array(
  *  modules =>
  *      [ <module name> => '<version number in std php format>' ]
  *  plugins =>
  *      [ <plugin name> => '<version number in std php format>' ]
  * )
  * or null is connection to server is lost
  *
  * @return array|null
  */
 public function getExtensionVersions()
 {
     $frontendName = 'Core';
     $frontendOptions = array();
     $frontendOptions['lifetime'] = Zend_Registry::get('config')->get('cache')->get('lifetime');
     $frontendOptions['automatic_serialization'] = true;
     $backendName = 'File';
     $backendOptions = array();
     $cacheDir = self::getConnector()->getRootPath() . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . 'userdata' . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR . 'extensions';
     if (is_dir($cacheDir) == false) {
         $rmConfig = new RM_Config();
         $chmodOctal = intval($rmConfig->getValue('rm_config_chmod_value'), 8);
         mkdir($cacheDir, $chmodOctal);
     }
     $backendOptions['cache_dir'] = $cacheDir;
     $backendOptions['file_name_prefix'] = 'rm_extensions_cache';
     $cacheName = 'versions';
     $cache = Zend_Cache::factory($frontendName, $backendName, $frontendOptions, $backendOptions);
     if ($config = $cache->load($cacheName)) {
         return $config;
     }
     $configJson = @file_get_contents($this->_extensionVersionURL);
     try {
         if (isset($configJson) && $configJson !== false) {
             $config = Zend_Json::decode($configJson, Zend_Json::TYPE_ARRAY);
             $cache->save($config, $cacheName);
             return $config;
         } else {
             return null;
         }
     } catch (Exception $e) {
         return null;
     }
 }
Exemplo n.º 25
0
 /**
  * Initialize internal state of the paypal class
  *
  * @param string $invoiceNumber
  * @param string $description - the text description for the payment
  * @param string $total - the total amount to be charged
  * @throw RM_Exception
  * @return void
  */
 public function initialize($invoiceNumber, $description, $total)
 {
     $config = $this->_getConfig();
     if (!$config) {
         //TODO: add language constant
         throw new RM_Exception('No PayPal config defined.');
     }
     $configModel = new RM_Config();
     $currencyISO = $configModel->getValue('rm_config_currency_iso');
     $this->_addField('business', $config['account']);
     $this->_addField('notify_url', RM_Environment::getInstance()->getRouter()->_('PayPal_External', 'ipn'));
     $this->_addField('item_name', $description);
     $this->_addField('invoice', $invoiceNumber);
     $this->_addField('currency_code', $currencyISO);
     $this->_addField('amount', $total);
 }
Exemplo n.º 26
0
 /**
  * Initialize all objects at a first time, or if config has been changed.
  */
 public static function initialize()
 {
     self::$_list = array();
     $adminThumbnail = new RM_Media_Image();
     $adminThumbnail->_postfix = self::ADMIN;
     $adminThumbnail->_width = 100;
     $adminThumbnail->_height = 100;
     $adminThumbnail->_quality = 100;
     $adminThumbnail->_keepAspect = true;
     self::$_list[self::ADMIN] = $adminThumbnail;
     $config = new RM_Config();
     $thumbnail = new RM_Media_Image();
     $thumbnail->_postfix = self::THUMB;
     $thumbnail->_width = $config->getValue('rm_config_image_thumb_settings_x_res');
     $thumbnail->_height = $config->getValue('rm_config_image_thumb_settings_y_res');
     $thumbnail->_quality = $config->getValue('rm_config_image_thumb_settings_quality');
     $thumbnail->_keepAspect = (bool) $config->getValue('rm_config_image_thumb_settings_aspect');
     self::$_list[self::THUMB] = $thumbnail;
     $main = new RM_Media_Image();
     $main->_postfix = self::MAIN;
     $main->_width = $config->getValue('rm_config_image_settings_x_res');
     $main->_height = $config->getValue('rm_config_image_settings_y_res');
     $main->_quality = $config->getValue('rm_config_image_settings_quality');
     $main->_keepAspect = (bool) $config->getValue('rm_config_image_settings_aspect');
     self::$_list[self::MAIN] = $main;
 }
Exemplo n.º 27
0
 /**
  * Full installation process of plugin
  *
  * @param string $tempFileName
  * @param string $tempFilePath
  * @param stdclass $json
  * @return stdclass
  */
 function install($tempFileName, $tempFilePath, $json)
 {
     // get config values
     $rmConfig = new RM_Config();
     $chmodOctal = intval($rmConfig->getValue('rm_config_chmod_value'), 8);
     $rootPath = RM_Environment::getConnector()->getRootPath();
     $chunks = explode('.', $tempFileName);
     $pluginName = $chunks[0];
     //Plugin name will be always the first chunk, example: price.0.1.1.zip
     $pluginModel = new RM_Plugins();
     $existingPlugin = $pluginModel->fetchByName($pluginName);
     if ($existingPlugin !== null) {
         unlink($tempFilePath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'PluginAlreadyInstalled'));
     }
     $pluginFolderPath = $rootPath . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $pluginName;
     if (is_dir($pluginFolderPath)) {
         $result = RM_Filesystem::deleteFolder($pluginFolderPath);
         if ($result == false) {
             unlink($tempFilePath);
             throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'PluginFolderAlreadyExists') . ': ' . $pluginFolderPath);
         }
     }
     $result = mkdir($pluginFolderPath, $chmodOctal);
     if ($result == false) {
         unlink($tempFilePath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'CreatePluginFolderFailer'));
     } else {
         $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'PluginFolderCreatedSuccessfully'));
     }
     //4. unzip plugin into new directory
     if (!extension_loaded('zlib')) {
         unlink($tempFilePath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'ZlibNotSupported'));
     }
     $zip = new PclZip($tempFilePath);
     $result = $zip->extract(PCLZIP_OPT_PATH, $pluginFolderPath);
     if (!$result) {
         unlink($tempFilePath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'UnzipFailed'));
     } else {
         $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'UnzipSuccessfully'));
     }
     unlink($tempFilePath);
     chmod($pluginFolderPath, $chmodOctal);
     //4.0. create separate folder in 'userdata/plugins' for a new plugin
     $userdataFolderPath = $rootPath . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . 'userdata' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $pluginName;
     if (is_dir($userdataFolderPath)) {
         $result = RM_Filesystem::deleteFolder($userdataFolderPath);
         if ($result == false) {
             throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'PluginFolderAlreadyExists') . ': ' . $userdataFolderPath);
         }
     }
     $result = mkdir($userdataFolderPath . DIRECTORY_SEPARATOR, $chmodOctal);
     if ($result == false) {
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'CreatePluginUserdataFolderFailer'));
     } else {
         $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'PluginFolderCreatedSuccessfully'));
     }
     @rename($pluginFolderPath . DIRECTORY_SEPARATOR . 'views', $userdataFolderPath . DIRECTORY_SEPARATOR . 'views');
     @chmod($pluginFolderPath . DIRECTORY_SEPARATOR . 'views', $chmodOctal);
     @rename($pluginFolderPath . DIRECTORY_SEPARATOR . 'languages', $userdataFolderPath . DIRECTORY_SEPARATOR . 'languages');
     @chmod($pluginFolderPath . DIRECTORY_SEPARATOR . 'languages', $chmodOctal);
     @rename($pluginFolderPath . DIRECTORY_SEPARATOR . 'css', $userdataFolderPath . DIRECTORY_SEPARATOR . 'css');
     @chmod($pluginFolderPath . DIRECTORY_SEPARATOR . 'css', $chmodOctal);
     @rename($pluginFolderPath . DIRECTORY_SEPARATOR . 'images', $userdataFolderPath . DIRECTORY_SEPARATOR . 'images');
     @chmod($pluginFolderPath . DIRECTORY_SEPARATOR . 'images', $chmodOctal);
     @chmod($userdataFolderPath, $chmodOctal);
     //5. get INI file
     $iniFilePath = $pluginFolderPath . DIRECTORY_SEPARATOR . self::$_iniFilename;
     if (is_file($iniFilePath) == false) {
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'NoIniFile'));
     }
     //6. parse INI file
     $parser = new RM_Plugin_Config_Parser();
     try {
         $config = $parser->getConfig($iniFilePath);
     } catch (RM_Exception $e) {
         //Error in ini file parsing
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($e->getMessage());
     }
     //Check: could be a module if no 'module' value is in config
     if ($config->information['module'] == "") {
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'WrongTryToInstallModule'));
     }
     $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'UnzipSuccess'));
     //7. invoke SQL install file
     try {
         $result = self::installDatabase($pluginFolderPath);
     } catch (Exception $e) {
         self::uninstallDatabase($pluginFolderPath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($e->getMessage());
     }
     if ($result == false) {
         self::uninstallDatabase($pluginFolderPath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'WrongInstallSQLQueries'));
     } else {
         $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'InstallSQLSuccess'));
     }
     //8. create a new record in Plugin database
     $pluginRow = array();
     $pluginRow = $config->information;
     $pluginRow['module_name'] = $pluginRow['module'];
     unset($pluginRow['module']);
     //convert creation date into MySQL format
     $rmConfig = new RM_Config();
     $pluginRow['creation_date'] = $rmConfig->convertDates(strtotime($pluginRow['creation_date']), RM_Config::TIMESTAMP_DATEFORMAT, RM_Config::MYSQL_DATEFORMAT);
     //TODO:
     //1.check the insertions
     $pkey = $pluginModel->insert($pluginRow);
     //Create a new records in dependencies database table
     $model = new RM_Dependencies();
     if (is_array($config->dependencies)) {
         foreach ($config->dependencies as $dependency) {
             $model->insert($dependency);
         }
     }
     //9. get the main class of the plugin
     $pluginClassFilepath = $pluginFolderPath . DIRECTORY_SEPARATOR . RM_Plugin_Config::CLASSES . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . 'Plugin' . DIRECTORY_SEPARATOR . $config->information['name'] . '.php';
     if (is_file($pluginClassFilepath) == false) {
         self::uninstallDatabase($pluginFolderPath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'DoesntExists'));
     }
     require_once $pluginClassFilepath;
     $pluginClassName = 'RM_Plugin_' . $config->information['name'];
     if (class_exists($pluginClassName) == false) {
         self::uninstallDatabase($pluginFolderPath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($pluginClassName . $this->_translate->_('Admin.Plugins.InstallMsg', 'DoesntExists'));
     }
     $pluginObject = new $pluginClassName();
     if (!$pluginObject instanceof RM_Plugin_Interface) {
         self::uninstallDatabase($pluginFolderPath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($pluginClassName . $this->_translate->_('Admin.Plugins.InstallMsg', 'WrongInterface'));
     }
     //10. invoke install method of that class (if we need something extra)
     $result = $pluginObject->install();
     $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'InstallSuccess'));
     //Check dependencies and if some of them is validate==false disable plugin
     $dependencyManager = new RM_Dependency_Manager();
     $plugin = $pluginModel->find($pkey)->current();
     $dependencies = $dependencyManager->getDependencies($plugin);
     foreach ($dependencies as $dependency) {
         if ($dependency->validate() == false) {
             try {
                 $pluginModel->disable($plugin);
                 break;
             } catch (Exception $e) {
                 //TODO: add log message that we could not disable this module.
             }
         }
     }
     return $json;
 }
Exemplo n.º 28
0
 function summaryvalidateAction()
 {
     $formModel = new RM_Forms();
     $form = $formModel->find('summary')->current();
     $valid = $form->validate($this->getRequest());
     if ($valid == false) {
         RM_Reservation_Manager::getInstance()->setFormErrors('summary', $form->getErrors())->save();
         $this->_redirect('Reservations', 'summary');
     }
     //Apply extras
     $extrasSystems = RM_Environment::getInstance()->getExtrasSystems();
     if (count($extrasSystems) !== 0) {
         $details = RM_Reservation_Manager::getInstance()->getAllDetails();
         foreach ($details as $detail) {
             foreach ($extrasSystems as $extrasSystem) {
                 $newDetail = $extrasSystem->applySelection($this->getRequest(), $detail);
                 if (false === $newDetail) {
                     RM_Reservation_Manager::getInstance()->setFormErrors('summary', array('ExtrasSelectionIsWrong'))->save();
                     $this->_redirect('Reservations', 'summary');
                 }
             }
             RM_Reservation_Manager::getInstance()->addDetails($newDetail);
         }
     }
     //Apply others
     $othersSystems = RM_Environment::getInstance()->getOthersSystems();
     if (count($othersSystems) !== 0) {
         $details = RM_Reservation_Manager::getInstance()->getAllDetails();
         foreach ($details as $detail) {
             foreach ($othersSystems as $othersSystem) {
                 $newDetail = $othersSystem->applySelection($this->getRequest(), $detail);
                 if (false === $newDetail) {
                     RM_Reservation_Manager::getInstance()->setFormErrors('summary', array('OthersSelectionIsWrong'))->save();
                     $this->_redirect('Reservations', 'summary');
                 }
             }
             RM_Reservation_Manager::getInstance()->addDetails($newDetail);
         }
     }
     // Create the User
     $manager = RM_Reservation_Manager::getInstance();
     if ($manager->getCriteria() === null) {
         $this->_redirect('Reservations', 'sessiontimedout');
     }
     $user = $manager->getUser();
     // this is the resmania user instance
     $loginStatus = RM_Environment::getConnector()->getLoginStatus();
     // get the Host CMS login status.
     if (isset($user)) {
         if (!$loginStatus) {
             // check if the user is logged into the CMS
             $userPassword = $user->password;
             //This in unencrypted one, we need to login to cms.
             $registered = $user->isRegistered();
             if ($registered == false) {
                 // if we are not logged in and not registered, register the user
                 $config = new RM_Config();
                 if ($config->getValue('rm_config_enable_cms_user_creation')) {
                     $user->setTable(RM_Environment::getConnector()->getUsersModel());
                 } else {
                     $user->setTable(new RM_Users());
                 }
                 if ($user->group_id == null) {
                     $user->group_id = RM_UserGroups::REGULAR;
                 }
                 $user->save();
             }
             // login
             RM_Environment::getConnector()->authenticate($user->username, $userPassword);
         }
     }
     // save the reservation with the in_progress flag set as true.
     // this manse the reservation will not be visable until the processing is complete.
     $reservationModel = new RM_Reservations();
     // we need to check is there a reservation in status progress in database with the same
     // id as we have here.
     $inProgressReservation = $reservationModel->find($manager->getReservationID())->current();
     if ($inProgressReservation !== null) {
         if ($inProgressReservation->in_progress == 1) {
             $inProgressReservation->delete();
         } else {
             //we already have a full stored reservation in database so we need reset Manager and go to the first page
             $manager->reset();
             $this->_redirect('Unit', 'list');
         }
     }
     $reservationModel->insertNewReservation($manager->getUser(), $manager->getAllDetails(), 1, 0, $manager->getReservationID());
     RM_Log::toLog("New Reservation Created with the ID: " . $manager->getReservationID());
     // direct the process to the payment provider form...
     $this->_forward('form', RM_Environment::getInstance()->getPaymentSystem()->getControllerName());
 }
Exemplo n.º 29
0
 public function listhtmlJsonAction()
 {
     $reservationID = $this->_getParam('id', null);
     if ($reservationID == null) {
         return array('data' => array('success' => false));
     }
     $reservationModel = new RM_Reservations();
     $reservation = $reservationModel->find($reservationID)->current();
     if ($reservation == null) {
         return array('data' => array('success' => false));
     }
     $unitModel = new RM_Units();
     $reservationDetails = $reservation->getDetails();
     $reservationDetailsJson = array();
     foreach ($reservationDetails as $reservationDetail) {
         $unit = $reservationDetail->findUnit();
         $extrasModel = new RM_Extras();
         $extras = $extrasModel->getByUnit($unit);
         if ($extras->count() == 0) {
             continue;
         }
         $config = new RM_Config();
         $currencySymbol = $config->getValue('rm_config_currency_symbol');
         // tax
         $taxSystem = RM_Environment::getInstance()->getTaxSystem();
         $taxes = $taxSystem->getAllTaxes($unit);
         // we need to create a new reservation details object so that the tax can be calculated
         $periodObj = new RM_Reservation_Period(new RM_Date(strtotime($reservationDetail->start_datetime)), new RM_Date(strtotime($reservationDetail->end_datetime)));
         $persons = new RM_Reservation_Persons(array("adults" => $reservationDetail->adults, "children" => $reservationDetail->children, "infants" => $reservationDetail->infants));
         $fullReservationDetails = new RM_Reservation_Details($unit, $periodObj, $persons, array());
         $summaryModel = new RM_ReservationSummary();
         $extrasJson = array();
         foreach ($extras as $extra) {
             // calculate the tax due on the extra...
             $extraSubTotal = $extra->calculate($reservationDetail);
             $taxTotal = 0;
             foreach ($taxes as $tax) {
                 $taxTotal = $taxTotal + $tax->calculate($extraSubTotal, $fullReservationDetails);
             }
             $extraSubTotal = $extraSubTotal + $taxTotal;
             $extraJson = new stdClass();
             $extraJson->id = $extra->id;
             $extraJson->name = $extra->getName(RM_Environment::getInstance()->getLocale());
             $extraJson->min = (int) $extra->min;
             $extraJson->max = (int) $extra->max;
             $extraJson->type = RM_Environment::getInstance()->getTranslation()->_('Admin.Extras.Type', ucfirst($extra->type));
             $extraJson->price = $currencySymbol . $extraSubTotal;
             $reservationDetailsExtra = $summaryModel->getByDetail($reservationDetail, RM_Module_Extras::SUMMARY_TYPE, $extra->id);
             if ($reservationDetailsExtra == null) {
                 $extraJson->saved_price = $currencySymbol . '0';
                 $extraJson->value = 0;
             } else {
                 $extraJson->saved_price = $currencySymbol . $reservationDetailsExtra->total_amount;
                 $extraJson->value = (int) $reservationDetailsExtra->value;
             }
             $extrasJson[] = $extraJson;
         }
         $unit = $unitModel->get($reservationDetail->unit_id);
         if ($unit == null) {
             $unitName = "DELETED";
         } else {
             $unitName = $unit->name;
         }
         $priceSystem = RM_Prices_Manager::getInstance()->getRealPriceSystem($unit);
         $reservationDetailJson = new stdClass();
         $reservationDetailJson->id = $reservationDetail->id;
         $reservationDetailJson->extras = $extrasJson;
         $reservationDetailJson->unit_id = $reservationDetail->unit_id;
         $reservationDetailJson->unit_name = $unitName;
         $reservationDetailJson->start = $reservationDetail->getStartDatetime($priceSystem->getDateformat(true));
         $reservationDetailJson->end = $reservationDetail->getEndDatetime($priceSystem->getDateformat(true));
         $reservationDetailJson->subtotal = $reservationDetail->total_price;
         $reservationDetailsJson[] = $reservationDetailJson;
     }
     $json = new stdClass();
     $json->details = $reservationDetailsJson;
     return array('data' => $json);
 }
Exemplo n.º 30
0
 /** Download the Core Zip File
  *  step 1
  *
  * @return json
  */
 public function downloadcoreJsonAction()
 {
     $tmpPath = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'temp'));
     if (is_writable($tmpPath)) {
         if (!file_exists($tmpPath . DIRECTORY_SEPARATOR . "upgrade")) {
             if (!@mkdir($tmpPath . DIRECTORY_SEPARATOR . "upgrade")) {
                 return array('data' => array('success' => false, 'msg' => 'Could not create temp upgrade folder'));
             }
         }
     } else {
         return array('data' => array('success' => false, 'msg' => 'Temp Not Writable'));
     }
     $version = RM_Environment::getInstance()->getLatestVersion();
     $config = new RM_Config();
     $licenseKey = $config->getValue('rm_config_licensekey');
     $sourceFileSize = @file_get_contents(RM_Environment::getInstance()->getDistroURL() . "d.php?d=" . base64_encode('{"d": "' . $_SERVER['SERVER_NAME'] . '", "l": "' . $licenseKey . '", "p": "core", "v":"' . $version . '", "qt": "size"}'));
     if ($sourceFileSize === "false") {
         return array('data' => array('success' => false, 'msg' => $this->_translate->_('Common', 'LicenseNotValid')));
     }
     $sourceFile = RM_Environment::getInstance()->getDistroURL() . "d.php?d=" . base64_encode('{"d": "' . $_SERVER['SERVER_NAME'] . '", "l": "' . $licenseKey . '", "p": "core", "v":"' . $version . '"}');
     $this->_setSourceSize($sourceFileSize, $this->_getParam('sessionid'));
     $destinationFile = $tmpPath . DIRECTORY_SEPARATOR . 'upgrade' . DIRECTORY_SEPARATOR . 'core.zip';
     // remove any old versions of core.zip
     unlink($destinationFile);
     if (function_exists('copy')) {
         // check this is enabled
         $copyResult = copy($sourceFile, $destinationFile);
     } else {
         // try to use fopen to copy this instead...
         $rmfs = new RM_Filesystem();
         $copyResult = $rmfs->fileDownload($sourceFile, $destinationFile);
     }
     if (!$copyResult) {
         RM_Log::toLog('Upgrade - Core Download Failed (source: ' . $sourceFile . " destination: " . $destinationFile . ")", RM_Log::ERR);
         return array('data' => array('success' => false, 'msg' => 'Download Failed'));
     }
     RM_Log::toLog('Upgrade - Core Download Completed OK', RM_Log::INFO);
     return array('data' => array('success' => true));
 }