Example #1
0
 public function recent_news_configure($action = 'show_settings', $widget_data = array())
 {
     if ($this->dx_auth->is_admin() == FALSE) {
         exit;
     }
     switch ($action) {
         case 'show_settings':
             $this->load->library('lib_category');
             $cats = $this->lib_category->build();
             //$this->display_tpl('recent_news_form', array('widget' => $widget_data, 'cats' => $cats));
             $this->render('recent_news_form', array('widget' => $widget_data, 'cats' => $cats));
             break;
         case 'update_settings':
             $this->form_validation->set_rules('news_count', lang("Amount of news", "core"), 'trim|required|is_natural_no_zero|min_length[1]');
             $this->form_validation->set_rules('max_symdols', lang("Maximum number of characters", "core"), 'trim|required|is_natural|min_length[1]');
             if ($this->form_validation->run($this) == FALSE) {
                 showMessage(validation_errors());
             } else {
                 $data = array('news_count' => $_POST['news_count'], 'max_symdols' => $_POST['max_symdols'], 'categories' => $_POST['categories'], 'display' => $_POST['display']);
                 $this->load->module('admin/widgets_manager')->update_config($widget_data['id'], $data);
                 showMessage(lang("Settings have been saved", 'core'));
                 if ($_POST['action'] == 'tomain') {
                     pjax('/admin/widgets_manager/index');
                 }
             }
             break;
         case 'install_defaults':
             $this->load->module('admin/widgets_manager')->update_config($widget_data['id'], $this->defaults);
             break;
     }
 }
Example #2
0
 /**
  * Configure widget settings
  * @param string $action
  * @param array $widget_data
  */
 public function show_form_configure($action = 'show_settings', array $widget_data = [])
 {
     if ($this->dx_auth->is_admin() == FALSE) {
         exit;
     }
     switch ($action) {
         case 'show_settings':
             assetManager::create()->setData('widget', $widget_data)->setData('forms', $this->xforms_model->get_forms())->renderAdmin('widget_settings');
             break;
         case 'update_settings':
             $this->form_validation->set_rules('form_id', 'Форма', 'required');
             if ($this->form_validation->run($this) == FALSE) {
                 showMessage(validation_errors(), false, 'r');
             } else {
                 $data = ['form_id' => $this->input->post('form_id')];
                 $this->load->module('admin/widgets_manager')->update_config($widget_data['id'], $data);
                 showMessage(lang('amt_settings_saved', 'xforms'));
                 if ($this->input->post('action') == 'tomain') {
                     pjax('/admin/widgets_manager/index');
                 }
             }
             break;
         case 'install_defaults':
             $this->load->module('admin/widgets_manager')->update_config($widget_data['id'], $this->defaults);
             break;
     }
 }
Example #3
0
 public function latest_fotos_configure($action = 'show_settings', $widget_data = array())
 {
     if ($this->dx_auth->is_admin() == FALSE) {
         exit;
     }
     switch ($action) {
         case 'show_settings':
             //$this->display_tpl('latest_fotos_form', array('widget' => $widget_data));
             $this->render('latest_fotos_form', array('widget' => $widget_data));
             break;
         case 'update_settings':
             $this->load->library('Form_validation');
             $this->form_validation->set_rules('limit', lang("Image limit", 'gallery'), 'trim|required|integer');
             if ($this->form_validation->run($this) == FALSE) {
                 showMessage(validation_errors(), false, 'r');
                 exit;
             }
             $data = array('limit' => $_POST['limit'], 'order' => $_POST['order']);
             $this->load->module('admin/widgets_manager')->update_config($widget_data['id'], $data);
             showMessage(lang("Settings have been saved", 'gallery'));
             if ($_POST['action'] == 'tomain') {
                 pjax('/admin/widgets_manager/index');
             }
             break;
         case 'install_defaults':
             $data = array('limit' => 5, 'order' => 'latest');
             $this->load->module('admin/widgets_manager')->update_config($widget_data['id'], $data);
             break;
     }
 }
Example #4
0
 public function edit($id, $locale = null)
 {
     if (null === $locale) {
         $locale = chose_language();
     }
     $model = $this->email->getTemplateById($id, $locale);
     if (!$model) {
         $this->load->module('core');
         $this->core->error_404();
         exit;
     }
     $variables = unserialize($model['variables']);
     if ($_POST) {
         if ($this->email->edit($id, array(), $locale)) {
             showMessage(lang('Template edited', 'cmsemail'));
             if ($this->input->post('action') == 'tomain') {
                 pjax('/admin/components/cp/cmsemail/index');
             }
         } else {
             showMessage($this->email->errors, '', 'r');
         }
     } else {
         \CMSFactory\assetManager::create()->setData('locale', $locale)->setData('languages', $this->db->get('languages')->result_array())->setData('model', $model)->setData('variables', $variables)->registerScript('email', TRUE)->renderAdmin('edit');
     }
 }
