function edit() { $data = array(); $this->template->add_package(array('ckeditor', 'ck_jq_adapter')); $data['Image'] = $Image = $this->load->model('gallery_images_model'); $image_id = $this->uri->segment(5); $Image->get_by_id($image_id); if (!$Image->exists()) { return show_404(); } $data['breadcrumb'] = set_crumbs(array('galleries' => 'Galleries', 'galleries/images/index/' . $Image->gallery_id => 'Images', current_url() => 'Image Edit')); // Validate Form $this->form_validation->set_rules('title', 'Title', "trim|required"); $this->form_validation->set_rules('alt', 'Alternative Text', "trim"); $this->form_validation->set_rules('description', 'Description', 'trim'); $this->form_validation->set_rules('filename', 'filename', 'trim|required'); $this->form_validation->set_rules('hide', 'Hide', 'trim|integer'); if ($this->form_validation->run() == TRUE) { $Image->from_array($this->input->post()); $Image->description = $this->input->post('description') != '' ? $this->input->post('description') : NULL; $Image->alt = $this->input->post('alt') != '' ? $this->input->post('alt') : NULL; $Image->hide = $this->input->post('hide') ? 1 : 0; $Image->save(); $this->session->set_flashdata('message', '<p class="success">Image saved successfully.</p>'); redirect(ADMIN_PATH . '/galleries/images/index/' . $Image->gallery_id); } $_SESSION['KCFINDER'] = array(); $_SESSION['KCFINDER']['disabled'] = false; $_SESSION['isLoggedIn'] = true; $this->template->view('admin/images/edit', $data); }
function edit() { // Init $data = array(); $data['breadcrumb'] = set_crumbs(array('navigations/groups' => 'Navigations', current_url() => 'Navigation Edit')); $data['Group'] = $Group = $this->load->model('navigations_model'); $data['edit_mode'] = $edit_mode = FALSE; $group_id = $this->uri->segment(4); if (!empty($group_id)) { $data['edit_mode'] = $edit_mode = TRUE; $Group->get_by_id($group_id); if (!$Group->exists()) { return show_404(); } } $this->form_validation->set_rules('title', 'Title', 'trim|required|max_length[255]'); // Form validation if ($this->form_validation->run() == TRUE) { $Group->from_array($this->input->post()); $Group->save(); $this->session->set_flashdata('message', '<p class="success">Navigation Saved.<p>'); if ($edit_mode) { redirect(ADMIN_PATH . '/navigations'); } else { redirect(ADMIN_PATH . '/navigations/items/tree/' . $Group->id); } } $this->template->view('admin/navigations/edit', $data); }
function edit() { $data['breadcrumb'] = set_crumbs(array('galleries' => 'Galleries', current_url() => 'Gallery Edit')); $data['Gallery'] = $Gallery = $this->load->model('galleries_model'); $data['edit_mode'] = $edit_mode = FALSE; $gallery_id = $this->uri->segment(4); $this->load->helper('file'); // Set Mode if ($gallery_id) { $data['edit_mode'] = $edit_mode = TRUE; $Gallery->get_by_id($gallery_id); if (!$Gallery->exists()) { return show_404(); } } // Validate Form $this->form_validation->set_rules('title', 'Title', "trim|required"); if ($this->form_validation->run() == TRUE) { $Gallery->from_array($this->input->post()); $Gallery->save(); if ($edit_mode) { $this->session->set_flashdata('message', '<p class="success">Gallery saved successfully.</p>'); redirect(ADMIN_PATH . '/galleries'); } else { redirect(ADMIN_PATH . '/galleries/images/index/' . $Gallery->id); } } $this->template->view('admin/galleries/edit', $data); }
function index() { // Init $data = array(); $this->load->library('pagination'); $per_page = 500; $data['breadcrumb'] = set_crumbs(array('trivia/invitationlog/' => 'Invitations', current_url() => 'Logs')); $invitationsModel = $this->load->model('trivia/invitation_log_model'); $sort = $this->input->get('sort') != "" ? $this->input->get('sort') : ''; $order = $this->input->get('order') != "" ? $this->input->get('order') : ''; $data['query_string'] = !empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''; $limit = $this->uri->segment(5) ? $this->uri->segment(5) : 0; // Create Pagination $config['base_url'] = site_url(ADMIN_PATH . '/trivia/invitationlog/index/'); $config['total_rows'] = $invitationsModel->record_count(); $config['per_page'] = $per_page; $config['uri_segment'] = '5'; $config['num_links'] = 5; $config['suffix'] = $data['query_string']; $this->pagination->initialize($config); $filter = $this->input->get('filter') ? $this->input->get('filter') : ''; // sending params to view page $data['no_pages'] = ceil($config['total_rows'] / $per_page); $data['total'] = $config['total_rows']; $data['limit'] = $limit; $data['status'] = $invitationsModel->getInvitationStatus(); $data['per_page'] = $config['per_page']; $invitations = $invitationsModel->get_all_invitations($sort, $order, $per_page, $limit, $filter); $data['invitaitons'] = $invitations; $this->template->view('admin/invitation_log', $data); }
function edit() { $catId = $this->uri->segment(5); $breadCrumbLabel = $catId != "" ? 'Edit Category' : 'Add Category'; $fileName = ""; $data = array(); $data['breadcrumb'] = set_crumbs(array('redemption/categories' => 'Redemption', current_url() => $breadCrumbLabel)); $data['categories'] = $this->redemption_categories_model->get_category_options(); $data['category_model'] = $Categories = $this->redemption_categories_model; $data['edit_mode'] = $edit_mode = FALSE; if ($catId) { $data['edit_mode'] = $edit_mode = TRUE; $Categories->get_by_id($catId); } $this->form_validation->set_rules('name', 'Category Name', 'trim|required'); $this->form_validation->set_rules('slug', 'Slug', 'trim|required|' . ($edit_mode && $Categories->slug == $this->input->post('slug') ? '' : 'is_unique[' . self::RED_CATEGORY . '.slug]')); $this->form_validation->set_rules('description', 'Description', 'trim|required'); $this->form_validation->set_rules('excerpt', 'Excerpt', 'trim|required'); if ($this->form_validation->run() == TRUE) { try { $fileName = $Categories->uploadImages($_FILES['image_categories']); } catch (Exception $ex) { $this->session->set_flashdata('message', '<p class="error">' . $ex->getMessage() . '</p>'); redirect(ADMIN_PATH . '/redemption/categories/edit/' . $catId); } $Categories->from_array($this->input->post()); if (isset($_FILES['image_categories']) && $_FILES['image_categories']['name']) { $Categories->image_categories = $fileName; } $Categories->save(); $this->session->set_flashdata('message', '<p class="success">Category Saved Successfully.</p>'); redirect(ADMIN_PATH . '/redemption/categories'); } $this->template->view('admin/categories/edit', $data); }
public function index() { $data = array(); $this->load->library('pagination'); $per_page = 50; $data['breadcrumb'] = set_crumbs(array('reports/quote/' => 'Reports', current_url() => 'Quote')); $reportModel = $this->load->model('reports/report_model'); $sort = $this->input->get('sort') != "" ? $this->input->get('sort') : ''; $order = $this->input->get('order') != "" ? $this->input->get('order') : ''; $data['query_string'] = !empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''; $limit = $this->uri->segment(5) ? $this->uri->segment(5) : 0; $config['base_url'] = site_url(ADMIN_PATH . '/reports/quote/index/'); $trows = count($reportModel->getQuoteReportsCount()); $config['total_rows'] = $trows; $config['per_page'] = $per_page; $config['uri_segment'] = '5'; $config['num_links'] = 5; $config['suffix'] = $data['query_string']; $this->pagination->initialize($config); $filter = $this->input->get('filter') ? $this->input->get('filter') : ''; $data['no_pages'] = ceil($config['total_rows'] / $per_page); $data['total'] = $config['total_rows']; $data['limit'] = $limit; $data['per_page'] = $config['per_page']; $reports = $reportModel->getQuoteReports($sort, $order, $per_page, $limit, $filter); $data['reports'] = $reports; // print_r($data);exit; $this->template->view('admin/quote', $data); }
function edit() { $catId = $this->uri->segment(5); $breadCrumbLabel = $catId != "" ? 'Edit Category' : 'Add Category'; // Init $data = array(); $data['breadcrumb'] = set_crumbs(array('trivia/categories' => 'Trivia Categories', current_url() => $breadCrumbLabel)); $data['categories'] = $Categories = $this->load->model('trivia/trivia_categories_model'); $data['edit_mode'] = $edit_mode = FALSE; // Edit Mode if ($catId) { $data['edit_mode'] = $edit_mode = TRUE; $Categories->get_by_id($catId); } // Validate Form $this->form_validation->set_rules('name', 'Category Name', 'trim|required'); // Process Form if ($this->form_validation->run() == TRUE) { $Categories->from_array($this->input->post()); $currentDate = date('Y-m-d H:i:s'); if (!$edit_mode) { $Categories->created_by = $this->secure->get_user_session()->id; $Categories->created_on = $currentDate; } $Categories->save(); $this->session->set_flashdata('message', '<p class="success">Category Saved Successfully.</p>'); redirect(ADMIN_PATH . '/trivia/categories'); } // Get Groups From DB $this->template->view('admin/categories/edit', $data); }
function index() { // Init $data = array(); $this->load->library('pagination'); $per_page = 50; $data['breadcrumb'] = set_crumbs(array('reports/binder' => 'Reports', current_url() => 'Binder Reports')); $binder = $this->load->model('quote/binder_request_model'); $sort = $this->input->get('sort') != "" ? $this->input->get('sort') : ''; $order = $this->input->get('order') != "" ? $this->input->get('order') : ''; $data['query_string'] = !empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''; $limit = $this->uri->segment(5) ? $this->uri->segment(5) : 0; // Create Pagination $config['base_url'] = site_url(ADMIN_PATH . '/reports/binder/index/'); $trows = $binder->countBinderReport(); $config['total_rows'] = count($trows); $config['per_page'] = $per_page; $config['uri_segment'] = '5'; $config['num_links'] = 5; $config['suffix'] = $data['query_string']; $this->pagination->initialize($config); // sending params to view page $data['no_pages'] = ceil($config['total_rows'] / $per_page); $data['total'] = $config['total_rows']; $data['limit'] = $limit; $data['per_page'] = $config['per_page']; $report = $binder->getBinderReport($sort, $order, $per_page, $limit); // print_r($report); exit; $data['report'] = $report; $this->template->view('admin/binder', $data); }
function index() { $data = array(); $data['breadcrumb'] = set_crumbs(array('trivia/reward/' => 'Rewards', current_url() => 'Reward')); $Rewards = $this->load->model('points/user_log_points_model'); $this->load->library('pagination'); $per_page = 50; $data['query_string'] = !empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''; $limit = $this->uri->segment(5) ? $this->uri->segment(5) : 0; $sort = $this->input->get('sort') != "" ? $this->input->get('sort') : ''; $order = $this->input->get('order') != "" ? $this->input->get('order') : ''; $data['persons'] = $Rewards->get_all_persons($sort, $order, $per_page, $limit); // Create Pagination $config['base_url'] = site_url(ADMIN_PATH . '/trivia/reward/index/'); $config['total_rows'] = $Rewards->record_count(); $config['per_page'] = $per_page; $config['uri_segment'] = '5'; $config['num_links'] = 5; $config['suffix'] = $data['query_string']; $this->pagination->initialize($config); $data['no_pages'] = ceil($config['total_rows'] / $per_page); $data['total'] = $config['total_rows']; $data['limit'] = $limit; $data['per_page'] = $config['per_page']; $this->template->view('admin/rewards', $data); }
function index() { // Init $data = array(); $data['breadcrumb'] = set_crumbs(array(current_url() => 'General Settings')); $this->load->model('settings/settings_model'); $this->load->model('users/groups_model'); $this->load->model('content/entries_model'); // Get Themes $data['themes'] = $this->template->get_themes(); $data['layouts'] = $this->template->get_theme_layouts(); // Get Groups $Groups = new Groups_model(); $data['Groups'] = $Groups->where('type !=', 'super_admin')->order_by('name')->get(); // Get All Entries $Entries = new Entries_model(); $data['Entries'] = $Entries->order_by('title')->get(); // Build object with current settings $Settings_table = $this->settings_model->get(); $data['Settings'] = new stdClass(); foreach ($Settings_table as $Setting) { $data['Settings']->{$Setting->slug} = new stdClass(); $data['Settings']->{$Setting->slug}->value = $Setting->value; $data['Settings']->{$Setting->slug}->module = $Setting->module; } // Form Validation Rules $this->form_validation->set_rules('site_name', 'Site Name', 'trim|required'); $this->form_validation->set_rules('notification_email', 'Notification Email', 'trim|required|valid_email'); $this->form_validation->set_rules('content[site_homepage]', 'Site Homepage', 'trim|required'); $this->form_validation->set_rules('content[custom_404]', 'Custom 404', 'trim|required'); $this->form_validation->set_rules('enable_admin_toolbar', 'Admin Toolbar', 'trim|required'); $this->form_validation->set_rules('suspend', 'Suspend Site', 'trim|required'); $this->form_validation->set_rules('users[default_group]', 'Default User Group', 'trim|required'); $this->form_validation->set_rules('users[enable_registration]', 'User Registration', 'trim|required'); $this->form_validation->set_rules('users[email_activation]', 'Require Email Activation', 'trim|required'); // Form Processing if ($this->form_validation->run() == TRUE) { foreach ($_POST as $slug => $value) { if (is_array($value)) { // Value is an array so save it as a module setting foreach ($value as $module_slug => $module_value) { $Settings_m = new Settings_model(); $Settings_m->where('slug', $module_slug)->where('module', $slug)->update('value', $module_value); } } else { $Settings_m = new Settings_model(); $Settings_m->where('slug', $slug)->where('module IS NULL')->update('value', $value); } unset($Settings_m); } $this->load->library('cache'); $this->cache->delete_all('settings'); $this->session->set_flashdata('message', '<p class="success">Settings Saved.</p>'); redirect(uri_string()); } $this->template->view('admin/general_settings', $data); }
function edit() { // Init $data = array(); $data['edit_mode'] = FALSE; $this->template->add_package(array('codemirror')); $data['breadcrumb'] = set_crumbs(array('content/snippets' => 'Snippets', current_url() => 'Snippet Edit')); $data['revision_id'] = $revision_id = $this->uri->segment(6); $this->load->model('snippets_model'); $data['Snippet'] = $Snippet = new Snippets_model(); $snippet_id = $this->uri->segment(5); // Edit mode if ($snippet_id) { $data['edit_mode'] = TRUE; $Snippet->get_by_id($snippet_id); // Check if snippet exists if (!$Snippet->exists()) { return show_404(); } // Load a revision if a revision id was provided in the URL if (!empty($revision_id)) { $this->load->model('revisions_model'); $Revision = new Revisions_model(); $Revision->get_by_id($revision_id); if ($Revision->exists()) { $revision_data = @unserialize($Revision->revision_data); $Snippet->from_array($revision_data); } else { return show_404(); } } } $this->form_validation->set_rules('title', 'Title', 'trim|required'); $this->form_validation->set_rules('short_name', 'Short Name', 'trim|required|alpha_dash|max_length[50]|is_unique[snippets.short_name.id.' . $snippet_id . ']'); $this->form_validation->set_rules('snippet', 'Snippet', ''); // Form validation if ($this->form_validation->run() == TRUE) { $Snippet->from_array($this->input->post()); if ($data['edit_mode']) { $Snippet->id = $snippet_id; } $Snippet->save(); $Snippet->add_revision(); // Clear cache $this->load->library('cache'); $this->cache->delete_all('snippets'); $this->session->set_flashdata('message', '<p class="success">Snippet Saved.</p>'); if ($this->input->post('save_exit')) { redirect(ADMIN_PATH . '/content/snippets/'); } else { redirect(ADMIN_PATH . '/content/snippets/edit/' . $Snippet->id); } } $this->template->view('admin/snippets/edit', $data); }
function index() { $data = array(); $data['breadcrumb'] = set_crumbs(array(current_url() => 'Server Info')); $this->template->add_stylesheet('/application/modules/settings/assets/css/server_info.css'); ob_start(); phpinfo(); $pinfo = ob_get_contents(); ob_end_clean(); $data['pinfo'] = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $pinfo); $this->template->view('admin/server_info', $data); }
function edit() { // Init $data = array(); $data['breadcrumb'] = set_crumbs(array('users/groups' => 'User Groups', current_url() => 'Group Edit')); $data['Group'] = $Group = $this->load->model('groups_model'); $data['permissions'] = array(); $group_id = $this->uri->segment(5); $data['edit_mode'] = $edit_mode = FALSE; $data['permission_options'] = unserialize(ADMIN_ACCESS_OPTIONS); // Edit Mode if ($group_id) { $data['edit_mode'] = $edit_mode = TRUE; $Group->get_by_id($group_id); // Stop non-super admins from editing super admins if ($this->secure->get_group_session()->type != SUPER_ADMIN && $Group->type == SUPER_ADMIN) { show_404(); } if ($Group->exists()) { $data['permissions'] = unserialize($Group->permissions); } else { show_404(); } } // Validate Form $this->form_validation->set_rules('name', 'Group Name', "trim|required|callback_name_check[{$group_id}]"); $this->form_validation->set_rules('permissions[access][]', 'Access Permissions', "trim"); if ($edit_mode && $Group->modifiable_permissions) { $this->form_validation->set_rules('type', 'Group Type', "trim|required"); } else { $this->form_validation->set_rules('type', 'Group Type', "trim"); } if ($this->form_validation->run() == TRUE) { $Group = new Groups_model(); // Load group to update if in edit mode if (!empty($group_id)) { $Group->get_by_id($group_id); } $Group->from_array($this->input->post()); // If permissions posted serialize for db if ($this->input->post('permissions') && $this->input->post('type') == 'administrator') { $Group->permissions = serialize($this->input->post('permissions')); } elseif ($edit_mode && $data['Group']->modifiable_permissions || !$edit_mode || $edit_mode && $Group->type == ADMINISTRATOR && $this->Group_session->type == SUPER_ADMIN) { $Group->permissions = NULL; } // Save Changes $Group->save(); $this->session->set_flashdata('message', '<p class="success">User Group Saved.</p>'); redirect(ADMIN_PATH . '/users/groups'); } $this->template->view('admin/groups/edit', $data); }
function index() { $data = array(); $data['breadcrumb'] = set_crumbs(array(current_url() => 'Clear Cache')); $this->form_validation->set_rules('cache[]', 'Cache', 'required'); if ($this->form_validation->run() == TRUE) { $this->load->library('cache'); foreach ($this->input->post('cache') as $cache => $value) { // Clear cache switch ($cache) { case "entries": $this->cache->delete_all('entries'); break; case "content_types": $this->cache->delete_all('content_types'); break; case "snippets": $this->cache->delete_all('snippets'); break; case "images": // Cached images are located outside the cache directory // due to strict security restrictions on the cache folder $this->load->helper('file'); if (file_exists(CMS_ROOT . IMAGE_CACHE)) { foreach (glob(CMS_ROOT . IMAGE_CACHE . '/*') as $file) { @unlink($file); } } break; case "navigations": $this->cache->delete_all('navigations'); break; case "categories": $this->cache->delete_all('categories'); break; case "settings": $this->cache->delete_all('settings'); break; case "datamapper": $this->cache->delete_all('datamapper'); break; } } // Set a success message $this->session->set_flashdata('message', '<p class="success">Cache succcessfully cleared.</p>'); redirect(current_url()); } $this->template->view('admin/clear_cache', $data); }
public function index() { $data = array(); $this->load->library('pagination'); $per_page = 50; $filter = array(); if ($this->input->post()) { $filter = $this->input->post(); } if ($this->input->get('reset')) { $this->session->unset_userdata(self::RED_ORDERS); } else { if (!empty($filter)) { $this->session->set_userdata(array(self::RED_ORDERS => $filter)); } else { $filter = $this->session->userdata(self::RED_ORDERS); } } $data['breadcrumb'] = set_crumbs(array('/redemption/order/' => 'Requests', current_url() => 'Orders')); $requestsModel = $this->load->model('redemption/order_model'); $sort = $this->input->get('sort') != "" ? $this->input->get('sort') : ''; $order = $this->input->get('order') != "" ? $this->input->get('order') : ''; $data['query_string'] = !empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''; $limit = $this->uri->segment(5) ? $this->uri->segment(5) : 0; $count = count($requestsModel->record_count($sort, $order, $per_page, $limit, $filter)); $config['base_url'] = site_url(ADMIN_PATH . '/redemption/order/index/'); $config['total_rows'] = $count; $config['per_page'] = $per_page; $config['uri_segment'] = '5'; $config['num_links'] = 5; $config['suffix'] = $data['query_string']; $this->pagination->initialize($config); $data['no_pages'] = ceil($config['total_rows'] / $per_page); $data['total'] = $config['total_rows']; $data['limit'] = $limit; $data['per_page'] = $config['per_page']; $data['params'] = $filter; $requests = $requestsModel->getOrderData($sort, $order, $per_page, $limit, $filter); $data['requestsdata'] = $requests; // print_r($data);exit; $this->template->view('admin/order', $data); }
function index() { $data = array(); $data['breadcrumb'] = set_crumbs(array()); if ($this->settings->ga_profile_id != '') { $this->template->add_stylesheet('application/modules/dashboard/assets/css/google_analytics.css'); try { $this->load->model('google_analytics_model'); $data['ga_data'] = $this->google_analytics_model->get_by_type('overview'); } catch (Exception $e) { $data['ga_data'] = '<p class="error">Unable to connect to Google Analytics. Please ensure your <a href="' . site_url(ADMIN_PATH . '/settings/general-settings') . '">analytic settings</a> are correct.</p>'; } $data['month_year'] = array(); for ($i = 0; $i < 12; $i++) { $unix_month = strtotime("-{$i} months"); $data['month_year'][$unix_month] = date('F Y', $unix_month); } } $this->template->view('admin/index', $data); }
public function index() { $data = array(); $this->load->library('pagination'); $per_page = 50; $data['breadcrumb'] = set_crumbs(array('reports/autousers' => 'Reports', current_url() => 'Auto Registered Users')); $binder = $this->load->model('users/users_model'); $sort = $this->input->get('sort') != "" ? $this->input->get('sort') : ''; $order = $this->input->get('order') != "" ? $this->input->get('order') : ''; $data['query_string'] = !empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''; $limit = $this->uri->segment(5) ? $this->uri->segment(5) : 0; // Create Pagination $config['base_url'] = site_url(ADMIN_PATH . '/reports/autousers/index/'); $filter = $this->input->post(); if ($this->input->get('reset')) { $this->session->unset_userdata(self::TABLE_ID); } else { if (!empty($filter)) { $this->session->set_userdata(array(self::TABLE_ID => $filter)); } else { $filter = $this->session->userdata(self::TABLE_ID); } } $trows = $binder->countAutoRegisteredUsers($filter); $config['total_rows'] = $trows['trows']; $config['per_page'] = $per_page; $config['uri_segment'] = '5'; $config['num_links'] = 5; $config['suffix'] = $data['query_string']; $this->pagination->initialize($config); // sending params to view page $data['no_pages'] = ceil($config['total_rows'] / $per_page); $data['total'] = $config['total_rows']; $data['limit'] = $limit; $data['per_page'] = $config['per_page']; $data['params'] = $filter; $report = $binder->getAutoRegisteredUsers($sort, $order, $per_page, $limit, $filter); // print_r($report); exit; $data['report'] = $report; $this->template->view('admin/auto_user', $data); }
public function edit() { // Init $data = array(); $q_id = $this->uri->segment(5); $breadCrumbLabel = $q_id != "" ? "Edit Question" : "Add Question"; $categoryModel = $this->load->model('trivia/trivia_categories_model'); $data['breadcrumb'] = set_crumbs(array('trivia/questions' => 'Trivia', current_url() => $breadCrumbLabel)); $data['Question'] = $Question = $this->load->model('trivia/trivia_questions_model'); $optionAssociation = $this->load->model('trivia/trivia_questions_association_model'); $data['edit_mode'] = $edit_mode = FALSE; $data['categories'] = $categoryModel->get_category_options(); // Edit Mode if ($q_id) { $data['edit_mode'] = $edit_mode = TRUE; $Question->get_by_id($q_id); } //get all options if ($data['edit_mode']) { $data['total_options'] = $optionAssociation->fetch_options_by_qid($q_id); } // Validate Form $this->form_validation->set_rules('question', 'Question', 'trim|required'); $this->form_validation->set_rules('answers[]', 'Options', 'trim|required'); $this->form_validation->set_rules('date_on', 'For Date', 'trim|required'); $this->form_validation->set_rules('categories', 'Category', 'required'); // Process Form if ($this->form_validation->run() == TRUE) { $postData = $this->input->post(); // print_r($postData); // exit; $Question->save_question($postData, $q_id); $this->session->set_flashdata('message', '<p class="success">Question Saved Successfully.</p>'); redirect(ADMIN_PATH . '/trivia/questions'); } // Get Groups From DB $this->template->view('admin/question/edit', $data); }
function edit() { $data = array(); $data['product'] = $productModel = $this->load->model('products_model'); $categoryModel = $this->load->model('redemption_categories_model'); $relationModel = $this->load->model('category_product_relation_model'); $priceModel = $this->load->model('product_price'); $product_id = $this->uri->segment(5); $data['edit_mode'] = $edit_mode = FALSE; $images = array(); // Edit Mode if ($product_id) { $data['edit_mode'] = $edit_mode = TRUE; $data['product_id'] = $product_id; $data['images'] = $productModel->getProductImages($product_id); $productModel->get_by_id($product_id); if (!$productModel->exists()) { show_404(); } } $data['breadcrumb'] = set_crumbs(array('' => 'Redemptions', 'redemption/products' => 'Products', current_url() => ($edit_mode ? 'Edit' : 'Add') . ' Product')); $data['in_stock'] = $productModel->getProductStockStatuses(); $data['status'] = $productModel->getProductStatuses(); $data['categories'] = $categoryModel->getAllCategoriesWithIds(); $data['relation'] = array(); if ($edit_mode) { $data['relation'] = $relationModel->getCategoriesByProductId($product_id); $data['prices'] = $priceModel->getPriceByProductId($product_id); } // Validate Form $this->form_validation->set_rules('name', 'Name', "trim|required"); $this->form_validation->set_rules('p_order', 'Order', "trim|required"); $this->form_validation->set_rules('sku', 'SKU', 'trim|' . ($edit_mode && $productModel->sku == $this->input->post('sku') ? '' : 'is_unique[red_products.sku]')); $this->form_validation->set_rules('slug', 'Slug', 'trim|' . ($edit_mode && $productModel->slug == $this->input->post('slug') ? '' : 'is_unique[red_products.slug]')); $this->form_validation->set_rules('description', 'Description', 'trim'); $this->form_validation->set_rules('excerpt', 'Excerpt', 'trim'); $this->form_validation->set_rules('weight', 'Weight', 'trim'); $this->form_validation->set_rules('in_stock', 'In Stock', 'required'); if ($this->input->post('in_stock') == 1) { $this->form_validation->set_rules('quantity', 'Quantity', 'required|integer|greater_than[0]'); } $this->form_validation->set_rules('seo_title', 'Seo Title', 'trim'); $this->form_validation->set_rules('meta', 'Meta', 'trim'); $this->form_validation->set_rules('enabled', 'Status', 'required'); $this->form_validation->set_rules('extraprice[]', 'Price', 'required|integer'); // $this->form_validation->set_rules('price', 'Price', 'required|numeric|greater_than[0]'); // $this->form_validation->set_rules('saleprice', 'Sale Price', 'numeric'); $this->form_validation->set_rules('categories[]', 'Categories', 'trim|required'); if (isset($_FILES['product_image'])) { $number_of_files = sizeof($_FILES['product_image']['tmp_name']); $files = $_FILES['product_image']; $this->load->library('upload'); // next we pass the upload path for the images $config['upload_path'] = UPLOADPATH . 'product_images/'; $config['allowed_types'] = 'gif|jpg|png|GIF|PNG|JPG|JPEG|jpeg'; for ($i = 0; $i < $number_of_files; $i++) { $_FILES['product_image']['name'] = $files['name'][$i]; $_FILES['product_image']['type'] = $files['type'][$i]; $_FILES['product_image']['tmp_name'] = $files['tmp_name'][$i]; $_FILES['product_image']['error'] = $files['error'][$i]; $_FILES['product_image']['size'] = $files['size'][$i]; //now we initialize the upload library $this->upload->initialize($config); // we retrieve the number of files that were uploaded if ($_FILES['product_image']['name']) { if ($this->upload->do_upload('product_image')) { $data['uploads'][$i] = $this->upload->data(); $images[] = $data['uploads'][$i]['file_name']; } else { $data['upload_errors'][$i] = $this->upload->display_errors("<p class='error'>", "</p>"); } } } } // Process Form if ($this->form_validation->run() == TRUE && !isset($data['upload_errors'])) { // $images = array(); // foreach ($_FILES['product_image'] as $key => $image) { // if ($key == 'error') // continue; // $image = array_filter($image); // $i = 0; // foreach ($image as $value) { // $images[$i++][$key] = $value; // } // } // // foreach ($images as $image) { // $dirPath = UPLOADPATH . 'product_images/'; // $fileName = date('ymdhis') . "-" . $image['name']; // $config['upload_path'] = $dirPath; // $config['file_name'] = $fileName; // $config['allowed_types'] = array('jpg', 'jpeg', 'JPEG', 'JPG', 'png', 'PNG', 'bmp', 'BMP', 'gif', 'GIF'); // $config['max_size'] = '204800'; // if(!$this->uploadImage($image, $config)) // { // // } // } $postData = $this->input->post(); $categoryData = array(); if ($this->input->post('in_stock') != 1) { $postData['quantity'] = 0; } if (isset($postData['categories'])) { $categoryData = $postData['categories']; } $i = 0; $postData['saleprice'] = !empty($postData['saleprice']) ? $postData['saleprice'] : NULL; // print_r($postData);exit; $productModel->from_array($postData); $productModel->save(); foreach ($categoryData as $value) { $categoryData[$i++] = array('product_id' => $productModel->id, 'category_id' => $value); } if ($edit_mode) { $relationModel->get_by_product_id($product_id); $relationModel->delete_relation($product_id); } $price = array(); if (isset($postData['extraprice'])) { foreach ($postData['extraprice'] as $k => $value) { if ($value) { $price = array('id' => $k, 'product_id' => $productModel->id, 'price' => $value); $priceModel->updateProductPrice($price); } } } foreach ($categoryData as $value) { $relationModel->from_array($value); $relationModel->save(); } $id = $productModel->id; if (isset($images)) { foreach ($images as $image) { if ($image) { $form_data = array('product_id' => $id, 'image' => $image); $this->db->insert('red_product_images', $form_data); } } } $this->session->set_flashdata('message', '<p class="success">Product saved.</p>'); redirect(ADMIN_PATH . '/redemption/products'); } $this->template->view('admin/products/edit', $data); }
function index() { $data = array(); $data['breadcrumb'] = set_crumbs(array(current_url() => 'Theme Editor')); $theme_dir = CMS_ROOT . 'themes/' . $this->settings->theme . '/'; $data['files_found'] = TRUE; $data['file_readable'] = TRUE; $data['file_writable'] = TRUE; $this->load->helper('file'); $this->load->model('theme_editor_model'); $this->template->add_stylesheet('/application/modules/settings/assets/css/theme_editor.css'); // Load CodeMirror Scripts $this->template->add_package('codemirror'); // Get theme files $data['layouts'] = $this->theme_editor_model->get_theme_files('{php, html}', 'views/layouts'); $data['partials'] = $this->theme_editor_model->get_theme_files('{php, html}', 'views/partials'); $data['stylesheets'] = $this->theme_editor_model->get_theme_files('css'); $data['javascripts'] = $this->theme_editor_model->get_theme_files('js'); // Read selected file if ($hash = $this->uri->segment(5)) { $data['file'] = $file = url_base64_decode($hash); } else { // Check if assets/css/style.css exists and load it first if no other file specified if (isset($data['stylesheets']['assets/css/style.css'])) { $data['file'] = $file = url_base64_decode($data['stylesheets']['assets/css/style.css']['hash']); } else { // There was no style.css so load first file found if any foreach (array('stylesheets', 'layouts', 'partials', 'javascripts') as $theme_type) { if (!empty($data[$theme_type])) { $file_array = current($data[$theme_type]); $data['file'] = $file = url_base64_decode($file_array['hash']); break; } } } } if (!empty($file)) { // Check if the file exists and is readable if (is_readable($theme_dir . $file)) { // Read the file $data['code'] = read_file($theme_dir . $file); // Check if file is writable if (!is_writable($theme_dir . $file)) { $data['file_writable'] = FALSE; } // Determine CodeMirror mode from extension switch (pathinfo($file, PATHINFO_EXTENSION)) { case "css": $data['mode'] = 'text/css'; break; case "js": $data['mode'] = 'text/javascript'; break; default: $data['mode'] = 'application/x-httpd-php'; break; } } else { // Flag file as not found or not readable $data['file_readable'] = FALSE; } } else { // No theme files were found $data['files_found'] = FALSE; } // Form validation $this->form_validation->set_rules('code', 'Text Area', 'required'); if ($this->form_validation->run() == TRUE) { // Write post to file if (write_file($theme_dir . $file, $this->input->post('code'))) { $this->session->set_flashdata('message', '<p class="success">File saved successfully.</p>'); } else { $this->session->set_flashdata('message', '<p class="error">Unable to write to file.</p>'); } redirect(current_url()); } $this->template->view('admin/theme_editor', $data); }
function edit() { // Init $data = array(); $data['edit_mode'] = $edit_mode = FALSE; $data['breadcrumb'] = set_crumbs(array('content/entries' => 'Entries', current_url() => 'Entry Edit')); $data['content_type_id'] = $content_type_id = $this->uri->segment(5); $data['entry_id'] = $entry_id = $this->uri->segment(6); $data['revision_id'] = $revision_id = $this->uri->segment(7); // Get entry $this->load->model('users/users_model'); $this->load->model('entries_model'); $this->load->model('content_types_model'); // Used for content types dropdown $Content_types_model = new Content_types_model(); // If user not a super admin check if user's group is allowed access if ($this->Group_session->type != SUPER_ADMIN) { $this->content_types_model->group_start()->where('restrict_admin_access', 0)->or_where_related('admin_groups', 'group_id', $this->Group_session->id)->group_end(); $this->entries_model->group_start()->where('restrict_admin_access', 0)->or_where_related('content_types/admin_groups', 'group_id', $this->Group_session->id)->group_end(); // Only get Content Types user has access to for dropdown $Content_types_model->group_start()->where('restrict_admin_access', 0)->or_where_related('admin_groups', 'group_id', $this->Group_session->id)->group_end(); } $data['Entry'] = $Entry = $this->entries_model->get_by_id($entry_id); $data['Content_type'] = $Content_type = $this->content_types_model->get_by_id($content_type_id); // Load content fields library $config['Entry'] = $Entry; $config['content_type_id'] = $content_type_id; $this->load->add_package_path(APPPATH . 'modules/content/content_fields'); $Content_fields = $this->load->library('content_fields'); $Content_fields->initialize($config); // Check if versioning is enabled and whether a revision is loaded if ($Content_type->enable_versioning && is_numeric($revision_id)) { $Revision = new Revisions_model(); $Revision->get_by_id($revision_id); if ($Revision->exists()) { $revision_data = @unserialize($Revision->revision_data); // Update Entry and content fields from revision // Entries data gets queiried in the content_fields library initialize if (is_array($revision_data)) { $Entry->from_array($revision_data); $Content_fields->from_array($revision_data); } } } // Get content types for the setting's // content type dropdown $Change_content_types = $Content_types_model->where('id !=', $content_type_id)->order_by('title')->get(); $data['change_content_types'] = array('' => ''); foreach ($Change_content_types as $Change_content_type) { $entries_count = $Change_content_type->entries->count(); // Only add the content type to the Add Entry dropdown if it has not reached the // limit of entries allowed. An empty entries_allowed is unlimited if ($Change_content_type->entries_allowed == '' || $entries_count < $Change_content_type->entries_allowed || $entries_count == 0 && $Change_content_type->entries_allowed > 0) { $data['change_content_types'][$Change_content_type->id] = $Change_content_type->title; } } // Get Admins and Super Admins for the setting's // author dropdown $Users = $this->users_model->where_in_related('groups', 'type', array(SUPER_ADMIN, ADMINISTRATOR))->order_by('first_name')->get(); $data['authors'] = array('' => ''); foreach ($Users as $User) { $data['authors'][$User->id] = $User->full_name(); } // Validate that the content type exists if (!$Content_type->exists()) { return show_404(); } if ($Entry->exists()) { // Check that url content_type_id and entry content_type_id match if ($Entry->content_type_id != $content_type_id && !$revision_id) { return show_404(); } $data['edit_mode'] = $edit_mode = TRUE; } // Build categories tree if content type has a category group assigned if ($Content_type->category_group_id) { $this->load->library('categories_library'); $config['id'] = $Content_type->category_group_id; $config['admin_entries_categories'] = TRUE; $config['populate'] = option_array_value($Entry->categories->get(), 'id', 'id'); $data['categories_tree'] = $this->categories_library->list_categories($config); $Entry->categories->get(); } // Form Validation Rules if ($edit_mode) { $this->form_validation->set_rules('slug', 'URL', 'trim|max_length[255]|callback_unique_slug_check[' . addslashes($Entry->slug) . ']'); } else { $this->form_validation->set_rules('slug', 'URL', 'trim|max_length[255]|callback_unique_slug_check'); } $this->form_validation->set_rules('meta_title', 'Meta Title', 'trim'); $this->form_validation->set_rules('meta_description', 'Meta Description', 'trim'); $this->form_validation->set_rules('meta_keywords', 'Meta Keywords', 'trim'); $this->form_validation->set_rules('status', 'Status', 'trim|required'); $this->form_validation->set_rules('title', 'Entry Title', 'trim|required|max_length[100]'); $this->form_validation->set_rules('created_date', 'Date Created', 'trim|required'); // Validate url title if content type has a dynamic route if ($Content_type->dynamic_route != '') { $this->form_validation->set_rules('url_title', 'URL Title', 'trim|required|alpha_dash|max_length[100]|is_unique[entries.url_title' . ($edit_mode ? '.id.' . $Entry->id : '') . ']'); } // Get content fields html $field_validation = $Content_fields->validate(); // Validation and process form if ($this->form_validation->run() == TRUE && $field_validation) { // Populate from post and prep for insert / update $Entry->from_array($this->input->post()); $Entry->modified_date = date('Y-m-d H:i:s'); $Entry->created_date = date('Y-m-d H:i:s', strtotime($this->input->post('created_date'))); $Entry->slug = $this->input->post('slug') != '' ? $this->input->post('slug') : NULL; $Entry->url_title = $this->input->post('url_title') != '' ? $this->input->post('url_title') : NULL; $Entry->meta_title = $this->input->post('meta_title') != '' ? $this->input->post('meta_title') : NULL; $Entry->meta_description = $this->input->post('meta_description') != '' ? $this->input->post('meta_description') : NULL; $Entry->meta_keywords = $this->input->post('meta_keywords') != '' ? $this->input->post('meta_keywords') : NULL; $Entry->content_type_id = $content_type_id; $Entry->author_id = $this->input->post('author_id') != '' ? $this->input->post('author_id') : NULL; // Ensure the id wasn't overwritten by an id in the post if ($edit_mode) { $Entry->id = $entry_id; } $Entry->save(); // Save field data to entries_data $Content_fields->from_array($this->input->post()); $Content_fields->save(); // Add Revision if versioning enabled if ($Content_type->enable_versioning) { // Delete old revsions so that not to exceed max revisions setting $Revision = new Revisions_model(); $Revision->where_related('revision_resource_types', 'key_name', 'ENTRY')->where('resource_id', $entry_id)->order_by('id', 'desc')->limit(25, $Content_type->max_revisions - 1)->get()->delete_all(); // Serialize and save post data to entry revisions table $User = $this->secure->get_user_session(); $Revision = new Revisions_model(); $Revision->resource_id = $Entry->id; $Revision->revision_resource_type_id = Revision_resource_types_model::ENTRY; $Revision->content_type_id = $Entry->content_type_id; $Revision->author_id = $User->id; $Revision->author_name = $User->first_name . ' ' . $User->last_name; $Revision->revision_date = date('Y-m-d H:i:s'); $Revision->revision_data = serialize($this->input->post()); $Revision->save(); } // Assign entry to selected categories if ($Content_type->category_group_id) { $this->load->model('categories_entries_model'); $Categories_entries = new Categories_entries_model(); $categories_post = is_array($this->input->post('categories')) ? $this->input->post('categories') : array(); // Delete all of the entries categories that are not in the posted array $Categories_entries->where('entry_id', $Entry->id); if (!empty($categories_post)) { $Categories_entries->where_not_in('category_id', $categories_post); } $Categories_entries->get()->delete_all(); // Check if categories posted already exist in the relationship table // If not add them foreach ($categories_post as $category_id) { $Categories_entries = new Categories_entries_model(); $Categories_entries->where('category_id', $category_id)->where('entry_id', $Entry->id)->get(); if (!$Categories_entries->exists()) { $Categories_entries->category_id = $category_id; $Categories_entries->entry_id = $entry_id; $Categories_entries->save(); } } } // Clear cache so updates will show on next page load $this->load->library('cache'); $this->cache->delete_all('entries'); // Clear navigation cache so updates will show on next page load $this->load->library('navigations/navigations_library'); $this->navigations_library->clear_cache(); // Set a success message $this->session->set_flashdata('message', '<p class="success">Changes Saved.</p>'); // Deteremine where to redirect user if ($this->input->post('save_exit')) { redirect(ADMIN_PATH . "/content/entries"); } else { redirect(ADMIN_PATH . "/content/entries/edit/" . $Entry->content_type_id . "/" . $Entry->id); } } $_SESSION['KCFINDER'] = array(); $_SESSION['KCFINDER']['disabled'] = false; $_SESSION['isLoggedIn'] = true; // Field form needs to be built after running form_validation->run() $data['Fields'] = $Content_fields->form(); $this->template->view('admin/entries/edit', $data); }
public function binder_detail() { $data = array(); $this->load->helper('date'); $id = $this->input->get('id') != "" ? $this->input->get('id') : NULL; if ($id) { $binderModel = $this->load->model('binder_request_model'); $data['data'] = $binderModel->getBinderByid($id); $data['status'] = $binderModel->getAllStatus(); $data['breadcrumb'] = set_crumbs(array('quote/quote/' => 'Request', 'quote/quote/binder' => 'Binder', current_url() => 'Binder Detail')); $this->template->view('admin/binder_detail', $data); } else { redirect(ADMIN_PATH . '/quote/quote/binder'); } }
function add() { // Init $data = array(); $data['breadcrumb'] = set_crumbs(array('content/types' => 'Content Types', current_url() => 'Add Content Type')); $this->load->model('content_types_model'); $this->load->model('content_types_admin_groups_model'); $this->load->model('content_fields_model'); $this->load->model('users/groups_model'); $this->load->model('category_groups_model'); // Get theme layouts for theme layout dropdown $data['theme_layouts'] = $this->template->get_theme_layouts($this->settings->theme, TRUE); // Get all admin groups for admin group access $data['Admin_groups'] = $this->groups_model->where('type', ADMINISTRATOR)->order_by('name')->get(); // Get all user groups except super admin for group access $Groups = new Groups_model(); $data['Groups'] = $Groups->where('type !=', SUPER_ADMIN)->order_by('name')->get(); // Get all category groups for dropdown $data['category_groups'] = option_array_value($this->category_groups_model->order_by('title')->get(), 'id', 'title', array('' => '')); // Form Validation $this->form_validation->set_rules('title', 'Title', 'trim|required'); $this->form_validation->set_rules('short_name', 'Short Name', 'trim|required|alpha_dash|max_length[50]|is_unique[content_types.short_name]'); $this->form_validation->set_rules('enable_dynamic_routing', 'Enable Dynamic Routing', 'trim'); $this->form_validation->set_rules('enable_versioning', 'Enable Versioning', 'trim|required'); $this->form_validation->set_rules('max_revisions', 'Max Revisions', 'trim|required|integer|less_than[26]'); $this->form_validation->set_rules('category_group_id', 'Category Group', 'trim'); $this->form_validation->set_rules('restrict_admin_access', 'Restrict Admin Access', 'trim|required'); $this->form_validation->set_rules('selected_admin_groups[]', 'Administrative Access', 'trim'); $this->form_validation->set_rules('access', 'Access', 'trim|required'); $this->form_validation->set_rules('restrict_to[]', 'Group Access', 'trim'); $this->form_validation->set_rules('entries_allowed', 'Number of Entries Allowed', 'trim|integer'); // Add dynamic route validation if enable dynamic routing checkbox selected if ($this->input->post('enable_dynamic_routing') == 1) { $this->form_validation->set_rules('dynamic_route', 'Dynamic Route', 'trim|required|max_length[255]|callback_unique_dynamic_route'); } if ($this->form_validation->run() == TRUE) { // Save new content type $Content_type = new Content_types_model(); $Content_type->from_array($this->input->post()); $Content_type->dynamic_route = $this->input->post('dynamic_route') != '' && $this->input->post('enable_dynamic_routing') ? $this->input->post('dynamic_route') : NULL; $Content_type->restrict_to = $this->input->post('access') == 2 ? serialize($this->input->post('restrict_to')) : NULL; $Content_type->category_group_id = $this->input->post('category_group_id') != '' ? $this->input->post('category_group_id') : NULL; $Content_type->theme_layout = $this->input->post('theme_layout') != '' ? $this->input->post('theme_layout') : NULL; $Content_type->entries_allowed = $this->input->post('entries_allowed') != '' ? $this->input->post('entries_allowed') : NULL; $Content_type->save(); $Content_type->add_revision(); // Assign admin groups to this content type // if restrict admin access is enabled if ($Content_type->restrict_admin_access && is_array($this->input->post('selected_admin_groups'))) { $selected_admin_groups = $this->input->post('selected_admin_groups'); foreach ($selected_admin_groups as $admin_group) { $Content_types_admin_groups = new Content_types_admin_groups_model(); $Content_types_admin_groups->content_type_id = $Content_type->id; $Content_types_admin_groups->group_id = $admin_group; $Content_types_admin_groups->save(); } } // Clear cache $this->load->library('cache'); $this->cache->delete_all('entries'); $this->cache->delete_all('content_types'); redirect(ADMIN_PATH . "/content/types/edit/{$Content_type->id}"); } $this->template->view('admin/types/add', $data); }
function edit() { // Init $data = array(); $data['breadcrumb'] = set_crumbs(array('users' => 'Users', current_url() => 'User Edit')); $data['User'] = $User = $this->load->model('users_model'); $data['states'] = $this->states_model->get_states(); $data['edit_mode'] = $edit_mode = FALSE; $user_id = $this->uri->segment(4); // Edit Mode if ($user_id) { $data['edit_mode'] = $edit_mode = TRUE; $User->include_related('groups', 'type')->get_by_id($user_id); // Stop non-super users from editing super users if ($this->Group_session->type != SUPER_ADMIN && $data['User']->groups_type == SUPER_ADMIN) { show_404(); } if (!$User->exists()) { show_404(); } } // Validate Form $this->form_validation->set_rules('email', 'Email', "trim|required|valid_email|callback_email_check[{$user_id}]"); $this->form_validation->set_rules('group_id', 'Group', 'trim|required'); $this->form_validation->set_rules('first_name', 'First Name', 'trim|required'); $this->form_validation->set_rules('last_name', 'Last Name', 'trim|required'); $this->form_validation->set_rules('phone', 'Phone', 'trim|format_phone'); $this->form_validation->set_rules('address', 'Address', 'trim'); $this->form_validation->set_rules('address2', 'Address 2', 'trim'); $this->form_validation->set_rules('city', 'City', 'trim'); $this->form_validation->set_rules('state', 'State', 'trim'); $this->form_validation->set_rules('zip', 'Zip', 'trim'); if ($edit_mode) { $this->form_validation->set_rules('password', 'Password', 'trim'); if ($this->input->post('password')) { $this->form_validation->set_rules('confirm_password', 'Confirm Password', 'trim|required|matches[password]'); } } else { $this->form_validation->set_rules('password', 'Password', 'trim|required'); $this->form_validation->set_rules('confirm_password', 'Confirm Password', 'trim|required|matches[password]'); } // Process Form if ($this->form_validation->run() == TRUE) { if (!$this->input->post('password')) { unset($_POST['password']); } $User->from_array($this->input->post()); if ($this->input->post('password')) { $User->password = md5($this->config->item('encryption_key') . $this->input->post('password')); } // Set a created date if new user if (!$edit_mode) { $User->created_date = date('Y-m-d H:i:s'); } $User->save(); if ($edit_mode) { $usersArray = array('first_name' => $User->first_name, 'last_name' => $User->last_name, 'email' => $User->email, 'phone' => $User->phone); $User->UpdateUserToZoho($usersArray, $User->zoho_contact_id); $User->UpdateUserToIcontact($usersArray, $User->icontact_id); } else { $usersArray = array('first_name' => $User->first_name, 'last_name' => $User->last_name, 'email' => $User->email, 'phone' => $User->phone); $User->SaveUserToZoho($usersArray, $User->id); if ($this->settings->send_user_on_icontact) { $User->SaveUserToIcontact($usersArray, $User->id); } } $this->session->set_flashdata('message', '<p class="success">User saved.</p>'); redirect(ADMIN_PATH . '/users'); } // Get Groups From DB $this->load->model('groups_model'); if ($this->Group_session->type == SUPER_ADMIN) { $data['Groups'] = $this->groups_model->where('type =', USER)->get(); } else { $data['Groups'] = $this->groups_model->where('type =', USER)->get(); } $this->template->view('admin/users/edit', $data); }
function index() { // Init $data = array(); $data['breadcrumb'] = set_crumbs(array(current_url() => 'General Settings')); $this->load->model('settings/settings_model'); $this->load->model('users/groups_model'); $this->load->model('content/entries_model'); // Get Themes $data['themes'] = $this->template->get_themes(); $data['layouts'] = $this->template->get_theme_layouts(); // Get Groups $Groups = new Groups_model(); $data['Groups'] = $Groups->where('type !=', 'super_admin')->order_by('name')->get(); // Get All Entries $Entries = new Entries_model(); $data['Entries'] = $Entries->order_by('title')->get(); // Build object with current settings $Settings_table = $this->settings_model->get(); $data['Settings'] = new stdClass(); foreach ($Settings_table as $Setting) { $data['Settings']->{$Setting->slug} = new stdClass(); $data['Settings']->{$Setting->slug}->value = $Setting->value; $data['Settings']->{$Setting->slug}->module = $Setting->module; } // Form Validation Rules $this->form_validation->set_rules('site_name', 'Site Name', 'trim|required'); $this->form_validation->set_rules('notification_email', 'Notification Email', 'trim|required|valid_email'); $this->form_validation->set_rules('content[site_homepage]', 'Site Homepage', 'trim|required'); $this->form_validation->set_rules('content[custom_404]', 'Custom 404', 'trim|required'); // $this->form_validation->set_rules('enable_admin_toolbar', 'Admin Toolbar', 'trim|required'); $this->form_validation->set_rules('suspend', 'Suspend Site', 'trim|required'); $this->form_validation->set_rules('pagination_count', 'Pagination Count', 'trim|required|integer'); $this->form_validation->set_rules('points_earned_trivia_question', 'Point Earned In Correct Answer', 'trim|required|decimal'); $this->form_validation->set_rules('amount_earned_trivia_correct_answer', 'Amount Earned In One Point', 'trim|required|decimal'); // $this->form_validation->set_rules('users[default_group]', 'Default User Group', 'trim|required'); //$this->form_validation->set_rules('users[enable_registration]', 'User Registration', 'trim|required'); // $this->form_validation->set_rules('users[email_activation]', 'Require Email Activation', 'trim|required'); $this->form_validation->set_rules('bronze_points_per_referrals', 'Bronze(Points Per Referrals)', 'trim|required|decimal'); $this->form_validation->set_rules('silver_points_per_referrals', 'Silver(Points Per Referrals)', 'trim|required|decimal'); $this->form_validation->set_rules('gold_points_per_referrals', 'Gold(Points Per Referrals)', 'trim|required|decimal'); $this->form_validation->set_rules('bronze_club_quote_point', 'Points Per Quote', 'trim|decimal'); $this->form_validation->set_rules('silver_club_quote_point', 'Points Per Quote', 'trim|decimal'); $this->form_validation->set_rules('gold_club_quote_point', 'Points Per Quote', 'trim|decimal'); $this->form_validation->set_rules('bronze_no_referrals_trailing_months', 'Bronze Referrals In Trailing Months', 'trim|decimal'); $this->form_validation->set_rules('bronze_club_binder_point', 'Points Per Binder', 'trim|decimal'); $this->form_validation->set_rules('silver_club_binder_point', 'Points Per Binder', 'trim|decimal'); $this->form_validation->set_rules('gold_club_binder_point', 'Points Per Binder', 'trim|decimal'); $this->form_validation->set_rules('trialing_months', 'Trialing Months', 'trim|required|integer'); $this->form_validation->set_rules('registration_point', 'Points On Registration', 'trim|required|integer'); $this->form_validation->set_rules('allow_point_auto_registration', 'Allow Points On Auto Registration', 'trim|required'); $this->form_validation->set_rules('send_user_on_icontact', 'Send user on Icontact', 'trim|required'); $this->form_validation->set_rules('resubmit_survey_counter', 'Resubmit Survey Link After (How Many Requests)', 'trim|required|integer'); $this->form_validation->set_rules('survey_link', 'Survey Link', 'trim|required'); $this->form_validation->set_rules('min_amount_redeem', 'Minimum Amount For Redeem Points', 'trim|required|integer'); $this->form_validation->set_rules('flash_message', 'Flash Message', 'trim|required'); // Form Processing if ($this->form_validation->run() == TRUE) { foreach ($_POST as $slug => $value) { // print_r($_POST);exit; if (is_array($value)) { // Value is an array so save it as a module setting foreach ($value as $module_slug => $module_value) { $Settings_m = new Settings_model(); $Settings_m->where('slug', $module_slug)->where('module', $slug)->update('value', $module_value); } } else { $Settings_m = new Settings_model(); $Settings_m->where('slug', $slug)->where('module IS NULL')->update('value', $value); } unset($Settings_m); } $this->load->library('cache'); $this->cache->delete_all('settings'); $this->session->set_flashdata('message', '<p class="success">Settings Saved.</p>'); redirect(uri_string()); } $this->template->view('admin/general_settings', $data); }
public function edit_event() { $site_id = $this->uri->segment(4); $park_event_id = $this->uri->segment(5); if (!$site_id) { return show_404(); } $data = array(); $data['breadcrumb'] = set_crumbs(array('settings/sites' => 'Sites', "calendar/index/{$site_id}" => 'Calendar', current_url() => 'Calendar Events')); $this->load->model('park_events_model'); // Load site name $Site = $this->load->model('settings/sites_model'); $Site->where('id', $site_id)->get(); $data['Site'] = $Site; // Determine if the event is being added or edited if ($park_event_id === '0') { $data['edit_mode'] = $edit_mode = false; // Get the day that this new event is to be added for $year = $this->uri->segment(6); $month = $this->uri->segment(7); $day = $this->uri->segment(8); $calendar_day = date('Y-m-d', mktime(12, 0, 0, $month, $day, $year)); } else { $data['edit_mode'] = $edit_mode = true; // Load the event $data['Event'] = $Event = $this->park_events_model->get_event($park_event_id); } // Determine event type if ($edit_mode) { $edit_type = 'Edit'; $data['event_type'] = $event_type = $Event->park_hours ? 'Park Hours' : 'Event'; } else { $edit_type = 'Add'; $data['event_type'] = $event_type = 'Event'; } // Validate Form $this->form_validation->set_rules('title', 'Title', "trim|required"); $this->form_validation->set_rules('details', 'Details', "trim"); $this->form_validation->set_rules('event_bg_color', 'Event Color', "trim|required"); $this->form_validation->set_rules('park_closed', 'Park Closed', "trim|required"); if ($event_type == 'Event') { $this->form_validation->set_rules('event_link', 'Event Link', "trim"); $this->form_validation->set_rules('event_link_target', 'Event Link Target', "trim"); // Validate links dependingon link type if ($this->input->post('link_type') == 'INTERNAL') { $this->form_validation->set_rules('link_internal', 'Page', "trim|required"); } else { if ($this->input->post('link_type') == 'EXTERNAL') { $this->form_validation->set_rules('link_external', 'URL', "trim|required"); } } } if ($this->form_validation->run() == TRUE) { $park_event_data = array('event_text_color' => $this->input->post('event_text_color'), 'event_bg_color' => $this->input->post('event_bg_color'), 'title' => $this->input->post('park_closed') ? $this->config->item('calendar_park_closed') : $this->input->post('title'), 'details' => $this->input->post('details'), 'event_link' => $event_type == 'Event' ? $this->input->post('event_link') : '', 'event_link_internal' => $event_type == 'Event' ? $this->input->post('event_link_internal') : '', 'event_link_external' => $event_type == 'Event' ? $this->input->post('event_link_external') : '', 'event_link_target' => $event_type == 'Event' ? $this->input->post('event_link_target') : '', 'park_closed' => $this->input->post('park_closed') ? 1 : 0); // Save event data if ($edit_mode) { // Edit existing event $this->park_events_model->update_event($park_event_id, $park_event_data); } else { $park_event_data['calendar_day'] = $calendar_day; $park_event_data['park_hours'] = 0; $park_event_data['site_id'] = $site_id; // Add new event $this->park_events_model->add_event($park_event_data); } // Work out the month and year of the edited event if ($edit_mode) { $dates = explode('-', $Event->calendar_day); $year = $dates[0]; $month = $dates[1]; } redirect(ADMIN_PATH . "/calendar/index/{$site_id}/{$year}/{$month}"); } // Get all the sites pages $this->load->model('content/entries_model'); $Pages = $this->entries_model->where('status', 'published')->where('site_id', $site_id)->where('slug !=', 'NULL')->order_by('title')->get(); $data['Pages'] = option_array_value($Pages, 'slug', 'title', array('' => '- SELECT -')); // Get all Color options $data['colors'] = array(); foreach ($this->config->item('calendar_color_options') as $option_number => $colors) { if ($edit_mode) { $highlight = $colors['background-color'] == $Event->event_bg_color && $colors['text-color'] == $Event->event_text_color ? true : false; } else { $highlight = $option_number == 0 ? true : false; } $colorAttributes = array('style' => "background-color: {$colors['background-color']}; color: {$colors['text-color']};", 'class' => $highlight ? 'highlight' : ''); $data['colors'][] = $colorAttributes; } // Set Title $data['title'] = "{$edit_type} {$Site->name} Calendar {$event_type}"; // Load the view $this->template->add_package(array('ckeditor', 'ck_jq_adapter')); $this->template->view('admin/events', $data); }
function edit() { $Field = null; $data = array(); $data['edit_mode'] = FALSE; $this->load->model('content_fields_model'); $this->load->model('content_field_types_model'); $this->load->model('content_types_model'); $type_id = $this->uri->segment(5); $data['breadcrumb'] = set_crumbs(array('content/types' => 'Content Types', 'content/fields/index/' . $type_id => 'Content Fields', current_url() => 'Field Edit')); $data['Type'] = $Type = $this->content_types_model->get_by_id($type_id); // Check if content type exists if (!$Type->exists()) { return show_404(); } $field_id = $this->uri->segment(6); // Edit mode if ($field_id) { $data['edit_mode'] = TRUE; $data['Field'] = $Field = $this->content_fields_model->include_related('content_field_types', 'model_name')->get_by_id($field_id); // Check if field exists if (!$Field->exists()) { return show_404(); } } // Get content field types for dropdown and a datatype refrence $Content_field_types = $this->content_field_types_model->order_by('title')->get(); $datatype_ref_array = option_array_value($Content_field_types, 'id', 'datatype'); $data['Content_field_types'] = option_array_value($Content_field_types, 'id', 'title'); // Get setting fields $this->load->add_package_path(APPPATH . 'modules/content/content_fields'); $Content_fields = $this->load->library('content_fields'); $data['setting_fields'] = $Content_fields->settings($Field); // Form Validation $this->form_validation->set_rules('content_field_type_id', 'Type', 'trim|required'); $this->form_validation->set_rules('label', 'Label', 'trim|required'); $this->form_validation->set_rules('required', 'Required', 'trim|required'); if ($data['edit_mode']) { $this->form_validation->set_rules('short_tag', 'Short Tag', 'trim|alpha_dash|required|callback_unique_short_tag[' . $Field->short_tag . ']'); } else { $this->form_validation->set_rules('short_tag', 'Short Tag', 'trim|alpha_dash|required|callback_unique_short_tag'); } if ($this->form_validation->run() == TRUE) { $this->load->model('content_fields_model'); $Content_fields = new Content_fields_model(); $Content_fields->from_array($this->input->post()); $Content_fields->content_type_id = $type_id; $Content_fields->short_tag = $this->input->post('short_tag'); // Setting fields $Content_fields->settings = $this->input->post('settings') ? serialize($this->input->post('settings')) : NULL; // Edit mode if ($field_id) { $Content_fields->id = $field_id; } $Content_fields->save(); // If new record add column to entries data and set sort if (!$data['edit_mode']) { // Set a sort number so that the field will be // added to the end of the fields list. // Setting it to its ID# ensures that it is greater than the other field's sort $Content_fields->sort = $Content_fields->id; $Content_fields->save(); } $this->load->library('cache'); $this->cache->delete_all('content_types'); $this->cache->delete_all('entries'); // There is probably a better way to go about getting the // field datatype but this should work for now $datatype = isset($datatype_ref_array[$Content_fields->content_field_type_id]) ? $datatype_ref_array[$Content_fields->content_field_type_id] : 'text'; $Content_fields->save_entries_column($datatype); $this->session->set_flashdata('message', '<p class="success">Content field saved successfully.</p>'); redirect(ADMIN_PATH . '/content/fields/index/' . $Type->id); } $this->template->view('admin/fields/edit', $data); }
function edit() { // Init $data = array(); $data['Navigation'] = $Navigation = $this->load->model('navigations_model'); $data['Navigation_item'] = $Navigation_item = $this->load->model('navigation_items_model'); $data['navigation_id'] = $navigation_id = $this->uri->segment(5); $data['breadcrumb'] = set_crumbs(array('navigations' => 'Navigations', 'navigations/items/tree/' . $navigation_id => 'Navigation Tree', current_url() => 'Navigation Item Edit')); $data['edit_mode'] = $edit_mode = FALSE; $item_id = $this->uri->segment(6); // Verify navigation exists $Navigation->get_by_id($navigation_id); if (!$Navigation->exists()) { return show_404(); } // Set mode if ($item_id) { $Navigation_item->get_by_id($item_id); if (!$Navigation_item->exists()) { return show_404(); } $data['edit_mode'] = $edit_mode = TRUE; } // Get all entries for link dropdown $this->load->model('content/entries_model'); $Pages = $this->entries_model->where('status', 'published')->where('slug !=', 'NULL')->or_where('id =', $this->settings->content_module->site_homepage)->order_by('title')->get(); $data['Pages'] = option_array_value($Pages, 'id', 'title', array('' => '')); // Form validation rules if ($this->input->post('type') == 'page') { $this->form_validation->set_rules('entry_id', 'Pages', 'trim|required'); $this->form_validation->set_rules('page_link_text', 'Link Text', 'trim'); } else { $this->form_validation->set_rules('title', 'Link Text', 'trim|required'); $this->form_validation->set_rules('url', 'URL', 'trim|required'); } $this->form_validation->set_rules('type', 'Link Type', 'trim|required'); $this->form_validation->set_rules('tag_id', 'Tag ID', 'trim'); $this->form_validation->set_rules('class', 'Class', 'trim'); $this->form_validation->set_rules('target', 'Target', 'trim'); $this->form_validation->set_rules('disable_current', 'Disable Current', 'trim'); $this->form_validation->set_rules('disable_current_trail', 'Disable Current Trail', 'trim'); if ($this->form_validation->run() == TRUE) { $Navigation_item->from_array($this->input->post()); $Navigation_item->navigation_id = $navigation_id; if ($this->input->post('type') == 'page') { $Navigation_item->title = $this->input->post('page_link_text') ? $this->input->post('page_link_text') : NULL; $Navigation_item->url = NULL; } else { if ($this->input->post('type') == 'dynamic_route') { $Navigation_item->url = trim($this->input->post('url'), '/'); } else { $Navigation_item->entry_id = NULL; } } $Navigation_item->tag_id = $this->input->post('tag_id') ? $this->input->post('tag_id') : NULL; $Navigation_item->class = $this->input->post('class') ? $this->input->post('class') : NULL; $Navigation_item->target = $this->input->post('target') ? $this->input->post('target') : NULL; $Navigation_item->hide = $this->input->post('hide') ? 1 : 0; $Navigation_item->disable_current = $this->input->post('disable_current') ? 1 : 0; $Navigation_item->disable_current_trail = $this->input->post('disable_current_trail') ? 1 : 0; $Navigation_item->save(); // Set the sort to the id if creating new item if (!$edit_mode) { $Navigation_item->sort = $Navigation_item->id; $Navigation_item->save(); } // Clear navigation cache so updates will show on next page load $this->load->library('navigations_library'); $this->navigations_library->clear_cache(); $this->session->set_flashdata('message', '<p class="success">Navigation Item Saved</p>'); redirect(ADMIN_PATH . "/navigations/items/tree/{$navigation_id}"); } $this->template->view('admin/items/edit', $data); }