Пример #1
0
 /**
  * Build (return) the email template, will return false if the file is
  * not found
  * 
  * @param string $view
  * @return string|bool Email template text or false when file is not found
  */
 public function build($view, $content)
 {
     $CI =& get_instance();
     # Change the theme to the frontend theme to get the email template contents.
     $CI->template->set_theme(PAN::setting('theme'));
     $CI->_theme_path = $CI->template->get_theme_path();
     $file_location = $CI->_theme_path . 'views/emails/' . $view . '.php';
     if (file_exists($file_location)) {
         $email_content = file_get_contents($file_location);
         $email_content = Email_Template::parse_text($email_content, array('content' => $content));
         # Change the theme back to the admin theme to keep things running smoothly.
         $CI->template->set_theme('admin/' . PAN::setting('admin_theme'));
         return $email_content;
     } else {
         show_error('Could not send the email. ' . $file_location . ' does not exist.');
         return false;
     }
 }
Пример #2
0
 /**
  * The construct checks for authorization then loads in settings for
  * all of the admin controllers.
  *
  * @access	public
  * @return	void
  */
 public function __construct()
 {
     parent::__construct();
     // Load the Language files ready for output
     $this->lang->load('admin');
     $this->lang->load('buttons');
     if (in_array($this->method, $this->secured_methods) || in_array('_all_', $this->secured_methods)) {
         if (!$this->ion_auth->logged_in() and $this->method != 'no_internet_access') {
             $this->session->set_userdata('login_redirect', $this->uri->uri_string());
             redirect('admin/users/login');
         }
         // Be an admin or have access to this module a bit
         $module = $this->router->fetch_module();
         if (!$this->ion_auth->is_sadmin() and (empty($this->permissions) or $module !== 'dashboard' and empty($this->permissions[$module]))) {
             $this->session->set_userdata('error', lang('cp_access_denied'));
             redirect('dashboard');
             // show_error('Permission Denied');
         }
     }
     // If the setting is enabled redirect request to HTTPS
     if ($this->settings->admin_force_https and strtolower(substr(current_url(), 4, 1)) != 's') {
         redirect(str_replace('http:', 'https:', current_url()) . '?session=' . session_id());
     }
     $this->load->helper('admin_theme');
     ci()->admin_theme = $this->theme_m->get_admin();
     // Using a bad slug? Weak
     if (empty($this->admin_theme->slug)) {
         show_error('This site has been set to use an admin theme that does not exist.');
     }
     // make a constant as this is used in a lot of places
     defined('ADMIN_THEME') or define('ADMIN_THEME', $this->admin_theme->slug);
     $this->load->library('form_validation');
     // Set the location of assets
     Asset::add_path('theme', $this->admin_theme->web_path . '/');
     Asset::set_path('theme');
     // grab the theme options if there are any
     ci()->theme_options = $this->appcache->model('theme_m', 'get_values_by', array(array('theme' => ADMIN_THEME)));
     // Active Admin Section (might be null, but who cares)
     $this->template->active_section = $this->section;
     Events::trigger('admin_controller');
     // Template configuration
     $this->template->enable_parser(FALSE)->set('theme_options', $this->theme_options)->set_theme('' . PAN::setting('admin_theme'))->set_layout('index');
     $this->template->set_partial('notifications', 'partials/notifications');
     $this->template->module = $this->router->fetch_module();
     // Active Admin Section (might be null, but who cares)
     $this->template->active_section = $this->section;
     // Get the diskspace library
     $this->load->library('system/diskSpace');
     // Get detils about the server
     $dUsage = new diskSpace(".");
     $this->template->perentagefree = $dUsage->percentage_free;
     // will output: Percentage Free: 93%
     $this->template->percentageused = $dUsage->percentage_used;
     // Setting up the base pagination config
     $this->pagination_config['per_page'] = Settings::get('items_per_page');
     $this->pagination_config['num_links'] = 5;
     $this->pagination_config['full_tag_open'] = '';
     $this->pagination_config['full_tag_close'] = '';
     $this->pagination_config['first_tag_open'] = '';
     $this->pagination_config['first_tag_close'] = '';
     $this->pagination_config['last_tag_open'] = '';
     $this->pagination_config['last_tag_close'] = '';
     $this->pagination_config['prev_tag_open'] = '';
     $this->pagination_config['prev_tag_close'] = '';
     $this->pagination_config['next_tag_open'] = '';
     $this->pagination_config['next_tag_close'] = '';
     $this->pagination_config['cur_tag_open'] = '';
     $this->pagination_config['cur_tag_close'] = '';
     $this->pagination_config['num_tag_open'] = '';
     $this->pagination_config['num_tag_close'] = '';
     // Try to determine the pagination base_url
     $segments = $this->uri->segment_array();
     if ($this->uri->total_segments() >= 4) {
         array_pop($segments);
     }
     if (Settings::get('application_debug') == true) {
         $this->output->enable_profiler(true);
     } else {
         $this->output->enable_profiler(false);
     }
     $this->pagination_config['base_url'] = site_url(implode('/', $segments));
     $this->pagination_config['uri_segment'] = 4;
     // Add the theme path to the asset paths
     // trigger the run() method in the selected admin theme -
     $class = 'Theme_' . ucfirst($this->admin_theme->slug);
     call_user_func(array(new $class(), 'run'));
     log_message('debug', "Main_Controller Class Initialized");
 }
Пример #3
0
*
*/
/**
 * Tables.
 **/
$config['tables']['groups'] = 'groups';
$config['tables']['users'] = 'users';
$config['tables']['meta'] = 'meta';
/**
 * Site Title, example.com
 */
$config['site_title'] = PAN::setting('site_name');
/**
 * Admin Email, admin@example.com
 */
$config['admin_email'] = PAN::setting('notify_email');
/**
 * Default group, use name
 */
$config['default_group'] = 'members';
/**
 * Default administrators group, use name
 */
$config['admin_group'] = 'admin';
/**
 * Meta table column you want to join WITH.
 * Joins from users.id
 **/
$config['join'] = 'user_id';
/**
 * Columns in your meta table,
Пример #4
0
function format_time($unix)
{
    if ($unix == '' || !is_numeric($unix)) {
        return $unix;
    }
    if (empty($unix) or $unix == '0') {
        return 'n/a';
    }
    return date(PAN::setting('time_format'), $unix);
}
Пример #5
0
function get_pdf($type, $return_html = false, $data)
{
    $CI =& get_instance();
    $original_layout = $CI->template->_layout;
    //    unset($CI->template->_partials['notifications']);
    $CI->template->_module = 'reports';
    $CI->load->helper('typography');
    $CI->load->model('files/files_m');
    $CI->template->pdf_mode = true;
    $CI->template->set_theme(PAN::setting('theme'));
    Asset::add_path('theme', $CI->template->get_theme_path());
    //    asset::add_path($CI->template->get_theme_path());
    $CI->template->reports = $data;
    $CI->template->set_layout('pdf_report');
    $html = $CI->template->build($type, $data, TRUE);
    // do not show on screen - can be used to output to pdf
    include_once APPPATH . 'libraries/dompdf/dompdf_config.custom.inc.php';
    include_once APPPATH . 'libraries/dompdf/dompdf_config.inc.php';
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper(Settings::get('pdf_page_size'));
    $dompdf->render();
    $filepath = prepare_export($type, 'pdf');
    $filename = basename($filepath);
    file_put_contents($filepath, $dompdf->output());
    $dompdf->stream($filename);
    return array('dompdf' => $dompdf);
}