/**
  * send email
  *
  * @param string $send_to - recepient email
  * @param string $patern_name - email patern  name
  * @param array $variables - variables to raplase in message:
  *   $variables = array('$user$' => 'UserName')
  * @return bool
  */
 public function sendEmail($send_to, $patern_name, $variables, $attachment = FALSE)
 {
     //loading CodeIgniter Email library
     $this->load->library('email');
     $locale = \MY_Controller::getCurrentLocale();
     //Getting settings
     $patern_settings = $this->cmsemail_model->getPaternSettings($patern_name);
     $default_settings = $this->cmsemail_model->getSettings($locale);
     //Prepare settings into correct array for initialize library
     if ($patern_settings) {
         foreach ($patern_settings as $key => $value) {
             if (!$value) {
                 if ($default_settings[$key]) {
                     $patern_settings[$key] = $default_settings[$key];
                 }
             }
         }
     }
     $default_settings['type'] = strtolower($patern_settings['type']);
     $patern_settings['protocol'] = $default_settings['protocol'];
     if (strtolower($default_settings['protocol']) == strtolower("SMTP")) {
         $patern_settings['smtp_port'] = $default_settings['port'];
         $patern_settings['smtp_host'] = $default_settings['smtp_host'];
         $patern_settings['smtp_user'] = $default_settings['smtp_user'];
         $patern_settings['smtp_pass'] = $default_settings['smtp_pass'];
         $patern_settings['smtp_crypto'] = $default_settings['encryption'];
         $this->email->set_newline("\r\n");
     }
     //Initializing library settings
     $this->_set_config($patern_settings);
     //Sending user email if active in options
     if ($patern_settings['user_message_active']) {
         $this->from_email = $patern_settings['from_email'];
         $this->from = $patern_settings['from'];
         $this->send_to = $send_to;
         $this->theme = $patern_settings['theme'];
         $this->message = $this->replaceVariables($patern_settings['user_message'], $variables);
         if (!$this->_sendEmail()) {
             $this->errors[] = lang('User message doesnt send', 'cmsemail');
         } else {
             //Registering event is success
             \CMSFactory\Events::create()->registerEvent(array('from' => $this->from, 'from_email' => $this->from_email, 'send_to' => $this->send_to, 'theme' => $this->theme, 'message' => $this->message), 'ParentEmail:userSend');
             \CMSFactory\Events::runFactory();
         }
     }
     //Sending administrator email if active in options
     if ($patern_settings['admin_message_active']) {
         $this->from_email = $patern_settings['from_email'];
         $this->from = $patern_settings['from'];
         if ($patern_settings['admin_email']) {
             $this->send_to = $patern_settings['admin_email'];
         } else {
             $this->send_to = $default_settings['admin_email'];
         }
         $this->theme = $patern_settings['theme'];
         $this->message = $this->replaceVariables($patern_settings['admin_message'], $variables);
         $this->attachment = $attachment;
         if (!$this->_sendEmail()) {
             $this->errors[] = lang('User message doesnt send', 'cmsemail');
         } else {
             //Registering event is success
             \CMSFactory\Events::create()->registerEvent(array('from' => $this->from, 'from_email' => $this->from_email, 'send_to' => $this->send_to, 'theme' => $this->theme, 'message' => $this->message), 'ParentEmail:adminSend');
             \CMSFactory\Events::runFactory();
         }
     }
     //Returning status
     if ($this->errors) {
         return FALSE;
     } else {
         return TRUE;
     }
 }
