aboutsummaryrefslogtreecommitdiff
path: root/mod/blog
diff options
context:
space:
mode:
Diffstat (limited to 'mod/blog')
-rw-r--r--mod/blog/actions/blog/save.php6
-rw-r--r--mod/blog/classes/ElggBlog.php4
-rw-r--r--mod/blog/languages/en.php11
-rw-r--r--mod/blog/lib/blog.php17
-rw-r--r--mod/blog/start.php55
-rw-r--r--mod/blog/views/default/blog/group_module.php3
-rw-r--r--mod/blog/views/default/blog/sidebar.php2
-rw-r--r--mod/blog/views/default/blog/sidebar/archives.php10
-rw-r--r--mod/blog/views/default/object/blog.php6
9 files changed, 75 insertions, 39 deletions
diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php
index 8ca8ce846..8923cd0d2 100644
--- a/mod/blog/actions/blog/save.php
+++ b/mod/blog/actions/blog/save.php
@@ -78,11 +78,8 @@ foreach ($values as $name => $default) {
case 'excerpt':
if ($value) {
- $value = elgg_get_excerpt($value);
- } else {
- $value = elgg_get_excerpt($values['description']);
+ $values[$name] = elgg_get_excerpt($value);
}
- $values[$name] = $value;
break;
case 'container_guid':
@@ -144,7 +141,6 @@ if (!$error) {
system_message(elgg_echo('blog:message:saved'));
$status = $blog->status;
- $db_prefix = elgg_get_config('dbprefix');
// add to river if changing status or published, regardless of new post
// because we remove it for drafts.
diff --git a/mod/blog/classes/ElggBlog.php b/mod/blog/classes/ElggBlog.php
index ee2ec73ef..8d4401c57 100644
--- a/mod/blog/classes/ElggBlog.php
+++ b/mod/blog/classes/ElggBlog.php
@@ -1,6 +1,10 @@
<?php
/**
* Extended class to override the time_created
+ *
+ * @property string $status The published status of the blog post (published, draft)
+ * @property string $comments_on Whether commenting is allowed (Off, On)
+ * @property string $excerpt An excerpt of the blog post used when displaying the post
*/
class ElggBlog extends ElggObject {
diff --git a/mod/blog/languages/en.php b/mod/blog/languages/en.php
index 8a21c1f8d..5248a6f51 100644
--- a/mod/blog/languages/en.php
+++ b/mod/blog/languages/en.php
@@ -41,7 +41,6 @@ $english = array(
'blog:message:saved' => 'Blog post saved.',
'blog:error:cannot_save' => 'Cannot save blog post.',
'blog:error:cannot_write_to_container' => 'Insufficient access to save blog to group.',
- 'blog:error:post_not_found' => 'This post has been removed, is invalid, or you do not have permission to view it.',
'blog:messages:warning:draft' => 'There is an unsaved draft of this post!',
'blog:edit_revision_notice' => '(Old version)',
'blog:message:deleted_post' => 'Blog post deleted.',
@@ -58,6 +57,16 @@ $english = array(
// notifications
'blog:newpost' => 'A new blog post',
+ 'blog:notification' =>
+'
+%s made a new blog post.
+
+%s
+%s
+
+View and comment on the new blog post:
+%s
+',
// widget
'blog:widget:description' => 'Display your latest blog posts',
diff --git a/mod/blog/lib/blog.php b/mod/blog/lib/blog.php
index 590547a8c..43de7a646 100644
--- a/mod/blog/lib/blog.php
+++ b/mod/blog/lib/blog.php
@@ -22,11 +22,11 @@ function blog_get_page_content_read($guid = NULL) {
$return['filter'] = '';
if (!elgg_instanceof($blog, 'object', 'blog')) {
- $return['content'] = elgg_echo('blog:error:post_not_found');
+ $return['content'] = elgg_echo('noaccess');
return $return;
}
- $return['title'] = htmlspecialchars($blog->title);
+ $return['title'] = $blog->title;
$container = $blog->getContainerEntity();
$crumbs_title = $container->name;
@@ -187,11 +187,16 @@ function blog_get_page_content_archive($owner_guid, $lower = 0, $upper = 0) {
$now = time();
- $user = get_user($owner_guid);
+ $owner = get_entity($owner_guid);
elgg_set_page_owner_guid($owner_guid);
- $crumbs_title = $user->name;
- elgg_push_breadcrumb($crumbs_title, "blog/owner/{$user->username}");
+ $crumbs_title = $owner->name;
+ if (elgg_instanceof($owner, 'user')) {
+ $url = "blog/owner/{$owner->username}";
+ } else {
+ $url = "blog/group/$owner->guid/all";
+ }
+ elgg_push_breadcrumb($crumbs_title, $url);
elgg_push_breadcrumb(elgg_echo('blog:archives'));
if ($lower) {
@@ -209,7 +214,7 @@ function blog_get_page_content_archive($owner_guid, $lower = 0, $upper = 0) {
);
if ($owner_guid) {
- $options['owner_guid'] = $owner_guid;
+ $options['container_guid'] = $owner_guid;
}
// admin / owners can see any posts
diff --git a/mod/blog/start.php b/mod/blog/start.php
index fa57e7b96..9faf1794e 100644
--- a/mod/blog/start.php
+++ b/mod/blog/start.php
@@ -60,7 +60,7 @@ function blog_init() {
elgg_extend_view('groups/tool_latest', 'blog/group_module');
// add a blog widget
- elgg_register_widget_type('blog', elgg_echo('blog'), elgg_echo('blog:widget:description'), 'profile');
+ elgg_register_widget_type('blog', elgg_echo('blog'), elgg_echo('blog:widget:description'));
// register actions
$action_path = elgg_get_plugins_path() . 'blog/actions/blog';
@@ -125,6 +125,7 @@ function blog_page_handler($page) {
$params = blog_get_page_content_archive($user->guid, $page[2], $page[3]);
break;
case 'view':
+ case 'read': // Elgg 1.7 compatibility
$params = blog_get_page_content_read($page[1]);
break;
case 'add':
@@ -136,7 +137,11 @@ function blog_page_handler($page) {
$params = blog_get_page_content_edit($page_type, $page[1], $page[2]);
break;
case 'group':
- $params = blog_get_page_content_list($page[1]);
+ if ($page[2] == 'all') {
+ $params = blog_get_page_content_list($page[1]);
+ } else {
+ $params = blog_get_page_content_archive($page[1], $page[3], $page[4]);
+ }
break;
case 'all':
$params = blog_get_page_content_list();
@@ -222,6 +227,33 @@ function blog_entity_menu_setup($hook, $type, $return, $params) {
}
/**
+ * Set the notification message body
+ *
+ * @param string $hook Hook name
+ * @param string $type Hook type
+ * @param string $message The current message body
+ * @param array $params Parameters about the blog posted
+ * @return string
+ */
+function blog_notify_message($hook, $type, $message, $params) {
+ $entity = $params['entity'];
+ $to_entity = $params['to_entity'];
+ $method = $params['method'];
+ if (elgg_instanceof($entity, 'object', 'blog')) {
+ $descr = $entity->excerpt;
+ $title = $entity->title;
+ $owner = $entity->getOwnerEntity();
+ return elgg_echo('blog:notification', array(
+ $owner->name,
+ $title,
+ $descr,
+ $entity->getURL()
+ ));
+ }
+ return null;
+}
+
+/**
* Register blogs with ECML.
*/
function blog_ecml_views_hook($hook, $entity_type, $return_value, $params) {
@@ -234,7 +266,7 @@ function blog_ecml_views_hook($hook, $entity_type, $return_value, $params) {
* Upgrade from 1.7 to 1.8.
*/
function blog_run_upgrades($event, $type, $details) {
- $blog_upgrade_version = get_plugin_setting('upgrade_version', 'blogs');
+ $blog_upgrade_version = elgg_get_plugin_setting('upgrade_version', 'blogs');
if (!$blog_upgrade_version) {
// When upgrading, check if the ElggBlog class has been registered as this
@@ -243,23 +275,6 @@ function blog_run_upgrades($event, $type, $details) {
add_subtype('object', 'blog', 'ElggBlog');
}
- // only run this on the first migration to 1.8
- // add excerpt to all blogs that don't have it.
- $ia = elgg_set_ignore_access(true);
- $options = array(
- 'type' => 'object',
- 'subtype' => 'blog'
- );
-
- $blogs = new ElggBatch('elgg_get_entities', $options);
- foreach ($blogs as $blog) {
- if (!$blog->excerpt) {
- $blog->excerpt = elgg_get_excerpt($blog->description);
- }
- }
-
- elgg_set_ignore_access($ia);
-
elgg_set_plugin_setting('upgrade_version', 1, 'blogs');
}
}
diff --git a/mod/blog/views/default/blog/group_module.php b/mod/blog/views/default/blog/group_module.php
index 028827178..6082cdafd 100644
--- a/mod/blog/views/default/blog/group_module.php
+++ b/mod/blog/views/default/blog/group_module.php
@@ -20,11 +20,12 @@ $options = array(
'type' => 'object',
'subtype' => 'blog',
'container_guid' => elgg_get_page_owner_guid(),
+ 'metadata_name_value_pairs' => array('name' => 'status', 'value' => 'published'),
'limit' => 6,
'full_view' => false,
'pagination' => false,
);
-$content = elgg_list_entities($options);
+$content = elgg_list_entities_from_metadata($options);
elgg_pop_context();
if (!$content) {
diff --git a/mod/blog/views/default/blog/sidebar.php b/mod/blog/views/default/blog/sidebar.php
index 97a23c17e..0ae2b431c 100644
--- a/mod/blog/views/default/blog/sidebar.php
+++ b/mod/blog/views/default/blog/sidebar.php
@@ -18,7 +18,7 @@ if ($vars['page'] == 'all') {
}
// only users can have archives at present
-if (elgg_instanceof(elgg_get_page_owner_entity(), 'user')) {
+if ($vars['page'] == 'owner' || $vars['page'] == 'group') {
echo elgg_view('blog/sidebar/archives', $vars);
}
diff --git a/mod/blog/views/default/blog/sidebar/archives.php b/mod/blog/views/default/blog/sidebar/archives.php
index 3aa3db44f..3d8f28ca4 100644
--- a/mod/blog/views/default/blog/sidebar/archives.php
+++ b/mod/blog/views/default/blog/sidebar/archives.php
@@ -6,6 +6,12 @@
$loggedin_user = elgg_get_logged_in_user_entity();
$page_owner = elgg_get_page_owner_entity();
+if (elgg_instanceof($page_owner, 'user')) {
+ $url_segment = 'blog/archive/' . $page_owner->username;
+} else {
+ $url_segment = 'blog/group/' . $page_owner->getGUID() . '/archive';
+}
+
// This is a limitation of the URL schema.
if ($page_owner && $vars['page'] != 'friends') {
$dates = get_entity_dates('object', 'blog', $page_owner->getGUID());
@@ -13,11 +19,11 @@ if ($page_owner && $vars['page'] != 'friends') {
if ($dates) {
$title = elgg_echo('blog:archives');
$content = '<ul class="blog-archives">';
- foreach($dates as $date) {
+ foreach ($dates as $date) {
$timestamplow = mktime(0, 0, 0, substr($date,4,2) , 1, substr($date, 0, 4));
$timestamphigh = mktime(0, 0, 0, ((int) substr($date, 4, 2)) + 1, 1, substr($date, 0, 4));
- $link = elgg_get_site_url() . 'blog/archive/' . $page_owner->username . '/' . $timestamplow . '/' . $timestamphigh;
+ $link = elgg_get_site_url() . $url_segment . '/' . $timestamplow . '/' . $timestamphigh;
$month = elgg_echo('date:month:' . substr($date, 4, 2), array(substr($date, 0, 4)));
$content .= "<li><a href=\"$link\" title=\"$month\">$month</a></li>";
}
diff --git a/mod/blog/views/default/object/blog.php b/mod/blog/views/default/object/blog.php
index 3525b3d48..4403a6006 100644
--- a/mod/blog/views/default/object/blog.php
+++ b/mod/blog/views/default/object/blog.php
@@ -16,6 +16,9 @@ $owner = $blog->getOwnerEntity();
$container = $blog->getContainerEntity();
$categories = elgg_view('output/categories', $vars);
$excerpt = $blog->excerpt;
+if (!$excerpt) {
+ $excerpt = elgg_get_excerpt($blog->description);
+}
$owner_icon = elgg_view_entity_icon($owner, 'tiny');
$owner_link = elgg_view('output/url', array(
@@ -24,7 +27,6 @@ $owner_link = elgg_view('output/url', array(
'is_trusted' => true,
));
$author_text = elgg_echo('byline', array($owner_link));
-$tags = elgg_view('output/tags', array('tags' => $blog->tags));
$date = elgg_view_friendly_time($blog->time_created);
// The "on" status changes for comments, so best to check for !Off
@@ -71,7 +73,6 @@ if ($full) {
'title' => false,
'metadata' => $metadata,
'subtitle' => $subtitle,
- 'tags' => $tags,
);
$params = $params + $vars;
$summary = elgg_view('object/elements/summary', $params);
@@ -89,7 +90,6 @@ if ($full) {
'entity' => $blog,
'metadata' => $metadata,
'subtitle' => $subtitle,
- 'tags' => $tags,
'content' => $excerpt,
);
$params = $params + $vars;