Alternc  latest
Alternc logiel libre pour l'hébergement
Alternc_Api_Object_Subdomain Class Reference

Subdomain Api of AlternC, used by alternc-api package. More...

+ Inheritance diagram for Alternc_Api_Object_Subdomain:

Public Member Functions

 __construct ($service)
 
 get ($options)
 API Method from legacy class method dom->get_sub_domain_all($dom) More...
 
 set ($options)
 API Method from legacy class method dom->set_sub_domain($dom) More...
 

Public Attributes

const ERR_INVALID_ARGUMENT = 111201
 
const ERR_ALTERNC_FUNCTION = 111202
 
const ERR_NOT_FOUND = 111203
 

Protected Member Functions

 alterncLegacyErrorManager ()
 return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class More...
 
 offsetAndCount ($options, $max)
 ensure that offset & count are set properly from $options. More...
 

Protected Attributes

 $dom
 
 $admin
 
 $cuid
 
 $isAdmin
 
 $db
 

Detailed Description

Subdomain Api of AlternC, used by alternc-api package.

Definition at line 6 of file Subdomain.php.

Constructor & Destructor Documentation

◆ __construct()

Alternc_Api_Object_Subdomain::__construct (   $service)

Reimplemented from Alternc_Api_Legacyobject.

Definition at line 10 of file Subdomain.php.

10  {
11  global $dom;
12  parent::__construct($service);
13  $this->dom = $dom;
14  }

References $dom.

Member Function Documentation

◆ alterncLegacyErrorManager()

Alternc_Api_Legacyobject::alterncLegacyErrorManager ( )
protectedinherited

return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class

Definition at line 38 of file Legacyobject.php.

38  {
39  global $err;
40  return new Alternc_Api_Response(array("code" => self::ERR_ALTERNC_FUNCTION, "message" => "[" . $err->clsid . "] " . $err->error));
41  }
$err
Definition: bootstrap.php:72
Standard Response object for the AlternC API.
Definition: Response.php:7

References $err.

Referenced by Alternc_Api_Object_Mail\account(), Alternc_Api_Object_Account\add(), Alternc_Api_Object_Domain\add(), Alternc_Api_Object_Ftp\add(), Alternc_Api_Object_Mysql\add(), Alternc_Api_Object_Ssl\aliasAdd(), Alternc_Api_Object_Ssl\aliasDel(), Alternc_Api_Object_Policy\check(), Alternc_Api_Object_Mail\create(), Alternc_Api_Object_Account\del(), Alternc_Api_Object_Domain\del(), Alternc_Api_Object_Ftp\del(), Alternc_Api_Object_Mysql\del(), Alternc_Api_Object_Mail\delete(), Alternc_Api_Object_Mail\disable(), Alternc_Api_Object_Mail\enable(), Alternc_Api_Object_Ssl\finalize(), Alternc_Api_Object_Account\find(), Alternc_Api_Object_Ftp\find(), Alternc_Api_Object_Mysql\find(), Alternc_Api_Object_Policy\find(), Alternc_Api_Object_Domain\get(), Alternc_Api_Object_Mail\get(), get(), Alternc_Api_Object_Mail\getAll(), Alternc_Api_Object_Ssl\getCertificate(), Alternc_Api_Object_Ssl\importCert(), Alternc_Api_Object_Mail\isAvailable(), Alternc_Api_Object_Ftp\isFtp(), Alternc_Api_Object_Mail\listDomains(), Alternc_Api_Object_Account\lock(), Alternc_Api_Object_Mysql\lock(), Alternc_Api_Object_Ssl\newCsr(), Alternc_Api_Object_Mail\passwd(), set(), Alternc_Api_Object_Account\setAdmin(), Alternc_Api_Object_Mysql\setAdmin(), Alternc_Api_Object_Ssl\share(), Alternc_Api_Object_Mail\undelete(), Alternc_Api_Object_Account\unlock(), Alternc_Api_Object_Mysql\unlock(), Alternc_Api_Object_Account\unsetAdmin(), Alternc_Api_Object_Mysql\unsetAdmin(), Alternc_Api_Object_Account\update(), Alternc_Api_Object_Domain\update(), Alternc_Api_Object_Ftp\update(), Alternc_Api_Object_Mail\update(), Alternc_Api_Object_Mysql\update(), and Alternc_Api_Object_Policy\update().

◆ get()

Alternc_Api_Object_Subdomain::get (   $options)

API Method from legacy class method dom->get_sub_domain_all($dom)

Parameters
$optionsa hash with parameters transmitted to legacy call musr be the subdomain id ID
Returns
Alternc_Api_Response whose content is the list of subdomains on this server

Definition at line 21 of file Subdomain.php.

