[enh] adding more methods to Mail api
This commit is contained in:
parent
398813ab71
commit
9540b77ea1
|
@ -40,7 +40,7 @@ class Alternc_Api_Object_Mail extends Alternc_Api_Legacyobject {
|
||||||
* mandatory parameters: mail(str)
|
* mandatory parameters: mail(str)
|
||||||
* @return Alternc_Api_Response telling TRUE or FALSE
|
* @return Alternc_Api_Response telling TRUE or FALSE
|
||||||
*/
|
*/
|
||||||
function available($options) {
|
function isAvailable($options) {
|
||||||
if (!isset($options["mail"])) {
|
if (!isset($options["mail"])) {
|
||||||
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . "mail"));
|
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . "mail"));
|
||||||
}
|
}
|
||||||
|
@ -59,21 +59,253 @@ class Alternc_Api_Object_Mail extends Alternc_Api_Legacyobject {
|
||||||
* non-mandatory:
|
* non-mandatory:
|
||||||
* @return Alternc_Api_Response whose content is
|
* @return Alternc_Api_Response whose content is
|
||||||
*/
|
*/
|
||||||
function listMails($options) {
|
function getAll($options) {
|
||||||
$defaults = array("dom_id" => null, "search" => "", "offset" => 0, "count" => 30, "show_systemmails" => false);
|
$defaults = array("dom_id" => null, "search" => "", "offset" => 0, "count" => 30, "show_systemmails" => false);
|
||||||
foreach ($defaults as $key => $value) {
|
foreach ($defaults as $key => $value) {
|
||||||
if (!isset($options[$key])) {
|
if (!isset($options[$key])) {
|
||||||
$options[$key] = $value;
|
$options[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$did = $this->mail->enum_domain_mails($options["dom_id"], $options["search"],
|
$did = $this->mail->enum_domain_mails($options["dom_id"], $options["search"], $options["offset"], $options["count"], $options["show_systemmails"]);
|
||||||
$options["offset"], $options["count"], $options["show_systemmails"]);
|
|
||||||
if (!$did) {
|
if (!$did) {
|
||||||
return $this->alterncLegacyErrorManager();
|
return $this->alterncLegacyErrorManager();
|
||||||
} else {
|
} else {
|
||||||
return new Alternc_Api_Response(array("content" => $did));
|
return new Alternc_Api_Response(array("content" => $did));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** API Method from legacy class method $mail->create
|
||||||
|
* ($dom_id, $mail,$type="",$dontcheck=false){
|
||||||
|
* @param $options a hash with parameters transmitted to legacy call
|
||||||
|
* mandatory parameters:
|
||||||
|
* non-mandatory:
|
||||||
|
* @return Alternc_Api_Response whose content is
|
||||||
|
*/
|
||||||
|
function create($options) {
|
||||||
|
$defaults = array("type" => "");
|
||||||
|
$mandatory = array("dom_id", "mail");
|
||||||
|
$missing = "";
|
||||||
|
foreach ($mandatory as $key) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$missing.=$key . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($missing) {
|
||||||
|
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
|
||||||
|
}
|
||||||
|
foreach ($defaults as $key => $value) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$options[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$did = $this->mail->create($options["dom_id"], $options["mail"], $options["type"]);
|
||||||
|
if (!$did) {
|
||||||
|
return $this->alterncLegacyErrorManager();
|
||||||
|
} else {
|
||||||
|
return new Alternc_Api_Response(array("content" => $did));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** API Method from legacy class method $mail->get_details($mail_id)
|
||||||
|
* @param $options a hash with parameters transmitted to legacy call
|
||||||
|
* mandatory parameters: mail_id
|
||||||
|
* @return Alternc_Api_Response whose content is
|
||||||
|
*/
|
||||||
|
function get($options) {
|
||||||
|
$mandatory = array("mail_id");
|
||||||
|
$missing = "";
|
||||||
|
foreach ($mandatory as $key) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$missing.=$key . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($missing) {
|
||||||
|
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
|
||||||
|
}
|
||||||
|
$did = $this->mail->get_details($options["mail_id"]);
|
||||||
|
if (!$did) {
|
||||||
|
return $this->alterncLegacyErrorManager();
|
||||||
|
} else {
|
||||||
|
return new Alternc_Api_Response(array("content" => $did));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** API Method from legacy class method $mail->get_account_by_mail_id($mail_id)
|
||||||
|
* @param $options a hash with parameters transmitted to legacy call
|
||||||
|
* mandatory parameters: mail_id
|
||||||
|
* @return Alternc_Api_Response whose content is
|
||||||
|
*/
|
||||||
|
function account($options) {
|
||||||
|
$mandatory = array("mail_id");
|
||||||
|
$missing = "";
|
||||||
|
foreach ($mandatory as $key) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$missing.=$key . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($missing) {
|
||||||
|
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
|
||||||
|
}
|
||||||
|
$did = $this->mail->get_account_by_mail_id($options["mail_id"]);
|
||||||
|
if (!$did) {
|
||||||
|
return $this->alterncLegacyErrorManager();
|
||||||
|
} else {
|
||||||
|
return new Alternc_Api_Response(array("content" => $did));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** API Method from legacy class method $mail->delete($mail_id)
|
||||||
|
* @param $options a hash with parameters transmitted to legacy call
|
||||||
|
* mandatory parameters: mail_id
|
||||||
|
* @return Alternc_Api_Response whose content is
|
||||||
|
*/
|
||||||
|
function delete($options) {
|
||||||
|
$mandatory = array("mail_id");
|
||||||
|
$missing = "";
|
||||||
|
foreach ($mandatory as $key) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$missing.=$key . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($missing) {
|
||||||
|
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
|
||||||
|
}
|
||||||
|
$did = $this->mail->delete($options["mail_id"]);
|
||||||
|
if (!$did) {
|
||||||
|
return $this->alterncLegacyErrorManager();
|
||||||
|
} else {
|
||||||
|
return new Alternc_Api_Response(array("content" => $did));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** API Method from legacy class method $mail->undelete($mail_id)
|
||||||
|
* @param $options a hash with parameters transmitted to legacy call
|
||||||
|
* mandatory parameters: mail_id
|
||||||
|
* @return Alternc_Api_Response whose content is
|
||||||
|
*/
|
||||||
|
function undelete($options) {
|
||||||
|
$mandatory = array("mail_id");
|
||||||
|
$missing = "";
|
||||||
|
foreach ($mandatory as $key) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$missing.=$key . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($missing) {
|
||||||
|
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
|
||||||
|
}
|
||||||
|
$did = $this->mail->undelete($options["mail_id"]);
|
||||||
|
if (!$did) {
|
||||||
|
return $this->alterncLegacyErrorManager();
|
||||||
|
} else {
|
||||||
|
return new Alternc_Api_Response(array("content" => $did));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** API Method from legacy class method $mail->delete($mail_id)
|
||||||
|
* @param $options a hash with parameters transmitted to legacy call
|
||||||
|
* mandatory parameters: mail_id, password
|
||||||
|
* @return Alternc_Api_Response whose content is
|
||||||
|
*/
|
||||||
|
function passwd($options) {
|
||||||
|
$mandatory = array("mail_id", "password");
|
||||||
|
$missing = "";
|
||||||
|
foreach ($mandatory as $key) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$missing.=$key . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($missing) {
|
||||||
|
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
|
||||||
|
}
|
||||||
|
$did = $this->mail->set_passwd($options["mail_id"], $options["password"]);
|
||||||
|
if (!$did) {
|
||||||
|
return $this->alterncLegacyErrorManager();
|
||||||
|
} else {
|
||||||
|
return new Alternc_Api_Response(array("content" => $did));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** API Method from legacy class method $mail->enable($mail_id)
|
||||||
|
* @param $options a hash with parameters transmitted to legacy call
|
||||||
|
* mandatory parameters: mail_id
|
||||||
|
* @return Alternc_Api_Response whose content is
|
||||||
|
*/
|
||||||
|
function enable($options) {
|
||||||
|
$mandatory = array("mail_id");
|
||||||
|
$missing = "";
|
||||||
|
foreach ($mandatory as $key) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$missing.=$key . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($missing) {
|
||||||
|
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
|
||||||
|
}
|
||||||
|
$did = $this->mail->enable($options["mail_id"]);
|
||||||
|
if (!$did) {
|
||||||
|
return $this->alterncLegacyErrorManager();
|
||||||
|
} else {
|
||||||
|
return new Alternc_Api_Response(array("content" => $did));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** API Method from legacy class method $mail->disable($mail_id)
|
||||||
|
* @param $options a hash with parameters transmitted to legacy call
|
||||||
|
* mandatory parameters: mail_id
|
||||||
|
* @return Alternc_Api_Response whose content is
|
||||||
|
*/
|
||||||
|
function disable($options) {
|
||||||
|
$mandatory = array("mail_id");
|
||||||
|
$missing = "";
|
||||||
|
foreach ($mandatory as $key) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$missing.=$key . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($missing) {
|
||||||
|
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
|
||||||
|
}
|
||||||
|
$did = $this->mail->disable($options["mail_id"]);
|
||||||
|
if (!$did) {
|
||||||
|
return $this->alterncLegacyErrorManager();
|
||||||
|
} else {
|
||||||
|
return new Alternc_Api_Response(array("content" => $did));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** API Method from legacy class method $mail-> set_details
|
||||||
|
* ($mail_id, $islocal, $quotamb, $recipients,$delivery="dovecot",$dontcheck=false)
|
||||||
|
* @param $options a hash with parameters transmitted to legacy call
|
||||||
|
* mandatory parameters:
|
||||||
|
* non-mandatory:
|
||||||
|
* @return Alternc_Api_Response whose content is
|
||||||
|
*/
|
||||||
|
function update($options) {
|
||||||
|
$defaults = array("delivery" => "dovecot");
|
||||||
|
$mandatory = array("mail_id", "islocal", "quotamb", "recipients");
|
||||||
|
$missing = "";
|
||||||
|
foreach ($mandatory as $key) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$missing.=$key . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($missing) {
|
||||||
|
return new Alternc_Api_Response(array("code" => self::ERR_INVALID_ARGUMENT, "message" => "Missing or invalid argument: " . $missing));
|
||||||
|
}
|
||||||
|
foreach ($defaults as $key => $value) {
|
||||||
|
if (!isset($options[$key])) {
|
||||||
|
$options[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$did = $this->mail->set_details($options["mail_id"], $options["islocal"], $options["quotamb"], $options["recipients"], $options["delivery"]);
|
||||||
|
if (!$did) {
|
||||||
|
return $this->alterncLegacyErrorManager();
|
||||||
|
} else {
|
||||||
|
return new Alternc_Api_Response(array("content" => $did));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// class Alternc_Api_Object_Mail
|
// class Alternc_Api_Object_Mail
|
||||||
|
|
Loading…
Reference in New Issue