12 parent::__construct($service);
26 if ($this->isAdmin && isset($options[
"uid"])) {
27 $uid = intval($options[
"uid"]);
30 $did = $this->mail->enum_domains(
$uid);
44 if (!isset($options[
"mail"])) {
45 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " .
"mail"));
47 $did = $this->mail->available($options[
"mail"]);
63 $defaults = array(
"dom_id" =>
null,
"search" =>
"",
"offset" => 0,
"count" => 30,
"show_systemmails" =>
false);
65 if (!isset($options[
$key])) {
69 $did = $this->mail->enum_domain_mails($options[
"dom_id"], $options[
"search"], $options[
"offset"], $options[
"count"], $options[
"show_systemmails"]);
85 $defaults = array(
"type" =>
"");
86 $mandatory = array(
"dom_id",
"mail");
88 foreach ($mandatory as
$key) {
89 if (!isset($options[
$key])) {
94 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
97 if (!isset($options[
$key])) {
101 $did = $this->mail->create($options[
"dom_id"], $options[
"mail"], $options[
"type"]);
114 function get($options) {
115 $mandatory = array(
"mail_id");
117 foreach ($mandatory as
$key) {
118 if (!isset($options[
$key])) {
119 $missing.=
$key .
" ";
123 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
125 $did = $this->mail->get_details($options[
"mail_id"]);
139 $mandatory = array(
"mail_id");
141 foreach ($mandatory as
$key) {
142 if (!isset($options[
$key])) {
143 $missing.=
$key .
" ";
147 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
149 $did = $this->mail->get_account_by_mail_id($options[
"mail_id"]);
162 function delete($options) {
163 $mandatory = array(
"mail_id");
165 foreach ($mandatory as
$key) {
166 if (!isset($options[
$key])) {
167 $missing.=
$key .
" ";
171 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
173 $did = $this->mail->delete($options[
"mail_id"]);
187 $mandatory = array(
"mail_id");
189 foreach ($mandatory as
$key) {
190 if (!isset($options[
$key])) {
191 $missing.=
$key .
" ";
195 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
197 $did = $this->mail->undelete($options[
"mail_id"]);
211 $mandatory = array(
"mail_id",
"password");
213 foreach ($mandatory as
$key) {
214 if (!isset($options[
$key])) {
215 $missing.=
$key .
" ";
219 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
221 $did = $this->mail->set_passwd($options[
"mail_id"], $options[
"password"]);
235 $mandatory = array(
"mail_id");
237 foreach ($mandatory as
$key) {
238 if (!isset($options[
$key])) {
239 $missing.=
$key .
" ";
243 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
245 $did = $this->mail->enable($options[
"mail_id"]);
259 $mandatory = array(
"mail_id");
261 foreach ($mandatory as
$key) {
262 if (!isset($options[
$key])) {
263 $missing.=
$key .
" ";
267 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
269 $did = $this->mail->disable($options[
"mail_id"]);
285 $defaults = array(
"delivery" =>
"dovecot");
286 $mandatory = array(
"mail_id",
"islocal",
"quotamb",
"recipients");
288 foreach ($mandatory as
$key) {
289 if (!isset($options[
$key])) {
290 $missing.=
$key .
" ";
294 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing or invalid argument: " . $missing));
297 if (!isset($options[
$key])) {
301 $did = $this->mail->set_details($options[
"mail_id"], $options[
"islocal"], $options[
"quotamb"], $options[
"recipients"], $options[
"delivery"]);
318 if ($this->isAdmin && isset($options[
"uid"])) {
319 $uid = intval($options[
"uid"]);
321 if (!isset($options[
"email"]) || !isset($options[
"password"])) {
322 return new Alternc_Api_Response(array(
"code" => self::ERR_INVALID_ARGUMENT,
"message" =>
"Missing email or password argument"));
324 list($address,
$domain)=explode(
"@",$options[
"email"],2);
325 $stmt = $this->db->prepare(
"SELECT enabled,password FROM domaines d,address a WHERE a.domain_id=d.id AND address=? AND domaine=?;");
326 $stmt->execute(array($address,
$domain));
327 $me = $stmt->fetch(PDO::FETCH_OBJ);
328 if ($me && $me->enabled) {
342 if ($hash{0} !=
'{') {
343 if ($hash{0} ==
'$' ) {
353 if (substr($hash,0,7) ==
'{crypt}') {
354 if (crypt(
$password, substr($hash,7)) == substr($hash,7))
358 elseif (substr($hash,0,5) ==
'{MD5}') {
359 $encrypted_password =
'{MD5}' . base64_encode(md5(
$password,TRUE));
361 elseif (substr($hash,0,6) ==
'{SHA1}') {
362 $encrypted_password =
'{SHA}' . base64_encode(sha1(
$password, TRUE ));
364 elseif (substr($hash,0,6) ==
'{SSHA}') {
365 $salt = substr(base64_decode(substr($hash,6)),20);
366 $encrypted_password =
'{SSHA}' . base64_encode(sha1(
$password.$salt, TRUE ). $salt);
368 echo
"Unsupported password hash format";
372 if ($hash == $encrypted_password)
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
Domain Api of AlternC, used by alternc-api package.
check_password($password, $hash)
update($options)
API Method from legacy class method $mail-> set_details ($mail_id, $islocal, $quotamb,...
create($options)
API Method from legacy class method $mail->create ($dom_id, $mail,$type="",$dontcheck=false){.
isAvailable($options)
API Method from legacy class method mail->available()
account($options)
API Method from legacy class method $mail->get_account_by_mail_id($mail_id)
disable($options)
API Method from legacy class method $mail->disable($mail_id)
listDomains($options)
API Method from legacy class method mail->enum_domains()
login($options)
API Method for email authentication.
enable($options)
API Method from legacy class method $mail->enable($mail_id)
getAll($options)
API Method from legacy class method $mail->enum_domain_mails ($dom_id = null, $search="",...
passwd($options)
API Method from legacy class method $mail->delete($mail_id)
undelete($options)
API Method from legacy class method $mail->undelete($mail_id)
Standard Response object for the AlternC API.
if(empty($site_name)) elseif($piwik->site_add( $site_name, $site_urls))
if(empty($_POST['key'])||empty($_POST['val'])) $key