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


PHP forum_permissions函数代码示例

本文整理汇总了PHP中forum_permissions函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_permissions函数的具体用法?PHP forum_permissions怎么用?PHP forum_permissions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: action

 /**
 This is where you perform the action when the API is called, the parameter given is an instance of stdClass, this method should return an instance of stdClass.
 */
 public function action()
 {
     global $mybb, $db;
     $api = APISystem::get_instance();
     if (isset($api->paths[1]) && is_string($api->paths[1])) {
         switch (strtolower($api->paths[1])) {
             case "list":
                 if (isset($api->paths[2]) && is_string($api->paths[2]) && isset($forums[$api->paths[2]])) {
                     return (object) $forums[$api->paths[2]];
                 } else {
                     return (object) $forums;
                 }
                 break;
             case "posts":
                 if (isset($api->paths[2]) && is_string($api->paths[2])) {
                     $posts = array();
                     $tid = $db->escape_string($api->paths[2]);
                     $query = $db->write_query("SELECT * FROM " . TABLE_PREFIX . "posts p WHERE p.`tid` = '{$tid}'");
                     while ($post = $db->fetch_array($query)) {
                         $posts[$post["pid"]] = $post;
                     }
                     return (object) $posts;
                 } else {
                     // what forum?
                 }
                 break;
             case "permissions":
                 $forumpermissions = forum_permissions();
                 return (object) $forumpermissions;
             default:
                 break;
         }
     }
     throw new BadRequestException("No valid option given in the URL.");
 }
开发者ID:Shade-,项目名称:MyBB-RESTful-API-System,代码行数:38,代码来源:threadapi.class.php

示例2: get_forum_func

function get_forum_func()
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $forumpermissions, $fcache, $forum_cache;
    $lang->load("index");
    $inactiveforums = get_inactive_forums();
    if ($mybb->user['uid'] == 0) {
        // Build a forum cache.
        $query = $db->query("\n            SELECT *, threads as unread_count\n            FROM " . TABLE_PREFIX . "forums\n            WHERE active != 0 " . ($inactiveforums ? " AND fid NOT IN ({$inactiveforums})" : '') . "\n            ORDER BY pid, disporder\n        ");
        $forumsread = unserialize($mybb->cookies['mybb']['forumread']);
    } else {
        // Build a forum cache.
        $query = $db->query("\n            SELECT f.*, fr.dateline AS lastread, fs.fsid, (\n                select count(*) from " . TABLE_PREFIX . "threads where fid=f.fid and lastpost > fr.dateline\n            ) as unread_count\n            FROM " . TABLE_PREFIX . "forums f\n            LEFT JOIN " . TABLE_PREFIX . "forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}')\n            LEFT JOIN " . TABLE_PREFIX . "forumsubscriptions fs ON (fs.fid=f.fid AND fs.uid='{$mybb->user['uid']}')\n            WHERE f.active != 0 " . ($inactiveforums ? " AND f.fid NOT IN ({$inactiveforums})" : '') . "\n            ORDER BY pid, disporder\n        ");
    }
    while ($forum = $db->fetch_array($query)) {
        if ($mybb->user['uid'] == 0) {
            if ($forumsread[$forum['fid']]) {
                $forum['lastread'] = $forumsread[$forum['fid']];
            }
        }
        $fcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
    }
    $forumpermissions = forum_permissions();
    $excols = "index";
    $permissioncache['-1'] = "1";
    $showdepth = 10;
    $xml_nodes = new xmlrpcval(array(), 'array');
    $done = array();
    $xml_tree = treeBuild(0, $fcache, $xml_nodes, $done);
    $xml_nodes->addArray($xml_tree);
    return new xmlrpcresp($xml_nodes);
}
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:31,代码来源:get_forum.php

示例3: remove_attachment_func

function remove_attachment_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    chdir("../");
    $lang->load("member");
    $parser = new postParser();
    $input = Tapatalk_Input::filterXmlInput(array('attachment_id' => Tapatalk_Input::INT, 'forum_id' => Tapatalk_Input::INT, 'group_id' => Tapatalk_Input::STRING, 'post_id' => Tapatalk_Input::INT), $xmlrpc_params);
    $fid = $input['forum_id'];
    $forum = get_forum($fid);
    if (!$forum) {
        return xmlrespfalse($lang->error_invalidforum);
    }
    $forumpermissions = forum_permissions($fid);
    if ($forum['open'] == 0 || $forum['type'] != "f") {
        return xmlrespfalse($lang->error_closedinvalidforum);
    }
    if ($mybb->user['uid'] < 1 || $forumpermissions['canview'] == 0 || $forumpermissions['canpostthreads'] == 0 || $mybb->user['suspendposting'] == 1) {
        return tt_no_permission();
    }
    tt_check_forum_password($forum['fid']);
    $posthash = $input['group_id'];
    $mybb->input['posthash'] = $posthash;
    // If we're removing an attachment that belongs to an existing post, some security checks...
    $query = $db->simple_select("attachments", "pid", "aid='{$input['attachment_id']}'");
    $attachment = $db->fetch_array($query);
    $pid = $attachment['pid'];
    if ($pid > 0) {
        if ($pid != $input['post_id']) {
            return xmlrespfalse("The attachment you are trying to remove does not belong to this post");
        }
        $query = $db->simple_select("posts", "*", "pid='{$pid}'");
        $post = $db->fetch_array($query);
        if (!$post['pid']) {
            return xmlrespfalse($lang->error_invalidpost);
        }
        // Get thread info
        $tid = $post['tid'];
        $thread = get_thread($tid);
        if (!$thread['tid']) {
            return xmlrespfalse($lang->error_invalidthread);
        }
        if (!is_moderator($fid, "caneditposts")) {
            if ($thread['closed'] == 1) {
                return xmlrespfalse($lang->redirect_threadclosed);
            }
            if ($forumpermissions['caneditposts'] == 0) {
                return tt_no_permission();
            }
            if ($mybb->user['uid'] != $post['uid']) {
                return tt_no_permission();
            }
        }
    } else {
        $pid = 0;
    }
    require_once MYBB_ROOT . "inc/functions_upload.php";
    remove_attachment($pid, $mybb->input['posthash'], $input['attachment_id']);
    return xmlresptrue();
}
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:59,代码来源:remove_attachment.php

