summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/user/helpers/user.php28
-rw-r--r--modules/user/helpers/user_installer.php4
-rw-r--r--modules/user/models/user.php9
3 files changed, 39 insertions, 2 deletions
diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php
new file mode 100644
index 00000000..10015b83
--- /dev/null
+++ b/modules/user/helpers/user.php
@@ -0,0 +1,28 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * This helper provides a common around the user management functions.
+ *
+ * @author Tim Almdal <public@timalmdal.com>
+ *
+ */
+class user {
+} \ No newline at end of file
diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php
index e0f7312e..391915a3 100644
--- a/modules/user/helpers/user_installer.php
+++ b/modules/user/helpers/user_installer.php
@@ -68,10 +68,10 @@ class user_installer {
$user = ORM::factory("user")->where("display_name", "admin")->find();
$user->name = "admin";
$user->display_name = "Gallery Administrator";
- // @todo create a helper function to encrypt the password.
- $user->password = user_password::hash_password("admin");
+ $user->password = "admin";
$user->save();
$id = $user->id;
+
$db->query("UPDATE `items` SET `owner_id` = $id WHERE `owner_id` IS NULL");
foreach (array("administrator", "registered") as $group_name) {
diff --git a/modules/user/models/user.php b/modules/user/models/user.php
index 8b48b7e5..d02d0ae0 100644
--- a/modules/user/models/user.php
+++ b/modules/user/models/user.php
@@ -19,4 +19,13 @@
*/
class User_Model extends ORM {
protected $has_and_belongs_to_many = array('groups');
+
+ public function __set($column, $value) {
+ switch ($column) {
+ case "password":
+ $value = user_password::hash_password($value);
+ break;
+ }
+ parent::__set($column, $value);
+ }
} \ No newline at end of file