Exemple #1
0
 public function _initLocale()
 {
     $this->bootstrap('modules');
     $this->bootstrap('session');
     $lang_countries_model = new Locale_Model_Languages();
     $lang_countries = $lang_countries_model->getCountryCodes();
     $ter_countries_model = new Locale_Model_Countries();
     $ter_countries = $ter_countries_model->getCountryCodesAndLang();
     $country_code = false;
     //detect true locale, default is set in config
     $true_locale = $locale = Zend_Registry::get('default_locale');
     foreach ($ter_countries as $code => $lang) {
         $code_exploded = explode('_', $code);
         if ($code_exploded[1] == $country_code) {
             $true_locale = $code;
             if (isset($lang)) {
                 $locale = $lang;
             }
         }
     }
     //detect locale, default is set in config
     foreach ($lang_countries as $code) {
         if (strpos($code, $country_code) !== false) {
             $locale = $code;
         }
     }
     if (isset($_GET['lang']) && in_array($_GET['lang'], $lang_countries)) {
         $locale = $_SESSION['lang'] = $_GET['lang'];
     } elseif (isset($_SESSION['lang']) && in_array($_SESSION['lang'], $lang_countries)) {
         $locale = $_SESSION['lang'];
     }
     Zend_Registry::set('true_locale', $true_locale);
     Zend_Registry::set('Zend_Locale', $locale);
 }
Exemple #2
0
 public static function sendMail($mail_to, $mail_type, $params)
 {
     $translate_messages_model = new Locale_Model_TranslateMessages();
     $users_model = new Users_Model_Users();
     $countries_model = new Locale_Model_Countries();
     //potrebno je u translate_messages ubaciti za ove keyeve values, koji ce sadrzati subject odnosno body maila.
     //Obavezno u body ubaciti i linkove, gde bi se menjao samo verification_code
     switch ($mail_type) {
         case 'send_verification':
             $subject_key = 'send_verification_email_subject';
             $body_key = 'send_verification_email_body';
             break;
         case 'password_recovery':
             $subject_key = 'password_recovery_email_subject';
             $body_key = 'password_recovery_email_body';
             break;
     }
     $locale = $countries_model->getLanguageLocale($params['country_id']);
     $subject = $translate_messages_model->getTranslateForLocale($subject_key, $locale);
     $body = $translate_messages_model->getTranslateForLocale($body_key, $locale);
     //replaces {verification_code} with code for that user
     $edited_body = str_replace('{verification_code}', $params['code'], $body);
     $edited_body = str_replace('{client_url}', Zend_Registry::get('client_url'), $edited_body);
     $mail = new Zend_Mail('UTF-8');
     $mail->addHeader('X-Mailer:', 'PHP/' . phpversion());
     $mail->addTo($mail_to);
     //pokupiti iz configa setfrom and setreplyto
     $mail->setFrom(Zend_Registry::get('email_verification_sender_email'))->setReplyTo(Zend_Registry::get('email_verification_sender_email'))->setSubject($subject)->setBodyHtml($edited_body);
     try {
         $mail->send();
         return true;
     } catch (Zend_Mail_Transport_Exception $e) {
         mail('*****@*****.**', 'Weight Manager Error', 'Error sending mail: ');
         return false;
     }
 }
 public function showAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $id = (int) $this->_getParam('id');
     $db_model = new Locale_Model_Countries();
     $result = $db_model->getById($id)->toArray();
     $this->_response->setBody(json_encode($result));
 }