當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。