Пример #2
0
function runFactory()
{
    \CMSFactory\Events::runFactory();
}
Пример #3
0
 /**
  * Show edit category window
  *
  * @access public
  */
 function edit($id)
 {
     //cp_check_perm('category_edit');
     $cat = $this->cms_admin->get_category($id);
     /** Init Event. Pre Create Category */
     \CMSFactory\Events::create()->registerEvent(array('pageId' => $id, 'url' => $cat['url']), 'Categories:preUpdate');
     \CMSFactory\Events::runFactory();
     ($hook = get_hook('admin_edit_category')) ? eval($hook) : NULL;
     if ($cat !== FALSE) {
         // Get langs
         $langs = $this->cms_base->get_langs();
         $this->template->assign('langs', $langs);
         $settings = unserialize($cat['settings']);
         $cat['fetch_pages'] = unserialize($cat['fetch_pages']);
         $this->template->add_array($cat);
         $this->template->assign('tree', $this->lib_category->build());
         $this->template->assign('include_cats', $this->sub_cats($this->lib_category->build()));
         $this->template->assign('settings', $settings);
         ($hook = get_hook('admin_show_category_edit')) ? eval($hook) : NULL;
         $this->template->show('category_edit', FALSE);
     } else {
         return FALSE;
     }
 }
Пример #4
0
 public function index()
 {
     // get latest pages
     $this->db->limit(5);
     $this->db->order_by('created', 'DESC');
     $this->db->where('lang_alias', 0);
     $latest = $this->db->get('content')->result_array();
     // get recenly updated pages
     $this->db->limit(5);
     $this->db->order_by('updated', 'DESC');
     $this->db->where('updated >', 0);
     $this->db->where('lang_alias', 0);
     $updated = $this->db->get('content')->result_array();
     // get comments
     if ($this->db->get_where('components', array('name' => 'comments'))->row()) {
         $comments = $this->db->where('status', '0')->or_where('status', '1')->order_by('date', 'DESC')->get('comments')->result_array();
         $total_comments = count($comments);
         $comments = array_slice($comments, 0, 5);
     } else {
         $total_comments = 0;
     }
     // total pages
     $this->db->where('post_status', 'publish');
     $this->db->from('content');
     $total_pages = $this->db->count_all_results();
     // total categories
     $this->db->from('category');
     $total_cats = $this->db->count_all_results();
     $this->template->add_array(array('latest' => $latest, 'updated' => $updated, 'comments' => $comments, 'total_cats' => $total_cats, 'total_pages' => $total_pages, 'total_comments' => $total_comments));
     // If we are online - load system news.
     $s_ip = substr($_SERVER['SERVER_ADDR'], 0, strrpos($_SERVER['SERVER_ADDR'], '.'));
     switch ($s_ip) {
         case '127.0.0':
         case '127.0.1':
         case '10.0.0':
         case '172.16.0':
         case '192.168.0':
             $on_local = TRUE;
             break;
     }
     if (($api_news = $this->cache->fetch('api_news_cache')) !== FALSE) {
         $this->template->assign('api_news', $api_news);
     } else {
         if ($on_local !== TRUE) {
             $this->config->load('api');
             $api_news = $this->_curl_post($this->config->item('imagecms_latest_news'), array('for' => IMAGECMS_NUMBER));
             if (count(unserialize($api_news['result'])) > 1 and $api_news['code'] == '200') {
                 $this->template->assign('api_news', unserialize($api_news['result']));
                 $this->cache->store('api_news_cache', unserialize($api_news['result']));
             } else {
                 $this->cache->store('api_news_cache', 'false');
             }
         }
     }
     // Get system upgrade info
     //        $this->load->module('admin/sys_upgrade');
     //        $status = $this->sys_upgrade->_check_status();
     // Get next version number
     $next_v = explode('_', $status['upgrade_file']);
     if (isset($next_v[2])) {
         $this->template->assign('next_v', str_replace('.zip', '', $next_v[2]));
     }
     $this->template->add_array(array('cms_number' => IMAGECMS_NUMBER, 'sys_status' => $status));
     \CMSFactory\Events::create()->registerEvent('', 'Dashboard:show');
     \CMSFactory\Events::runFactory();
     $this->template->show('dashboard', FALSE);
 }
 public function edit_module_widget($id, $update_info = FALSE, $locale = NULL)
 {
     //cp_check_perm('widget_access_settings');
     $locale = $locale ? $locale : MY_Controller::defaultLocale();
     if ($_POST) {
         $this->update_widget($id, $update_info, $locale);
         $this->cache->delete_all();
         $this->lib_admin->log(lang("Widget edited", "admin"));
     } else {
         $widget = $this->db->where('widgets.id', $id)->join('widget_i18n', 'widget_i18n.id=widgets.id AND locale="' . $locale . '"', 'left')->get('widgets');
         /** Init Event. Pre Create Category */
         \CMSFactory\Events::create()->registerEvent(array('widgetId' => $id), 'WidgetModule:preUpdate');
         \CMSFactory\Events::runFactory();
         $this->template->add_array(array('widget_id' => $id, 'widget' => $widget->row_array(), 'locale' => $locale, 'languages' => $this->db->get('languages')->result_array()));
         $this->template->show('widget_edit_module', FALSE);
     }
 }
