summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-07-29 22:28:56 -0400
committerEvan Prodromou <evan@prodromou.name>2008-07-29 22:28:56 -0400
commitd79dc8344b529281dfb8a8383c529720a429472b (patch)
tree33d4914a14e62b657a426520a5844340c187059b /classes
parent44fb662efb0e664287863dfe106f332a83a2f622 (diff)
refactor notice-adding code to one static method on Notice
darcs-hash:20080730022856-84dde-f19e4ff5d5ae2603b63b8aebd8f878ec90b3ce22.gz
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 02526bae2..ef8f7046e 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -75,4 +75,34 @@ class Notice extends DB_DataObject
}
return true;
}
+
+ static function saveNew($profile_id, $content, $source=NULL, $is_local=1) {
+
+ $notice = new Notice();
+ $notice->profile_id = $profile_id;
+ $notice->is_local = $is_local;
+ $notice->created = DB_DataObject_Cast::dateTime();
+ # Default theme uses 'content' for something else
+ $notice->content = $content;
+
+ $notice->rendered = common_render_content($notice->content, $notice);
+
+ $id = $notice->insert();
+
+ if (!$id) {
+ return _('Problem saving notice.');
+ }
+
+ $orig = clone($notice);
+ $notice->uri = common_notice_uri($notice);
+
+ if (!$notice->update($orig)) {
+ return _('Problem saving notice.');
+ }
+
+ common_save_replies($notice);
+ $notice->saveTags();
+
+ return $notice;
+ }
}