예제 #1
0
/**
 * @param array $user
 * @param array $view
 * @param DefaultTable $table
 */
function build_user_view_table($user, $view, &$table)
{
    global $user_view_fields;
    foreach ($view['fields'] as $field) {
        if (!$user_view_fields[$field]) {
            continue;
        }
        $view_field = $user_view_fields[$field];
        $field_options = array();
        if ($view_field['align']) {
            $field_options['class'] = "align_" . $view_field['align'];
        }
        if ($user['view'][$field]) {
            $value = $user['view'][$field];
        } else {
            $value = $user[$field];
        }
        if ($field == "postnum") {
            $value = my_number_format($user[$field]);
        }
        $table->construct_cell($value, $field_options);
    }
    $table->construct_cell("<input type=\"checkbox\" class=\"checkbox\" name=\"inlinemod_{$user['uid']}\" id=\"inlinemod_{$user['uid']}\" value=\"1\" onclick=\"\$('#uid_{$user['uid']}').toggleClass('inline_selected');\" />");
    $table->construct_row();
}
예제 #2
0
/**
 * @param DefaultTable $table
 * @param int $pid
 * @param int $depth
 */
function fetch_forum_announcements(&$table, $pid = 0, $depth = 1)
{
    global $mybb, $db, $lang, $announcements, $page;
    static $forums_by_parent;
    if (!is_array($forums_by_parent)) {
        $forum_cache = cache_forums();
        foreach ($forum_cache as $forum) {
            $forums_by_parent[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
        }
    }
    if (!is_array($forums_by_parent[$pid])) {
        return;
    }
    foreach ($forums_by_parent[$pid] as $children) {
        foreach ($children as $forum) {
            $forum['name'] = htmlspecialchars_uni($forum['name']);
            if ($forum['active'] == 0) {
                $forum['name'] = "<em>" . $forum['name'] . "</em>";
            }
            if ($forum['type'] == "c") {
                $forum['name'] = "<strong>" . $forum['name'] . "</strong>";
            }
            $table->construct_cell("<div style=\"padding-left: " . 40 * ($depth - 1) . "px;\">{$forum['name']}</div>");
            $table->construct_cell("<a href=\"index.php?module=forum-announcements&amp;action=add&amp;fid={$forum['fid']}\">{$lang->add_announcement}</a>", array("class" => "align_center", "colspan" => 2));
            $table->construct_row();
            if (isset($announcements[$forum['fid']])) {
                foreach ($announcements[$forum['fid']] as $aid => $announcement) {
                    if ($announcement['enddate'] < TIME_NOW && $announcement['enddate'] != 0) {
                        $icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"(Expired)\" title=\"Expired Announcement\"  style=\"vertical-align: middle;\" /> ";
                    } else {
                        $icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"(Active)\" title=\"Active Announcement\"  style=\"vertical-align: middle;\" /> ";
                    }
                    $table->construct_cell("<div style=\"padding-left: " . 40 * $depth . "px;\">{$icon}<a href=\"index.php?module=forum-announcements&amp;action=edit&amp;aid={$aid}\">" . htmlspecialchars_uni($announcement['subject']) . "</a></div>");
                    $table->construct_cell("<a href=\"index.php?module=forum-announcements&amp;action=edit&amp;aid={$aid}\">{$lang->edit}</a>", array("class" => "align_center"));
                    $table->construct_cell("<a href=\"index.php?module=forum-announcements&amp;action=delete&amp;aid={$aid}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_announcement_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
                    $table->construct_row();
                }
            }
            // Build the list for any sub forums of this forum
            if (isset($forums_by_parent[$forum['fid']])) {
                fetch_forum_announcements($table, $forum['fid'], $depth + 1);
            }
        }
    }
}
예제 #3
0
/**
 * @param array $attachment
 * @param DefaultTable $table
 * @param bool $use_form
 */
function build_attachment_row($attachment, &$table, $use_form = false)
{
    global $mybb, $form, $lang;
    $attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
    // Here we do a bit of detection, we want to automatically check for removal any missing attachments and any not assigned to a post uploaded > 24hours ago
    // Check if the attachment exists in the file system
    $checked = false;
    $title = $cell_class = '';
    if (!file_exists(MYBB_ROOT . $mybb->settings['uploadspath'] . "/{$attachment['attachname']}")) {
        $cell_class = "bad_attachment";
        $title = $lang->error_not_found;
        $checked = true;
    } elseif (!$attachment['pid'] && $attachment['dateuploaded'] < TIME_NOW - 60 * 60 * 24 && $attachment['dateuploaded'] != 0) {
        $cell_class = "bad_attachment";
        $title = $lang->error_not_attached;
        $checked = true;
    } else {
        if (!$attachment['tid'] && $attachment['pid']) {
            $cell_class = "bad_attachment";
            $title = $lang->error_does_not_exist;
            $checked = true;
        } else {
            if ($attachment['visible'] == 0) {
                $cell_class = "invisible_attachment";
            }
        }
    }
    if ($cell_class) {
        $cell_class .= " align_center";
    } else {
        $cell_class = "align_center";
    }
    if ($use_form == true && is_object($form)) {
        $table->construct_cell($form->generate_check_box('aids[]', $attachment['aid'], '', array('checked' => $checked)));
    }
    $table->construct_cell(get_attachment_icon(get_extension($attachment['filename'])), array('width' => 1));
    $table->construct_cell("<a href=\"../attachment.php?aid={$attachment['aid']}\" target=\"_blank\">{$attachment['filename']}</a>");
    $table->construct_cell(get_friendly_size($attachment['filesize']), array('class' => $cell_class));
    if ($attachment['user_username']) {
        $attachment['username'] = $attachment['username'];
    }
    $table->construct_cell(build_profile_link($attachment['username'], $attachment['uid'], "_blank"), array("class" => "align_center"));
    $table->construct_cell("<a href=\"../" . get_post_link($attachment['pid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($attachment['subject']) . "</a>", array("class" => "align_center"));
    $table->construct_cell(my_number_format($attachment['downloads']), array("class" => "align_center"));
    if ($attachment['dateuploaded'] > 0) {
        $date = my_date('relative', $attachment['dateuploaded']);
    } else {
        $date = $lang->unknown;
    }
    $table->construct_cell($date, array("class" => "align_center"));
    $table->construct_row();
}