public function executeRating(sfWebRequest $request) { if ($request->isXmlHttpRequest()) { $postParam = $request->getRequestParameters(); $postParam2 = $request->getPostParameters(); if ((array_key_exists('rating', $postParam) || array_key_exists('rating', $postParam2)) && array_key_exists('querytrackid', $postParam) && array_key_exists('resulttrackid', $postParam) && array_key_exists('resultposition', $postParam) && array_key_exists('featurevectortypeid', $postParam) && array_key_exists('distancetypeid', $postParam)) { $rating = array_key_exists('rating', $postParam) ? $postParam['rating'] : $postParam2['rating']; QueryCommentTrackPeer::updateRating($rating, $postParam['querytrackid'], $postParam['resulttrackid'], $postParam['resultposition'], $postParam['featurevectortypeid'], $postParam['distancetypeid']); return $this->renderText($postParam['rating']); } } $this->getResponse()->setStatusCode(500); return $this->renderText("Comment was not saved! Please contact us about the problem." . print_r($postParam, true) . print_r($postParam2, true)); }
/** * * @param sfWebRequest $request * @return WSRequestParameters */ public function extractParameters(sfWebRequest $request) { $webRequestParameters = new WSRequestParameters(); $logger = Logger::getLogger('core.webservices'); $requestMethod = $request->getMethod(); $contentType = $request->getContentType(); $logger->debug("HTTP Method: {$requestMethod}, Content-Type: {$contentType}"); $requestParameters = $request->getRequestParameters(); $logger->debug("Request Parameters: " . print_r($requestParameters, true)); if (!isset($requestParameters['ws_method'])) { throw new WebServiceException('Web service method is not specified', 400); } $webServiceMethod = $requestParameters['ws_method']; $methodParameters = array(); // Checking for deprecated method of sending parameters using an http header $header = $request->getHttpHeader('ohrm_ws_method_parameters'); if (!empty($header)) { $methodParameters = json_decode($header, true); if (!is_array($methodParameters)) { throw new WebServiceException("header ohrm_ws_method_parameters should be json encoded", 400); } } else { // get request parameters in URL (eg: /empNumber/11) after removing the default parameters $methodParameters = array_diff_key($requestParameters, array_flip(array('action', 'module', 'ws_method', '_sf_route'))); // Merge with GET parameters $methodParameters = array_merge($methodParameters, $request->getGetParameters()); // Check for JSON encoded body if ($contentType === 'application/json') { $postParams = json_decode(file_get_contents('php://input'), true); $methodParameters = array_merge($methodParameters, $postParams); } else { if ($requestMethod === 'POST') { $methodParameters = array_merge($methodParameters, $request->getPostParameters()); } } } // $arrayName = $this->getArrayNameForFunction($function); // if(!array_key_exists($arrayName, $methodParameters)) { // throw new WebServiceException('Required array name not provided', 404); // } $webRequestParameters->setRequestMethod($requestMethod); $webRequestParameters->setMethod($webServiceMethod); $webRequestParameters->setParameters($methodParameters); // $webRequestParameters->setAppId($authenticationParamerters['app_id']); // $webRequestParameters->setAppToken($authenticationParamerters['app_token']); // $webRequestParameters->setSessionToken($authenticationParamerters['session_token']); return $webRequestParameters; }
/** * * @param sfWebRequest $request * @return WSRequestParameters */ public function extractParamerts(sfWebRequest $request) { $webRequestParameters = new WSRequestParameters(); $requestMethod = $request->getMethod(); $parameters = array_keys($request->getRequestParameters()); if (count($parameters) < 4) { throw new WebServiceException('Web service method is not specified', 1001); } //$authenticationParamerters = json_decode($request->getHttpHeader('ohrm_ws_auth_parameters'), true); $methodParameters = json_decode($request->getHttpHeader('ohrm_ws_method_parameters'), true); // if (!is_array($authenticationParamerters)) { // throw new WebServiceException('Authentication parameters are sent in a wrong format', 1002); // } if (!is_array($methodParameters)) { throw new WebServiceException('Method parameters are sent in a wrong format', 1003); } $webRequestParameters->setRequestMethod($requestMethod); $webRequestParameters->setMethod($parameters[2]); $webRequestParameters->setParameters($methodParameters); // $webRequestParameters->setAppId($authenticationParamerters['app_id']); // $webRequestParameters->setAppToken($authenticationParamerters['app_token']); // $webRequestParameters->setSessionToken($authenticationParamerters['session_token']); return $webRequestParameters; }
public function executeAdd(sfWebRequest $request) { if ($request->isMethod('post')) { $name = $request->getParameter('reports')['name']; if (!$name) { $this->forwardToSecureAction(); } if (!in_array($name, array_keys(Reports::getGlobalReports($this->getUser())))) { $this->info_message = $this->getI18N()->__("You are not allowed to print this kind of report."); return $this->renderPartial("info_msg", array("info_message" => $this->info_message)); } $default_vals = array(); foreach ($request->getRequestParameters() as $rp_key => $rp_value) { if (strpos($rp_key, 'default_vals[') !== false && strpos($rp_key, ']') !== false && strpos($rp_key, ']') - strpos($rp_key, '[') > 1) { $default_vals[substr($rp_key, strpos($rp_key, '[') + 1, strpos($rp_key, ']') - strpos($rp_key, '[') - 1)] = $rp_value; } } $this->setWidgetsOptions($name); $this->form = new ReportsForm(null, array('fields' => $this->widgets, 'name' => $name, 'model_name' => $request->getParameter('catalogue', 'taxonomy'), 'with_js' => $request->getParameter('with_js', false), 'default_vals' => $default_vals, 'current_user' => $this->getUser())); $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { if (isset($request->getParameter('reports')['loan_id']) && count(Doctrine::getTable('Loans')->getPrintableLoans(array($request->getParameter('reports')['loan_id']), $this->getUser())) == 0) { $this->info_message = $this->getI18n()->__("You don't have the necessary credentials to print this loan"); } else { $this->info_message = $this->getI18n()->__("Your report has been saved. It will be availlable tomorrow"); $report = new Reports(); $report->fromArray(array('name' => $name, 'user_ref' => $this->getUser()->getId(), 'lang' => $this->getUser()->getCulture(), 'format' => $request->getParameter('reports')['format'], 'comment' => $request->getParameter('reports')['comment'])); $report->setParameters($request->getParameter('reports')); // Save the report whatever it's a fast or a non fast one $report->save(); //if it's a fast report, it can be downloaded directly if (Reports::getIsFast($name)) { $response = $this->processDownload($report); if ($response != 0) { $message = json_encode($this->getPartial("info_msg", array("info_message" => $this->info_message))); return $this->renderText('{ "report_url" : "' . $this->generateUrl("default", array("module" => "report", "action" => "downloadFile", "id" => $response), TRUE) . '", "message": ' . $message . ' }'); } } } return $this->renderPartial("info_msg", array("info_message" => $this->info_message)); } $val = $this->renderPartial("report_form", array('form' => $this->form, 'fields' => $this->widgets, 'fields_options' => $this->widgets_options, 'fields_at_second_line' => $this->widgets_second_line_count, 'model_name' => $request->getParameter('catalogue', 'taxonomy'), 'fast' => Reports::getIsFast($name), 'with_js' => $request->getParameter('with_js', false), 'default_vals' => $default_vals)); return $val; } }
public function executeAjaxAddPersonAndPassenger(sfWebRequest $request) { #Security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } //$this->setLayout(false); if ($request->getParameter('add_pass') == 'yes') { $this->person = new Person(); $this->person_title = 'Step 1 : Add person'; if ($request->getParameter('camp_id')) { $this->camp_id = $request->getParameter('camp_id'); } $this->stepped = 1; } if ($request->getParameter('add_pass_iti') == 'yes') { $this->person = new Person(); $this->person_title = 'Step 1 : Add person'; $this->person_itine = 1; } if ($request->getParameter('add_cont') == 'yes') { $this->person = new Person(); $this->person_title = 'Step 1 : Add person'; $this->contact = 1; } if ($request->getParameter('id')) { $this->person = PersonPeer::retrieveByPK($request->getParameter('id')); $this->person_title = 'Edit person'; } else { $this->person = new Person(); $this->person_title = 'Add person'; } # Person Form $this->person_form = new PersonForm($this->person); $this->back = $request->getReferer(); //session $this->key = $request->getParameter('key'); if (!$this->key) { $this->key = rand(1000, 9999); } if (strstr($request->getReferer(), 'person/view')) { if ($this->person) { //session $referer_session = $this->getUser()->getAttribute('ref'); if (!$referer_session) { $referer_session = array($this->key => array()); $this->getUser()->setAttribute('ref', $referer_session); } elseif (!isset($referer_session[$this->key])) { $a = '@person_view?id=' . $this->person->getId(); $referer_session[$this->key] = array('referer' => $a); $this->getUser()->setAttribute('ref', $referer_session[$this->key]); } } } $this->person_referer = $request->getParameter('referer'); if ($request->isMethod('post')) { if ($request->hasParameter('action_from_passenger_or_requester')) { $this->action_from = $request->getParameter('action_from_passenger_or_requester'); } $this->person_referer = $request->getParameter('referer'); $this->person_form->bind($request->getParameter('per')); if ($this->person_form->isValid() && $request->getParameter('per[first_name]') != "" && $request->getParameter('per[last_name]') != "") { $this->person->setTitle($this->person_form->getValue('title')); $this->person->setFirstName($this->person_form->getValue('first_name')); $this->person->setLastName($this->person_form->getValue('last_name')); $this->person->setAddress1($this->person_form->getValue('address1')); $this->person->setAddress2($this->person_form->getValue('address2')); $this->person->setCity($this->person_form->getValue('city')); $this->person->setCounty($this->person_form->getValue('county')); $this->person->setState($this->person_form->getValue('state')); $this->person->setCountry($this->person_form->getValue('country')); $this->person->setZipcode($this->person_form->getValue('zipcode')); $this->person->setDayPhone($this->person_form->getValue('day_phone')); $this->person->setDayComment($this->person_form->getValue('day_comment')); $this->person->setEveningPhone($this->person_form->getValue('evening_phone')); $this->person->setEveningComment($this->person_form->getValue('evening_comment')); $this->person->setMobilePhone($this->person_form->getValue('mobile_phone')); $this->person->setMobileComment($this->person_form->getValue('mobile_comment')); $this->person->setPagerPhone($this->person_form->getValue('paper_phone')); $this->person->setPagerComment($this->person_form->getValue('paper_comment')); $this->person->setOtherPhone($this->person_form->getValue('other_phone')); $this->person->setOtherComment($this->person_form->getValue('other_comment')); $this->person->setFaxPhone1($this->person_form->getValue('fax_phone1')); $this->person->setFaxComment1($this->person_form->getValue('fax_comment1')); $this->person->setAutoFax($this->person_form->getValue('auto_fax')); $this->person->setFaxPhone2($this->person_form->getValue('fax_phone2')); $this->person->setFaxComment2($this->person_form->getValue('fax_comment2')); $this->person->setEmail($this->person_form->getValue('email')); $this->person->setEmailTextOnly($this->person_form->getValue('email_text_only')); $this->person->setEmailBlocked($this->person_form->getValue('email_blocked')); $this->person->setComment($this->person_form->getValue('comment')); //$this->person->setBlockMailings($this->person_form->getValue('block_mailings')==0?null:$this->person_form->getValue('block_mailings')); $this->person->setBlockMailings($this->person_form->getValue('block_mailings')); $this->person->setNewsletter($this->person_form->getValue('newsletter')); $this->person->setGender($this->person_form->getValue('gender')); $this->person->setDeceased($this->person_form->getValue('deceased')); $this->person->setDeceasedComment($this->person_form->getValue('deceased_comment')); $this->person->setSecondaryEmail($this->person_form->getValue('secondary_email')); $this->person->setDeceasedDate($this->person_form->getValue('deceased_date')); $this->person->setMiddleName($this->person_form->getValue('middle_name')); $this->person->setSuffix($this->person_form->getValue('suffix')); $this->person->setNickname($this->person_form->getValue('nickname')); $this->person->setVeteran($this->person_form->getValue('veteran')); if ($this->person->isNew()) { $content = $this->getUser()->getName() . ' added new Person: ' . $this->person->getFirstName(); ActivityPeer::log($content); } $this->person->save(); //////////////////////////////////////#bglobal omar if ($this->person->getId()) { $passenger = new Passenger($this->person->getId()); $passenger->setPersonId($this->person->getId()); $passenger->save(); $c = new Criteria(); $c->add(RoleNotificationPeer::MID, 5); $c->add(RoleNotificationPeer::NOTIFICATION, 1); $c->addOr(RoleNotificationPeer::NOTIFICATION, 3); $c->addJoin(RoleNotificationPeer::ROLE_ID, PersonRolePeer::ROLE_ID); $c->addJoin(PersonRolePeer::PERSON_ID, PersonPeer::ID); $personemail = PersonPeer::doSelect($c); $allemail = array(); $pindex = 0; foreach ($personemail as $getEmail) { if (strlen($getEmail->getEmail()) > 0) { $allemail[$pindex++] = $getEmail->getEmail(); } else { if (strlen($getEmail->getSecondaryEmail()) > 0) { $allemail[$pindex++] = $getEmail->getSecondaryEmail(); } } } //$allemail[$pindex]="*****@*****.**"; /* $email['subject']="New Person added"; $link=$request->getHost()."/person/view/".$this->person->getId(); $body="A new person added in ".$request->getHost()."\r\n" .$this->person->getFirstName()." ".$this->person->getLastName()."\r\n Profile Link: ".$link; $email['body']=$body; $email['sender_email']="*****@*****.**"; $this->getComponent('mail', 'sendBulk', array( 'subject' => $email['subject'], 'recievers' => $allemail, 'sender' => $email['sender_email'], 'body' => $email['body'], ));*/ } ///////////////////////////////////// if ($request->hasParameter('has')) { $data = ''; if ($request->getParameter('camp_id')) { $data = '&camp_id=' . $request->getParameter('camp_id'); } $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!'); $this->redirect('@passenger_create?add_pass='******'has') . '&p_id=' . $this->person->getId() . $data); } if ($request->hasParameter('iti')) { $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!'); $this->redirect('@passenger_create?add_pass_iti=' . $request->getParameter('iti') . '&p_id=' . $this->person->getId()); } if ($request->hasParameter('contact')) { $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add contact!'); $this->redirect('@contact_create?person_id=' . $this->person->getId()); } $this->getUser()->setFlash('success', 'Person information has been successfully saved!'); $last = $request->getParameter('back'); $referer_session = $this->getUser()->getAttribute('ref'); //$back_url = '@person_view?id='.$this->person->getId(); //$this->redirect($back_url); //$this->person_a = $this->person_form->getValue('first_name').' '. $this->person_form->getValue('last_name'); //return $this->renderText('Person information has been successfully saved!'); //return $this->renderText($this->person_form->getValue('first_name').' '. $this->person_form->getValue('last_name')); $this->personpass_id = $this->person->getId(); $this->_passenger = PassengerPeer::getByPersonId($this->personpass_id); $this->personpass_last_name = $this->person->getLastName(); //echo $this->person->getId(); //$this->person_a = $this->person_form->getValue('first_name').' '. $this->person_form->getValue('last_name'); } else { if ($request->getParameter("per[title]") == "") { $this->titleError = "true"; } if ($request->getParameter("per[first_name]") == "") { $this->first_name_error = "true"; } if ($request->getParameter("per[last_name]") == "") { $this->last_name_error = "true"; } } $this->person_form__ = $request->getRequestParameters(); $this->setTemplate("ajaxAddPersonAndPassenger"); } else { # Set referer URL $this->person_referer = $request->getReferer() ? $request->getReferer() : '@person'; } }