/**
 * Mark a particular thread as read for the current user.
 *
 * @param int The thread ID
 * @param int The forum ID of the thread
 */
function mark_thread_read($tid, $fid)
{
    global $mybb, $db;
    // Can only do "true" tracking for registered users
    if ($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid']) {
        // For registered users, store the information in the database.
        switch ($db->type) {
            case "pgsql":
            case "sqlite2":
            case "sqlite3":
                $db->shutdown_query($db->build_replace_query("threadsread", array('tid' => $tid, 'uid' => $mybb->user['uid'], 'dateline' => TIME_NOW), "tid"));
                break;
            default:
                $db->write_query("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "threadsread (tid, uid, dateline)\n\t\t\t\t\tVALUES('{$tid}', '{$mybb->user['uid']}', '" . TIME_NOW . "')\n\t\t\t\t");
        }
        // Fetch ALL of the child forums of this forum
        $forums = get_child_list($fid);
        $forums[] = $fid;
        $forums = implode(",", $forums);
        $unread_count = fetch_unread_count($forums);
        if ($unread_count == 0) {
            mark_forum_read($fid);
        }
    } else {
        my_set_array_cookie("threadread", $tid, TIME_NOW);
    }
}
Example #2
0
function get_child_list($pid = 0, $prefix = '')
{
    $list = array();
    $data = M('access')->where("pid=%d", $pid)->field('id,title')->select();
    foreach ($data as $value) {
        $suffix = $value == end($data) ? ' └ ' : ' ├ ';
        $middle = $value == end($data) ? '    ' : ' │ ';
        $list[$value['id']] = $prefix . $suffix . $value['title'];
        $count = M('access')->where("pid=%d", $pid)->count();
        if ($count > 0) {
            $chil = get_child_list($value['id'], $prefix . $middle);
            $list = $list + $chil;
        }
    }
    return $list;
}
Example #3
0
         if (!empty($children)) {
             $flist_reports .= ",'" . implode("','", $children) . "'";
         }
         ++$numreportedposts;
     }
     // For the Mod Log
     if ($forum['canviewmodlog'] == 1) {
         $flist_modlog .= ",'{$forum['fid']}'";
         $children = get_child_list($forum['fid']);
         if (!empty($children)) {
             $flist_modlog .= ",'" . implode("','", $children) . "'";
         }
         ++$nummodlogs;
     }
     $flist .= ",'{$forum['fid']}'";
     $children = get_child_list($forum['fid']);
     if (!empty($children)) {
         $flist .= ",'" . implode("','", $children) . "'";
     }
     $moderated_forums[] = $forum['fid'];
 }
 if ($flist_queue_threads) {
     $tflist_queue_threads = " AND t.fid IN (0{$flist_queue_threads})";
     $flist_queue_threads = " AND fid IN (0{$flist_queue_threads})";
 }
 if ($flist_queue_posts) {
     $tflist_queue_posts = " AND t.fid IN (0{$flist_queue_posts})";
     $flist_queue_posts = " AND fid IN (0{$flist_queue_posts})";
 }
 if ($flist_queue_attach) {
     $tflist_queue_attach = " AND t.fid IN (0{$flist_queue_attach})";
/**
 * Build a array list of the forums this user cannot search due to password protection
 *
 * @param int the fids to check (leave null to check all forums)
 * @return return a array list of password protected forums the user cannot search
 */
function get_password_protected_forums($fids = array())
{
    global $forum_cache, $mybb;
    if (!is_array($fids)) {
        return false;
    }
    if (!is_array($forum_cache)) {
        $forum_cache = cache_forums();
        if (!$forum_cache) {
            return false;
        }
    }
    if (empty($fids)) {
        $fids = array_keys($forum_cache);
    }
    $pass_fids = array();
    foreach ($fids as $fid) {
        if (empty($forum_cache[$fid]['password'])) {
            continue;
        }
        if (md5($mybb->user['uid'] . $forum_cache[$fid]['password']) != $mybb->cookies['forumpass'][$fid]) {
            $pass_fids[] = $fid;
            $child_list = get_child_list($fid);
        }
        if (is_array($child_list)) {
            $pass_fids = array_merge($pass_fids, $child_list);
        }
    }
    return array_unique($pass_fids);
}
Example #5
0
         $search_sql .= " AND a.uid='{$user['uid']}'";
     }
 }
 $forum_cache = cache_forums();
 // Searching for attachments in a specific forum, we need to fetch all child forums too
 if ($mybb->input['forum']) {
     if (!is_array($mybb->input['forum'])) {
         $mybb->input['forum'] = array($mybb->input['forum']);
     }
     $fid_in = array();
     foreach ($mybb->input['forum'] as $fid) {
         if (!$forum_cache[$fid]) {
             $errors[] = $lang->error_invalid_forums;
             break;
         }
         $child_forums = get_child_list($fid);
         $child_forums[] = $fid;
         $fid_in = array_merge($fid_in, $child_forums);
     }
     if (count($fid_in) > 0) {
         $search_sql .= " AND p.fid IN (" . implode(",", $fid_in) . ")";
     }
 }
 // LESS THAN or GREATER THAN
 if ($mybb->input['dateuploaded'] && $mybb->request_method == "post") {
     $mybb->input['dateuploaded'] = TIME_NOW - $mybb->input['dateuploaded'] * 60 * 60 * 24;
 }
 if ($mybb->input['filesize'] && $mybb->request_method == "post") {
     $mybb->input['filesize'] *= 1024;
 }
 $direction_fields = array("dateuploaded", "filesize", "downloads");
Example #6
0
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);
}
Example #7
0
/**
 * Generate an array of all child and descendant forums for a specific forum.
 *
 * @param int The forum ID
 * @param return Array of descendants
 */
function get_child_list($fid)
{
    static $forums_by_parent;
    $forums = array();
    if (!is_array($forums_by_parent)) {
        $forum_cache = cache_forums();
        foreach ($forum_cache as $forum) {
            if ($forum['active'] != 0) {
                $forums_by_parent[$forum['pid']][$forum['fid']] = $forum;
            }
        }
    }
    if (!is_array($forums_by_parent[$fid])) {
        return;
    }
    foreach ($forums_by_parent[$fid] as $forum) {
        $forums[] = $forum['fid'];
        $children = get_child_list($forum['fid']);
        if (is_array($children)) {
            $forums = array_merge($forums, $children);
        }
    }
    return $forums;
}