当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::setResponseSubject方法代码示例

本文整理汇总了PHP中Response::setResponseSubject方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::setResponseSubject方法的具体用法?PHP Response::setResponseSubject怎么用?PHP Response::setResponseSubject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Response的用法示例。


在下文中一共展示了Response::setResponseSubject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _main

 /**
  * Function called once this service is called
  * 
  * @param Request
  * @return Response
  * */
 public function _main(Request $request)
 {
     // do not allow blank searches
     if (empty($request->query)) {
         $response = new Response();
         $response->setResponseSubject("Debe insertar un texto a buscar");
         $response->createFromText("Usted no ha insertado ning&uacute;n texto a buscar en Wikipedia. Inserte el texto en el asunto del email, justo despu&eacute;s de la palabra WIKIPEDIA.<br/><br/>Por ejemplo: Asunto: WIKIPEDIA jose marti");
         return $response;
     }
     // find the right query in wikipedia
     $correctedQuery = $this->search($request->query);
     if (empty($correctedQuery)) {
         $response = new Response();
         $response->setResponseSubject("Su busqueda no produjo resultados");
         $response->createFromText("Su b&uacute;squeda <b>{$request->query}</b> no fue encontrada en Wikipedia. Por favor modifique el texto e intente nuevamente.");
         return $response;
     }
     // get the HTML code for the page
     $page = $this->get(urlencode($correctedQuery));
     // get the home image
     $imageName = empty($page['images']) ? false : $page['images'][0];
     // create a json object to send to the template
     $responseContent = array("title" => $page['title'], "body" => $page['body'], "image" => $imageName, "isLarge" => $page['isLarge']);
     // send the response to the template
     $response = new Response();
     $response->setResponseSubject("Wikipedia: {$page['title']}");
     $response->createFromTemplate("wikipedia.tpl", $responseContent, $page['images']);
     return $response;
 }
开发者ID:Apretaste,项目名称:wikipedia,代码行数:35,代码来源:service.php

示例2: _main

 /**
  * Function executed when the service is called
  *
  * @param Request
  * @return Response
  * */
 public function _main(Request $request)
 {
     $response = new Response();
     $response->setResponseSubject("Terminos de uso de Apretaste");
     $response->createFromTemplate("basic.tpl", array());
     return $response;
 }
开发者ID:Apretaste,项目名称:Sandbox,代码行数:13,代码来源:service.php

示例3: processAction

 /**
  * Process the page when its submitted
  *
  * @author kuma, salvipascual
  * @version 1.0
  * */
 public function processAction()
 {
     // get the values from the post
     $captcha = trim($this->request->getPost('captcha'));
     $name = trim($this->request->getPost('name'));
     $inviter = trim($this->request->getPost('email'));
     $guest = trim($this->request->getPost('guest'));
     if (!isset($_SESSION['phrase'])) {
         $_SESSION['phrase'] = uniqid();
     }
     // throw a die()
     // check all values passed are valid
     if (strtoupper($captcha) != strtoupper($_SESSION['phrase']) || $name == "" || !filter_var($inviter, FILTER_VALIDATE_EMAIL) || !filter_var($guest, FILTER_VALIDATE_EMAIL)) {
         die("Error procesando, por favor valla atras y comience nuevamente.");
     }
     // params for the response
     $this->view->name = $name;
     $this->view->email = $inviter;
     // create classes needed
     $connection = new Connection();
     $email = new Email();
     $utils = new Utils();
     $render = new Render();
     // do not invite people who are already using Apretaste
     if ($utils->personExist($guest)) {
         $this->view->already = true;
         return $this->dispatcher->forward(array("controller" => "invitar", "action" => "index"));
     }
     // send notification to the inviter
     $response = new Response();
     $response->setResponseSubject("Gracias por darle internet a un Cubano");
     $response->setEmailLayout("email_simple.tpl");
     $response->createFromTemplate("invitationThankYou.tpl", array('num_notifications' => 0));
     $response->internal = true;
     $html = $render->renderHTML(new Service(), $response);
     $email->sendEmail($inviter, $response->subject, $html);
     // send invitations to the guest
     $response = new Response();
     $response->setResponseSubject("{$name} le ha invitado a revisar internet desde su email");
     $responseContent = array("host" => $name, "guest" => $guest, 'num_notifications' => 0);
     $response->createFromTemplate("invitation.tpl", $responseContent);
     $response->internal = true;
     $html = $render->renderHTML(new Service(), $response);
     $email->sendEmail($guest, $response->subject, $html);
     // save all the invitations into the database at the same time
     $connection->deepQuery("INSERT INTO invitations (email_inviter,email_invited,source) VALUES ('{$inviter}','{$guest}','abroad')");
     // redirect to the invite page
     $this->view->message = true;
     return $this->dispatcher->forward(array("controller" => "invitar", "action" => "index"));
 }
