From 4e2a58e02ae4fe55ebc801a816c6ddb304df4b18 Mon Sep 17 00:00:00 2001 From: brettp Date: Tue, 9 Mar 2010 00:52:52 +0000 Subject: 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 --- mod/sitepages/actions/addfront.php | 66 ++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 39 deletions(-) (limited to 'mod/sitepages/actions/addfront.php') diff --git a/mod/sitepages/actions/addfront.php b/mod/sitepages/actions/addfront.php index 5a86189db..6b8782da7 100644 --- a/mod/sitepages/actions/addfront.php +++ b/mod/sitepages/actions/addfront.php @@ -1,51 +1,39 @@ + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + * */ -// Make sure we're logged as admin admin_gatekeeper(); -// Get input data -$frontContents = get_input('frontContents'); -$css = get_input('css'); -$previous_guid = get_input('front_guid'); - -//remove the old front page -if(get_entity($previous_guid)){ - delete_entity($previous_guid); +$content = get_input('sitepages_content', '', FALSE); +$css = get_input('css', '', FALSE); +$loggedin_user_guid = get_loggedin_userid(); + +// Cache to the session for sticky forms +// @todo does nothing yet. +$_SESSION['sitepages:content'] = $content; +$_SESSION['sitepages:css'] = $css; + +if (!$sitepage = sitepages_get_sitepage_object('front')) { + $sitepage = sitepages_create_sitepage_object('front'); } -//var_export($pageshell);exit; +$sitepage->title = $css; +$sitepage->description = $content; -// Cache to the session -$_SESSION['pageshell'] = $pageshell; -$_SESSION['css'] = $css; - -// Initialise a new ElggObject -$frontpage = new ElggObject(); -// Tell the system what type of external page it is -$frontpage->subtype = "frontpage"; -// Set its owner to the current user -$frontpage->owner_guid = $_SESSION['user']->getGUID(); -// Set its access to public -$frontpage->access_id = 2; -// Set its title and description appropriately -$frontpage->title = $css; -$frontpage->description = $frontContents; - -// Before we can set metadata, save -if (!$frontpage->save()) { +if ($sitepage->save()) { + system_message(elgg_echo("sitepages:posted")); + unset($_SESSION['sitepages:content']); + unset($_SESSION['sitepages:css']); +} else { register_error(elgg_echo("sitepages:error")); - forward("pg/sitepages/index.php?type=front"); } -// Success message -system_message(elgg_echo("sitepages:posted")); - -// Remove the cache -unset($_SESSION['css']); unset($_SESSION['pageshell']); - - -// Forward back to the page -forward("pg/sitepages/index.php?type=front"); +forward($_SERVER['HTTP_REFERER']); \ No newline at end of file -- cgit v1.2.3