Example #5
0
 /**
  * Update settings from POST
  * @param $_POST
  * @author A.Gula <*****@*****.**>
  * @copyright (c) 2013, ImageCMS
  */
 public function update_settings()
 {
     $result = array_map('trim', $_POST);
     /** Save input data */
     $this->db->where('identif', 'socauth')->update('components', array('settings' => serialize($result)));
     showMessage(lang('Settings are saved', 'socauth'));
     pjax($_SERVER[HTTP_REFERER]);
 }
Example #6
0
 public function update_settings()
 {
     $settings = json_encode($_POST['sr']);
     $this->rating_model->update_settings($settings);
     if ($this->input->post('action') == 'tomain') {
         pjax('/admin/components/modules_table');
     }
     showMessage(lang("Settings saved success", 'star_rating'));
 }
Example #7
0
 public function updateSettings()
 {
     $this->db->update('mod_sample_settings', array('value' => $this->input->post('mailTo')), array('name' => 'mailTo'));
     $this->db->update('mod_sample_settings', array('value' => $this->input->post('useEmailNotification')), array('name' => 'useEmailNotification'));
     $this->db->update('mod_sample_settings', array('value' => $this->input->post('key')), array('name' => 'key'));
     showMessage(lang('Settings saved', 'sample_module'));
     if ($_POST['action'] == 'back') {
         pjax('/admin/components/modules_table');
     }
 }
Example #8
0
 public function __construct()
 {
     if (!extension_loaded('soap')) {
         showMessage(lang('PHP SOAP extension is not installed'), '', 'r');
         pjax('/admin');
     }
     parent::__construct();
     $this->update = new Update();
     $this->load->library('lib_admin');
     $this->lib_admin->init_settings();
     ini_set("soap.wsdl_cache_enabled", "0");
 }
Example #9
0
 public function update_settings()
 {
     $data = $_POST['ss'];
     $string = serialize($data);
     $this->db->set('settings', $string);
     $this->db->where('name', 'share');
     $this->db->update('components');
     if ($this->input->post('action') == 'tomain') {
         pjax('/admin/components/modules_table');
     }
     showMessage(lang('Settings successfully saved', 'share'));
 }
Example #10
0
 public function update()
 {
     //Yandex market settings
     if ($_POST['displayedCats']) {
         $this->db->set('value', serialize($this->input->post('displayedCats')));
         $this->db->where('id', 1);
         $this->db->update('mod_hotline_categories');
     } else {
         $this->db->set('value', '');
         $this->db->where('id', 1);
         $this->db->update('mod_hotline_categories');
     }
     pjax(site_url() . 'admin/components/cp/hotline');
 }
Example #11
0
 function delete_menu($name = null)
 {
     if ($name == null) {
         $name = $this->input->post('ids');
         foreach ($name as $n) {
             $this->menu->prepare_menu_array($n);
             $this->root_menu =& $this->menu->menu_array;
             $this->sub_menu =& $this->menu->sub_menu_array;
             $this->process_root($this->root_menu);
             //root menus array
             foreach ($this->root_menu as $menu) {
                 $this->menu_model->delete_menu_item($menu['id']);
             }
             //sub menus array
             foreach ($this->sub_menu as $menu) {
                 $this->menu_model->delete_menu_item($menu['id']);
             }
             //delete main menu
             $this->menu_model->delete_menu($n);
         }
         showMessage(lang("Menu removed", 'menu'));
         pjax('/admin/components/cp/menu');
     } else {
         $this->menu->prepare_menu_array($name);
         $this->root_menu =& $this->menu->menu_array;
         $this->sub_menu =& $this->menu->sub_menu_array;
         $this->process_root($this->root_menu);
         //root menus array
         foreach ($this->root_menu as $menu) {
             $this->menu_model->delete_menu_item($menu['id']);
         }
         //sub menus array
         foreach ($this->sub_menu as $menu) {
             $this->menu_model->delete_menu_item($menu['id']);
         }
         //delete main menu
         $this->menu_model->delete_menu($name);
         showMessage(lang("Menu removed", 'menu'));
         pjax('/admin/components/cp/menu');
     }
 }