开发者ID:Apretaste,项目名称:Core,代码行数:56,代码来源:InvitarController.php

示例4: mainAction

 public function mainAction()
 {
     // inicialize supporting classes
     $timeStart = time();
     $connection = new Connection();
     $email = new Email();
     $service = new Service();
     $service->showAds = true;
     $render = new Render();
     $response = new Response();
     $wwwroot = $this->di->get('path')['root'];
     $log = "";
     // get people who did not finish a survey for the last 3 days
     $surveys = $connection->deepQuery("\n\t\t\tSELECT A.*, B.title, B.deadline, B.value FROM \n\t\t\t(\n\t\t\t\tSELECT email, survey,  \n\t\t\t\tDATEDIFF(CURRENT_DATE, MAX(date_choosen)) as days_since,\n\t\t\t\t(\n\t\t\t\t\tSELECT COUNT(*) \n\t\t\t\t\tFROM _survey_question \n\t\t\t\t\tWHERE _survey_question.survey = _survey_answer_choosen.survey\n\t\t\t\t) as total, \n\t\t\t\tCOUNT(question) as choosen from _survey_answer_choosen GROUP BY email, survey\n\t\t\t) A\n\t\t\tJOIN _survey B\n\t\t\tON A.survey = B.id\n\t\t\tWHERE A.total > A.choosen \n\t\t\tAND A.days_since >= 7\n\t\t\tAND B.active = 1\n\t\t\tAND DATEDIFF(B.deadline, B.date_created) > 0\n\t\t\tAND A.email NOT IN (SELECT DISTINCT email FROM remarketing WHERE type='SURVEY')");
     // send emails to users
     $log .= "\nSURVEY REMARKETING (" . count($surveys) . ")\n";
     foreach ($surveys as $survey) {
         $content = array("survey" => $survey->survey, "days" => $survey->days_since, "missing" => $survey->total - $survey->choosen, "title" => $survey->title, "deadline" => $survey->deadline, "value" => $survey->value);
         // create html response
         $response->setResponseSubject("No queremos que pierda \${$survey->value}");
         $response->createFromTemplate('surveyReminder.tpl', $content);
         $response->internal = true;
         // send email to the person
         $html = $render->renderHTML($service, $response);
         $email->sendEmail($survey->email, $response->subject, $html);
         // add entry to remarketing
         $connection->deepQuery("INSERT INTO remarketing(email, type) VALUES ('{$survey->email}', 'SURVEY');");
         // display notifications
         $log .= "\t{$survey->email} | surveyID: {$survey->survey} \n";
     }
     // get final delay
     $timeEnd = time();
     $timeDiff = $timeEnd - $timeStart;
     // printing log
     $log .= "EXECUTION TIME: {$timeDiff} seconds\n\n";
     echo $log;
     // saving the log
     $logger = new \Phalcon\Logger\Adapter\File("{$wwwroot}/logs/surveyreminder.log");
     $logger->log($log);
     $logger->close();
     // save the status in the database
     $connection->deepQuery("UPDATE task_status SET executed=CURRENT_TIMESTAMP, delay='{$timeDiff}' WHERE task='survey'");
 }
开发者ID:Apretaste,项目名称:Core,代码行数:43,代码来源:SurveyTask.php

示例5: _lista

 public function _lista(Request $request)
 {
     $max = intval($request->query);
     if ($max > 10000) {
         $response = new Response();
         $response->setResponseSubject("Numero demasiado grande para procesar");
         $response->createFromText("El numero {$max} es demasiado grande para procesar la lista de primos.");
         return $response;
     }
     $primos = array();
     for ($i = 1; $i <= $max; $i++) {
         if ($this->esPrimo($i)) {
             $primos[] = $i;
         }
     }
     $response = new Response();
     $response->setResponseSubject("Lista de numeros primos hasta el {$max}");
     $response->createFromTemplate("lista.tpl", array("primos" => $primos, "max" => $max));
     return $response;
 }
