예제 #1
0
파일: admin.php 프로젝트: blekedeg/lbhpers
 /**
  * Constructor method
  */
 public function __construct()
 {
     parent::__construct();
     // Load the required classes
     $this->load->library('form_validation');
     $this->load->model('navigation_m');
     $this->load->model('pages/page_m');
     $this->lang->load('navigation');
     $this->template->append_js('module::navigation.js')->append_css('module::navigation.css');
     // Get Navigation Groups
     $this->template->groups = $this->navigation_m->get_groups();
     $this->template->groups_select = array_for_select($this->template->groups, 'id', 'title');
     $all_modules = $this->module_m->get_all(array('is_frontend' => true));
     //only allow modules that user has permissions for
     foreach ($all_modules as $module) {
         if (in_array($module['slug'], $this->permissions) or $this->current_user->group == 'admin') {
             $modules[] = $module;
         }
     }
     $this->template->modules_select = array_for_select($modules, 'slug', 'name');
     // Get Pages and create pages tree
     $tree = array();
     if ($pages = $this->page_m->get_all()) {
         foreach ($pages as $page) {
             $tree[$page->parent_id][] = $page;
         }
     }
     unset($pages);
     $this->template->pages_select = $tree;
     // Set the validation rules for the navigation items
     $this->form_validation->set_rules($this->validation_rules);
 }
예제 #2
0
파일: admin.php 프로젝트: 8496tar/pyrocms
 /**
  * Constructor method
  * @access public
  * @return void
  */
 public function __construct()
 {
     // Call the parent's contstructor
     parent::__construct();
     // Load the required classes
     $this->load->library('form_validation');
     $this->load->model('navigation_m');
     $this->load->model('pages/pages_m');
     $this->lang->load('navigation');
     $this->template->set_partial('shortcuts', 'admin/partials/shortcuts');
     $this->template->append_metadata(js('navigation.js', 'navigation'));
     // Get Navigation Groups
     $this->data->groups = $this->navigation_m->get_groups();
     $this->data->groups_select = array_for_select($this->data->groups, 'id', 'title');
     $modules = $this->module_m->get_all(array('is_frontend' => true));
     $this->data->modules_select = array_for_select($modules, 'slug', 'name');
     // Get Pages and create pages tree
     $tree = array();
     if ($pages = $this->pages_m->get_all()) {
         foreach ($pages as $page) {
             $tree[$page->parent_id][] = $page;
         }
     }
     unset($pages);
     $this->data->pages_select = $tree;
     // Set the validation rules for the navigation items
     $this->validation_rules = array(array('field' => 'title', 'label' => lang('nav_title_label'), 'rules' => 'trim|required|max_length[40]'), array('field' => 'link_type', 'label' => lang('nav_type_label'), 'rules' => 'trim|alpha'), array('field' => 'url', 'label' => lang('nav_url_label'), 'rules' => 'trim'), array('field' => 'uri', 'label' => lang('nav_uri_label'), 'rules' => 'trim'), array('field' => 'module_name', 'label' => lang('nav_module_label'), 'rules' => 'trim|alpha_dash'), array('field' => 'page_id', 'label' => lang('nav_page_label'), 'rules' => 'trim|numeric'), array('field' => 'navigation_group_id', 'label' => lang('nav_group_label'), 'rules' => 'trim|numeric|required'), array('field' => 'target', 'label' => lang('nav_target_label'), 'rules' => 'trim|max_length[10]'));
     $this->form_validation->set_rules($this->validation_rules);
 }
 public function __construct()
 {
     parent::__construct();
     //        $this->load->model('enquiry/news_m');
     //        $this->data['trickers'] = $this->news_m->get_by(array('status' => 1),false,5);
     $this->load->model('settings/setting_m');
     $this->load->library('ion_auth');
     $metadata = $this->setting_m->get();
     $this->data['metadata'] = array_for_select($metadata, 'settings_name', 'settings_value');
 }
예제 #4
0
 public function __construct()
 {
     parent::__construct();
     $this->load->library('grocery_CRUD');
     $this->upload_path = '../assets/uploads/' . 'hotels';
     $this->wrapper = 'gc_admin_wrapper';
     $this->load->model('generic_model');
     $this->load->helper('email');
     $metadata = $this->db->get_where('settings', array('settings_status' => 1))->result();
     $this->data['metadata'] = array_for_select($metadata, 'settings_name', 'settings_value', 'site_name');
 }
예제 #5
0
 /**
  * Constructor method
  */
 public function __construct()
 {
     parent::__construct();
     // Load the required classes
     $this->load->model('user_m');
     $this->load->model('groups/group_m');
     $this->load->helper('user');
     $this->load->library('form_validation');
     $this->lang->load('user');
     $this->template->groups = $this->group_m->get_all();
     $this->template->groups_select = array_for_select($this->template->groups, 'id', 'description');
 }
예제 #6
0
 public function __construct()
 {
     parent::__construct();
     $this->load->library(array('ion_auth', 'form_validation'));
     $this->load->helper(array('language', 'pagination', 'array'));
     $this->load->model('blog_m');
     if (!$this->ion_auth->logged_in()) {
         // redirect them to the login page
         redirect(ADMIN_URL . '/login', 'refresh');
     }
     $category = $this->blog_m->getData('post_category', array('status' => 'live'))->result_array();
     $category = array_for_select($category, 'id', 'title');
     $this->template->set_layout('default', 'admin')->set_partial('header', 'admin/partials/header')->set_partial('sidebar', 'admin/partials/sidebar')->set_partial('footer', 'admin/partials/footer')->set('category', $category);
 }
예제 #7
0
파일: admin.php 프로젝트: netfreak/pyrocms
 function __construct()
 {
     parent::Admin_Controller();
     $this->load->library('user_lib');
     $this->load->model('users_m');
     $this->load->helper('user');
     $this->lang->load('user');
     $this->data->roles = $this->permissions_m->get_roles();
     $this->data->roles_select = array_for_select($this->data->roles, 'abbrev', 'title');
     // Sidebar data
     $this->data->inactive_user_count = $this->users_m->count_by('is_active', 0);
     $this->data->active_user_count = $this->users_m->count_by('is_active', 1);
     $this->template->set_partial('sidebar', 'admin/sidebar');
 }
예제 #8
0
 /**
  * Constructor method
  */
 public function __construct()
 {
     parent::__construct();
     // Load the required classes
     $this->load->model('user_m');
     $this->load->model('groups/group_m');
     $this->load->helper('user');
     $this->load->library('form_validation');
     $this->lang->load('user');
     if ($this->current_user->group != 'admin') {
         $this->template->groups = $this->group_m->where_not_in('name', 'admin')->get_all();
     } else {
         $this->template->groups = $this->group_m->get_all();
     }
     $this->template->groups_select = array_for_select($this->template->groups, 'id', 'description');
 }
예제 #9
0
파일: admin.php 프로젝트: reith2004/pyrocms
	/**
	 * Constructor method
	 * @access public
	 * @return void
	 */
	public function __construct()
	{
		// Call the parent's constructor method
		parent::Admin_Controller();

		// Load the required classes
		$this->load->model('users_m');
		$this->load->model('groups/group_m');
		$this->load->helper('user');
		$this->load->library('form_validation');
		$this->lang->load('user');

		$this->data->groups = $this->group_m->get_all();
		$this->data->groups_select = array_for_select($this->data->groups, 'id', 'description');

		$this->template->set_partial('shortcuts', 'admin/partials/shortcuts');
	}
예제 #10
0
 /**
  * Constructor method
  * @access public
  * @return void
  */
 public function __construct()
 {
     // Call the parent's constructor method
     parent::Admin_Controller();
     // Load the required classes
     $this->load->model('users_m');
     $this->load->helper('user');
     $this->load->library('form_validation');
     $this->lang->load('user');
     // Create the validation array
     $this->validation_rules = array(array('field' => 'first_name', 'label' => lang('user_first_name_label'), 'rules' => 'required|alpha_dash'), array('field' => 'last_name', 'label' => lang('user_last_name_label'), 'rules' => 'required|surname'), array('field' => 'display_name', 'label' => lang('user_display_name'), 'rules' => 'required|alphanumeric|maxlength[50]'), array('field' => 'password', 'label' => lang('user_password_label'), 'rules' => 'min_length[6]|max_length[20]'), array('field' => 'confirm_password', 'label' => lang('user_password_confirm_label'), 'rules' => 'matches[password]'), array('field' => 'email', 'label' => lang('user_email_label'), 'rules' => 'required|valid_email'), array('field' => 'username', 'label' => lang('user_username'), 'rules' => 'required|alphanumeric|maxlength[20]'), array('field' => 'group', 'label' => lang('user_group_id_label'), 'rules' => 'required'), array('field' => 'active', 'label' => lang('user_active_label'), 'rules' => ''));
     $this->data->roles = $this->permissions_m->get_roles();
     $this->data->roles_select = array_for_select($this->data->roles, 'name', 'title');
     // Sidebar data
     $this->data->inactive_user_count = $this->users_m->count_by('active', 0);
     $this->data->active_user_count = $this->users_m->count_by('active', 1);
     $this->template->set_partial('sidebar', 'admin/sidebar');
 }
