/** * 详情弹窗数据响应 * * AJAX入口 * @param string $type 详情请求类型(用于支持一个管理页有多种详情弹窗,默认为空) */ public function ajax_detail($type) { $pk = act_decrypt(I('pk')); // 权限检查 if (false === $this->checkPk($pk, 'detail')) { return false; } $call = 'detail' . ($type ? '_' . $type : ''); return call_user_func_array(array(&$this, $call), array($pk)); }
public function search($pk) { $map['status'] = 1; if ($val = act_decrypt(I('pk'))) { $map['id'] = $val; } if ($val = I('query')) { $map['_string'] = "(hy.name LIKE '%{$val}%' OR hy.user_no='{$val}')"; } if ($val = I('cls')) { $map['student.class_id'] = $val; } $map = count($map) > 1 ? $map : 'false'; $lists = $this->where($map)->reflect(array('student|id|user_id|class_id,building,room,bank_card,parent_phone', 'class|student.class_id|id|name class_name'))->select('hy'); if (1 === count($lists)) { $user = $lists[0]; $user['id'] = act_encrypt($user['id']); $user['name'] = $user['name']; $user['phone'] = val_decrypt($user['phone']); $user['class_id'] = act_encrypt($classId = $user['class_id']); $user['roles'] = $this->callback_rolesRead($user['roles']); $lists = null; } else { foreach ($lists as $k => &$v) { $v['id'] = act_encrypt($v['id']); } } if ($user['building'] && $user['room']) { $user['dorm'] = $user['building'] . ' - ' . $user['room']; $roomMates = $this->reflect(array('student|id|user_id|building,room'))->where(array('student.building' => $user['building'], 'id' => array('neq', act_decrypt($user['id'])), 'student.room' => $user['room']))->select('hy'); $roomMates = md_arr_2_asc_arr($roomMates, 'name', 'phone'); $user['roomMates'] = ''; foreach ($roomMates as $k => $v) { $user['roomMates'] .= $k; $user['roomMates'] .= $v ? '(' . $v . ')<br>' : ''; } } $classMonitorId = D('StudentCadre')->getCadreUid($classId, '班长'); $classSecretaryId = D('StudentCadre')->getCadreUid($classId, '团支书'); $userM['monitor'] = $this->where(array('id' => $classMonitorId))->find() ?: array(); $userS['secretary'] = $this->where(array('id' => $classSecretaryId))->find() ?: array(); $user['class_id'] = act_decrypt($user['class_id']); $userI['instructor'] = $this->reflect(array('instructor|id|teacher_id|class_id'))->where(array('instructor.class_id' => $user['class_id']))->select(array('hy' => true)); $ms = array_merge($userM, $userS, $userI); foreach ($ms as $k => $v) { if ($k != 'instructor') { $user[$k] = $v['name'] . '(' . $v['phone'] . ')'; } else { foreach ($v as $k1 => $v1) { $user[$k] .= $v1['name'] . '(' . $v1['phone'] . ')<br/>'; } } } $arr['userInfo'] = array('name' => '姓名', 'user_no' => '学号', 'sex' => '性别', 'roles' => '角色', 'class_name' => '班级', 'monitor' => '班长', 'secretary' => '团支书', 'instructor' => '辅导员', 'college' => '学院', 'phone' => '电话', 'email' => '邮箱', 'dorm' => '寝室', 'roomMates' => '室友', 'nation' => '民族', 'native' => '籍贯', 'qq' => 'QQ', 'parent_phone' => '家长电话', 'id_card' => '身份证号', 'bank_phone' => '银行卡号', 'roles' => '职务'); $arr['lists'] = $lists; $arr['user'] = $user; $arr['arrInfo'] = array('class_name', 'user_no', 'nation', 'roles', 'native'); return $arr; }
/** * 标记已读 */ protected function ajax_read(&$json) { $pkArr = I('pk'); if (!$pkArr) { return; } $pkArr = explode(',', $pkArr); foreach ($pkArr as $k => &$v) { $v = act_decrypt($v); } $json['status'] = $this->setRead($pkArr); $json['info'] = $json['status'] ? '操作成功!' : ($this->getError() ?: '操作失败!'); }
/** * 角色切换入口 */ public function switchs() { if (!in_array($roleId = act_decrypt(I('role')), session('roleIdArr'))) { $this->error('操作非法!'); } $this->roleCache($roleId); $this->redirect('Index/index'); }