function delete() { global $gbl, $sgbl, $login, $ghtml; // Don't delete unless the parent is the real owner. Or the parent is admin. if (!$this->getParentO()->isAdmin() && !$this->isRightParent()) { return; } do_actionlog($login, $this, "delete", ""); $qlist = $this->getQuotaVariableList(); foreach ((array) $qlist as $k => $v) { if ($this->isHardQuota($k)) { $this->getParentO()->used->{$k} -= $this->priv->{$k}; } } if ($this->get__table() === 'ticket') { dprint(" <b> Ticket <br> <br> "); dprint($this->parent_clname . "<br> "); dprint($this->getParentO()->nname); } if (!$this->isDeleted()) { $this->dbaction = "delete"; } $this->deleteSpecific(); $this->execInChildren("d", "delete"); }
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()); }