Example #12
0
 function edit_trash($id)
 {
     $query = $this->db->get_where('trash', array('id' => $id));
     $this->template->add_array(array('trash' => $query->row()));
     if (count($this->db->get_where('components', array('name' => 'shop'))->row()) > 0) {
         $this->db->order_by("name", "asc");
         $query = $this->db->get('shop_products_i18n');
         $this->template->add_array(array('products' => $query->result()));
         $this->db->order_by("name", "asc");
         $query = $this->db->get('shop_category_i18n');
         $this->template->add_array(array('category' => $query->result()));
     }
     $this->db->order_by("name", "asc");
     $query = $this->db->get('category');
     $this->template->add_array(array('category_base' => $query->result()));
     if (!$this->ajaxRequest) {
         $this->display_tpl('edit_trash');
     }
     if ($_POST) {
         switch ($this->input->post('redirect_type')) {
             case "url":
                 $array = array('id' => $this->input->post('id'), 'trash_url' => $this->input->post('old_url'), 'trash_redirect_type' => $this->input->post('redirect_type'), 'trash_type' => $this->input->post('type'), 'trash_redirect' => prep_url($this->input->post('redirect_url')));
                 break;
             case "product":
                 $query = $this->db->get_where('shop_products', array('id' => $this->input->post('products')));
                 $url = $query->row();
                 $array = array('id' => $this->input->post('id'), 'trash_id' => $this->input->post('products'), 'trash_url' => $this->input->post('old_url'), 'trash_redirect_type' => $this->input->post('redirect_type'), 'trash_type' => $this->input->post('type'), 'trash_redirect' => site_url() . 'shop/product/' . $url->url);
                 break;
             case "category":
                 $query = $this->db->get_where('shop_category', array('id' => $this->input->post('category')));
                 $url = $query->row();
                 $array = array('id' => $this->input->post('id'), 'trash_id' => $this->input->post('category'), 'trash_url' => $this->input->post('old_url'), 'trash_redirect_type' => $this->input->post('redirect_type'), 'trash_type' => $this->input->post('type'), 'trash_redirect' => site_url() . 'shop/category/' . $url->full_path);
                 break;
             case "basecategory":
                 $query = $this->db->get_where('category', array('id' => $this->input->post('category_base')));
                 $url = $query->row();
                 $array = array('id' => $this->input->post('id'), 'trash_id' => $this->input->post('category_base'), 'trash_url' => $this->input->post('old_url'), 'trash_redirect_type' => $this->input->post('redirect_type'), 'trash_type' => $this->input->post('type'), 'trash_redirect' => site_url($this->cms_base->get_category_full_path($url->id)));
                 break;
             case "404":
                 $array = array('id' => $this->input->post('id'), 'trash_url' => $this->input->post('old_url'), 'trash_redirect_type' => $this->input->post('redirect_type'));
                 break;
             default:
                 $array = array('id' => $this->input->post('id'), 'trash_url' => $this->input->post('old_url'), 'trash_redirect_type' => $this->input->post('redirect_type'));
                 break;
         }
         $this->db->where('id', $this->input->post('id'));
         $this->db->update('trash', $array);
     }
     if ($this->input->post('action')) {
         showMessage(lang('Success', 'trash'));
     }
     if ($this->input->post('action') == 'exit') {
         pjax('/admin/components/init_window/trash');
     }
 }
 public function delete_group($id)
 {
     //todo: delete group
     $this->db->where('id', $id)->delete('content_field_groups');
     $this->db->where('group_id', $id)->update('content_fields_groups_relations', array('group_id' => '0'));
     $this->db->where('field_group', $id)->update('category', array('field_group' => '-1'));
     $this->db->where('category_field_group', $id)->update('category', array('category_field_group' => '-1'));
     $this->lib_admin->log(lang("Group deleted successfuly", "cfcm") . '. Id: ' . $id);
     showMessage(lang('Group deleted successfuly', 'cfcm'));
     pjax('/admin/components/cp/cfcm#fields_groups');
 }
