diff --git a/lib/Alternc/Api/Object/Account.php b/lib/Alternc/Api/Object/Account.php index 7d1e4713..8e5cffb1 100644 --- a/lib/Alternc/Api/Object/Account.php +++ b/lib/Alternc/Api/Object/Account.php @@ -5,7 +5,6 @@ */ class Alternc_Api_Object_Account extends Alternc_Api_Legacyobject { - /** API Method from legacy class method admin->add_mem() * @param $options a hash with parameters transmitted to legacy call * mandatory parameters: login, pass, nom, prenom, mail, diff --git a/lib/Alternc/Api/Object/Domain.php b/lib/Alternc/Api/Object/Domain.php index 1ec98367..307fc229 100644 --- a/lib/Alternc/Api/Object/Domain.php +++ b/lib/Alternc/Api/Object/Domain.php @@ -44,13 +44,45 @@ class Alternc_Api_Object_Domain extends Alternc_Api_Legacyobject { while ($me = $stmt->fetch(PDO::FETCH_OBJ)) { $result[$me->domaine] = $me; } - list($offset,$count)=$this->offsetAndCount($options, count($result)); + list($offset, $count) = $this->offsetAndCount($options, count($result)); if ($offset != -1 || $count != -1) { $result = array_slice($result, $offset, $count); } return new Alternc_Api_Response(array("content" => $result)); } + /** API Method from legacy class method dom->get_domain_all($dom) + * @param $options a hash with parameters transmitted to legacy call + * musr be the domain name $dom + * @return Alternc_Api_Response whose content is the list of domain info and subdomains + */ + function get($options) { + global $cuid; + if ($this->isAdmin) { + if (isset($options["uid"])) { + $cuid = intval($options["uid"]); + } + } + $mandatory = array("dom"); + $missing = ""; + foreach ($mandatory as $key) { + if (!isset($options[$key])) { + $missing.=$key . " "; + } + } + if ($missing) { + return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing)); + } + $this->dom->lock(); + $did = $this->dom->get_domain_all($options["dom"]); + $this->dom->unlock(); + if (!$did) { + return $this->alterncLegacyErrorManager(); + } else { + return new Alternc_Api_Response(array("content" => $did)); + } + } + /** API Method from legacy class method dom->add_domain() * @param $options a hash with parameters transmitted to legacy call * mandatory parameters: domain(str), dns(bool) diff --git a/lib/Alternc/Api/Object/Subdomain.php b/lib/Alternc/Api/Object/Subdomain.php new file mode 100644 index 00000000..cae60cd0 --- /dev/null +++ b/lib/Alternc/Api/Object/Subdomain.php @@ -0,0 +1,89 @@ +dom = $dom; + } + + /** API Method from legacy class method dom->get_sub_domain_all($dom) + * @param $options a hash with parameters transmitted to legacy call + * musr be the subdomain id ID + * @return Alternc_Api_Response whose content is the list of subdomains on this server + */ + function get($options) { + global $cuid; + if ($this->isAdmin) { + if (isset($options["uid"])) { + $cuid = intval($options["uid"]); + } + } + $mandatory = array("id"); + $missing = ""; + foreach ($mandatory as $key) { + if (!isset($options[$key])) { + $missing.=$key . " "; + } + } + if ($missing) { + return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing)); + } + $this->dom->lock(); + $did = $this->dom->get_sub_domain_all($options["id"]); + $this->dom->unlock(); + if (!$did) { + return $this->alterncLegacyErrorManager(); + } else { + return new Alternc_Api_Response(array("content" => $did)); + } + } + + /** API Method from legacy class method dom->set_sub_domain($dom) + * @param $options a hash with parameters transmitted to legacy call + * must be $dom, $sub, $type, $dest and could be $sub_domain_id + * @return Alternc_Api_Response whose content is true or false + * if the change has been made + */ + function set($options) { + global $cuid; + if ($this->isAdmin) { + if (isset($options["uid"])) { + $cuid = intval($options["uid"]); + } + } + $mandatory = array("dom", "sub", "type", "dest"); + $defaults = array("sub_domain_id" => null); + $missing = ""; + foreach ($mandatory as $key) { + if (!isset($options[$key])) { + $missing.=$key . " "; + } + } + foreach ($defaults as $key => $value) { + if (!isset($options[$key])) { + $options[$key] = $value; + } + } + if ($missing) { + return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing)); + } + $this->dom->lock(); + $did = $this->dom->set_sub_domain($options["dom"], $options["sub"], $options["type"], $options["dest"], $options["sub_domain_id"]); + $this->dom->unlock(); + if (!$did) { + return $this->alterncLegacyErrorManager(); + } else { + return new Alternc_Api_Response(array("content" => $did)); + } + } + +} + +// class Alternc_Api_Object_Subdomain