Exemplo n.º 1
0
<?php

include_once '../common/include-file.php';
$id = '';
if (isset($_POST['gid']) && $_POST['gid'] != '') {
    $id = $_POST['gid'];
    $menuGroup = new AccountMenuGroup();
    $data = array('id' => $id, 'name' => $_POST['name']);
    $menuGroup->updateById($data);
} else {
    $menuGroup = new AccountMenuGroup();
    $data = array('name' => $_POST['name']);
    $id = $menuGroup->insert($data);
}
header("Location:" . $CONTEXT_PATH . "/wxcms/menuList.php?gid=" . $id);
Exemplo n.º 2
0
include_once '../common/include-file.php';
include_once '../wxapi/wxconsts.php';
include_once '../wxapi/WxApi.class.php';
$wxAccount = new Account();
$wxAccount = $wxAccount->getSingleAccount();
$appId = $wxAccount['appid'];
$appSecret = $wxAccount['appsecret'];
$gid = $_GET['gid'];
$accountMenu = new AccountMenu();
$sql = ' select * from t_wxcms_account_menu where gid = ' . $gid . ' order by parentId , sort ';
$querySet = $accountMenu->queryBySql($sql);
$menuStr = prepareMenu($querySet);
$rst = WxApi::create_menu($appId, $appSecret, $menuStr);
if ($rst->errcode == 0) {
    $wxAccountGroup = new AccountMenuGroup();
    $wxAccountGroup->updateById(array("id" => $gid, "enable" => 1));
    header("Location:" . $CONTEXT_PATH . "/wxcms/success.php?type=1");
} else {
    header("Location:" . $CONTEXT_PATH . "/wxcms/failure.php?type=1&errcode=" . $rst->errcode);
}
function prepareMenu($querySet)
{
    $menuArr = array();
    $subMenuArr = array();
    foreach ($querySet as $item) {
        if ($item['parentId'] == 0) {
            array_push($menuArr, $item);
        } else {
            if (empty($subMenuArr[$item['parentId']])) {
                $subMenuArr[$item['parentId']] = array(getMenuJson($item));
            } else {