summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-08-03 08:12:39 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-08-03 08:12:39 -0700
commit2e82c5e9ca3a924e98d8998b397d25c83d716d55 (patch)
tree2db525dbdf4adbdd404d9d95e171aa25c3092a5d
parentbb8c83db819a99e34ba45e9c1c31a79e08b7c194 (diff)
parent7ad0808a117fd1db4e94da8d7763ccca1d69350a (diff)
Merge branch 'master' of git@github.com:gallery/gallery3
-rw-r--r--modules/akismet/helpers/akismet_event.php6
-rw-r--r--modules/comment/models/comment.php8
-rw-r--r--modules/gallery/libraries/MY_ORM.php12
-rw-r--r--modules/gallery/models/item.php2
-rw-r--r--modules/gallery/tests/Item_Model_Test.php2
-rw-r--r--modules/notification/helpers/notification_event.php8
-rw-r--r--modules/search/helpers/search_event.php4
-rw-r--r--modules/user/models/group.php2
-rw-r--r--modules/user/models/user.php2
9 files changed, 23 insertions, 23 deletions
diff --git a/modules/akismet/helpers/akismet_event.php b/modules/akismet/helpers/akismet_event.php
index d6cde222..cec6d95d 100644
--- a/modules/akismet/helpers/akismet_event.php
+++ b/modules/akismet/helpers/akismet_event.php
@@ -40,14 +40,14 @@ class akismet_event_Core {
$comment->save();
}
- static function comment_updated($comment) {
+ static function comment_updated($original, $new) {
if (!module::get_var("akismet", "api_key")) {
return;
}
- if ($comment->original("state") != "spam" && $comment->state == "spam") {
+ if ($original->state != "spam" && $new->state == "spam") {
akismet::submit_spam($new);
- } else if ($comment->original("state") == "spam" && $comment->state != "spam") {
+ } else if ($original->state == "spam" && $new->state != "spam") {
akismet::submit_ham($new);
}
}
diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php
index d052a39c..83d0888a 100644
--- a/modules/comment/models/comment.php
+++ b/modules/comment/models/comment.php
@@ -64,17 +64,17 @@ class Comment_Model extends ORM {
$created = true;
}
}
+ $visible_change = $this->original()->state == "published" || $this->state == "published";
parent::save();
if (isset($created)) {
module::event("comment_created", $this);
} else {
- module::event("comment_updated", $this);
+ module::event("comment_updated", $this->original(), $this);
}
- // We only notify on the related items if we're making a visible change, which means moving in
- // or out of a published state
- if ($this->original("state") == "published" || $this->state == "published") {
+ // We only notify on the related items if we're making a visible change.
+ if ($visible_change) {
module::event("item_related_update", $this->item());
}
diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php
index 1d3c1ef3..de8adc1d 100644
--- a/modules/gallery/libraries/MY_ORM.php
+++ b/modules/gallery/libraries/MY_ORM.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class ORM extends ORM_Core {
- // Track the original value of this ORM instance so that we can look it up in ORM::original()
+ // Track the original value of this ORM so that we can look it up in ORM::original()
protected $original = null;
public function open_paren() {
@@ -34,13 +34,13 @@ class ORM extends ORM_Core {
public function save() {
model_cache::clear();
$result = parent::save();
- $this->original = $this->object;
+ $this->original = clone $this;
return $result;
}
public function __set($column, $value) {
if (!isset($this->original)) {
- $this->original = $this->object;
+ $this->original = clone $this;
}
return parent::__set($column, $value);
@@ -48,14 +48,14 @@ class ORM extends ORM_Core {
public function __unset($column) {
if (!isset($this->original)) {
- $this->original = $this->object;
+ $this->original = clone $this;
}
return parent::__unset($column);
}
- public function original($column) {
- return $this->original[$column];
+ public function original() {
+ return $this->original;
}
}
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index b3c7998b..f3e6b8f3 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -365,7 +365,7 @@ class Item_Model extends ORM_MPTT {
}
parent::save();
if (isset($send_event)) {
- module::event("item_updated", $this);
+ module::event("item_updated", $this->original(), $this);
}
return $this;
}
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index c2773097..0940d076 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -147,7 +147,7 @@ class Item_Model_Test extends Unit_Test_Case {
$item->save();
$item->title = "NEW_VALUE";
- $this->assert_same("ORIGINAL_VALUE", $item->original("title"));
+ $this->assert_same("ORIGINAL_VALUE", $item->original()->title);
$this->assert_same("NEW_VALUE", $item->title);
}
}
diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php
index c6e770a7..d1b76e93 100644
--- a/modules/notification/helpers/notification_event.php
+++ b/modules/notification/helpers/notification_event.php
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class notification_event_Core {
- static function item_updated($item) {
- notification::send_item_updated($item);
+ static function item_updated($original, $new) {
+ notification::send_item_updated($new);
}
static function item_created($item) {
@@ -40,8 +40,8 @@ class notification_event_Core {
}
}
- static function comment_updated($item) {
- if ($item->state == "published" && $item->original("state") != "published") {
+ static function comment_updated($original, $new) {
+ if ($new->state == "published" && $original->state != "published") {
notification::send_comment_published($new);
}
}
diff --git a/modules/search/helpers/search_event.php b/modules/search/helpers/search_event.php
index 764fdd18..b65763af 100644
--- a/modules/search/helpers/search_event.php
+++ b/modules/search/helpers/search_event.php
@@ -22,8 +22,8 @@ class search_event_Core {
search::update($item);
}
- static function item_updated($item) {
- search::update($item);
+ static function item_updated($original, $new) {
+ search::update($new);
}
static function item_deleted($item) {
diff --git a/modules/user/models/group.php b/modules/user/models/group.php
index bb3fb58b..8af78012 100644
--- a/modules/user/models/group.php
+++ b/modules/user/models/group.php
@@ -41,7 +41,7 @@ class Group_Model extends ORM {
if (isset($created)) {
module::event("group_created", $this);
} else {
- module::event("group_updated", $this);
+ module::event("group_updated", $this->original(), $this);
}
return $this;
}
diff --git a/modules/user/models/user.php b/modules/user/models/user.php
index def65a6f..4b43adff 100644
--- a/modules/user/models/user.php
+++ b/modules/user/models/user.php
@@ -68,7 +68,7 @@ class User_Model extends ORM {
if (isset($created)) {
module::event("user_created", $this);
} else {
- module::event("user_updated", $this);
+ module::event("user_updated", $this->original(), $this);
}
return $this;
}