コード例 #1
0
 public function insert()
 {
     if ($_REQUEST['typeid']) {
         //左侧树的添加类型
         $MSASmodel = D("MisSystemAnnouncementSet");
         if ($_POST['typevalue'] == 1) {
             //判断添加的类型 1为主类型
             $_POST['pid'] = 0;
             $_POST['typeid'] = 1;
         } else {
             if ($_POST['typevalue'] == 2) {
                 //子类型
                 $_POST['typeid'] = 2;
                 $_POST['pid'] = $_REQUEST['pid'];
             }
         }
         if (false === $MSASmodel->create()) {
             $this->error($MSASmodel->getError());
         }
         $re = $MSASmodel->add();
         if ($re === false) {
             $this->error("操作失败");
         } else {
             $this->success("操作成功");
         }
     }
     if (getCommonSettingSkey("SYSTEM_ANNOUNCEMENT")) {
         //开启开关 发布公告需审核
         if ($_POST['commit'] == 5) {
             $_POST['commit'] = 5;
         } else {
             if ($_POST['commit'] == 1) {
                 $_POST['commit'] = 2;
                 //代表审核中
             }
         }
     }
     //判断未选部门和人员时
     if ($_POST['deptid'] == "" && $_POST['personid'] == "") {
         $_POST['scopetype'] = 3;
     }
     if ($_POST['deptid'] || $_POST['personid']) {
         $_POST['scopetype'] = 2;
     }
     if ($_POST['deptid'] != "" && $_POST['personid'] != "") {
         $_POST['scopetype'] = 1;
     }
     //将选择的部门(多个)转化数组为字符串
     if ($_POST['deptid']) {
         $_POST['deptid'] = implode(',', $_POST['deptid']);
     }
     //将选择的人员id(多个)数组转化为字符串
     if ($_POST['personid']) {
         $_POST['personid'] = implode(',', $_POST['personid']);
     }
     //公告结束时间
     if ($_POST['endtime']) {
         $_POST['endtime'] = strtotime($_POST['endtime']) + 24 * 3600 - 1;
     } else {
         $_POST['endtime'] = 0;
     }
     $_POST['type'] = $_POST['type'];
     $_POST['toptime'] = strtotime($_POST['toptime']) + 24 * 3600 - 1;
     //公告开始时间转化时间戳
     $_POST['starttime'] = strtotime($_POST['starttime']);
     //公告结束时间戳
     $_POST['createid'] = $_SESSION[C('USER_AUTH_KEY')];
     //创建公告表对象
     $MSAModel = D('MisSystemAnnouncement');
     $result = $MSAModel->data($_POST)->add();
     if ($result) {
         $this->swf_upload($result, 78);
         //上传附件
         $this->success('操作成功!');
     } else {
         $this->error('操作失败!');
     }
 }
コード例 #2
0
ファイル: OAHelperAction.class.php プロジェクト: tmlsoft/main
 /**
  * @Title: SystemNotices
  * @Description: todo(系统公告)
  * 并且排除已读的数据
  * @author 杨东
  * @date 2013-3-15 下午5:45:07
  * @throws
  */
 public function getNewNotices($returnType = 'json')
 {
     //获取当前登录人部门id 角色id
     $userModel = M("user");
     $userList = $userModel->where("id=" . $this->userid)->find();
     $snmodel = M('MisSystemAnnouncement');
     $snumodel = M('MisSystemAnnouncementUser');
     $map['status'] = array("gt", -1);
     $map['commit'] = array("eq", 1);
     $time = time();
     $map['endtime'] = array(array('eq', 0), array('gt', $time), 'or');
     $map['starttime'] = array('lt', $time);
     if ($this->userid != 1) {
         //不是管理员 只能看到在范围内的公告
         $map['_string'] = "( (scopetype=2 and ( (find_in_set('" . $userList['dept_id'] . "',deptid) or find_in_set('" . $userList['id'] . "',personid)) or createid=" . $this->userid . "  ) ) or (scopetype=3))";
     }
     //是否有审核开关
     if (getCommonSettingSkey("SYSTEM_ANNOUNCEMENT")) {
     }
     $sql = "SELECT\n\t\t`mis_system_announcement`.`id` as id,\n\t\t`mis_system_announcement`.`type` as `type`,\n\t\t`mis_system_announcement`.`title` as title,\n\t\t`user`.`name` as username,\n\t\t`mis_system_announcement`.`createtime` as createtime\n\t\tFROM `mis_system_announcement`\n\t\tLEFT JOIN `user`\n\t\tON `mis_system_announcement`.createid=`user`.id\n\t\tWHERE (`mis_system_announcement`.`status` >  - 1)\n\t\tAND (`mis_system_announcement`.`commit` = 1)\n\t\tAND ((`mis_system_announcement`.`endtime` = 0)\n\t\tOR (`mis_system_announcement`.`endtime` > " . time() . "))\n\t\tAND (`mis_system_announcement`.`starttime` < " . time() . ")\n\t\tORDER BY `mis_system_announcement`.sendtime DESC\n\t\tLIMIT 0,10";
     //此处获取返回数据
     $returnData = $snmodel->query($sql);
     //现在重新拼装带URL的返回值数据
     foreach ($returnData as $key => $val) {
         $maps['userid'] = $this->userid;
         $maps['announceid'] = $val[id];
         $maps['status'] = 1;
         $num = $snumodel->where($maps)->count();
         if ($num > 0) {
             $returnData[$key]['status'] = "1";
         } else {
             $returnData[$key]['status'] = "0";
         }
         $returnData[$key]['urldata'] = "MisSystemPanelMethod,systemNoticesview,id," . $returnData[$key]['id'] . ",type," . $returnData[$key]['type'];
     }
     return $this->getReturnData($returnData, $returnType);
 }
