aboutsummaryrefslogtreecommitdiff
path: root/mod/sitepages/actions/add.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-09 00:52:52 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-09 00:52:52 +0000
commit4e2a58e02ae4fe55ebc801a816c6ddb304df4b18 (patch)
treef958306f06db27bc2182f30356bead605b2d4b93 /mod/sitepages/actions/add.php
parent617ebb97d840cf77f3b483273f029732e8dc0db7 (diff)
downloadelgg-4e2a58e02ae4fe55ebc801a816c6ddb304df4b18.tar.gz
elgg-4e2a58e02ae4fe55ebc801a816c6ddb304df4b18.tar.bz2
Brought sitepages up to standards.
Added basic static keyword/view substitution support. git-svn-id: http://code.elgg.org/elgg/trunk@5312 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/sitepages/actions/add.php')
-rw-r--r--mod/sitepages/actions/add.php93
1 files changed, 41 insertions, 52 deletions
diff --git a/mod/sitepages/actions/add.php b/mod/sitepages/actions/add.php
index 3b7f4eb2d..bc38d8067 100644
--- a/mod/sitepages/actions/add.php
+++ b/mod/sitepages/actions/add.php
@@ -1,64 +1,53 @@
<?php
/**
- * Elgg external pages: add/edit
+ * Site pages save/edit
+ *
+ * @package SitePages
+ * @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.com/
+ *
*/
// Make sure we're logged as admin
admin_gatekeeper();
// Get input data
-$contents = get_input('sitepagescontent', '', false);
-$type = get_input('content_type');
-$tags = get_input('sitepagestags');
-$previous_guid = get_input('expage_guid');
+$content = get_input('sitepages_content', '', FALSE);
+$page_type = get_input('page_type');
+$tags = get_input('sitepages_tags');
+$tag_array = string_to_tag_array($tags);
-// Cache to the session
-$_SESSION['sitepages_content'] = $contents;
-$_SESSION['sitepagestype'] = $type;
-$_SESSION['sitepagestags'] = $tags;
-
-// Convert string of tags into a preformatted array
-$tagarray = string_to_tag_array($tags);
-
-// Make sure the content exists
-if (empty($contents)) {
- register_error(elgg_echo("sitepages:blank"));
- forward("mod/sitepages/add.php");
-
-// Otherwise, save the new external page
+// Cache to the session for sticky forms
+// @todo make these work.
+$_SESSION['sitepages_content'] = $content;
+$_SESSION['sitepages_type'] = $type;
+$_SESSION['sitepages_tags'] = $tags;
+
+if (!$sitepage = sitepages_get_sitepage_object($page_type)) {
+ $sitepage = sitepages_create_sitepage_object($page_type);
+}
+
+if (empty($content)) {
+ register_error(elgg_echo('sitepages:blank'));
} else {
- //remove the old external page
- if(get_entity($previous_guid)){
- delete_entity($previous_guid);
- }
-
- // Initialise a new ElggObject
- $sitepages = new ElggObject();
- // Tell the system what type of external page it is
- $sitepages->subtype = $type;
- // Set its owner to the current user
- $sitepages->owner_guid = $_SESSION['user']->getGUID();
- // For now, set its access to public
- $sitepages->access_id = 2;
- // Set its title and description appropriately
- $sitepages->title = $type;
- $sitepages->description = $contents;
- // Before we can set metadata, save
- if (!$sitepages->save()) {
- register_error(elgg_echo("sitepages:error"));
- forward("mod/sitepages/add.php");
- }
- // Now let's add tags. We can pass an array directly to the object property! Easy.
- if (is_array($tagarray)) {
- $sitepages->tags = $tagarray;
+ $sitepage->title = $type;
+ $sitepage->description = $content;
+ $sitepage->tags = $tag_array;
+
+ if (!$sitepage->save()) {
+ register_error(elgg_echo('sitepages:error'));
+ } else {
+ system_message(elgg_echo('sitepages:posted'));
+ // @todo this needs to be accurate for create or update.
+ add_to_river('river/sitepages/create', 'create', $_SESSION['user']->guid, $sitepages->guid);
}
- // Success message
- system_message(elgg_echo("sitepages:posted"));
- // add to river
- add_to_river('river/sitepages/create','create',$_SESSION['user']->guid,$sitepages->guid);
- // Remove the cache
- unset($_SESSION['sitepages_content']); unset($_SESSION['sitepagestitle']); unset($_SESSION['sitepagestags']);
-
- // Forward back to the page
- forward("pg/sitepages/index.php?type={$type}");
+
+ // @todo Good intensions...
+ unset($_SESSION['sitepages_content']);
+ unset($_SESSION['sitepagestitle']);
+ unset($_SESSION['sitepagestags']);
}
+
+forward($_SERVER['HTTP_REFERER']); \ No newline at end of file