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

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

+ Inheritance diagram for Alternc_Api_Object_Ftp:

Public Member Functions

 __construct ($service)
 
 add ($options)
 API Method from legacy class method ftp->add_ftp() More...
 
 update ($options)
 API Method from legacy class method ftp->put_ftp_details() More...
 
 del ($options)
 API Method from legacy class method ftp->del_ftp() More...
 
 find ($options)
 API Method from legacy class method ftp->get_list() More...
 
 isFtp ($options)
 API Method from legacy class method ftp->is_ftp() 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

 $ftp
 
 $admin
 
 $cuid
 
 $isAdmin
 
 $db
 

Detailed Description

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

Definition at line 6 of file Ftp.php.

Constructor & Destructor Documentation

Alternc_Api_Object_Ftp::__construct (   $service)

Definition at line 10 of file Ftp.php.

References $ftp.

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

Member Function Documentation

Alternc_Api_Object_Ftp::add (   $options)

API Method from legacy class method ftp->add_ftp()

Parameters
$optionsa hash with parameters transmitted to legacy call mandatory parameters: prefix, login, pass, dir
Returns
Alternc_Api_Response whose content is the newly created UID

Definition at line 21 of file Ftp.php.

References $key, and Alternc_Api_Legacyobject\alterncLegacyErrorManager().

21  {
22  $mandatory = array("prefix", "login", "pass", "dir");
23  $missing = "";
24  foreach ($mandatory as $key) {
25  if (!isset($options[$key])) {
26  $missing.=$key . " ";
27  }
28  }
29  if ($missing) {
30  return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
31  }
32  $ftpid = $this->ftp->add_ftp($options["prefix"], $options["login"], $options["pass"], $options["dir"]);
33  if (!$ftpid) {
34  return $this->alterncLegacyErrorManager();
35  } else {
36  return new Alternc_Api_Response(array("content" => $ftpid));
37  }
38  }
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
Standard Response object for the AlternC API.
Definition: Response.php:7
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.

References $err.

Referenced by Alternc_Api_Object_Mail\account(), Alternc_Api_Object_Account\add(), 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(), 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(), 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(), 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(), 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_Object_Ftp::del (   $options)

API Method from legacy class method ftp->del_ftp()

Parameters
$optionsa hash with parameters transmitted to legacy call mandatory parameters: id
Returns
Alternc_Api_Response TRUE if the FTP account has been deleted.

Definition at line 76 of file Ftp.php.

References Alternc_Api_Legacyobject\alterncLegacyErrorManager().

76  {
77  if (!isset($options["id"])) {
78  return new Alternc_Api_Response(array("code" => self::ERR_ALTERNC_FUNCTION, "message" => "Missing or invalid argument: ID"));
79  }
80  $result = $this->ftp->delete_ftp(intval($options["id"]));
81  if (!$result) {
82  return $this->alterncLegacyErrorManager();
83  } else {
84  return new Alternc_Api_Response(array("content" => true));
85  }
86  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class ...
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Object_Ftp::find (   $options)

API Method from legacy class method ftp->get_list()

Parameters
$optionsa hash with parameters transmitted to legacy call non-mandatory parameters: Any of: offset(int=0), count(int=+inf)
Returns
Alternc_Api_Response An array with all matching FTP account informations as hashes

Definition at line 94 of file Ftp.php.

References Alternc_Api_Legacyobject\alterncLegacyErrorManager(), and Alternc_Api_Legacyobject\offsetAndCount().

94  {
95  $result = $this->ftp->get_list();
96  if (!$result) {
97  return $this->alterncLegacyErrorManager();
98  } else {
99  list($offset, $count) = $this->offsetAndCount($options, count($result));
100  if ($offset != -1 || $count != -1) {
101  $result = array_slice($result, $offset, $count);
102  }
103  return new Alternc_Api_Response(array("content" => $result));
104  }
105  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class ...
offsetAndCount($options, $max)
ensure that offset & count are set properly from $options.
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Object_Ftp::isFtp (   $options)

API Method from legacy class method ftp->is_ftp()

Parameters
$optionsa hash with parameters transmitted to legacy call mandatory parameters: DIR
Returns
Alternc_Api_Response Integer the ID of the account in this folder, or FALSE

Definition at line 112 of file Ftp.php.

References Alternc_Api_Legacyobject\alterncLegacyErrorManager().

112  {
113  if (!isset($options["dir"])) {
114  return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: DIR"));
115  }
116  $result = $this->ftp->is_ftp($options["dir"]);
117  if (!$result) {
118  return $this->alterncLegacyErrorManager();
119  } else {
120  return new Alternc_Api_Response(array("content" => $result));
121  }
122  }
alterncLegacyErrorManager()
return a proper Alternc_Api_Response from an error class and error string from AlternC legacy class ...
Standard Response object for the AlternC API.
Definition: Response.php:7
Alternc_Api_Legacyobject::offsetAndCount (   $options,
  $max 
)
protectedinherited

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

Definition at line 45 of file Legacyobject.php.

Referenced by Alternc_Api_Object_Domain\find(), 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  }
Alternc_Api_Object_Ftp::update (   $options)

API Method from legacy class method ftp->put_ftp_details()

Parameters
$optionsa hash with parameters transmitted to legacy call mandatory parameters: id non-mandatory: prefix, login, pass, dir
Returns
Alternc_Api_Response whose content is the updated UID

Definition at line 46 of file Ftp.php.

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

46  {
47  $defaults = array("prefix", "login", "dir");
48  if (!isset($options["id"])) {
49  return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: ID"));
50  }
51  $id = intval($options["id"]);
52  $old = $this->ftp->get_ftp_details($id);
53  if (!$old) {
54  return new Alternc_Api_Response(array("code" => self::ERR_NOT_FOUND, "message" => "FTP Account not found"));
55  }
56  foreach ($defaults as $key) {
57  if (!isset($options[$key])) {
58  $options[$key] = $old[$key];
59  }
60  }
61  if (!isset($options["pass"]))
62  $options["pass"] = "";
63  $result = $this->ftp->put_ftp_details($id, $options["prefix"], $options["login"], $options["pass"], $options["dir"]);
64  if (!$result) {
65  return $this->alterncLegacyErrorManager();
66  } else {
67  return new Alternc_Api_Response(array("content" => $result));
68  }
69  }
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
if(!isset($is_include)) if(!$key &&!$crt) $id
Standard Response object for the AlternC API.
Definition: Response.php:7

Member Data Documentation

Alternc_Api_Legacyobject::$admin
protectedinherited

Definition at line 11 of file Legacyobject.php.

Referenced by Alternc_Api_Legacyobject\__construct().

Alternc_Api_Legacyobject::$db
protectedinherited

Definition at line 14 of file Legacyobject.php.

Alternc_Api_Object_Ftp::$ftp
protected

Definition at line 8 of file Ftp.php.

Referenced by __construct().

Alternc_Api_Legacyobject::$isAdmin
protectedinherited

Definition at line 13 of file Legacyobject.php.

Referenced by Alternc_Api_Legacyobject\__construct().

const Alternc_Api_Legacyobject::ERR_ALTERNC_FUNCTION = 111202
inherited

Definition at line 17 of file Legacyobject.php.

const Alternc_Api_Legacyobject::ERR_INVALID_ARGUMENT = 111201
inherited

Definition at line 16 of file Legacyobject.php.

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: