当前位置: 首页>>代码示例>>PHP>>正文


PHP UserUtil::getUserDep方法代码示例

本文整理汇总了PHP中UserUtil::getUserDep方法的典型用法代码示例。如果您正苦于以下问题:PHP UserUtil::getUserDep方法的具体用法?PHP UserUtil::getUserDep怎么用?PHP UserUtil::getUserDep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserUtil的用法示例。


在下文中一共展示了UserUtil::getUserDep方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTopicInfo

 /**
  * 取得帖子的信息
  * @param:  &$db
  * @param:  $id
  * @param:  $pre_page
  * @param:  $offset_page
  * @return: $topic_array 
  * @access: public
  * @static
  */
 public static function getTopicInfo(&$db, $id, $pre_page = 10, $offset_page = 0)
 {
     /*{{{*/
     $topic_array = array();
     $topic_status = self::getTopicStatus($db, $id);
     //如果显示第一页,则必须给出主题
     if ($offset_page == 0) {
         $sql = 'select title, express, author, content, post_date, is_edit, ' . ' edit_user, edit_time, subject_status, is_best, is_top from bbs_subject where id=?';
         $sth = $db->Prepare($sql);
         $res = $db->Execute($sth, array($id));
         $rows = $res->FetchRow();
         $posttime = set_locale_time($rows['post_date']);
         $user_name = $rows['author'];
         $user_id = UserUtil::getUserId($db, $user_name);
         $user_header = UserUtil::getUserHeader($db, $user_id);
         $user_info = UserUtil::getUserInfo($db, $user_id);
         $register_date = $user_info['register_date'];
         $user_level = $user_info['user_level'];
         $user_address = $user_info['user_hometown'];
         $user_topic_number = $user_info['user_topic'];
         $user_sign = ConvertString($user_info['user_sign'], ROOT_URL, IMAGE_URL . 'express/');
         $is_edit = 0;
         $edit_user = '';
         $edit_time = '';
         if ($rows['is_edit']) {
             $is_edit = 1;
             $edit_user = $rows['edit_user'];
             $edit_time = $rows['edit_time'];
         }
         $user_online = UserUtil::isOnline($db, $user_id);
         $user_can_be_edit = 0;
         if (!$_SESSION['user']['name']) {
             $user_can_be_edit = 0;
         } else {
             if (strtolower($_SESSION['user']['name']) == strtolower($user_name)) {
                 $user_can_be_edit = 1;
             } else {
                 if (strtolower($_SESSION['user']['name']) != strtolower($user_name)) {
                     //判断用户是否是这个版块的版主。
                     $dep = UserUtil::getUserDep($db, $_SESSION['user']['name']);
                     if ($dep == 1 || $dep == 2) {
                         $user_can_be_edit = 1;
                     } else {
                         if ($dep == 3) {
                             $temp_layout_id = self::getLayoutId($db, $id);
                             $user_can_be_edit = UserUtil::isThisLayoutAdmin($db, $id, $temp_layout_id, $_SESSION['user']['name']);
                         }
                     }
                 }
             }
         }
         //判断是否有附件
         //如果有附件,则使用代码替换
         $content = '';
         if ($topic_status == 2) {
             $content = TU_TOPIC_WAS_LOCKED;
         } else {
             $content = $rows['content'] . self::haveAttach($db, $id);
             if ($is_edit) {
                 $attach_string = TU_SUB_TITLE . $edit_user . TU_FROM . $edit_time . TU_EDIT;
                 $content .= "\n\n" . $attach_string;
             }
         }
         $title = $rows['title'];
         $title = htmlspecialchars($title);
         if ($rows['is_best']) {
             $title = "<font color=red>[" . BEST_LABEL . "]</font>" . $title;
         }
         if ($rows['is_top']) {
             $title = "<font color=red>[" . TOP_LABEL . "]</font>" . $title;
         }
         $topic_array[] = array('id' => $id, 'posttime' => $posttime, 'sort_number' => 1, 'user_name' => $user_name, 'user_id' => $user_id, 'user_header' => $user_header, 'user_sign' => $user_sign, 'register_date' => $register_date, 'user_level' => $user_level, 'user_address' => $user_address, 'user_topic_number' => $user_topic_number, 'title' => $title, 'content' => ConvertString($content, ROOT_URL, IMAGE_URL . 'express/'), 'online' => $user_online, 'can_be_edit' => $user_can_be_edit, 'is_topic' => 1, 'express' => $rows['express']);
         $pre_page = $pre_page - 1;
     } else {
         if ($offset_page >= 1) {
             $offset_page = $offset_page - 1;
         }
     }
     //再查回复的帖子
     $sql = 'select id, title, express,author, content, post_date, is_edit, edit_user, ' . ' edit_time, reply_status from bbs_reply where subject_id=? ' . ' order by id asc';
     $res = $db->SelectLimit($sql, $pre_page, $offset_page, array($id));
     while ($rows = $res->FetchRow()) {
         $posttime = set_locale_time($rows['post_date']);
         $sort_number = $sort_begin;
         $user_name = $rows['author'];
         $user_id = UserUtil::getUserId($db, $user_name);
         $user_header = UserUtil::getUserHeader($db, $user_id);
         $user_info = UserUtil::getUserInfo($db, $user_id);
         $register_date = $user_info['register_date'];
         $user_level = $user_info['user_level'];
//.........这里部分代码省略.........
开发者ID:hylinux,项目名称:ltebbs,代码行数:101,代码来源:TopicUtil.class.php

示例2: run

 /**
  * 运行本类
  */
 public function run()
 {
     /*{{{*/
     $id = $this->getParameterFromGET('id');
     $is_topic = $this->getParameterFromGET('topic');
     $bbs_id = 0;
     //判断$id是否存在。
     if ($is_topic == 1) {
         //如果等于1,则为主题
         if (!TopicUtil::isExists($this->db, $id)) {
             $this->AlertAndBack(SE_TOPIC_ID_IS_NOT_EXISTS);
             return;
         } else {
             //如果存在,则判断用户是否有权利修改
             $sql = 'select author, layout_id from bbs_subject where id=?';
             $sth = $this->db->Prepare($sql);
             $res = $this->db->Execute($sth, array($id));
             $rows = $res->FetchRow();
             $user_name = $rows['author'];
             $bbs_id = $rows['layout_id'];
             $user_can_be_edit = 0;
             if (strtolower($_SESSION['user']['name']) == strtolower($user_name)) {
                 $user_can_be_edit = 1;
             } else {
                 if (strtolower($_SESSION['user']['name']) != strtolower($user_name)) {
                     //判断用户是否是这个版块的版主。
                     $dep = UserUtil::getUserDep($this->db, $_SESSION['user']['name']);
                     if ($dep == 1 || $dep == 2) {
                         $user_can_be_edit = 1;
                     } else {
                         if ($dep == 3) {
                             $user_can_be_edit = UserUtil::isThisLayoutAdmin($this->db, $id, $bbs_id, $_SESSION['user']['name']);
                         }
                     }
                 }
             }
             if (!$user_can_be_edit) {
                 $this->AlertAndBack(SE_YOU_HAVE_NO_PRIVIATE);
                 return;
             }
         }
     } else {
         //$topic 为其他值,那么就是回帖,而不是主题
         $sql = 'select author, subject_id, layout_id from bbs_reply where id=?';
         $sth = $this->db->Prepare($sql);
         $res = $this->db->Execute($sth, array($id));
         $rows = $res->FetchRow();
         if (!$rows['author']) {
             $this->AlertAndBack(SE_TOPIC_ID_IS_NOT_EXISTS);
             return;
         }
         //如果存在,
         //则判断用户是否有权限
         $user_name = $rows['author'];
         $subject_id = $rows['subject_id'];
         $bbs_id = $rows['layout_id'];
         $user_can_be_edit = 0;
         if (strtolower($_SESSION['user']['name']) == strtolower($user_name)) {
             $user_can_be_edit = 1;
         } else {
             if (strtolower($_SESSION['user']['name']) != strtolower($user_name)) {
                 //判断用户是否是这个版块的版主。
                 $dep = UserUtil::getUserDep($this->db, $_SESSION['user']['name']);
                 if ($dep == 1 || $dep == 2) {
                     $user_can_be_edit = 1;
                 } else {
                     if ($dep == 3) {
                         $user_can_be_edit = UserUtil::isThisLayoutAdmin($this->db, $subject_id, $bbs_id, $_SESSION['user']['name']);
                     }
                 }
             }
         }
         if (!$user_can_be_edit) {
             $this->AlertAndBack(SE_YOU_HAVE_NO_PRIVIATE);
             return;
         }
     }
     $smarty = $this->getSmarty();
     if ($is_topic) {
         $smarty->assign('clone_title', SE_EDIT_TOPIC);
     } else {
         $smarty->assign('clone_title', SE_EDIT_REPLY);
     }
     //更新用户在本版的信息
     LayoutUtil::updateOnlineUser($this->db, $bbs_id);
     //返回论坛上面的导行栏。
     $nav_array = LayoutUtil::getParentLayoutInfo($this->db, $bbs_id);
     //导航栏
     $smarty->assign('nav_array', $nav_array);
     //先删除已经不存在的用户
     LayoutUtil::delNotExistsUser($this->db);
     //用户有权限了。
     //则可以开始显示用户帖子的内容
     $smarty->assign('id_edit', 1);
     $smarty->assign('is_topic', $is_topic);
     $smarty->assign('is_edit', 1);
     $smarty->assign('bbsid', $id);
//.........这里部分代码省略.........
开发者ID:hylinux,项目名称:ltebbs,代码行数:101,代码来源:ShowEdit.class.php

示例3: run

 /**
  * 保存编辑后的帖子
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //收集变量
     $topic = $this->getParameterFromPOST('topic');
     $id = $this->getParameterFromPOST('id');
     $title = $this->getParameterFromPOST('title');
     $content = $this->getParameterFromPOST('content');
     $express = $this->getParameterFromPOST('express');
     $delattach = $this->getParameterFromPOST('delattach');
     if (!$title || strlen($title) <= 0) {
         $this->AlertAndBack(SE_TITLE_IS_EMPTY);
         return;
     }
     /*
           if ( strlen($title) > 140 ) {
              $this->AlertAndBack(SE_TITLE_TOO_LONG);
              return;
           }*/
     if (!$content || strlen($content) <= 0) {
         $this->AlertAndBack(SE_CONTENT_IS_EMPTY);
         return;
     }
     //做出基本的判断/*{{{*/
     if (!$id) {
         $this->AlertandBack(SE_NO_TOPIC_ID);
         return;
     }
     //找出这个帖子所在的版块的id, 作者。
     $layout_id = 0;
     $author = '';
     if ($topic) {
         //如果是主题
         $sql = 'select layout_id, author from bbs_subject where id=?';
         $sth = $this->db->prepare($sql);
         $res = $this->db->execute($sth, array($id));
         $rows = $res->FetchRow();
         $layout_id = $rows['layout_id'];
         $author = $rows['author'];
     } else {
         $sql = 'select layout_id, author from bbs_reply where id=?';
         $sth = $this->db->prepare($sql);
         $res = $this->db->execute($sth, array($id));
         $rows = $res->FetchRow();
         $layout_id = $rows['layout_id'];
         $author = $rows['author'];
     }
     if (!$layout_id) {
         //保存的帖子根本不存在。
         $this->AlertAndBlack(SE_TOPIC_IS_NOT_EXISTS);
         return;
     }
     //判断用户是否可以编辑
     if ($topic) {
         //如果等于1,则为主题
         //如果存在,则判断用户是否有权利修改
         $sql = 'select author, layout_id from bbs_subject where id=?';
         $sth = $this->db->Prepare($sql);
         $res = $this->db->Execute($sth, array($id));
         $rows = $res->FetchRow();
         $user_name = $rows['author'];
         $bbs_id = $rows['layout_id'];
         $user_can_be_edit = 0;
         if (strtolower($_SESSION['user']['name']) == strtolower($user_name)) {
             $user_can_be_edit = 1;
         } else {
             if (strtolower($_SESSION['user']['name']) != strtolower($user_name)) {
                 //判断用户是否是这个版块的版主。
                 $dep = UserUtil::getUserDep($db, $_SESSION['user']['name']);
                 if ($dep == 1 || $dep == 2) {
                     $user_can_be_edit = 1;
                 } else {
                     if ($dep == 3) {
                         $user_can_be_edit = UserUtil::isThisLayoutAdmin($db, $id, $_SESSION['user']['name']);
                     }
                 }
             }
         }
         if (!$user_can_be_edit) {
             $this->AlertAndBack(SE_YOU_HAVE_NO_PRIVIATE);
             return;
         }
     } else {
         //$topic 为其他值,那么就是回帖,而不是主题
         $sql = 'select author, subject_id, layout_id from bbs_reply where id=?';
         $sth = $this->db->Prepare($sql);
         $res = $this->db->Execute($sth, array($id));
         $rows = $res->FetchRow();
         if (!$rows['author']) {
             $this->AlertAndBack(SE_TOPIC_ID_IS_NOT_EXISTS);
             return;
         }
         //如果存在,
         //则判断用户是否有权限
         $user_name = $rows['author'];
//.........这里部分代码省略.........
开发者ID:hylinux,项目名称:ltebbs,代码行数:101,代码来源:SaveEdit.class.php


注:本文中的UserUtil::getUserDep方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。