Example #14
0
 /**
  * Upload image
  *
  * Upload image to album folder.
  *
  */
 public function upload_image($album_id = 0)
 {
     $temp_conf = $this->conf;
     if (is_array($_FILES['newPic'])) {
         // making transformation of $_FILES array for CodeIgniter's Upload class
         $this->transform_FILES('newPic');
         // configs for Upload
         $this->conf['upload_path'] = $this->conf['upload_path'] . $album_id;
         if (!is_dir($this->conf['upload_path'])) {
             mkdir($this->conf['upload_path']);
         }
         $config['upload_path'] = $this->conf['upload_path'];
         $config['allowed_types'] = $this->conf['allowed_types'];
         $config['max_size'] = 1024 * 1024 * $this->max_image_size;
         // init Upload
         $this->load->library('upload', $config);
         // saving each file
         $data = array();
         $i = 0;
         foreach ($_FILES as $fieldName => $filesData) {
             if (!$this->upload->do_upload($fieldName)) {
                 $error = $filesData['name'] . " - " . $this->upload->display_errors('', '') . "<br /> ";
                 $data['error'] .= $error;
             } else {
                 $data[$i] = array('upload_data' => $this->upload->data());
                 // Resize Image and create thumb
                 $this->resize_and_thumb($data[$i]['upload_data']);
                 $this->add_image($album_id, $data[$i]['upload_data']);
             }
             $buf = $this->conf['upload_path'];
             $this->conf = $temp_conf;
             $this->conf['upload_path'] = $buf;
             $i++;
         }
         if (isset($data['error'])) {
             showMessage($data['error'], '', 'r');
         } else {
             showMessage('Upload success');
             pjax('');
         }
     }
 }
 /**
  * Delete language
  */
 function delete()
 {
     //cp_check_perm('lang_delete');
     //$id = $this->input->post('lang_id');
     $id = $this->input->post('ids');
     if (is_array($id)) {
         foreach ($id as $item) {
             $lang = $this->cms_admin->get_lang($item);
             ($hook = get_hook('admin_language_delete')) ? eval($hook) : NULL;
             if ($lang['default'] == 1) {
                 showMessage(lang("This language has been used by default and can not be deleted", "admin"), lang("Blocking", "admin"), 'r');
                 exit;
             }
             $this->cms_admin->delete_lang($item);
             $this->deleteLanguageFolders($lang['locale']);
             // delete translated pages
             $this->db->where('lang', $item);
             $this->db->delete('content');
             $this->cache->delete('main_site_langs');
             $this->lib_admin->log(lang("Deleted the ID language", "admin") . " " . $item);
         }
     } else {
         $lang = $this->cms_admin->get_lang($id);
         ($hook = get_hook('admin_language_delete')) ? eval($hook) : NULL;
         if ($lang['default'] == 1) {
             showMessage(lang("This language has been used by default and can not be deleted", "admin"), lang("Blocking", "admin"), 'r');
             exit;
         }
         $this->cms_admin->delete_lang($id);
         // delete translated pages
         $this->db->where('lang', $id);
         $this->db->delete('content');
         $this->deleteLanguageFolders($lang['locale']);
         $this->cache->delete('main_site_langs');
         $this->lib_admin->log(lang("Deleted the ID language", "admin") . ' ' . $id);
     }
     showMessage(lang("the language has been deleted", "admin"));
     pjax('/admin/languages');
     //updateDiv('languages_page_w_content', site_url('admin/languages/'));
 }
Example #16
0
 /**
  * Create po-file
  * @param type $module_template
  * @param type $type
  * @param type $lang
  */
 public function createFile($module_template, $type, $lang)
 {
     if ($_POST) {
         $lang = $this->input->post('locale');
         $type = $this->input->post('type');
         $module_template = $this->input->post('module_template');
         $settings = $this->input->post();
         $settings['lang'] = $lang;
         if ($this->poFileManager->create($module_template, $type, $lang, $settings)) {
             showMessage(lang('File was succcessfuly created.', 'translator'), lang('Message', 'translator'));
             if ($this->input->post('action') == 'showEdit') {
                 $this->setSession($module_template, $type, $lang);
                 pjax('/admin/components/init_window/translator');
             }
         } else {
             foreach ($this->poFileManager->getErrors() as $error) {
                 showMessage($error, lang('Error', 'translator'), 'r');
             }
         }
     } else {
         $this->getExistingLocales();
         \CMSFactory\assetManager::create()->registerScript('admin')->registerStyle('admin')->setData('langs', $this->langs)->renderAdmin('create');
         if ($module_template && $type && $lang) {
             switch ($type) {
                 case 'modules':
                     $names = $this->renderModulesNames($lang);
                     $file_name = $module_template;
                     break;
                 case 'templates':
                     $names = $this->renderTemplatesNames($lang);
                     $file_name = $module_template;
                     break;
                 case 'main':
                     $file_name = $type;
                     break;
             }
             $names = trim(preg_replace('/\\s\\s+/', ' ', $names));
             jsCode("Translator.start('','" . $names . "', '" . $type . "', '" . $lang . "', '" . $file_name . "');");
         }
     }
 }
 public function deletePermition($id = null)
 {
     if (!$id) {
         return false;
     } else {
         $this->db->where('id', $id)->delete(self::$rbac_privileges_table . "_i18n");
         $this->db->where('id', $id)->delete(self::$rbac_privileges_table);
         showMessage("Привилегия удалена");
         pjax('/admin/rbac/roleEdit/1');
     }
 }
Example #18
0
 public function recent_product_comments_configure($action = 'show_settings', $widget_data = array())
 {
     if ($this->dx_auth->is_admin() == FALSE) {
         exit;
     }
     // Only admin access
     switch ($action) {
         case 'show_settings':
             \CMSFactory\assetManager::create()->setData('widget', $widget_data)->renderAdmin('recent_product_comments_form');
             break;
         case 'update_settings':
             $this->form_validation->set_rules('comments_count', lang("Number of responses"), 'trim|required|is_natural_no_zero|min_length[1]');
             $this->form_validation->set_rules('symbols_count', lang("Number of characters"), 'required|trim|is_natural');
             if ($this->form_validation->run($this) == FALSE) {
                 showMessage(validation_errors());
             } else {
                 $data = array('comments_count' => $_POST['comments_count'], 'symbols_count' => $_POST['symbols_count']);
                 $this->load->module('admin/widgets_manager')->update_config($widget_data['id'], $data);
                 showMessage(lang("Settings have been saved", 'comments'));
                 if ($_POST['action'] == 'tomain') {
                     pjax('/admin/widgets_manager/index');
                 }
             }
             break;
         case 'install_defaults':
             $this->load->module('admin/widgets_manager')->update_config($widget_data['id'], $this->defaults);
             break;
     }
 }
