Exemple #1
0
 /**
  * 生成后台菜单
  */
 public static function menu($groupId = '')
 {
     $condition = "";
     if (!empty($groupId) && $_SESSION['admin']['user_id'] > '1') {
         $group = \Model\Content::findContent('user_group', $groupId, 'user_group_id');
         $condition .= "m.menu_id in ({$group['user_group_menu']})";
     }
     $result = self::db('menu AS m')->field("m.*, IF(parent.top_id IS NULL, m.menu_id, parent.top_id) AS top_id, IF(parent.top_listsort IS NULL, '0', parent.top_listsort) AS top_listsort, IF(parent.top_name IS NULL, m.menu_name, top_name) AS top_name, menu_icon")->join("(SELECT `menu_id` AS top_id, `menu_name` AS top_name, `menu_pid` AS top_pid, `menu_listsort` AS top_listsort FROM `" . self::$modelPrefix . "menu` where menu_pid = 0) AS parent ON parent.top_id = m.menu_pid")->where($condition)->order('top_listsort ASC, m.menu_listsort ASC, m.menu_id DESC')->select();
     foreach ($result as $key => $value) {
         if ($value['menu_pid'] == 0) {
             $menu[$value['top_name']]['menu_id'] = $value['top_id'];
             $menu[$value['top_name']]['menu_name'] = $value['top_name'];
             $menu[$value['top_name']]['menu_link'] = $value['menu_link'];
             $menu[$value['top_name']]['menu_icon'] = $value['menu_icon'];
             $menu[$value['top_name']]['menu_listsort'] = $value['menu_listsort'];
             $menu[$value['top_name']]['menu_type'] = $value['menu_type'];
         }
     }
     foreach ($result as $key => $value) {
         if (!empty($menu[$value['top_name']]) && $value['menu_pid'] != 0) {
             $menu[$value['top_name']]['menu_child'][] = $value;
         }
     }
     return $menu;
 }
Exemple #2
0
 /**
  * 添加/编辑内容
  */
 public function action()
 {
     $id = $this->g('id');
     if (empty($id)) {
         $this->assign('method', 'POST');
         $this->assign('title', "添加 - {$this->model['model_title']}");
     } else {
         $content = \Model\Content::findContent($this->table, $id, "{$this->fieldPrefix}id");
         if (empty($content)) {
             $this->error('不存在的内容');
         }
         $this->assign($content);
         $this->assign('method', 'PUT');
         $this->assign('id', $id);
         $this->assign('title', "编辑 - {$this->model['model_title']}");
         foreach ($this->field as $key => $value) {
             $this->field[$key] = $value;
             $this->field[$key]['field_option'] = $value['field_option'];
             $this->field[$key]['value'] = $content["{$this->fieldPrefix}{$value['field_name']}"];
         }
     }
     $this->assign('field', $this->field);
     $this->assign('form', new \Expand\Form\Form());
     $this->layout(is_file("{$this->modelThemePrefixPath}_action.php") ? MODULE . "_action" : 'Content_action');
 }
