From 4766f36a4d74924f21ff329c4318ce4e069ffa04 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 3 Mar 2010 17:53:05 +0000 Subject: Pulled in the interface changes. git-svn-id: http://code.elgg.org/elgg/trunk@5257 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/pages/actions/pages/delete.php | 35 +++++++++ mod/pages/actions/pages/edit.php | 126 ++++++++++++++++++++++++++++++++ mod/pages/actions/pages/editwelcome.php | 77 +++++++++++++++++++ 3 files changed, 238 insertions(+) create mode 100644 mod/pages/actions/pages/delete.php create mode 100644 mod/pages/actions/pages/edit.php create mode 100644 mod/pages/actions/pages/editwelcome.php (limited to 'mod/pages/actions') diff --git a/mod/pages/actions/pages/delete.php b/mod/pages/actions/pages/delete.php new file mode 100644 index 000000000..740f1f6eb --- /dev/null +++ b/mod/pages/actions/pages/delete.php @@ -0,0 +1,35 @@ +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; + } + } + forward('pg/pages/owned/' . $_SESSION['user']->username); + exit; + } + + } + + } + + register_error(elgg_echo('pages:delete:failure')); + forward($_SERVER['HTTP_REFERER']); + +?> \ No newline at end of file diff --git a/mod/pages/actions/pages/edit.php b/mod/pages/actions/pages/edit.php new file mode 100644 index 000000000..84aed61d6 --- /dev/null +++ b/mod/pages/actions/pages/edit.php @@ -0,0 +1,126 @@ +pages as $shortname => $valuetype) { + $input[$shortname] = get_input($shortname); + 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; + } + + // 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) + { + 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); + + + 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; + } + else + register_error(elgg_echo('pages:notsaved')); + + } + else + { + register_error(elgg_echo("pages:noaccess")); + } + + + // 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 new file mode 100644 index 000000000..85d6e6138 --- /dev/null +++ b/mod/pages/actions/pages/editwelcome.php @@ -0,0 +1,77 @@ +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 { + 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; + +?> \ No newline at end of file -- cgit v1.2.3