/**
  * 行为入口
  * @see \Think\Behavior::run()
  */
 public function run(&$the)
 {
     $the->_assets = $this->loadAssets();
     if (ss_uid()) {
         $the->hyAlerts = $this->getUnreadList();
     }
 }
Example #2
0
 /**
  * 权限忽略规则
  * @return boolean
  */
 public static function preAuth($allowPublic = false)
 {
     // 跳过公共控制器
     if ('HyStart' !== CONTROLLER_NAME && !ss_uid()) {
         redirect(U('System/HyStart/login'));
     }
     if (!$allowPublic) {
         return;
     }
     $public = C('PUBLIC_CONTROLLER');
     return in_array(CONTROLLER_NAME, is_array($public) ? $public : explode(',', $public));
 }
Example #3
0
 public function ajax_add(&$json)
 {
     $offset = I('offset');
     $data['content'] = I('content');
     Hook::listen('hy_filter', $data['content']);
     $data['user_id'] = ss_uid();
     $data['create_time'] = time();
     $data['anonymous'] = 0;
     if (false === $this->add($data)) {
         return $json['info'] = $this->getError();
     }
     $json['status'] = true;
     $json['data'] = $this->lists($offset);
 }
Example #4
0
 public function index()
 {
     // 基础访问认证
     $this->baseAccessAuth();
     $this->setPageTitle('首页');
     // 菜单输出
     $this->jsonAssign('hyMenu', S('menuCache_' . session('roles')));
     // 登录信息
     $log = M('frame_log')->where(array('user_id' => ss_uid(), 'status' => 1, 'controller' => 'HyStart', 'action' => 'ajax', 'description' => array('like', '%成功%')))->order('id desc')->getField('create_time', 2);
     $this->lastLogin = date('Y年m月d日 H:i', $log[1]);
     // 角色信息
     $this->role = session('roleTitle');
     $roles = session('roleSwitch');
     if (count($roles)) {
         $this->roles = $roles;
     }
     // 系统公告
     $this->notice = D('HyNotice')->limit('5')->select(array('hy' => true));
     $this->display();
 }
Example #5
0
 /**
  * 行为入口
  * @see \Think\Behavior::run()
  */
 public function run(&$params)
 {
     if (!isset($GLOBALS['logStep'])) {
         $GLOBALS['logStep'] = array('description' => '', 'sql' => '');
         return;
     }
     if (is_string($params) || is_array($params)) {
         if (is_array($params)) {
             $style = $params['style'];
             $msg = $params['msg'];
             $sql = $params['sql'];
             if ($msg && $style) {
                 $msg = "<span class=\"{$style}\">{$msg}</span>";
             }
         } elseif (is_string($params)) {
             $msg = $params;
         }
         if ($msg) {
             $GLOBALS['logStep']['description'] .= " >> {$msg}";
         }
         if ($sql) {
             $GLOBALS['logStep']['sql'] = $sql;
         }
         return;
     }
     $log = array();
     $log['user_id'] = ss_uid();
     $log['description'] = $GLOBALS['logStep']['description'];
     if (!$log['user_id'] || !$log['description']) {
         return;
     }
     $log['sql'] = $GLOBALS['logStep']['sql'];
     $log['module'] = CONTROLLER_NAME;
     $log['controller'] = CONTROLLER_NAME;
     $log['action'] = ACTION_NAME;
     $log['post'] = json_encode($_REQUEST, JSON_UNESCAPED_UNICODE);
     $log['url'] = __SELF__;
     $log['create_time'] = time();
     $log['ip'] = get_client_ip();
     M('frame_log')->add($log);
 }
Example #6
0
 /**
  * 角色确定和切换时触发
  * @param array $role
  */
 public function onRoleSwitch($role)
 {
     switch ($role['table']) {
         case 'student':
             session('student', true);
             session('teacher', false);
             $belong = M($role['table'])->where(array('user_id' => ss_uid()))->getField('class_id');
             session('classId', $belong);
             if ('class' == $role['name']) {
                 session('userJob', D('StudentCadre')->getCadreJob(ss_uid()));
             }
             break;
         case 'teacher':
             session('student', false);
             session('teacher', true);
             if ('instructor' == $role['name']) {
                 session('myClassArr', M('instructor')->where(array('teacher_id' => ss_uid()))->getField('class_id', true));
                 session('userJob', $belong['job']);
             }
             break;
     }
     session('collegeName', M('college')->getFieldById(session('collegeId'), 'name'));
 }
