Ejemplo n.º 1
0
    function addCheckboxes($name, $desc, $table, $linking_table = false, $table_col = false, $link_col = false, $id = false, $admin = false)
    {
        global $rows;
        $rows .= '<tr';
        if ($admin) {
            $rows .= ' class="admin"';
        }
        //special exceptions (this is terrible)
        if ($table == "modules") {
            $description = "name";
        } elseif ($table == 'skills') {
            $description = 'title';
        } else {
            $description = "description";
        }
        $rows .= '>
				<td class="left">' . $desc . '</td>
				<td>';
        if ($id) {
            $result = db_query("SELECT \n\t\t\t\t\t\t\tt.id, \n\t\t\t\t\t\t\tt.{$description} description, \n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM {$linking_table} l WHERE l.{$table_col} = {$id} AND l.{$link_col} = t.id) checked\n\t\t\t\t\t\tFROM {$table} t\n\t\t\t\t\t\tWHERE t.isActive = 1\n\t\t\t\t\t\tORDER BY t.{$description}");
        } else {
            $result = db_query("SELECT id, {$description} description, 0 checked FROM {$table} WHERE isActive = 1 ORDER BY {$description}");
        }
        if ($total = db_found($result)) {
            $counter = 0;
            $max = ceil($total / 3);
            $rows .= '<table class="nospacing" width="100%"><tr>';
            while ($r = db_fetch($result)) {
                if ($counter == 0) {
                    $rows .= '<td width="33%" style="vertical-align:top;"><table class="nospacing">';
                }
                $chkname = "chk_" . $name . "_" . $r["id"];
                $rows .= '
							<tr>
							<td>' . draw_form_checkbox($chkname, $r["checked"]) . '</td>
							<td>' . drawCheckboxText($chkname, $r["description"]) . '</td>
							</tr>';
                if ($counter == $max - 1) {
                    $rows .= '</table></td>';
                    $counter = 0;
                } else {
                    $counter++;
                }
            }
            if ($counter != 0) {
                $rows .= '</table></td>';
            }
            $rows .= '</tr></table>';
        }
        $rows .= '
				</td>
			</tr>';
    }
Ejemplo n.º 2
0
function drawThreadCommentForm($showAdmin = false)
{
    global $page, $_josh, $_SESSION;
    $name = $_josh['request']['folder'] == 'bb' ? 'description' : 'message';
    $return = '<a name="bottom"></a><form ';
    if ($_josh['db']['language'] == 'mysql') {
        $return .= 'accept-charset="utf-8" ';
    }
    $return .= 'method="post" action="' . $_josh['request']['path_query'] . '" onsubmit="javascript:return validate(this);"><tr valign="top">
			<td class="left">' . drawName($_SESSION['user_id'], $_SESSION['full_name'], false, true, false) . '</td>
			<td>' . draw_form_textarea($name . langExt(), '', 'mceEditor thread');
    if ($showAdmin && $page['is_admin']) {
        $return .= '
			<table class="nospacing">
				<tr>
					<td width="16">' . draw_form_checkbox('is_admin') . '</td>
					<td>' . drawCheckboxText('is_admin', 'This followup is admin-only (invisible to most users)') . '</td>
				</tr>
			</table>';
    }
    $return .= '
			</td>
		</tr>
		<tr>
			<td class="bottom" colspan="2">' . draw_form_submit(getString('add_followup')) . '</td>
		</tr>
		</form>';
    return $return;
}
Ejemplo n.º 3
0
    function addCheckboxes($name, $desc, $table, $linking_table = false, $table_col = false, $link_col = false, $id = false, $admin = false)
    {
        global $rows;
        $rows .= '<tr';
        if ($admin) {
            $rows .= ' class="admin"';
        }
        $title = "title";
        $checked = 0;
        //special addition for permissions
        $where = $name == "permissions" ? " AND l.is_admin = 1" : "";
        //special exception for channels table
        if ($table == "channels") {
            $title = "title" . langExt();
            $checked = 1;
        }
        $rows .= '>
			<td class="left">' . $desc . '</td>
			<td>';
        if ($id) {
            $result = db_query("SELECT \n\t\t\t\t\t\tt.id, \n\t\t\t\t\t\tt.{$title},\n\t\t\t\t\t\t(SELECT COUNT(*) FROM {$linking_table} l WHERE l.{$table_col} = {$id} AND l.{$link_col} = t.id {$where}) checked\n\t\t\t\t\tFROM {$table} t\n\t\t\t\t\tWHERE t.is_active = 1\n\t\t\t\t\tORDER BY t.{$title}");
        } else {
            $result = db_query("SELECT id, {$title}, {$checked} checked FROM {$table} WHERE is_active = 1 ORDER BY {$title}");
        }
        if ($total = db_found($result)) {
            $counter = 0;
            $max = ceil($total / 3);
            $rows .= '<table class="nospacing" width="100%"><tr>';
            while ($r = db_fetch($result)) {
                if ($counter == 0) {
                    $rows .= '<td width="33%" style="vertical-align:top;"><table class="nospacing">';
                }
                $chkname = "chk-" . $name . "-" . $r["id"];
                $rows .= '
						<tr>
						<td>' . draw_form_checkbox($chkname, $r["checked"]) . '</td>
						<td>' . drawCheckboxText($chkname, $r[$title]) . '</td>
						</tr>';
                if ($counter == $max - 1) {
                    $rows .= '</table></td>';
                    $counter = 0;
                } else {
                    $counter++;
                }
            }
            if ($counter != 0) {
                $rows .= '</table></td>';
            }
            $rows .= '</tr></table>';
        }
        $rows .= '
			</td>
		</tr>';
    }