示例4: upload_attach_func

function upload_attach_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $lang->load("member");
    $parser = new postParser();
    $input = Tapatalk_Input::filterXmlInput(array('forum_id' => Tapatalk_Input::INT, 'group_id' => Tapatalk_Input::STRING, 'content' => Tapatalk_Input::STRING), $xmlrpc_params);
    $fid = $input['forum_id'];
    //return xmlrespfalse(print_r($_FILES, true));
    // Fetch forum information.
    $forum = get_forum($fid);
    if (!$forum) {
        return xmlrespfalse($lang->error_invalidforum);
    }
    $forumpermissions = forum_permissions($fid);
    if ($forum['open'] == 0 || $forum['type'] != "f") {
        return xmlrespfalse($lang->error_closedinvalidforum);
    }
    if ($mybb->user['uid'] < 1 || $forumpermissions['canview'] == 0 || $forumpermissions['canpostthreads'] == 0 || $mybb->user['suspendposting'] == 1) {
        return tt_no_permission();
    }
    // Check if this forum is password protected and we have a valid password
    tt_check_forum_password($forum['fid']);
    $posthash = $input['group_id'];
    if (empty($posthash)) {
        $posthash = md5($mybb->user['uid'] . random_str());
    }
    $mybb->input['posthash'] = $posthash;
    if (!empty($mybb->input['pid'])) {
        $attachwhere = "pid='{$mybb->input['pid']}'";
    } else {
        $attachwhere = "posthash='{$posthash}'";
    }
    $query = $db->simple_select("attachments", "COUNT(aid) as numattachs", $attachwhere);
    $attachcount = $db->fetch_field($query, "numattachs");
    //if(is_array($_FILES['attachment']['name'])){
    foreach ($_FILES['attachment'] as $k => $v) {
        if (is_array($_FILES['attachment'][$k])) {
            $_FILES['attachment'][$k] = $_FILES['attachment'][$k][0];
        }
    }
    //}
    if ($_FILES['attachment']['type'] == 'image/jpg') {
        $_FILES['attachment']['type'] = 'image/jpeg';
    }
    // If there's an attachment, check it and upload it
    if ($_FILES['attachment']['size'] > 0 && $forumpermissions['canpostattachments'] != 0 && ($mybb->settings['maxattachments'] == 0 || $attachcount < $mybb->settings['maxattachments'])) {
        require_once MYBB_ROOT . "inc/functions_upload.php";
        $attachedfile = upload_attachment($_FILES['attachment'], false);
    }
    if (empty($attachedfile)) {
        return xmlrespfalse("No file uploaded");
    }
    //return xmlrespfalse(print_r($attachedfile, true));
    if ($attachedfile['error']) {
        return xmlrespfalse(implode(" :: ", $attachedfile['error']));
    }
    $result = new xmlrpcval(array('attachment_id' => new xmlrpcval($attachedfile['aid'], 'string'), 'group_id' => new xmlrpcval($posthash, 'string'), 'result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'file_size' => new xmlrpcval($attachedfile['filesize'], 'int')), 'struct');
    return new xmlrpcresp($result);
}
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:59,代码来源:upload_attach.php

示例5: fetch_unread_count

/**
 * Fetches the number of unread threads for the current user in a particular forum.
 *
 * @param string The forums (CSV list)
 * @return int The number of unread threads
 */
function fetch_unread_count($fid)
{
    global $cache, $db, $mybb;
    $onlyview = $onlyview2 = '';
    $permissions = forum_permissions($fid);
    $cutoff = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24;
    if (!empty($permissions['canonlyviewownthreads'])) {
        $onlyview = " AND uid = '{$mybb->user['uid']}'";
        $onlyview2 = " AND t.uid = '{$mybb->user['uid']}'";
    }
    if ($mybb->user['uid'] == 0) {
        $comma = '';
        $tids = '';
        $threadsread = my_unserialize($mybb->cookies['mybb']['threadread']);
        $forumsread = my_unserialize($mybb->cookies['mybb']['forumread']);
        if (!empty($threadsread)) {
            foreach ($threadsread as $key => $value) {
                $tids .= $comma . intval($key);
                $comma = ',';
            }
        }
        if (!empty($tids)) {
            $count = 0;
            // We've read at least some threads, are they here?
            $query = $db->simple_select("threads", "lastpost, tid, fid", "visible=1 AND closed NOT LIKE 'moved|%' AND fid IN ({$fid}) AND lastpost > '{$cutoff}'{$onlyview}", array("limit" => 100));
            while ($thread = $db->fetch_array($query)) {
                if ($thread['lastpost'] > intval($threadsread[$thread['tid']]) && $thread['lastpost'] > intval($forumsread[$thread['fid']])) {
                    ++$count;
                }
            }
            return $count;
        }
        // Not read any threads?
        return false;
    } else {
        // START - Unread posts MOD
        $fieldname = 'dateline';
        if (function_exists("unreadPosts_is_installed") && unreadPosts_is_installed()) {
            $cutoff = $mybb->user['lastmark'];
        }
        // END - Unread posts MOD
        switch ($db->type) {
            case "pgsql":
                $query = $db->query("\n                    SELECT COUNT(t.tid) AS unread_count\n                    FROM " . TABLE_PREFIX . "threads t\n                    LEFT JOIN " . TABLE_PREFIX . "threadsread tr ON (tr.tid=t.tid AND tr.uid='{$mybb->user['uid']}')\n                    LEFT JOIN " . TABLE_PREFIX . "forumsread fr ON (fr.fid=t.fid AND fr.uid='{$mybb->user['uid']}')\n                    WHERE t.visible=1 AND t.closed NOT LIKE 'moved|%' \n                        AND t.fid IN ({$fid}) \n                        AND t.lastpost > COALESCE(tr.dateline,{$cutoff}) \n                        AND t.lastpost > COALESCE(fr.dateline,{$cutoff}) \n                        AND t.lastpost > {$cutoff}\n                        {$onlyview2}\n                ");
                break;
            default:
                $query = $db->query("\n                    SELECT COUNT(t.tid) AS unread_count\n                    FROM " . TABLE_PREFIX . "threads t\n                    LEFT JOIN " . TABLE_PREFIX . "threadsread tr ON (tr.tid=t.tid AND tr.uid='{$mybb->user['uid']}')\n                    LEFT JOIN " . TABLE_PREFIX . "forumsread fr ON (fr.fid=t.fid AND fr.uid='{$mybb->user['uid']}')\n                    WHERE t.visible=1 AND t.closed NOT LIKE 'moved|%' \n                        AND t.fid IN ({$fid}) \n                        AND t.lastpost > IFNULL(tr.dateline,{$cutoff}) \n                        AND t.lastpost > IFNULL(fr.dateline,{$cutoff}) \n                        AND t.lastpost > {$cutoff}\n                        {$onlyview2}\n                ");
        }
        return (int) $db->fetch_field($query, "unread_count");
    }
}
开发者ID:kpietrek,项目名称:MyBB-View_Unread_posts,代码行数:57,代码来源:functions_indicators.php

示例6: subscribe_topic_func

function subscribe_topic_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $lang->load("usercp");
    $input = Tapatalk_Input::filterXmlInput(array('topic_id' => Tapatalk_Input::INT), $xmlrpc_params);
    $thread = get_thread($input['topic_id']);
    if (!$thread['tid']) {
        return xmlrespfalse($lang->error_invalidthread);
    }
    $forumpermissions = forum_permissions($thread['fid']);
    if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
        return tt_no_permission();
    }
    add_subscribed_thread($thread['tid'], 0);
    return xmlresptrue();
}
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:16,代码来源:subscribe_topic.php

