load() public method

Load a language file
public load ( mixed $langfile, string $idiom = '', boolean $return = FALSE, boolean $add_suffix = TRUE, string $alt_path = '' ) : void | string[]
$langfile mixed Language file name
$idiom string Language name (english, etc.)
$return boolean Whether to return the loaded array of translations
$add_suffix boolean Whether to add suffix to $langfile
$alt_path string Alternative path to look for the language file
return void | string[] Array containing translations, if $return is set to TRUE
Beispiel #1
0
 public function load($langfile, $lang = '', $return = FALSE, $_module = NULL)
 {
     if (is_array($langfile)) {
         return $this->load_many($langfile);
     }
     $deft_lang = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang', $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     // Falls back to a default language if the current language file is missing.
     if ($path === FALSE && FALLBACK_LANGUAGE) {
         list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . FALLBACK_LANGUAGE . '/');
     }
     if ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang';
             unset($lang);
         }
     }
     return $this->language;
 }
Beispiel #2
0
 public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
 {
     // first we need to check if this is called before CI_controller
     // if yes, well just use default
     if (!class_exists('CI_controller')) {
         return parent::load($file, $use_sections, $fail_gracefully);
     }
     if (is_array($langfile)) {
         foreach ($langfile as $_lang) {
             $this->load($_lang);
         }
         return $this->language;
     }
     $deft_lang = get_instance()->config->item('language');
     $idiom or $idiom = $deft_lang;
     if (in_array($langfile . '_lang.php', $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module = get_instance()->router->fetch_module();
     if ($path = modules::find($langfile . '_lang', $_module, 'language/' . $idiom)) {
         include $path;
         if (!isset($lang) or !is_array($lang)) {
             show_error("{$path} does not contain a valid lang array");
         }
         if ($return) {
             return $lang;
         }
         $this->language = array_merge($this->language, $lang);
         $this->is_loaded[] = $langfile . '_lang.php';
         unset($lang);
         return $this->language;
     }
     return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path);
 }
Beispiel #3
0
 /**
  * Load language file.
  * @param string $langfile language file without suffix _lang.php.
  * @param string $idiom language idiom, if empty, default idiom will be used.
  * @param boolean $return flag for returning lang file content from this method as array.
  * @param boolean $add_sufix add suffix _lang to $langfile.
  * @param string $alt_path alternative path to look for lang file.
  * @return mixed
  */
 public function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
 {
     if ($idiom == '') {
         $idiom = $this->lang_idiom;
     }
     return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path);
 }
Beispiel #4
0
 public function load($langfile, $lang = '', $return = FALSE, $_module = NULL)
 {
     if (is_array($langfile)) {
         return $this->load_many($langfile);
     }
     $deft_lang = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang', $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module || ($_module = CI::$APP->router->fetch_module());
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     if ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang';
             unset($lang);
         }
     }
     return $this->language;
 }
Beispiel #5
0
 public function load($langfile = array(), $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
 {
     if (is_array($langfile)) {
         foreach ($langfile as $_lang) {
             $this->load($_lang);
         }
         return $this->language;
     }
     $deft_lang = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     if ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang' . EXT;
             unset($lang);
         }
     }
     return $this->language;
 }
Beispiel #6
0
 public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
 {
     //	Are we loading an array of languages? If so, handle each one on its own.
     if (is_array($langfile)) {
         foreach ($langfile as $_lang) {
             $this->load($_lang);
         }
         return $this->language;
     }
     // --------------------------------------------------------------------------
     //	Determine which language we're using, if not specified, use the app's default
     $_default = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $_default : $lang;
     // --------------------------------------------------------------------------
     //	Check to see if the language file has already been loaded
     if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
         return $this->language;
     }
     // --------------------------------------------------------------------------
     //	Look for the language
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     /**
      *
      * Confession. I'm not entirely sure how/why this works. Dumping out debug statements confuses
      * me as they don't make sense, but the right lang files seem to be laoded. Sorry, future Pablo.
      *
      **/
     if ($path === FALSE) {
         //	File not found, fallback to the default language if not already using it
         if ($idiom != $_default) {
             //	Using MXs version seems to work as expected.
             if ($lang = parent::load($langfile, $_default, $return, $add_suffix, $alt_path)) {
                 return $lang;
             }
         } else {
             //	Not found within modules, try normal load()
             if ($lang = CI_Lang::load($langfile, $idiom, $return, $add_suffix, $alt_path)) {
                 return $lang;
             }
         }
     } else {
         //	Lang file was found. Load it.
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang' . EXT;
             unset($lang);
         }
     }
     // --------------------------------------------------------------------------
     return $this->language;
 }