コード例 #3
0
 public function checkLogin()
 {
     $account = $_REQUEST["account"];
     $pwd = $_REQUEST["password"];
     $userinfo = Cookie::get("userinfo");
     if ($account && $pwd || $userinfo["user"] && $userinfo['pwd']) {
         if ($account && $pwd) {
             $map = array();
             $map['account'] = $account;
             $map['password'] = $pwd;
         } else {
             $map = array();
             $map['account'] = $userinfo['user'];
             $map['password'] = $userinfo['pwd'];
         }
         $map["status"] = array('gt', 0);
         $authInfo = RBAC::authenticate($map);
         if ($authInfo) {
             //cookie验证重新赋值
             if (ACTION_NAME != "getAllScheduleList") {
                 $this->setBBSCookie($authInfo);
                 $this->setUserInfoCookie($authInfo);
             }
             if (!isset($_SESSION[C('USER_AUTH_KEY')])) {
                 $this->setSession($authInfo);
                 //更新user_online表
                 $online_model = M("user_online");
                 $onlinedata = array();
                 $onlinedata["modify_time"] = time();
                 $onlinedata["session_id"] = session_id();
                 $online_model->where("userid=" . $authInfo['id'])->save($onlinedata);
             }
             // 缓存访问权限
             RBAC::saveAccessList();
             $same_time_login = intval(getCommonSettingSkey("SAME_TIME_LOGIN"));
             if (ACTION_NAME != "getAllScheduleList") {
                 $modeluseronline = D("UserOnline");
                 $aMap = array();
                 $aMap['userid'] = $authInfo["id"];
                 $info = $modeluseronline->where($aMap)->find();
                 $time = time();
                 $session_id = session_id();
                 if ($info) {
                     //存在,则检查session_id
                     if ($same_time_login == 0) {
                         if ($info['session_id'] == $session_id) {
                             //修改时间
                             $modeluseronline->where($aMap)->setField('modify_time', $time);
                         } else {
                             $this->assign("jumpUrl", __APP__ . '/Public/login/');
                             unset($_SESSION);
                             Cookie::delete("userinfo");
                             Cookie::delete("bbsuserinfo");
                             Cookie::clear();
                             session_destroy();
                             $this->error("已在其他地方登陆,被迫下线", '', '', '301');
                             exit;
                         }
                     } else {
                         $modeluseronline->where($aMap)->setField('modify_time', $time);
                     }
                 } else {
                     //如果不存在userid,插入
                     $data = array();
                     $data = array('userid' => $authInfo["id"], 'session_id' => $session_id, 'modify_time' => $time, 'createid' => $authInfo["id"], 'createtime' => $time);
                     $modeluseronline->add($data);
                 }
             }
             return true;
         }
     } else {
         //提示请求时返回json数据
         if (ACTION_NAME == "getAllScheduleList") {
             $rehtml["html"] = 0;
             $rehtml['date'] = "";
             $rehtml['datalist'] = 0;
             echo json_encode($rehtml);
             exit;
         }
     }
     unset($_SESSION);
     Cookie::delete("userinfo");
     Cookie::delete("bbsuserinfo");
     Cookie::clear();
     session_destroy();
     return false;
 }