Alternc  latest
Alternc logiel libre pour l'h├ębergement
 All Classes Namespaces Files Functions Variables Pages
Alternc_Api_Legacyobject Class Reference

Any Legacy AlternC Api should use this class as a parent to be able to handle properly the access rights & error messages. More...

+ Inheritance diagram for Alternc_Api_Legacyobject:

Public Member Functions

 __construct ($service)
 

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

 $admin
 
 $cuid
 
 $isAdmin
 
 $db
 

Detailed Description

Any Legacy AlternC Api should use this class as a parent to be able to handle properly the access rights & error messages.

Author
benjamin

Definition at line 9 of file Legacyobject.php.

Constructor & Destructor Documentation

Alternc_Api_Legacyobject::__construct (   $service)

Definition at line 20 of file Legacyobject.php.

References $admin, $cuid, $isAdmin, and cuid.

20  {
21  global $admin, $cuid;
22  if (!($service instanceof Alternc_Api_Service)) {
23  throw new \Exception("Bad argument: service is not an Alternc_Api_Service", self::ERR_INVALID_ARGUMENT);
24  }
25  // We store the global $cuid to AlternC legacy classes
26  $this->db = $service->db;
27  $this->cuid = $cuid = $service->token->uid;
28  $this->isAdmin = $service->token->isAdmin;
29  // We use the global $admin from AlternC legacy classes
30  $this->admin = $admin;
31  // Set the legacy rights:
32  $this->admin->enabled = $this->isAdmin;
33  }
Service API used by server to export API methods this class can be used to implement an API service /...
Definition: Service.php:11
if($dryrun) print cuid
Definition: mail_add.php:94

Member Function Documentation

Alternc_Api_Legacyobject::alterncLegacyErrorManager ( )
protected

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.

References $err.

Referenced by Alternc_Api_Object_Mail\account(), Alternc_Api_Object_Account\add(), Alternc_Api_Object_Ftp\add(), Alternc_Api_Object_Mysql\add(), Alternc_Api_Object_Domain\add(), Alternc_Api_Object_Ssl\aliasAdd(), Alternc_Api_Object_Ssl\aliasDel(), Alternc_Api_Object_Policy\check(), Alternc_Api_Object_Mail\create(), Alternc_Api_Object_Ftp\del(), Alternc_Api_Object_Account\del(), Alternc_Api_Object_Mysql\del(), Alternc_Api_Object_Domain\del(), Alternc_Api_Object_Mail\delete(), Alternc_Api_Object_Mail\disable(), Alternc_Api_Object_Mail\enable(), Alternc_Api_Object_Ssl\finalize(), Alternc_Api_Object_Policy\find(), Alternc_Api_Object_Ftp\find(), Alternc_Api_Object_Account\find(), Alternc_Api_Object_Mysql\find(), Alternc_Api_Object_Subdomain\get(), Alternc_Api_Object_Domain\get(), Alternc_Api_Object_Mail\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(), Alternc_Api_Object_Subdomain\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_Policy\update(), Alternc_Api_Object_Ftp\update(), Alternc_Api_Object_Account\update(), Alternc_Api_Object_Mysql\update(), Alternc_Api_Object_Domain\update(), and Alternc_Api_Object_Mail\update().

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
Alternc_Api_Legacyobject::offsetAndCount (   $options,
  $max 
)
protected

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

Definition at line 45 of file Legacyobject.php.

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

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  }

Member Data Documentation

Alternc_Api_Legacyobject::$admin
protected

Definition at line 11 of file Legacyobject.php.

Referenced by __construct().

Alternc_Api_Legacyobject::$db
protected

Definition at line 14 of file Legacyobject.php.

Alternc_Api_Legacyobject::$isAdmin
protected

Definition at line 13 of file Legacyobject.php.

Referenced by __construct().

const Alternc_Api_Legacyobject::ERR_ALTERNC_FUNCTION = 111202

Definition at line 17 of file Legacyobject.php.

const Alternc_Api_Legacyobject::ERR_INVALID_ARGUMENT = 111201

Definition at line 16 of file Legacyobject.php.

const Alternc_Api_Legacyobject::ERR_NOT_FOUND = 111203

Definition at line 18 of file Legacyobject.php.


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