public function __construct() { parent::__construct(); ci()->load->model(['dropdown_models/dropdown_parent_model', 'dropdown_models/dropdown_item_model']); $this->dropdown_parent_model =& ci()->dropdown_parent_model; $this->dropdown_item_model =& ci()->dropdown_item_model; }
public function __construct() { parent::__construct(); if (setting('email-templates.required') == 'plain') { $this->rules['plain']['rules'] = 'required|' . $this->rules['plain']['rules']; } if (setting('email-templates.required') == 'html') { $this->rules['html']['rules'] = 'required|' . $this->rules['html']['rules']; } if (setting('email-templates.required') == 'plain & html') { $this->rules['plain']['rules'] = 'required|' . $this->rules['plain']['rules']; $this->rules['html']['rules'] = 'required|' . $this->rules['html']['rules']; } /* listen for update or insert and switch up the date/times */ ci()->event->register('database.addon_email_templates.before.update', function (&$method, &$primary_value, &$data, &$skip_validation) { if (!empty($data['active_from']) || !empty($data['active_to'])) { $data['active_from'] = date('Y-m-d H:i:s', strtotime($data['active_from'])); $data['active_to'] = date('Y-m-d H:i:s', strtotime($data['active_to'])); } }); ci()->event->register('database.addon_email_templates.before.insert', function (&$method, &$primary_value, &$data, &$skip_validation) { if (!empty($data['active_from']) || !empty($data['active_to'])) { $data['active_from'] = date('Y-m-d H:i:s', strtotime($data['active_from'])); $data['active_to'] = date('Y-m-d H:i:s', strtotime($data['active_to'])); } }); }
public function __construct() { parent::__construct(); ci()->validate->attach('must_be_1', function ($field_data, $field, $param, $validate_obj) { $validate_obj->set_message('must_be_1', 'The Trigger time format is not valid.'); return (int) $field_data['trigger_valid'] == 1; }); }
public function __construct() { parent::__construct(); /* used to flatten out the multi select array */ ci()->validate->attach('category_join', function (&$_field_data, &$field, &$param, &$validation) { if (is_array($field)) { $field = ' ' . implode(' ', $field) . ' '; } }); }
public function __construct() { parent::__construct(); if (!($this->caches[$this->cache_prefix] = $this->cache->get($this->cache_prefix))) { $query = $this->get_many_by('active', 1); foreach ((array) $query as $row) { $this->caches[$this->cache_prefix][$row->match] = $row->url; } $this->cache->save($this->cache_prefix, $this->caches[$this->cache_prefix], get_ttl()); } }
public function __construct() { parent::__construct(); /* attach a custom validation function onto validate library */ $this->load->library('validate'); $this->validate->attach('password', function ($field_data, $field, $param, $validate_obj) { /* field data, current field, current field param, validation object */ $validate_obj->set_message('password', 'Your password is not in the correct format.'); return (bool) preg_match(setting('auth', 'Password regex'), $field); }); /* setup the rules from the config */ $this->rules['username']['rules'] .= '|min_length[' . setting('auth', 'Username Min Length') . ']|max_length[' . setting('auth', 'Username Max Length') . ']|filter_input[' . setting('auth', 'Username Max Length') . ']'; /* does the username need to be unquie? */ if (!setting('auth', 'Allow Same Username')) { $this->rules['username']['rules'] .= '|is_uniquem[o_user_model.username.id]'; } if (!setting('auth', 'Allow Same Email')) { $this->rules['email']['rules'] .= '|is_uniquem[o_user_model.email.id]'; } }
public function __construct() { parent::__construct(); ci()->validate->attach('save_as_file', function (&$_field_data, &$field, &$param, $validate) { $folder = __DIR__ . '/../saved'; if ($_field_data['is_file'] == 1) { if (is_writable(__DIR__ . '/..')) { @mkdir($folder, 0777); file_put_contents($folder . '/' . $_field_data['name'] . '.tmpl', $field); } } else { @unlink($folder . '/' . $_field_data['name'] . '.tmpl'); } }); ci()->event->register('database.cms_templates.after.get', function (&$method, &$result) { $filename = __DIR__ . '/../saved/' . $result->name . '.tmpl'; if ($result->is_file && file_exists($filename)) { $result->content = file_get_contents($filename); } }); }