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


PHP build_prefixes函数代码示例

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


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

示例1: alt_trow

 $trow = alt_trow();
 if ($similar_thread['icon'] > 0 && $icon_cache[$similar_thread['icon']]) {
     $icon = $icon_cache[$similar_thread['icon']];
     $icon = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" />";
 } else {
     $icon = "&nbsp;";
 }
 if (!$similar_thread['username']) {
     $similar_thread['username'] = $similar_thread['threadusername'];
     $similar_thread['profilelink'] = $similar_thread['threadusername'];
 } else {
     $similar_thread['profilelink'] = build_profile_link($similar_thread['username'], $similar_thread['uid']);
 }
 // If this thread has a prefix, insert a space between prefix and subject
 if ($similar_thread['prefix'] != 0) {
     $prefix = build_prefixes($similar_thread['prefix']);
     $similar_thread['threadprefix'] = $prefix['displaystyle'] . '&nbsp;';
 }
 $similar_thread['subject'] = $parser->parse_badwords($similar_thread['subject']);
 $similar_thread['subject'] = htmlspecialchars_uni($similar_thread['subject']);
 $similar_thread['threadlink'] = get_thread_link($similar_thread['tid']);
 $similar_thread['lastpostlink'] = get_thread_link($similar_thread['tid'], 0, "lastpost");
 $lastpostdate = my_date($mybb->settings['dateformat'], $similar_thread['lastpost']);
 $lastposttime = my_date($mybb->settings['timeformat'], $similar_thread['lastpost']);
 $lastposter = $similar_thread['lastposter'];
 $lastposteruid = $similar_thread['lastposteruid'];
 // Don't link to guest's profiles (they have no profile).
 if ($lastposteruid == 0) {
     $lastposterlink = $lastposter;
 } else {
     $lastposterlink = build_profile_link($lastposter, $lastposteruid);
开发者ID:ThinhNguyenVB,项目名称:Gradient-Studios-Website,代码行数:31,代码来源:showthread.php

示例2: 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

示例3: define

define("IN_MYBB", 1);
define('THIS_SCRIPT', 'sendthread.php');
$templatelist = "sendthread,forumdisplay_password_wrongpass,forumdisplay_password";
require_once "./global.php";
require_once MYBB_ROOT . "inc/functions_post.php";
require_once MYBB_ROOT . "inc/class_parser.php";
$parser = new postParser();
// Load global language phrases
$lang->load("sendthread");
// Get thread info
$tid = intval($mybb->input['tid']);
$thread = get_thread($tid);
// Get thread prefix
$breadcrumbprefix = '';
if ($thread['prefix']) {
    $threadprefix = build_prefixes($thread['prefix']);
    if (isset($threadprefix['displaystyle'])) {
        $breadcrumbprefix = $threadprefix['displaystyle'] . '&nbsp;';
    }
}
$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
// Invalid thread
if (!$thread['tid']) {
    error($lang->error_invalidthread);
}
// Guests cannot use this feature
if (!$mybb->user['uid']) {
    error_no_permission();
}
$fid = $thread['fid'];
// Make navigation
开发者ID:ThinhNguyenVB,项目名称:Gradient-Studios-Website,代码行数:31,代码来源:sendthread.php

示例4: IN

 // Threads being read?
 if ($mybb->settings['threadreadcut'] > 0) {
     $query = $db->simple_select("threadsread", "*", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})");
     while ($readthread = $db->fetch_array($query)) {
         $threadcache[$readthread['tid']]['lastread'] = $readthread['dateline'];
     }
 }
 // Icon Stuff
 if ($mybb->settings['dotfolders'] != 0) {
     $query = $db->simple_select("posts", "tid,uid", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})");
     while ($post = $db->fetch_array($query)) {
         $threadcache[$post['tid']]['doticon'] = 1;
     }
 }
 $icon_cache = $cache->read("posticons");
 $threadprefixes = build_prefixes();
 // Run the threads...
 $latest_threads_threads = '';
 foreach ($threadcache as $thread) {
     if ($thread['tid']) {
         $bgcolor = alt_trow();
         $folder = '';
         $folder_label = '';
         $prefix = '';
         $gotounread = '';
         $isnew = 0;
         $donenew = 0;
         $lastread = 0;
         // If this thread has a prefix...
         if ($thread['prefix'] != 0) {
             if (!empty($threadprefixes[$thread['prefix']])) {
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:31,代码来源:usercp.php

示例5: google_seo_url_create

/**
 * Create a unique URL in the database for a specific item type,id.
 * First fetch the title of the item from the MyBB database,
 * then process (translate, separate, truncate, uniquify) that title,
 * then check for existing entries in the Google SEO database,
 * finally insert it into the database if it's not already there.
 *
 * @param string Type of the item (forums, threads, etc.)
 * @param array IDs of the item (fid for forums, tid for threads, etc.)
 */
function google_seo_url_create($type, $ids)
{
    global $db, $settings;
    global $google_seo_url_cache;
    $ids = array_map('intval', (array) $ids);
    foreach ($ids as $id) {
        $google_seo_url_cache[$type][$id] = 0;
    }
    if ($db->google_seo_query_limit <= 0) {
        return;
    }
    $data = $db->google_seo_url[$type];
    // Is Google SEO URL enabled for this type?
    if ($data['scheme']) {
        // Query the item title as base for our URL.
        $db->google_seo_query_limit--;
        $titles = $db->query("SELECT {$data['name']},{$data['id']}{$data['extra']}\n                              FROM {$data['table']}\n                              WHERE {$data['id']} IN (" . implode(",", $ids) . ")");
        while ($row = $db->fetch_array($titles)) {
            $url = $row[$data['name']];
            // MyBB unfortunately allows HTML in forum names.
            if ($type == GOOGLE_SEO_FORUM) {
                $url = strip_tags($url);
            }
            // Thread Prefixes
            if ($row['prefix']) {
                $prefix = build_prefixes($row['prefix']);
                if ($prefix['prefix']) {
                    $url = google_seo_expand($settings['google_seo_url_threadprefix'], array('url' => $url, 'prefix' => $prefix['prefix'], 'separator' => $settings['google_seo_url_separator']));
                }
            }
            $id = $row[$data['id']];
            // Prepare the URL.
            if ($settings['google_seo_url_translation']) {
                $url = google_seo_url_translation($url);
            }
            $url = google_seo_url_separate($url);
            $url = google_seo_url_truncate($url);
            $uniqueurl = google_seo_url_uniquify($url, $id);
            // Special case: for empty URLs we must use the unique variant
            if ($url == "" || $settings['google_seo_url_uniquifier_force']) {
                $url = $uniqueurl;
            }
            // Parents
            if ($row['parent']) {
                $parent_type = $db->google_seo_url[$type]['parent_type'];
                $parent_id = (int) $row['parent'];
                // TODO: Parents costs us an extra query. Cache?
                $db->google_seo_query_limit--;
                $query = $db->simple_select('google_seo', 'url AS parent', "active=1 AND idtype={$parent_type} AND id={$parent_id}");
                $parent = $db->fetch_field($query, 'parent');
                if ($parent) {
                    $url = google_seo_expand($db->google_seo_url[$type]['parent'], array('url' => $url, 'parent' => $parent));
                    $uniqueurl = google_seo_expand($db->google_seo_url[$type]['parent'], array('url' => $url, 'parent' => $parent));
                }
            }
            // Check for existing entry and possible collisions.
            $db->google_seo_query_limit--;
            $query = $db->query("SELECT url,id FROM " . TABLE_PREFIX . "google_seo\n                                 WHERE active=1 AND idtype={$type} AND id<={$id}\n                                 AND url IN ('" . $db->escape_string($url) . "','" . $db->escape_string($uniqueurl) . "')\n                                 AND EXISTS(SELECT {$data['id']}\n                                            FROM {$data['table']}\n                                            WHERE {$data['id']}=id)\n                                 ORDER BY id ASC");
            $urlrow = $db->fetch_array($query);
            $uniquerow = $db->fetch_array($query);
            // Check if the entry was not up to date anyway.
            if ($urlrow && $urlrow['id'] == $id && $urlrow['url'] == $url) {
                // It's up to date. Do nothing.
            } else {
                if ($uniquerow && $uniquerow['id'] == $id && $uniquerow['url'] == $uniqueurl) {
                    // It's up to date for the unique URL.
                    $url = $uniqueurl;
                } else {
                    // Use unique URL if there was a row with a different id.
                    if ($urlrow && $urlrow['id'] != $id) {
                        $url = $uniqueurl;
                    }
                    // Set old entries for us to not active.
                    $db->google_seo_query_limit--;
                    $db->write_query("UPDATE " . TABLE_PREFIX . "google_seo\n                                  SET active=NULL\n                                  WHERE active=1\n                                  AND idtype={$type}\n                                  AND id={$id}");
                    // Insert new entry (while possibly replacing old ones).
                    $db->google_seo_query_limit--;
                    $db->write_query("REPLACE INTO " . TABLE_PREFIX . "google_seo\n                                  VALUES (active,idtype,id,url),\n                                  ('1','{$type}','{$id}','" . $db->escape_string($url) . "')");
                }
            }
            // Finalize URL.
            if ($settings['google_seo_url_lowercase']) {
                $url = my_strtolower($url);
            }
            $url = google_seo_url_finalize($url, $data['scheme']);
            $google_seo_url_cache[$type][$id] = $url;
        }
    }
}
开发者ID:learnix-xx,项目名称:MyBB-Google-SEO,代码行数:99,代码来源:url.php

示例6: get_thread_func

function get_thread_func($xmlrpc_params)
{
    global $db, $lang, $mybb, $position, $plugins, $pids;
    global $pforumcache, $currentitem, $forum_cache, $navbits, $base_url, $archiveurl;
    $input = Tapatalk_Input::filterXmlInput(array('topic_id' => Tapatalk_Input::STRING, 'start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT, 'return_html' => Tapatalk_Input::INT), $xmlrpc_params);
    if (preg_match('/^ann_/', $input['topic_id'])) {
        $_GET["aid"] = intval(str_replace('ann_', '', $input['topic_id']));
        return get_announcement_func($xmlrpc_params);
    }
    $lang->load("showthread");
    global $parser;
    $parser = new Tapatalk_Parser();
    // Get the thread details from the database.
    $thread = get_thread($input['topic_id']);
    if (!empty($thread['closed'])) {
        $moved = explode("|", $thread['closed']);
        if ($moved[0] == "moved") {
            $thread = get_thread($moved[1]);
        }
    }
    // Get thread prefix if there is one.
    $thread['threadprefix'] = '';
    $thread['displayprefix'] = '';
    if ($thread['prefix'] != 0) {
        $threadprefix = build_prefixes($thread['prefix']);
        if ($threadprefix['prefix']) {
            $thread['threadprefix'] = $threadprefix['prefix'] . '&nbsp;';
            $thread['displayprefix'] = $threadprefix['displaystyle'] . '&nbsp;';
        }
    }
    $thread['subject'] = $parser->parse_badwords($thread['subject']);
    $tid = $thread['tid'];
    $fid = $thread['fid'];
    if (!$thread['username']) {
        $thread['username'] = $lang->guest;
    }
    $visibleonly = "AND visible='1'";
    // Is the currently logged in user a moderator of this forum?
    if (is_moderator($fid)) {
        $visibleonly = " AND (visible='1' OR visible='0')";
        $ismod = true;
    } else {
        $ismod = false;
    }
    $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 ($forumpermissions['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid']) {
        error_no_permission();
    }
    // Make sure we are looking at a real thread here.
    if (!$thread['tid'] || $thread['visible'] == 0 && $ismod == false || $thread['visible'] > 1 && $ismod == true) {
        return xmlrespfalse($lang->error_invalidthread);
    }
    // Does the thread belong to a valid forum?
    $forum = get_forum($fid);
    if (!$forum || $forum['type'] != "f") {
        return xmlrespfalse($lang->error_invalidforum);
    }
    tt_check_forum_password($forum['fid']);
    if ($thread['firstpost'] == 0) {
        update_first_post($tid);
    }
    // Mark this thread as read
    mark_thread_read($tid, $fid);
    // Increment the thread view.
    if ($mybb->settings['delayedthreadviews'] == 1) {
        $db->shutdown_query("INSERT INTO " . TABLE_PREFIX . "threadviews (tid) VALUES('{$tid}')");
    } else {
        $db->shutdown_query("UPDATE " . TABLE_PREFIX . "threads SET views=views+1 WHERE tid='{$tid}'");
    }
    ++$thread['views'];
    // Work out if we are showing unapproved posts as well (if the user is a moderator etc.)
    if ($ismod) {
        $visible = "AND (p.visible='0' OR p.visible='1')";
    } else {
        $visible = "AND p.visible='1'";
    }
    // Fetch the ignore list for the current user if they have one
    $ignored_users = array();
    if ($mybb->user['uid'] > 0 && $mybb->user['ignorelist'] != "") {
        $ignore_list = explode(',', $mybb->user['ignorelist']);
        foreach ($ignore_list as $uid) {
            $ignored_users[$uid] = 1;
        }
    }
    list($start, $limit) = process_page($input['start_num'], $input['last_num']);
    // Recount replies if user is a moderator to take into account unapproved posts.
    if ($ismod) {
        $query = $db->simple_select("posts p", "COUNT(*) AS replies", "p.tid='{$tid}' {$visible}");
        $thread['replies'] = $db->fetch_field($query, 'replies') - 1;
    }
    $postcount = intval($thread['replies']) + 1;
    $pids = "";
    $comma = '';
    $query = $db->simple_select("posts p", "p.pid", "p.tid='{$tid}' {$visible}", array('order_by' => 'p.dateline', 'limit_start' => $start, 'limit' => $limit));
    while ($getid = $db->fetch_array($query)) {
        // Set the ID of the first post on page to $pid if it doesn't hold any value
//.........这里部分代码省略.........
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:101,代码来源:get_thread.php

示例7: verify_prefix

 /**
  * Verify thread prefix.
  *
  * @return boolean True when valid, false when not valid.
  */
 function verify_prefix()
 {
     $prefix =& $this->data['prefix'];
     $prefix_cache = build_prefixes();
     // If a valid prefix isn't supplied, don't assign one.
     if (empty($prefix)) {
         $prefix = 0;
     } else {
         $prefix_cache = build_prefixes($prefix);
         if (empty($prefix_cache)) {
             $this->set_error('invalid_prefix');
             return false;
         }
         if ($prefix_cache['groups'] != "-1") {
             if (!empty($this->data['edit_uid'])) {
                 // Post is being edited
                 $user = get_user($this->data['edit_uid']);
             } else {
                 $user = get_user($this->data['uid']);
             }
             if (!is_member($prefix_cache['groups'], array('usergroup' => $user['usergroup'], 'additionalgroups' => $user['additionalgroups']))) {
                 $this->set_error('invalid_prefix');
                 return false;
             }
         }
         if ($prefix_cache['forums'] != "-1") {
             // Decide whether this prefix can be used in our forum
             $forums = explode(",", $prefix_cache['forums']);
             if (!in_array($this->data['fid'], $forums)) {
                 $this->set_error('invalid_prefix');
                 return false;
             }
         }
     }
     // Does this forum require a prefix?
     $forum = get_forum($this->data['fid']);
     if ($forum['requireprefix'] == 1) {
         $num_prefixes = false;
         // Go through each of our prefixes and decide if there are any possible prefixes to use.
         if (!empty($this->data['edit_uid'])) {
             // Post is being edited
             $user = get_user($this->data['edit_uid']);
         } else {
             $user = get_user($this->data['uid']);
         }
         $prefix_cache = build_prefixes();
         if (!empty($prefix_cache)) {
             foreach ($prefix_cache as $required) {
                 if ($required['forums'] != "-1") {
                     // Decide whether this prefix can be used in our forum
                     $forums = explode(",", $required['forums']);
                     if (!in_array($forum['fid'], $forums)) {
                         continue;
                     }
                 }
                 if ($required['groups'] != "-1") {
                     if (!is_member($required['groups'], array('usergroup' => $user['usergroup'], 'additionalgroups' => $user['additionalgroups']))) {
                         $num_prefixes = true;
                     }
                 } else {
                     $num_prefixes = true;
                 }
             }
         }
         if ($prefix == 0 && $num_prefixes) {
             $this->set_error('require_prefix');
             return false;
         }
     }
     return true;
 }
开发者ID:olada,项目名称:mybbintegrator,代码行数:76,代码来源:post.php

示例8: log_admin_action

        log_admin_action($prefix['pid'], $prefix['prefix']);
        $cache->update_threadprefixes();
        flash_message($lang->success_thread_prefix_deleted, 'success');
        admin_redirect('index.php?module=config-thread_prefixes');
    } else {
        $page->output_confirm_action("index.php?module=config-thread_prefixes&amp;action=delete_prefix&amp;pid={$mybb->input['pid']}", $lang->confirm_thread_prefix_deletion);
    }
}
if (!$mybb->input['action']) {
    $plugins->run_hooks('admin_config_thread_prefixes_start');
    $page->output_header($lang->thread_prefixes);
    $page->output_nav_tabs($sub_tabs, 'thread_prefixes');
    $table = new Table();
    $table->construct_header($lang->prefix);
    $table->construct_header($lang->controls, array('class' => 'align_center', 'colspan' => 2));
    $prefixes = build_prefixes();
    if ($prefixes) {
        foreach ($prefixes as $prefix) {
            $table->construct_cell("<a href=\"index.php?module=config-thread_prefixes&amp;action=edit_prefix&amp;pid={$prefix['pid']}\"><strong>" . htmlspecialchars_uni($prefix['prefix']) . "</strong></a>");
            $table->construct_cell("<a href=\"index.php?module=config-thread_prefixes&amp;action=edit_prefix&amp;pid={$prefix['pid']}\">{$lang->edit}</a>", array('width' => 100, 'class' => "align_center"));
            $table->construct_cell("<a href=\"index.php?module=config-thread_prefixes&amp;action=delete_prefix&amp;pid={$prefix['pid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_thread_prefix_deletion}')\">{$lang->delete}</a>", array('width' => 100, 'class' => 'align_center'));
            $table->construct_row();
        }
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_thread_prefixes, array('colspan' => 3));
        $table->construct_row();
    }
    $table->output($lang->thread_prefixes);
    $page->output_footer();
}
开发者ID:slothly,项目名称:mybb,代码行数:31,代码来源:thread_prefixes.php

示例9: get_prefix_list

function get_prefix_list($fid)
{
    global $db, $mybb;
    if ($fid != 'all') {
        $fid = intval($fid);
    }
    if (defined('OLD_PREFIX')) {
        // Does this user have additional groups?
        if ($mybb->user['additionalgroups']) {
            $exp = explode(",", $mybb->user['additionalgroups']);
            // Because we like apostrophes...
            $imps = array();
            foreach ($exp as $group) {
                $imps[] = "'{$group}'";
            }
            $additional_groups = implode(",", $imps);
            $extra_sql = "groups IN ({$additional_groups}) OR ";
        } else {
            $extra_sql = '';
        }
        switch ($db->type) {
            case "pgsql":
            case "sqlite":
                $whereforum = "";
                if ($fid != 'all') {
                    $whereforum = " AND (','||forums||',' LIKE '%,{$fid},%' OR ','||forums||',' LIKE '%,-1,%' OR forums='')";
                }
                $query = $db->query("\n                    SELECT pid, prefix\n                    FROM " . TABLE_PREFIX . "threadprefixes\n                    WHERE ({$extra_sql}','||groups||',' LIKE '%,{$mybb->user['usergroup']},%' OR ','||groups||',' LIKE '%,-1,%' OR groups='')\n                    {$whereforum}\n                ");
                break;
            default:
                $whereforum = "";
                if ($fid != 'all') {
                    $whereforum = " AND (CONCAT(',',forums,',') LIKE '%,{$fid},%' OR CONCAT(',',forums,',') LIKE '%,-1,%' OR forums='')";
                }
                $query = $db->query("\n                    SELECT pid, prefix\n                    FROM " . TABLE_PREFIX . "threadprefixes\n                    WHERE ({$extra_sql}CONCAT(',',groups,',') LIKE '%,{$mybb->user['usergroup']},%' OR CONCAT(',',groups,',') LIKE '%,-1,%' OR groups='')\n                    {$whereforum}\n                ");
        }
        $prefixes = array();
        if ($db->num_rows($query) > 0) {
            while ($prefix = $db->fetch_array($query)) {
                $prefixes[$prefix['pid']] = $prefix;
            }
        }
    } else {
        $prefix_cache = build_prefixes(0);
        if (!$prefix_cache) {
            return array();
            // We've got no prefixes to show
        }
        $groups = array($mybb->user['usergroup']);
        if ($mybb->user['additionalgroups']) {
            $exp = explode(",", $mybb->user['additionalgroups']);
            foreach ($exp as $group) {
                $groups[] = $group;
            }
        }
        // Go through each of our prefixes and decide which ones we can use
        $prefixes = array();
        foreach ($prefix_cache as $prefix) {
            if ($fid != "all" && $prefix['forums'] != "-1") {
                // Decide whether this prefix can be used in our forum
                $forums = explode(",", $prefix['forums']);
                if (!in_array($fid, $forums)) {
                    // This prefix is not in our forum list
                    continue;
                }
            }
            if ($prefix['groups'] != "-1") {
                $prefix_groups = explode(",", $prefix['groups']);
                foreach ($groups as $group) {
                    if (in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']])) {
                        // Our group can use this prefix!
                        $prefixes[$prefix['pid']] = $prefix;
                    }
                }
            } else {
                // This prefix is for anybody to use...
                $prefixes[$prefix['pid']] = $prefix;
            }
        }
    }
    return $prefixes;
}
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:82,代码来源:get_topic.php

示例10: build_prefix_select

/**
 * Build the thread prefix selection menu
 *
 *  @param mixed The forum ID (integer ID or string all)
 *  @param mixed The selected prefix ID (integer ID or string any)
 *  @return string The thread prefix selection menu
 */
function build_prefix_select($fid, $selected_pid = 0, $multiple = 0)
{
    global $cache, $db, $lang, $mybb;
    if ($fid != 'all') {
        $fid = intval($fid);
    }
    $prefix_cache = build_prefixes(0);
    if (!$prefix_cache) {
        return false;
        // We've got no prefixes to show
    }
    $groups = array($mybb->user['usergroup']);
    if ($mybb->user['additionalgroups']) {
        $exp = explode(",", $mybb->user['additionalgroups']);
        foreach ($exp as $group) {
            $groups[] = $group;
        }
    }
    // Go through each of our prefixes and decide which ones we can use
    $prefixes = array();
    foreach ($prefix_cache as $prefix) {
        if ($fid != "all" && $prefix['forums'] != "-1") {
            // Decide whether this prefix can be used in our forum
            $forums = explode(",", $prefix['forums']);
            if (!in_array($fid, $forums)) {
                // This prefix is not in our forum list
                continue;
            }
        }
        if ($prefix['groups'] != "-1") {
            $prefix_groups = explode(",", $prefix['groups']);
            foreach ($groups as $group) {
                if (in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']])) {
                    // Our group can use this prefix!
                    $prefixes[$prefix['pid']] = $prefix;
                }
            }
        } else {
            // This prefix is for anybody to use...
            $prefixes[$prefix['pid']] = $prefix;
        }
    }
    if (empty($prefixes)) {
        return false;
    }
    $prefixselect = "";
    if ($multiple != 0) {
        $prefixselect = "<select name=\"threadprefix[]\" multiple=\"multiple\" size=\"5\">\n";
    } else {
        $prefixselect = "<select name=\"threadprefix\">\n";
    }
    if ($multiple == 1) {
        $any_selected = "";
        if ($selected_pid == 'any') {
            $any_selected = " selected=\"selected\"";
        }
        $prefixselect .= "<option value=\"any\"" . $any_selected . ">" . $lang->any_prefix . "</option>\n";
    }
    $default_selected = "";
    if (intval($selected_pid) == 0 && $selected_pid != 'any') {
        $default_selected = " selected=\"selected\"";
    }
    $prefixselect .= "<option value=\"0\"" . $default_selected . ">" . $lang->no_prefix . "</option>\n";
    foreach ($prefixes as $prefix) {
        $selected = "";
        if ($prefix['pid'] == $selected_pid) {
            $selected = " selected=\"selected\"";
        }
        $prefixselect .= "<option value=\"" . $prefix['pid'] . "\"" . $selected . ">" . htmlspecialchars_uni($prefix['prefix']) . "</option>\n";
    }
    $prefixselect .= "</select>\n&nbsp;";
    return $prefixselect;
}
开发者ID:khanfusiion,项目名称:mybb,代码行数:80,代码来源:functions.php

示例11: verify_prefix

 /**
  * Verify thread prefix.
  *
  * @return boolean True when valid, false when not valid.
  */
 function verify_prefix()
 {
     $prefix =& $this->data['prefix'];
     // If a valid prefix isn't supplied, don't assign one.
     if (empty($prefix)) {
         $prefix = 0;
     } else {
         $verification = build_prefixes($prefix);
         if (!$verification) {
             $this->set_error('invalid_prefix');
             return false;
         }
         if ($verification['groups'] != "-1") {
             if (!empty($this->data['edit_uid'])) {
                 // Post is being edited
                 $user = get_user($this->data['edit_uid']);
             } else {
                 $user = get_user($this->data['uid']);
             }
             $groups = array($user['usergroup']);
             if (!empty($user['additionalgroups'])) {
                 $groups = array_merge($groups, explode(',', $user['additionalgroups']));
             }
             $prefix_groups = explode(",", $verification['groups']);
             $valid_group = false;
             foreach ($groups as $group) {
                 if (in_array($group, $prefix_groups)) {
                     $valid_group = true;
                     break;
                 }
             }
             if (!$valid_group) {
                 $this->set_error('invalid_prefix');
                 return false;
             }
         }
         if ($verification['forums'] != "-1") {
             // Decide whether this prefix can be used in our forum
             $forums = explode(",", $verification['forums']);
             if (!in_array($this->data['fid'], $forums)) {
                 $this->set_error('invalid_prefix');
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:slothly,项目名称:mybb,代码行数:52,代码来源:post.php

示例12: build_forum_prefix_select

/**
 * Build the thread prefix selection menu for a forum
 *
 *  @param int $fid The forum ID (integer ID)
 *  @param int $selected_pid The selected prefix ID (integer ID)
 */
function build_forum_prefix_select($fid, $selected_pid = 0)
{
    global $cache, $db, $lang, $mybb, $templates;
    $fid = (int) $fid;
    $prefix_cache = build_prefixes(0);
    if (empty($prefix_cache)) {
        return false;
        // We've got no prefixes to show
    }
    // Go through each of our prefixes and decide which ones we can use
    $prefixes = array();
    foreach ($prefix_cache as $prefix) {
        if ($prefix['forums'] != "-1") {
            // Decide whether this prefix can be used in our forum
            $forums = explode(",", $prefix['forums']);
            if (in_array($fid, $forums)) {
                // This forum can use this prefix!
                $prefixes[$prefix['pid']] = $prefix;
            }
        } else {
            // This prefix is for anybody to use...
            $prefixes[$prefix['pid']] = $prefix;
        }
    }
    if (empty($prefixes)) {
        return false;
    }
    $default_selected = array();
    $selected_pid = (int) $selected_pid;
    if ($selected_pid == 0) {
        $default_selected['all'] = ' selected="selected"';
    } else {
        if ($selected_pid == -1) {
            $default_selected['none'] = ' selected="selected"';
        } else {
            if ($selected_pid == -2) {
                $default_selected['any'] = ' selected="selected"';
            }
        }
    }
    foreach ($prefixes as $prefix) {
        $selected = '';
        if ($prefix['pid'] == $selected_pid) {
            $selected = ' selected="selected"';
        }
        $prefix['prefix'] = htmlspecialchars_uni($prefix['prefix']);
        eval('$prefixselect_prefix .= "' . $templates->get("forumdisplay_threadlist_prefixes_prefix") . '";');
    }
    eval('$prefixselect = "' . $templates->get("forumdisplay_threadlist_prefixes") . '";');
    return $prefixselect;
}
开发者ID:ateista-pl,项目名称:forum,代码行数:57,代码来源:functions.php


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