adding proper DOMAIN find function

This commit is contained in:
Benjamin Sonntag 2015-01-08 12:05:29 +01:00
parent cb2ad782b4
commit dee572ab48
3 changed files with 15 additions and 7 deletions

View File

@ -11,6 +11,7 @@ class Alternc_Api_Legacyobject {
protected $admin; // m_admin instance protected $admin; // m_admin instance
protected $cuid; // current user id protected $cuid; // current user id
protected $isAdmin; // is it an Admin account? protected $isAdmin; // is it an Admin account?
protected $db; // PDO DB access to AlternC's database.
const ERR_INVALID_ARGUMENT = 111201; const ERR_INVALID_ARGUMENT = 111201;
const ERR_ALTERNC_FUNCTION = 111202; 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); 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 // We store the global $cuid to AlternC legacy classes
$this->db=$service->db;
$this->cuid=$cuid=$service->token->uid; $this->cuid=$cuid=$service->token->uid;
$this->isAdmin=$service->token->isAdmin; $this->isAdmin=$service->token->isAdmin;
// We use the global $admin from AlternC legacy classes // We use the global $admin from AlternC legacy classes

View File

@ -35,11 +35,18 @@ class Alternc_Api_Object_Domain extends Alternc_Api_Legacyobject {
} else { } else {
$uid=$cuid; $uid=$cuid;
} }
$result=$this->dom->get_domain_list($uid); if ($uid!=-1) {
if (!$result) { $sql=" WHERE compte=$uid ";
return $this->alterncLegacyErrorManager();
} else { } 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["count"])) $count=intval($options["count"]);
if (isset($options["offset"])) $offset=intval($options["offset"]); if (isset($options["offset"])) $offset=intval($options["offset"]);
if ($offset!=-1 || $count!=-1) { if ($offset!=-1 || $count!=-1) {
@ -48,7 +55,6 @@ class Alternc_Api_Object_Domain extends Alternc_Api_Legacyobject {
$result= array_slice($result, $offset, $count); $result= array_slice($result, $offset, $count);
} }
return new Alternc_Api_Response( array("content" =>$result) ); return new Alternc_Api_Response( array("content" =>$result) );
}
} }

View File

@ -9,7 +9,7 @@
class Alternc_Api_Service { class Alternc_Api_Service {
private $db; // PDO object public $db; // PDO object
private $loggerList; // List of loggers private $loggerList; // List of loggers
private $allowedAuth; // list of allowed authenticators private $allowedAuth; // list of allowed authenticators
public $token; // Token (useful for called classes) public $token; // Token (useful for called classes)