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

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

+ Inheritance diagram for Alternc_Api_Object_Policy:

Public Member Functions

 update ($options)
 API Method from legacy class method admin->editPolicy($policy,$minsize,$maxsize,$classcount,$allowlogin) More...
 
 find ($options)
 API Method from legacy class method admin->listPasswordPolicies() More...
 
 check ($options)
 API Method from legacy class method admin->checkPolicy($policy,$login,$password) 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

 $admin
 
 $cuid
 
 $isAdmin
 
 $db
 

Detailed Description

Passowrd Policy Api of AlternC, used by alternc-api package.

Definition at line 6 of file Policy.php.

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(), 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(), find(), Alternc_Api_Object_Domain\get(), Alternc_Api_Object_Mail\get(), Alternc_Api_Object_Subdomain\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_Account\update(), Alternc_Api_Object_Domain\update(), Alternc_Api_Object_Ftp\update(), Alternc_Api_Object_Mail\update(), Alternc_Api_Object_Mysql\update(), and update().

◆ check()

Alternc_Api_Object_Policy::check (   $options)

API Method from legacy class method admin->checkPolicy($policy,$login,$password)

Parameters
$optionsa hash with parameters transmitted to legacy call mandatory parameters: policy login password
Returns
Alternc_Api_Response TRUE if the password match the policy

Definition at line 52 of file Policy.php.

52  {
53  $mandatory = array("policy", "login", "password");
54  $missing = "";
55  foreach ($mandatory as $key) {
56  if (!isset($options[$key])) {
57  $missing.=$key . " ";
58  }
59  }
60  if ($missing) {
61  return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
62  }
63  $result = $this->admin->checkPolicy($options["policy"], $options["login"], $options["password"]);
64  if (!$result) {
65  return $this->alterncLegacyErrorManager();
66  } else {
67  return new Alternc_Api_Response(array("content" => true));
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

References $key, and Alternc_Api_Legacyobject\alterncLegacyErrorManager().

◆ find()

Alternc_Api_Object_Policy::find (   $options)

API Method from legacy class method admin->listPasswordPolicies()

Parameters
$optionsa hash with parameters transmitted to legacy call no options is used.
Returns
Alternc_Api_Response An array with all password policies

Definition at line 37 of file Policy.php.

37  {
38  $result = $this->admin->listPasswordPolicies();
39 
40  if (!$result) {
41  return $this->alterncLegacyErrorManager();
42  } else {
43  return new Alternc_Api_Response(array("content" => $result));
44  }
45  }

References 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().

◆ update()

Alternc_Api_Object_Policy::update (   $options)

API Method from legacy class method admin->editPolicy($policy,$minsize,$maxsize,$classcount,$allowlogin)

Parameters
$optionsa hash with parameters transmitted to legacy call mandatory parameters: policy minsize maxsize classcount allowlogin
Returns
Alternc_Api_Response TRUE if the password policy has been updated

Definition at line 13 of file Policy.php.

13  {
14  $mandatory = array("policy", "minsize", "maxsize", "classcount", "allowlogin");
15  $missing = "";
16  foreach ($mandatory as $key) {
17  if (!isset($options[$key])) {
18  $missing.=$key . " ";
19  }
20  }
21  if ($missing) {
22  return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
23  }
24  $result = $this->admin->editPolicy($options["policy"], $options["minsize"], $options["maxsize"], $options["classcount"], $options["allowlogin"]);
25  if (!$result) {
26  return $this->alterncLegacyErrorManager();
27  } else {
28  return new Alternc_Api_Response(array("content" => true));
29  }
30  }

References $key, 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.

◆ $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: