Beispiel #1
0
function __cmd_desc_add($p, $parent = null)
{
    global $gbl, $sgbl, $login, $ghtml;
    if (!$parent) {
        if (isset($p['parent-class']) && isset($p['parent-name'])) {
            $parent = new $p['parent-class'](null, 'localhost', $p['parent-name']);
            dprint("{$parent->nname}\n");
            $parent->get();
            if ($parent->dbaction === 'add') {
                throw new lxException("parent_doesnt_exist", "nname", $p['parent-name']);
            }
            if (!$parent->checkIfSomeParent($login->getClName())) {
                throw new lxException("you_are_not_the_owner_of_parent", "", $p['parent-name']);
            }
        } else {
            $parent = $login;
        }
    }
    copy_nname_to_name($p);
    $class = $p['class'];
    $var = get_variable($p);
    if (isset($p['count'])) {
        $oldname = $p['name'];
        for ($i = 0; $i < $p['count']; $i++) {
            if ($class === 'domain') {
                $p['name'] = "{$oldname}{$i}.com";
            } else {
                $p['name'] = "{$oldname}{$i}";
            }
            $param = exec_class_method($class, "addCommand", $parent, $class, $p);
            unset($var['template-name']);
            $param = lx_array_merge(array($param, $var));
            do_desc_add($parent, $class, $param);
        }
        $parent->was();
        exit;
    }
    $param = exec_class_method($class, "addCommand", $parent, $class, $p);
    unset($var['template-name']);
    $param = lx_array_merge(array($param, $var));
    do_desc_add($parent, $class, $param);
    $parent->was();
}
function __ac_desc_add($object, $param = null)
{
    global $gbl, $sgbl, $login, $ghtml;
    $class = $ghtml->frm_o_cname;
    if ($login->isDemo()) {
        throw new lxException("cannot_add_in_demo", $pk);
    }
    if (!$param) {
        $param = $ghtml->createCurrentParam($class);
    }
    do_desc_add($object, $class, $param);
    if (!isset($gbl->__this_redirect)) {
        if (exec_class_method($class, "createListAlist", $object, $class)) {
            $gbl->__this_redirect = $ghtml->getFullUrl("a=list&c={$class}");
        } else {
            $gbl->__this_redirect = $ghtml->getFullUrl("a=show");
        }
    }
    $descr = get_description($class);
    $gbl->__this_redirect .= "&frm_smessage=added_successfully&frm_m_smessage_data={$descr}";
    if ($class === 'domain' || $class === 'client' || $class === 'vps') {
        $gbl->setSessionV('__refresh_lpanel', 'true');
    }
}