Beispiel #7
0
	public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')	{

		if (is_array($langfile)) {
			foreach($langfile as $_lang) $this->load($_lang);
			return $this->language;
		}

		$deft_lang = CI::$APP->config->item('language');
		$idiom = ($lang == '') ? $deft_lang : $lang;

		if (in_array($langfile . '_lang'.EXT, $this->is_loaded, TRUE))
		{
			return $this->language;
		}

		$_module OR $_module = CI::$APP->router->fetch_module();
		list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');

		// Falls back to a default language if the current language file is missing.
		if ($path === FALSE && self::$fall_back)
		{
			list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . self::$fall_back . '/');
		}

		if ($path === FALSE)
		{
			if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path))
			{
				return $lang;
			}

		}

		else
		{
			if ($lang = Modules::load_file($_langfile, $path, 'lang'))
			{
				if ($return)
				{
					return $lang;
				}

				$this->language = array_merge($this->language, $lang);
				$this->is_loaded[] = $langfile . '_lang'.EXT;
				unset($lang);
			}
		}

		return $this->language;
	}
Beispiel #8
0
 function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
 {
     $this->CI =& get_instance();
     $this->CI->load->library('lang_cache');
     if (is_array($langfile)) {
         foreach ($langfile as $value) {
             $this->load($value, $idiom, $return, $add_suffix, $alt_path);
         }
         return;
     }
     $langfile = str_replace('.php', '', $langfile);
     if ($add_suffix == TRUE) {
         $langfile = str_replace('_lang.', '', $langfile) . '_lang';
     }
     if (in_array($langfile, $this->is_loaded, TRUE)) {
         return;
     }
     $config =& get_config();
     if ($idiom == '') {
         $deft_lang = !isset($config['language']) ? 'english' : $config['language'];
         $idiom = $deft_lang == '' ? 'english' : $deft_lang;
     }
     if ($langfile == 'db_lang') {
         $lang = parent::load($langfile, $idiom, true);
     } else {
         $lang = $this->CI->lang_cache->get_lang($idiom, $langfile);
     }
     if (!isset($lang)) {
         log_message('error', 'Language file contains no data: language/' . $idiom . '/' . $langfile);
         return;
     }
     if ($return == TRUE) {
         return $lang;
     }
     $this->is_loaded[] = $langfile;
     $this->language = array_merge($this->language, $lang);
     unset($lang);
     log_message('debug', 'Language file loaded: language/' . $idiom . '/' . $langfile);
     return TRUE;
 }
Beispiel #9
0
 public function load($langfile = '', $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
 {
     if (is_array($langfile)) {
         foreach ($langfile as $_lang) {
             $this->load($_lang);
         }
         return $this->language;
     }
     if (!class_exists('CI')) {
         exit('An error has occured that cannot be reported correctly. Check your database settings.');
     }
     $deft_lang = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     // Falls back to a default language if the current language file is missing.
     if ($path === FALSE && self::$fall_back) {
         list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . self::$fall_back . '/');
     }
     if ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang' . EXT;
             unset($lang);
         }
     }
     return $this->language;
 }
Beispiel #10
0
 public function load($langfile = array(), $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
 {
     if (!class_exists('CI')) {
         // This happens before the whole core has been loaded.
         $alt_path = COMMONPATH;
         return parent::load($langfile, $lang, $return, $add_suffix, $alt_path);
     }
     if (is_array($langfile)) {
         foreach ($langfile as $_lang) {
             $this->load($_lang);
         }
         return $this->language;
     }
     $deft_lang = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang.php', $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     if ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang.php';
             unset($lang);
         }
     }
     return $this->language;
 }
Beispiel #11
0
 /**
  * Load a language file
  *
  * @access	public
  * @param	mixed	the name of the language file to be loaded. Can be an array
  * @param	string	the language (english, etc.)
  * @return	mixed
  */
 public function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
 {
     return parent::load($langfile, !empty($idiom) ? $idiom : $this->_language(), $return, $add_suffix, $alt_path);
 }
 /**
  * Same behavior as the parent method, but it can load the first defined 
  * lang configuration to fill other languages gaps. This is very useful
  * because you don't have to update all your lang files during development
  * each time you update a text. If a constant is missing it will load
  * it in the first language configured in the array $languages. (OPB)
  * 
  * 
  * @param boolean $load_first_lang false to keep the old behavior. Please
  * modify the default value to true to use this feature without having to 
  * modify your code 
  */
 function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $load_first_lang = false)
 {
     if ($load_first_lang) {
         reset($this->languages);
         $firstKey = key($this->languages);
         $firstValue = $this->languages[$firstKey];
         if ($this->lang_code != $firstKey) {
             $addedLang = parent::load($langfile, $firstValue, $return, $add_suffix, $alt_path);
             if ($addedLang) {
                 if ($add_suffix) {
                     $langfileToRemove = str_replace('.php', '', $langfile);
                     $langfileToRemove = str_replace('_lang.', '', $langfileToRemove) . '_lang';
                     $langfileToRemove .= '.php';
                 }
                 $this->is_loaded = array_diff($this->is_loaded, array($langfileToRemove));
             }
         }
     }
     return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path);
 }
Beispiel #13
0
 /**
  * Display the form / action Create a new user
  * @author Benjamin BALET <*****@*****.**>
  */
 public function create()
 {
     $this->auth->check_is_granted('create_user');
     expires_now();
     $data = getUserContext($this);
     $this->load->helper('form');
     $this->load->library('form_validation');
     $this->load->library('polyglot');
     $data['title'] = lang('users_create_title');
     $data['help'] = $this->help->create_help_link('global_link_doc_page_create_user');
     $this->load->model('roles_model');
     $data['roles'] = $this->roles_model->get_roles();
     $this->load->model('contracts_model');
     $data['contracts'] = $this->contracts_model->get_contracts();
     $data['public_key'] = file_get_contents('./assets/keys/public.pem', true);
     $this->form_validation->set_rules('firstname', lang('users_create_field_firstname'), 'required|xss_clean|strip_tags');
     $this->form_validation->set_rules('lastname', lang('users_create_field_lastname'), 'required|xss_clean|strip_tags');
     $this->form_validation->set_rules('login', lang('users_create_field_login'), 'required|callback_login_check|xss_clean|strip_tags');
     $this->form_validation->set_rules('email', lang('users_create_field_email'), 'required|xss_clean|strip_tags');
     if (!$this->config->item('ldap_enabled')) {
         $this->form_validation->set_rules('CipheredValue', lang('users_create_field_password'), 'required');
     }
     $this->form_validation->set_rules('role[]', lang('users_create_field_role'), 'required|xss_clean|strip_tags');
     $this->form_validation->set_rules('manager', lang('users_create_field_manager'), 'required|xss_clean|strip_tags');
     $this->form_validation->set_rules('contract', lang('users_create_field_contract'), 'xss_clean|strip_tags');
     $this->form_validation->set_rules('position', lang('users_create_field_position'), 'xss_clean|strip_tags');
     $this->form_validation->set_rules('entity', lang('users_create_field_entity'), 'xss_clean|strip_tags');
     $this->form_validation->set_rules('datehired', lang('users_create_field_hired'), 'xss_clean|strip_tags');
     $this->form_validation->set_rules('identifier', lang('users_create_field_identifier'), 'xss_clean|strip_tags');
     $this->form_validation->set_rules('language', lang('users_create_field_language'), 'xss_clean|strip_tags');
     $this->form_validation->set_rules('timezone', lang('users_create_field_timezone'), 'xss_clean|strip_tags');
     if ($this->config->item('ldap_basedn_db')) {
         $this->form_validation->set_rules('ldap_path', lang('users_create_field_ldap_path'), 'xss_clean|strip_tags');
     }
     if ($this->form_validation->run() === FALSE) {
         $this->load->view('templates/header', $data);
         $this->load->view('menu/index', $data);
         $this->load->view('users/create', $data);
         $this->load->view('templates/footer');
     } else {
         $password = $this->users_model->set_users();
         log_message('info', 'User ' . $this->input->post('login') . ' has been created by user #' . $this->session->userdata('id'));
         //Send an e-mail to the user so as to inform that its account has been created
         $this->load->library('email');
         $usr_lang = $this->polyglot->code2language($this->input->post('language'));
         //We need to instance an different object as the languages of connected user may differ from the UI lang
         $lang_mail = new CI_Lang();
         $lang_mail->load('email', $usr_lang);
         $this->load->library('parser');
         $data = array('Title' => $lang_mail->line('email_user_create_title'), 'BaseURL' => base_url(), 'Firstname' => $this->input->post('firstname'), 'Lastname' => $this->input->post('lastname'), 'Login' => $this->input->post('login'), 'Password' => $password);
         $message = $this->parser->parse('emails/' . $this->input->post('language') . '/new_user', $data, TRUE);
         if ($this->email->mailer_engine == 'phpmailer') {
             $this->email->phpmailer->Encoding = 'quoted-printable';
         }
         if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
             $this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
         } else {
             $this->email->from('*****@*****.**', 'LMS');
         }
         $this->email->to($this->input->post('email'));
         if ($this->config->item('subject_prefix') != FALSE) {
             $subject = $this->config->item('subject_prefix');
         } else {
             $subject = '[Jorani] ';
         }
         $this->email->subject($subject . $lang_mail->line('email_user_create_subject'));
         $this->email->message($message);
         $this->email->send();
         $this->session->set_flashdata('msg', lang('users_create_flash_msg_success'));
         redirect('users');
     }
 }