Example #19
0
 function translate($id, $lang)
 {
     $cat = $this->cms_admin->get_category($id);
     ($hook = get_hook('admin_on_translate_cat')) ? eval($hook) : NULL;
     if (count($_POST) > 0) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('name', lang("Title", "admin"), 'trim|required|min_length[1]|max_length[160]');
         $this->form_validation->set_rules('image', lang("Image", "admin"), 'max_length[250]');
         $this->form_validation->set_rules('description', lang("Description ", "admin"), 'trim');
         $this->form_validation->set_rules('keywords', lang("Keywords", "admin"), 'trim');
         $this->form_validation->set_rules('short_desc', lang("Short description", "admin"), 'trim');
         $this->form_validation->set_rules('title', lang("Meta title", "admin"), 'trim|max_length[250]');
         ($hook = get_hook('admin_set_cat_translate_rules')) ? eval($hook) : NULL;
         if ($this->form_validation->run($this) == FALSE) {
             showMessage(validation_errors(), '' . 'r');
         } else {
             $data = array();
             $data['alias'] = $id;
             $data['lang'] = $lang;
             $data['name'] = $this->input->post('name');
             $data['image'] = $_POST['image'];
             $data['description'] = $_POST['description'];
             $data['keywords'] = $_POST['keywords'];
             $data['short_desc'] = $_POST['short_desc'];
             $data['title'] = $_POST['title'];
             $this->db->where('alias', $id);
             $this->db->where('lang', $lang);
             $query = $this->db->get('category_translate');
             if ($query->num_rows() == 0) {
                 $this->lib_admin->log(lang("Translated the category", "admin") . " " . '<a href="' . $BASE_URL . '/admin/categories/edit/' . $cat['id'] . '"> ' . $cat['name'] . '</a>');
                 ($hook = get_hook('admin_insert_cat_translation')) ? eval($hook) : NULL;
                 $this->db->insert('category_translate', $data);
             } else {
                 $this->lib_admin->log(lang("Changed the category translation", "admin") . " " . '<a href="' . $BASE_URL . '/admin/categories/edit/' . $cat['id'] . '"> ' . $cat['name'] . '</a>');
                 ($hook = get_hook('admin_update_cat_translation')) ? eval($hook) : NULL;
                 $this->db->where('alias', $id);
                 $this->db->where('lang', $lang);
                 $this->db->update('category_translate', $data);
             }
             $this->cache->delete_all();
             showMessage(lang("Category translation updated", "admin"));
             $active = $_POST['action'];
             if ($active == 'close') {
                 pjax('/admin/categories/translate/' . $id . '/' . $lang);
             } else {
                 pjax('/admin/categories/edit/' . $id);
             }
         }
         exit;
     }
     if ($cat !== FALSE) {
         // Get translated category
         $this->db->where('alias', $id);
         $this->db->where('lang', $lang);
         $query = $this->db->get('category_translate');
         // Get langs
         $langs = $this->cms_base->get_langs();
         $this->template->assign('langs', $langs);
         if ($query->num_rows() > 0) {
             $this->template->add_array(array('cat' => $query->row_array()));
         }
         $this->template->add_array(array('orig_cat' => $cat, 'lang' => $lang));
         ($hook = get_hook('admin_show_cat_translate')) ? eval($hook) : NULL;
         $this->template->show('cat_translate_edit', FALSE);
     } else {
         return FALSE;
     }
 }
 public function update_settings()
 {
     $data = array('max_comment_length' => (int) $this->input->post('max_comment_length'), 'period' => (int) $this->input->post('period'), 'can_comment' => (int) $this->input->post('can_comment'), 'use_captcha' => (bool) $this->input->post('use_captcha'), 'use_moderation' => (bool) $this->input->post('use_moderation'));
     $this->comments->save_settings($data);
     $this->lib_admin->log(lang("Comments settings was edited", "comments"));
     showMessage(lang('Changes saved', 'comments'));
     pjax('/admin/components/cp/comments');
 }
