0byt3m1n1-V2
Path:
/
home
/
nlpacade
/
www
/
arcaneoverseas.com
/
application
/
controllers
/
admin
/
[
Home
]
File: user.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class User extends CI_Controller { /** * Index Page for this controller. * * Maps to the following URL * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * Since this controller is set as the default controller in * config/routes.php, it's displayed at http://example.com/ * * So any other public methods not prefixed with an underscore will * map to /index.php/welcome/<method_name> * @see http://codeigniter.com/user_guide/general/urls.html */ /* * Doctrine EntityManager */ public $em; /* * constructeur */ public function __construct() { parent::__construct(); /* Session controle */ if ($this->session->userdata("logged_in") != true) redirect('admin/login/index'); /* Standard Libraries */ $this->layout->set_theme('admin/interne_page'); //Instantiate a Doctrine Entity Manager $this->em = $this->doctrine->em; /* Standard Libraries */ $this->load->database(); $this->load->helper('url'); /* Load Crud */ $this->load->library('grocery_CRUD'); } public function index() { $data = array(); $crud = new grocery_CRUD(); $crud->where('profils_id', '1'); $crud->set_table('users'); $crud->set_relation('profils_id', 'profils', 'nom'); $crud->display_as('profils_id', 'Profil'); //$crud->required_fields('nom', 'password', 'email'); $crud->set_field_upload('photo', 'assets/uploads/images_profil'); $crud->columns('nom', 'prenom', 'etat'); $crud->change_field_type('profils_id', 'hidden', '1'); $crud->callback_after_upload(array($this, 'resizeImage')); $crud->callback_field('etat', array($this, 'callback_active')); $crud->change_field_type('password', 'password'); //$crud->callback_insert(array($this, 'cleanUrl')); //$crud->callback_update(array($this, 'cleanUrlAndUpdate')); $crud->callback_before_insert(array($this, 'encrypt_password_callback')); $crud->callback_before_update(array($this, 'encrypt_password_callback')); $output = $crud->render(); $output->title_module = "Gérer Administrateurs"; $output->ariane = '<a href="">Accueil</a> > <a href="">Configuration du site</a> > Gérer Administrateurs'; $this->layout->views('admin/session_user') ->views('admin/header') ->views('admin/nav') ->view('admin/view_standart', $output); } /** * * * @param array $post_array * @param type $primary_key * @return type */ function encrypt_password_callback($post_array, $primary_key = null) { $post_array['password'] = md5($post_array['password']); return $post_array; } /** * * @param type $value * @return type */ public function callback_active($value = NULL) { $options = array('oui', 'non'); $option_tag = ''; foreach ($options as $option) { $attribute = 'value="' . $option . '"'; if ($option == $value) { $attribute .= ' selected="selected"'; } $option_tag .= "<option $attribute>$option</option>"; } return '<select name="etat">' . $option_tag . '</select>'; } /** * * @param type $uploader_response * @param type $field_info * @param type $files_to_upload * @return boolean */ public function resizeImage($uploader_response, $field_info, $files_to_upload) { $this->load->library('image_moo'); //Is only one file uploaded so it ok to use it with $uploader_response[0]. $file_uploaded = $field_info->upload_path . '/' . $uploader_response[0]->name; $file_uploaded_thamb = $field_info->upload_path . '/thamb/' . $uploader_response[0]->name; $file_uploaded_contenu = $field_info->upload_path . '/contenu/' . $uploader_response[0]->name; $pic = $this->image_moo->load($file_uploaded); $pic->resize(900, 700)->save($file_uploaded, true); $pic->resize(640, 377)->save($file_uploaded_contenu, true); $pic->resize(100, 100)->save($file_uploaded_thamb, true); return true; } } /* End of file welcome.php */ /* Location: ./application/controllers/welcome.php */
©
2018.