adding proper DOMAIN find function
This commit is contained in:
parent
cb2ad782b4
commit
dee572ab48
|
@ -11,7 +11,8 @@ class Alternc_Api_Legacyobject {
|
|||
protected $admin; // m_admin instance
|
||||
protected $cuid; // current user id
|
||||
protected $isAdmin; // is it an Admin account?
|
||||
|
||||
protected $db; // PDO DB access to AlternC's database.
|
||||
|
||||
const ERR_INVALID_ARGUMENT = 111201;
|
||||
const ERR_ALTERNC_FUNCTION = 111202;
|
||||
|
||||
|
@ -21,6 +22,7 @@ class Alternc_Api_Legacyobject {
|
|||
throw new \Exception("Bad argument: service is not an Alternc_Api_Service", self::ERR_INVALID_ARGUMENT);
|
||||
}
|
||||
// We store the global $cuid to AlternC legacy classes
|
||||
$this->db=$service->db;
|
||||
$this->cuid=$cuid=$service->token->uid;
|
||||
$this->isAdmin=$service->token->isAdmin;
|
||||
// We use the global $admin from AlternC legacy classes
|
||||
|
|
|
@ -35,11 +35,18 @@ class Alternc_Api_Object_Domain extends Alternc_Api_Legacyobject {
|
|||
} else {
|
||||
$uid=$cuid;
|
||||
}
|
||||
$result=$this->dom->get_domain_list($uid);
|
||||
if (!$result) {
|
||||
return $this->alterncLegacyErrorManager();
|
||||
if ($uid!=-1) {
|
||||
$sql=" WHERE compte=$uid ";
|
||||
} else {
|
||||
$offset=-1; $count=-1;
|
||||
$sql="";
|
||||
}
|
||||
$stmt = $this->db->prepare("SELECT * FROM domaines $sql ORDER BY domaine");
|
||||
$stmt->execute();
|
||||
$result = array();
|
||||
while ($me = $stmt->fetch(PDO::FETCH_OBJ)) {
|
||||
$result[$me->domaine] = $me;
|
||||
}
|
||||
$offset=-1; $count=-1;
|
||||
if (isset($options["count"])) $count=intval($options["count"]);
|
||||
if (isset($options["offset"])) $offset=intval($options["offset"]);
|
||||
if ($offset!=-1 || $count!=-1) {
|
||||
|
@ -48,7 +55,6 @@ class Alternc_Api_Object_Domain extends Alternc_Api_Legacyobject {
|
|||
$result= array_slice($result, $offset, $count);
|
||||
}
|
||||
return new Alternc_Api_Response( array("content" =>$result) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
class Alternc_Api_Service {
|
||||
|
||||
|
||||
private $db; // PDO object
|
||||
public $db; // PDO object
|
||||
private $loggerList; // List of loggers
|
||||
private $allowedAuth; // list of allowed authenticators
|
||||
public $token; // Token (useful for called classes)
|
||||
|
|
Loading…
Reference in New Issue