Example #21
0
 function _create()
 {
     if (!$this->ajaxRequest) {
         $this->display_tpl('create_group');
     }
     //cp_check_perm('roles_create');
     if ($_POST) {
         $this->form_validation->set_rules('name', lang('amt_identif'), 'required|trim|max_length[150]|min_length[2]|alpha_dash');
         $this->form_validation->set_rules('alt_name', lang('amt_tname'), 'required|trim|max_length[150]|min_length[2]');
         $this->form_validation->set_rules('desc', lang('amt_description'), 'trim|max_length[300]|min_length[2]');
         if ($this->form_validation->run($this) == FALSE) {
             showMessage(validation_errors(), false, 'r');
         } else {
             $data = array('name' => $this->input->post('name'), 'alt_name' => $this->input->post('alt_name'), 'desc' => $this->lib_admin->db_post('desc'));
             ($hook = get_hook('users_create_role')) ? eval($hook) : NULL;
             $this->db->insert('roles', $data);
             $this->lib_admin->log(lang('amt_created_group') . $data['name']);
             showMessage(lang('amt_group_created'));
             $action = $_POST['action'];
             $user_info = $this->db->get_where('roles', array('name' => $data['name']));
             $row = $user_info->row();
             if ($action == 'close') {
                 pjax('/admin/components/cp/user_manager/edit/' . $row->id);
             } else {
                 pjax('/admin/components/init_window/user_manager#group');
             }
         }
     }
 }
 /**
  * Edit Banner by Id Banner
  * @access public
  * @param int $id
  * @param string $locale
  * @author L.Andriy <*****@*****.**>
  * @copyright (c) 2013, ImageCMS
  */
 public function edit($id, $locale = null)
 {
     /** Locale value is necessary */
     $locale != null or $locale = $this->def_locale;
     if ($_POST) {
         $this->load->library('Form_validation');
         $this->form_validation->set_rules('name', lang('Banner name', 'banners'), 'required|xss_clean|max_length[45]');
         $this->form_validation->set_rules('photo', lang('Photo', 'banners'), 'required|xss_clean');
         if ($this->form_validation->run($this) != FALSE) {
             /** Set Update data */
             $data = array('name' => $_POST['name'], 'active' => (int) $this->input->post('active'), 'description' => $this->input->post('description'), 'active_to' => $this->input->post('active_to_permanent') == 'on' ? -1 : (int) strtotime($this->input->post('active_to')), 'where_show' => count($_POST['data']) ? serialize(array_unique($this->input->post('data'))) : serialize(array()), 'photo' => $this->input->post('photo'), 'url' => $this->input->post('url'), 'locale' => $locale, 'group' => serialize($this->input->post('group')), 'id' => (int) $id);
             /** Update banner from data-array */
             $this->banner_model->edit_banner($data);
             /** Show successful message and redirect */
             $this->lib_admin->log(lang("Banner was edited", "banners") . '. Id: ' . $id);
             showMessage(lang('Data is saved', 'banners'));
             if ($this->input->post('action') == 'tomain') {
                 pjax('/admin/components/init_window/banners');
             }
         } else {
             /** Show validation error message */
             showMessage(validation_errors(), false, 'r');
         }
     } else {
         $banner = $this->banner_model->get_one_banner($id, $locale);
         $groups = $this->banner_model->getGroups();
         if (!isset($banner['id']) or empty($banner)) {
             $banner['id'] = $id;
         }
         /** Show Banner edit template */
         CMSFactory\assetManager::create()->registerScript('main', TRUE)->registerStyle('style', TRUE)->setData(array('is_shop' => $this->is_shop, 'banner' => $banner, 'locale' => $locale, 'languages' => $this->db->get('languages')->result_array(), 'groups' => $groups))->renderAdmin('edit');
     }
 }
 public function delete()
 {
     //cp_check_perm('widget_delete');
     $name = $this->input->post('ids');
     $this->db->where_in('name', $name);
     $this->db->delete('widgets');
     $this->db->where('s_name', 'main');
     $this->db->select('site_template');
     $query = $this->db->get('settings')->row_array();
     foreach ($name as $n) {
         if (file_exists(PUBPATH . '/templates/' . $query['site_template'] . '/widgets/' . $n . '.tpl')) {
             @unlink(PUBPATH . '/templates/' . $query['site_template'] . '/widgets/' . $n . '.tpl');
         }
         $this->lib_admin->log(lang("Deleted a widget", "admin") . " " . $n);
     }
     showMessage(lang("Widget successfully deleted", "admin"));
     $this->cache->delete_all();
     pjax('/admin/widgets_manager/index');
 }