Exemple #3
0
 /**
  * 添加/编辑内容
  */
 public function action()
 {
     $field = \Model\Field::fieldList($this->model['model_id'], array('field_status' => '1'));
     $id = $this->g('id');
     if (empty($id)) {
         $this->assign('method', 'POST');
         $this->assign('title', "添加 - {$this->model['lang_key']}");
     } else {
         $content = \Model\Content::findContent($this->table, $id, "{$this->fieldPrefix}id");
         if (empty($content)) {
             $this->error('不存在的内容');
         }
         $this->assign($content);
         $this->assign('method', 'PUT');
         $this->assign('id', $id);
         $this->assign('title', "编辑 - {$this->model['lang_key']}");
         foreach ($field as $key => $value) {
             $field[$key] = $value;
             $field[$key]['value'] = $content["{$this->fieldPrefix}{$value['field_name']}"];
         }
     }
     $this->assign('field', $field);
     $this->assign('form', new \Expand\Form\Form());
     $this->display(is_file(THEME . '/' . GROUP . "/{$this->theme}/" . MODULE . '/' . MODULE . "_action.php") ? MODULE . "_action" : 'Content_action');
 }
 /**
  * 添加/编辑内容
  */
 public function action()
 {
     $field = \Model\Field::fieldList($this->model['model_id'], '1');
     $id = $this->g('id');
     if (empty($id)) {
         $this->assign('method', 'POST');
         $this->assign('title', "{$GLOBALS['_LANG']['CONTENT']['ADD']} - {$this->model['lang_key']}");
     } else {
         $content = \Model\Content::findContent($this->table, $id, "{$this->fieldPrefix}id");
         if (empty($content)) {
             $this->error($GLOBALS['_LANG']['CONTENT']['NOT_EXIST_CONTENT']);
         }
         $this->assign($content);
         $this->assign('method', 'PUT');
         $this->assign('id', $id);
         $this->assign('title', "{$GLOBALS['_LANG']['CONTENT']['EDIT']} - {$this->model['lang_key']}");
         foreach ($field as $key => $value) {
             $field[$key] = $value;
             $field[$key]['value'] = $content["{$this->fieldPrefix}{$value['field_name']}"];
         }
     }
     $this->assign('field', $field);
     $this->assign('form', new \Expand\Form\Form());
     $this->layout(is_file(THEME . '/' . GROUP . "/{$this->theme['value']}/" . MODULE . "_action.php") ? MODULE . "_action" : 'Content_action');
 }
 /**
  * 获取系统更新信息
  * @return boolean 返回抓去结果
  */
 public static function getUpdate()
 {
     $version = \Model\Option::findOption('version')['value'];
     $findUpdate = \Model\Content::findContent('update_list', $version, 'update_list_pre_version');
     if (empty($findUpdate)) {
         $update = \Model\Extra::getUpdate($version);
         return $update['status'];
     }
 }
 /**
  * 更新系统
  */
 public function upgrade()
 {
     \Model\Option::getUpdate();
     $version = \Model\Option::findOption('version')['value'];
     $content = \Model\Content::findContent('update_list', $version, 'update_list_pre_version');
     $this->assign($content);
     $this->assign('title', \Model\Menu::getTitleWithMenu());
     $this->layout();
 }
Exemple #7
0
 public function action($jump = TRUE, $commit = TRUE)
 {
     if ($_POST['parent'] == '0') {
         $_POST['value'] = (string) ucfirst(strtolower($_POST['value']));
     } else {
         $controller = \Model\Content::findContent('node', $_POST['parent'], 'node_id');
         $_POST['check_value'] = GROUP . $_POST['method_type'] . $controller['node_value'] . $_POST['value'];
     }
     parent::action();
 }
Exemple #8
0
 public function before()
 {
     if (in_array(METHOD, ['POST', 'PUT'])) {
         if ($_POST['controller'] == '0' || $_POST['controller'] == '-1') {
             $_POST['value'] = (string) ucfirst(strtolower($_POST['value']));
         } else {
             $controller = \Model\Content::findContent('node', $_POST['controller'], 'node_id');
             $_POST['check_value'] = GROUP . $_POST['method_type'] . $controller['node_value'] . $_POST['value'];
         }
     }
 }
 /**
  * 全体任务列表
  */
 public function index()
 {
     $condition = "task_delete = 0 ";
     $param = array();
     $title = "全体任务列表";
     //筛选任务状态类型
     $type = $this->g('type');
     if ($type >= '0') {
         $condition .= " AND task_status = :task_status";
         $param['task_status'] = $type;
     }
     //筛选任务项目
     $project = $this->g('project');
     if ($project > '0') {
         $condition .= " AND task_project = :task_project ";
         $param['task_project'] = $project;
         $title = "项目[" . \Model\Content::findContent('project', $project, 'project_id')['project_title'] . "]任务列表";
     }
     //筛选任务部门
     $departmengt = $this->g('department');
     if ($departmengt > '0') {
         $condition .= " AND task_department_id = :task_department_id ";
         $param['task_department_id'] = $departmengt;
         $title = "部门" . \Model\Content::findContent('department', $departmengt, 'department_id')['department_name'] . "任务列表";
     }
     //筛选任务执行人
     $user = $this->g('user');
     if ($user > '0') {
         $condition .= " AND task_user_id = :task_user_id ";
         $param['task_user_id'] = $user;
         $title = "用户" . \Model\Content::findContent('user', $user, 'user_id')['user_name'] . "的任务列表";
     }
     //搜索
     if (!empty($_GET['search'])) {
         $condition .= " AND task_title LIKE :task_title";
         $param['task_title'] = '%' . $this->g('search') . '%';
     }
     //审核和完成的任务,按照ID倒序则可
     if (in_array($type, array('2', '4'))) {
         $order = "task_id DESC";
     } else {
         $order = "task_priority ASC, task_status ASC, task_id DESC";
     }
     $page = new \Expand\Team\Page();
     $total = count(\Model\Content::listContent('task', $param, $condition));
     $count = $page->total($total);
     $page->handle();
     $list = \Model\Content::listContent('task', $param, $condition, $order, "{$page->firstRow}, {$page->listRows}");
     $show = $page->show();
     $this->assign('page', $show);
     $this->assign('list', $list);
     $this->assign('title', $title);
     $this->layout('Task_index');
 }