Пример #6
0
 /**
  * Update existing page by ID
  *
  * @access public
  */
 function update($page_id)
 {
     //cp_check_perm('page_edit');
     $data = $this->db->get_where('content', array('id' => $page_id));
     if ($data->num_rows() > 0) {
         $data = $data->row_array();
     } else {
         $data = FALSE;
     }
     /** Init Event. Pre Edit Page */
     \CMSFactory\Events::create()->registerEvent(array('pageId' => $page_id, 'url' => $data['url']), 'BaseAdminPage:preUpdate');
     \CMSFactory\Events::runFactory();
     $this->form_validation->set_rules('page_title', lang("Title", "admin"), 'trim|required|min_length[1]|max_length[500]');
     $this->form_validation->set_rules('page_url', lang("URL", "admin"), 'alpha_dash');
     $this->form_validation->set_rules('page_keywords', lang("Keywords", "admin"), 'trim');
     $this->form_validation->set_rules('prev_text', lang("Preliminary contents", "admin"), 'trim|required');
     $this->form_validation->set_rules('page_description', lang("Description ", "admin"), 'trim');
     $this->form_validation->set_rules('full_tpl', lang("Page template", "admin"), 'trim|max_length[50]|min_length[2]|callback_tpl_validation');
     $this->form_validation->set_rules('main_tpl', lang("Main page template ", "admin"), 'trim|max_length[50]|min_length[2]|callback_tpl_validation');
     $this->form_validation->set_rules('create_date', lang("Creation date", "admin"), 'required|valid_date');
     $this->form_validation->set_rules('create_time', lang("Creation time", "admin"), 'required|valid_time');
     $this->form_validation->set_rules('publish_date', lang("Publication date", "admin"), 'required|valid_date');
     $this->form_validation->set_rules('publish_time', lang("Publication time", "admin"), 'required|valid_time');
     ($hook = get_hook('admin_page_update_set_rules')) ? eval($hook) : NULL;
     $page_category = $this->cms_admin->get_category($data['category']);
     if ($page_category['field_group'] != -1 && $page_category) {
         $groupId = $page_category['field_group'];
         ($hook = get_hook('cfcm_set_rules')) ? eval($hook) : NULL;
     }
     if ($this->form_validation->run($this) == FALSE) {
         ($hook = get_hook('admin_page_update_val_failed')) ? eval($hook) : NULL;
         showMessage(validation_errors(), false, 'r');
     } else {
         // load site settings
         $settings = $this->cms_admin->get_settings();
         if ($this->input->post('page_url') == '' or $this->input->post('page_url') == NULL) {
             $this->load->helper('translit');
             $url = translit_url($this->input->post('page_title'));
         } else {
             $url = $this->input->post('page_url');
         }
         // check if we have existing module with entered URL
         $this->db->where('name', $url);
         $query = $this->db->get('components');
         if ($query->num_rows() > 0) {
             showMessage(lang("Reserved the same name module", "admin"), false, 'r');
             exit;
         }
         // end module check
         // check if we have existing category with entered URL
         $this->db->where('url', $url);
         $query = $this->db->get('category', 1);
         if ($query->num_rows() > 0) {
             showMessage(lang("Reserved of the same name category", "admin"), false, 'r');
             exit;
         }
         // end check
         // check if we have existing page with entered URL
         $b_page = $this->cms_admin->get_page($page_id);
         $this->db->where('url', $url);
         $this->db->where('category', $this->input->post('category'));
         $this->db->where('category !=', $b_page['category']);
         $this->db->where('lang', $b_page['lang']);
         $query = $this->db->get('content', 1);
         if ($query->num_rows() > 0) {
             showMessage(lang("Page with URL", "admin") . '<b>' . $url . '</b>' . lang("in ID category", "admin") . $this->input->post('category') . lang(" already exists. Specify or select another URL"), false, 'r');
             exit;
         }
         // end check
         $full_url = $this->lib_category->GetValue($this->input->post('category'), 'path_url');
         if ($full_url == FALSE) {
             $full_url = '';
         }
         $keywords = $this->lib_admin->db_post('page_keywords');
         $description = $this->lib_admin->db_post('page_description');
         // create keywords
         //            if ($keywords == '' AND $settings['create_keywords'] == 'auto') {
         //                $keywords = $this->lib_seo->get_keywords($this->input->post('prev_text') . ' ' . $this->input->post('full_text'));
         //            }
         // create description
         //            if ($description == '' AND $settings['create_description'] == 'auto') {
         //                $description = $this->lib_seo->get_description($this->input->post('prev_text') . ' ' . $this->input->post('full_text'));
         //            }
         //            mb_substr($keywords, -1) == ',' ? $keywords = mb_substr($keywords, 0, -1) : TRUE;
         $publish_date = $this->input->post('publish_date') . ' ' . $this->input->post('publish_time');
         $create_date = $this->input->post('create_date') . ' ' . $this->input->post('create_time');
         $data = array('title' => trim($this->input->post('page_title')), 'meta_title' => trim($this->input->post('meta_title')), 'url' => str_replace('.', '', trim($url)), 'cat_url' => $full_url, 'keywords' => $keywords, 'description' => $description, 'full_text' => trim($this->input->post('full_text')), 'prev_text' => trim($this->lib_admin->db_post('prev_text')), 'category' => $this->input->post('category'), 'full_tpl' => $_POST['full_tpl'], 'main_tpl' => $_POST['main_tpl'], 'comments_status' => $this->input->post('comments_status'), 'post_status' => $this->input->post('post_status'), 'author' => $this->dx_auth->get_username(), 'publish_date' => strtotime($publish_date), 'created' => strtotime($create_date), 'updated' => time());
         $data['id'] = $page_id;
         if ($b_page['lang_alias'] != 0) {
             $data['url'] = $b_page['url'];
         }
         $this->on_page_update($data);
         $this->load->module('cfcm')->save_item_data($page_id, 'page');
         $this->cache->delete_all();
         //($hook = get_hook('admin_page_update')) ? eval($hook) : NULL;
         if ($this->cms_admin->update_page($page_id, $data) >= 1) {
             $this->lib_admin->log(lang("Changed the page", "admin") . " " . '<a href="' . site_url('admin/pages/edit/' . $page_id) . '">' . $data['title'] . '</a>');
             $action = $this->input->post('action');
             $path = '/admin/pages/GetPagesByCategory';
             if ($action == 'edit') {
                 $path = '/admin/pages/edit/' . $page_id;
             }
             showMessage(lang("Page contents have been updated", "admin"));
             pjax($path);
         } else {
             showMessage('', false, 'r');
         }
     }
 }
Пример #7
0
 public function edit_module_widget($id)
 {
     //cp_check_perm('widget_access_settings');
     $widget = $this->get($id);
     /** Init Event. Pre Create Category */
     \CMSFactory\Events::create()->registerEvent(array('widgetId' => $id), 'WidgetModule:preUpdate');
     \CMSFactory\Events::runFactory();
     $this->template->add_array(array('widget' => $widget->row_array()));
     $this->template->show('widget_edit_module', FALSE);
 }