Example #7
0
 /**
  * @overrides
  */
 protected function initFieldsOptions()
 {
     return array('title' => array('title' => '标题', 'list' => array('callback' => array('tplReplace', C('TPL_DETAIL_BTN')), 'search' => array('query' => 'like')), 'form' => array('type' => 'text', 'validate' => array('required' => true, 'maxlength' => 20))), 'content' => array('title' => '公告内容', 'list' => array('hidden' => true), 'form' => array('type' => 'textarea', 'attr' => 'style="height:200px;width:107%;"', 'style' => 'make-umeditor', 'fill' => array('both' => array('content')), 'validate' => array('required' => true))), 'file_id' => array('title' => '相关文件', 'list' => array('callback' => array('fileDown'), 'order' => false), 'form' => array('type' => 'file', 'file' => array('ext' => 'doc,docx,zip,rar,txt'), 'style' => 'input-small')), 'create_time' => array('title' => '发布时间', 'list' => array('callback' => array('to_time'), 'search' => array('title' => '发布时间不早于', 'type' => 'date', 'callback' => array('tplReplace', '{callback}' => array('strtotime'), ' create_time < ({0}+3600*24)', '{#}'))), 'form' => array('add' => false, 'edit' => false, 'fill' => array('add' => array('value', time())))), 'update_time' => array('title' => '修改时间', 'list' => array('callback' => array('to_time')), 'form' => array('add' => false, 'edit' => false, 'fill' => array('edit' => array('value', time())))), 'creator_id' => array('form' => array('fill' => array('both' => array('value', ss_uid())))));
 }
Example #8
0
 /**
  * 未读消息列表
  * @return array
  */
 public function getUnreadList()
 {
     // 因此方法执行频度较高,所以采用原生SQL
     $userId = ss_uid();
     $sql = "SELECT `id`,`category`,`icon`,`message`,`url`,`type`,`create_time` FROM `" . DTP . "frame_alert` where `to_users` LIKE '%,{$userId},%' AND ( IFNULL(`read_users`,'')='' OR `read_users` NOT LIKE '%,{$userId},%') AND `status`=1 ORDER BY `id` DESC";
     return $this->query($sql);
 }
Example #9
0
 public function profile()
 {
     $user = $this->reflect($this->getPersonalReflect())->where(array('id' => ss_uid()))->find('hy');
     if (session('student')) {
         $user['base'] = array('角色' => $roleNames = $this->callback_rolesRead($user['roles']), '学院' => session('collegeName'), '班级' => $user['class_id_text'], '班内职务' => $user['job'], '宿舍楼' => $user['building'], '寝室号' => $user['room'], '累计登录次数' => $user['login_times'] . '次');
     } else {
         $user['base'] = array('角色' => $roleNames = $this->callback_rolesRead($user['roles']), '学院' => $user['college_id_text'], '职务' => $user['job'], '部门' => $user['department'], '累计登录次数' => $user['login_times']);
     }
     $user['form'] = $this->getBaseInfoFields();
     $user['rolesname'] = session('roleSwitch');
     $user['roleDefault'] = M('frame_role')->getFieldById(substr($arr['roles'], 0, strpos($arr['roles'], ',') ?: 1), 'title');
     $user['logs'] = M('frame_log')->where(array('user_id' => ss_uid(), 'status' => 1, 'controller' => 'HyStart', 'action' => 'ajax'))->order('id desc')->getField('id,create_time,ip,description', 5);
     return $user;
 }
Example #10
0
 /**
  * @overrides
  */
 protected function initFieldsOptions()
 {
     return array('create_time' => array('list' => array('title' => '时间', 'callback' => array('to_time')), 'form' => array('fill' => array('both' => array('value', TIME)))), 'type' => array('form' => array('fill' => array('both' => array('value', 2)))), 'category' => array('title' => '类别', 'list' => array('search' => array('type' => 'text', 'query' => 'like')), 'form' => array('type' => 'text', 'tip' => '填写通知用途,方便筛选', 'validate' => array('required' => true, 'maxlength' => 10))), 'to_users' => array('form' => array('title' => '班级', 'type' => 'select', 'select' => array('multiple' => true, 'optgroup' => true), 'validate' => array('required' => true), 'fill' => array('both' => array('to_users')))), 'message' => array('title' => '内容', 'list' => array('callback' => $this->getContentListCallback(), 'search' => array('type' => 'text', 'query' => 'like')), 'form' => array('type' => 'textarea', 'attr' => 'style="height:150px;"', 'validate' => array('required' => true, 'maxlength' => 180))), 'read_users' => null, 'icon' => array('form' => array('fill' => array('both' => array('value', C('ADMIN_ALERT_ICON'))))), 'creator_id' => array('form' => array('fill' => array('both' => array('value', ss_uid())))));
 }
 /**
  * 用户登录信息注销
  */
 private function userLogout()
 {
     if (!ss_uid()) {
         return;
     }
     $this->model = new HyAccountModel();
     $this->model->where(array('id' => ss_uid()))->setField('session_id', '');
     session('[destroy]');
 }