Example #1
0
 function getSpecialObject($class)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!$this->isLxclient()) {
         dprint("Special object called in nonclient {$this->get__table()}:{$this->nname}<br> \n");
         //debugBacktrace();
     }
     $objectname = $class . "_o";
     // Don't ever call get_classvar_description from here. That will create an infinite loop.
     $name = get_real_class_variable($class, "__special_class");
     if (!$name) {
         $name = strfrom($class, "sp_");
     }
     $bname = $name . "_b";
     if (isset($this->{$objectname})) {
         return $this->{$objectname}->{$bname};
     }
     $obj = new $class($this->__masterserver, null, $this->getClName());
     $obj->get();
     //$this->addObject($class, $obj);
     $this->{$objectname} = $obj;
     $obj->{$bname}->__parent_o = $this;
     return $obj->{$bname};
 }
Example #2
0
function get_classvar_description($class, $var = null)
{
    global $gbl, $sgbl, $login, $ghtml;
    global $g_language_desc;
    global $g_language_mes;
    //$var = fix_nname_to_be_variable($var);
    if (csb($var, "__")) {
        $dvar = $var;
    } else {
        if ($var) {
            $dvar = "__desc_{$var}";
        } else {
            $dvar = "__desc";
        }
    }
    $rvar = strfrom($dvar, "__desc_");
    $rvar = strfrom($rvar, "__acdesc_");
    $class = strtolower($class);
    $ret = get_real_class_variable($class, $dvar);
    if (!$ret) {
        return null;
    }
    $ret['help'] = $ret[2];
    if (cse($dvar, "_o") || cse($dvar, "_l")) {
        return $ret;
    }
    if (!$g_language_desc) {
        return $ret;
    }
    /*
    	 if ($login->getSpecialObject('sp_specialplay')->isCoreLanguage()) {
    		 return $ret;
    	 }
    */
    $k = trim($ret[2], "_\n ");
    if (isset($g_language_desc->__description[$k])) {
        $ret[2] = $g_language_desc->__description[$k][0];
        if (isset($g_language_mes->__helpvar[$rvar])) {
            $ret['help'] = $g_language_mes->__helpvar[$rvar];
        } else {
            if (isset($g_language_mes->__help[$dvar])) {
                $ret['help'] = $g_language_desc->__help[$k];
            } else {
                $ret['help'] = $ret[2];
            }
        }
    }
    return $ret;
}
function do_desc_add($object, $class, $param)
{
    global $gbl, $sgbl, $login, $ghtml;
    $quotaclass = exec_class_method($class, "getquotaclass", $class);
    $numvar = "{$quotaclass}_num";
    $qobject = $object->getClientParentO();
    dprint($qobject->getClname());
    if ($qobject->isQuotaVariable($numvar)) {
        if (isQuotaGreaterThanOrEq($qobject->used->{$numvar}, $qobject->priv->{$numvar})) {
            throw new lxException("Quota Exceeded for {$class}", 'nname', $numvar);
        }
    }
    /*
    	$list = $qobject->getQuotaVariableList();
    	foreach((array) $list as $l => $v) {
    		if (csb($l, "{$class}_m_")) {
    			$license = strtil(strfrom($l, "_n_"), "_num");
    			$licvar = strtil(strfrom($l, "_m_"), "_n_");
    			if (isset($param[$licvar]) && $param[$licvar] === $license) {
    				if (isQuotaGreaterThanOrEq($qobject->used->$l, $qobject->priv->$l)) {
    					throw new lxException("Quota Exceeded for $class $licvar.$license", 'nname', $numvar);
    				}
    			}
    		}
    	}
    */
    // Setting it here itself so that the add can override if necessary. This is done in tickets, where the parent is always the admin.
    $param['parent_clname'] = $object->getClName();
    // In the case of mailaccount, the real parent is mmail, while the object is added to client.
    if (isset($param['real_clparent_f'])) {
        $parent_class = exec_class_method($class, 'defaultParentClass', $object);
        $param['parent_clname'] = createParentName($parent_class, $param['real_clparent_f']);
    }
    $param = exec_class_method($class, 'Add', $object, $class, $param);
    // First loop to create a unique nname if applicable.... FOr the 'unique-nname-creation' to work in the second loop, the variables must be resolved before that... So this extra looping...
    foreach ($param as $k => $v) {
        if (csb($k, "__v_") || csb($k, "__m_")) {
            continue;
        }
        $object->resolve_class_differences($class, $k, $dclass, $dk);
    }
    foreach ($param as $k => $v) {
        if (csb($k, "__v_") || csb($k, "__m_")) {
            continue;
        }
        $object->resolve_class_heirarchy($class, $k, $dclass, $dk);
        $object->resolve_class_differences($class, $k, $ddclass, $ddk);
        $nnamevar = get_real_class_variable($ddclass, "__rewrite_nname_const");
        if ($nnamevar) {
            $nnamelist = null;
            foreach ($nnamevar as $n) {
                $nnamelist[] = $param[$n];
            }
            $nparam[$dclass]['nname'] = implode($sgbl->__var_nname_impstr, $nnamelist);
        }
        $nparam[$dclass][$dk] = $v;
    }
    // First Pass
    foreach ($nparam as $k => $v) {
        if (csa($k, "_s_")) {
            continue;
        }
        if ($k === 'priv') {
            $olist[$k] = new priv(null, null, $nparam[$class]['nname']);
            check_priv($object, $class, $olist[$k], $v);
            continue;
        }
        if ($k === 'used') {
            $olist[$k] = new Used(null, null, $nparam[$class]['nname']);
            $olist[$k]->create($v);
            continue;
        }
        if ($k === 'listpriv') {
            //$olist[$k] = new listpriv($object->__masterserver, null, $class . "_s_vv_p_" . $nparam[$class]['nname']);
            $olist[$k] = new listpriv($object->__masterserver, null, $class . "-" . $nparam[$class]['nname']);
            check_listpriv($object, $class, $olist[$k], $v);
            continue;
        }
        if (csa($k, "_b")) {
            $olist[$k] = new $k($object->__masterserver, null, $nparam[$class]['nname']);
        } else {
            $olist[$k] = new $k($object->__masterserver, null, $v['nname']);
        }
        $olist[$k]->inheritSyncServer($object);
        $olist[$k]->initThisDef();
        $olist[$k]->create($v);
        // The createsyncclass needs the syncserver variable to be set. Which may not be available. So we have to run this again.
        if ($olist[$k]->hasDriverClass()) {
            $olist[$k]->createSyncClass();
        }
    }
    // The main object has to inherit the masterserver here itself, so that its children will inherit it later when they are added through addobject.
    if (!cse($class, "_a") && exec_class_method($class, "isDatabase") && exists_in_db($object->__masterserver, $class, $olist[$class]->nname)) {
        // If the parent is getting added too, then that means we are in the client add page, and thus the variable is vps_name, domain_name rather than nname.
        if ($object->dbaction === 'add') {
            $vname = "{$class}_name";
        } else {
            $vname = "nname";
        }
        throw new lxException("{$olist[$class]->nname}+already+exists+in+{$class}.", $vname, $class);
    }
    //Second Pass...
    foreach ($nparam as $k => $v) {
        if (!csa($k, "_s_") && !csa($k, "-")) {
            continue;
        }
        $clist = explode("_s_", $k);
        $k = $clist[1];
        $cl = $clist[0];
        $nolist[$k] = new $k($object->__masterserver, null, $v['nname']);
        $nolist[$k]->inheritSyncServer($olist[$cl]);
        $nolist[$k]->initThisDef();
        $nolist[$k]->create($v);
        // The createsyncclass needs the syncserver variable to be set. Which may not be available. So we have to run this again.
        if ($nolist[$k]->hasDriverClass()) {
            $nolist[$k]->createSyncClass();
        }
        $olist[$cl]->addObject($k, $nolist[$k]);
    }
    foreach ($olist as $k => $v) {
        if (cse($k, "_b") || $k === 'used' || $k === 'priv' || $k === 'listpriv') {
            $olist[$class]->{$k} = $v;
            continue;
        }
        if ($k != $class) {
            $olist[$class]->addObject($k, $v);
            continue;
        }
    }
    if (isset($param['__v_priv'])) {
        $olist[$class]->priv = $param['__v_priv'];
    }
    if (isset($param['__v_listpriv'])) {
        $olist[$class]->listpriv = $param['__v_listpriv'];
    }
    //$olist[$class]->parent_clname = $object->getClName();
    $rparent = $object;
    $olist[$class]->__parent_o = $rparent;
    $olist[$class]->postAdd();
    $rparent->addToList($class, $olist[$class]);
    $olist[$class]->superPostAdd();
    //dprintr($object);
    notify_admin("add", $object, $olist[$class]);
    do_actionlog($login, $olist[$class], "add", "");
    //This shouldn't happen here. This should be done only after the synctosystem since, the sync can fail and the write may not happen at all.
    //$olist[$class]->changeUsedFromParentAll();
    dprint($olist[$class]->getParentO());
}