diff options
author | Sem <sembrestels@riseup.net> | 2012-01-12 16:15:16 +0100 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2012-01-12 16:15:16 +0100 |
commit | cc544cfa2086e418318a899ffd550adfb744c7ba (patch) | |
tree | 6c04fbe2e3df67513aa76803cb8d05c105ba219b /mod/blog | |
parent | e7d64510ebd823f186282e2b80780295bcca1b79 (diff) | |
parent | 68e4829ac0959d86c651e7ed6dc255c39694c8af (diff) | |
download | elgg-cc544cfa2086e418318a899ffd550adfb744c7ba.tar.gz elgg-cc544cfa2086e418318a899ffd550adfb744c7ba.tar.bz2 |
Merge Elgg 1.8.3.
Diffstat (limited to 'mod/blog')
-rw-r--r-- | mod/blog/actions/blog/save.php | 6 | ||||
-rw-r--r-- | mod/blog/classes/ElggBlog.php | 4 | ||||
-rw-r--r-- | mod/blog/lib/blog.php | 13 | ||||
-rw-r--r-- | mod/blog/start.php | 26 | ||||
-rw-r--r-- | mod/blog/views/default/blog/group_module.php | 3 | ||||
-rw-r--r-- | mod/blog/views/default/blog/sidebar.php | 2 | ||||
-rw-r--r-- | mod/blog/views/default/blog/sidebar/archives.php | 10 | ||||
-rw-r--r-- | mod/blog/views/default/object/blog.php | 3 |
8 files changed, 35 insertions, 32 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/lib/blog.php b/mod/blog/lib/blog.php index 590547a8c..286fe1832 100644 --- a/mod/blog/lib/blog.php +++ b/mod/blog/lib/blog.php @@ -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..a8553b4b8 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -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(); @@ -234,7 +239,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 +248,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..aa8074a69 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( |