aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-26 17:36:33 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-26 17:36:33 +0000
commit65b53458f584d3a4f6441f6c4ee353bccbd69ae2 (patch)
tree029201ec05ec04ac1735ebfd1751b14b122c5a0f /mod
parent1c3c87facfdc3b140ccfb6ff363a8e5469d9b16e (diff)
downloadelgg-65b53458f584d3a4f6441f6c4ee353bccbd69ae2.tar.gz
elgg-65b53458f584d3a4f6441f6c4ee353bccbd69ae2.tar.bz2
Bookmarks work with groups and use new style content header filter.
git-svn-id: http://code.elgg.org/elgg/trunk@5878 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod')
-rw-r--r--mod/bookmarks/add.php58
-rw-r--r--mod/bookmarks/all.php37
-rw-r--r--mod/bookmarks/friends.php34
-rw-r--r--mod/bookmarks/index.php60
-rw-r--r--mod/bookmarks/start.php199
5 files changed, 140 insertions, 248 deletions
diff --git a/mod/bookmarks/add.php b/mod/bookmarks/add.php
deleted file mode 100644
index 7fe6e8956..000000000
--- a/mod/bookmarks/add.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/**
- * Elgg bookmarks plugin add bookmark page
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-global $CONFIG;
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// You need to be logged in for this one
-gatekeeper();
-
-// Get the current page's owner
-$page_owner = page_owner_entity();
-if ($page_owner === false || is_null($page_owner)) {
- $page_owner = $_SESSION['user'];
- set_page_owner($page_owner->getGUID());
-}
-if ($page_owner instanceof ElggGroup)
- $container = $page_owner->guid;
-
-//set up breadcrumbs
-elgg_push_breadcrumb(elgg_echo('bookmarks:all'), $CONFIG->wwwroot."mod/bookmarks/all.php");
-elgg_push_breadcrumb(elgg_echo("bookmarks:add"));
-
-$area1 .= elgg_view('navigation/breadcrumbs');
-
-// get the filter menu
-$area1 .= elgg_view('page_elements/content_header', array('context' => "action", 'type' => 'bookmarks'));
-
-// If we've been given a bookmark to edit, grab it
-if ($this_guid = get_input('bookmark',0)) {
- $entity = get_entity($this_guid);
- if ($entity->canEdit()) {
- $area2 .= elgg_view('bookmarks/form',array('entity' => $entity, 'container_guid' => $container));
- }
-} else {
- $area2 .= elgg_view('bookmarks/form', array('container_guid' => $container));
-}
-
-$area3 = elgg_view('bookmarks/ownerblock');
-// include a view for plugins to extend
-$area3 .= elgg_view("bookmarks/sidebar", array("object_type" => 'bookmarks'));
-// if logged in, get the bookmarklet
-$area3 .= elgg_view("bookmarks/bookmarklet");
-
-// Format page
-$body = elgg_view_layout('one_column_with_sidebar', $area1.$area2, $area3);
-
-// Draw it
-echo page_draw(elgg_echo('bookmarks:add'),$body); \ No newline at end of file
diff --git a/mod/bookmarks/all.php b/mod/bookmarks/all.php
deleted file mode 100644
index 87dd5f852..000000000
--- a/mod/bookmarks/all.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-/**
- * Elgg bookmarks plugin everyone page
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// get the filter menu
-$area1 = elgg_view('page_elements/content_header', array('context' => "everyone", 'type' => 'bookmarks'));
-
-// List bookmarks
-set_context('search');
-$area2 .= elgg_list_entities(array('type' => 'object', 'subtype' => 'bookmarks'));
-set_context('bookmarks');
-
-// include a view for plugins to extend
-$area3 = elgg_view("bookmarks/sidebar", array("object_type" => 'bookmarks'));
-
-// if logged in, get the bookmarklet
-if(isloggedin()){
- $area3 .= elgg_view("bookmarks/bookmarklet");
-}
-// include statistics
-$count = elgg_get_entities(array('type' => 'object', 'subtype' => 'bookmarks', 'count' => true));
-$area3 .= elgg_view("bookmarks/stats", array('count' => $count));
-// Format page
-$body = elgg_view_layout('one_column_with_sidebar', $area1.$area2, $area3);
-
-// Draw it
-echo page_draw(elgg_echo('bookmarks:all'),$body); \ No newline at end of file
diff --git a/mod/bookmarks/friends.php b/mod/bookmarks/friends.php
deleted file mode 100644
index 158108553..000000000
--- a/mod/bookmarks/friends.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * Elgg bookmarks plugin friends' page
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// get the filter menu
-$area1 = elgg_view("page_elements/content_header", array('context' => "friends", 'type' => 'bookmarks'));
-
-// List bookmarks
-set_context('search');
-$area2 .= list_user_friends_objects(page_owner(),'bookmarks',10,false,false);
-set_context('bookmarks');
-
-// include a view for plugins to extend
-$area3 = elgg_view("bookmarks/sidebar", array("object_type" => 'bookmarks'));
-
-// if logged in, get the bookmarklet
-if(isloggedin()){
- $area3 .= elgg_view("bookmarks/bookmarklet");
-}
-// Format page
-$body = elgg_view_layout('one_column_with_sidebar', $area1.$area2, $area3);
-
-// Draw it
-echo page_draw(elgg_echo('bookmarks:friends'),$body); \ No newline at end of file
diff --git a/mod/bookmarks/index.php b/mod/bookmarks/index.php
deleted file mode 100644
index 21166f7a9..000000000
--- a/mod/bookmarks/index.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-/**
- * Elgg bookmarks plugin index page
- *
- * @package ElggBookmarks
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-global $CONFIG;
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// access check for closed groups
-group_gatekeeper();
-
-$page_owner = page_owner_entity();
-if ($page_owner === false || is_null($page_owner)) {
- $page_owner = $_SESSION['user'];
- set_page_owner($page_owner->getGUID());
-}
-
-elgg_push_breadcrumb(elgg_echo('bookmarks:all'), $CONFIG->wwwroot."mod/bookmarks/all.php");
-elgg_push_breadcrumb(sprintf(elgg_echo("bookmarks:user"),$page_owner->name));
-
-//set bookmarks header
-if(page_owner() == get_loggedin_userid()) {
- $area1 .= elgg_view('page_elements/content_header', array('context' => "mine", 'type' => 'bookmarks'));
-} else {
- $area1 .= elgg_view('navigation/breadcrumbs');
- $area1 .= elgg_view('page_elements/content_header_member', array('type' => 'bookmarks'));
-}
-
-// List bookmarks
-set_context('search');
-$bookmarks = elgg_list_entities(array('type' => 'object', 'subtype' => 'bookmarks', 'owner_guid' => page_owner()));
-if(!$bookmarks && ($page_owner->guid == get_loggedin_user()->guid))
- $bookmarks = elgg_view('help/bookmarks');
-$area2 .= $bookmarks;
-set_context('bookmarks');
-
-//if the logged in user is not looking at their stuff, display the ownerblock
-if(page_owner() != get_loggedin_user()->guid){
- $area3 = elgg_view('bookmarks/ownerblock');
-}
-// include a view for plugins to extend
-$area3 .= elgg_view("bookmarks/sidebar", array("object_type" => 'bookmarks'));
-
-if(isloggedin()){
- // if logged in, get the bookmarklet
- $area3 .= elgg_view("bookmarks/bookmarklet");
-}
-// Format page
-$body = elgg_view_layout('one_column_with_sidebar', $area1.$area2, $area3);
-
-// Draw it
-echo page_draw(sprintf(elgg_echo("bookmarks:user"),page_owner_entity()->name), $body); \ No newline at end of file
diff --git a/mod/bookmarks/start.php b/mod/bookmarks/start.php
index c37899034..ec1fb1c3a 100644
--- a/mod/bookmarks/start.php
+++ b/mod/bookmarks/start.php
@@ -15,7 +15,7 @@ function bookmarks_init() {
global $CONFIG;
//add a tools menu option
- add_menu(elgg_echo('bookmarks'), $CONFIG->wwwroot . 'mod/bookmarks/all.php');
+ add_menu(elgg_echo('bookmarks'), $CONFIG->wwwroot . 'pg/bookmarks');
// Register a page handler, so we can have nice URLs
register_page_handler('bookmarks', 'bookmarks_page_handler');
@@ -42,10 +42,9 @@ function bookmarks_init() {
// Add group menu option
add_group_tool_option('bookmarks',elgg_echo('bookmarks:enablebookmarks'),true);
-
- // Extend Groups profile page
- elgg_extend_view('groups/tool_latest','bookmarks/group_bookmarks');
+ // Extend Groups profile page
+ elgg_extend_view('groups/tool_latest','bookmarks/group_bookmarks');
}
/**
@@ -55,88 +54,170 @@ function bookmarks_init() {
function bookmarks_pagesetup() {
global $CONFIG;
- // Set up menu for logged in users
- // add submenu options - @todo partially removed - now provided by drop-down menu filter in content area
- if (get_context() == "bookmarks") {
-/*
- if (isloggedin()) {
- if (page_owner()) {
- $page_owner = page_owner_entity();
- add_submenu_item(elgg_echo('bookmarks:read'),$CONFIG->wwwroot."pg/bookmarks/" . $page_owner->username . "/items");
- }
- if(!$page_owner instanceof ElggGroup)
- add_submenu_item(elgg_echo('bookmarks:friends'),$CONFIG->wwwroot."pg/bookmarks/" . $_SESSION['user']->username . "/friends");
- }
-
- if(!$page_owner instanceof ElggGroup)
- add_submenu_item(elgg_echo('bookmarks:everyone'),$CONFIG->wwwroot."mod/bookmarks/everyone.php");
-*/
-
- // Bookmarklet
- if ((isloggedin()) && (page_owner()) && (can_write_to_container(0, page_owner()))) {
- $page_owner = page_owner_entity();
- $bmtext = elgg_echo('bookmarks:bookmarklet');
- if ($page_owner instanceof ElggGroup)
- $bmtext = elgg_echo('bookmarks:bookmarklet:group');
- // add_submenu_item($bmtext, $CONFIG->wwwroot . "pg/bookmarks/{$page_owner->username}/bookmarklet");
- }
- }
-
- $page_owner = page_owner_entity();
+ $page_owner = page_owner_entity();
+ // Add group bookmark menu item
+ if (isloggedin()) {
if ($page_owner instanceof ElggGroup && get_context() == 'groups') {
- if($page_owner->bookmarks_enable != "no"){
- add_submenu_item(sprintf(elgg_echo("bookmarks:group"),$page_owner->name), $CONFIG->wwwroot . "pg/bookmarks/" . $page_owner->username . '/items');
+ if ($page_owner->bookmarks_enable != "no") {
+ add_submenu_item(sprintf(elgg_echo("bookmarks:group"),$page_owner->name), $CONFIG->wwwroot . "pg/bookmarks/" . $page_owner->username . '/items');
+ }
}
}
}
/**
- * Bookmarks page handler; allows the use of fancy URLs
+ * Bookmarks page handler
+ * Expects URLs like:
+ * pg/bookmarks/username/[friends||items||add||edit||bookmarklet]
+ *
*
* @param array $page From the page_handler function
* @return true|false Depending on success
*/
function bookmarks_page_handler($page) {
+ global $CONFIG;
// The first component of a bookmarks URL is the username
+ // If the username is set_input()'d and has group:NN in it, magic happens
+ // and the page_owner_entity() is the group.
if (isset($page[0])) {
- set_input('username',$page[0]);
+ $owner_name = $page[0];
+ set_input('username', $owner_name);
+
+ // grab the page owner here so the group magic works.
+ $owner = page_owner_entity();
}
- // The second part dictates what we're doing
- if (isset($page[1])) {
- switch($page[1]) {
- case "friends":
- include(dirname(__FILE__) . "/friends.php");
- return true;
+ // owner name passed but invalid.
+ if ($owner_name && !$owner) {
+ $sidebar = elgg_view('bookmarks/sidebar', array('object_type' => 'bookmarks'));
+ $content = elgg_echo("bookmarks:unknown_user");
+
+ $body = elgg_view_layout('one_column_with_sidebar', $content, $sidebar);
+ echo page_draw(sprintf(elgg_echo("bookmarks:user"), page_owner_entity()->name), $body);
+
+ return FALSE;
+ }
+
+ $logged_in_user = get_loggedin_user();
+ $section = (isset($page[1])) ? $page[1] : $section = 'items';
+
+ elgg_push_breadcrumb(elgg_echo('bookmarks:all'), $CONFIG->wwwroot . 'pg/bookmarks/');
+
+ if ($owner) {
+ switch($section) {
+ case 'friends':
+ elgg_push_breadcrumb(sprintf(elgg_echo('bookmarks:friends'), $owner->name));
+
+ $content = list_user_friends_objects($owner->getGUID(), 'bookmarks', 10, false, false);
+ $context = ($owner == $logged_in_user) ? 'friends' : '';
break;
- case "items":
- include(dirname(__FILE__) . "/index.php");
- return true;
+
+ default:
+ case 'items':
+ elgg_push_breadcrumb(sprintf(elgg_echo('bookmarks:user'), $owner->name));
+
+ group_gatekeeper();
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'bookmarks'
+ );
+
+ if ($owner instanceof ElggGroup) {
+ $options['container_guid'] = $owner->getGUID();
+ } else {
+ $options['owner_guid'] = $owner->getGUID();
+ }
+
+ $content = elgg_list_entities($options);
+
+ if (!$content && ($owner == $logged_in_user)) {
+ $content = elgg_view('help/bookmarks');
+ }
+
+ $context = ($owner == $logged_in_user) ? 'mine' : '';
break;
- case "add":
- include(dirname(__FILE__) . "/add.php");
- return true;
+
+ case 'add':
+ gatekeeper();
+ elgg_push_breadcrumb(elgg_echo('bookmarks:add'));
+
+ $vars = array();
+ if ($owner instanceof ElggGroup) {
+ $vars['container_guid'] = $owner->getGUID();
+ }
+
+ $context = 'action';
+ $content = elgg_view('bookmarks/form', $vars);
break;
- case "edit":
- set_input('bookmark',$page[2]);
- include(dirname(__FILE__) . "/add.php");
- return true;
+
+ case 'edit':
+ gatekeeper();
+
+ elgg_push_breadcrumb(elgg_echo('bookmarks:edit'));
+
+ $vars = array();
+ // this will never be the case.
+ if ($owner instanceof ElggGroup) {
+ $vars['container_guid'] = $owner->getGUID();
+ }
+
+ $bookmark = (isset($page[2])) ? get_entity($page[2]) : FALSE;
+
+ if ($bookmark && elgg_instanceof($bookmark, 'object', 'bookmarks') && $bookmark->canEdit()) {
+ $vars['entity'] = $bookmark;
+ $content = elgg_view('bookmarks/form', $vars);
+ } else {
+ $content = elgg_echo('bookmarks:cannot_find_bookmark');
+ }
+
break;
- case "bookmarklet":
- include(dirname(__FILE__) . "/bookmarklet.php");
- return true;
+
+ // I don't think this is used.
+ case 'bookmarklet':
+ gatekeeper();
+
+ $content = elgg_view_title(elgg_echo('bookmarks:bookmarklet'));
+ $content .= elgg_view('bookmarks/bookmarklet', array('pg_owner' => $owner));
+
break;
}
- // If the URL is just 'bookmarks/username', or just 'bookmarks/', load the standard bookmarks index
+
} else {
- include(dirname(__FILE__) . "/index.php");
- return true;
+ // no owner name passed, show everything.
+ $content = elgg_list_entities(array('type' => 'object', 'subtype' => 'bookmarks'));
+ $context = 'everyone';
}
- return false;
+ // sidebar
+ if ($logged_in_user != $owner) {
+ $area3 = elgg_view('bookmarks/ownerblock');
+ }
+
+ $sidebar = elgg_view('bookmarks/sidebar', array('object_type' => 'bookmarks'));
+
+ if (isloggedin()){
+ $sidebar .= elgg_view('bookmarks/bookmarklet');
+ }
+
+ // main content
+ if ($owner != $logged_in_user || $context == 'action') {
+ $header = elgg_view('navigation/breadcrumbs');
+ }
+
+ $header .= elgg_view("page_elements/content_header", array(
+ 'context' => $context,
+ 'type' => 'bookmarks',
+ 'all_link' => "{$CONFIG->url}pg/bookmarks/",
+ 'new_link' => "{$CONFIG->url}pg/bookmarks/{$owner_name}/add"
+ ));
+
+ $content = $header . $content;
+ $body = elgg_view_layout('one_column_with_sidebar', $content, $sidebar);
+ echo page_draw(sprintf(elgg_echo("bookmarks:user"), page_owner_entity()->name), $body);
+ return TRUE;
}
/**