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/addmeta.php | 59 +++++++++++++++------------------------ 1 file changed, 23 insertions(+), 36 deletions(-) (limited to 'mod/sitepages/actions/addmeta.php') diff --git a/mod/sitepages/actions/addmeta.php b/mod/sitepages/actions/addmeta.php index 432152ef1..e9f40cdb4 100644 --- a/mod/sitepages/actions/addmeta.php +++ b/mod/sitepages/actions/addmeta.php @@ -1,49 +1,36 @@ + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + * */ -// Make sure we're logged as admin admin_gatekeeper(); -// Get input data -$description = get_input('description', '', false); -$metatags = get_input('metatags', '', false); -$previous_guid = get_input('seo_guid'); - -//remove the old front page -if(get_entity($previous_guid)){ - delete_entity($previous_guid); -} +$description = get_input('description', '', FALSE); +$metatags = get_input('metatags', '', FALSE); // Cache to the session $_SESSION['description'] = $description; $_SESSION['metatags'] = $metatags; - -// Initialise a new ElggObject -$seo = new ElggObject(); -// Tell the system what type of external page it is -$seo->subtype = "sitemeta"; -// Set its owner to the current user -$seo->owner_guid = $_SESSION['user']->getGUID(); -// Set its access to public -$seo->access_id = 2; -// Set its title and description appropriately -$seo->title = $metatags; -$seo->description = $description; - -// Before we can set metadata, save -if (!$seo->save()) { - register_error(elgg_echo("sitepages:error")); - forward("pg/sitepages/index.php?type=seo"); + +if (!$sitepage = sitepages_get_sitepage_object('front')) { + $sitepage = sitepages_create_sitepage_object('front'); } -// Success message -system_message(elgg_echo("sitepages:seocreated")); +$sitepage->title = $metatags; +$sitepage->description = $description; + +if ($sitepage->save()) { + system_message(elgg_echo("sitepages:seocreated")); + unset($_SESSION['description']); unset($_SESSION['metatags']); +} else { + register_error(elgg_echo("sitepages:error")); +} -// Remove the cache -unset($_SESSION['description']); unset($_SESSION['metatags']); - - -// Forward back to the page -forward("pg/sitepages/index.php?type=seo"); +forward($_SERVER['HTTP_REFERER']); \ No newline at end of file -- cgit v1.2.3