diff options
| author | Tim Almdal <tnalmdal@shaw.ca> | 2009-10-05 14:04:27 -0700 | 
|---|---|---|
| committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-10-09 01:26:35 -0700 | 
| commit | 00ee91837faf4807fb17dde3272ca8248a9dcd94 (patch) | |
| tree | 29bf1e98cdb6fc16c548b5dfbe15a965cb524235 /modules/gallery/models | |
| parent | f67bfd099296602f60d48914ae4b09d65b0ad8d3 (diff) | |
Convert direct lookups for the user table using ORM to using the user::lookup_by_name and user_lookup API methods.
Convert the Admin_User controller
Convert the login and password change controller
Change the item model to call user::lookup to get the owner.
On the log model, delete the relationship between the log and user table, and replace with a
call to user::lookup
(cherry picked from commit 194cc3b27a73afe5119da9f09407c1e068dc6fa3)
Create the get_user_list, lookup_by_name, lookup_by_hash and get_group_list api functions
Diffstat (limited to 'modules/gallery/models')
| -rw-r--r-- | modules/gallery/models/item.php | 2 | ||||
| -rw-r--r-- | modules/gallery/models/log.php | 17 | 
2 files changed, 17 insertions, 2 deletions
| diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 6499fd2d..6f0e3525 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -333,7 +333,7 @@ class Item_Model extends ORM_MPTT {        // This relationship depends on an outside module, which may not be present so handle        // failures gracefully.        try { -        return model_cache::get("user", $this->owner_id); +        return user::lookup($this->owner_id);        } catch (Exception $e) {          return null;        } diff --git a/modules/gallery/models/log.php b/modules/gallery/models/log.php index 6734afb8..d143d7bd 100644 --- a/modules/gallery/models/log.php +++ b/modules/gallery/models/log.php @@ -18,5 +18,20 @@   * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.   */  class Log_Model extends ORM { -  protected $has_one = array("user"); +  /** +   * @see ORM::__get() +   */ +  public function __get($column) { +    if ($column == "user") { +      // This relationship depends on an outside module, which may not be present so handle +      // failures gracefully. +      try { +        return user::lookup($this->user_id); +      } catch (Exception $e) { +        return null; +      } +    } else { +      return parent::__get($column); +    } +  }  } | 
