Esempio n. 1
0
 public function __construct()
 {
     parent::__construct();
     // Set the validation rules
     $val_rules = array(array('field' => 'id'), array('field' => 'user_id'), array('field' => 'name', 'label' => 'lang:site.descriptive_name', 'rules' => 'trim|max_length[100]|required'), array('field' => 'domain', 'label' => 'lang:site.domain', 'rules' => 'trim|callback__valid_domain|max_length[100]|required'), array('field' => 'ref', 'label' => 'lang:site.ref', 'rules' => 'trim|alpha_dash|callback__underscore|min_length[1]|max_length[20]|required'), array('field' => 'username', 'label' => 'lang:user_username', 'rules' => 'trim|required'), array('field' => 'first_name', 'label' => 'lang:user_first_name', 'rules' => 'trim|required'), array('field' => 'last_name', 'label' => 'lang:user_last_name', 'rules' => 'trim|required'), array('field' => 'email', 'label' => 'lang:user_email', 'rules' => 'trim|required|valid_email'));
     $val_create = array(array('field' => 'password', 'label' => 'lang:user_password', 'rules' => 'trim|min_length[6]|required'));
     $val_edit = array(array('field' => 'password', 'label' => 'lang:user_password', 'rules' => 'trim'));
     $this->site_validation_rules = array_merge($val_rules, $this->method == 'create' ? $val_create : $val_edit);
 }
Esempio n. 2
0
	function __construct()
	{  
		parent::__construct();
		/* load lang */
		$this->lang->load('home'); 
			$this->load->model('produk_model', 'pm');

			$this->load->model('promo_model', 'pm2');
		/* load model */
	}
 public function __construct()
 {
     parent::__construct();
     $this->val_rules = array();
     $settings = $this->settings_m->get_settings();
     // set the validation rules dynamically
     foreach ($settings as $slug => $value) {
         $this->val_rules[] = array('field' => $slug, 'label' => lang('site.' . $slug), 'rules' => 'trim|required');
     }
 }
Esempio n. 4
0
 public function __construct()
 {
     parent::__construct();
     ci()->ref = $this->ref = $this->uri->segment(4);
     ci()->type = $this->type = $this->uri->segment(5);
     ci()->slug = $this->slug = $this->uri->segment(6);
     ci()->shared = $this->shared = (bool) $this->uri->segment(7);
     $this->db->set_dbprefix($this->ref . '_');
     $this->load->model('addons_m');
 }
Esempio n. 5
0
	function __construct(){  
		parent::__construct(); 
		/* load config */
		$this->load->config('conf_login');
		/* load lang */
		$this->lang->load('login');
		/* load model */
		$this->load->model('login_model', 'lm');

		/* to check system speed and query --> just for admin */
		//$this->output->enable_profiler(TRUE);
	}
Esempio n. 6
0
 public function __construct()
 {
     parent::__construct();
     // Set the validation rules
     $val_rules = array(array('field' => 'id'), array('field' => 'username', 'label' => 'lang:user_username', 'rules' => 'trim|required'), array('field' => 'email', 'label' => 'lang:user_email', 'rules' => 'trim|required|valid_email'));
     $val_create = array(array('field' => 'password', 'label' => 'lang:user_password', 'rules' => 'trim|' . 'min_length[' . config_item('min_password_length') . ']|' . 'max_length[' . config_item('max_password_length') . ']|' . 'required'), array('field' => 'confirm_password', 'label' => 'lang:user_confirm_password', 'rules' => 'trim|' . 'min_length[' . config_item('min_password_length') . ']|' . 'max_length[' . config_item('max_password_length') . ']|' . 'required|' . 'matches[password]'));
     $val_edit = array(array('field' => 'password', 'label' => 'lang:user_password', 'rules' => 'trim|matches[confirm_password]'), array('field' => 'confirm_password', 'label' => 'lang:user_confirm_password', 'rules' => 'trim|matches[password]'));
     if ($this->method == 'add') {
         $this->user_validation_rules = array_merge($val_rules, $val_create);
     } else {
         $this->user_validation_rules = array_merge($val_rules, $val_edit);
     }
     // login validation
     $this->login_rules = array(array('field' => 'email', 'label' => lang('email_label'), 'rules' => 'required|callback__check_login'), array('field' => 'password', 'label' => lang('password_label'), 'rules' => 'required'));
 }
Esempio n. 7
0
 function sites($app)
 {
     $app->get('/sites', function ($request, $response, $args) {
         $sites = new Sites_Controller();
         $skills = new Skills_Controller();
         $images = new Images_Controller();
         $return = ['auth' => $this->auth, 'user' => $this->user, 'sites' => $sites->getAll(), 'skills' => $skills->getAll(), 'images' => $images->getAll()];
         return $this->view->render($response, 'sites.html', $return);
     });
     $app->post('/sites/add', function ($request, $response, $args) {
         $sites = new Sites_Controller();
         $sites->add($request, $response, $args);
         // maybe I need to use flash messages
         //http://help.slimframework.com/discussions/problems/12059-how-to-display-flash-message-in-twig-view
         // https://github.com/slimphp/Slim-Flash
         // only works in v2
         //$app->redirect('/skills');
         return $response->withStatus(302)->withHeader('Location', '/sites');
     });
     $app->get('/sites/edit', function ($request, $response, $args) {
         $sites = new Sites_Controller();
         $site = $sites->getSite($request, $response, $args);
         $skills = new Skills_Controller();
         $skills = $skills->getAll();
         $images = new Images_Controller();
         $images = $images->getAll();
         foreach ($skills as &$skill) {
             foreach ($site['skills'] as $siteSkill) {
                 if ($siteSkill['id'] == $skill['id']) {
                     $skill['inUse'] = true;
                 }
             }
         }
         foreach ($images as &$image) {
             foreach ($site['images'] as $siteImage) {
                 if ($siteImage['id'] == $image['id']) {
                     $image['inUse'] = true;
                 }
             }
         }
         $return = ['auth' => $this->auth, 'user' => $this->user, 'site' => $site, 'skills' => $skills, 'images' => $images];
         return $this->view->render($response, '/forms/editSites.html', $return);
     });
     $app->post('/sites/edit', function ($request, $response, $args) {
         $sites = new Sites_Controller();
         $site = $sites->edit($request, $response, $args);
         return $response->withStatus(302)->withHeader('Location', '/sites');
     });
     $app->post('/sites/delete', function ($request, $response, $args) {
         $sites = new Sites_Controller();
         $sites->delete($request, $response, $args);
         return $response->withStatus(302)->withHeader('Location', '/sites');
     });
     return $app;
 }
Esempio n. 8
0
 public function sites()
 {
     $body = $this->response->getBody();
     $sites = new Sites_Controller();
     $body->write(json_encode($sites->getAll()));
 }