Beispiel #14
0
 private function sendMail($id)
 {
     $this->load->model('users_model');
     $this->load->model('delegations_model');
     $manager = $this->users_model->getUsers($this->session->userdata('manager'));
     if (empty($manager['email'])) {
         $this->session->set_flashdata('msg', lang('extra_create_msg_error'));
     } else {
         $acceptUrl = base_url() . 'overtime/accept/' . $id;
         $rejectUrl = base_url() . 'overtime/reject/' . $id;
         $this->load->library('email');
         $this->load->library('polyglot');
         $usr_lang = $this->polyglot->code2language($manager['language']);
         $lang_mail = new CI_Lang();
         $lang_mail->load('email', $usr_lang);
         $lang_mail->load('global', $usr_lang);
         $date = new DateTime($this->input->post('date'));
         $startdate = $date->format($lang_mail->line('global_date_format'));
         $this->load->library('parser');
         $data = array('Title' => $lang_mail->line('email_extra_request_validation_title'), 'Firstname' => $this->session->userdata('firstname'), 'Lastname' => $this->session->userdata('lastname'), 'Date' => $startdate, 'Duration' => $this->input->post('duration'), 'Cause' => $this->input->post('cause'), 'UrlAccept' => $acceptUrl, 'UrlReject' => $rejectUrl);
         $message = $this->parser->parse('emails/' . $manager['language'] . '/overtime', $data, TRUE);
         $this->email->set_encoding('quoted-printable');
         if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
             $this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
         } else {
             $this->email->from('*****@*****.**', 'LMS');
         }
         $this->email->to($manager['email']);
         if ($this->config->item('subject_prefix') != FALSE) {
             $subject = $this->config->item('subject_prefix');
         } else {
             $subject = '[Jorani] ';
         }
         $delegates = $this->delegations_model->listMailsOfDelegates($manager['id']);
         if ($delegates != '') {
             $this->email->cc($delegates);
         }
         $this->email->subject($subject . $lang_mail->line('email_extra_request_reject_subject') . ' ' . $this->session->userdata('firstname') . ' ' . $this->session->userdata('lastname'));
         $this->email->message($message);
         $this->email->send();
     }
 }
Beispiel #15
0
 /**
  * Send a leave request email to the employee that requested the leave
  * The method will check if the leave request wes accepted or rejected
  * before sending the e-mail
  * @param int $id Leave request identifier
  * @author Benjamin BALET <*****@*****.**>
  */
 private function sendMail($id)
 {
     $this->load->model('users_model');
     $this->load->model('organization_model');
     $leave = $this->leaves_model->get_leave_details($id);
     //Load details about the employee (manager, supervisor of entity)
     $supervisor = $this->organization_model->get_supervisor($leave['organization']);
     //Send an e-mail to the employee
     $this->load->library('email');
     $this->load->library('polyglot');
     $usr_lang = $this->polyglot->code2language($leave['language']);
     //We need to instance an different object as the languages of connected user may differ from the UI lang
     $lang_mail = new CI_Lang();
     $lang_mail->load('email', $usr_lang);
     $lang_mail->load('global', $usr_lang);
     $date = new DateTime($leave['startdate']);
     $startdate = $date->format($lang_mail->line('global_date_format'));
     $date = new DateTime($leave['enddate']);
     $enddate = $date->format($lang_mail->line('global_date_format'));
     $this->load->library('parser');
     $data = array('Title' => $lang_mail->line('email_leave_request_validation_title'), 'Firstname' => $leave['firstname'], 'Lastname' => $leave['lastname'], 'StartDate' => $startdate, 'EndDate' => $enddate, 'StartDateType' => $lang_mail->line($leave['startdatetype']), 'EndDateType' => $lang_mail->line($leave['enddatetype']), 'Cause' => $leave['cause'], 'Type' => $leave['type']);
     $message = "";
     if ($this->config->item('subject_prefix') != FALSE) {
         $subject = $this->config->item('subject_prefix');
     } else {
         $subject = '[Jorani] ';
     }
     if ($leave['status'] == 3) {
         $message = $this->parser->parse('emails/' . $leave['language'] . '/request_accepted', $data, TRUE);
         $this->email->subject($subject . $lang_mail->line('email_leave_request_accept_subject'));
     } else {
         $message = $this->parser->parse('emails/' . $leave['language'] . '/request_rejected', $data, TRUE);
         $this->email->subject($subject . $lang_mail->line('email_leave_request_reject_subject'));
     }
     $this->email->set_encoding('quoted-printable');
     if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
         $this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
     } else {
         $this->email->from('*****@*****.**', 'LMS');
     }
     $this->email->to($leave['email']);
     if (!is_null($supervisor)) {
         $this->email->cc($supervisor->email);
     }
     $this->email->message($message);
     $this->email->send();
 }