开发者ID:Apretaste,项目名称:Sandbox,代码行数:20,代码来源:service.php

示例6: renderResponse


//.........这里部分代码省略.........
         return $render->renderJSON($response);
     }
     // render the template email it to the user
     // only save stadistics for email requests
     if ($format == "email") {
         // get the person, false if the person does not exist
         $person = $utils->getPerson($email);
         // if the person exist in Apretaste
         if ($person !== false) {
             // update last access time to current and make person active
             $connection->deepQuery("UPDATE person SET active=1, last_access=CURRENT_TIMESTAMP WHERE email='{$email}'");
         } else {
             $inviteSource = 'alone';
             // alone if the user came by himself, no invitation
             $sql = "START TRANSACTION;";
             // start the long query
             // check if the person was invited to Apretaste
             $invites = $connection->deepQuery("SELECT * FROM invitations WHERE email_invited='{$email}' AND used=0 ORDER BY invitation_time DESC");
             if (count($invites) > 0) {
                 // check how this user came to know Apretaste, for stadistics
                 $inviteSource = $invites[0]->source;
                 // give prizes to the invitations via service invitar
                 // if more than one person invites X, they all get prizes
                 foreach ($invites as $invite) {
                     switch ($invite->source) {
                         case "internal":
                             // assign tickets and credits
                             $sql .= "INSERT INTO ticket (email, origin) VALUES ('{$invite->email_inviter}', 'RAFFLE');";
                             $sql .= "UPDATE person SET credit=credit+0.25 WHERE email='{$invite->email_inviter}';";
                             // email the invitor
                             $newTicket = new Response();
                             $newTicket->setResponseEmail($invite->email_inviter);
                             $newTicket->setEmailLayout("email_simple.tpl");
                             $newTicket->setResponseSubject("Ha ganado un ticket para nuestra Rifa");
                             $newTicket->createFromTemplate("invitationWonTicket.tpl", array("guest" => $email));
                             $newTicket->internal = true;
                             $responses[] = $newTicket;
                             break;
                         case "abroad":
                             $newGuest = new Response();
                             $newGuest->setResponseEmail($invite->email_inviter);
                             $newGuest->setResponseSubject("Tu amigo ha atendido tu invitacion");
                             $inviter = $utils->usernameFromEmail($invite->email_inviter);
                             $pInviter = $utils->getPerson($invite->email_inviter);
                             if (!isset($pInviter->name)) {
                                 $pInviter->name = '';
                             }
                             if ($pInviter !== false) {
                                 if (trim($pInviter->name) !== '') {
                                     $inviter = $pInviter->name;
                                 }
                             }
                             $pGuest = $utils->getPerson($email);
                             $guest = $email;
                             if ($pGuest !== false) {
                                 $guest = $pGuest->username;
                             }
                             $newGuest->createFromTemplate("invitationNewGuest.tpl", array("inviter" => $inviter, "guest" => $guest, "guest_email" => $email));
                             $newGuest->internal = true;
                             $responses[] = $newGuest;
                             break;
                     }
                 }
                 // mark all opened invitations to that email as used
                 $sql .= "UPDATE invitations SET used=1, used_time=CURRENT_TIMESTAMP WHERE email_invited='{$email}' AND used=0;";
             }
开发者ID:Apretaste,项目名称:Core,代码行数:67,代码来源:RunController.php

示例7: getResponseBasedOnNumberOfResults

 /**
  * Search and return based on number of results
  * 
  * @author salvipascual
  * */
 private function getResponseBasedOnNumberOfResults(Request $request, $numberOfResults)
 {
     // if the search is empty, return a message to the user
     if (empty($request->query)) {
         $serviceUsage = str_replace("{APRETASTE_EMAIL}", $this->utils->getValidEmailAddress(), nl2br($this->serviceUsage));
         $response = new Response();
         $response->setResponseSubject("Inserte un producto o servicio a buscar");
         $response->createFromText("Usted no ha insertado ning&uacute;n producto o servicio a buscar, use nuestra tienda de la siguiente manera:<br/><br/><br/>{$serviceUsage}");
         return $response;
     }
     // search for the results of the query
     $searchResult = $this->search($request->query, $numberOfResults);
     $count = $searchResult['count'];
     $items = $searchResult['items'];
     // return error to the user if no items were found
     if (count($items) == 0) {
         $response = new Response();
         $response->setResponseSubject("Su busqueda no produjo resultados");
         $response->createFromText("Su b&uacute;squeda '{$request->query}' no produjo ning&uacute;n resultado. Por favor utilice otra frase de b&uacute;squeda e intente nuevamente.");
         return $response;
     }
     // get the path
     $di = \Phalcon\DI\FactoryDefault::getDefault();
     $wwwroot = $di->get('path')['root'];
     // check if is a buscar or buscartodo
     $isSimpleSearch = $numberOfResults <= 10;
     // clean the text and save the images
     $images = array();
     foreach ($items as $item) {
         // clean the text
         $item->ad_title = $this->clean($item->ad_title);
         $item->ad_body = $this->clean($item->ad_body);
         // save images if 10 results
         if ($isSimpleSearch) {
             if ($item->number_of_pictures == 0) {
                 continue;
             }
             $file = "{$wwwroot}/public/tienda/" . md5($item->source_url) . "_1.jpg";
             if (file_exists($file)) {
                 $images[] = $file;
             }
         }
     }
     // select template
     $template = $isSimpleSearch ? "buscar.tpl" : "buscartodo.tpl";
     // send variables to the template
     $responseContent = array("numberOfDisplayedResults" => $isSimpleSearch ? count($items) > 10 ? 10 : count($items) : count($items), "numberOfTotalResults" => $count, "searchQuery" => $request->query, "items" => $items, "wwwroot" => $wwwroot);
     // display the results in the template
     $response = new Response();
     $response->setResponseSubject("La busqueda que usted pidio");
     $response->createFromTemplate($template, $responseContent, $images);
     return $response;
 }
开发者ID:Apretaste,项目名称:tienda,代码行数:58,代码来源:service.php

示例8: subserviceEnum

 /**
  * Subservice utility for ENUM profile fields
  *
  * @param Request $request			
  * @param String $field			
  * @param array $enum			
  * @param String $wrong_template			
  * @param String $wrong_subject			
  * @param String $field			
  *
  * @return Response/void
  */
 private function subserviceEnum(Request $request, $field, $enum, $wrong_subject, $prefix = null, $synonymous = array())
 {
     if (!is_null($prefix)) {
         if (stripos($request->query, $prefix) === 0) {
             $request->query = trim(substr($request->query, strlen($prefix)));
         }
     }
     $query = strtoupper(trim($request->query));
     // if the query is empty, set to null the field
     if (empty($query)) {
         return new Response();
     } else {
         // search for $synonymous
         if (isset($synonymous[$query])) {
             $query = $synonymous[$query];
         }
         // search query in the list
         if (array_search($query, $enum) !== false) {
             // update the field
             $this->update("{$field} = '{$query}'", $request->email);
             return new Response();
         } else {
             // wrong query, return a response with selectable list
             $response = new Response();
             $response->setResponseSubject($wrong_subject);
             // NOTE: The template name include the field name
             // clear underscores
             foreach ($enum as $k => $v) {
                 $enum[$k] = str_replace('_', ' ', $v);
             }
             $response->createFromTemplate('wrong_' . $field . '.tpl', array('list' => $enum));
             return $response;
         }
     }
 }
开发者ID:Apretaste,项目名称:Sandbox,代码行数:47,代码来源:service.php

示例9: _main

 /**
  * Get the list of conversations
  *
  * @param Request
  * @return Response
  * */
 public function _main(Request $request)
 {
     $argument = trim($request->query);
     $person = $this->utils->getPerson($request->email);
     // Extracting username and text
     $parts = explode(' ', $argument);
     $un = false;
     $nt = false;
     if (isset($parts[0]) && !empty($parts[0])) {
         $un = $parts[0];
     }
     if (isset($parts[1])) {
         $nt = trim(substr($argument, strlen($un)));
         if ($nt == '') {
             $nt = false;
         }
     }
     if ($un !== false) {
         if ($un[0] == '@') {
             $un = substr($un, 1);
         }
     }
     // Connecting to database
     $db = new Connection();
     // If subject's query is empty ...
     if ($un === false) {
         // Searching contacts of the current user
         $contacts = $db->deepQuery("SELECT (select username FROM person WHERE person.email = subq.username) as username,  \r\n\t\t\t\t\t\t\t\t\t\tsubq.username as email \r\n\t\t\t\t\t\t\t\t\t\tFROM (SELECT from_user as username FROM _note WHERE to_user = '{$person->email}'\r\n\t\t\t\t\t\t\t\t\t\tUNION SELECT to_user as username FROM _note WHERE from_user = '{$person->email}') as subq \r\n\t\t\t\t\t\t\t\t\t\tWHERE username <> '' AND username IS NOT NULL GROUP BY username");
         // Preparing contacts list
         if (is_array($contacts)) {
             foreach ($contacts as $k => $contact) {
                 $last_note = $this->getConversation($person->email, $contact->email, 1);
                 $contacts[$k]->last_note = array('from' => $last_note[0]->from_username, 'note' => $last_note[0]->text, 'date' => $last_note[0]->date);
             }
         }
         // Return the response
         $response = new Response();
         $response->setResponseSubject("Deseas enviar una nota?");
         $response->createFromTemplate("nouser.tpl", array("contacts" => $contacts));
         return $response;
     }
     // Searching the user $un in the database
     $friend = false;
     $find = $db->deepQuery("SELECT email FROM person WHERE username = '{$un}';");
     // The user $un not exists
     if (!isset($find[0])) {
         $response = new Response();
         $response->setResponseSubject("El usuario @{$un} no existe");
         $response->createFromTemplate("user_not_exists.tpl", array("username" => $un));
         return $response;
     }
     $friend = $this->utils->getPerson($find[0]->email);
     // Sending the note
     if ($nt !== false) {
         if ($nt == 'Reemplace este texto por su nota') {
             $response = new Response();
             $response->setResponseSubject("No reemplazaste el texto por tu nota");
             $response->createFromTemplate("howto.tpl", array());
             return $response;
         }
         // Store note in database
         $db->deepQuery("INSERT INTO _note (from_user, to_user, text) VALUES ('{$request->email}','{$friend->email}','{$nt}');");
         // Retrieve notes between users
         $notes = $this->getConversation($person->email, $friend->email);
         // Response for friend
         $response = new Response();
         $response->setResponseEmail($friend->email);
         $response->setResponseSubject("Nueva nota de @{$person->username}");
         $response->createFromTemplate("basic.tpl", array('username' => $person->username, 'notes' => $notes));
         // Generate a notification
         $this->utils->addNotification($request->email, 'nota', "Enviamos su nota a @{$un}", 'NOTA');
         return $response;
     }
     // Empty note, sending conversation...
     $notes = $this->getConversation($person->email, $friend->email);
     $response = new Response();
     $response->setResponseSubject("Su charla con @{$friend->username}");
     $response->createFromTemplate("basic.tpl", array('username' => $friend->username, 'notes' => $notes));
     return $response;
 }
开发者ID:Apretaste,项目名称:nota,代码行数:86,代码来源:service.php

示例10: Response

 /**
  * A test for a subservice WIKIPEDIA
  * */
 function _test(Request $request)
 {
     $response = new Response();
     $response->setResponseSubject("Just a test for subservice");
     $response->createFromText("A test for the subservice WIKIPEDIA");
     return $response;
 }
开发者ID:Apretaste,项目名称:Sandbox,代码行数:10,代码来源:service.php

示例11: commonImageResponse

 /**
  * Common response
  *
  * @author kuma
  * @param string $title
  * @param string $url
  * @return Response
  */
 private function commonImageResponse($title, $url)
 {
     // download and prepare the image
     $image = $this->downloadAndPrepareImage($url);
     // create response
     $response = new Response();
     $response->setResponseSubject("Clima: " . html_entity_decode($title));
     $response->createFromTemplate("image.tpl", array("title" => $title, "image" => $image), array($image));
     return $response;
 }
开发者ID:Apretaste,项目名称:clima,代码行数:18,代码来源:service.php

示例12: surveyResponse

 /**
  * Return Survey response
  *
  * @param Request $request			
  * @param integer $survey_id			
  * @return Response
  */
 private function surveyResponse($request, $survey_id)
 {
     $survey = $this->getSurveyDetails($request->email, $survey_id);
     // do not process invalid responses
     if ($survey == false || !isset($survey[0]) || empty($survey)) {
         return new Response();
     }
     $newsurvey = new stdClass();
     $newsurvey->id = $survey[0]->survey;
     $newsurvey->title = $survey[0]->survey_title;
     $newsurvey->details = $survey[0]->survey_details;
     $newsurvey->questions = array();
     foreach ($survey as $r) {
         if (!isset($newsurvey->questions[$r->question])) {
             $obj = new stdClass();
             $obj->id = $r->question;
             $obj->title = $r->question_title;
             $obj->answers = array();
             $obj->selectable = true;
             $newsurvey->questions[$r->question] = $obj;
         }
         $obj = new stdClass();
         $obj->id = $r->answer;
         $obj->title = $r->answer_title;
         $obj->choosen = $r->choosen == '1' ? true : false;
         if ($obj->choosen) {
             $newsurvey->questions[$r->question]->selectable = false;
         }
         $newsurvey->questions[$r->question]->answers[] = $obj;
     }
     $response = new Response();
     $response->setResponseSubject('Encuesta: ' . $newsurvey->title);
     $response->createFromTemplate('survey.tpl', array('survey' => $newsurvey));
     return $response;
 }
开发者ID:Apretaste,项目名称:encuesta,代码行数:42,代码来源:service.php

示例13: _negocios

 /**
  * List of businesses that accept bitcoin
  *
  * @param Request
  * @return Response
  * */
 public function _negocios(Request $request)
 {
     // @TODO remove bulshit answer to use the service
     $response = new Response();
     $response->setResponseSubject("Bitcoin temporalmente no disponible");
     $response->createFromText("Lo sentimos, pero Bitcoin esta temporalmente detenido. Le dejaremos saber cuando empecemos a funcionar. Gracias!");
     return $response;
     // END TODO
     $path = $this->pathToService;
     $images = array("{$path}/images/airbnb.jpg", "{$path}/images/carnival.jpg", "{$path}/images/virgin-atlantic.jpg", "{$path}/images/unilever.jpg", "{$path}/images/netflix.png", "{$path}/images/DimeCuba.jpg");
     $response = new Response();
     $response->setResponseSubject("Negocios que aceptan BitCoin");
     $response->createFromTemplate("negocios.tpl", array("path" => $path), $images);
     return $response;
 }
开发者ID:Apretaste,项目名称:bitcoin,代码行数:21,代码来源:service.php

示例14: _estadisticas

 /**
  * Subservice ESTADISTICAS
  *
  * @param Request $request        	
  * @return Response
  */
 public function _estadisticas(Request $request)
 {
     // get list of ads for the user
     $connection = new Connection();
     $result = $connection->deepQuery("SELECT * FROM ads WHERE owner = '{$request->email}' ORDER BY id");
     // list all the ads
     if (count($result) > 0) {
         $response = new Response();
         $response->setResponseSubject('Sus anuncios en Apretaste');
         $response->createFromTemplate('stats.tpl', array('stats' => $result));
         return $response;
     }
     // in case the user don't have any ads
     $response = new Response();
     $response->setResponseSubject('Usted no tiene anuncio corriendo');
     $response->createFromText('Usted no tiene ningun anuncio en Apretaste');
     return $response;
 }
开发者ID:Apretaste,项目名称:publicidad,代码行数:24,代码来源:service.php

示例15: recoverAction

 /**
  * Recovers a pin and create a pin for users with blank pins
  *
  * @author salvipascual
  * @param GET email
  * @return JSON
  * */
 public function recoverAction()
 {
     $email = trim($this->request->get('email'));
     $utils = new Utils();
     $connection = new Connection();
     // check if the email exist
     if (!$utils->personExist($email)) {
         die('{"code":"error","message":"invalid user"}');
     }
     // get pin from the user
     $pin = $connection->deepQuery("SELECT pin FROM person WHERE email='{$email}'");
     $pin = $pin[0]->pin;
     // if pin is blank, create it
     if (empty($pin)) {
         $pin = mt_rand(1000, 9999);
         $connection->deepQuery("UPDATE person SET pin='{$pin}' WHERE email='{$email}'");
     }
     // create response to email the new code
     $subject = "Su codigo de Apretaste";
     $response = new Response();
     $response->setEmailLayout("email_simple.tpl");
     $response->setResponseSubject($subject);
     $response->createFromTemplate("pinrecover.tpl", array("pin" => $pin));
     $response->internal = true;
     // render the template as html
     $render = new Render();
     $body = $render->renderHTML(new Service(), $response);
     // email the code to the user
     $emailSender = new Email();
     $emailSender->sendEmail($email, $subject, $body);
     // return ok response
     die('{"code":"ok"}');
 }
开发者ID:Apretaste,项目名称:Core,代码行数:40,代码来源:ApiController.php


注:本文中的Response::setResponseSubject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。