Ejemplo n.º 1
0
/**
* Save the item(s) to the menu selected
*/
function moveMenuSave($option, $cid, $menu, $menutype)
{
    global $database, $my;
    // add all decendants to the list
    foreach ($cid as $id) {
        addDescendants($id, $cid);
    }
    $row = new mosMenu($database);
    $ordering = 1000000;
    $firstroot = 0;
    foreach ($cid as $id) {
        $row->load($id);
        // is it moved together with his parent?
        $found = false;
        if ($row->parent != 0) {
            foreach ($cid as $idx) {
                if ($idx == $row->parent) {
                    $found = true;
                    break;
                }
            }
        }
        // if
        if (!$found) {
            $row->parent = 0;
            $row->ordering = $ordering++;
            if (!$firstroot) {
                $firstroot = $row->id;
            }
        }
        // if
        $row->menutype = $menu;
        if (!$row->store()) {
            echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        // if
    }
    // foreach
    if ($firstroot) {
        $row->load($firstroot);
        $row->updateOrder("menutype='" . $row->menutype . "' AND parent='" . $row->parent . "'");
    }
    // if
    $msg = sprintf(Tn_('%d Menu Item moved to %s', '%d Menu Items moved to %s', count($cid)), count($cid), $menu);
    mosRedirect('index2.php?option=' . $option . '&menutype=' . $menutype . '&mosmsg=' . $msg);
}
Ejemplo n.º 2
0
/**
* Save the item(s) to the menu selected
*/
function moveMenuSave($option, $cid, $menu, $menutype)
{
    global $database;
    // add all decendants to the list
    foreach ($cid as $id) {
        addDescendants($id, $cid);
    }
    $row = new mosMenu($database);
    $ordering = 1000000;
    $firstroot = 0;
    foreach ($cid as $id) {
        $row->load($id);
        // is it moved together with his parent?
        $found = false;
        if ($row->parent != 0) {
            foreach ($cid as $idx) {
                if ($idx == $row->parent) {
                    $found = true;
                    break;
                }
            }
        }
        // if
        if (!$found) {
            $row->parent = 0;
            $row->ordering = $ordering++;
            if (!$firstroot) {
                $firstroot = $row->id;
            }
        }
        // if
        $row->menutype = $menu;
        if (!$row->store()) {
            echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        // if
    }
    // foreach
    if ($firstroot) {
        $row->load($firstroot);
        $row->updateOrder('menutype = ' . $database->Quote($row->menutype) . ' AND parent = ' . (int) $row->parent);
    }
    // if
    // clean any existing cache files
    mosCache::cleanCache('com_content');
    $msg = count($cid) . ' Itens de menu movidos para' . $menu;
    mosRedirect('index2.php?option=' . $option . '&menutype=' . $menutype . '&mosmsg=' . $msg);
}