/** * */ 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, '', '&')); }
/** * */ 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, '', '&')); }