Example #24
0
 /**
  * Edit discount 
  * @paran (int) $id
  * @paran (string) $locale
  * @return html  
  */
 public function edit($id, $locale = null)
 {
     if (null === $locale) {
         $locale = \MY_Controller::getCurrentLocale();
     }
     if ($this->input->post()) {
         $postArray = $this->input->post();
         $typeDiscount = $postArray['type_discount'];
         $discauntManager = new \mod_discount\classes\DiscountManager();
         $discauntManager->validation($postArray, $id);
         if (count($discauntManager->error) == 0) {
             // If empty field with discount key, then generate key
             if ($postArray['key'] == null) {
                 $postArray['key'] = $this->generateDiscountKey();
             }
             //Prepare data for insert in table mod_shop_discounts
             $data = array('name' => $postArray['name'], 'key' => $postArray['key'], 'max_apply' => $postArray['max_apply'], 'type_value' => $postArray['type_value'], 'value' => $postArray['value'], 'type_discount' => $typeDiscount, 'date_begin' => strtotime($postArray['date_begin']), 'date_end' => strtotime($postArray['date_end']), 'active' => '1');
             //Prepare data for inserting in the table of selected discount type
             $typeDiscountData = $postArray[$typeDiscount];
             // Check range for cumulative discount
             if ($typeDiscount == "comulativ" and $this->discount_model_admin->checkRangeForCumulativeDiscount($postArray[$typeDiscount], $id)) {
                 showMessage(lang('Has been already created with the cumulative discount value', 'mod_discount'), '', 'r');
                 return;
             }
             // Insert data
             if ($this->discount_model_admin->updateDiscountById($id, $data, $typeDiscountData, $locale)) {
                 showMessage(lang('Changes saved', 'mod_discount'));
             }
             //Return to list of discounts, if user clicked 'save and exit'
             if ($postArray['action'] == 'tomain') {
                 pjax('/admin/components/init_window/mod_discount/index' . $_SESSION['QueryDiscountList']);
             } else {
                 pjax('/admin/components/init_window/mod_discount/edit/' . $id);
             }
         } else {
             showMessage(implode('<br/> ', $discauntManager->error), '', 'r');
         }
     } else {
         //Get list of user roles and info about current discount
         $userGroups = $this->discount_model_admin->getUserGroups(MY_Controller::getCurrentLocale());
         $discountData = $this->discount_model_admin->getDiscountAllDataById($id, $locale);
         //if can't get info about discount from database then 404 error
         if ($discountData == false) {
             $this->error404(lang('Discount not found', 'mod_discount'));
         }
         //If discount type user then get user name and email
         if ($discountData['type_discount'] == 'user') {
             $discountData['user']['userInfo'] = $this->discount_model_admin->getUserNameAndEmailById($discountData['user']['user_id']);
         }
         //If discount type product then get product name
         if ($discountData['type_discount'] == 'product') {
             $discountData['product']['productInfo'] = $this->discount_model_admin->getProductById($discountData['product']['product_id']);
         }
         //Prepare date for rendering
         $data = array('discount' => $discountData, 'userGroups' => $userGroups, 'CS' => $this->discount_model_admin->getMainCurrencySymbol(), 'filterQuery' => $_SESSION['QueryDiscountList'], 'categories' => ShopCore::app()->SCategoryTree->getTree(), 'languages' => $this->db->get('languages')->result_array(), 'locale' => $locale);
         //Render template and set data
         \CMSFactory\assetManager::create()->setData($data)->renderAdmin('edit');
     }
 }
Example #25
0
 function create()
 {
     $options->list_id = $this->input->post('list');
     $options->subject = $this->input->post('subject');
     $options->from_email = $this->input->post('from_email');
     $options->from_name = $this->input->post('from_name');
     $options->auto_footer = FALSE;
     $options->auto_tweet = FALSE;
     $options->auto_fb_post = '';
     $content->html = $this->input->post('text');
     $content->text = $this->input->post('text');
     try {
         $this->mailChimp->campaigns->create('regular', $options, $content, $segment_opts, $type_opts);
         showMessage(lang('Campain create successful', 'mail_chimp'));
         pjax('/admin/components/init_window/mail_chimp');
     } catch (Exception $exc) {
         showMessage($exc->getMessage(), FALSE, 'r');
     }
 }
Example #26
0
 function deinstall()
 {
     //cp_check_perm('module_deinstall');
     $modules = $_POST['ids'];
     foreach ($modules as $module) {
         $module = strtolower($module);
         ($hook = get_hook('admin_deinstall_module')) ? eval($hook) : NULL;
         if (file_exists(APPPATH . 'modules/' . $module . '/' . $module . '.php') and $this->is_installed($module) == 1) {
             $this->load->module($module);
             if (method_exists($module, '_deinstall') === TRUE) {
                 $this->{$module}->_deinstall();
             }
             $this->db->limit(1);
             $this->db->delete('components', array('name' => $module));
             $this->lib_admin->log(lang("Deleted a module", "admin") . " " . $module);
             showMessage(lang("The module successfully uninstall", "admin"));
             pjax('/admin/components/modules_table');
         } else {
             showMessage(lang("Module deletion error", "admin"), false, 'r');
             pjax('/admin/components/modules_table');
         }
         // Update hooks
         $this->load->library('cms_hooks');
         $this->cms_hooks->build_hooks();
     }
 }
