public function get_mc_list_field() { $list = $_POST['list_id']; $form_id = $_POST['form_id']; $mailchimp = new RM_MailChimp_Service(); $form = new RM_Forms(); $form->load_from_db($form_id); $content = $mailchimp->mc_field_mapping($form_id, $form->form_options, $list); echo $content; die; }
public function getNode() { $std = new stdClass(); $std->id = $this->name . '_controlpanelJson_EditJson'; $std->text = $this->getName(); $std->disabled = false; $std->iconCls = 'RM_modules_leaf_icon'; $nodes = array(); $formModel = new RM_Forms(); $globalForms = $formModel->getAllGlobal(); foreach ($globalForms as $form) { $nodeStd = new stdClass(); $nodeStd->text = $form->name; $nodeStd->id = 'FormDesigner_EditJson_' . $form->id; $nodeStd->formID = $form->id; $nodeStd->unitTypeID = RM_UnitTypes::DEFAULT_TYPE; $nodeStd->leaf = true; $nodeStd->iconCls = "RM_module_formdesigner_leaf_icon"; $nodes[] = $nodeStd; } $unitTypesModel = new RM_UnitTypes(); $nonGlobalForms = $formModel->getAllNonGlobal(); $types = $unitTypesModel->fetchAll(); foreach ($types as $type) { $nodeUnit = new stdClass(); $nodeUnit->text = $type->getName(); $nodeUnit->leaf = false; $nodeUnit->expanded = false; $nodeUnit->disabled = true; $nodeUnit->children = array(); foreach ($nonGlobalForms as $form) { $nodeStd = new stdClass(); $nodeStd->text = $form->name; $nodeStd->id = 'FormDesigner_EditJson_' . $form->id . '_' . $type->id; $nodeStd->formID = $form->id; $nodeStd->unitTypeID = $type->id; $nodeStd->leaf = true; $nodeStd->iconCls = "RM_module_formdesigner_leaf_icon"; $nodeUnit->children[] = $nodeStd; } $nodes[] = $nodeUnit; } if (count($nodes) == 0) { $std->leaf = 'true'; } else { $std->expanded = 'true'; $std->children = $nodes; } return $std; }
public function uninstall() { parent::uninstall(); //1. remove template for advanced search panel $rootPath = RM_Environment::getConnector()->getRootPath(); $file = implode(DIRECTORY_SEPARATOR, array($rootPath, 'RM', 'userdata', 'views', 'user', 'scripts', 'Search', 'advanced', 'category_advancedsearch.phtml')); RM_Filesystem::deleteFile($file); //2. remove information about this panel from database in form->state field $formModel = new RM_Forms(); $form = $formModel->find('advancedsearch')->current(); $deleted = $form->deletePanel('category_advancedsearch'); if ($deleted) { $form->save(); } }
function unsetFromForm($panelID) { $panel = $this->find($panelID)->current(); $panelXtype = RM_Form_Naming_Manager::generatePanelXType($panelID); $model = new RM_Forms(); $form = $model->find($panel->form_id)->current()->getForm(); $formState = Zend_Json::decode($form->state); foreach ($formState as $columnKey => $column) { foreach ($column as $key => $panel) { if ($panel['xtype'] == $panelXtype) { unset($formState[$columnKey][$key]); $form->state = Zend_Json::encode($formState); $form->save(); return true; } } } return false; }
public function advancedvalidateJsonAction() { $this->_withoutView(); $formModel = new RM_Forms(); $form = $formModel->find('advancedsearch')->current(); $formvalid = $form->validate($this->getRequest()); $data = $this->_getParam('search', array()); // count records to be returned $criteria = new RM_Unit_Search_Criteria($data); $criteria->publishedOnly = true; $unitModel = new RM_Units(); $totalUnits = $unitModel->getAll($criteria)->count(); // count records end if ($formvalid == false) { $errors = $form->getErrors(); $returnData = array('data' => array('success' => false, 'errors' => $errors, 'count' => $totalUnits)); } else { $errors = $form->getErrors(); $returnData = array('data' => array('success' => true, 'errors' => null, 'count' => $totalUnits)); } return $returnData; }
public function __construct(RM_Forms $be_form) { $this->fields = array(); $this->form_type = RM_BASE_FORM; $this->custom_pre_str = ''; $this->custom_post_str = ''; $this->form_id = $be_form->get_form_id(); $this->form_name = $be_form->get_form_name(); $this->form_options = $be_form->get_form_options(); $this->form_options->form_should_auto_expire = $be_form->get_form_should_auto_expire(); $this->form_options->form_should_send_email = $be_form->get_form_should_send_email(); if (isset($be_form->form_redirect) && $be_form->form_redirect != "none" && $be_form->form_redirect != "") { $this->form_options->redirection_type = $be_form->form_redirect; } else { $this->form_options->redirection_type = null; } $this->form_options->redirect_page = $be_form->get_form_redirect_to_page(); $this->form_options->redirect_url = $be_form->get_form_redirect_to_url(); $this->primary_field_indices = array(); $this->service = new RM_Front_Form_Service(); }
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()); }
function view($model, $service, $request, $params) { if (!$request instanceof RM_Request) { $postdata = file_get_contents("php://input"); $request = json_decode($postdata); if (isset($request->form_id) && (int) $request->form_id) { $model = new RM_Forms(); $model->load_from_db($request->form_id); $model->set((array) $request); $model->update_into_db(); echo 'saved'; } else { echo 'not saved'; } die; } if (isset($request->req['rm_form_id']) && (int) $request->req['rm_form_id']) { $data = new stdClass(); $view = $this->mv_handler->setView('form_view_sett'); $model->load_from_db($request->req['rm_form_id']); $data->model = $model; } else { $data = RM_UI_Strings::get('MSG_FS_NOT_AUTHORIZED'); $view = $this->mv_handler->setView('show_notice'); } $view->render($data); }
public function submissions($model, RM_Front_Service $service, $request, $params) { $i = 0; $user_email = $service->get_user_email(); //var_dump($user_email);die; if (null != $user_email) { if (isset($request->req['submission_id'])) { $submission = new RM_Submissions(); $submission->load_from_db($request->req['submission_id']); if ($submission->get_user_email() == $user_email) { $view = $this->mv_handler->setView('front_submission_data', true); $data = new stdClass(); $settings = new RM_Options(); $data->is_authorized = true; $data->submission = $submission; $data->payment = $service->get('PAYPAL_LOGS', array('submission_id' => $submission->get_submission_id()), array('%d'), 'row', 0, 99999); if ($data->payment != null) { $data->payment->total_amount = $settings->get_formatted_amount($data->payment->total_amount, $data->payment->currency); if ($data->payment->log) { $data->payment->log = maybe_unserialize($data->payment->log); } } $data->notes = $service->get('NOTES', array('submission_id' => $submission->get_submission_id(), 'status' => 'publish'), array('%d', '%s'), 'results', 0, 99999, '*', null, true); $i = 0; if (is_array($data->notes)) { foreach ($data->notes as $note) { $data->notes[$i]->author = get_userdata($note->published_by)->display_name; if ($note->last_edited_by) { $data->notes[$i++]->editor = get_userdata($note->last_edited_by)->display_name; } else { $data->notes[$i++]->editor = null; } } } /* * Check submission type */ $form = new RM_Forms(); $form->load_from_db($submission->get_form_id()); $form_type = $form->get_form_type() == "1" ? "Registration" : "Contact"; $data->form_type = $form_type; $data->form_type_status = $form->get_form_type(); $data->form_name = $form->get_form_name(); $data->form_is_unique_token = $form->get_form_is_unique_token(); /* * User details if form is registration type */ if ($form->get_form_type() == "1") { $email = $submission->get_user_email(); if ($email != "") { $user = get_user_by('email', $email); $data->user = $user; } } return $view->read($data); } else { $view = $this->mv_handler->setView('not_authorized', true); } $msg = RM_UI_Strings::get('MSG_INVALID_SUBMISSION_ID_FOR_EMAIL'); return $view->read($msg); } else { $data = new stdClass(); $data->is_authorized = true; $data->submissions = array(); $data->form_names = array(); $data->submission_exists = false; //data for user page $user = get_user_by('email', $user_email); if ($user instanceof WP_User) { $data->is_user = true; $data->user = $user; $data->custom_fields = $service->get_custom_fields($user_email); } else { $data->is_user = false; } //For pagination of submissions $entries_per_page_sub = 20; $req_page_sub = isset($request->req['rm_reqpage_sub']) && $request->req['rm_reqpage_sub'] > 0 ? $request->req['rm_reqpage_sub'] : 1; $offset_sub = ($req_page_sub - 1) * $entries_per_page_sub; $total_entries_sub = $service->get_submission_count($user_email); $submissions = $service->get_submissions_by_email($user_email, $entries_per_page_sub, $offset_sub); $submission_ids = array(); if ($submissions) { $data->submission_exists = true; foreach ($submissions as $submission) { $form_name = $service->get('FORMS', array('form_id' => $submission->form_id), array('%d'), 'var', 0, 1, 'form_name'); $data->submissions[$i] = new stdClass(); $data->submissions[$i]->submission_ids = array(); $data->submissions[$i]->submission_id = $submission->submission_id; $submission_ids[$i] = $submission->submission_id; $data->submissions[$i]->submitted_on = $submission->submitted_on; $data->submissions[$i]->form_name = $form_name; $data->form_names[$submission->submission_id] = $form_name; $i++; } $settings = new RM_Options(); $data->date_format = get_option('date_format'); $data->payments = $service->get_payments_by_submission_id($submission_ids, 999999, 0, null, true); $i = 0; if ($data->payments) { foreach ($data->payments as $p) { $data->payments[$i]->total_amount = $settings->get_formatted_amount($data->payments[$i]->total_amount, $data->payments[$i]->currency); $i++; } } //For pagination of payments $entries_per_page_pay = 20; $req_page_pay = isset($request->req['rm_reqpage_pay']) && $request->req['rm_reqpage_pay'] > 0 ? $request->req['rm_reqpage_pay'] : 1; $data->offset_pay = $offset_pay = ($req_page_pay - 1) * $entries_per_page_pay; $total_entries_pay = $i; $data->total_pages_pay = (int) ($total_entries_pay / $entries_per_page_pay) + ($total_entries_pay % $entries_per_page_pay == 0 ? 0 : 1); $data->curr_page_pay = $req_page_pay; $data->starting_serial_number_pay = $offset_pay + 1; $data->end_offset_this_page = $data->curr_page_pay < $data->total_pages_pay ? $data->offset_pay + $entries_per_page_pay : $total_entries_pay; //Pagination Ends payments //$data->rm_slug = $request->req['page']; //$data->stat_data = $service->get_form_stats($data->current_form_id, $offset, $entries_per_page); $data->total_pages_sub = (int) ($total_entries_sub / $entries_per_page_sub) + ($total_entries_sub % $entries_per_page_sub == 0 ? 0 : 1); $data->curr_page_sub = $req_page_sub; $data->starting_serial_number_sub = $offset_sub + 1; //Pagination Ends submissions $data->active_tab_index = isset($request->req['rm_tab']) ? (int) $request->req['rm_tab'] : 0; $view = $this->mv_handler->setView('front_submissions', true); return $view->read($data); } elseif ($data->is_user === true) { $data->payments = false; $data->submissions = false; $view = $this->mv_handler->setView('front_submissions', true); return $view->read($data); } else { $view = $this->mv_handler->setView('not_authorized', true); $msg = RM_UI_Strings::get('MSG_NO_SUBMISSION_FRONT'); return $view->read($msg); } } } else { $view = $this->mv_handler->setView('not_authorized', true); $msg = RM_UI_Strings::get('MSG_NOT_AUTHORIZED'); return $view->read($msg); } }
public function process($model, RM_Front_Form_Service $service, $request, $params) { $data = new stdClass(); if (isset($params['form_id']) && $params['form_id']) { $form = new RM_Forms(); $form->load_from_db($params['form_id']); //echo "<pre>",var_dump($form),die(); } else { return; } //Called from PayPal, straight to processing. if (isset($request->req['rm_pproc'])) { if ($request->req['rm_pproc'] == 'success' || $request->req['rm_pproc'] == 'cancel' || $request->req['rm_pproc'] == 'ipn') { //error_log('rm_pproc = '.$request->req['rm_pproc']); $paystate = $service->process_payment(null, null, $service, $request); $params['form'] = $form; $params['is_payment_form'] = true; $params['is_payment_done'] = true; /*else //Pending or cancelation cases { $params['form'] = $form; $params['is_payment_form'] = true; $params['is_payment_done'] = false; }*/ $service->save_form($request, $params); return; } } /* * If register form type then check if user exists */ $user_exists = false; if ($form->form_type == 1 && !is_user_logged_in()) { if ($service->user_exists($form, $request)) { $user_exists = true; } else { Form::clearErrors('form_' . $form->form_id); } } if (isset($request->req['stat_id'])) { $stat_id = $request->req['stat_id']; } else { $stat_id = null; } /* * Validates the form in case form is not expired. */ if ($this->mv_handler->validateForm('form_' . $form->form_id) && !$service->is_form_expired($form) && !$user_exists && !$service->is_browser_reload_duplication($stat_id)) { $params['form'] = $form; // echo "<pre>",var_dump($form),die(); if ($service->is_off_limit_submission($form->form_id)) { die(RM_UI_Strings::get("ALERT_SUBMISSIOM_LIMIT")); } $service->update_stat_entry($stat_id); if ($service->get_setting('enable_mailchimp') == 'yes') { $form_options_mc = $form->get_form_options(); //die; if ($form_options_mc->form_is_opt_in_checkbox == 1) { $should_subscribe = isset($request->req['rm_subscribe_mc']) && $request->req['rm_subscribe_mc'][0] == 1 ? 'yes' : 'no'; } else { $should_subscribe = 'yes'; } if ($should_subscribe == 'yes') { $mailchimp = new RM_MailChimp_Service(); $mc_member = new stdClass(); if (isset($request->req[$form_options_mc->mailchimp_mapped_email])) { $mc_member->email = $request->req[$form_options_mc->mailchimp_mapped_email]; if (isset($request->req[$form_options_mc->mailchimp_mapped_first_name])) { $mc_member->first_name = $request->req[$form_options_mc->mailchimp_mapped_first_name]; } else { $mc_member->first_name = NULL; } if (isset($request->req[$form_options_mc->mailchimp_mapped_last_name])) { $mc_member->last_name = $request->req[$form_options_mc->mailchimp_mapped_last_name]; } else { $mc_member->last_name = NULL; } $mailchimp->subscribe($mc_member, $form_options_mc->mailchimp_list); } } } if (isset($request->req['rm_payment_form'])) { //Do not register user if the payment+registration type form, wait for payment confirmation. $params['is_payment_form'] = true; $params['is_payment_done'] = false; $rd = $service->save_form($request, $params, true, false); //die("xx"); $res = $service->process_payment($form->get_form_id(), $rd, $service, $request); if ($res == 'zero_amount') { $params['is_payment_form'] = true; $params['is_payment_done'] = true; $params['za_user_id'] = $rd->user_id; $rd = $service->save_form($request, $params); //$submission_id = $rd->submission_id; } } else { $rd = $service->save_form($request, $params); $submission_id = $rd->submission_id; } } else { if (isset($request->req['rm_submission_id'])) { $submissions = new RM_Submissions(); $submissions->load_from_db($request->req['rm_submission_id']); } /* * Get all the fields associated with the Form */ $data->fields_data = $service->get_all_form_fields($params['form_id']); $i = 0; if (is_array($data->fields_data) || is_object($data->fields_data)) { foreach ($data->fields_data as $field_data) { $data->fields_data[$i++]->properties = $service->set_properties(maybe_unserialize($field_data->field_options)); } } $data->form = $form; $data->is_auto_generate = false; /* * Checking if password generation is configured */ if ($form->get_form_type() == 1) { $auto_generate = $service->get_setting('auto_generated_password'); if ($auto_generate == "yes") { $data->is_auto_generate = true; } } /* * Check if mailchimp is enabled in options */ if ($service->get_setting('enable_mailchimp') == 'yes') { $data->is_mailchimp_enabled = true; } else { $data->is_mailchimp_enabled = false; } /* * If user role are to be choosen by registrar */ /* echo '<pre>'; print_r($form); */ if (!empty($form->form_options->form_should_user_pick) || !(isset($form->form_user_role) && !empty($form->form_user_role))) { $role_pick = $form->form_options->form_should_user_pick; if ($role_pick) { global $wp_roles; $allowed_roles = array(); $default_wp_roles = $wp_roles->get_names(); $form_roles = $form->get_form_user_role(); if (is_array($form_roles) && count($form_roles) > 0) { foreach ($form_roles as $val) { if (array_key_exists($val, $default_wp_roles)) { $allowed_roles[$val] = $default_wp_roles[$val]; } } } $data->allowed_roles = $allowed_roles; $data->role_as = empty($form->form_options->form_user_field_label) ? RM_UI_Strings::get('LABEL_ROLE_AS') : $form->form_options->form_user_field_label; } } /* * Checking if form is expired */ $data->expired = $service->is_form_expired($form); $data->user_exists = $user_exists; if (isset($submissions)) { $data->submissions = $submissions; } $data->curr_symbol = $service->get_setting('currency_symbol'); $data->currency_pos = $service->get_setting('currency_symbol_position'); $data->stat_id = $service->create_stat_entry($params); if ($service->get_setting('theme') == 'matchmytheme') { $data->submit_btn_fgcolor = $form->form_options->form_submit_btn_color; $data->submit_btn_bgcolor = $form->form_options->form_submit_btn_bck_color; } else { $data->submit_btn_fgcolor = null; $data->submit_btn_bgcolor = null; } $data->expiry_details = $service->get_form_expiry_stats($form); $view = $this->mv_handler->setView("user_form", true); return $view->read($data); } }
public function add_form() { $forms = RM_DBManager::get_all(RM_Forms::get_identifier(), $offset = 0, $limit = 1000, $column = 'form_name,form_id', $sort_by = '', $descending = false); return $forms; }
public function manage($model, $service, $request, $params) { $data = new stdClass(); if (isset($request->req['rm_action'])) { if ($request->req['rm_action'] === 'delete') { $this->remove_field($model, $service, $request, $params); } elseif ($request->req['rm_action'] === 'add_page') { $data->current_page = $this->add_page($model, $service, $request, $params); } elseif ($request->req['rm_action'] === 'delete_page') { $this->delete_page($model, $service, $request, $params); } elseif ($request->req['rm_action'] === 'rename_page') { $this->rename_page($model, $service, $request, $params); } } if (isset($request->req['rm_form_id'])) { $fields_data = $service->get_all_form_fields($request->req['rm_form_id']); } else { die(RM_UI_Strings::get('MSG_NO_FORM_SELECTED')); } $data->fields_data = $fields_data; $data->forms = RM_Utilities::get_forms_dropdown($service); $data->field_types = RM_Utilities::get_field_types(); $data->form_id = $request->req['rm_form_id']; $form = new RM_Forms(); $form->load_from_db($data->form_id); $fopts = $form->get_form_options(); $g = array_keys($data->field_types); if ($data->fields_data && is_array($data->fields_data)) { foreach ($data->fields_data as $in => $out) { if (!in_array($out->field_type, $g)) { unset($data->fields_data[$in]); } } } if (!$fopts->form_pages) { $data->total_page = 1; $data->form_pages = array('Page 1'); } else { $data->total_page = count($fopts->form_pages); $data->form_pages = $fopts->form_pages; } if (!isset($data->current_page)) { $data->current_page = isset($request->req['rm_form_page_no']) ? $request->req['rm_form_page_no'] : 1; } $view = $this->mv_handler->setView("field_manager"); $view->render($data); }
/** * 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'); } }
/** * Save the user override css file contents */ public function savecssJsonAction() { $contents = $this->_getParam('contents'); $formsModel = new RM_Forms(); $result = $formsModel->saveCSSFile($contents); return array('data' => array('success' => $result)); }
public function view($model, RM_Services $service, $request, $params) { if (isset($request->req['rm_submission_id'])) { if (!$model->load_from_db($request->req['rm_submission_id'])) { $view = $this->mv_handler->setView('show_notice'); $data = RM_UI_Strings::get('MSG_DO_NOT_HAVE_ACCESS'); $view->render($data); } else { if (isset($request->req['rm_action']) && $request->req['rm_action'] == 'delete') { $request->req['rm_form_id'] = $model->get_form_id(); $request->req['rm_selected'] = $request->req['rm_submission_id']; $this->remove($model, $service, $request, $params); unset($request->req['rm_selected']); } else { $settings = new RM_Options(); $data = new stdClass(); $data->submission = $model; $data->payment = $service->get('PAYPAL_LOGS', array('submission_id' => $model->get_submission_id()), array('%d'), 'row', 0, 99999); if ($data->payment != null) { $data->payment->total_amount = $settings->get_formatted_amount($data->payment->total_amount, $data->payment->currency); if ($data->payment->log) { $data->payment->log = maybe_unserialize($data->payment->log); } } $data->notes = $service->get('NOTES', array('submission_id' => $model->get_submission_id()), array('%d'), 'results', 0, 99999, '*', null, true); $i = 0; if (is_array($data->notes)) { foreach ($data->notes as $note) { $data->notes[$i]->author = get_userdata($note->published_by)->display_name; if ($note->last_edited_by) { $data->notes[$i++]->editor = get_userdata($note->last_edited_by)->display_name; } else { $data->notes[$i++]->editor = null; } } } /* * Check submission type */ $form = new RM_Forms(); $form->load_from_db($model->get_form_id()); $form_type = $form->get_form_type() == "1" ? "Registration" : "Contact"; $data->form_type = $form_type; $data->form_type_status = $form->get_form_type(); //$data->form_name = $form->get_form_name(); $data->form_is_unique_token = $form->get_form_is_unique_token(); /* * User details if form is registration type */ if ($form->get_form_type() == "1") { $email = $model->get_user_email(); if ($email != "") { $user = get_user_by('email', $email); $data->user = $user; } } $view = $this->mv_handler->setView('view_submission'); $view->render($data); } } } else { throw new InvalidArgumentException(RM_UI_Strings::get('MSG_INVALID_SUBMISSION_ID')); } }
public function manage_form_page($action, $form_id, $page_no = null, $new_page_name = null) { $form = new RM_Forms(); $form->load_from_db($form_id); $fopts = $form->get_form_options(); $form_pages = $fopts->form_pages; switch ($action) { case 'add_page': if ($form_pages == null) { $form_pages = array('Page 1', 'Page 2'); } else { $total_page = count($form_pages); $new_page_no = $total_page + 1; $form_pages[] = 'Page ' . $new_page_no; } break; case 'delete_page': if ($form_pages == null || !$page_no) { return; } else { if ($page_no == 1) { return; } //can't delete first page. if (isset($form_pages[$page_no - 1])) { RM_DBManager::remove_fields_for_page($page_no, $form_id); unset($form_pages[$page_no - 1]); } } break; case 'rename_page': if ($form_pages == null || !$page_no || !$new_page_name) { return; } else { if (isset($form_pages[$page_no - 1])) { $form_pages[$page_no - 1] = $new_page_name; } } break; } $x = (object) array('form_pages' => $form_pages); $form->set_form_options($x); $form->update_into_db(); return count($form_pages); }
/** * Action for validating unit 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 unit detail information is valid this method will save unit information into global * reservation manager object and will redirect user to the next step of the reservation process. */ function detailsvalidateAction() { $this->_withoutView(); $unitID = $this->_getParam('unit_id', null); if ($unitID == null) { $this->_redirect('Unit', 'list'); return; } // this is the subunits if groups is being implemented $selectedUnitIds = json_decode($this->_getParam('selected_unit_ids', "[]")); $quantity = $this->_getParam('quantity', 1); $formModel = new RM_Forms(); $form = $formModel->find('unitdetails')->current(); $valid = $form->validate($this->getRequest()); if ($valid == false) { RM_Reservation_Manager::getInstance()->setFormErrors('unitdetails', $form->getErrors())->save(); $this->_redirect('Unit', 'details', array('unit_id' => $unitID)); } //We have a priority to use a user selected dates on the page, not from criteria if ($this->_request->getParam('rm_calendar_dates', null) != null) { // get the dates from the calendar selection $datesString = $this->_request->getParam('rm_calendar_dates'); $dates = explode(',', $datesString); $startDateMySQL = $dates[0]; $endDateMySQL = $dates[count($dates) - 1]; $adults = $this->_getParam("adults", 1); $children = $this->_getParam("children", 0); $infants = $this->_getParam("infants", 0); $persons = new RM_Reservation_Persons(array("adults" => $adults, "children" => $children, "infants" => $infants)); } else { $criteria = RM_Reservation_Manager::getInstance()->getCriteria(); $startDateMySQL = $criteria->start_datetime; $endDateMySQL = $criteria->end_datetime; $persons = new RM_Reservation_Persons(array("adults" => $criteria->adults, "children" => $criteria->children, "infants" => $criteria->infants)); } $period = new RM_Reservation_Period(new RM_Date(strtotime($startDateMySQL)), new RM_Date(strtotime($endDateMySQL))); $unitModel = new RM_Units(); $otherinfo = $this->_getParam("otherInfo", array()); $manager = RM_Reservation_Manager::getInstance(); // use a temporary session to pass a value to the groups module init $_SESSION["returnAllUnits"] = true; // get price... $unit = $unitModel->get($unitID, RM_Environment::getInstance()->getLocale(), array("summary", "description")); $information = new RM_Prices_Information($unit, $period, $persons, $otherinfo); $priceSystem = RM_Environment::getInstance()->getPriceSystem(); try { $calculatedTotalPrice = $priceSystem->getTotalUnitPrice($information); } catch (RM_Exception $e) { RM_Reservation_Manager::getInstance()->setFormErrors('unitdetails', array($e->getMessage()))->save(); $this->_redirect('Unit', 'details', array('unit_id' => $selectedUnitId)); } $selectedCount = 1; // loop through the selected units and save these foreach ($selectedUnitIds as $selectedUnitId) { if ($selectedCount >= $quantity) { break; } $selectedUnit = $unitModel->get($selectedUnitId, RM_Environment::getInstance()->getLocale()); $details = new RM_Reservation_Details($selectedUnit, $period, $persons, $otherinfo, $calculatedTotalPrice); $manager->addDetails($details); $selectedCount += 1; } $manager->resetFormErrors('unitdetails')->save(); $details = $manager->getAllDetails(); // reset the returnAllUnits if it's set unset($_SESSION["returnAllUnits"]); $cmsUser = RM_Environment::getConnector()->getUser(); if ($cmsUser->isGuest() == false) { $user = $cmsUser->findResmaniaUser(); if ($user !== null) { RM_Reservation_Manager::getInstance()->setUser($user); $this->_redirect('Reservations', 'summary'); } } elseif (RM_Reservation_Manager::getInstance()->getUser() !== null) { $this->_redirect('Reservations', 'summary'); } $this->_redirect('User', 'userdetails'); }