21  {
22  global $cuid;
23  if ($this->isAdmin) {
24  if (isset($options["uid"])) {
25  $cuid = intval($options["uid"]);
26  }
27  }
28  $mandatory = array("id");
29  $missing = "";
30  foreach ($mandatory as $key) {
31  if (!isset($options[$key])) {
32  $missing.=$key . " ";
33  }
34  }
35  if ($missing) {
36  return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
37  }
38  $this->dom->lock();
39  $did = $this->dom->get_sub_domain_all($options["id"]);
40  $this->dom->unlock();
41  if (!$did) {
42  return $this->alterncLegacyErrorManager();
43  } else {
44  return new Alternc_Api_Response(array("content" => $did));
45  }
46  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class
if(empty($_POST['key'])||empty($_POST['val'])) $key
Definition: tempovars.php:14

References Alternc_Api_Legacyobject\$cuid, $key, and Alternc_Api_Legacyobject\alterncLegacyErrorManager().

◆ offsetAndCount()

Alternc_Api_Legacyobject::offsetAndCount (   $options,
  $max 
)
protectedinherited

ensure that offset & count are set properly from $options.

Definition at line 45 of file Legacyobject.php.

45  {
46  $offset = -1;
47  $count = -1;
48  if (isset($options["count"]))
49  $count = intval($options["count"]);
50  if (isset($options["offset"]))
51  $offset = intval($options["offset"]);
52  if ($offset != -1 || $count != -1) {
53  if ($offset < 0 || $offset > $max)
54  $offset = 0;
55  if ($count < 0 || $count > 1000)
56  $count = 1000;
57  }
58  return array($offset, $count);
59  }

Referenced by Alternc_Api_Object_Account\find(), Alternc_Api_Object_Domain\find(), Alternc_Api_Object_Ftp\find(), and Alternc_Api_Object_Mysql\find().

◆ set()

Alternc_Api_Object_Subdomain::set (   $options)

API Method from legacy class method dom->set_sub_domain($dom)

Parameters
$optionsa hash with parameters transmitted to legacy call must be $dom, $sub, $type, $dest and could be $sub_domain_id
Returns
Alternc_Api_Response whose content is true or false if the change has been made

Definition at line 54 of file Subdomain.php.

54  {
55  global $cuid;
56  if ($this->isAdmin) {
57  if (isset($options["uid"])) {
58  $cuid = intval($options["uid"]);
59  }
60  }
61  $mandatory = array("dom", "sub", "type", "dest");
62  $defaults = array("sub_domain_id" => null);
63  $missing = "";
64  foreach ($mandatory as $key) {
65  if (!isset($options[$key])) {
66  $missing.=$key . " ";
67  }
68  }
69  foreach ($defaults as $key => $value) {
70  if (!isset($options[$key])) {
71  $options[$key] = $value;
72  }
73  }
74  if ($missing) {
75  return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
76  }
77  $this->dom->lock();
78  $did = $this->dom->set_sub_domain($options["dom"], $options["sub"], $options["type"], $options["dest"], $options["sub_domain_id"]);
79  $this->dom->unlock();
80  if (!$did) {
81  return $this->alterncLegacyErrorManager();
82  } else {
83  return new Alternc_Api_Response(array("content" => $did));
84  }
85  }
$value

References Alternc_Api_Legacyobject\$cuid, $key, $value, and Alternc_Api_Legacyobject\alterncLegacyErrorManager().

Member Data Documentation

◆ $admin

Alternc_Api_Legacyobject::$admin
protectedinherited

Definition at line 11 of file Legacyobject.php.

Referenced by Alternc_Api_Legacyobject\__construct().

◆ $cuid

◆ $db

Alternc_Api_Legacyobject::$db
protectedinherited

Definition at line 14 of file Legacyobject.php.

◆ $dom

Alternc_Api_Object_Subdomain::$dom
protected

Definition at line 8 of file Subdomain.php.

Referenced by __construct().

◆ $isAdmin

Alternc_Api_Legacyobject::$isAdmin
protectedinherited

Definition at line 13 of file Legacyobject.php.

Referenced by Alternc_Api_Legacyobject\__construct().

◆ ERR_ALTERNC_FUNCTION

const Alternc_Api_Legacyobject::ERR_ALTERNC_FUNCTION = 111202
inherited

Definition at line 17 of file Legacyobject.php.

◆ ERR_INVALID_ARGUMENT

const Alternc_Api_Legacyobject::ERR_INVALID_ARGUMENT = 111201
inherited

Definition at line 16 of file Legacyobject.php.

◆ ERR_NOT_FOUND

const Alternc_Api_Legacyobject::ERR_NOT_FOUND = 111203
inherited

Definition at line 18 of file Legacyobject.php.


The documentation for this class was generated from the following file: