[geeklog-cvs] geeklog: If a static page does not exist and the user has static...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Nov 29 11:55:06 EST 2009
changeset 7496:59e9aa23b118
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/59e9aa23b118
user: Dirk Haun <dirk at haun-online.de>
date: Sun Nov 29 17:15:16 2009 +0100
description:
If a static page does not exist and the user has staticpages.edit rights, send them to the Static Page Editor (feature request #0000975)
diffstat:
plugins/staticpages/language/english.php | 1 +
plugins/staticpages/language/english_utf-8.php | 1 +
plugins/staticpages/services.inc.php | 88 ++++++++++++++++++-----------
public_html/admin/plugins/staticpages/index.php | 11 +++-
public_html/docs/history | 2 +
5 files changed, 69 insertions(+), 34 deletions(-)
diffs (156 lines):
diff -r 5efbfc846ad1 -r 59e9aa23b118 plugins/staticpages/language/english.php
--- a/plugins/staticpages/language/english.php Sun Nov 29 13:35:24 2009 +0100
+++ b/plugins/staticpages/language/english.php Sun Nov 29 17:15:16 2009 +0100
@@ -116,6 +116,7 @@
$PLG_staticpages_MESSAGE15 = 'Your comment has been submitted for review and will be published when approved by a moderator.';
$PLG_staticpages_MESSAGE19 = 'Your page has been successfully saved.';
$PLG_staticpages_MESSAGE20 = 'Your page has been successfully deleted.';
+$PLG_staticpages_MESSAGE21 = 'This page does not exist yet. To create the page, please fill in the form below. If you are here by mistake, click the Cancel button.';
// Messages for the plugin upgrade
$PLG_staticpages_MESSAGE3001 = 'Plugin upgrade not supported.';
diff -r 5efbfc846ad1 -r 59e9aa23b118 plugins/staticpages/language/english_utf-8.php
--- a/plugins/staticpages/language/english_utf-8.php Sun Nov 29 13:35:24 2009 +0100
+++ b/plugins/staticpages/language/english_utf-8.php Sun Nov 29 17:15:16 2009 +0100
@@ -116,6 +116,7 @@
$PLG_staticpages_MESSAGE15 = 'Your comment has been submitted for review and will be published when approved by a moderator.';
$PLG_staticpages_MESSAGE19 = 'Your page has been successfully saved.';
$PLG_staticpages_MESSAGE20 = 'Your page has been successfully deleted.';
+$PLG_staticpages_MESSAGE21 = 'This page does not exist yet. To create the page, please fill in the form below. If you are here by mistake, click the Cancel button.';
// Messages for the plugin upgrade
$PLG_staticpages_MESSAGE3001 = 'Plugin upgrade not supported.';
diff -r 5efbfc846ad1 -r 59e9aa23b118 plugins/staticpages/services.inc.php
--- a/plugins/staticpages/services.inc.php Sun Nov 29 13:35:24 2009 +0100
+++ b/plugins/staticpages/services.inc.php Sun Nov 29 17:15:16 2009 +0100
@@ -590,42 +590,64 @@
// WE ASSUME $output doesn't have any confidential fields
} else { // an error occured (page not found, access denied, ...)
- if (empty ($page)) {
- $failflg = 0;
- } else {
- $failflg = DB_getItem ($_TABLES['staticpage'], 'sp_nf', "sp_id='$page'");
- }
- if ($failflg) {
- if ($mode !== 'autotag') {
- $output = COM_siteHeader ('menu');
- }
- $output .= COM_startBlock ($LANG_LOGIN[1], '',
- COM_getBlockTemplate ('_msg_block', 'header'));
- $login = new Template ($_CONF['path_layout'] . 'submit');
- $login->set_file (array ('login' => 'submitloginrequired.thtml'));
- $login->set_var ('login_message', $LANG_LOGIN[2]);
- $login->set_var ('site_url', $_CONF['site_url']);
- $login->set_var ('lang_login', $LANG_LOGIN[3]);
- $login->set_var ('lang_newuser', $LANG_LOGIN[4]);
- $login->parse ('output', 'login');
- $output .= $login->finish ($login->get_var ('output'));
- $output .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
- if ($mode !== 'autotag') {
- $output .= COM_siteFooter (true);
- }
- } else {
- if ($mode !== 'autotag') {
- $output = COM_siteHeader ('menu');
- }
- $output .= COM_startBlock ($LANG_ACCESS['accessdenied'], '',
- COM_getBlockTemplate ('_msg_block', 'header'));
- $output .= $LANG_STATIC['deny_msg'];
- $output .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
- if ($mode !== 'autotag') {
- $output .= COM_siteFooter (true);
+
+ /**
+ * if the user has edit permissions and the page does not exist,
+ * send them to the editor so they can create it "wiki style"
+ */
+ $create_page = false;
+ if (($mode !== 'autotag') && ($count == 0) &&
+ SEC_hasRights('staticpages.edit')) {
+ // check again without permissions
+ if (DB_count($_TABLES['staticpage'], 'sp_id', $page) == 0) {
+ $url = $_CONF['site_admin_url']
+ . '/plugins/staticpages/index.php?mode=edit&sp_new_id='
+ . $page . '&msg=21';
+ $output = COM_refresh($url);
+ $create_page = true;
}
}
+ if (! $create_page) {
+ if (empty($page)) {
+ $failflg = 0;
+ } else {
+ $failflg = DB_getItem($_TABLES['staticpage'], 'sp_nf',
+ "sp_id = '$page'");
+ }
+ if ($failflg) {
+ if ($mode !== 'autotag') {
+ $output = COM_siteHeader('menu');
+ }
+ $output .= COM_startBlock($LANG_LOGIN[1], '',
+ COM_getBlockTemplate('_msg_block', 'header'));
+ $login = new Template($_CONF['path_layout'] . 'submit');
+ $login->set_file(array('login' => 'submitloginrequired.thtml'));
+ $login->set_var('login_message', $LANG_LOGIN[2]);
+ $login->set_var('site_url', $_CONF['site_url']);
+ $login->set_var('lang_login', $LANG_LOGIN[3]);
+ $login->set_var('lang_newuser', $LANG_LOGIN[4]);
+ $login->parse('output', 'login');
+ $output .= $login->finish($login->get_var('output'));
+ $output .= COM_endBlock(COM_getBlockTemplate('_msg_block',
+ 'footer'));
+ if ($mode !== 'autotag') {
+ $output .= COM_siteFooter(true);
+ }
+ } else {
+ if ($mode !== 'autotag') {
+ $output = COM_siteHeader('menu');
+ }
+ $output .= COM_startBlock($LANG_ACCESS['accessdenied'], '',
+ COM_getBlockTemplate('_msg_block', 'header'));
+ $output .= $LANG_STATIC['deny_msg'];
+ $output .= COM_endBlock(COM_getBlockTemplate('_msg_block',
+ 'footer'));
+ if ($mode !== 'autotag') {
+ $output .= COM_siteFooter(true);
+ }
+ }
+ }
return PLG_RET_ERROR;
}
diff -r 5efbfc846ad1 -r 59e9aa23b118 public_html/admin/plugins/staticpages/index.php
--- a/public_html/admin/plugins/staticpages/index.php Sun Nov 29 13:35:24 2009 +0100
+++ b/public_html/admin/plugins/staticpages/index.php Sun Nov 29 17:15:16 2009 +0100
@@ -479,7 +479,16 @@
$A['sp_old_id'] = $A['sp_id'];
}
} elseif ($mode == 'edit') {
- $A['sp_id'] = COM_makesid();
+ // check if a new sp_id has been suggested
+ $sp_new_id = '';
+ if (isset($_GET['sp_new_id'])) {
+ $sp_new_id = COM_applyFilter($_GET['sp_new_id']);
+ }
+ if (empty($sp_new_id)) {
+ $A['sp_id'] = COM_makesid();
+ } else {
+ $A['sp_id'] = $sp_new_id;
+ }
$A['sp_uid'] = $_USER['uid'];
$A['unixdate'] = time();
$A['sp_help'] = '';
diff -r 5efbfc846ad1 -r 59e9aa23b118 public_html/docs/history
--- a/public_html/docs/history Sun Nov 29 13:35:24 2009 +0100
+++ b/public_html/docs/history Sun Nov 29 17:15:16 2009 +0100
@@ -14,6 +14,8 @@
Static Pages Plugin 1.6.2
-------------------
+- If a page does not exist and the user has staticpages.edit rights, send them
+ to the Static Page Editor (feature request #0000975) [Dirk]
- Added a Comment Default config option (feature request #0000966) [Dirk]
- Added support for query highlighting [Dirk]
More information about the geeklog-cvs
mailing list