public function LoginParticulier() { $this->mLayout = "empty"; $this->mTheme = 'login-page'; $this->mViewFile = 'loginparticulier'; if (validate_form()) { $username = $this->input->post('username'); $password = $this->input->post('password'); $this->load->model('User_model', 'user_model'); $user = $this->user_model->get_by('email', $username); // only admin and staff can login /*if ( verify_role(['admin', 'staff'], $user) ) {*/ // password correct if (verify_pw($password, $user['password'])) { // limited fields to store in session $fields = array('id', 'role', 'email', 'first_name', 'last_name', 'created_at'); $user_data = elements($fields, $user); login_user($user); // success set_alert('success', 'Connexion réussie'); redirect('home'); exit; } //} // failed set_alert('danger', 'Nom d\'utilisateur ou Mot de passe incorrect'); redirect('/login/Loginparticulier'); } }
public function Cadastrar() { $Endereco = elements(array('logradouro', 'bairro', 'numero', 'cep', 'idCidade'), $this->input->post()); $this->form_validation->set_rules('logradouro', 'Logradouro', 'trim|required|max_length[45]|ucwords|'); //$this->form_validation->set_message('is_unique', "O endereço ". $Endereco['logradouro'] ." já existe."); //Verifica se o formmulário é válido if ($this->form_validation->run()) { //Pega os campos e recebe os valores do post $dados = elements(array('logradouro', 'bairro', 'numero', 'cep'), $this->input->post()); $dados['idCidade'] = $this->input->post('cidade'); //setando flagAtivo para True //$dados['flagAtivo'] = 1; $this->ClienteModel->insertEndereco($dados); } else { $this->session->set_flashdata('erro', 'Endereç já existe!'); } /*$dados = array( 'pasta' => 'lojaCliente', 'view' => 'clienteEndereco', 'Estado' => $this->ClienteModel->getAllEstado(), //'cidade' => $this->ClienteModel->getAllCidade()->result(), ); $this->load->view('Principal', $dados);*/ }
public function index() { $this->mLayout = "empty"; $this->mTheme = 'login-page'; $this->mViewFile = 'login'; if (validate_form()) { $username = $this->input->post('username'); $password = $this->input->post('password'); $this->load->model('Backend_user_model', 'backend_users'); $user = $this->backend_users->get_by('username', $username); // only admin and staff can login if (verify_role(['admin', 'staff-1', 'staff-2', 'staff-3'], $user)) { // password correct if (verify_pw($password, $user['password'])) { // limited fields to store in session $fields = array('id', 'role', 'username', 'full_name', 'created_at'); $user_data = elements($fields, $user); login_user($user); // success set_alert('success', 'Login success'); redirect('home'); exit; } } // failed set_alert('danger', 'Invalid Login'); redirect('login'); } }
function create_tour($data) { if ($data['tour_type'] == 'Manual') { $data['from_start_time'] = date('Y-m-d', strtotime(element('from_start_date', $data))) . ' ' . element('from_start_time', $data); $crop_data = elements(array('from', 'to', 'available_seats', 'start_price', 'from_start_time'), $data); $add_tour = $this->db->insert_string('tours', $crop_data); $this->db->query($add_tour); } elseif ($data['tour_type'] == 'Automatic') { $startDate = date('Y-m-d', strtotime($data['automatic_from'])); $endDate = date('Y-m-d', strtotime($data['automatic_until'])); if ($data['automatic_day'] == 'Day') { for ($i = strtotime($startDate); $i <= strtotime($endDate); $i = strtotime('+1 day', $i)) { $data['from_start_time'] = date('Y-m-d', $i) . ' ' . element('automatic_time', $data); // date('Y-m-d', strtotime(element('from_start_date', $data))). ' ' .element('from_start_time', $data); $crop_data = elements(array('from', 'to', 'available_seats', 'start_price', 'from_start_time'), $data); $add_tour = $this->db->insert_string('tours', $crop_data); $this->db->query($add_tour); } } else { for ($i = strtotime($data['automatic_day'], strtotime($startDate)); $i <= strtotime($endDate); $i = strtotime('+1 week', $i)) { $data['from_start_time'] = date('Y-m-d', $i) . ' ' . element('automatic_time', $data); // date('Y-m-d', strtotime(element('from_start_date', $data))). ' ' .element('from_start_time', $data); $crop_data = elements(array('from', 'to', 'available_seats', 'start_price', 'from_start_time'), $data); $add_tour = $this->db->insert_string('tours', $crop_data); $this->db->query($add_tour); } } } else { die('Incorrect tour type! Contact administrator'); } }
function create_tour($data) { $data['from_start_time'] = date('Y-m-d', strtotime(element('from_start_date', $data))) . ' ' . element('from_start_time', $data); $crop_data = elements(array('from', 'to', 'available_seats', 'start_price', 'from_start_time'), $data); $add_tour = $this->db->insert_string('tours', $crop_data); $this->db->query($add_tour); }
public function gerenciar_configuracoes() { esta_logado(TRUE); if ($this->input->post('salvar')) { if (verifica_adm(TRUE)) { $upload = $this->midia_model->fazer_upload('arquivo'); $configuracoes = elements(array('nome_site', 'url_logomarca', 'email_adm'), $this->input->post()); foreach ($configuracoes as $nome_config => $valor_config) { define_config($nome_config, $valor_config); } define_msg('configok', 'Configurações atualizadas com sucesso.', 'sucesso'); redirect('configuracoes/gerenciar_configuracoes'); } else { redirect('configuracoes/gerenciar_configuracoes'); } } //vai carregar o modulo usuarios e mostrar a tela de recuperação de senha set_tema('footerinc', '<script> $(document).ready(function() { App.init(); }); </script>', FALSE); set_tema('titulo', 'Configuração do Sistema'); set_tema('conteudo', load_modulo('configuracoes', 'gerenciar')); set_tema('rodape', ''); //vai substituir o rodape padrao load_template(); }
public function index() { $errors = FALSE; if ($this->input->method(TRUE) === 'GET') { $this->generate_page('register', ['errors' => $errors]); } else { $this->load->model('Account_model', 'account'); $this->load->helper(['string', 'array']); $this->form_validation->set_rules('username', 'Username', 'required|is_unique[account.username]|regex_match[/^(?=.{8,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$/]'); $this->form_validation->set_rules('firstname', 'First Name', 'required'); $this->form_validation->set_rules('lastname', 'Last Name', 'required'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[account.email]'); $this->form_validation->set_rules('contact_number', 'Contact Number', 'required|exact_length[11]|is_unique[account.contact_number]'); $this->form_validation->set_rules('password', 'Password', 'required'); $this->form_validation->set_rules('confirm_password', 'Confirm Password', 'required|matches[password]'); if ($this->form_validation->run() == FALSE) { $errors = array_values($this->form_validation->error_array()); $this->generate_page('register', ['errors' => $errors]); } else { $input = $this->input->post(); $account = elements(['username', 'firstname', 'lastname', 'email', 'contact_number'], $input); $account['password_salt'] = uniqid(); $account['password_hash'] = md5($input['password'] . $account['password_salt']); $account['verification_code'] = random_string('alnum', 6); if ($this->account->add($account)) { $this->session->set_flashdata('infos', ['Account created.', 'Please check your email for verification link.']); redirect('login'); } else { $this->generate_page('register', ['errors' => 'Account creation failed.']); } } } }
/** * The call for editing a package * @param string $package_name The name of the package to edit * @todo Permission validation is in place, but check that the user has permission to * edit in the first place */ public function edit($package_name) { $this->load->model('spark'); $this->load->model('contributor'); $this->load->library('form_validation'); $this->load->helper('form_helper'); $submit = $this->input->post('submit'); $spark_id = $this->input->post('spark_id'); $success = FALSE; if ($submit) { if ($this->form_validation->run('edit-package')) { $update = elements(array('name', 'summary', 'description', 'website', 'repository_type', 'base_location', 'fork_id', 'is_browse'), $_POST); Spark::update($spark_id, $update); UserHelper::setNotice("This spark has been updated. Thanks again, you're awesome."); $success = TRUE; } else { UserHelper::setNotice("Whoops, there were some errors...", FALSE); } } if ($success) { $spark = Spark::getInfo($update['name']); } else { $spark = Spark::getInfo($package_name); } if (!$spark) { show_404(); } $data = array(); $data['sparkslist'] = Spark::get_index_list(); $data['contribution'] = $spark; $this->load->view('packages/edit', $data); }
public function editar($id) { if (!$id) { $this->session->set_flashdata('msg', '<div class="error">El pais solicitado no existe.</div>'); redirect('paises'); } elseif ($_POST) { $this->load->helper('date'); $this->load->library('Utils'); $pais = Country::find($id); $pais->update_attributes(elements(array('pais'), $_POST)); if ($pais->is_valid()) { if ($pais->save()) { $this->session->set_flashdata('msg', '<div class="success">El pais se guardó correctamente.</div>'); redirect('paises'); } else { $this->session->set_flashdata('msg', '<div class="error">Hubo un error al guardar los datos.</div>'); redirect('paises/editar/' . $id); } } else { $data['errors'] = $pais->errors; } } else { $data['a'] = Country::find($id); } $data['titulo'] = "Editar pais"; $data['action'] = "paises/editar/" . $id; $this->template->write_view('content', 'paises/agregar', $data); $this->template->render(); }
public function edit() { $this->Purview_model->checkPurviewAjax($this->tablefunc, 'edit'); $post = $this->input->post(NULL, TRUE); if ($post['id'] && $post['action'] == site_aurl($this->tablefunc)) { if ($this->Data_model->getSingle(array('username' => $post['username'], 'id !=' => $post['id']))) { show_jsonmsg(array('status' => 206)); } $time = time(); $data = elements($this->fields, $post); $data['updatetime'] = $time; if ($post['password'] != '') { $this->load->helper('string'); $salt = random_string('alnum', 6); $data['password'] = md5pass($post['password'], $salt); $data['salt'] = $salt; } $datawhere = array('id' => $post['id']); $this->Data_model->editData($datawhere, $data); show_jsonmsg(array('status' => 200, 'id' => $post['id'], 'remsg' => $this->_setlist($this->Data_model->getSingle(array('id' => $post['id'])), false))); } else { $id = $this->uri->segment(4); if ($id > 0 && ($view = $this->Data_model->getSingle(array('id' => $id)))) { $res = array('tpl' => 'view', 'tablefunc' => $this->tablefunc, 'view' => $view, 'usergroup' => $this->Data_model->getData(array('status' => 1), 'listorder', 0, 0, 'usergroup')); show_jsonmsg(array('status' => 200, 'remsg' => $this->load->view($this->tablefunc, $res, true))); } else { show_jsonmsg(array('status' => 203)); } } }
public function editar($id) { if (!$id) { $this->session->set_flashdata('msg', '<div class="error">El tutor solicitado no existe.</div>'); redirect('tutores'); } elseif ($_POST) { $this->load->helper('date'); $this->load->library('Utils'); $insert = $_POST; $insert['fecha_nacimiento'] = $this->utils->fecha_formato('%Y-%m-%d', $insert['fecha_nacimiento']); $insert['fecha_inscripcion'] = $this->utils->fecha_formato('%Y-%m-%d', $insert['fecha_inscripcion']); $tutor = Student::find($id); $tutor->update_attributes(elements(array('city_id', 'nombre', 'apellido', 'fecha_nacimiento', 'sexo', 'tipo_documento', 'nro_documento', 'domicilio', 'tenencia', 'nacionalidad', 'grupo_sanguineo', 'telefono', 'celular', 'obs_medicas', 'observaciones', 'colegio_procedencia', 'fecha_inscripcion'), $insert)); if ($tutor->is_valid()) { if ($tutor->save()) { $this->session->set_flashdata('msg', '<div class="success">El tutor se guardó correctamente.</div>'); redirect('tutores/editar/' . $id); } else { $this->session->set_flashdata('msg', '<div class="error">Hubo un error al guardar los datos.</div>'); redirect('tutores/editar/' . $id); } } else { $data['errors'] = $tutor->errors; } } else { $data['a'] = Student::find($id); } $data['paises'] = Country::all(); $data['provincias'] = State::all(); $data['ciudades'] = City::all(); $data['titulo'] = "Editar tutor"; $data['action'] = "tutores/editar/" . $id; $this->template->write_view('content', 'tutores/agregar', $data); $this->template->render(); }
public function pagination($opts = array()) { $config = $this->application->get_config('pagination', 'pagination'); $config = array_merge($config, elements(array_keys($config), $opts), array('use_page_numbers' => (bool) element('use_page_numbers', $opts) ? 'true' : 'false', 'page_query_string' => (bool) element('page_query_string', $opts) ? 'true' : 'false', 'display_pages' => (bool) element('display_pages', $opts) ? 'true' : 'false')); $this->pagination->initialize($config); return $this->pagination->create_links(); }
public function logar() { $this->form_validation->set_rules('login', 'Login', 'trim|required|max_length[20]'); $this->form_validation->set_rules('senha', 'Senha', 'trim|required|strtolower'); //Verifica se os campo foi preenchido corretamente e retorna true para a validação if ($this->form_validation->run()) { //Pega os valores que esta no post e transforma em array $dados = elements(array('login', 'senha'), $this->input->post()); //Verifica se os dados estão validos enviando os valores para a model if ($this->LoginModel->doValidate($dados)) { //Retorna todas as informações do usuario $dados = $this->LoginModel->getUsuario($dados); //Dados de sessão do usuario $session = array('id' => $dados[0]['idLogin'], 'nivelAcesso' => $dados[0]['nivelAcesso'], 'login' => $dados[0]['login'], 'is_logged_in' => true); //Enviar os dados para a view $this->session->set_userdata($session); //Redireciona para a pagina principal redirect('admin'); } else { //Redireciona para a tela de login $this->session->set_flashdata('loginInvalido', 'Usuário ou Senha invalidos.'); redirect('admin/login'); } } else { //Redireciona para a tela de login $this->session->set_flashdata('loginVazio', 'Campo(s) obrigatório(s) não preenchido(s).'); redirect('admin/login'); } }
public function editar() { esta_logado(); $this->form_validation->set_message('matches', 'Por favor selecione um solicitante'); $this->form_validation->set_rules('titulo', 'Titulo', 'required'); if ($this->form_validation->run() == TRUE) { $dados = elements(array(), $this->input->post()); $upload = $this->slideshows->do_upload('foto'); $dados = elements(array(), $this->input->post()); @($dados['foto'] = $upload['file_name']); if ($dados['foto'] == '<') { $dados = elements(array('titulo', 'link'), $this->input->post()); $this->slideshows->do_update($dados, array('id' => $this->input->post('idslideshows'))); } else { if (is_array($upload) && $upload['file_name'] != '') { $dados = elements(array(), $this->input->post()); $dados['foto'] = $upload['file_name']; $this->slideshows->do_update($dados, array('id' => $this->input->post('idslideshows'))); } else { set_msg('msgerro', $upload, 'erro'); redirect(current_url()); } } } set_tema('titulo', 'Alteração de mídia'); set_tema('conteudo', load_modulo('slideshows', 'editar')); load_template(); }
public function add_announcement() { $infos = isset($_SESSION['infos']) ? $_SESSION['infos'] : FALSE; $errors = isset($_SESSION['errors']) ? $_SESSION['errors'] : FALSE; if ($this->input->method(TRUE) === 'GET') { $this->generate_page('super-admin/announcement-add', ['infos' => $infos, 'errors' => $errors]); } else { $this->form_validation->set_rules('title', 'Title', 'required'); $this->form_validation->set_rules('description', 'Description', 'required'); if ($this->form_validation->run() == FALSE) { $errors = array_values($this->form_validation->error_array()); $this->generate_page('super-admin/announcement-add', ['infos' => $infos, 'errors' => $errors]); } else { $input = $this->input->post(); $this->load->helper('array'); $announcement = elements(['title', 'description'], $input); if ($this->miscellaneous->add_announcement($announcement)) { $infos = ["Announcement added ({$announcement['title']})."]; } else { $errors = ['Announcement addition failed.']; } $this->generate_page('super-admin/announcement-add', ['infos' => $infos, 'errors' => $errors]); } } }
public function confirmar($sip,$cod){ $this->form_validation->set_error_delimiters('<span style="color:red">', '</span>'); $this -> form_validation ->set_rules('situacao','Resposta','required|trim'); $this -> form_validation ->set_rules('justificativa','Justificativa','trim|max_length[100]'); if ($this->form_validation->run() == FALSE) { $session_data = $this->session->userdata('logged_autrz'); $this->load->view('autorizar/autorizar_view',$session_data); } else { $dados=elements(array('situacao'), $this ->input->post()); if($dados['situacao']=='negado')://se for negado apresentar justificativa $dados['justificativa'] = $this ->input->post('justificativa'); endif; $this->inscricao_m->atualizar_do($dados,array('codinscricao' => $this->uri->segment(4))); $this->load->view('autorizar/autorizar_view',$session_data); } }
public function edit() { $this->Purview_model->checkPurviewAjax($this->tablefunc, 'edit'); $post = $this->input->post(NULL, TRUE); if ($post['id'] && $post['action'] == site_aurl($this->tablefunc)) { $data = elements($this->fields, $post); $data['updatetime'] = time(); $data['puttime'] = human_to_unix($post['puttime']); $data['uid'] = $this->session->userdata('uid'); $data['tags'] = $this->Tags_model->loadTagIds($post['tags'], $this->editlang); $data['recommends'] = isset($post['recommends']) && $post['recommends'] ? implode(',', $post['recommends']) : ''; $this->Data_model->editData(array('id' => $post['id']), $data); $category = $this->Data_model->getSingle(array('id' => $data['category']), 'category'); $cachefile = $category['model'] . '/detail_' . $this->editlang . '_' . $category['dir'] . '_' . $post['id']; if (file_exists('data/cache/' . $cachefile)) { $this->Cache_model->delete($cachefile); } $this->Cache_model->deleteSome($this->tablefunc . '_' . $this->editlang); $this->Cache_model->deleteSome('recommend_' . $this->editlang . '_' . $this->tablefunc); $this->Cache_model->deleteSome($category['dir'] . '/related_' . $this->editlang . '_' . $post['id']); show_jsonmsg(array('status' => 200, 'id' => $post['id'], 'remsg' => $this->_setlist($this->Data_model->getSingle(array('id' => $post['id'])), false))); } else { $id = $this->uri->segment(4); if ($id > 0 && ($view = $this->Data_model->getSingle(array('id' => $id)))) { $res = array('tpl' => 'view', 'tablefunc' => $this->tablefunc, 'view' => $view, 'categoryarr' => $this->categoryarr, 'recommendarr' => $this->recommendarr, 'recommends' => $view['recommends'] == '' ? array() : explode(',', $view['recommends']), 'tags' => $this->Tags_model->loadTags($view['tags'], $this->editlang)); show_jsonmsg(array('status' => 200, 'remsg' => $this->load->view($this->tablefunc, $res, true))); } else { show_jsonmsg(array('status' => 203)); } } }
public function create() { $this->form_validation->set_rules('categoria', 'CATEGORIA', 'required'); $this->form_validation->set_message('required', 'Escolha um tipo de equipamento!'); //VERIFICA SE O USUÁRIO ESCOLHEU UMA CATEGORIA, ÚNICO CAMPO QUE NÃO VEM VALOR PADRÃO. if ($this->form_validation->run() == TRUE) { $dados = elements(array('iddisciplina', 'idsala', 'datareserva', 'horainicio', 'periodo', 'categoria'), $this->input->post()); //PRA CADA CATEGORIA SELECIONADA foreach ($categoria as $linha) { //SELECIONO TODOS OS EQUIPAMENTOS DELA $listaEquipamentos = $this->Reserva->getEquipamento_byCategoria($linha)->result(); foreach ($listaEquipamentos as $equipamento) { //VERIFICO UM POR UM SE POSSUI RESERVA if ($this->Reserva->verificaReservado($equipamento->idequipamento, $dados) == NULL) { //SE NÃO POSSUIR SALVO EM UM ARRAY. INDICE = IDCATEGORIA, CONTEUDO = IDEQUIPAMENTO $disponivel[$linha] = $equipamento->idequipamento; } else { //SE POSSUIR RESERVA ENVIO IDCATEGORIA NA MENSAGEM $this->session->set_flashdata('indisponivel', 'Equipamento tipo ' . $linha . ' indisponível!'); redirect('equipamentos/create'); } } } //SE PRA CADA CATEGORIA SELECIONA POSSUIR UM EQUIPAMENTO LIVRE VAI SAIR DOS DOIS FOREACH //ENVIANDO O ARRAY DADOS PARA TABELA 'RESERVA' E O DISPONIVEL PARA 'RESERVAEQUIPAMENTO' $this->Reserva->do_insert($dados, $disponivel); } else { $data_template = array('dateMin' => date('Y-m-d', strtotime('+2 day')), 'dateMax' => date('Y-m-d', strtotime('+2 week')), 'selectDisciplina' => $this->Reserva->getDisciplina($this->session->idprofessor)->result(), 'selectSala' => $this->Reserva->getSala()->result(), 'checkboxCategoria' => $this->Reserva->getCategoria()->result(), 'controller' => strtolower($this->router->fetch_class()), 'page' => $this->router->fetch_method()); $this->load->view('template', $data_template); } }
public function Cliente() { $cpf = elements(array('nome', 'cpf', 'email', 'dataNascimento'), $this->input->post()); $this->form_validation->set_rules('nome', 'Nome', 'trim|required|max_length[45]|ucwords'); $this->form_validation->set_message('is_unique', "O cpf " . $cpf['cpf'] . " já existe."); //Verifica se o formmulário é válido if ($this->form_validation->run()) { //Pega os campos e recebe os valores do post $dados = elements(array('nome', 'cpf', 'email', 'dataNascimento', 'dataCadastro', 'flagAtivo', 'idEndereco', 'idTelefone', 'idSexo', 'idLogin'), $this->input->post()); $dados['idEndereco'] = $this->input->post('enderecoPost'); $dados['idTelefone'] = $this->input->post('telefonePost'); $dados['idLogin'] = $this->input->post('loginPost'); $dados['dataCadastro'] = date('Y-m-d'); $dados['flagAtivo'] = 1; $this->ClienteModel->insertCadastrar($dados); } else { $this->session->set_flashdata('erro', 'cadastrar já existe!'); } /*$dados = array( 'pasta' => 'lojaCliente', 'view' => 'clienteCadastrar', 'sexo' => $this->ClienteModel->getAllSexo()->result(), ); $this->load->view('Principal', $dados);*/ }
public function run($post_opts = array()) { $config = $this->application->get_config(element('action', $post_opts), 'actions'); $post_data = array_merge(clean_parameters($config), clean_parameters(elements(array_keys($config), $post_opts))); $response = array(); $start = microtime(true); $this->curl->create(element('server', $post_opts)); $this->curl->option('buffersize', 10); $this->curl->option('useragent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)'); $this->curl->option('returntransfer', true); $this->curl->option('followlocation', true); $this->curl->option('connecttimeout', true); $this->curl->post($post_data); $data = $this->curl->execute(); $this->response_time = round(microtime(true) - $start, 3) . " seconds"; if ($data !== false) { if (strcasecmp(element('responseformat', $post_opts), 'json') == 0) { $response = json_decode($data, true); } else { $response = $data; } $this->set_message('call_search_success'); } else { $this->set_error('call_search_error'); } $this->curl->close(); return $response; }
public function update() { //inicio: validacao do form //Copiados da função CREATE, porém com algumas alterações... $this->form_validation->set_rules('nome', 'NOME', 'trim|required|max_length[50]|ucwords'); //Esta linha foi comentada para não extender a aula, mas deve-se fazer uma regra para este update... // $this->form_validation->set_message('is_unique', 'Este %s já está cadastrado no sistema'); //Configurar antes a msg. Ao executar, a msg volta ao padrão // $this->form_validation->set_rules('email', 'EMAIL', 'trim|required|max_length[50]|strtolower|valid_email|is_unique[curso_ci.email]'); // $this->form_validation->set_rules('login', 'LOGIN', 'trim|required|max_length[25]|strtolower|is_unique[curso_ci.login]'); $this->form_validation->set_rules('senha', 'SENHA', 'trim|required|strtolower'); //será convertido em MD5...então não há necessidade desta regra: max_length[32] $this->form_validation->set_message('matches', 'O campo %s está diferente do campo %s'); //Configurar antes a msg. Ao executar, a msg volta ao padrão $this->form_validation->set_rules('senha2', 'REPITA A SENHA', 'trim|required|strtolower|matches[senha]'); //será convertido em MD5...então não há necessidade desta regra: max_length[32] //fim: validacao do form if ($this->form_validation->run() == TRUE) { //se a validação passar, então insiro no banco com método post $dados = elements(array('nome', 'senha'), $this->input->post()); //o metodo post() é o mesmo que fazer: $_POST $dados['senha'] = md5($dados['senha']); //criptografa a senha com MD5 $this->crud_model->do_update($dados, array('id' => $this->input->post('idusuario'))); //Chamo o método da classe MODEL que faz o insert } $dados = array('titulo' => 'CRUD » Update', 'tela' => 'update'); $this->load->view('crud', $dados); }
/** * 修改点信息 */ function updatePoint($info_id) { $jsonStr = $this->post['json']; $post_data = json_decode($jsonStr, true); $data = elements($this->fields, $post_data); $this->map_info->updateInfo($info_id, $data); output_jsonmsg_succ($info_id); }
function ingresarNuevoParametroAgenda($d) { $insert = elements(array('horaInicio', 'horaFin', 'aplica_sabado', 'aplica_domingo'), $d); $insert['activo'] = 1; $insert['aplica_sabado'] = $insert['aplica_sabado'] == '' ? 0 : 1; $insert['aplica_domingo'] = $insert['aplica_domingo'] == '' ? 0 : 1; $this->db->insert('agenda_parametros', $insert); }
public function _format_data($mode) { $input = elements(['name', 'class', 'acquisition_method', 'acquisition_state', 'estimated_cost', 'beginning_quantity', 'details', 'is_disposed'], $this->input->post(), NULL); if ($mode === MODE_CREATE) { $input['created_by'] = user_id(); unset($input['is_disposed']); } return $input; }
protected function findModelNameByUrl($t) { $models = array("books" => "UserBook", "lists" => "UserList", "roles" => "UserRole", "statuses" => "OrderStatus", "payment" => "OrderPyment", "shipping" => "OrderShipping", "discounts" => "UserDiscount", "bills" => "OrderBill", "jobs" => null, "etc" => null); if (!array_key_exists($t, $models)) { return elements($t); } if (isset($models[$t])) { return elements($models[$t]); } }
public function testElements() { $array = ['color' => 'red', 'shape' => 'round', 'radius' => '10', 'diameter' => '20']; $output = elements(array('color', 'shape', 'height'), $array); $this->assertArrayHasKey('color', $output); $this->assertArrayHasKey('shape', $output); $this->assertArrayHasKey('height', $output); $output = elements(array('color', 'shape', 'height'), $array, 'foobar'); $this->assertArrayHasKey('height', $output); }
public function update() { $this->form_validation->set_rules('descricaocategoria', 'DESCRIÇÃO', 'trim|required|max_length[15]|ucwords'); if ($this->form_validation->run() == TRUE) { $dados = elements(array('descricaocategoria'), $this->input->post()); $this->Categoria->do_update($dados, array('idcategoria' => $this->input->post('idcategoria'))); } $data_template = array('controller' => $this->router->fetch_class(), 'action' => $this->router->fetch_method(), 'page' => 'update'); $this->load->view('template', $data_template); }
public function editar($dados = NULL) { if ($dados != NULL) { $campos = array('aceita_descricao'); $aceita_id = $dados['aceita_id']; $dados = elements($campos, $dados); $this->db->where('aceita_id', $aceita_id); $this->db->update('aceita', $dados); } }
public function editar($dados = NULL) { if ($dados != NULL) { $campos = array('admin_nome', 'admin_email', 'admin_senha'); $admin_id = $dados['admin_id']; $dados = elements($campos, $dados); $this->db->where('admin_id', $admin_id); $this->db->update('admin', $dados); } }
public function save() { $this->Purview_model->checkPurviewAjax($this->tablefunc, 'save'); $post = $this->input->post(NULL, TRUE); $data = elements($this->fields, $post); $data['updatetime'] = time(); $data['lastip'] = $this->input->ip_address(); $this->Data_model->editData(array('id' => $this->session->userdata('uid')), $data, 'user'); show_jsonmsg(array('status' => 200)); }