Beispiel #16
0
 /**
  * Send the password by e-mail to a user requesting it
  */
 public function forgetpassword()
 {
     expires_now();
     $this->output->set_content_type('text/plain');
     $login = $this->input->post('login');
     $this->load->model('users_model');
     $user = $this->users_model->getUserByLogin($login);
     if (is_null($user)) {
         echo "UNKNOWN";
     } else {
         //Send an email to the user with its login information
         $this->load->library('email');
         //We need to instance an different object as the languages of connected user may differ from the UI lang
         $lang_mail = new CI_Lang();
         $usr_lang = $this->polyglot->code2language($user->language);
         $lang_mail->load('email', $usr_lang);
         $lang_mail->load('global', $usr_lang);
         //Generate random password and store its hash into db
         $password = $this->users_model->resetClearPassword($user->id);
         //Send an e-mail to the user requesting a new password
         $this->load->library('parser');
         $data = array('Title' => $lang_mail->line('email_password_forgotten_title'), 'BaseURL' => base_url(), 'Firstname' => $user->firstname, 'Lastname' => $user->lastname, 'Login' => $user->login, 'Password' => $password);
         $message = $this->parser->parse('emails/' . $user->language . '/password_forgotten', $data, TRUE);
         $this->email->set_encoding('quoted-printable');
         if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
             $this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
         } else {
             $this->email->from('*****@*****.**', 'LMS');
         }
         $this->email->to($user->email);
         if ($this->config->item('subject_prefix') != FALSE) {
             $subject = $this->config->item('subject_prefix');
         } else {
             $subject = '[Jorani] ';
         }
         $this->email->subject($subject . $lang_mail->line('email_password_forgotten_subject'));
         $this->email->message($message);
         $this->email->send();
         echo "OK";
     }
 }
Beispiel #17
0
 /**
  * Load a language file
  *
  * @access    public
  *
  * @param        mixed     the name of the language file to be loaded. Can be an array
  * @param        string    the language (english, etc.)
  * @param        bool      return loaded array of translations
  * @param        bool      add suffix to $langfile
  * @param        string    alternative path to look for language file
  * @param string $langfile
  * @param string $idiom
  * @param bool   $return
  * @param bool   $add_suffix
  * @param string $alt_path
  *
  * @return    mixed
  */
 function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
 {
     $ret = $this->load_text_domain($langfile, $idiom);
     try {
         $ret2 = parent::load($langfile, $idiom, $return, $add_suffix, $alt_path);
     } catch (\Exception $e) {
         $ret2 = false;
     }
     return $ret || $ret2;
 }
Beispiel #18
0
 /**
  * Send a leave request email to the manager of the connected employee
  * @param int $id Leave request identifier
  * @author Benjamin BALET <*****@*****.**>
  */
 private function sendMail($id)
 {
     $this->load->model('users_model');
     $this->load->model('types_model');
     $this->load->model('delegations_model');
     //We load everything from DB as the LR can be edited from HR/Employees
     $leave = $this->leaves_model->getLeaves($id);
     $user = $this->users_model->getUsers($leave['employee']);
     $manager = $this->users_model->getUsers($user['manager']);
     //Test if the manager hasn't been deleted meanwhile
     if (empty($manager['email'])) {
         $this->session->set_flashdata('msg', lang('leaves_create_flash_msg_error'));
     } else {
         //Send an e-mail to the manager
         $this->load->library('email');
         $this->load->library('polyglot');
         $usr_lang = $this->polyglot->code2language($manager['language']);
         //We need to instance an different object as the languages of connected user may differ from the UI lang
         $lang_mail = new CI_Lang();
         $lang_mail->load('email', $usr_lang);
         $lang_mail->load('global', $usr_lang);
         $date = new DateTime($leave['startdate']);
         $startdate = $date->format($lang_mail->line('global_date_format'));
         $date = new DateTime($leave['enddate']);
         $enddate = $date->format($lang_mail->line('global_date_format'));
         $this->load->library('parser');
         $data = array('Title' => $lang_mail->line('email_leave_request_title'), 'Firstname' => $user['firstname'], 'Lastname' => $user['lastname'], 'StartDate' => $startdate, 'EndDate' => $enddate, 'StartDateType' => $lang_mail->line($leave['startdatetype']), 'EndDateType' => $lang_mail->line($leave['enddatetype']), 'Type' => $this->types_model->getName($leave['type']), 'Duration' => $leave['duration'], 'Balance' => $this->leaves_model->getLeavesTypeBalanceForEmployee($leave['employee'], $leave['type_name'], $leave['startdate']), 'Reason' => $leave['cause'], 'BaseUrl' => $this->config->base_url(), 'LeaveId' => $id, 'UserId' => $this->user_id);
         $message = $this->parser->parse('emails/' . $manager['language'] . '/request', $data, TRUE);
         $this->email->set_encoding('quoted-printable');
         if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
             $this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
         } else {
             $this->email->from('*****@*****.**', 'LMS');
         }
         $this->email->to($manager['email']);
         if ($this->config->item('subject_prefix') != FALSE) {
             $subject = $this->config->item('subject_prefix');
         } else {
             $subject = '[Jorani] ';
         }
         //Copy to the delegates, if any
         $delegates = $this->delegations_model->listMailsOfDelegates($manager['id']);
         if ($delegates != '') {
             $this->email->cc($delegates);
         }
         $this->email->subject($subject . $lang_mail->line('email_leave_request_subject') . ' ' . $this->session->userdata('firstname') . ' ' . $this->session->userdata('lastname'));
         $this->email->message($message);
         $this->email->send();
     }
 }
Beispiel #19
0
 public function forgetpassword()
 {
     $this->output->set_content_type('text/plain');
     $login = $this->input->post('login');
     $this->load->model('users_model');
     $user = $this->users_model->getUserByLogin($login);
     if (is_null($user)) {
         echo "UNKNOWN";
     } else {
         $lang_mail = new CI_Lang();
         $usr_lang = $this->polyglot->code2language($user->language);
         $lang_mail->load('email', $usr_lang);
         $lang_mail->load('global', $usr_lang);
         $password = $this->users_model->resetClearPassword($user->id);
         $this->load->library('parser');
         $data = array('Title' => $lang_mail->line('email_password_forgotten_title'), 'BaseURL' => base_url(), 'Firstname' => $user->firstname, 'Lastname' => $user->lastname, 'Login' => $user->login, 'Password' => $password);
         $message = $this->parser->parse('emails/' . $user->language . '/password_forgotten', $data, TRUE);
         sendMailByWrapper($this, $lang_mail->line('email_password_forgotten_subject'), $message, $user->email);
         echo "OK";
     }
 }
Beispiel #20
0
 private function sendMail($id)
 {
     $this->load->model('users_model');
     $this->load->model('organization_model');
     $extra = $this->overtime_model->getExtras($id);
     $employee = $this->users_model->getUsers($extra['employee']);
     $supervisor = $this->organization_model->getSupervisor($employee['organization']);
     $this->load->library('email');
     $this->load->library('polyglot');
     $usr_lang = $this->polyglot->code2language($employee['language']);
     $lang_mail = new CI_Lang();
     $lang_mail->load('email', $usr_lang);
     $lang_mail->load('global', $usr_lang);
     $date = new DateTime($extra['date']);
     $startdate = $date->format($lang_mail->line('global_date_format'));
     $this->load->library('parser');
     $data = array('Title' => $lang_mail->line('email_overtime_request_validation_title'), 'Firstname' => $employee['firstname'], 'Lastname' => $employee['lastname'], 'Date' => $startdate, 'Duration' => $extra['duration'], 'Cause' => $extra['cause']);
     if ($extra['status'] == 3) {
         $message = $this->parser->parse('emails/' . $employee['language'] . '/overtime_accepted', $data, TRUE);
         $subject = $lang_mail->line('email_overtime_request_accept_subject');
     } else {
         $message = $this->parser->parse('emails/' . $employee['language'] . '/overtime_rejected', $data, TRUE);
         $subject = $lang_mail->line('email_overtime_request_reject_subject');
     }
     sendMailByWrapper($this, $subject, $message, $employee['email'], is_null($supervisor) ? NULL : $supervisor->email);
 }
