aboutsummaryrefslogtreecommitdiff
path: root/mod/pages/actions
diff options
context:
space:
mode:
Diffstat (limited to 'mod/pages/actions')
-rw-r--r--mod/pages/actions/pages/delete.php59
-rw-r--r--mod/pages/actions/pages/edit.php252
-rw-r--r--mod/pages/actions/pages/editwelcome.php130
3 files changed, 213 insertions, 228 deletions
diff --git a/mod/pages/actions/pages/delete.php b/mod/pages/actions/pages/delete.php
index 8bda9e794..1ce30472c 100644
--- a/mod/pages/actions/pages/delete.php
+++ b/mod/pages/actions/pages/delete.php
@@ -1,35 +1,38 @@
<?php
+/**
+ * Remove a page
+ *
+ * @package ElggPages
+ */
- $page = get_input('page');
-
- if ($page = get_entity($page)) {
-
- if ($page->canEdit()) {
-
- // Bring all child elements forward
- $parent = $page->parent_guid;
- if ($children = elgg_get_entities_from_metadata(array('metadata_name' => 'parent_guid', 'metadata_value' => $page->getGUID()))) {
- foreach($children as $child) {
- $child->parent_guid = $parent;
- }
+$page = get_input('page');
+
+if ($page = get_entity($page)) {
+
+ if ($page->canEdit()) {
+
+ // Bring all child elements forward
+ $parent = $page->parent_guid;
+ if ($children = elgg_get_entities_from_metadata(array('metadata_name' => 'parent_guid', 'metadata_value' => $page->getGUID()))) {
+ foreach($children as $child) {
+ $child->parent_guid = $parent;
}
- if ($page->delete()) {
- system_message(elgg_echo('pages:delete:success'));
- if ($parent) {
- if ($parent = get_entity($parent)) {
- forward($parent->getURL());
- exit;
- }
+ }
+ if ($page->delete()) {
+ system_message(elgg_echo('pages:delete:success'));
+ if ($parent) {
+ if ($parent = get_entity($parent)) {
+ forward($parent->getURL());
+ exit;
}
- forward('pg/pages/owned/' . $_SESSION['user']->username);
- exit;
}
-
- }
-
+ forward('pg/pages/owned/' . $_SESSION['user']->username);
+ exit;
+ }
+
}
-
- register_error(elgg_echo('pages:delete:failure'));
- forward($_SERVER['HTTP_REFERER']);
-?>
+}
+
+register_error(elgg_echo('pages:delete:failure'));
+forward($_SERVER['HTTP_REFERER']);
diff --git a/mod/pages/actions/pages/edit.php b/mod/pages/actions/pages/edit.php
index ba6d0acdc..c4075a7bb 100644
--- a/mod/pages/actions/pages/edit.php
+++ b/mod/pages/actions/pages/edit.php
@@ -1,141 +1,137 @@
<?php
- /**
- * Elgg Pages
- *
- * @package ElggPages
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.com/
- */
-
- // Load configuration
- global $CONFIG;
-
- gatekeeper();
- set_context('pages');
-
- //boolean to select correct add to river. It will be new or edit
- $which_river = 'new';
-
- // Get group fields
- $input = array();
- foreach($CONFIG->pages as $shortname => $valuetype) {
- $input[$shortname] = get_input($shortname);
- if ($shortname == 'title') {
- $input[$shortname] = strip_tags($input[$shortname]);
- }
- if ($valuetype == 'tags')
- $input[$shortname] = string_to_tag_array($input[$shortname]);
+/**
+ * Edit a page
+ *
+ * @package ElggPages
+ */
+
+// Load configuration
+global $CONFIG;
+
+gatekeeper();
+set_context('pages');
+
+//boolean to select correct add to river. It will be new or edit
+$which_river = 'new';
+
+// Get group fields
+$input = array();
+foreach($CONFIG->pages as $shortname => $valuetype) {
+ $input[$shortname] = get_input($shortname);
+ if ($shortname == 'title') {
+ $input[$shortname] = strip_tags($input[$shortname]);
}
-
- // Get parent
- $parent_guid = (int)get_input('parent_guid', 0);
-
- // New or old?
- $page = NULL;
- $pages_guid = (int)get_input('pages_guid');
- if ($pages_guid)
+ if ($valuetype == 'tags')
+ $input[$shortname] = string_to_tag_array($input[$shortname]);
+}
+
+// Get parent
+$parent_guid = (int)get_input('parent_guid', 0);
+
+// New or old?
+$page = NULL;
+$pages_guid = (int)get_input('pages_guid');
+if ($pages_guid)
+{
+ $page = get_entity($pages_guid);
+ if (!$page->canEdit())
+ $page = NULL; // if we can't edit it, go no further.
+
+ //select river boolean to edit
+ $which_river = 'edit';
+}
+else
+{
+ $page = new ElggObject();
+ if (!$parent_guid)
+ $page->subtype = 'page_top';
+ else
+ $page->subtype = 'page';
+
+ // New instance, so set container_guid
+ $container_guid = get_input('container_guid', $_SESSION['user']->getGUID());
+ $page->container_guid = $container_guid;
+
+ // cache data in session in case data from form does not validate
+ $_SESSION['page_description'] = $input['description'];
+ $_SESSION['page_tags'] = get_input('tags');
+ $_SESSION['page_read_access'] = (int)get_input('access_id');
+ $_SESSION['page_write_access'] = (int)get_input('write_access_id');
+}
+
+// Have we got it? Can we edit it?
+if ($page instanceof ElggObject)
+{
+ // Yes we have, and yes we can.
+
+ // Save fields - note we always save latest description as both description and annotation
+ if (sizeof($input) > 0)
{
- $page = get_entity($pages_guid);
- if (!$page->canEdit())
- $page = NULL; // if we can't edit it, go no further.
-
- //select river boolean to edit
- $which_river = 'edit';
+ foreach($input as $shortname => $value) {
+ if ((!$pages_guid) || (($pages_guid) && ($shortname != 'title')))
+ $page->$shortname = $value;
+ }
}
- else
+
+
+ // Validate create
+ if (!$page->title)
{
- $page = new ElggObject();
- if (!$parent_guid)
- $page->subtype = 'page_top';
- else
- $page->subtype = 'page';
-
- // New instance, so set container_guid
- $container_guid = get_input('container_guid', $_SESSION['user']->getGUID());
- $page->container_guid = $container_guid;
-
- // cache data in session in case data from form does not validate
- $_SESSION['page_description'] = $input['description'];
- $_SESSION['page_tags'] = get_input('tags');
- $_SESSION['page_read_access'] = (int)get_input('access_id');
- $_SESSION['page_write_access'] = (int)get_input('write_access_id');
+ register_error(elgg_echo("pages:notitle"));
+
+ forward($_SERVER['HTTP_REFERER']);
+ exit;
}
-
- // Have we got it? Can we edit it?
- if ($page instanceof ElggObject)
+
+ // Access ids
+ $page->access_id = (int)get_input('access_id', ACCESS_PRIVATE);
+
+ // Write access id
+ $page->write_access_id = (int)get_input('write_access_id', ACCESS_PRIVATE);
+
+ // Set parent
+ $page->parent_guid = $parent_guid;
+
+ // Ensure ultimate owner
+ $page->owner_guid = ($page->owner_guid ? $page->owner_guid : $_SESSION['user']->guid);
+
+ // finally save
+ if ($page->save())
{
- // Yes we have, and yes we can.
-
- // Save fields - note we always save latest description as both description and annotation
- if (sizeof($input) > 0)
- {
- foreach($input as $shortname => $value) {
- if ((!$pages_guid) || (($pages_guid) && ($shortname != 'title')))
- $page->$shortname = $value;
- }
- }
-
-
- // Validate create
- if (!$page->title)
- {
- register_error(elgg_echo("pages:notitle"));
-
- forward($_SERVER['HTTP_REFERER']);
- exit;
- }
-
- // Access ids
- $page->access_id = (int)get_input('access_id', ACCESS_PRIVATE);
-
- // Write access id
- $page->write_access_id = (int)get_input('write_access_id', ACCESS_PRIVATE);
-
- // Set parent
- $page->parent_guid = $parent_guid;
-
- // Ensure ultimate owner
- $page->owner_guid = ($page->owner_guid ? $page->owner_guid : $_SESSION['user']->guid);
-
- // finally save
- if ($page->save())
- {
-
- // Now save description as an annotation
- $page->annotate('page', $page->description, $page->access_id);
-
- // clear cache
- unset($_SESSION['page_description']);
- unset($_SESSION['page_tags']);
- unset($_SESSION['page_read_access']);
- unset($_SESSION['page_write_access']);
-
-
- system_message(elgg_echo("pages:saved"));
-
- //add to river
- if($which_river == 'new')
- add_to_river('river/object/page/create','create',$_SESSION['user']->guid,$page->guid);
- else
- add_to_river('river/object/page/update','update',$_SESSION['user']->guid,$page->guid);
-
- // Forward to the user's profile
- forward($page->getUrl());
- exit;
- }
+
+ // Now save description as an annotation
+ $page->annotate('page', $page->description, $page->access_id);
+
+ // clear cache
+ unset($_SESSION['page_description']);
+ unset($_SESSION['page_tags']);
+ unset($_SESSION['page_read_access']);
+ unset($_SESSION['page_write_access']);
+
+
+ system_message(elgg_echo("pages:saved"));
+
+ //add to river
+ if($which_river == 'new')
+ add_to_river('river/object/page/create','create',$_SESSION['user']->guid,$page->guid);
else
- register_error(elgg_echo('pages:notsaved'));
+ add_to_river('river/object/page/update','update',$_SESSION['user']->guid,$page->guid);
+ // Forward to the user's profile
+ forward($page->getUrl());
+ exit;
}
else
- {
- register_error(elgg_echo("pages:noaccess"));
- }
-
+ register_error(elgg_echo('pages:notsaved'));
+
+}
+else
+{
+ register_error(elgg_echo("pages:noaccess"));
+}
+
- // Forward to the user's profile
- forward($page->getUrl());
- exit;
+// Forward to the user's profile
+forward($page->getUrl());
+exit;
?>
diff --git a/mod/pages/actions/pages/editwelcome.php b/mod/pages/actions/pages/editwelcome.php
index 5d29a5fd9..dd832cb28 100644
--- a/mod/pages/actions/pages/editwelcome.php
+++ b/mod/pages/actions/pages/editwelcome.php
@@ -1,77 +1,63 @@
<?php
- /**
- * Elgg Pages Edit welcome message
- *
- * @package ElggPages
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.com/
- */
+/**
+ * Elgg Pages Edit welcome message
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ */
- // Load configuration
- global $CONFIG;
-
- gatekeeper();
+// Load configuration
+global $CONFIG;
- // Get group fields
- $message = get_input("pages_welcome");
- $owner_guid = get_input("owner_guid");
- $object_guid = get_input("object_guid");
- $access_id = (int) get_input("access_id");
-
- //check to see if this is an edit or new welcome message
- if($object_guid){
-
- //it is an edit so grab the object
- $welcome = get_entity($object_guid);
- if ($welcome->getSubtype() == "pages_welcome" && $welcome->canEdit()) {
-
- $welcome->description = $message;
- $welcome->access_id = $access_id;
- $welcome->save();
- system_message(elgg_echo("pages:welcomeposted"));
-
+gatekeeper();
+
+// Get group fields
+$message = get_input("pages_welcome");
+$owner_guid = get_input("owner_guid");
+$object_guid = get_input("object_guid");
+$access_id = (int) get_input("access_id");
+
+//check to see if this is an edit or new welcome message
+if($object_guid){
+
+ //it is an edit so grab the object
+ $welcome = get_entity($object_guid);
+ if ($welcome->getSubtype() == "pages_welcome" && $welcome->canEdit()) {
+
+ $welcome->description = $message;
+ $welcome->access_id = $access_id;
+ $welcome->save();
+ system_message(elgg_echo("pages:welcomeposted"));
+
+ } else {
+ register_error(elgg_echo("pages:welcomeerror"));
+ }
+} else {
+ //it is a new welcome object
+ if ($owner_guid) {
+ $welcome = new ElggObject();
+ // Tell the system it's a pages welcome message
+ $welcome->subtype = "pages_welcome";
+ $welcome->title = "Welcome";
+ $welcome->description = $message;
+ $welcome->access_id = $access_id;
+
+ // Set the owner
+ $welcome->owner_guid = $owner_guid;
+
+ // save
+ if (!$welcome->save()){
+ register_error(elgg_echo("pages:welcomeerror"));
} else {
-
- register_error(elgg_echo("pages:welcomeerror"));
-
+ system_message(elgg_echo("pages:welcomeposted"));
}
-
-
- }else{
-
- //it is a new welcome object
- if ($owner_guid){
-
- $welcome = new ElggObject();
- // Tell the system it's a pages welcome message
- $welcome->subtype = "pages_welcome";
- $welcome->title = "Welcome";
- $welcome->description = $message;
- $welcome->access_id = $access_id;
-
- // Set the owner
- $welcome->owner_guid = $owner_guid;
-
- // save
- if (!$welcome->save()){
- register_error(elgg_echo("pages:welcomeerror"));
- } else {
- system_message(elgg_echo("pages:welcomeposted"));
- }
-
-
- } else {
-
- register_error(elgg_echo("pages:welcomeerror"));
-
- }
-
- }//end of first if statement
-
- // Forward to the main blog page
- forward("pg/pages/owned/" . get_user($owner_guid)->username);
- exit;
-
-?>
+ } else {
+ register_error(elgg_echo("pages:welcomeerror"));
+ }
+}
+
+// Forward to the main blog page
+forward("pg/pages/owned/" . get_user($owner_guid)->username); \ No newline at end of file