public template ( $template_file, $template_lang = '', $template_path = '', $template_dir_prefix = '' ) |
function template($template_file, $template_lang = '', $template_path = '', $template_dir_prefix = '')
{
global $config, $phpbb_root_path, $user;
$template_dir_prefix = !$template_dir_prefix || $template_dir_prefix[0] === '/' ? $template_dir_prefix : '/' . $template_dir_prefix;
$this->setup_template();
if (!trim($template_file)) {
trigger_error('No template file for emailing set.', E_USER_ERROR);
}
if (!trim($template_lang)) {
// fall back to board default language if the user's language is
// missing $template_file. If this does not exist either,
// $this->template->set_filenames will do a trigger_error
$template_lang = basename($config['default_lang']);
}
$ext_template_paths = array(array('name' => $template_lang . '_email', 'ext_path' => 'language/' . $template_lang . '/email' . $template_dir_prefix));
if ($template_path) {
$template_paths = array($template_path . $template_dir_prefix);
} else {
$template_path = !empty($user->lang_path) ? $user->lang_path : $phpbb_root_path . 'language/';
$template_path .= $template_lang . '/email';
$template_paths = array($template_path . $template_dir_prefix);
$board_language = basename($config['default_lang']);
// we can only specify default language fallback when the path is not a custom one for which we
// do not know the default language alternative
if ($template_lang !== $board_language) {
$fallback_template_path = !empty($user->lang_path) ? $user->lang_path : $phpbb_root_path . 'language/';
$fallback_template_path .= $board_language . '/email';
$template_paths[] = $fallback_template_path . $template_dir_prefix;
$ext_template_paths[] = array('name' => $board_language . '_email', 'ext_path' => 'language/' . $board_language . '/email' . $template_dir_prefix);
}
// If everything fails just fall back to en template
if ($template_lang !== 'en' && $board_language !== 'en') {
$fallback_template_path = !empty($user->lang_path) ? $user->lang_path : $phpbb_root_path . 'language/';
$fallback_template_path .= 'en/email';
$template_paths[] = $fallback_template_path . $template_dir_prefix;
$ext_template_paths[] = array('name' => 'en_email', 'ext_path' => 'language/en/email' . $template_dir_prefix);
}
}
$this->set_template_paths($ext_template_paths, $template_paths);
$this->template->set_filenames(array('body' => $template_file . '.txt'));
return true;
}
public function ucp_register_user_row_after($event) { if ($this->config['require_activation'] != USER_ACTIVATION_ADMIN) { // Grab an array of user_id's with a_user permissions ... these users can activate a user $admin_ary = $this->auth->acl_get_list(false, 'a_user', false); $admin_ary = !empty($admin_ary[0]['a_user']) ? $admin_ary[0]['a_user'] : array(); // Also include founders $where_sql = ' WHERE user_type = ' . USER_FOUNDER; if (sizeof($admin_ary)) { $where_sql .= ' OR ' . $this->db->sql_in_set('user_id', $admin_ary); } $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type FROM ' . USERS_TABLE . ' ' . $where_sql; $result = $this->db->sql_query($sql); $data = array('username' => $this->request->variable('username', '', true), 'email' => strtolower($this->request->variable('email', '')), 'user_regdate' => time(), 'user_ip' => $this->user->ip, 'lang' => basename($this->request->variable('lang', $this->user->lang_name))); while ($row = $this->db->sql_fetchrow($result)) { if (!class_exists('messenger')) { include $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext; } $messenger = new \messenger(false); $server_url = generate_board_url(); $messenger->template('@dmzx_notifyadmin/admin_notify_registered', $data['lang']); $messenger->to($row['user_email'], $row['username']); $messenger->im($row['user_jabber'], $row['username']); $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'USER_MAIL' => $data['email'], 'USER_REGDATE' => date($this->config['default_dateformat'], $data['user_regdate']), 'USER_IP' => $data['user_ip'])); $messenger->send(NOTIFY_EMAIL); } $this->db->sql_freeresult($result); } }