예제 #11
0
 function __construct()
 {
     parent::Admin_Controller();
     $this->load->model('navigation_m');
     $this->load->module_model('pages', 'pages_m');
     $this->load->module_helper('pages', 'pages');
     $this->load->helper('array');
     // Get Navigation Groups
     $this->data->groups = $this->navigation_m->getGroups();
     $this->data->groups_select = array_for_select($this->data->groups, 'id', 'title');
     $modules = $this->modules_m->getModules(array('is_frontend' => true));
     $this->data->modules_select = array_for_select($modules, 'slug', 'name');
     // Get Pages and create pages tree
     $tree = array();
     foreach ($this->pages_m->getPages() as $page) {
         $tree[$page->parent][] = $page;
     }
     $this->data->pages_select = $tree;
 }
 public function __construct()
 {
     parent::__construct();
     $this->load->library('ion_auth');
     $this->load->language('language');
     if (!$this->ion_auth->logged_in()) {
         $this->session->set_flashdata('errorlogin', "You must log in!");
         redirect('login');
     }
     $userdata = $this->ion_auth->user($this->session->userdata('user_id'))->row();
     $this->data['uname'] = $userdata->first_name . ' ' . $userdata->last_name;
     $this->data['uid'] = $userdata->id;
     $this->data['uemail'] = $userdata->email;
     $this->data['ucompany'] = $userdata->company;
     $this->data['uphone'] = $userdata->phone;
     $this->load->model('settings/setting_m');
     $metadata = $this->setting_m->get();
     $this->data['metadata'] = array_for_select($metadata, 'settings_name', 'settings_value');
     $this->load->library('grocery_CRUD');
 }
예제 #13
0
파일: admin.php 프로젝트: netfreak/pyrocms
 function __construct()
 {
     parent::Admin_Controller();
     $this->load->model('navigation_m');
     $this->load->model('pages/pages_m');
     $this->load->helper('array');
     $this->lang->load('navigation');
     $this->template->set_partial('sidebar', 'admin/sidebar');
     $this->template->append_metadata(js('navigation.js', 'navigation'));
     // Get Navigation Groups
     $this->data->groups = $this->navigation_m->get_groups();
     $this->data->groups_select = array_for_select($this->data->groups, 'id', 'title');
     $modules = $this->modules_m->getModules(array('is_frontend' => true));
     $this->data->modules_select = array_for_select($modules, 'slug', 'name');
     // Get Pages and create pages tree
     $tree = array();
     if ($pages = $this->pages_m->get_all()) {
         foreach ($pages as $page) {
             $tree[$page->parent_id][] = $page;
         }
     }
     unset($pages);
     $this->data->pages_select = $tree;
 }
