} $form_container->output_cell("<img src=\"{$image}\" alt=\"\" />", array("class" => "align_center", "width" => 1)); $form_container->output_cell($form->generate_text_box("name[{$smilie['sid']}]", $smilie['name'], array('id' => 'name', 'style' => 'width: 98%'))); $form_container->output_cell($form->generate_text_box("find[{$smilie['sid']}]", $smilie['find'], array('id' => 'find', 'style' => 'width: 95%'))); $form_container->output_cell($form->generate_text_box("disporder[{$smilie['sid']}]", $smilie['disporder'], array('id' => 'disporder', 'style' => 'width: 80%'))); $form_container->output_cell($form->generate_yes_no_radio("showclickable[{$smilie['sid']}]", $smilie['showclickable']), array("class" => "align_center")); $form_container->output_cell($form->generate_check_box("delete[{$smilie['sid']}]", 1, $mybb->input['delete']), array("class" => "align_center")); $form_container->construct_row(); } if ($form_container->num_rows() == 0) { $form_container->output_cell($lang->no_smilies, array('colspan' => 6)); $form_container->construct_row(); } $form_container->end(); $buttons[] = $form->generate_submit_button($lang->save_smilies); $buttons[] = $form->generate_reset_button($lang->reset); $form->output_submit_wrapper($buttons); $form->end(); $page->output_footer(); } if (!$mybb->input['action']) { $plugins->run_hooks("admin_config_smilies_start"); $page->output_header($lang->manage_smilies); $sub_tabs['manage_smilies'] = array('title' => $lang->manage_smilies, 'link' => "index.php?module=config-smilies", 'description' => $lang->manage_smilies_desc); $sub_tabs['add_smilie'] = array('title' => $lang->add_smilie, 'link' => "index.php?module=config-smilies&action=add"); $sub_tabs['add_multiple_smilies'] = array('title' => $lang->add_multiple_smilies, 'link' => "index.php?module=config-smilies&action=add_multiple"); $sub_tabs['mass_edit'] = array('title' => $lang->mass_edit, 'link' => "index.php?module=config-smilies&action=mass_edit"); $page->output_nav_tabs($sub_tabs, 'manage_smilies'); $pagenum = intval($mybb->input['page']); if ($pagenum) { $start = ($pagenum - 1) * 20;
$plugins->run_hooks("newpoints_admin_maintenance_edituser_commit"); $db->update_query('users', $updates, 'uid=\'' . intval($mybb->input['uid']) . '\''); flash_message($lang->newpoints_user_edited, 'success'); admin_redirect("index.php?module=newpoints-maintenance"); } $form = new Form("index.php?module=newpoints-maintenance&action=edituser", "post", "newpoints"); echo $form->generate_hidden_field("uid", intval($mybb->input['uid'])); echo $form->generate_hidden_field("my_post_key", $mybb->post_code); echo $form->generate_hidden_field("do_change", 1); $form_container = new FormContainer($lang->newpoints_edituser); $form_container->output_row($lang->newpoints_edituser_points, $lang->newpoints_edituser_points_desc, $form->generate_text_box('points', round($user['newpoints'], intval($mybb->settings['newpoints_main_decimal'])), array('id' => 'points')), 'points'); $form_container->end(); $plugins->run_hooks("newpoints_admin_maintenance_edituser_form"); $buttons = array(); $buttons[] = $form->generate_submit_button($lang->newpoints_submit_button); $buttons[] = $form->generate_reset_button($lang->newpoints_reset_button); $form->output_submit_wrapper($buttons); $form->end(); $plugins->run_hooks("newpoints_admin_maintenance_edituser_end"); } elseif ($mybb->input['action'] == 'recount') { $plugins->run_hooks("newpoints_admin_maintenance_recount_start"); if ($mybb->input['no']) { admin_redirect("index.php?module=newpoints-maintenance"); } if ($mybb->request_method == "post") { $mybb->input['per_page'] = intval($mybb->input['per_page']); if (!isset($mybb->input['my_post_key']) || $mybb->post_code != $mybb->input['my_post_key'] || !$mybb->input['per_page']) { $mybb->request_method = "get"; flash_message($lang->newpoints_error, 'error'); admin_redirect("index.php?module=newpoints-maintenance"); }
} $awards->update_cache(); $awards->admin_redirect(); } $form = new Form($awards->build_url('action=updatedisporder'), 'post'); $query2 = $db->simple_select('ougc_awards', 'COUNT(aid) AS awards'); $awardscount = (int) $db->fetch_field($query2, 'awards'); echo draw_admin_pagination($mybb->input['page'], $limit, $awardscount, 'index.php?module=user-ougc_awards'); while ($award = $db->fetch_array($query)) { $edit_link = "index.php?module=user-ougc_awards&action=edit&aid={$award['aid']}"; $award['visible'] or $award['name'] = '<i>' . $award['name'] . '</i>'; $table->construct_cell('<img src="' . $awards->get_award_icon($award['aid']) . '" />', array('class' => 'align_center')); $table->construct_cell('<a href="' . $edit_link . '">' . $award['name'] . '</a>'); $table->construct_cell($award['description']); $table->construct_cell($form->generate_text_box('disporder[' . $award['aid'] . ']', (int) $award['disporder'], array('style' => 'text-align: center; width: 30px;')), array('class' => 'align_center')); $table->construct_cell('<img src="styles/default/images/icons/bullet_o' . (!$award['visible'] ? 'ff' : 'n') . '.png" alt="" title="' . (!$award['visible'] ? $lang->ougc_awards_form_hidden : $lang->ougc_awards_form_visible) . '" />', array('class' => 'align_center')); $popup = new PopupMenu("award_{$award['aid']}", $lang->options); $popup->add_item($lang->ougc_awards_tab_give, "index.php?module=user-ougc_awards&action=give&aid={$award['aid']}"); $popup->add_item($lang->ougc_awards_tab_revoke, "index.php?module=user-ougc_awards&action=revoke&aid={$award['aid']}"); $popup->add_item($lang->ougc_awards_tab_users, "index.php?module=user-ougc_awards&action=users&aid={$award['aid']}"); $popup->add_item($lang->ougc_awards_tab_edit, $edit_link); $popup->add_item($lang->ougc_awards_tab_delete, "index.php?module=user-ougc_awards&action=delete&aid={$award['aid']}"); $table->construct_cell($popup->fetch(), array('class' => 'align_center')); $table->construct_row(); } $table->output($lang->ougc_awards_tab_view_d); $form->output_submit_wrapper(array($form->generate_submit_button($lang->ougc_awards_button_order), $form->generate_reset_button($lang->reset))); $form->end(); } $page->output_footer(); }
function newpoints_shop_admin() { global $db, $lang, $mybb, $page, $run_module, $action_file, $mybbadmin, $plugins; newpoints_lang_load('newpoints_shop'); if ($run_module == 'newpoints' && $action_file == 'newpoints_shop') { if ($mybb->request_method == "post") { switch ($mybb->input['action']) { case 'do_addcat': if ($mybb->input['name'] == '') { newpoints_shop_messageredirect($lang->newpoints_shop_missing_field, 1); } $name = $db->escape_string($mybb->input['name']); $description = $db->escape_string($mybb->input['description']); // get visible to user groups options if (is_array($mybb->input['usergroups'])) { foreach ($mybb->input['usergroups'] as $gid) { if ($gid == $mybb->input['usergroups']) { unset($mybb->input['usergroups'][$gid]); } } $usergroups = implode(",", $mybb->input['usergroups']); } else { $usergroups = ''; } $usergroups = $db->escape_string($usergroups); $visible = intval($mybb->input['visible']); $icon = $db->escape_string($mybb->input['icon']); $disporder = intval($mybb->input['disporder']); $expanded = intval($mybb->input['expanded']); $insert_query = array('name' => $name, 'description' => $description, 'usergroups' => $usergroups, 'visible' => $visible, 'disporder' => $disporder, 'icon' => $icon, 'expanded' => $expanded); $db->insert_query('newpoints_shop_categories', $insert_query); newpoints_shop_messageredirect($lang->newpoints_shop_cat_added); break; case 'do_editcat': $cid = intval($mybb->input['cid']); if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1); } if ($mybb->input['name'] == '') { newpoints_shop_messageredirect($lang->newpoints_shop_missing_field, 1); } $name = $db->escape_string($mybb->input['name']); $description = $db->escape_string($mybb->input['description']); // get visible to user groups options if (is_array($mybb->input['usergroups'])) { foreach ($mybb->input['usergroups'] as $gid) { if ($gid == $mybb->input['usergroups']) { unset($mybb->input['usergroups'][$gid]); } } $usergroups = implode(",", $mybb->input['usergroups']); } else { $usergroups = ''; } $usergroups = $db->escape_string($usergroups); $visible = intval($mybb->input['visible']); $icon = $db->escape_string($mybb->input['icon']); $disporder = intval($mybb->input['disporder']); $expanded = intval($mybb->input['expanded']); $update_query = array('name' => $name, 'description' => $description, 'usergroups' => $usergroups, 'visible' => $visible, 'disporder' => $disporder, 'icon' => $icon, 'expanded' => $expanded); $db->update_query('newpoints_shop_categories', $update_query, 'cid=\'' . $cid . '\''); newpoints_shop_messageredirect($lang->newpoints_shop_cat_edited); break; case 'do_additem': if ($mybb->input['name'] == '' || $mybb->input['cid'] == '') { newpoints_shop_messageredirect($lang->newpoints_shop_missing_field, 1); } $name = $db->escape_string($mybb->input['name']); $description = $db->escape_string($mybb->input['description']); $icon = $db->escape_string($mybb->input['icon']); $pm = $db->escape_string($mybb->input['pm']); $price = floatval($mybb->input['price']); $infinite = intval($mybb->input['infinite']); if ($infinite == 1) { $stock = 0; } else { $stock = intval($mybb->input['stock']); } $limit = intval($mybb->input['limit']); $visible = intval($mybb->input['visible']); $disporder = intval($mybb->input['disporder']); $sendable = intval($mybb->input['sendable']); $sellable = intval($mybb->input['sellable']); $cid = intval($mybb->input['cid']); if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1); } $insert_array = array('name' => $name, 'description' => $description, 'icon' => $icon, 'visible' => $visible, 'disporder' => $disporder, 'price' => $price, 'infinite' => $infinite, 'stock' => $stock, 'limit' => $limit, 'sendable' => $sendable, 'sellable' => $sellable, 'cid' => $cid, 'pm' => $pm); $plugins->run_hooks("newpoints_shop_commit", $insert_array); $db->insert_query('newpoints_shop_items', $insert_array); $db->write_query('UPDATE ' . TABLE_PREFIX . 'newpoints_shop_categories SET items = items+1 WHERE cid=\'' . $cid . '\''); newpoints_shop_messageredirect($lang->newpoints_shop_item_added, 0, "items&cid=" . $cid); break; case 'do_edititem': $iid = intval($mybb->input['iid']); if ($iid <= 0 || !($item = $db->fetch_array($db->simple_select('newpoints_shop_items', '*', "iid = {$iid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_item, 1, 'items'); } if ($mybb->input['name'] == '' || $mybb->input['cid'] == '') { newpoints_shop_messageredirect($lang->newpoints_shop_missing_field, 1); } $name = $db->escape_string($mybb->input['name']); $description = $db->escape_string($mybb->input['description']); $icon = $db->escape_string($mybb->input['icon']); $price = floatval($mybb->input['price']); $pm = $db->escape_string($mybb->input['pm']); $infinite = intval($mybb->input['infinite']); if ($infinite == 1) { $stock = 0; } else { $stock = intval($mybb->input['stock']); } $limit = intval($mybb->input['limit']); $visible = intval($mybb->input['visible']); $disporder = intval($mybb->input['disporder']); $sendable = intval($mybb->input['sendable']); $sellable = intval($mybb->input['sellable']); $cid = intval($mybb->input['cid']); if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1); } $update_array = array('name' => $name, 'description' => $description, 'icon' => $icon, 'visible' => $visible, 'disporder' => $disporder, 'price' => $price, 'infinite' => $infinite, 'stock' => $stock, 'limit' => $limit, 'sendable' => $sendable, 'sellable' => $sellable, 'cid' => $cid, 'pm' => $pm); $plugins->run_hooks("newpoints_shop_commit", $update_array); $db->update_query('newpoints_shop_items', $update_array, 'iid=\'' . $iid . '\''); if ($cid != $item['cid']) { $db->write_query('UPDATE ' . TABLE_PREFIX . 'newpoints_shop_categories SET items = items-1 WHERE cid=\'' . $item['cid'] . '\''); $db->write_query('UPDATE ' . TABLE_PREFIX . 'newpoints_shop_categories SET items = items+1 WHERE cid=\'' . $cid . '\''); } newpoints_shop_messageredirect($lang->newpoints_shop_item_edited, 0, "items&cid=" . $cid); break; } } if ($mybb->input['action'] == 'do_deletecat') { $page->add_breadcrumb_item($lang->newpoints_shop, 'index.php?module=newpoints-shop'); $page->output_header($lang->newpoints_shop); $cid = intval($mybb->input['cid']); if ($mybb->input['no']) { admin_redirect("index.php?module=newpoints-shop"); } if ($mybb->request_method == "post") { if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', 'cid', "cid = {$cid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1); } $db->delete_query('newpoints_shop_categories', "cid = {$cid}"); // unassign items from this category $db->update_query('newpoints_shop_items', array('cid' => 0), "cid = {$cid}"); newpoints_shop_messageredirect($lang->newpoints_shop_cat_deleted); } else { $mybb->input['cid'] = intval($mybb->input['cid']); $form = new Form("index.php?module=newpoints-shop&action=do_deletecat&cid={$mybb->input['cid']}&my_post_key={$mybb->post_code}", 'post'); echo "<div class=\"confirm_action\">\n"; echo "<p>{$lang->newpoints_shop_confirm_deletecat}</p>\n"; echo "<br />\n"; echo "<p class=\"buttons\">\n"; echo $form->generate_submit_button($lang->yes, array('class' => 'button_yes')); echo $form->generate_submit_button($lang->no, array("name" => "no", 'class' => 'button_no')); echo "</p>\n"; echo "</div>\n"; $form->end(); } } elseif ($mybb->input['action'] == 'do_deleteitem') { $page->add_breadcrumb_item($lang->newpoints_shop, 'index.php?module=newpoints-shop'); $page->output_header($lang->newpoints_shop); $iid = intval($mybb->input['iid']); if ($mybb->input['no']) { admin_redirect("index.php?module=newpoints-shop", 0, "items&cid=" . $cid); } if ($mybb->request_method == "post") { if ($iid <= 0 || !($item = $db->fetch_array($db->simple_select('newpoints_shop_items', 'cid', "iid = {$iid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_item, 1, "items&cid=" . $cid); } $db->delete_query('newpoints_shop_items', "iid = {$iid}"); // remove one from the items count $db->write_query('UPDATE ' . TABLE_PREFIX . 'newpoints_shop_categories SET items = items-1 WHERE cid=\'' . $item['cid'] . '\''); newpoints_shop_messageredirect($lang->newpoints_shop_item_deleted, 0, "items&cid=" . $cid); } else { $mybb->input['iid'] = intval($mybb->input['iid']); $form = new Form("index.php?module=newpoints-shop&action=do_deleteitem&iid={$mybb->input['iid']}&my_post_key={$mybb->post_code}", 'post'); echo "<div class=\"confirm_action\">\n"; echo "<p>{$lang->newpoints_shop_confirm_deleteitem}</p>\n"; echo "<br />\n"; echo "<p class=\"buttons\">\n"; echo $form->generate_submit_button($lang->yes, array('class' => 'button_yes')); echo $form->generate_submit_button($lang->no, array("name" => "no", 'class' => 'button_no')); echo "</p>\n"; echo "</div>\n"; $form->end(); } } elseif ($mybb->input['action'] == 'remove') { $page->add_breadcrumb_item($lang->newpoints_shop, 'index.php?module=newpoints-shop'); $page->output_header($lang->newpoints_shop); $iid = intval($mybb->input['iid']); $mybb->input['uid'] = intval($mybb->input['uid']); if ($mybb->input['no']) { admin_redirect("index.php?module=newpoints-shop", 0, "items&cid=" . $cid); } if ($mybb->request_method == "post") { if ($iid <= 0 || !($item = $db->fetch_array($db->simple_select('newpoints_shop_items', '*', "iid = {$iid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_item, 1, "items&cid=" . $cid); } $uid = (int) $mybb->input['uid']; if ($uid <= 0) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_user, 1); } $user = get_user($uid); // we're viewing someone else's inventory if (empty($user)) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_user, 1); } $inventory = @unserialize($user['newpoints_items']); if (!$inventory) { newpoints_shop_messageredirect($lang->newpoints_shop_inventory_empty, 1); } // make sure we own the item $key = array_search($item['iid'], $inventory); if ($key === false) { newpoints_shop_messageredirect($lang->newpoints_shop_selected_item_not_owned, 1); } // remove item from our inventory unset($inventory[$key]); sort($inventory); $db->update_query('users', array('newpoints_items' => serialize($inventory)), 'uid=\'' . $uid . '\''); // update stock if ($item['infinite'] != 1) { $db->update_query('newpoints_shop_items', array('stock' => $item['stock'] + 1), 'iid=\'' . $item['iid'] . '\''); } newpoints_addpoints($uid, floatval($item['price']) * $mybb->settings['newpoints_shop_percent']); newpoints_shop_messageredirect($lang->newpoints_shop_item_removed, 0, "inventory&uid=" . $uid); } else { $form = new Form("index.php?module=newpoints-shop&action=remove&iid={$mybb->input['iid']}&uid={$mybb->input['uid']}&my_post_key={$mybb->post_code}", 'post'); echo "<div class=\"confirm_action\">\n"; echo "<p>{$lang->newpoints_shop_confirm_removeitem}</p>\n"; echo "<br />\n"; echo "<p class=\"buttons\">\n"; echo $form->generate_submit_button($lang->yes, array('class' => 'button_yes')); echo $form->generate_submit_button($lang->no, array("name" => "no", 'class' => 'button_no')); echo "</p>\n"; echo "</div>\n"; $form->end(); } } if (!$mybb->input['action'] || $mybb->input['action'] == 'categories' || $mybb->input['action'] == 'inventory' || $mybb->input['action'] == 'addcat' || $mybb->input['action'] == 'editcat') { $page->add_breadcrumb_item($lang->newpoints_shop, 'index.php?module=newpoints-shop'); $page->output_header($lang->newpoints_shop); $sub_tabs['newpoints_shop_categories'] = array('title' => $lang->newpoints_shop_categories, 'link' => 'index.php?module=newpoints-shop', 'description' => $lang->newpoints_shop_categories_desc); if (!$mybb->input['action'] || $mybb->input['action'] == 'categories' || $mybb->input['action'] == 'addcat' || $mybb->input['action'] == 'editcat') { $sub_tabs['newpoints_shop_categories_add'] = array('title' => $lang->newpoints_shop_addcat, 'link' => 'index.php?module=newpoints-shop&action=addcat', 'description' => $lang->newpoints_shop_addcat_desc); $sub_tabs['newpoints_shop_categories_edit'] = array('title' => $lang->newpoints_shop_editcat, 'link' => 'index.php?module=newpoints-shop&action=editcat', 'description' => $lang->newpoints_shop_editcat_desc); $sub_tabs['newpoints_shop_categories_delete'] = array('title' => $lang->newpoints_shop_deletecat, 'link' => 'index.php?module=newpoints-shop&action=do_deletecat', 'description' => $lang->newpoints_shop_deletecat_desc); } } if ($mybb->input['action'] == 'inventory') { $sub_tabs['newpoints_shop_inventory'] = array('title' => $lang->newpoints_shop_inventory, 'link' => 'index.php?module=newpoints-shop&action=inventory&uid=' . intval($mybb->input['uid']), 'description' => $lang->newpoints_shop_inventory_desc); } if ($mybb->input['action'] == 'items' || $mybb->input['action'] == 'additem' || $mybb->input['action'] == 'edititem') { $page->add_breadcrumb_item($lang->newpoints_shop, 'index.php?module=newpoints-shop'); $page->output_header($lang->newpoints_shop); $sub_tabs['newpoints_shop_categories'] = array('title' => $lang->newpoints_shop_categories, 'link' => 'index.php?module=newpoints-shop', 'description' => $lang->newpoints_shop_categories_desc); $sub_tabs['newpoints_shop_items'] = array('title' => $lang->newpoints_shop_items, 'link' => 'index.php?module=newpoints-shop&action=items&cid=' . intval($mybb->input['cid']), 'description' => $lang->newpoints_shop_items_desc); if ($mybb->input['action'] == 'items' || $mybb->input['action'] == 'additem' || $mybb->input['action'] == 'edititem') { $sub_tabs['newpoints_shop_items_add'] = array('title' => $lang->newpoints_shop_additem, 'link' => 'index.php?module=newpoints-shop&action=additem&cid=' . intval($mybb->input['cid']), 'description' => $lang->newpoints_shop_additem_desc); $sub_tabs['newpoints_shop_items_edit'] = array('title' => $lang->newpoints_shop_edititem, 'link' => 'index.php?module=newpoints-shop&action=edititem', 'description' => $lang->newpoints_shop_edititem_desc); $sub_tabs['newpoints_shop_items_delete'] = array('title' => $lang->newpoints_shop_deleteitem, 'link' => 'index.php?module=newpoints-shop&action=do_deleteitem', 'description' => $lang->newpoints_shop_deleteitem_desc); } } if (!$mybb->input['action'] || $mybb->input['action'] == 'categories') { $page->output_nav_tabs($sub_tabs, 'newpoints_shop_categories'); // table $table = new Table(); $table->construct_header($lang->newpoints_shop_cat_name, array('width' => '30%')); $table->construct_header($lang->newpoints_shop_cat_description, array('width' => '35%')); $table->construct_header($lang->newpoints_shop_cat_items, array('width' => '10%', 'class' => 'align_center')); $table->construct_header($lang->newpoints_shop_cat_disporder, array('width' => '10%', 'class' => 'align_center')); $table->construct_header($lang->newpoints_shop_cat_action, array('width' => '25%', 'class' => 'align_center')); $query = $db->simple_select('newpoints_shop_categories', '*', '', array('order_by' => 'disporder', 'order_dir' => 'ASC')); while ($cat = $db->fetch_array($query)) { $table->construct_cell("<a href=\"index.php?module=newpoints-shop&action=items&cid={$cat['cid']}\">" . htmlspecialchars_uni($cat['name']) . "</a>"); $table->construct_cell(htmlspecialchars_uni($cat['description'])); $table->construct_cell(intval($cat['items']), array('class' => 'align_center')); $table->construct_cell(intval($cat['disporder']), array('class' => 'align_center')); // actions column $table->construct_cell("<a href=\"index.php?module=newpoints-shop&action=editcat&cid=" . intval($cat['cid']) . "\">" . $lang->newpoints_shop_edit . "</a> - <a href=\"index.php?module=newpoints-shop&action=do_deletecat&cid=" . intval($cat['cid']) . "\">" . $lang->newpoints_shop_delete . "</a>", array('class' => 'align_center')); $table->construct_row(); } if ($table->num_rows() == 0) { $table->construct_cell($lang->newpoints_shop_no_cats, array('colspan' => 5)); $table->construct_row(); } $table->output($lang->newpoints_shop_categories); } elseif ($mybb->input['action'] == 'addcat') { $page->output_nav_tabs($sub_tabs, 'newpoints_shop_categories_add'); $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title')); while ($usergroup = $db->fetch_array($query)) { $options[$usergroup['gid']] = $usergroup['title']; } $form = new Form("index.php?module=newpoints-shop&action=do_addcat", "post", "newpoints_shop"); $form_container = new FormContainer($lang->newpoints_shop_addcat); $form_container->output_row($lang->newpoints_shop_addedit_cat_name . "<em>*</em>", $lang->newpoints_shop_addedit_cat_name_desc, $form->generate_text_box('name', '', array('id' => 'name')), 'name'); $form_container->output_row($lang->newpoints_shop_addedit_cat_description, $lang->newpoints_shop_addedit_cat_description_desc, $form->generate_text_box('description', '', array('id' => 'description')), 'description'); $form_container->output_row($lang->newpoints_shop_addedit_cat_visible, $lang->newpoints_shop_addedit_cat_visible_desc, $form->generate_yes_no_radio('visible', 1), 'visible'); $form_container->output_row($lang->newpoints_shop_addedit_cat_icon, $lang->newpoints_shop_addedit_cat_icon_desc, $form->generate_text_box('icon', '', array('id' => 'icon')), 'icon'); $form_container->output_row($lang->newpoints_shop_addedit_cat_usergroups, $lang->newpoints_shop_addedit_cat_usergroups_desc, $form->generate_select_box('usergroups[]', $options, '', array('id' => 'usergroups', 'multiple' => true, 'size' => 5)), 'groups'); $form_container->output_row($lang->newpoints_shop_addedit_cat_disporder, $lang->newpoints_shop_addedit_cat_disporder_desc, $form->generate_text_box('disporder', '0', array('id' => 'disporder')), 'disporder'); $form_container->output_row($lang->newpoints_shop_addedit_cat_expanded, $lang->newpoints_shop_addedit_cat_expanded_desc, $form->generate_yes_no_radio('expanded', 1), 'expanded'); $form_container->end(); $buttons = ""; $buttons[] = $form->generate_submit_button($lang->newpoints_shop_submit); $buttons[] = $form->generate_reset_button($lang->newpoints_shop_reset); $form->output_submit_wrapper($buttons); $form->end(); } elseif ($mybb->input['action'] == 'editcat') { $page->output_nav_tabs($sub_tabs, 'newpoints_shop_categories_edit'); $cid = intval($mybb->input['cid']); if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1); } $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title')); while ($usergroup = $db->fetch_array($query)) { $options[$usergroup['gid']] = $usergroup['title']; } $form = new Form("index.php?module=newpoints-shop&action=do_editcat", "post", "newpoints_shop"); echo $form->generate_hidden_field('cid', $cat['cid']); $form_container = new FormContainer($lang->newpoints_shop_addcat); $form_container->output_row($lang->newpoints_shop_addedit_cat_name . "<em>*</em>", $lang->newpoints_shop_addedit_cat_name_desc, $form->generate_text_box('name', htmlspecialchars_uni($cat['name']), array('id' => 'name')), 'name'); $form_container->output_row($lang->newpoints_shop_addedit_cat_description, $lang->newpoints_shop_addedit_cat_description_desc, $form->generate_text_box('description', htmlspecialchars_uni($cat['description']), array('id' => 'description')), 'description'); $form_container->output_row($lang->newpoints_shop_addedit_cat_visible, $lang->newpoints_shop_addedit_cat_visible_desc, $form->generate_yes_no_radio('visible', intval($cat['visible'])), 'visible'); $form_container->output_row($lang->newpoints_shop_addedit_cat_icon, $lang->newpoints_shop_addedit_cat_icon_desc, $form->generate_text_box('icon', htmlspecialchars_uni($cat['icon']), array('id' => 'icon')), 'icon'); $form_container->output_row($lang->newpoints_shop_addedit_cat_usergroups, $lang->newpoints_shop_addedit_cat_usergroups_desc, $form->generate_select_box('usergroups[]', $options, explode(',', $cat['usergroups']), array('id' => 'usergroups', 'multiple' => true, 'size' => 5)), 'groups'); $form_container->output_row($lang->newpoints_shop_addedit_cat_disporder, $lang->newpoints_shop_addedit_cat_disporder_desc, $form->generate_text_box('disporder', intval($cat['disporder']), array('id' => 'disporder')), 'disporder'); $form_container->output_row($lang->newpoints_shop_addedit_cat_expanded, $lang->newpoints_shop_addedit_cat_expanded_desc, $form->generate_yes_no_radio('expanded', intval($cat['expanded'])), 'expanded'); $form_container->end(); $buttons = ""; $buttons[] = $form->generate_submit_button($lang->newpoints_shop_submit); $buttons[] = $form->generate_reset_button($lang->newpoints_shop_reset); $form->output_submit_wrapper($buttons); $form->end(); } else { if ($mybb->input['action'] == 'items') { $page->output_nav_tabs($sub_tabs, 'newpoints_shop_items'); $cid = intval($mybb->input['cid']); if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1); } // table $table = new Table(); $table->construct_header($lang->newpoints_shop_item_icon, array('width' => '10%', 'class' => 'align_center')); $table->construct_header($lang->newpoints_shop_item_name, array('width' => '30%')); $table->construct_header($lang->newpoints_shop_item_price, array('width' => '15%', 'class' => 'align_center')); $table->construct_header($lang->newpoints_shop_item_disporder, array('width' => '15%', 'class' => 'align_center')); $table->construct_header($lang->newpoints_shop_item_action, array('width' => '20%', 'class' => 'align_center')); $query = $db->simple_select('newpoints_shop_items', '*', 'cid=\'' . $cid . '\'', array('order_by' => 'disporder', 'order_dir' => 'ASC')); while ($item = $db->fetch_array($query)) { if ($item['infinite'] == 1) { $item['stock'] = $lang->newpoints_shop_infinite; } if ($item['visible'] == 0) { $visible_info = ' (<span style="color: #FF0000;">hidden</span>)'; } else { $visible_info = ''; } $table->construct_cell(htmlspecialchars_uni($item['icon']) ? '<img src="' . $mybb->settings['bburl'] . '/' . $item['icon'] . '">' : '<img src="' . $mybb->settings['bburl'] . '/images/newpoints/default.png">', array('class' => 'align_center')); $table->construct_cell(htmlspecialchars_uni($item['name']) . " (" . (intval($item['infinite']) ? $lang->newpoints_shop_infinite : intval($item['stock'])) . ")" . $visible_info . "<br /><small>" . htmlspecialchars_uni($item['description']) . "</small>"); $table->construct_cell(newpoints_format_points($item['price']), array('class' => 'align_center')); $table->construct_cell(intval($item['disporder']), array('class' => 'align_center')); // actions column $table->construct_cell("<a href=\"index.php?module=newpoints-shop&action=edititem&iid=" . intval($item['iid']) . "\">" . $lang->newpoints_shop_edit . "</a> - <a href=\"index.php?module=newpoints-shop&action=do_deleteitem&iid=" . intval($item['iid']) . "\">" . $lang->newpoints_shop_delete . "</a>", array('class' => 'align_center')); $table->construct_row(); } if ($table->num_rows() == 0) { $table->construct_cell($lang->newpoints_shop_no_items, array('colspan' => 6)); $table->construct_row(); } $table->output($lang->newpoints_shop_items); } elseif ($mybb->input['action'] == 'additem') { $page->output_nav_tabs($sub_tabs, 'newpoints_shop_items_add'); $cid = intval($mybb->input['cid']); if ($cid > 0) { if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1); } } else { $cid = 0; } $categories[0] = $lang->newpoints_shop_select_cat; $query = $db->simple_select('newpoints_shop_categories', '*'); while ($cat = $db->fetch_array($query)) { $categories[$cat['cid']] = $cat['name']; } $form = new Form("index.php?module=newpoints-shop&action=do_additem", "post", "newpoints_shop"); $form_container = new FormContainer($lang->newpoints_shop_additem); $form_container->output_row($lang->newpoints_shop_addedit_item_name . "<em>*</em>", $lang->newpoints_shop_addedit_item_name_desc, $form->generate_text_box('name', '', array('id' => 'name')), 'name'); $form_container->output_row($lang->newpoints_shop_addedit_item_description, $lang->newpoints_shop_addedit_item_description_desc, $form->generate_text_box('description', '', array('id' => 'description')), 'description'); $form_container->output_row($lang->newpoints_shop_addedit_item_price, $lang->newpoints_shop_addedit_item_price_desc, $form->generate_text_box('price', '0', array('id' => 'price')), 'price'); $form_container->output_row($lang->newpoints_shop_addedit_item_icon, $lang->newpoints_shop_addedit_item_icon_desc, $form->generate_text_box('icon', '', array('id' => 'icon')), 'icon'); $form_container->output_row($lang->newpoints_shop_addedit_item_disporder, $lang->newpoints_shop_addedit_item_disporder_desc, $form->generate_text_box('disporder', '0', array('id' => 'disporder')), 'disporder'); $form_container->output_row($lang->newpoints_shop_addedit_item_stock, $lang->newpoints_shop_addedit_item_stock_desc, $form->generate_text_box('stock', '0', array('id' => 'stock')), 'stock'); $form_container->output_row($lang->newpoints_shop_addedit_item_infinite, $lang->newpoints_shop_addedit_item_infinite_desc, $form->generate_yes_no_radio('infinite', 1), 'infinite'); $form_container->output_row($lang->newpoints_shop_addedit_item_limit, $lang->newpoints_shop_addedit_item_limit_desc, $form->generate_text_box('limit', '0', array('id' => 'limit')), 'limit'); $form_container->output_row($lang->newpoints_shop_addedit_item_visible, $lang->newpoints_shop_addedit_item_visible_desc, $form->generate_yes_no_radio('visible', 1), 'visible'); $form_container->output_row($lang->newpoints_shop_addedit_item_sendable, $lang->newpoints_shop_addedit_item_sendable_desc, $form->generate_yes_no_radio('sendable', 1), 'sendable'); $form_container->output_row($lang->newpoints_shop_addedit_item_sellable, $lang->newpoints_shop_addedit_item_sellable_desc, $form->generate_yes_no_radio('sellable', 1), 'sellable'); $form_container->output_row($lang->newpoints_shop_addedit_item_pm, $lang->newpoints_shop_addedit_item_pm_desc, $form->generate_text_area('pm', '', array('id' => 'pm_text')), 'pm'); $form_container->output_row($lang->newpoints_shop_addedit_item_category . "<em>*</em>", $lang->newpoints_shop_addedit_item_category_desc, $form->generate_select_box('cid', $categories, $cid, array('id' => 'cid')), 'cid'); $args = array($form_container, $form, array()); $plugins->run_hooks("newpoints_shop_row", $args); $form_container->end(); $buttons = ""; $buttons[] = $form->generate_submit_button($lang->newpoints_shop_submit); $buttons[] = $form->generate_reset_button($lang->newpoints_shop_reset); $form->output_submit_wrapper($buttons); $form->end(); } elseif ($mybb->input['action'] == 'edititem') { $page->output_nav_tabs($sub_tabs, 'newpoints_shop_items_edit'); $iid = intval($mybb->input['iid']); if ($iid <= 0 || !($item = $db->fetch_array($db->simple_select('newpoints_shop_items', '*', "iid = {$iid}")))) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_item, 1, 'items'); } $categories[0] = $lang->newpoints_shop_select_cat; $query = $db->simple_select('newpoints_shop_categories', '*'); while ($cat = $db->fetch_array($query)) { $categories[$cat['cid']] = $cat['name']; } $form = new Form("index.php?module=newpoints-shop&action=do_edititem", "post", "newpoints_shop"); echo $form->generate_hidden_field('iid', $iid); $form_container = new FormContainer($lang->newpoints_shop_additem); $form_container->output_row($lang->newpoints_shop_addedit_item_name . "<em>*</em>", $lang->newpoints_shop_addedit_item_name_desc, $form->generate_text_box('name', htmlspecialchars_uni($item['name']), array('id' => 'name')), 'name'); $form_container->output_row($lang->newpoints_shop_addedit_item_description, $lang->newpoints_shop_addedit_item_description_desc, $form->generate_text_box('description', htmlspecialchars_uni($item['description']), array('id' => 'description')), 'description'); $form_container->output_row($lang->newpoints_shop_addedit_item_price, $lang->newpoints_shop_addedit_item_price_desc, $form->generate_text_box('price', floatval($item['price']), array('id' => 'price')), 'price'); $form_container->output_row($lang->newpoints_shop_addedit_item_icon, $lang->newpoints_shop_addedit_item_icon_desc, $form->generate_text_box('icon', htmlspecialchars_uni($item['icon']), array('id' => 'icon')), 'icon'); $form_container->output_row($lang->newpoints_shop_addedit_item_disporder, $lang->newpoints_shop_addedit_item_disporder_desc, $form->generate_text_box('disporder', intval($item['disporder']), array('id' => 'disporder')), 'disporder'); $form_container->output_row($lang->newpoints_shop_addedit_item_stock, $lang->newpoints_shop_addedit_item_stock_desc, $form->generate_text_box('stock', intval($item['stock']), array('id' => 'stock')), 'stock'); $form_container->output_row($lang->newpoints_shop_addedit_item_infinite, $lang->newpoints_shop_addedit_item_infinite_desc, $form->generate_yes_no_radio('infinite', intval($item['infinite'])), 'infinite'); $form_container->output_row($lang->newpoints_shop_addedit_item_limit, $lang->newpoints_shop_addedit_item_limit_desc, $form->generate_text_box('limit', intval($item['limit']), array('id' => 'limit')), 'limit'); $form_container->output_row($lang->newpoints_shop_addedit_item_visible, $lang->newpoints_shop_addedit_item_visible_desc, $form->generate_yes_no_radio('visible', intval($item['visible'])), 'visible'); $form_container->output_row($lang->newpoints_shop_addedit_item_sendable, $lang->newpoints_shop_addedit_item_sendable_desc, $form->generate_yes_no_radio('sendable', intval($item['sendable'])), 'sendable'); $form_container->output_row($lang->newpoints_shop_addedit_item_sellable, $lang->newpoints_shop_addedit_item_sellable_desc, $form->generate_yes_no_radio('sellable', intval($item['sellable'])), 'sellable'); $form_container->output_row($lang->newpoints_shop_addedit_item_pm, $lang->newpoints_shop_addedit_item_pm_desc, $form->generate_text_area('pm', htmlspecialchars_uni($item['pm']), array('id' => 'pm_text')), 'pm'); $form_container->output_row($lang->newpoints_shop_addedit_item_category . "<em>*</em>", $lang->newpoints_shop_addedit_item_category_desc, $form->generate_select_box('cid', $categories, intval($item['cid']), array('id' => 'cid')), 'cid'); $args = array($form_container, $form, $item); $plugins->run_hooks("newpoints_shop_row", $args); $form_container->end(); $buttons = ""; $buttons[] = $form->generate_submit_button($lang->newpoints_shop_submit); $buttons[] = $form->generate_reset_button($lang->newpoints_shop_reset); $form->output_submit_wrapper($buttons); $form->end(); } else { if ($mybb->input['action'] == 'inventory') { $page->output_nav_tabs($sub_tabs, 'newpoints_shop_inventory'); $uid = (int) $mybb->input['uid']; if ($uid <= 0) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_user, 1); } $user = get_user($uid); // we're viewing someone else's inventory if (empty($user)) { newpoints_shop_messageredirect($lang->newpoints_shop_invalid_user, 1); } $inventory = @unserialize($user['newpoints_items']); if (!$inventory) { $inventory = array(0); } // Item id is 0 because it doesn't exist, this when we use it in the query we won't show anything // table $table = new Table(); $table->construct_header($lang->newpoints_shop_item_icon, array('width' => '10%', 'class' => 'align_center')); $table->construct_header($lang->newpoints_shop_item_name, array('width' => '30%')); $table->construct_header($lang->newpoints_shop_item_price, array('width' => '15%', 'class' => 'align_center')); $table->construct_header($lang->newpoints_shop_item_disporder, array('width' => '15%', 'class' => 'align_center')); $table->construct_header($lang->newpoints_shop_item_action, array('width' => '20%', 'class' => 'align_center')); $query = $db->simple_select('newpoints_shop_items', '*', 'iid IN (' . implode(',', array_unique($inventory)) . ')', array('order_by' => 'disporder', 'order_dir' => 'ASC')); while ($item = $db->fetch_array($query)) { if ($item['infinite'] == 1) { $item['stock'] = $lang->newpoints_shop_infinite; } if ($item['visible'] == 0) { $visible_info = ' (<span style="color: #FF0000;">hidden</span>)'; } else { $visible_info = ''; } $table->construct_cell(htmlspecialchars_uni($item['icon']) ? '<img src="' . $mybb->settings['bburl'] . '/' . $item['icon'] . '">' : '<img src="' . $mybb->settings['bburl'] . '/images/newpoints/default.png">', array('class' => 'align_center')); $table->construct_cell(htmlspecialchars_uni($item['name']) . " (" . count(array_keys($inventory, $item['iid'])) . ")" . $visible_info . "<br /><small>" . htmlspecialchars_uni($item['description']) . "</small>"); $table->construct_cell(newpoints_format_points($item['price']), array('class' => 'align_center')); $table->construct_cell(intval($item['disporder']), array('class' => 'align_center')); // actions column $table->construct_cell("<a href=\"index.php?module=newpoints-shop&action=remove&iid=" . intval($item['iid']) . "&uid=" . (int) $user['uid'] . "\">" . $lang->newpoints_shop_remove . "</a>", array('class' => 'align_center')); $table->construct_row(); } if ($table->num_rows() == 0) { $table->construct_cell($lang->newpoints_shop_no_items, array('colspan' => 5)); $table->construct_row(); } $table->output($lang->newpoints_shop_inventory_of . " " . htmlspecialchars_uni($user['username'])); } } } $page->output_footer(); exit; } }
} else { if ($mybb->request_method == 'post' && $mybb->get_input('action') == 'updatedisporder') { foreach ($mybb->get_input('disporder', 2) as $cid => $disporder) { $ougc_pages->update_category(array('disporder' => $disporder), $cid); } $ougc_pages->update_cache(); $ougc_pages->redirect(); } echo $multipage; $query = $db->simple_select('ougc_pages_categories', '*', '', array('limit_start' => $ougc_pages->query_start, 'limit' => $ougc_pages->query_limit, 'order_by' => 'disporder')); $form = new Form($ougc_pages->build_url('action=updatedisporder'), 'post'); while ($category = $db->fetch_array($query)) { $manage_link = $ougc_pages->build_url(array('manage' => 'pages', 'cid' => $category['cid'])); $category['name'] = htmlspecialchars_uni($category['name']); $category['visible'] or $category['name'] = '<em>' . $category['name'] . '</em>'; $table->construct_cell('<a href="' . $manage_link . '"><strong>' . $category['name'] . '</strong></a> <span style="font-size: 90%">(' . $ougc_pages->build_category_link($lang->ougc_pages_view_page, $category['cid']) . ')</span>'); $table->construct_cell($form->generate_text_box('disporder[' . $category['cid'] . ']', (int) $category['disporder'], array('style' => 'text-align: center; width: 30px;')), array('class' => 'align_center')); $table->construct_cell('<a href="' . $ougc_pages->build_url(array('action' => 'update', 'cid' => $category['cid'], 'my_post_key' => $mybb->post_code)) . '"><img src="styles/default/images/icons/bullet_o' . (!$category['visible'] ? 'ff' : 'n') . '.png" alt="" title="' . (!$category['visible'] ? $lang->ougc_pages_form_disabled : $lang->ougc_pages_form_visible) . '" /></a>', array('class' => 'align_center')); $popup = new PopupMenu('category_' . $category['cid'], $lang->options); $popup->add_item($lang->ougc_pages_manage, $manage_link); $popup->add_item($lang->edit, $ougc_pages->build_url(array('action' => 'edit', 'cid' => $category['cid']))); $popup->add_item($lang->delete, $ougc_pages->build_url(array('action' => 'delete', 'cid' => $category['cid']))); $table->construct_cell($popup->fetch(), array('class' => 'align_center')); $table->construct_row(); } $table->output($sub_tabs['ougc_pages_cat_view']['title']); $form->output_submit_wrapper(array($form->generate_submit_button($lang->ougc_pages_button_disponder), $form->generate_reset_button($lang->reset))); $form->end(); } $page->output_footer(); }