X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=inc%2Fdb%2Fanydb.php;h=596561cbc9027c15f89cbaf51aae9b1b000046b6;hp=c88367a46277fb081309b020288e58eed88a6647;hb=3c74920cb66b4e6c47c7e8a0eaeed40ffb7e8544;hpb=57511b4efd7402ef58de66ac1fe2c01ed1b1d7b5 diff --git a/inc/db/anydb.php b/inc/db/anydb.php index c88367a..596561c 100644 --- a/inc/db/anydb.php +++ b/inc/db/anydb.php @@ -9,10 +9,12 @@ class feature { private $imgpath = null; private $title = null; private $description = null; + private $date = 0; + private $user = null; const err_lonlat_invalid = 1; - function __construct ($id, $lon, $lat, $imgpath, $title, $description) { + function __construct ($id, $lon, $lat, $imgpath, $title, $description, $date, $user) { $this->imgpath = $imgpath; // id @@ -26,6 +28,12 @@ class feature { // description $this->description = $description; + // date + $this->date = $date; + + // user + $this->user = $user; + // longitude if (!isset ($lon) || !is_numeric ($lon) || ($lon < -180) || ($lon > 180)) { @@ -69,10 +77,10 @@ interface anydbConnection { public function users_table_exists(); /* - * create users table; if $error_if_exists is true; throws an err_query - * error in case users table already exists. + * create users table; + * throws an err_query error in case users table already exists. */ - public function create_users_table($error_if_exists); + public function create_users_table(); /* * return true if items table already exists @@ -80,16 +88,18 @@ interface anydbConnection { public function items_table_exists(); /* - * create items table; if $error_if_exists is true; throws an err_query - * error in case items table already exists. + * create items table; + * throws an err_query error in case items table already exists. */ - public function create_items_table($error_if_exists); + public function create_items_table(); /* - * set password $pwd for user $usrname. If $usrname does not exist, create - * it. + * set password $pwd for user $usrname. + * If $usrname does not exist: + * - if $create_if_not_exists is true: create user. + * - if $create_if_not_exists is false: throws an err_query error. */ - public function setpwd($usrname, $pwd); + public function setpwd($usrname, $pwd, $create_if_not_exists); /* * check that $pwd_md5 is md5 for $username password. @@ -114,22 +124,21 @@ interface anydbConnection { public function getfeature($id); /* - * returns an array of available features + * returns an array of features managed by $user. If $user is undefined or + * if user is "admin", return all available features. */ - public function listfeatures(); + public function listfeatures($user); /* - * returns true if a feature with imgpath exists + * returns the most recent features sorted by date. If $num_features is not + * defined or is null, returns all features sorted by date. */ - public function imgpath_exists($imgpath); + public function mostrecentfeatures($num_features); /* - * returns Minimum Bounding Rectangle containing all feature locations. - * That function must return a result even if database is not functional. - * Minimum Bounding Rectangle is presented as an Array: - * [bottom, left, top, right] + * returns true if a feature with imgpath exists */ - public function mbr(); + public function imgpath_exists($imgpath); /* * get name of database backend