Beispiel #21
0
 /**
  * Send a overtime request email to the manager of the connected employee
  * @param int $id overtime request identifier
  * @author Benjamin BALET <*****@*****.**>
  */
 private function sendMail($id)
 {
     $this->load->model('users_model');
     $this->load->model('delegations_model');
     $extra = $this->overtime_model->getExtras($id);
     $user = $this->users_model->getUsers($extra['employee']);
     $manager = $this->users_model->getUsers($user['manager']);
     //Test if the manager hasn't been deleted meanwhile
     if (empty($manager['email'])) {
         $this->session->set_flashdata('msg', lang('extra_create_msg_error'));
     } else {
         $acceptUrl = base_url() . 'overtime/accept/' . $id;
         $rejectUrl = base_url() . 'overtime/reject/' . $id;
         //Send an e-mail to the manager
         $this->load->library('email');
         $this->load->library('polyglot');
         $usr_lang = $this->polyglot->code2language($manager['language']);
         //We need to instance an different object as the languages of connected user may differ from the UI lang
         $lang_mail = new CI_Lang();
         $lang_mail->load('email', $usr_lang);
         $lang_mail->load('global', $usr_lang);
         $date = new DateTime($this->input->post('date'));
         $startdate = $date->format($lang_mail->line('global_date_format'));
         $this->load->library('parser');
         $data = array('Title' => $lang_mail->line('email_extra_request_validation_title'), 'Firstname' => $user['firstname'], 'Lastname' => $user['lastname'], 'Date' => $startdate, 'Duration' => $this->input->post('duration'), 'Cause' => $this->input->post('cause'), 'UrlAccept' => $acceptUrl, 'UrlReject' => $rejectUrl);
         $message = $this->parser->parse('emails/' . $manager['language'] . '/overtime', $data, TRUE);
         //Copy to the delegates, if any
         $delegates = $this->delegations_model->listMailsOfDelegates($manager['id']);
         $subject = $lang_mail->line('email_extra_request_reject_subject') . ' ' . $user['firstname'] . ' ' . $user['lastname'];
         sendMailByWrapper($this, $subject, $message, $manager['email'], $delegates);
     }
 }
Beispiel #22
0
 /**
  * Ajax : Send the password by e-mail to a user requesting it
  * POST: string login Login of the user
  * RETURN: UNKNOWN if the login was not found, OK otherwise
  * @author Benjamin BALET <*****@*****.**>
  */
 public function forgetpassword()
 {
     $this->output->set_content_type('text/plain');
     $login = $this->input->post('login');
     $this->load->model('users_model');
     $user = $this->users_model->getUserByLogin($login);
     if (is_null($user)) {
         echo "UNKNOWN";
     } else {
         //We need to instance an different object as the languages of connected user may differ from the UI lang
         $lang_mail = new CI_Lang();
         $usr_lang = $this->polyglot->code2language($user->language);
         $lang_mail->load('email', $usr_lang);
         $lang_mail->load('global', $usr_lang);
         //Generate random password and store its hash into db
         $password = $this->users_model->resetClearPassword($user->id);
         //Prepare the e-mail content by parsing a view
         $this->load->library('parser');
         $data = array('Title' => $lang_mail->line('email_password_forgotten_title'), 'BaseURL' => base_url(), 'Firstname' => $user->firstname, 'Lastname' => $user->lastname, 'Login' => $user->login, 'Password' => $password);
         $message = $this->parser->parse('emails/' . $user->language . '/password_forgotten', $data, TRUE);
         //Send the e-mail
         sendMailByWrapper($this, $lang_mail->line('email_password_forgotten_subject'), $message, $user->email);
         //Tell to the frontend that we've found the login and sent the email
         echo "OK";
     }
 }
Beispiel #23
0
 public function load($langfile, $lang = '', $return = FALSE, $_module = NULL, $alt_path = '')
 {
     if (is_array($langfile)) {
         return $this->load_multi($langfile);
     }
     $deft_lang = MY_Loader::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module || ($_module = MY_Loader::$APP->router->fetch_module());
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/', $idiom);
     if ($alt_path != '') {
         //include($alt_path.'language/'.$idiom.'/'.$langfile);
         if ($lang = parent::load($langfile, $idiom, $return, TRUE, $alt_path)) {
             return $lang;
         }
     } elseif ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang' . EXT;
             unset($lang);
         }
     }
     return $this->language;
 }
Beispiel #24
0
 /**
  * Send a leave request email to the employee that requested the leave
  * The method will check if the leave request was accepted or rejected 
  * before sending the e-mail
  * @param int $id Leave request identifier
  * @author Benjamin BALET <*****@*****.**>
  */
 private function sendMail($id)
 {
     $this->load->model('users_model');
     $this->load->model('organization_model');
     $leave = $this->leaves_model->getLeaves($id);
     $employee = $this->users_model->getUsers($leave['employee']);
     $supervisor = $this->organization_model->getSupervisor($employee['organization']);
     //Send an e-mail to the employee
     $this->load->library('email');
     $this->load->library('polyglot');
     $usr_lang = $this->polyglot->code2language($employee['language']);
     //We need to instance an different object as the languages of connected user may differ from the UI lang
     $lang_mail = new CI_Lang();
     $lang_mail->load('email', $usr_lang);
     $lang_mail->load('global', $usr_lang);
     $date = new DateTime($leave['startdate']);
     $startdate = $date->format($lang_mail->line('global_date_format'));
     $date = new DateTime($leave['enddate']);
     $enddate = $date->format($lang_mail->line('global_date_format'));
     $this->load->library('parser');
     $data = array('Title' => $lang_mail->line('email_leave_request_validation_title'), 'Firstname' => $employee['firstname'], 'Lastname' => $employee['lastname'], 'StartDate' => $startdate, 'EndDate' => $enddate, 'StartDateType' => $lang_mail->line($leave['startdatetype']), 'EndDateType' => $lang_mail->line($leave['enddatetype']), 'Cause' => $leave['cause'], 'Type' => $leave['type_name']);
     if ($leave['status'] == 3) {
         //accepted
         $message = $this->parser->parse('emails/' . $employee['language'] . '/request_accepted', $data, TRUE);
         $subject = $lang_mail->line('email_leave_request_accept_subject');
     } else {
         //rejected
         $message = $this->parser->parse('emails/' . $employee['language'] . '/request_rejected', $data, TRUE);
         $subject = $lang_mail->line('email_leave_request_reject_subject');
     }
     sendMailByWrapper($this, $subject, $message, $employee['email'], is_null($supervisor) ? NULL : $supervisor->email);
 }
Beispiel #25
0
 /**
  * Send a overtime request email to the manager of the connected employee
  * @param int $id Leave request identifier
  * @author Benjamin BALET <*****@*****.**>
  */
 private function sendMail($id)
 {
     $this->load->model('users_model');
     $this->load->model('delegations_model');
     $manager = $this->users_model->get_users($this->session->userdata('manager'));
     //Test if the manager hasn't been deleted meanwhile
     if (empty($manager['email'])) {
         $this->session->set_flashdata('msg', lang('extra_create_msg_error'));
     } else {
         $acceptUrl = base_url() . 'overtime/accept/' . $id;
         $rejectUrl = base_url() . 'overtime/reject/' . $id;
         //Send an e-mail to the manager
         $this->load->library('email');
         $this->load->library('polyglot');
         $usr_lang = $this->polyglot->code2language($manager['language']);
         //We need to instance an different object as the languages of connected user may differ from the UI lang
         $lang_mail = new CI_Lang();
         $lang_mail->load('email', $usr_lang);
         $lang_mail->load('global', $usr_lang);
         $date = new DateTime($this->input->post('date'));
         $startdate = $date->format($lang_mail->line('global_date_format'));
         $this->load->library('parser');
         $data = array('Title' => $lang_mail->line('email_extra_request_validation_title'), 'Firstname' => $this->session->userdata('firstname'), 'Lastname' => $this->session->userdata('lastname'), 'Date' => $startdate, 'Duration' => $this->input->post('duration'), 'Cause' => $this->input->post('cause'), 'UrlAccept' => $acceptUrl, 'UrlReject' => $rejectUrl);
         $message = $this->parser->parse('emails/' . $manager['language'] . '/overtime', $data, TRUE);
         if ($this->email->mailer_engine == 'phpmailer') {
             $this->email->phpmailer->Encoding = 'quoted-printable';
         }
         if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
             $this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
         } else {
             $this->email->from('*****@*****.**', 'LMS');
         }
         $this->email->to($manager['email']);
         if ($this->config->item('subject_prefix') != FALSE) {
             $subject = $this->config->item('subject_prefix');
         } else {
             $subject = '[Jorani] ';
         }
         //Copy to the delegates, if any
         $delegates = $this->delegations_model->get_delegates_mails($manager['id']);
         if ($delegates != '') {
             $this->email->cc($delegates);
         }
         $this->email->subject($subject . $lang_mail->line('email_extra_request_reject_subject') . $this->session->userdata('firstname') . ' ' . $this->session->userdata('lastname'));
         $this->email->message($message);
         $this->email->send();
     }
 }