14 function add($options) {
15 $mandatory = array(
"login",
"pass",
"nom",
"prenom",
"mail");
16 $defaults = array(
"canpass" => 1,
"type" =>
"default",
"duration" => 0,
"notes" =>
"",
"force" => 0,
"create_dom" =>
"");
18 foreach ($mandatory as
$key) {
19 if (!isset($options[
$key])) {
24 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
27 if (!isset($options[
$key])) {
31 if (!isset($options[
"db_server_id"])) {
32 $stmt = $this->db->prepare(
"SELECT MIN(db_servers.id) AS id FROM db_servers;");
34 $me = $stmt->fetch(PDO::FETCH_OBJ);
35 $options[
"db_server_id"] = $me->id;
37 $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"]);
52 $defaults = array(
"nom",
"prenom",
"mail",
"canpass",
"enabled",
"type",
"duration",
"notes");
53 if (!isset($options[
"uid"])) {
54 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: UID"));
56 $uid = intval($options[
"uid"]);
57 $old = $this->admin->get(
$uid);
59 return new Alternc_Api_Response(array(
"code" => self::ERR_NOT_FOUND,
"message" =>
"User not found"));
62 foreach ($defaults as
$key) {
63 if (!isset($options[
$key])) {
67 if (!isset($options[
"pass"]))
68 $options[
"pass"] =
"";
69 $uid = $this->admin->update_mem(
$uid, $options[
"mail"], $options[
"nom"], $options[
"prenom"], $options[
"pass"], $options[
"enabled"], $options[
"canpass"], $options[
"type"], $options[
"duration"], $options[
"notes"]);
82 function del($options) {
83 if (!isset($options[
"uid"])) {
84 return new Alternc_Api_Response(array(
"code" => self::ERR_ALTERNC_FUNCTION,
"message" =>
"Missing or invalid argument: UID"));
86 $result = $this->admin->del_mem(intval($options[
"uid"]));
100 if (!isset($options[
"uid"])) {
101 return new Alternc_Api_Response(array(
"code" => self::ERR_ALTERNC_FUNCTION,
"message" =>
"Missing or invalid argument: UID"));
103 $result = $this->admin->lock_mem(intval($options[
"uid"]));
117 if (!isset($options[
"uid"])) {
118 return new Alternc_Api_Response(array(
"code" => self::ERR_ALTERNC_FUNCTION,
"message" =>
"Missing or invalid argument: UID"));
120 $result = $this->admin->unlock_mem(intval($options[
"uid"]));
134 if (!isset($options[
"uid"])) {
135 return new Alternc_Api_Response(array(
"code" => self::ERR_ALTERNC_FUNCTION,
"message" =>
"Missing or invalid argument: UID"));
137 $result = $this->admin->normal2su(intval($options[
"uid"]));
151 if (!isset($options[
"uid"])) {
152 return new Alternc_Api_Response(array(
"code" => self::ERR_ALTERNC_FUNCTION,
"message" =>
"Missing or invalid argument: UID"));
154 $result = $this->admin->su2normal(intval($options[
"uid"]));
171 if (!$result && isset($options[
"uid"])) {
172 $result = $this->admin->get(intval($options[
"uid"]));
174 $result = array($result);
176 if (!$result && isset($options[
"login"])) {
177 $result = $this->admin->get_list(1,
"", $options[
"login"],
"login");
179 if (!$result && isset($options[
"domain"])) {
180 $result = $this->admin->get_list(1,
"", $options[
"domain"],
"domaine");
182 if (!$result && isset($options[
"creator"])) {
183 $result = $this->admin->get_list(1, intval($options[
"creator"]));
186 $result = $this->admin->get_list(1,
"");
192 list($offset, $count) = $this->
offsetAndCount($options, count($result));
193 if ($offset != -1 || $count != -1) {
194 $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()
del($options)
API Method from legacy class method admin->del_mem()
setAdmin($options)
API Method from legacy class method admin->normal2su()
update($options)
API Method from legacy class method admin->update_mem()
find($options)
API Method from legacy class method admin->get_list()
unsetAdmin($options)
API Method from legacy class method admin->su2normal()
lock($options)
API Method from legacy class method admin->lock_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