Skip to content

Instantly share code, notes, and snippets.

@luniki
Created February 3, 2011 12:36
Show Gist options
  • Save luniki/809421 to your computer and use it in GitHub Desktop.
Save luniki/809421 to your computer and use it in GitHub Desktop.
diff --git a/lib/classes/StudipDocument.class.php b/lib/classes/StudipDocument.class.php
index 4293ed4..637f3d0 100644
--- a/lib/classes/StudipDocument.class.php
+++ b/lib/classes/StudipDocument.class.php
@@ -107,4 +107,38 @@ class StudipDocument extends SimpleORMap {
$this->db_table = 'dokumente';
parent::__construct($id);
}
+
+ /**
+ * Store entry in database; if data is actually changed triggerChdate() is called.
+ * Posts the Notifications "DocumentCreated" or "DocumentUpdated" if successful.
+ * The subject of the notification is this document.
+ *
+ * @return number|boolean either false or the number of the affected rows
+ */
+ function store()
+ {
+ $notification = $this->isNew() ? 'DocumentCreated' : 'DocumentUpdated';
+
+ if ($ret = parent::store() !== false) {
+ NotificationCenter::postNotification($notification, $this);
+ }
+ return $ret;
+ }
+
+ /**
+ * Delete entry from database.
+ * The object is cleared and turned to new state.
+ * Posts the Notification "DocumentDeleted" if successful.
+ * The subject of the notification is the former document.
+ *
+ * @return boolean always true
+ */
+ function delete()
+ {
+ $to_delete = clone $this;
+ if ($ret = parent::delete()) {
+ NotificationCenter::postNotification('DocumentDeleted', $to_delete);
+ }
+ return $ret;
+ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment