Initial commit
This commit is contained in:
73
playarea/plugins/bive-admin-panel/scripts/wingman.php
Normal file
73
playarea/plugins/bive-admin-panel/scripts/wingman.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
$b->router_add("/wingman/load_submenu_search/", "wingman_load_submenu_search", array("post"));
|
||||
|
||||
function wingman_load_submenu_search()
|
||||
{
|
||||
global $b;
|
||||
$search = $_POST["search"];
|
||||
$admin_page = $_POST["page"];
|
||||
|
||||
$pages = $b->admin_pages;
|
||||
$active_submenu = false;
|
||||
|
||||
foreach ($pages as $key => $value) {
|
||||
if($value["hide"]) continue;
|
||||
if($b->admin_page_has_child($key, $admin_page))
|
||||
$active_submenu = $value;
|
||||
}
|
||||
|
||||
if($active_submenu !== false) {
|
||||
$b->template_load("bive-admin-panel/template/menu/nav_subpage.php", array(
|
||||
"active_submenu" => $active_submenu,
|
||||
"open_child"=> true,
|
||||
"admin_page" => $admin_page,
|
||||
"search" => $search
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$b->router_add("/wingman/favorite_add_page/", "wingman_favorite_add_page", array("post"));
|
||||
|
||||
function wingman_favorite_add_page()
|
||||
{
|
||||
global $b;
|
||||
$user_id = $b->session_get("user_id");
|
||||
if(!$user_id) exit(json_encode(array("ok" => false)));
|
||||
|
||||
$link_url = $_POST["link"];
|
||||
$link_name = $_POST["name"];
|
||||
|
||||
$favorite = new Favorite(0);
|
||||
$favorite->create($link_name, "");
|
||||
$favorite->set_prop("user_id", $user_id);
|
||||
$favorite->set_prop("link", $link_url);
|
||||
|
||||
exit(json_encode(array("ok" => true)));
|
||||
}
|
||||
|
||||
$b->router_add("/wingman/favorite_remove_page/", "wingman_favorite_remove_page", array("post"));
|
||||
|
||||
function wingman_favorite_remove_page()
|
||||
{
|
||||
global $b;
|
||||
$user_id = $b->session_get("user_id");
|
||||
if(!$user_id) exit(json_encode(array("ok" => false)));
|
||||
|
||||
$link_url = $_POST["link"];
|
||||
$search = new Search(array(
|
||||
"class" => "Favorite",
|
||||
"props" => array(
|
||||
"user_id" => $user_id,
|
||||
"link" => $link_url
|
||||
)
|
||||
));
|
||||
|
||||
$favorites = $search->collect();
|
||||
|
||||
foreach ($favorites as $key => $item) {
|
||||
$item->delete();
|
||||
}
|
||||
|
||||
exit(json_encode(array("ok" => true)));
|
||||
}
|
||||
Reference in New Issue
Block a user