예제 #14
0
 /**
  * Create the form for editing a widget instance
  * 
  * @return void
  */
 public function edit($id = 0)
 {
     if (!($id && ($widget = $this->widgets->get_instance($id)))) {
         // @todo: set error
         return false;
     }
     $data = array();
     if ($input = $this->input->post()) {
         $title = $input['title'];
         $widget_id = $input['widget_id'];
         $widget_area_id = $input['widget_area_id'];
         $instance_id = $input['widget_instance_id'];
         unset($input['title'], $input['widget_id'], $input['widget_area_id'], $input['widget_instance_id']);
         $result = $this->widgets->edit_instance($instance_id, $title, $widget_area_id, $input);
         if ($result['status'] === 'success') {
             // Fire an event. A widget instance has been updated pass the widget instance id.
             Events::trigger('widget_instance_updated', $instance_id);
             $status = 'success';
             $message = lang('success_label');
             $area = $this->widgets->get_area($widget_area_id);
         } else {
             $status = 'error';
             $message = $result['error'];
         }
         if ($this->input->is_ajax_request()) {
             $data = array();
             $status === 'success' and $data['messages'][$status] = $message;
             $message = $this->load->view('admin/partials/notices', $data, true);
             return $this->template->build_json(array('status' => $status, 'message' => $message, 'active' => isset($area) && $area ? '#area-' . $area->slug . ' header' : false));
         }
         if ($status === 'success') {
             $this->session->set_flashdata($status, $message);
             redirect('admins/widgets');
             return;
         }
         $data['messages'][$status] = $message;
     }
     $this->db->order_by('`title`');
     $data['widget_areas'] = $this->widgets->list_areas();
     $data['widget_areas'] = array_for_select($data['widget_areas'], 'id', 'title');
     $data['widget'] = $widget;
     $data['form'] = $this->widgets->render_backend($widget->slug, isset($widget->options) ? $widget->options : array());
     $this->template->build('admin/instances/form', $data);
 }
예제 #15
0
파일: admin.php 프로젝트: netfreak/pyrocms
 function edit($id = 0)
 {
     if (empty($id)) {
         redirect('admin/pages');
     }
     // We use this controller property for a validation callback later on
     $this->page_id = $id;
     // Set data, if it exists
     if (!($page = $this->pages_m->get($id))) {
         $this->session->set_flashdata('error', $this->lang->line('pages_page_not_found_error'));
         redirect('admin/pages/create');
     }
     $this->load->library('validation');
     $this->validation->set_rules($this->rules);
     $this->validation->set_fields();
     // Auto-set data for the page if a post variable overrides it
     foreach (array_keys($this->rules) as $field) {
         if ($this->input->post($field) !== FALSE) {
             $page->{$field} = $this->validation->{$field};
         }
     }
     // Give validation a try, who knows, it just might work!
     if ($this->validation->run()) {
         // Run the update code with the POST data
         $this->pages_m->update($id, $_POST);
         // The slug has changed
         if ($this->input->post('slug') != $this->input->post('old_slug')) {
             $this->pages_m->reindex_descendants($id);
         }
         // Wipe cache for this model as the data has changed
         $this->cache->delete_all('pages_m');
         $this->session->set_flashdata('success', sprintf($this->lang->line('pages_edit_success'), $this->input->post('title')));
         redirect('admin/pages');
     }
     // If a parent id was passed, fetch the parent details
     if ($page->parent_id > 0) {
         $parent_page = $this->pages_m->get($page->parent_id);
         $parent_page->path = $this->pages_m->get_path_by_id($page->parent_id);
     }
     // Assign data for display
     $this->data->page =& $page;
     $this->data->parent_page =& $parent_page;
     $page_layouts = $this->page_layouts_m->get_all();
     $this->data->page_layouts = array_for_select($page_layouts, 'id', 'title');
     // Get "roles" (like access levels)
     //$this->data->roles = $this->permissions_m->get_roles();
     //ksort($this->data->roles);
     //$this->data->roles_select = array_for_select($this->data->roles, 'id', 'title');
     // Load WYSIWYG editor
     $this->template->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE))->append_metadata(js('codemirror/codemirror.js'))->append_metadata(js('form.js', 'pages'))->build('admin/form', $this->data);
 }
예제 #16
0
파일: admin.php 프로젝트: bwoodall/pyrocms
 /**
  * Edit permission rules
  *
  * @access public
  * @param int $id The ID of the rule to edit
  * @return void
  */
 public function edit($id = 0)
 {
     // Got ID?
     if (empty($id)) {
         redirect('admin/permissions');
     }
     // Get the permissions
     $permission_rule = $this->permissions_m->get_rule($id);
     if (!$permission_rule) {
         $this->session->set_flashdata('error', $this->lang->line('perm_rule_not_exist_error'));
         redirect('admin/permissions/create');
     }
     // Set some extra rules based on the role type
     if ($this->input->post('role_type') == 'user') {
         $this->validation_rules[4]['rules'] .= '|required';
     } else {
         $this->validation_rules[5]['rules'] .= '|required';
     }
     // Set the validation rules
     $this->form_validation->set_rules($this->validation_rules);
     if ($this->form_validation->run()) {
         $this->permissions_m->update_rule($id, $_POST);
         $this->session->set_flashdata('success', $this->lang->line('perm_rule_save_success'));
         redirect('admin/permissions');
     }
     // Loop through each validation rule
     foreach ($this->validation_rules as $rule) {
         $permission_rule->{$rule['field']} = set_value($rule['field']);
     }
     // Get controllers and methods arrays for selected values to populate ajax boxes
     $this->data->permission_rule =& $permission_rule;
     $this->data->controllers_select = array('*' => $this->lang->line('perm_controller_select_default')) + array_for_select($this->modules_m->get_module_controllers($this->data->permission_rule->module));
     $this->data->methods_select = array('*' => $this->lang->line('perm_method_select_default')) + array_for_select($this->modules_m->get_module_controller_methods($this->data->permission_rule->module, $this->data->permission_rule->controller));
     $this->template->build('admin/rules/form', $this->data);
 }
예제 #17
0
파일: admin.php 프로젝트: namdum/pyrocms
 /**
  * Sets up common form inputs.
  *
  * This is used in both the creation and editing forms.
  */
 private function _form_data()
 {
     $page_layouts = $this->page_layouts_m->get_all();
     $this->template->page_layouts = array_for_select($page_layouts, 'id', 'title');
     // Load navigation list
     $this->load->model('navigation/navigation_m');
     $navigation_groups = $this->navigation_m->get_groups();
     $this->template->navigation_groups = array_for_select($navigation_groups, 'id', 'title');
     $this->load->model('groups/group_m');
     $groups = $this->group_m->get_all();
     foreach ($groups as $group) {
         $group->name !== 'admin' && ($group_options[$group->id] = $group->name);
     }
     $this->template->group_options = $group_options;
     $this->template->append_js('jquery/jquery.tagsinput.js')->append_js('jquery/jquery.cooki.js')->append_js('module::form.js')->append_css('jquery/jquery.tagsinput.css');
 }
예제 #18
0
파일: admin.php 프로젝트: nhockiki/pyrocms
 function edit($id = 0)
 {
     if (empty($id)) {
         redirect('admin/permissions/index');
     }
     $this->data->permission_rule = $this->permissions_m->getRule($id);
     if (!$this->data->permission_rule) {
         $this->session->set_flashdata('error', $this->lang->line('perm_rule_not_exist_error'));
         redirect('admin/permissions/create');
     }
     $this->load->library('validation');
     $rules['module'] = 'trim|required';
     $rules['controller'] = 'trim|required';
     $rules['method'] = 'trim|required';
     $rules['permission_role_id'] = 'trim|numeric|required';
     $rules['user_id'] = 'trim';
     //|required';
     $this->validation->set_rules($rules);
     $fields['permission_role_id'] = 'Role';
     $this->validation->set_fields($fields);
     if ($this->validation->run()) {
         $this->permissions_m->updateRule($id, $_POST);
         $this->session->set_flashdata('success', $this->lang->line('perm_rule_save_success'));
         redirect('admin/permissions/index');
     }
     foreach (array_keys($rules) as $field) {
         if (isset($_POST[$field])) {
             $this->data->permission_rule->{$field} = $this->validation->{$field};
         }
     }
     // Get controllers and methods arrays for selected values to populate ajax boxes
     $this->data->controllers_select = array('*' => $this->lang->line('perm_controller_select_default')) + array_for_select($this->modules_m->getControllers($this->data->permission_rule->module));
     $this->data->methods_select = array('*' => $this->lang->line('perm_method_select_default')) + array_for_select($this->modules_m->getMethods($this->data->permission_rule->module, $this->data->permission_rule->controller));
     $this->layout->create('admin/rules/form', $this->data);
 }