Example #27
0
 public function edit($name, $locale = null)
 {
     if ($locale == null) {
         $locale = MY_Controller::getCurrentLocale();
     }
     if ($name != '') {
         $model = $this->sample_mail_model->getMailArray($name, $locale);
         if (empty($model)) {
             $model = $this->sample_mail_model->getMailArray($name, MY_Controller::getCurrentLocale());
         }
     }
     $settings = unserialize($model['settings']);
     if (empty($_POST)) {
         $this->render('edit', array('model' => $model, 'settings' => $settings, 'languages' => $this->cms_admin->get_langs(), 'locale' => $locale));
     } else {
         $this->form_validation->set_rules('mail_name', lang('Template name'), 'required|xss_clean');
         $this->form_validation->set_rules('mail_theme', lang('Tempalate theme'), 'xss_clean');
         $this->form_validation->set_rules('sender_name', lang('From'), 'xss_clean');
         $this->form_validation->set_rules('from_email', lang('From (email)'), 'xss_clean|valid_email');
         $this->form_validation->set_rules('mail_text', lang('Message template'), 'xss_clean');
         if ($this->form_validation->run($this) == FALSE) {
             if ($this->form_validation->run($this) == FALSE) {
                 showMessage(validation_errors());
             } else {
                 $data['name'] = $this->input->post('mail_name');
                 $data['text'] = $this->input->post('mail_text');
                 $data['settings']['theme'] = $this->input->post('mail_theme');
                 $data['settings']['from'] = $this->input->post('sender_name');
                 $data['settings']['from_mail'] = $this->input->post('from_email');
                 $data['settings']['variables'] = $this->input->post('mail_variables');
                 $data['settings']['mail_type'] = $this->input->post('mail_type');
                 $data['locale'] = $locale;
                 $data['description'] = $this->input->post('mail_desc');
                 $this->sample_mail_model->fromArray($data);
                 showMessage(lang('Template successfully edited'));
                 if ($this->input->post('action') == 'tomain') {
                     pjax('/admin/components/cp/sample_mail/index');
                 }
             }
         }
     }
 }
Example #28
0
 private function send_to_email()
 {
     $this->load->library('email');
     $this->load->library('form_validation');
     $this->load->helper('file');
     $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
     if ($this->form_validation->run($this) == FALSE) {
         showMessage(validation_errors(), false, 'r');
     } else {
         $user = $this->get_admin_info();
         $fileName = \libraries\Backup::create()->createBackup($_POST['file_type'], "sql");
         $this->email->to($_POST['email']);
         $this->email->from($user['email']);
         $this->email->subject(lang("Backup copying", "admin") . date('d-m-Y H:i:s'));
         $this->email->message(' ');
         $this->email->attach($fileName);
         $this->email->send();
         @unlink($fileName);
         $this->done();
     }
     pjax('/admin/backup');
 }
Example #29
0
 function move_pages($action)
 {
     //cp_check_perm('page_edit');
     $ids = $_POST['pages'];
     $this->db->select('category');
     $page = $this->db->get_where('content', array('id' => substr($_POST['pages'][0], 5)))->row_array();
     if ((int) $_POST['new_cat'] > 0) {
         $category = $this->lib_category->get_category($_POST['new_cat']);
     } else {
         $category['id'] = 0;
         $category['path_url'] = '';
     }
     if (count($ids) > 0) {
         foreach ($ids as $k => $v) {
             $page_id = substr($v, 5);
             $data = array('category' => $category['id'], 'cat_url' => $category['path_url']);
             switch ($action) {
                 case 'move':
                     ($hook = get_hook('admin_pages_move')) ? eval($hook) : NULL;
                     $this->db->where('id', $page_id);
                     $this->db->update('content', $data);
                     $this->db->where('lang_alias', $page_id);
                     $this->db->update('content', $data);
                     break;
                 case 'copy':
                     $page = $this->db->get_where('content', array('id' => $page_id))->row_array();
                     $page['category'] = $data['category'];
                     $page['cat_url'] = $data['cat_url'];
                     $page['lang_alias'] = 0;
                     $page['comments_count'] = 0;
                     $this->db->like('url', $page['url']);
                     $new_url = $this->db->get('content')->num_rows();
                     $page['url'] .= $new_url + 1;
                     unset($page['id']);
                     ($hook = get_hook('admin_pages_copy')) ? eval($hook) : NULL;
                     $this->db->insert('content', $page);
                     $new_id = $this->db->insert_id();
                     $this->_copy_content_fields($page_id, $new_id);
                     // Copy page to other languages
                     $pages = $this->db->get_where('content', array('lang_alias' => $page_id))->result_array();
                     foreach ($pages as $page) {
                         unset($page['id']);
                         $page['category'] = $data['category'];
                         $page['cat_url'] = $data['cat_url'];
                         $page['comments_count'] = 0;
                         $page['lang_alias'] = $new_id;
                         $page['url'] = $page['url'] . time();
                         $this->db->insert('content', $page);
                         $this->_copy_content_fields($page_id, $this->db->insert_id());
                     }
                     break;
             }
         }
         if ($action == 'copy') {
             showMessage(lang('Page successfuly copied', 'admin'));
         } else {
             if ($action == 'move') {
                 showMessage(lang("Successfull moving", "admin"));
             }
         }
         pjax($_SERVER["HTTP_REFERER"]);
     } else {
         showMessage(lang("The operation error", "admin"));
     }
 }