]> dev.renevier.net Git - syp.git/blobdiff - inc/db/anydb.php
err_lonlat_invalid exceptions not thrown correctly
[syp.git] / inc / db / anydb.php
index 47d9a06dc3a154b9870aa0ddfd28affc6445caee..ca61b0f3135877af1c96737f6d9b2f2be8259e94 100644 (file)
@@ -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,17 +28,23 @@ 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)) {
-            throw new Exception ($this->err_lonlat_invalid);
+            throw new Exception (self::err_lonlat_invalid);
         }
         $this->lon = $lon;
 
         // latitude
         if (!isset ($lat) || !is_numeric ($lat) ||
              ($lat < -90) || ($lat > 90)) {
-            throw new Exception ($this->err_lonlat_invalid);
+            throw new Exception (self::err_lonlat_invalid);
         }
         $this->lat = $lat;
     }
@@ -85,9 +93,15 @@ interface anydbConnection {
      */
     public function create_items_table();
 
+    /*
+     * returns true if $usrname is name of an existing user, false otherwise.
+     */
+    public function user_exists ($usrname);
+
     /*
      * set password $pwd for user $usrname. If $usrname does not exist, create
      * it.
+     * throws an err_query error in case $pwd is null
      */
     public function setpwd($usrname, $pwd);
 
@@ -114,22 +128,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