mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-05-02 19:19:17 -04:00
Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
Conflicts: modules/gallery/models/item.php
This commit is contained in:
@@ -65,12 +65,14 @@ class Comment_Model extends ORM {
|
||||
}
|
||||
}
|
||||
$visible_change = $this->original()->state == "published" || $this->state == "published";
|
||||
|
||||
$original = clone $this->original();
|
||||
parent::save();
|
||||
|
||||
if (isset($created)) {
|
||||
module::event("comment_created", $this);
|
||||
} else {
|
||||
module::event("comment_updated", $this->original(), $this);
|
||||
module::event("comment_updated", $original, $this);
|
||||
}
|
||||
|
||||
// We only notify on the related items if we're making a visible change.
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
*/
|
||||
class ORM extends ORM_Core {
|
||||
// Track the original value of this ORM so that we can look it up in ORM::original()
|
||||
protected $original;
|
||||
protected $original = null;
|
||||
|
||||
public function save() {
|
||||
model_cache::clear();
|
||||
$result = parent::save();
|
||||
$this->original = clone $this;
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -47,24 +48,7 @@ class ORM extends ORM_Core {
|
||||
return parent::__unset($column);
|
||||
}
|
||||
|
||||
public function reload($reload_all=true) {
|
||||
if ($reload_all) {
|
||||
parent::reload();
|
||||
}
|
||||
$this->original = clone $this;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function clear() {
|
||||
parent::clear();
|
||||
$this->original = clone $this;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function original() {
|
||||
if (!isset($this->original)) {
|
||||
$this->original = clone $this;
|
||||
}
|
||||
return $this->original;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,8 +442,9 @@ class Item_Model extends ORM_MPTT {
|
||||
->where("right_ptr", "<", $this->right_ptr)
|
||||
->execute();
|
||||
}
|
||||
$original = clone $this->original();
|
||||
parent::save();
|
||||
module::event("item_updated", $this->original(), $this);
|
||||
module::event("item_updated", $original, $this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,6 @@ class Item_Model_Test extends Unit_Test_Case {
|
||||
$item = self::_create_random_item();
|
||||
$item->title = "ORIGINAL_VALUE";
|
||||
$item->save();
|
||||
$item->reload(false);
|
||||
$item->title = "NEW_VALUE";
|
||||
|
||||
$this->assert_same("ORIGINAL_VALUE", $item->original()->title);
|
||||
|
||||
@@ -92,19 +92,22 @@ class notification {
|
||||
return array_keys($subscribers);
|
||||
}
|
||||
|
||||
static function send_item_updated($item) {
|
||||
static function send_item_updated($original, $item) {
|
||||
$subscribers = self::get_subscribers($item);
|
||||
if (!$subscribers) {
|
||||
return;
|
||||
}
|
||||
|
||||
$v = new View("item_updated.html");
|
||||
$v->original = $original;
|
||||
$v->item = $item;
|
||||
$v->subject = $item->is_album() ?
|
||||
t("Album \"%title\" updated", array("title" => $item->original()->title)) :
|
||||
t("Album \"%title\" updated", array("title" => $original->title)) :
|
||||
($item->is_photo() ?
|
||||
t("Photo \"%title\" updated", array("title" => $item->original()->title))
|
||||
: t("Movie \"%title\" updated", array("title" => $item->original()->title)));
|
||||
t("Photo \"%title\" updated", array("title" => $original->title))
|
||||
: t("Movie \"%title\" updated", array("title" => $original->title)));
|
||||
|
||||
Kohana_Log::add("error",print_r($v->render(),1));
|
||||
|
||||
self::_notify($subscribers, $item, $v->render(), $v->subject);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,9 @@ class notification_event_Core {
|
||||
// don't want to screw up the processing that was generating the notification
|
||||
// so we don't pass the exception up the call stack
|
||||
static function item_updated($original, $new) {
|
||||
Kohana_Log::add("error",print_r("item_updated({$original->title}, {$new->title})",1));
|
||||
try {
|
||||
notification::send_item_updated($new);
|
||||
notification::send_item_updated($original, $new);
|
||||
} catch (Exception $e) {
|
||||
Kohana_Log::add("error", "@todo notification_event::item_updated() failed");
|
||||
Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<h2> <?= html::clean($subject) ?> </h2>
|
||||
<table>
|
||||
<tr>
|
||||
<? if ($item->original("title") != $item->title): ?>
|
||||
<? if ($original->title != $item->title): ?>
|
||||
<td><?= t("New title:") ?></td>
|
||||
<td><?= html::clean($item->title) ?></td>
|
||||
<? else: ?>
|
||||
@@ -19,7 +19,7 @@
|
||||
<td><?= t("Url:") ?></td>
|
||||
<td><a href="<?= $item->abs_url() ?>"><?= $item->abs_url() ?></a></td>
|
||||
</tr>
|
||||
<? if ($item->original("description") != $item->description): ?>
|
||||
<? if ($original->description != $item->description): ?>
|
||||
<tr>
|
||||
<td><?= t("New description:") ?></td>
|
||||
<td><?= html::clean($item->description) ?></td>
|
||||
|
||||
@@ -41,11 +41,13 @@ class Group_Model extends ORM implements Group_Definition {
|
||||
if (!$this->loaded()) {
|
||||
$created = 1;
|
||||
}
|
||||
|
||||
$original = clone $this->original();
|
||||
parent::save();
|
||||
if (isset($created)) {
|
||||
module::event("group_created", $this);
|
||||
} else {
|
||||
module::event("group_updated", $this->original(), $this);
|
||||
module::event("group_updated", $original, $this);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -69,11 +69,13 @@ class User_Model extends ORM implements User_Definition {
|
||||
if (!$this->loaded()) {
|
||||
$created = 1;
|
||||
}
|
||||
|
||||
$original = clone $this->original();
|
||||
parent::save();
|
||||
if (isset($created)) {
|
||||
module::event("user_created", $this);
|
||||
} else {
|
||||
module::event("user_updated", $this->original(), $this);
|
||||
module::event("user_updated", $original, $this);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user