private function update() { $userData = $this->session->userdata('CRUD_AUTH'); if ($userData['group']['group_name'] == "Administrators") { $this->load->model('admin/admin_menu'); } else { $this->load->model('admin/home_menu'); } $this->load->model('user/user_menu'); $this->load->add_package_path(APPPATH . 'third_party/scrud/'); $var = array(); $var['update_flag'] = 1; if ($userData['group']['group_name'] == "Administrators") { $var['main_menu'] = $this->admin_menu->fetch('account'); } else { $var['main_menu'] = $this->home_menu->fetch('account'); } $var['user_menu'] = $this->user_menu->fetch('password'); $errors = array(); $crudAuth = $this->session->userdata('CRUD_AUTH'); if ($this->input->post('current_password') == '') { $errors['current_password'] = '******'; } if ($this->input->post('new_password') == '') { $errors['new_password'] = '******'; } if ($this->input->post('confirm_new_password') == '') { $errors['confirm_new_password'] = '******'; } if (count($errors) <= 0) { if ($this->input->post('new_password') != $this->input->post('confirm_new_password')) { $errors['confirm_new_password'] = '******'; } } if (count($errors) <= 0) { $userDao = new ScrudDao('crud_users', $this->db); $params = array(); $params['conditions'] = array('id = ? and user_password = ?', array($crudAuth['id'], sha1($this->input->post('current_password')))); $rs = $userDao->findFirst($params); if (empty($rs)) { $errors['current_password'] = "******"; } } if (count($errors) <= 0) { $data['id'] = $crudAuth['id']; $data['user_password'] = sha1($this->input->post('new_password')); $userDao->save($data); } $var['errors'] = $errors; $var['main_content'] = $this->load->view('user/password', $var, true); $this->load->view('layouts/user/default', $var); }
function removeConfig($data) { $CI =& get_instance(); $comDao = new ScrudDao('crud_components', $CI->db); $params = array(); $params['conditions'] = array('id = ?', array($_POST['key']['crud_components']['id'])); $com = $comDao->findFirst($params); if ($data['crud_components']['component_table'] != $com['component_table']) { if (file_exists(__DATABASE_CONFIG_PATH__ . '/' . $CI->db->database . '/' . sha1('com_' . $_POST['key']['crud_components']['id']))) { removeDir(__DATABASE_CONFIG_PATH__ . '/' . $CI->db->database . '/' . sha1('com_' . $_POST['key']['crud_components']['id'])); } } return $data; }
$options = $e[1]; } } $attributes = array(); if (isset($e[2]) && !empty($e[2])) { $attributes = $e[2]; } echo __select('data.' . $field, $options, $attributes); break; case 'autocomplete': $options = array(); $params = array(); if (isset($e[1]) && !empty($e[1])) { if (array_key_exists('option_table', $e[1])) { if (array_key_exists('option_key', $e[1]) && array_key_exists('option_value', $e[1])) { $_dao = new ScrudDao($e[1]['option_table'], $CI->db); $params['fields'] = array($e[1]['option_key'], $e[1]['option_value']); $rs = $_dao->find($params); if (!empty($rs)) { foreach ($rs as $v) { $options[$v[$e[1]['option_key']]] = $v[$e[1]['option_value']]; } } } } else { $options = $e[1]; } } $attributes = array(); if (isset($e[2]) && !empty($e[2])) { $attributes = $e[2];
public function getoptions() { $var = array(); $config = $this->input->post('config'); if (!empty($config)) { $crudDao = new ScrudDao($config['table'], $this->db); if (isset($config['key']) && trim($config['key']) != '' && isset($config['value']) && trim($config['value']) != '') { $params = array(); $params['fields'] = array($config['key'], $config['value']); $rs = $crudDao->find($params); if (!empty($rs)) { foreach ($rs as $v) { $var[$v[$config['key']]] = $v[$config['value']]; } } } } header('Content-Type: application/json'); echo json_encode($var); }
/** * */ private function del() { $CI =& get_instance(); $hook = Hook::singleton(); $crudAuth = $CI->session->userdata('CRUD_AUTH'); $historyDao = new ScrudDao('crud_histories', $CI->db); $history = array(); $history['user_id'] = isset($crudAuth['id']) ? $crudAuth['id'] : 0; $history['user_name'] = isset($crudAuth['user_name']) ? $crudAuth['user_name'] : ''; $history['history_table_name'] = $this->conf['table']; $history['history_date_time'] = date("Y-m-d H:i:s"); if (isset($_GET['key']) && $_GET['auth_token'] == $CI->session->userdata('auth_token_xtable')) { $params = array(); $strCon = ""; $aryVal = array(); $_tmp = ""; foreach ($this->primaryKey as $f) { $strCon .= $_tmp . " " . $f . ' = ?'; $_tmp = " AND "; $aryVal[] = $_GET['key'][$f]; } $crudAuth = $CI->session->userdata('CRUD_AUTH'); if ($this->globalAccess == false && !empty($crudAuth) && in_array($this->conf['table'] . '.created_by', $this->fields)) { $strCon .= ' ' . $_tmp . $this->conf['table'] . '.created_by = ' . $crudAuth['id'] . ' '; $_tmp = 'AND '; } $params = array($strCon, $aryVal); $tmpData = $this->dao->findFirst(array('conditions' => $params)); if (!empty($tmpData)) { $this->dao->remove($params); if ($hook->isExisted('SCRUD_COMPLETE_DELETE')) { $hook->execute('SCRUD_COMPLETE_DELETE', $tmpData); } $history['history_data'] = json_encode($tmpData[$this->conf['table']]); $history['history_action'] = 'delete'; $historyDao->insert($history); } else { $q = $this->queryString; $q['xtype'] = 'index'; if (isset($q['key'])) { unset($q['key']); } if (isset($q['auth_token'])) { unset($q['auth_token']); } header("Location: ?" . http_build_query($q, '', '&')); } } $q = $this->queryString; $q['xtype'] = 'index'; if (isset($q['key'])) { unset($q['key']); } if (isset($q['auth_token'])) { unset($q['auth_token']); } header("Location: ?" . http_build_query($q, '', '&')); }
public function saveUserPermission() { $this->load->library('session'); $userDao = new ScrudDao('crud_users', $this->db); $pDao = new ScrudDao('crud_user_permissions', $this->db); $data = $this->input->post('data'); $this->db->query('TRUNCATE TABLE `crud_user_permissions`'); if (count($data) > 0) { foreach ($data as $k => $v) { $user = array(); $user['user_manage_flag'] = $v['user_manage_flag']; $userDao->update($user, array('id = ?', array($v['user_id']))); $crudAuth = $this->session->userdata('CRUD_AUTH'); if ($v['user_id'] == $crudAuth['id']) { $crudAuth['user_manage_flag'] = $v['user_manage_flag']; $this->session->set_userdata('CRUD_AUTH', $crudAuth); } if (count($v['tables']) > 0) { $tables = $v['tables']; foreach ($tables as $k1 => $v1) { if (count($v1['permission_type']) > 0) { foreach ($v1['permission_type'] as $permission) { if ((int) $permission > 0) { $p = array(); $p['user_id'] = $v['user_id']; $p['table_name'] = $v1['table_name']; $p['permission_type'] = $permission; $pDao->save($p); } } } } } } } $ary = array(1, 2, 3, 4); foreach ($data as $k => $v) { foreach ($ary as $v1) { if ($v['user_manage_flag'] == 1 || $v['user_manage_flag'] == 3) { $p = array(); $p['user_id'] = $v['user_id']; $p['table_name'] = 'crud_users'; $p['permission_type'] = $v1; $pDao->save($p); } } } foreach ($data as $k => $v) { foreach ($ary as $v1) { if ($v['user_manage_flag'] == 1 || $v['user_manage_flag'] == 3) { $p = array(); $p['user_id'] = $v['user_id']; $p['table_name'] = 'crud_groups'; $p['permission_type'] = $v1; $pDao->save($p); } } } }
public function saveUserPermission() { $this->load->library('session'); $userDao = new ScrudDao('crud_users', $this->db); $pDao = new ScrudDao('crud_user_permissions', $this->db); $data = $this->input->post('data'); $this->db->delete('crud_user_permissions', array('user_id' => $data[0]['user_id'])); if (count($data) > 0) { foreach ($data as $k => $v) { $user = array(); $user['user_manage_flag'] = $v['user_manage_flag']; $user['user_setting_management'] = $v['user_setting_management']; $user['user_global_access'] = $v['user_global_access']; $userDao->update($user, array('id = ?', array($v['user_id']))); $crudAuth = $this->session->userdata('CRUD_AUTH'); if ($v['user_id'] == $crudAuth['id']) { $crudAuth['user_manage_flag'] = $v['user_manage_flag']; $crudAuth['user_setting_management'] = $v['user_setting_management']; $crudAuth['user_global_access'] = $v['user_global_access']; } if (count($v['coms']) > 0) { $coms = $v['coms']; foreach ($coms as $k1 => $v1) { if (count($v1['permission_type']) > 0) { foreach ($v1['permission_type'] as $permission) { if ((int) $permission > 0) { $p = array(); $p['user_id'] = $v['user_id']; $p['com_id'] = $v1['com_id']; $p['permission_type'] = $permission; $pDao->save($p); } } } } } } } }
/** * */ private function del() { $CI =& get_instance(); $crudAuth = $CI->session->userdata('CRUD_AUTH'); $historyDao = new ScrudDao('crud_histories', $CI->db); $history = array(); $history['user_id'] = isset($crudAuth['id']) ? $crudAuth['id'] : 0; $history['user_name'] = isset($crudAuth['user_name']) ? $crudAuth['user_name'] : ''; $history['history_table_name'] = $this->conf['table']; $history['history_date_time'] = date("Y-m-d H:i:s"); if (isset($_GET['key']) && $_GET['auth_token'] == $CI->session->userdata('auth_token_xtable')) { $params = array(); $strCon = ""; $aryVal = array(); $_tmp = ""; foreach ($this->primaryKey as $f) { $strCon .= $_tmp . " " . $f . ' = ?'; $_tmp = " AND "; $aryVal[] = $_GET['key'][$f]; } $params = array($strCon, $aryVal); $tmpData = $this->dao->findFirst(array('conditions' => $params)); $this->dao->remove($params); $history['history_data'] = json_encode($tmpData[$this->conf['table']]); $history['history_action'] = 'delete'; $historyDao->insert($history); } $q = $this->queryString; $q['xtype'] = 'index'; if (isset($q['key'])) { unset($q['key']); } if (isset($q['auth_token'])) { unset($q['auth_token']); } header("Location: ?" . http_build_query($q, '', '&')); }
echo $this->lang->line('actions'); ?> </th> </tr> </thead> <tbody> <?php if (count($tables) > 2) { foreach ($tables as $k => $table) { if ($table == 'cruds') { continue; } if (strpos($table, 'crud_') !== false) { continue; } $comDao = new ScrudDao('crud_components', $this->db); $params = array(); $params['conditions'] = array('component_table = ?', array($table)); $coms = $comDao->findFirst($params); ?> <tr> <td style="text-align:center;"><?php echo $k + 1; ?> </td> <td><?php echo $table; ?> </td> <td style="text-align: center;"> <a type="button" class="btn btn-mini btn-info" id="table_btn_fields" onclick="edit_table('<?php