예제 #19
0
 private function _form_data()
 {
     $page_layouts = $this->page_layouts_m->get_all();
     $this->template->page_layouts = array_for_select($page_layouts, 'id', 'title');
     // Load navigation list
     $this->load->model('navigation/navigation_m');
     $navigation_groups = $this->navigation_m->get_groups();
     $this->template->navigation_groups = array_for_select($navigation_groups, 'id', 'title');
     $this->load->model('groups/group_m');
     $groups = $this->group_m->get_all();
     foreach ($groups as $group) {
         $group->name !== 'admin' && ($group_options[$group->id] = $group->name);
     }
     $this->template->group_options = $group_options;
 }
예제 #20
0
파일: ajax.php 프로젝트: Tapha/pyrocms
 /**
  * Create the form for editing a widget instance
  * @access public
  * @return void
  */
 public function edit_widget_instance_form()
 {
     $instance_id = $this->input->post('instance_id');
     if (!$instance_id) {
         exit;
     }
     $widget = $this->widgets->get_instance($instance_id);
     $widget_area = $this->widgets->get_area($widget->widget_area_slug);
     $widget_areas = $this->widgets->list_areas();
     $widget_areas = array_for_select($widget_areas, 'id', 'title');
     $this->load->view('admin/ajax/instance_form', array('widget' => $widget, 'widget_area' => $widget_area, 'widget_areas' => $widget_areas));
 }
 public function index()
 {
     $this->load->model('settings/settingsmodel');
     $metadata = $this->db->get('settings')->result();
     $metadata = array_for_select($metadata, 'settings_name', 'settings_value');
     //var_dump($metadata);die;
     $this->form_validation->set_rules($this->validation_rules);
     if ($this->form_validation->run() == TRUE) {
         $emails = $this->newsletter_m->get_by(array('status' => 1));
         $emails = array_for_select($emails, 'email');
         $from = $metadata['newsletter_email'];
         $subject = $this->input->post('subject');
         $body = $this->input->post('body');
         //var_dump($this->data['metadata']);die;
         //Create the Transport. I created it using the gmail configuration
         //            $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
         //                    ->setUsername('*****@*****.**')
         //                    ->setPassword('********');
         // You could alternatively use a different transport such as Sendmail or Mail:
         //Sendmail:
         $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
         //Mail
         //        $transport = Swift_MailTransport::newInstance();
         $mailer = Swift_Mailer::newInstance($transport);
         //start of decorator plugin
         $users = array(array('email' => '*****@*****.**', 'username' => 'user_amrit', 'password' => 'pwd_amrit'), array('email' => '*****@*****.**', 'username' => 'santosh Thapa', 'password' => 'pws_santosh_thapa'), array('email' => '*****@*****.**', 'username' => 'Susang Thapa', 'password' => 'pwd_susang_thapa'));
         /*
                     $replacements = array();
                     foreach ($users as $user) {
         
                         $replacements[$user['email']] = array(
                             '{username}' => $user['username'],
                             '{password}' => $user['password']
                         );
                     }
         
                     $decorator = new Swift_Plugins_DecoratorPlugin($replacements);
                     $mailer->registerPlugin($decorator);
         */
         //eof decorator plugin
         //Create the message
         $message = Swift_Message::newInstance();
         //Give the message a subject
         $message->setSubject($subject)->setFrom($from)->setSubject($subject)->setBody($body);
         //        $message->setSubject('send mail test')
         //                ->setFrom($metadata['newsletter_email'])
         //                ->setTo(' amritms@gmail.com')
         //                ->setBody('Test 5 using php Here is the message sent with swiftmailer ', 'text/html');
         //                ->addPart('<q>just php mail Here is the message sent with swiftmailer</q>', 'text/html');
         //Create the Mailer using your created Transport
         //        foreach ($users as $user) {
         //            $message->addTo($user['email']);
         //        }
         //        $result = $mailer->send($message);
         // Use AntiFlood to re-connect after 100 emails
         //$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100));
         // And specify a time in seconds to pause for (30 secs)
         $mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100, 30));
         //
         foreach ($users as $user) {
             $message->addTo($user['email']);
         }
         //Send the message
         //        foreach ($emails as $e) {
         //            $to->setAddresses($e);
         //            $result = $mailer->send($message);
         //        }
         //        foreach ($users as $e) {
         //            $to->setAddresses($e['email']);
         //            $result = $mailer->send($message);
         //        }
         //$to = $message->getHeaders()->get('To');var_dump($to);die;
         $result = $mailer->send($message, $failures);
         if ($result) {
             $this->session->set_flashdata('success', "Email sent successfully");
         } else {
             $this->session->set_flashdata('error', "Email failed to send");
         }
         //    echo 'failures:';
         //            var_dump($failures);
         redirect(base_url('newsletter/send_newsletter'), 'refresh');
     } else {
         $data = new stdClass();
         // Go through all the known fields and get the post values
         foreach ($this->validation_rules as $key => $field) {
             $data->{$field}['field'] = set_value($field['field']);
         }
     }
     $this->data['method'] = 'Send Newsletter';
     $this->data['main_content'] = 'newsletter_form';
     $this->data['editData'] = $data;
     $this->load->view('admin_wrapper', $this->data);
 }
