12 parent::__construct($service);
22 function add($options) {
23 $mandatory = array(
"login",
"pass",
"nom",
"prenom",
"mail");
24 $defaults = array(
"canpass" => 1,
"type" =>
"default",
"duration" => 0,
"notes" =>
"",
"force" => 0,
"create_dom" =>
"");
26 foreach ($mandatory as
$key) {
27 if (!isset($options[
$key])) {
32 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
35 if (!isset($options[
$key])) {
39 if (!isset($options[
"db_server_id"])) {
40 $stmt = $this->db->prepare(
"SELECT MIN(db_servers.id) AS id FROM db_servers;");
42 $me = $stmt->fetch(PDO::FETCH_OBJ);
43 $options[
"db_server_id"] = $me->id;
45 $uid = $this->admin->add_mem($options[
"login"], $options[
"pass"], $options[
"nom"], $options[
"prenom"], $options[
"mail"], $options[
"canpass"], $options[
"type"], $options[
"duration"], $options[
"notes"], $options[
"force"], $options[
"create_dom"], $options[
"db_server_id"]);
60 $defaults = array(
"nom",
"prenom",
"mail",
"canpass",
"enabled",
"type",
"duration",
"notes");
61 if (!isset($options[
"uid"])) {
62 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: UID"));
64 $uid = intval($options[
"uid"]);
65 $old = $this->admin->get(
$uid);
67 return new Alternc_Api_Response(array(
"code" => self::ERR_NOT_FOUND,
"message" =>
"User not found"));
70 foreach ($defaults as
$key) {
71 if (!isset($options[
$key])) {
75 if (!isset($options[
"pass"]))
76 $options[
"pass"] =
"";
77 $uid = $this->admin->update_mem(
$uid, $options[
"mail"], $options[
"nom"], $options[
"prenom"], $options[
"pass"], $options[
"enabled"], $options[
"canpass"], $options[
"type"], $options[
"duration"], $options[
"notes"]);
90 function del($options) {
91 if (!isset($options[
"uid"])) {
92 return new Alternc_Api_Response(array(
"code" => self::ERR_ALTERNC_FUNCTION,
"message" =>
"Missing or invalid argument: UID"));
94 $result = $this->admin->del_mem(intval($options[
"uid"]));
108 if (!isset($options[
"uid"])) {
109 return new Alternc_Api_Response(array(
"code" => self::ERR_ALTERNC_FUNCTION,
"message" =>
"Missing or invalid argument: UID"));
111 $result = $this->admin->lock_mem(intval($options[
"uid"]));
125 if (!isset($options[
"uid"])) {
126 return new Alternc_Api_Response(array(
"code" => self::ERR_ALTERNC_FUNCTION,
"message" =>
"Missing or invalid argument: UID"));
128 $result = $this->admin->unlock_mem(intval($options[
"uid"]));
142 if (!isset($options[
"uid"])) {
143 return new Alternc_Api_Response(array(
"code" => self::ERR_ALTERNC_FUNCTION,
"message" =>
"Missing or invalid argument: UID"));
145 $result = $this->admin->normal2su(intval($options[
"uid"]));
159 if (!isset($options[
"uid"])) {
160 return new Alternc_Api_Response(array(
"code" => self::ERR_ALTERNC_FUNCTION,
"message" =>
"Missing or invalid argument: UID"));
162 $result = $this->admin->su2normal(intval($options[
"uid"]));
179 if (!$result && isset($options[
"uid"])) {
180 $result = $this->admin->get(intval($options[
"uid"]));
182 $result = array($result);
184 if (!$result && isset($options[
"login"])) {
185 $result = $this->admin->get_list(1,
"", $options[
"login"],
"login");
187 if (!$result && isset($options[
"domain"])) {
188 $result = $this->admin->get_list(1,
"", $options[
"domain"],
"domaine");
190 if (!$result && isset($options[
"creator"])) {
191 $result = $this->admin->get_list(1, intval($options[
"creator"]));
194 $result = $this->admin->get_list(1,
"");
200 list($offset, $count) = $this->
offsetAndCount($options, count($result));
201 if ($offset != -1 || $count != -1) {
202 $result = array_slice($result, $offset, $count);
Any Legacy AlternC Api should use this class as a parent to be able to handle properly the access rig...
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.
Account Api of AlternC, used by alternc-api package.
unlock($options)
API Method from legacy class method admin->unlock_mem()
find($options)
API Method from legacy class method admin->get_list()
lock($options)
API Method from legacy class method admin->lock_mem()
update($options)
API Method from legacy class method admin->update_mem()
setAdmin($options)
API Method from legacy class method admin->normal2su()
unsetAdmin($options)
API Method from legacy class method admin->su2normal()
del($options)
API Method from legacy class method admin->del_mem()
add($options)
API Method from legacy class method admin->add_mem()
Standard Response object for the AlternC API.
if(empty($_POST['key'])||empty($_POST['val'])) $key