Exemple #10
0
 public function before()
 {
     if (METHOD == 'POST') {
         $this->isP('password', '请填写密码');
     }
     if (empty($_POST['password'])) {
         $_POST['password'] = \Model\Content::findContent('user', $_POST['id'], 'user_id')['user_password'];
     } else {
         $_POST['password'] = (string) \Core\Func\CoreFunc::generatePwd($this->p('password'));
     }
 }
Exemple #11
0
 /**
  * 删除文档指定内容
  */
 public function deleteContent()
 {
     $id = $this->isG('id', '请选择您要删除的文档内容');
     $check = \Model\Content::findContent('doc_content', $id, 'doc_content_id');
     if (empty($check)) {
         $this->error('不存在的文档内容');
     }
     $resul = $this->db('doc_content')->where('doc_content_id = :doc_content_id')->update(array('doc_content_delete' => '1', 'noset' => array('doc_content_id' => $id)));
     if ($resul === false) {
         $this->error('删除失败');
     }
     $this->success('删除文档内容成功');
 }
Exemple #12
0
 /**
  * 查找当前的分类ID
  */
 private function getCurrentCatid()
 {
     $this->catid = (int) $_GET['id'];
     if (MODULE != 'Page' && ACTION == 'view') {
         $model = strtolower(MODULE);
         $checkModel = \Model\ModelManage::findModel($model, 'model_name');
         if (!empty($checkModel)) {
             $content = \Model\Content::findContent($model, $this->catid, "{$model}_id");
             $this->catid = $content["{$model}_catid"];
         }
     }
     $this->assign('catid', $this->catid);
 }
Exemple #13
0
 /**
  * 设置菜单
  */
 public function setMenu()
 {
     $id = $this->isG('id', '请提交用户组');
     $record = [];
     $recordList = \Model\Content::findContent('user_group', $id, 'user_group_id')['user_group_menu'];
     if (!empty($recordList)) {
         $record = explode(',', $recordList);
     }
     $this->assign('record', json_encode($record));
     $this->assign('list', \Core\Func\CoreFunc::$param['menu']);
     $this->assign('prefix', 'menu_');
     $this->display('User_group_setting');
 }
Exemple #14
0
 public function dologin()
 {
     $mark = $this->isG('mark', '非法请求');
     $check = \Model\Content::findContent('dologin', $mark, 'dologin_mark');
     if (empty($check)) {
         $this->error('不存在的记录');
     }
     if ($check['dologin_createtime'] <= time() - 30 && $check['dologin_status'] == '0') {
         $this->error('登录超时,请重新运行软件');
     }
     $this->db('dologin')->where('dologin_id = :dologin_id')->update(array('dologin_status' => '1', 'noset' => array('dologin_id' => $check['dologin_id'])));
     $_SESSION['admin'] = json_decode($check['dologin_session'], true);
     $this->success('登录成功!', $this->url(GROUP . '-Index-index'));
 }
Exemple #15
0
 public function before()
 {
     if ($_SESSION['admin']['user_id'] == '1') {
         return true;
     }
     $findNode = \Model\Content::findContent('node', GROUP . METHOD . MODULE . ACTION, 'node_check_value');
     if (empty($findNode)) {
         return true;
     }
     $list = \Model\Content::listContent(['table' => 'node_group', 'condition' => 'user_group_id = :user_group_id AND node_id = :node_id', 'param' => ['user_group_id' => $_SESSION['ticket']['user_group_id'], 'node_id' => $findNode['node_id']]]);
     if (empty($list)) {
         $this->error(empty($findNode['node_msg']) ? '您的权限不足' : $findNode['node_msg']);
     }
 }
 /**
  * 提取报表
  */
 public function extract()
 {
     $head = explode(',', \Model\Content::findContent('department', $_SESSION['team']['user_department_id'], 'department_id')['department_header']);
     if (!in_array($_SESSION['team']['user_id'], $head) && ACTION == 'extract') {
         $this->error('您不是部门负责人,无权访问');
     }
     $condition = "r.report_date BETWEEN :begin AND :end ";
     $param = array();
     //allExtract将移除此限制
     if (ACTION == 'extract') {
         $condition .= " AND r.department_id = :department_id";
         $param['department_id'] = $_SESSION['team']['user_department_id'];
     }
     if (!empty($_GET['begin']) && !empty($_GET['end'])) {
         $param['begin'] = $_GET['begin'];
         $param['end'] = $_GET['end'];
     } else {
         $param['begin'] = date('Y-m-d');
         $param['end'] = date('Y-m-d');
     }
     if (!empty($_GET['user'])) {
         $condition .= " AND r.user_id = :user_id";
         $param['user_id'] = $this->g('user');
     }
     $result = $this->db('report AS r ')->join("{$this->prefix}report_content AS rc ON rc.report_id = r.report_id")->where($condition)->order('report_date DESC')->select($param);
     //是否导出excel
     if (!empty($_GET['excel'])) {
         $label = new \Expand\Label();
         $excelTitle = array('日期/用户', '报表内容');
         foreach ($result as $key => $value) {
             $list[$value['report_date']][$value['report_date']] = $value['report_date'];
             $list[$value['report_date'] . $value['user_id']][$value['user_id']] = $label->findUser('user', 'user_id', $value['user_id'])['user_name'];
             $list[$value['report_date'] . $value['user_id']][] = strip_tags(htmlspecialchars_decode($value['report_content']));
         }
         $excel = new \Expand\Excel\Excel();
         $excel->export(date('YmdHis') . '提取报表', $excelTitle, $list);
     } else {
         foreach ($result as $key => $value) {
             $list[$value['report_date']][$value['user_id']][] = $value;
         }
     }
     $this->assign('list', $list);
     $userList = \Model\Content::listContent('user');
     $this->assign('user', $userList);
     $this->assign('begin', $param['begin']);
     $this->assign('end', $param['end']);
     $this->assign('title', '提取报表');
     $this->layout('Report_extract');
 }
Exemple #17
0
 /**
  * 更新用户
  */
 public function action($jump = TRUE, $commit = TRUE)
 {
     $user = \Model\Content::findContent('user', (int) $_POST['id'], 'user_id');
     if (empty($user)) {
         $this->error('不存在的用户');
     }
     if ($this->p('password')) {
         $password = $this->p('password');
         if ($password != $this->p('confirm_password')) {
             $this->error('两次输入的密码不一致');
         }
         $_POST['password'] = (string) \Core\Func\CoreFunc::generatePwd($this->isP('account', '请提交帐号') . $password, 'PRIVATE_KEY');
     }
     parent::action();
 }
Exemple #18
0
 /**
  * 添加新内容
  */
 public function addContent()
 {
     $id = $this->isG('id', '丢失日志');
     $content = $this->isP('content', '请填写内容');
     $checkDoc = $this->db('doc')->where("doc_id = :doc_id AND doc_delete = '0'")->find(array('doc_id' => $id));
     $checkTree = \Model\Content::findContent('tree', $checkDoc['doc_tree_id'], 'tree_id');
     $this->db()->transaction();
     $time = time();
     $updateTime = $this->db()->query("UPDATE {$this->prefix}doc SET doc_updatetime = '{$time}' WHERE doc_id = :doc_id ", array('doc_id' => $id));
     if ($updateTime === FALSE) {
         $this->db()->rollBack();
         $this->error('更新时间出错');
     }
     \Model\Doc\Doc::addContent(array('doc_id' => $id, 'user_id' => $_SESSION['user']['user_id'], 'doc_content' => $content, 'doc_content_createtime' => $time));
     $this->db()->commit();
     $this->success('添加内容成功!', $this->url("/d/v/{$checkTree['tree_parent']}/{$id}", true));
 }
 public function setNode()
 {
     $id = $this->isP('id', '请选择用户组');
     if (empty($_POST['node'])) {
         $this->error('请选择该用户组的权限节点');
     }
     $group = \Model\Content::findContent('user_group', $id, 'user_group_id');
     if (empty($group)) {
         $this->error('用户组不存在');
     }
     //移除所有节点
     $this->db('node_group')->where('user_group_id = :user_group_id')->delete(array('user_group_id' => $id));
     foreach ($_POST['node'] as $key => $value) {
         $this->db('node_group')->insert(array('user_group_id' => $id, 'node_id' => $value));
     }
     $this->success('设置用户组权限节点成功!', $this->url('Team-User_group-index'));
 }
 /**
  * 设置节点
  */
 public function setNode()
 {
     $id = $this->isG('id', '请选择用户组');
     $group = \Model\Content::findContent('user_group', $id, 'user_group_id');
     if (empty($group)) {
         $this->error('用户组不存在');
     }
     $nodeList = $this->db('node_group')->where('user_group_id = :user_group_id')->select(array('user_group_id' => $id));
     foreach ($nodeList as $key => $value) {
         $groupNode[] = $value['node_id'];
     }
     $this->assign('groupNode', $groupNode);
     $this->assign($group);
     $this->assign('node', \Model\Node::nodeList());
     $this->assign('title', "设置'{$group['user_group_name']}'用户组权限节点");
     $this->layout();
 }
 /**
  * 验证用户节点
  * @todo 若没有添加节点,是否需要严重权限呢?
  * 应该在设置中添加一个选项,开启严格的权限检测和欢送检测。
  */
 protected function checkNode()
 {
     //登录,上传,下载文件为权限验证特例。以后看需要再更改吧
     if (in_array(MODULE, array('Login', 'Upload', 'SaveFile'))) {
         return true;
     }
     $findNode = \Model\Content::findContent('node', GROUP . METHOD . MODULE . ACTION, 'node_check_value');
     $nodeType = \Model\Content::findContent('option', 'node_type', 'option_name');
     //没加节点,则表示不验证权限
     if (empty($findNode) && $nodeType['value'] == '0') {
         return true;
     }
     $checkNode = $this->db('node_group')->where('user_group_id = :user_group_id AND node_id = :node_id')->find(array('user_group_id' => $_SESSION['team']['user_group_id'], 'node_id' => $findNode['node_id']));
     if (empty($checkNode)) {
         $this->error(empty($findNode['node_msg']) ? '您的权限不足' : $findNode['node_msg']);
     }
 }
 public function index()
 {
     $id = $this->isG('id', '请选择要下载的文件');
     $model = strtolower($this->isG('model', '请选择下载的模块'));
     //要下载文件的字段,缺省值为file
     $field = empty($_GET['field']) ? "{$model}_file" : $model . "_" . $this->g('field');
     /**
      * 多个文件下载的判断,如果存放文件的字段有多个文件存在时
      * 则根据提交过来的num参数,进行获取文件。
      * 由于拆分的文件,数组键值是从0开始的。所以需要减1
      */
     $num = $this->isG('num', '请选择要下载的文件序号');
     $res = \Model\Content::findContent($model, $id, "{$model}_id");
     if (empty($res)) {
         echo '<script>alert("文件已丢失或者地址不正确")</script>';
         exit;
     }
     $arrayFile = explode(',', $res[$field]);
     //确保下载的文件次序在范围内。
     if ($num > count($arrayFile)) {
         echo '<script>alert("文件已丢失或者地址不正确")</script>';
         exit;
     }
     $file = PES_PATH . $arrayFile[$num];
     $path_parts = pathinfo($file);
     \Core\Func\CoreFunc::$defaultPath = false;
     if (class_exists('\\finfo')) {
         $finfo = new \finfo(FILEINFO_MIME);
         $array = explode(';', $finfo->file($file));
         $mimetypes = $array[0];
     } elseif (function_exists('mime_content_type')) {
         $mimetypes = mime_content_type($file);
     } else {
         $mimetypes = $this->mimetypes[$path_parts['extension']];
         if (empty($mimetypes)) {
             echo '<script>alert("系统无法获知文件类型")</script>';
             exit;
         }
     }
     $name = empty($res["{$model}_title"]) ? '附件' : $res["{$model}_title"];
     header("Content-type: {$mimetypes}");
     header('Content-Disposition: attachment; filename="' . $name . "_{$num}" . '.' . $path_parts['extension'] . '"');
     readfile($file);
     exit;
 }
 public function __construct()
 {
     require dirname(dirname(__FILE__)) . '/Email/PHPMailerAutoload.php';
     $this->mail = new \PHPMailer();
     $siteTitle = \Model\Content::findContent('option', 'sitetitle', 'option_name')['value'];
     $mailSetting = json_decode(\Model\Content::findContent('option', 'mail', 'option_name')['value'], true);
     $this->trigger = $mailSetting['trigger'];
     $this->mail->CharSet = "utf-8";
     $this->mail->isSMTP();
     $this->mail->Host = $mailSetting['address'];
     $this->mail->SMTPAuth = true;
     $this->mail->Username = $mailSetting['account'];
     $this->mail->Password = $mailSetting['passwd'];
     $this->mail->SMTPSecure = 'tls';
     $this->mail->Port = $mailSetting['port'];
     $this->mail->From = $mailSetting['account'];
     $this->mail->FromName = $siteTitle;
 }
 /**
  * 添加报表
  * @param type $content 表报内容
  * @param type $taskId 任务ID | 主要用于任务日志追加为报表
  * @return type
  */
 public static function addReport($content, $taskId = '')
 {
     $findReport = self::db('report')->where('report_date = :report_date AND user_id = :user_id')->find(array('report_date' => date('Y-m-d'), 'user_id' => $_SESSION['team']['user_id']))['report_id'];
     if (empty($findReport)) {
         $findReport = self::db('report')->insert(array('report_date' => date('Y-m-d'), 'user_id' => $_SESSION['team']['user_id'], 'department_id' => $_SESSION['team']['user_department_id']));
         \Model\User::setEy($_SESSION['team']['user_id'], '1');
     } else {
         //防止由于用户迁移部门,导致获取当天报表失败
         self::db('report')->where('report_id = :report_id')->update(array('department_id' => $_SESSION['team']['user_department_id'], 'noset' => array('report_id' => $findReport)));
     }
     if (!empty($taskId)) {
         $task = \Model\Content::findContent('task', $taskId, 'task_id');
         $data['task_id'] = $task['task_id'];
         $data['task_title'] = $task['task_title'];
         $data['task_status'] = $task['task_status'];
     }
     $data['report_id'] = $findReport;
     $data['report_content'] = $content;
     return $report_content = self::db('report_content')->insert($data);
 }
Exemple #25
0
 /**
  * 注册帐号
  */
 public function signup()
 {
     if (\Model\Option::findOption('signup')['value'] == '0') {
         $this->error('本系统没有开启注册。');
     }
     $data['user_account'] = $this->isP('account', '请填写帐号');
     $existAccount = \Model\Content::findContent('user', $data['user_account'], 'user_account');
     if (!empty($existAccount)) {
         $this->error('帐号已存在');
     }
     $data['user_password'] = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $this->isP('password', '请填写密码'), 'PRIVATE_KEY');
     $repwd = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $this->isP('repassword', '请填写密码'), 'PRIVATE_KEY');
     if ($data['user_password'] != $repwd) {
         $this->error('两次密码不一致');
     }
     $data['user_mail'] = $this->isP('mail', '请填写帐号');
     $existEmail = \Model\Content::findContent('user', $data['user_mail'], 'user_mail');
     if (!empty($existEmail)) {
         $this->error('邮箱地址已存在');
     }
     \Core\Func\CoreFunc::$defaultPath = false;
     require PES_PATH . '/Expand/Identicon/autoload.php';
     $identicon = new \Identicon\Identicon();
     $imageDataUri = $identicon->getImageDataUri($data['user_mail']);
     $data['user_name'] = $this->isP('name', '请填写帐号');
     $data['user_status'] = '1';
     $data['user_createtime'] = time();
     $data['user_department_id'] = '2';
     //人事部
     $data['user_group_id'] = '2';
     //普通用户
     $data['user_head'] = $imageDataUri;
     $addResult = $this->db('user')->insert($data);
     if (empty($addResult)) {
         $this->error('注册失败');
     }
     unset($data['user_password']);
     $data['user_id'] = $addResult;
     $this->setLogin($data);
     $this->success('注册成功!', $this->url(GROUP . '-Index-index'));
 }
Exemple #26
0
 /**
  * 删除树
  */
 public function action()
 {
     $id = $this->isG('id', '请选择您要删除的树');
     if ($id === '1') {
         $this->error('树目录必须预留一个');
     }
     //检查是否有文章使用
     $check = \Model\Content::findContent('doc', $id, 'doc_tree_id');
     if (!empty($check)) {
         $this->error('删除前需要先迁移旗下文章到别的树');
     }
     $checkChild = \Model\Content::findContent('tree', $id, 'tree_parent');
     if (!empty($checkChild)) {
         $this->error('删除前需要先迁移旗下的子树');
     }
     $result = $this->db('tree')->where('tree_id = :id')->delete(array('id' => $id));
     if ($result === false) {
         $this->error('删除出错');
     }
     $this->success('删除成功', $this->url('/d/manage', true));
 }
Exemple #27
0
 /**
  * 提交任务日志
  */
 public function diary()
 {
     $data['task_id'] = $this->isP('task_id', '请选择任务');
     $task = \Model\Content::findContent('task', $data['task_id'], 'task_id');
     if (empty($task) || $_SESSION['team']['user_id'] != $task['task_user_id'] || $task['task_delete'] == '1') {
         $this->error('任务不存在或者您不是本任务执行人');
     }
     $data['diary_content'] = $this->isP('content', '请填写任务日志');
     $data['diary_time'] = time();
     $this->db()->transaction();
     $addResult = $this->db('task_diary')->insert($data);
     if (empty($addResult)) {
         $this->db()->rollBack();
         $this->error('添加日志失败');
     }
     //追加为报表
     if (!\Model\Report::addReport($data['diary_content'], $task['task_id'])) {
         $this->db()->rollBack();
         $this->error('添加报表失败');
     }
     $this->db()->commit();
     $this->success('发表任务日志成功!', $this->url('Team-Task-view', array('id' => $data['task_id'])));
 }
Exemple #28
0
 /**
  * 切换内容版本
  */
 public function useVersion()
 {
     $id = $this->isG('id', '请选择您要切换的历史版本');
     $history = \Model\Content::findContent('doc_content_history', $id, 'doc_content_history_id');
     if (empty($history)) {
         $this->error('不存在的历史版本');
     }
     $this->db()->transaction();
     $this->db('doc_content_history')->where('doc_content_id = :doc_content_id')->update(array('doc_content_current' => '0', 'noset' => array('doc_content_id' => $history['doc_content_id'])));
     //标记版本使用
     $setResult = $this->db('doc_content_history')->where('doc_content_history_id = :doc_content_history_id')->update(array('doc_content_current' => '1', 'noset' => array('doc_content_history_id' => $history['doc_content_history_id'])));
     if ($setResult == '0') {
         $this->db()->rollBack();
         $this->error('当前版本似乎已经在使用了');
     }
     //更新内容
     $updateContent = $this->db('doc_content')->where('doc_content_id = :doc_content_id')->update(array('doc_content' => $history['doc_content'], 'user_id' => $_SESSION['user']['user_id'], 'doc_content_updatetime' => time(), 'noset' => array('doc_content_id' => $history['doc_content_id'])));
     if ($updateContent == '0') {
         $this->db()->rollBack();
         $this->error('更新出错或者内容没有变化');
     }
     $this->db()->commit();
     $this->success('切换版本成功!');
 }
 /**
  * 获取更新
  * @param type $version 当前版本
  * @return boolean 返回获取的版本信息
  */
 public static function getUpdate($version)
 {
     if (!function_exists('curl_init')) {
         return array('status' => '-1', 'mes' => '系统没有启动CURL扩展');
     }
     $url = "http://api.pescms.com/page/index/version/{$version}/program/2";
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_TIMEOUT, 30);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     $tmpInfo = curl_exec($curl);
     curl_close($curl);
     $update = json_decode($tmpInfo, true);
     if ($update['status'] == '200') {
         $findUpdate = \Model\Content::findContent('update_list', $version, 'update_list_pre_version');
         if (empty($findUpdate)) {
             self::db('update_list')->insert(array('update_list_pre_version' => $version, 'update_list_version' => $update['info']['version'], 'update_list_createtime' => $update['info']['createtime'], 'update_list_type' => $update['info']['type'], 'update_list_content' => $update['info']['content'], 'update_list_file' => $update['info']['file'], 'update_list_sql' => $update['info']['sql']));
         }
     }
     return $update;
 }
Exemple #30
0
 /**
  * 获取对应的字段,然后进行内容值匹配
  * @param type $fieldId 字段ID
  * @param type $value 进行匹配的值
  */
 public function getFieldOptionToMatch($fieldId, $value)
 {
     $fieldContent = \Model\Content::findContent('field', $fieldId, 'field_id');
     $option = json_decode(htmlspecialchars_decode($fieldContent['field_option']), true);
     $search = array_search($value, $option);
     if (empty($search)) {
         return '未知值';
     } else {
         return $search;
     }
 }