/**
 * @param $email
 */
function email_simple_send($email)
{
    $CI =& get_instance();
    $CI->load->model('settings/setting_m');
    $metadata = $CI->setting_m->get();
    $data['metadata'] = array_for_select($metadata, 'settings_name', 'settings_value');
    require_once APPPATH . 'libraries/swift_mailer/swift_required.php';
    // Create the SMTP configuration
    //$transport = Swift_SmtpTransport::newInstance(  );
    //	$transport = Swift_SmtpTransport::newInstance( "smtp.audero.it", 25 );
    //	$transport->setUsername( "Username" );
    //	$transport->setPassword( "Password" );
    //Create the Transport
    $transport = Swift_MailTransport::newInstance('relay-hosting.secureserver.net', 25);
    /*
    You could alternatively use a different transport such as Sendmail or Mail:
    
    //Sendmail
    $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
    
    //Mail
    $transport = Swift_MailTransport::newInstance();
    */
    // Create the message
    $message = Swift_Message::newInstance();
    /*
     * mandatory field
     * in key-value (email-name) pair array
     */
    if (isset($email['to']) && !empty($email['to'])) {
        $message->setTo($email['to']);
    }
    //    $message->setTo(array(
    //                        "*****@*****.**" => "Aurelio De Rosa",
    //                        "*****@*****.**" => "Audero"
    //                    ));
    /*
     * optional field
     * in key-value (email-name) pair array
     */
    if (isset($email['cc']) && !empty($email['cc'])) {
        $message->setCc($email['cc']);
    }
    /*
     * optional field
     * in key-value (email-name) pair array
     */
    if (isset($email['bcc']) && !empty($email['bcc'])) {
        $message->setBcc($email['bcc']);
    }
    /*
     * text for subject
     * set to default if not set
     */
    if (isset($email['subject']) && !empty($email['subject'])) {
        $message->setSubject($email['subject']);
    } else {
        $message->setSubject('test subject');
    }
    /*
     * text for body
     * set to default if not set
     */
    if (isset($email['body']) && !empty($email['body'])) {
        $message->setBody($email['body'], 'text/html');
    } else {
        $message->setBody('test body', 'text/html');
    }
    /*
     * mandatory field
     * in key-value pair array
     * eg: $message->setFrom("*****@*****.**", "Your bank");
     */
    if (isset($email['from']) && !empty($email['from'])) {
        $message->setFrom($email['from']);
    } else {
        //defaults to site's admin email
        $message->setFrom($data['metadata']['site_email_info']);
    }
    //    $message->setFrom("*****@*****.**", "Your bank");
    /*
     * optional field
     * path to attachment (on server)
     */
    if (isset($email['attachment']) && !empty($email['attachment'])) {
        $message->attach(Swift_Attachment::fromPath($email['attachment']));
    }
    // Send the email
    $mailer = Swift_Mailer::newInstance($transport);
    if ($mailer->send($message, $failedRecipients)) {
        return true;
    } else {
        // Show failed recipients
        return $failedRecipients;
    }
}
예제 #23
0
 /**
  * Edit an existing page
  * @access public
  * @param int $id The ID of the page to edit
  * @return void
  */
 public function edit($id = 0)
 {
     $id or redirect('admin/pages');
     // Set the page ID and get the current page
     $this->page_id = $id;
     $page = $this->versioning->get($id);
     $revisions = $this->versioning->get_revisions($id);
     // Got page?
     if (!$page) {
         $this->session->set_flashdata('error', lang('pages_page_not_found_error'));
         redirect('admin/pages/create');
     }
     // Validate it
     if ($this->form_validation->run()) {
         // Set the data for the revision
         $revision_data = array('author_id' => $this->user->id, 'owner_id' => $id, 'body' => $_POST['body']);
         // Did the user wanted to restore a specific revision?
         if ($_POST['use_revision_id'] == $page->revision_id) {
             $_POST['revision_id'] = $this->versioning->create_revision($revision_data);
         } else {
             $_POST['revision_id'] = $_POST['use_revision_id'];
         }
         // Run the update code with the POST data
         $this->pages_m->update($id, $_POST);
         // The slug has changed
         if ($this->input->post('slug') != $this->input->post('old_slug')) {
             $this->pages_m->reindex_descendants($id);
         }
         // Wipe cache for this model as the data has changed
         $this->cache->delete_all('pages_m');
         // Set the flashdata message and redirect the user
         $this->session->set_flashdata('success', sprintf(lang('pages_edit_success'), $this->input->post('title')));
         // Redirect back to the form or main page
         $this->input->post('btnAction') == 'save_exit' ? redirect('admin/pages') : redirect('admin/pages/edit/' . $id);
     }
     // Loop through each validation rule
     foreach ($this->validation_rules as $rule) {
         if ($this->input->post($rule['field']) !== FALSE) {
             $page->{$rule['field']} = set_value($rule['field']);
         }
     }
     // If a parent id was passed, fetch the parent details
     if ($page->parent_id > 0) {
         $parent_page = $this->pages_m->get($page->parent_id);
         $parent_page->path = $this->pages_m->get_path_by_id($page->parent_id);
     }
     // Assign data for display
     $this->data->page =& $page;
     $this->data->revisions =& $revisions;
     $this->data->parent_page =& $parent_page;
     $page_layouts = $this->page_layouts_m->get_all();
     $this->data->page_layouts = array_for_select($page_layouts, 'id', 'title');
     // Load WYSIWYG editor
     $this->template->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE))->title($this->module_details['name'], sprintf(lang('pages.edit_title'), $page->title))->append_metadata(js('codemirror/codemirror.js'))->append_metadata(js('form.js', 'pages'))->build('admin/form', $this->data);
 }
예제 #24
0
파일: admin.php 프로젝트: Tapha/pyrocms
 /**
  * Edit an existing page
  * @access public
  * @param int $id The ID of the page to edit
  * @return void
  */
 public function edit($id = 0)
 {
     // Redirect if no ID has been specified
     if (empty($id)) {
         redirect('admin/pages');
     }
     // Set the page ID and get the current page
     $this->page_id = $id;
     $page = $this->pages_m->get($id);
     // Got page?
     if (!$page) {
         $this->session->set_flashdata('error', lang('pages_page_not_found_error'));
         redirect('admin/pages/create');
     }
     // Loop through each validation rule
     foreach ($this->validation_rules as $rule) {
         if ($this->input->post($rule['field']) !== FALSE) {
             $page->{$rule['field']} = set_value($rule['field']);
         }
     }
     // Validate it
     if ($this->form_validation->run()) {
         // Run the update code with the POST data
         $this->pages_m->update($id, $_POST);
         // The slug has changed
         if ($this->input->post('slug') != $this->input->post('old_slug')) {
             $this->pages_m->reindex_descendants($id);
         }
         // Wipe cache for this model as the data has changed
         $this->cache->delete_all('pages_m');
         // Set the flashdata message and redirect the user
         $this->session->set_flashdata('success', sprintf(lang('pages_edit_success'), $this->input->post('title')));
         redirect('admin/pages');
     }
     // If a parent id was passed, fetch the parent details
     if ($page->parent_id > 0) {
         $parent_page = $this->pages_m->get($page->parent_id);
         $parent_page->path = $this->pages_m->get_path_by_id($page->parent_id);
     }
     // Assign data for display
     $this->data->page =& $page;
     $this->data->parent_page =& $parent_page;
     $page_layouts = $this->page_layouts_m->get_all();
     $this->data->page_layouts = array_for_select($page_layouts, 'id', 'title');
     // Load WYSIWYG editor
     $this->template->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE))->append_metadata(js('codemirror/codemirror.js'))->append_metadata(js('form.js', 'pages'))->build('admin/form', $this->data);
 }