示例7: action

 /**
 This is where you perform the action when the API is called, the parameter given is an instance of stdClass, this method should return an instance of stdClass.
 */
 public function action()
 {
     global $mybb, $db;
     $api = APISystem::get_instance();
     if (isset($api->paths[1]) && is_string($api->paths[1])) {
         $forums = cache_forums();
         switch (strtolower($api->paths[1])) {
             case "list":
                 if (isset($api->paths[2]) && is_string($api->paths[2]) && isset($forums[$api->paths[2]])) {
                     return (object) $forums[$api->paths[2]];
                 } else {
                     return (object) $forums;
                 }
                 break;
             case "threads":
                 if (isset($api->paths[2]) && is_string($api->paths[2]) && isset($forums[$api->paths[2]])) {
                     $threads = array();
                     $fid = $db->escape_string($api->paths[2]);
                     $query = $db->write_query("SELECT * FROM " . TABLE_PREFIX . "threads t WHERE t.`fid` = '{$fid}'");
                     while ($thread = $db->fetch_array($query)) {
                         $threads[$thread["tid"]] = $thread;
                     }
                     return (object) $threads;
                 } else {
                     // what forum?
                 }
                 break;
             case "permissions":
                 if (isset($api->paths[2]) && is_string($api->paths[2]) && isset($forums[$api->paths[2]]) && $this->is_authenticated()) {
                     return (object) forum_permissions($api->paths[2], $this->get_user()->id, $this->get_user()->usergroup);
                 } else {
                     //what forum?
                 }
             default:
                 break;
         }
     }
     throw new BadRequestException("No valid option given in the URL.");
 }
开发者ID:Shade-,项目名称:MyBB-RESTful-API-System,代码行数:42,代码来源:forumapi.class.php

示例8: get_subscribed_forum_func

function get_subscribed_forum_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $lang->load("usercp");
    if ($mybb->user['uid'] == 0 || $mybb->usergroup['canusercp'] == 0) {
        return tt_no_permission();
    }
    $query = $db->simple_select("forumpermissions", "*", "gid='" . $db->escape_string($mybb->user['usergroup']) . "'");
    while ($permissions = $db->fetch_array($query)) {
        $permissioncache[$permissions['gid']][$permissions['fid']] = $permissions;
    }
    // Build a forum cache.
    $query = $db->query("\n\t\tSELECT f.fid, fr.dateline AS lastread\n\t\tFROM " . TABLE_PREFIX . "forums f\n\t\tLEFT JOIN " . TABLE_PREFIX . "forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}')\n\t\tWHERE f.active != 0\n\t\tORDER BY pid, disporder\n\t");
    while ($forum = $db->fetch_array($query)) {
        if ($mybb->user['uid'] == 0) {
            if ($forumsread[$forum['fid']]) {
                $forum['lastread'] = $forumsread[$forum['fid']];
            }
        }
        $readforums[$forum['fid']] = $forum['lastread'];
    }
    require_once MYBB_ROOT . "inc/functions_forumlist.php";
    $fpermissions = forum_permissions();
    $query = $db->query("\n\t\tSELECT fs.*, f.*, t.subject AS lastpostsubject, fr.dateline AS lastread\n\t\tFROM " . TABLE_PREFIX . "forumsubscriptions fs\n\t\tLEFT JOIN " . TABLE_PREFIX . "forums f ON (f.fid = fs.fid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid = f.lastposttid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}')\n\t\tWHERE f.type='f' AND fs.uid='" . $mybb->user['uid'] . "'\n\t\tORDER BY f.name ASC\n\t");
    $forums = '';
    $forum_list = array();
    while ($forum = $db->fetch_array($query)) {
        $forumpermissions = $fpermissions[$forum['fid']];
        if ($forumpermissions['canview'] != 0) {
            $lightbulb = get_forum_lightbulb(array('open' => $forum['open'], 'lastread' => $forum['lastread']), array('lastpost' => $forum['lastpost']));
            $forum_list[] = new xmlrpcval(array('forum_id' => new xmlrpcval($forum['fid'], 'string'), 'forum_name' => new xmlrpcval(basic_clean($forum['name']), 'base64'), 'is_protected' => new xmlrpcval(!empty($forum['password']), 'boolean'), 'new_post' => new xmlrpcval($lightbulb['folder'] == 'on', 'boolean')), 'struct');
        }
    }
    $result = new xmlrpcval(array('total_forums_num' => new xmlrpcval(count($forum_list), 'int'), 'forums' => new xmlrpcval($forum_list, 'array')), 'struct');
    return new xmlrpcresp($result);
}
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:36,代码来源:get_subscribed_forum.php

示例9: implode

     if (!$mybb->user['ismoderator']) {
         $sql[] = "p.visible='1'";
         $sql[] = "t.visible='1'";
     }
     $sql = implode(' AND ', $sql);
     $query = $db->query("\n\t\t\tSELECT p.pid, p.uid, p.fid, p.visible, p.message, t.tid, t.subject, t.visible AS thread_visible\n\t\t\tFROM " . TABLE_PREFIX . "posts p\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\n\t\t\tWHERE {$sql}\n\t\t");
     $forumpermissions = array();
     while ($post = $db->fetch_array($query)) {
         if (($post['visible'] == 0 || $post['thread_visible'] == 0) && !is_moderator($post['fid'], 'canviewunapprove')) {
             continue;
         }
         if (($post['visible'] == -1 || $post['thread_visible'] == -1) && !is_moderator($post['fid'], 'canviewdeleted')) {
             continue;
         }
         if (!isset($forumpermissions[$post['fid']])) {
             $forumpermissions[$post['fid']] = forum_permissions($post['fid']);
         }
         // Make sure we can view this post
         if (isset($forumpermissions[$post['fid']]['canonlyviewownthreads']) && $forumpermissions[$post['fid']]['canonlyviewownthreads'] == 1 && $post['uid'] != $mybb->user['uid']) {
             continue;
         }
         $post_reputation[$post['pid']] = $post;
     }
 }
 $reputation_votes = '';
 foreach ($reputation_cache as $reputation_vote) {
     // Get the reputation for the user who posted this comment
     if ($reputation_vote['adduid'] == 0) {
         $reputation_vote['user_reputation'] = 0;
     }
     $reputation_vote['user_reputation'] = get_reputation($reputation_vote['user_reputation'], $reputation_vote['adduid']);
开发者ID:styv300,项目名称:ToRepublic2.5,代码行数:31,代码来源:reputation.php

示例10: update_post

 /**
  * Updates a post that is already in the database.
  *
  */
 function update_post()
 {
     global $db, $mybb, $plugins;
     // Yes, validating is required.
     if ($this->get_validated() != true) {
         die("The post needs to be validated before inserting it into the DB.");
     }
     if (count($this->get_errors()) > 0) {
         die("The post is not valid.");
     }
     $post =& $this->data;
     $post['pid'] = (int) $post['pid'];
     $existing_post = get_post($post['pid']);
     $post['tid'] = $existing_post['tid'];
     $post['fid'] = $existing_post['fid'];
     $forum = get_forum($post['fid']);
     $forumpermissions = forum_permissions($post['fid'], $post['uid']);
     // Check if this is the first post in a thread.
     $options = array("order_by" => "dateline", "order_dir" => "asc", "limit_start" => 0, "limit" => 1);
     $query = $db->simple_select("posts", "pid", "tid='" . (int) $post['tid'] . "'", $options);
     $first_post_check = $db->fetch_array($query);
     if ($first_post_check['pid'] == $post['pid']) {
         $first_post = true;
     } else {
         $first_post = false;
     }
     // Decide on the visibility of this post.
     $ismod = is_moderator($post['fid'], "", $post['uid']);
     // Keep visibility for unapproved and deleted posts
     if ($existing_post['visible'] == 0) {
         $visible = 0;
     } elseif ($existing_post['visible'] == -1) {
         $visible = -1;
     } elseif ($forumpermissions['mod_edit_posts'] == 1 && !$ismod) {
         $visible = 0;
         require_once MYBB_ROOT . "inc/class_moderation.php";
         $moderation = new Moderation();
         $moderation->unapprove_posts(array($post['pid']));
     } else {
         $visible = 1;
     }
     // Update the thread details that might have been changed first.
     if ($first_post) {
         $this->tid = $post['tid'];
         if (isset($post['prefix'])) {
             $this->thread_update_data['prefix'] = (int) $post['prefix'];
         }
         if (isset($post['subject'])) {
             $this->thread_update_data['subject'] = $db->escape_string($post['subject']);
         }
         if (isset($post['icon'])) {
             $this->thread_update_data['icon'] = (int) $post['icon'];
         }
         if (count($this->thread_update_data) > 0) {
             $plugins->run_hooks("datahandler_post_update_thread", $this);
             $db->update_query("threads", $this->thread_update_data, "tid='" . (int) $post['tid'] . "'");
         }
     }
     // Prepare array for post updating.
     $this->pid = $post['pid'];
     if (isset($post['subject'])) {
         $this->post_update_data['subject'] = $db->escape_string($post['subject']);
     }
     if (isset($post['message'])) {
         $this->post_update_data['message'] = $db->escape_string($post['message']);
     }
     if (isset($post['editreason']) && trim($post['editreason']) != '') {
         $this->post_update_data['editreason'] = $db->escape_string(trim($post['editreason']));
     }
     if (isset($post['icon'])) {
         $this->post_update_data['icon'] = (int) $post['icon'];
     }
     if (isset($post['options'])) {
         if (isset($post['options']['disablesmilies'])) {
             $this->post_update_data['smilieoff'] = $db->escape_string($post['options']['disablesmilies']);
         }
         if (isset($post['options']['signature'])) {
             $this->post_update_data['includesig'] = $db->escape_string($post['options']['signature']);
         }
     }
     // If we need to show the edited by, let's do so.
     if ($mybb->settings['showeditedby'] == 1 && !is_moderator($post['fid'], "caneditposts", $post['edit_uid']) || $mybb->settings['showeditedbyadmin'] == 1 && is_moderator($post['fid'], "caneditposts", $post['edit_uid'])) {
         $this->post_update_data['edituid'] = (int) $post['edit_uid'];
         $this->post_update_data['edittime'] = TIME_NOW;
     }
     $plugins->run_hooks("datahandler_post_update", $this);
     $db->update_query("posts", $this->post_update_data, "pid='" . (int) $post['pid'] . "'");
     // Automatic subscription to the thread
     if ($post['options']['subscriptionmethod'] != "" && $post['uid'] > 0) {
         switch ($post['options']['subscriptionmethod']) {
             case "pm":
                 $notification = 2;
                 break;
             case "email":
                 $notification = 1;
                 break;
//.........这里部分代码省略.........
开发者ID:olada,项目名称:mybbintegrator,代码行数:101,代码来源:post.php

示例11: build_archive_forumbits

/**
* Gets a list of forums and possibly subforums.
*
* @param int The parent forum to get the childforums for.
* @return array Array of information regarding the child forums of this parent forum
*/
function build_archive_forumbits($pid = 0)
{
    global $db, $forumpermissions, $mybb, $lang, $archiveurl, $base_url;
    // Sort out the forum cache first.
    static $fcache;
    if (!is_array($fcache)) {
        // Fetch forums
        $query = $db->simple_select("forums", "*", "active!=0 AND password=''", array('order_by' => 'pid, disporder'));
        while ($forum = $db->fetch_array($query)) {
            $fcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
        }
        $forumpermissions = forum_permissions();
    }
    // Start the process.
    if (is_array($fcache[$pid])) {
        foreach ($fcache[$pid] as $key => $main) {
            foreach ($main as $key => $forum) {
                $perms = $forumpermissions[$forum['fid']];
                if (($perms['canview'] == 1 || $mybb->settings['hideprivateforums'] == 0) && $forum['active'] != 0) {
                    if ($forum['linkto']) {
                        $forums .= "<li><a href=\"{$forum['linkto']}\">{$forum['name']}</a>";
                    } elseif ($forum['type'] == "c") {
                        $forums .= "<li><strong><a href=\"{$base_url}forum-{$forum['fid']}.html\">{$forum['name']}</a></strong>";
                    } else {
                        $forums .= "<li><a href=\"{$base_url}forum-{$forum['fid']}.html\">{$forum['name']}</a>";
                    }
                    if ($fcache[$forum['fid']]) {
                        $forums .= "\n<ol>\n";
                        $forums .= build_archive_forumbits($forum['fid']);
                        $forums .= "</ol>\n";
                    }
                    $forums .= "</li>\n";
                }
            }
        }
    }
    return $forums;
}
开发者ID:GeorgeLVP,项目名称:mybb,代码行数:44,代码来源:index.php

示例12: m_get_moderate_post_func

function m_get_moderate_post_func($xmlrpc_params)
{
    global $input, $post, $thread, $forum, $pid, $tid, $fid, $modlogdata, $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $moderation, $parser;
    $input = Tapatalk_Input::filterXmlInput(array('start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT), $xmlrpc_params);
    mod_setup();
    list($start, $limit) = process_page($input['start_num'], $input['last_num']);
    // Load global language phrases
    $lang->load("modcp");
    if ($mybb->user['uid'] == 0 || $mybb->usergroup['canmodcp'] != 1) {
        return tt_no_permission();
    }
    $errors = '';
    // SQL for fetching items only related to forums this user moderates
    $moderated_forums = array();
    if ($mybb->usergroup['issupermod'] != 1) {
        $query = $db->simple_select("moderators", "*", "id='{$mybb->user['uid']}' AND isgroup = '0'");
        while ($forum = $db->fetch_array($query)) {
            $flist .= ",'{$forum['fid']}'";
            $children = get_child_list($forum['fid']);
            if (!empty($children)) {
                $flist .= ",'" . implode("','", $children) . "'";
            }
            $moderated_forums[] = $forum['fid'];
        }
        if ($flist) {
            $tflist = " AND t.fid IN (0{$flist})";
            $flist = " AND fid IN (0{$flist})";
        }
    } else {
        $flist = $tflist = '';
    }
    $forum_cache = $cache->read("forums");
    $query = $db->query("\n        SELECT COUNT(pid) AS unapprovedposts\n        FROM  " . TABLE_PREFIX . "posts p\n        LEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\n        WHERE p.visible='0' {$tflist} AND t.firstpost != p.pid\n    ");
    $unapproved_posts = $db->fetch_field($query, "unapprovedposts");
    $query = $db->query("\n        SELECT p.pid, p.subject, p.message, t.subject AS threadsubject, t.tid, u.username, p.uid, t.fid, p.dateline, u.avatar, t.views, t.replies, IF(b.lifted > UNIX_TIMESTAMP() OR b.lifted = 0, 1, 0) as isbanned\n        FROM  " . TABLE_PREFIX . "posts p\n        LEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\n        LEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\n        LEFT JOIN " . TABLE_PREFIX . "banned b ON (b.uid = p.uid)\n        left join " . TABLE_PREFIX . "forums f on f.fid = t.fid\n        WHERE p.visible='0' {$tflist} AND t.firstpost != p.pid\n        ORDER BY p.dateline DESC\n        LIMIT {$start}, {$limit}\n    ");
    $forumcache = $cache->read("forums");
    $post_list = array();
    while ($post = $db->fetch_array($query)) {
        $post['threadsubject'] = $parser->parse_badwords($post['threadsubject']);
        $forumpermissions = forum_permissions($post['fid']);
        $can_delete = 0;
        if ($mybb->user['uid'] == $post['uid']) {
            if ($forumpermissions['candeletethreads'] == 1 && $post['replies'] == 0) {
                $can_delete = 1;
            } else {
                if ($forumpermissions['candeleteposts'] == 1 && $post['replies'] > 0) {
                    $can_delete = 1;
                }
            }
        }
        $can_delete = (is_moderator($post['fid'], "candeleteposts") || $can_delete == 1) && $mybb->user['uid'] != 0;
        $post_list[] = new xmlrpcval(array('forum_id' => new xmlrpcval($post['fid'], 'string'), 'forum_name' => new xmlrpcval(basic_clean($forumcache[$post['fid']]['name']), 'base64'), 'topic_id' => new xmlrpcval($post['tid'], 'string'), 'topic_title' => new xmlrpcval($post['threadsubject'], 'base64'), 'post_id' => new xmlrpcval($post['pid'], 'string'), 'post_title' => new xmlrpcval($post['subject'], 'base64'), 'post_author_name' => new xmlrpcval($post['username'], 'base64'), 'icon_url' => new xmlrpcval(absolute_url($post['avatar']), 'string'), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode($post['dateline']), 'dateTime.iso8601'), 'short_content' => new xmlrpcval(process_short_content($post['message'], $parser), 'base64'), 'reply_number' => new xmlrpcval($post['replies'], 'int'), 'view_number' => new xmlrpcval($post['views'], 'int'), 'can_delete' => new xmlrpcval($can_delete, 'boolean'), 'can_approve' => new xmlrpcval(is_moderator($post['fid'], "canmanagethreads"), 'boolean'), 'can_move' => new xmlrpcval(is_moderator($post['fid'], "canmovetononmodforum"), 'boolean'), 'can_ban' => new xmlrpcval($mybb->usergroup['canmodcp'] == 1, 'boolean'), 'is_ban' => new xmlrpcval($post['isbanned'], 'boolean'), 'is_approved' => new xmlrpcval(false, 'boolean'), 'is_deleted' => new xmlrpcval(false, 'boolean')), "struct");
    }
    $result = new xmlrpcval(array('total_post_num' => new xmlrpcval($unapproved_posts, 'int'), 'posts' => new xmlrpcval($post_list, 'array')), 'struct');
    return new xmlrpcresp($result);
}
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:56,代码来源:moderation.php

示例13: get_unsearchable_forums

/**
 * Build a comma separated list of the forums this user cannot search
 *
 * @param int The parent ID to build from
 * @param int First rotation or not (leave at default)
 * @return return a CSV list of forums the user cannot search
 */
function get_unsearchable_forums($pid = "0", $first = 1)
{
    global $db, $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;
    $pid = intval($pid);
    if (!is_array($forum_cache)) {
        // Get Forums
        $query = $db->simple_select("forums", "fid,parentlist,password,active", '', array('order_by' => 'pid, disporder'));
        while ($forum = $db->fetch_array($query)) {
            $forum_cache[$forum['fid']] = $forum;
        }
    }
    if (!is_array($permissioncache)) {
        $permissioncache = forum_permissions();
    }
    foreach ($forum_cache as $fid => $forum) {
        if ($permissioncache[$forum['fid']]) {
            $perms = $permissioncache[$forum['fid']];
        } else {
            $perms = $mybb->usergroup;
        }
        $pwverified = 1;
        if ($forum['password'] != '') {
            if ($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'] . $forum['password'])) {
                $pwverified = 0;
            }
        }
        $parents = explode(",", $forum['parentlist']);
        if (is_array($parents)) {
            foreach ($parents as $parent) {
                if ($forum_cache[$parent]['active'] == 0) {
                    $forum['active'] = 0;
                }
            }
        }
        if ($perms['canview'] != 1 || $perms['cansearch'] != 1 || $pwverified == 0 || $forum['active'] == 0) {
            if ($unsearchableforums) {
                $unsearchableforums .= ",";
            }
            $unsearchableforums .= "'{$forum['fid']}'";
        }
    }
    $unsearchable = $unsearchableforums;
    // Get our unsearchable password protected forums
    $pass_protected_forums = get_password_protected_forums();
    if ($unsearchable && $pass_protected_forums) {
        $unsearchable .= ",";
    }
    if ($pass_protected_forums) {
        $unsearchable .= implode(",", $pass_protected_forums);
    }
    return $unsearchable;
}
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:59,代码来源:functions_search.php

示例14: build_friendly_wol_location

/**
 * Builds a friendly named Who's Online location from an "activity" and array of user data. Assumes fetch_wol_activity has already been called.
 *
 * @param array Array containing activity and essential IDs.
 * @return string Location name for the activity being performed.
 */
function build_friendly_wol_location($user_activity)
{
    global $db, $lang, $uid_list, $aid_list, $pid_list, $tid_list, $fid_list, $ann_list, $eid_list, $plugins, $parser, $mybb;
    global $threads, $forums, $forums_linkto, $forum_cache, $posts, $announcements, $events, $usernames, $attachments;
    // Fetch forum permissions for this user
    $unviewableforums = get_unviewable_forums();
    $inactiveforums = get_inactive_forums();
    $fidnot = '';
    $unviewablefids = $inactivefids = array();
    if ($unviewableforums) {
        $fidnot = " AND fid NOT IN ({$unviewableforums})";
        $unviewablefids = explode(',', $unviewableforums);
    }
    if ($inactiveforums) {
        $fidnot .= " AND fid NOT IN ({$inactiveforums})";
        $inactivefids = explode(',', $inactiveforums);
    }
    // Fetch any users
    if (!is_array($usernames) && count($uid_list) > 0) {
        $uid_sql = implode(",", $uid_list);
        if ($uid_sql != $mybb->user['uid']) {
            $query = $db->simple_select("users", "uid,username", "uid IN ({$uid_sql})");
            while ($user = $db->fetch_array($query)) {
                $usernames[$user['uid']] = $user['username'];
            }
        } else {
            $usernames[$mybb->user['uid']] = $mybb->user['username'];
        }
    }
    // Fetch any attachments
    if (!is_array($attachments) && count($aid_list) > 0) {
        $aid_sql = implode(",", $aid_list);
        $query = $db->simple_select("attachments", "aid,pid", "aid IN ({$aid_sql})");
        while ($attachment = $db->fetch_array($query)) {
            $attachments[$attachment['aid']] = $attachment['pid'];
            $pid_list[] = $attachment['pid'];
        }
    }
    // Fetch any announcements
    if (!is_array($announcements) && count($ann_list) > 0) {
        $aid_sql = implode(",", $ann_list);
        $query = $db->simple_select("announcements", "aid,subject", "aid IN ({$aid_sql}) {$fidnot}");
        while ($announcement = $db->fetch_array($query)) {
            $announcement_title = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
            $announcements[$announcement['aid']] = $announcement_title;
        }
    }
    // Fetch any posts
    if (!is_array($posts) && count($pid_list) > 0) {
        $pid_sql = implode(",", $pid_list);
        $query = $db->simple_select("posts", "pid,tid", "pid IN ({$pid_sql}) {$fidnot}");
        while ($post = $db->fetch_array($query)) {
            $posts[$post['pid']] = $post['tid'];
            $tid_list[] = $post['tid'];
        }
    }
    // Fetch any threads
    if (!is_array($threads) && count($tid_list) > 0) {
        $perms = array();
        $tid_sql = implode(",", $tid_list);
        $query = $db->simple_select('threads', 'uid, fid, tid, subject, visible, prefix', "tid IN({$tid_sql}) {$fidnot}");
        $threadprefixes = build_prefixes();
        while ($thread = $db->fetch_array($query)) {
            $thread['threadprefix'] = '';
            if ($thread['prefix'] && !empty($threadprefixes[$thread['prefix']])) {
                $thread['threadprefix'] = $threadprefixes[$thread['prefix']]['displaystyle'];
            }
            if (empty($perms[$thread['fid']])) {
                $perms[$thread['fid']] = forum_permissions($thread['fid']);
            }
            if (isset($perms[$thread['fid']]['canonlyviewownthreads']) && $perms[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'] && !is_moderator($thread['fid'])) {
                continue;
            }
            if (is_moderator($thread['fid']) || $thread['visible'] == 1) {
                $thread_title = '';
                if ($thread['threadprefix']) {
                    $thread_title = $thread['threadprefix'] . '&nbsp;';
                }
                $thread_title .= htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
                $threads[$thread['tid']] = $thread_title;
                $fid_list[] = $thread['fid'];
            }
        }
    }
    // Fetch any forums
    if (!is_array($forums) && count($fid_list) > 0) {
        $fidnot = array_merge($unviewablefids, $inactivefids);
        foreach ($forum_cache as $fid => $forum) {
            if (in_array($fid, $fid_list) && !in_array($fid, $fidnot)) {
                $forums[$fid] = $forum['name'];
                $forums_linkto[$fid] = $forum['linkto'];
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:olada,项目名称:mybbintegrator,代码行数:101,代码来源:functions_online.php

示例15: AND

}
$visibleonly = "AND visible='1'";
$visibleonly2 = "AND p.visible='1' AND t.visible='1'";
// Is the currently logged in user a moderator of this forum?
if (is_moderator($fid)) {
    $visibleonly = " AND (visible='1' OR visible='0')";
    $visibleonly2 = "AND (p.visible='1' OR p.visible='0') AND (t.visible='1' OR t.visible='0')";
    $ismod = true;
} else {
    $ismod = false;
}
// Make sure we are looking at a real thread here.
if (!$thread || $thread['visible'] != 1 && $ismod == false || $thread['visible'] > 1 && $ismod == true) {
    error($lang->error_invalidthread);
}
$forumpermissions = forum_permissions($thread['fid']);
// Does the user have permission to view this thread?
if ($forumpermissions['canview'] != 1 || $forumpermissions['canviewthreads'] != 1) {
    error_no_permission();
}
if (isset($forumpermissions['canonlyviewownthreads']) && $forumpermissions['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid']) {
    error_no_permission();
}
$archive_url = build_archive_link("thread", $tid);
// Does the thread belong to a valid forum?
$forum = get_forum($fid);
if (!$forum || $forum['type'] != "f") {
    error($lang->error_invalidforum);
}
// Check if this forum is password protected and we have a valid password
check_forum_password($forum['fid']);
开发者ID:ThinhNguyenVB,项目名称:Gradient-Studios-Website,代码行数:31,代码来源:showthread.php


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