logo       

CVS: phpwiki/lib/plugin ModeratedPage.php,1.3,1.4: msg#00178

web.wiki.phpwiki.checkins

Subject: CVS: phpwiki/lib/plugin ModeratedPage.php,1.3,1.4

Update of /cvsroot/phpwiki/phpwiki/lib/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27419/plugin

Modified Files:
ModeratedPage.php
Log Message:
more work on the last part

Index: ModeratedPage.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/ModeratedPage.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -2 -b -p -d -r1.3 -r1.4
--- ModeratedPage.php 6 Dec 2004 19:50:05 -0000 1.3
+++ ModeratedPage.php 29 Jan 2005 19:52:09 -0000 1.4
@@ -2,5 +2,5 @@
rcs_id('$Id$');
/*
- Copyright 2004 $ThePhpWikiProgrammingTeam
+ Copyright 2004,2005 $ThePhpWikiProgrammingTeam

This file is part of PhpWiki.
@@ -27,4 +27,6 @@ rcs_id('$Id$');
*
http://mywiki/SomeModeratedPage?action=ModeratedPage&id=kdclcr78431zr43uhrn&pass=approve
*
+ * Not yet ready! part 3/3 is missing: The moderator approve/reject methods.
+ *
* See http://phpwiki.org/PageModeration
* Author: ReiniUrban
@@ -64,17 +66,17 @@ extends WikiPlugin
return $this->error("No page specified");
$page = $dbi->getPage($args['page']);
- $moderation = $page->get("moderation");
- if ($moderation) {
- if (isset($moderation['id']) and $moderation['id'] ==
$args['id']) {
+ if ($moderated = $page->get("moderated")) {
+ if (array_key_exists($args['id'], $moderated['data'])) {
+ $moderation = $moderated['data'][$args['id']];
// handle defaults:
// approve or reject
if ($args['pass'] == 'approve')
- return $this->approve($args, $moderation);
+ return $this->approve($request, $args, $moderation);
elseif ($args['pass'] == 'reject')
- return $this->reject($args, $moderation);
+ return $this->reject($request, $args, $moderation);
else
return $this->error("Wrong pass ".$args['pass']);
} else {
- return $this->error("Wrong id");
+ return $this->error("Wrong id ".htmlentities($args['id']));
}
}
@@ -111,5 +113,6 @@ extends WikiPlugin
$users[$userid] = 0;
}
- list($args['emails'], $args['moderators']) =
$page->getPageChangeEmails(array($page->getName() => $users));
+ list($args['emails'], $args['moderators']) =
+ $page->getPageChangeEmails(array($page->getName() => $users));

if (!empty($args['require_access'])) {
@@ -136,5 +139,6 @@ extends WikiPlugin
if (is_array($status)) {
if (!empty($status['emails'])) {
- trigger_error(_("ModeratedPage: No emails for the moderators
defined"), E_USER_WARNING);
+ trigger_error(_("ModeratedPage: No emails for the moderators
defined"),
+ E_USER_WARNING);
return false;
}
@@ -159,5 +163,6 @@ extends WikiPlugin
if (is_array($status)) {
if (!empty($status['emails'])) {
- trigger_error(_("ModeratedPage: No emails for the moderators
defined"), E_USER_WARNING);
+ trigger_error(_("ModeratedPage: No emails for the moderators
defined"),
+ E_USER_WARNING);
return false;
}
@@ -181,5 +186,5 @@ extends WikiPlugin
for ($i = 1; $i <= 16; $i++) {
$r = function_exists('mt_rand') ? mt_rand(55, 90) : rand(55, 90);
- $s .= chr($r < 65 ? $r-17 : $r);
+ $s .= chr(($r < 65) ? ($r-17) : $r);
}
return $s;
@@ -207,5 +212,6 @@ extends WikiPlugin
}
// which action?
- if (!empty($status['require_access']) and
!in_array(action2access($action), $status['require_access']))
+ if (!empty($status['require_access'])
+ and !in_array(action2access($action), $status['require_access']))
return false; // allow and fall through, not moderated
if (!empty($status['require_level']) and $request->_user->_level >=
$status['require_level'])
@@ -228,5 +234,5 @@ extends WikiPlugin
join(", ",
$status['moderators'])
));
- //send email
+ // send email
$pagename = $page->getName();
$subject = "[".WIKI_NAME.'] '.$action.': '._("ModeratedPage").'
'.$pagename;
@@ -243,6 +249,7 @@ extends WikiPlugin
return false; // pass thru
} else {
- //FIXME: This will msg get lost on the edit redirect
- trigger_error(_("ModeratedPage Notification Error: Couldn't
send email"), E_USER_WARNING);
+ //FIXME: This msg get lost on the edit redirect
+ trigger_error(_("ModeratedPage Notification Error: Couldn't
send email"),
+ E_USER_WARNING);
return true;
}
@@ -253,16 +260,53 @@ extends WikiPlugin
/**
* Handle admin-side moderation resolve.
- * We might have to convert the GET to a POST request to continue with the
left-over stored request.
+ * We might have to convert the GET to a POST request to continue
+ * with the left-over stored request.
+ * Better we display a post form for verification.
*/
- function approve($args, $moderation) {
+ function approve(&$request, $args, &$moderation) {
// check id, convert to POST, continue
- ;
+ if ($request->isPost()) {
+ $this->error("ModeratedPage::approve not yet implemented");
+ } else {
+ return $this->_approval_form($request, $args, $moderation,
'approve');
+ }
}
/**
* Handle admin-side moderation resolve.
*/
- function reject($args, $moderation) {
+ function reject(&$request, $args, &$moderation) {
// check id, delete action
- ;
+ if ($request->isPost()) {
+ $this->error("ModeratedPage::reject not yet implemented");
+ } else {
+ return $this->_approval_form($request, $args, $moderation,
'reject');
+ }
+ }
+
+ function _approval_form(&$request, $args, $moderation, $pass='approve') {
+ $header = HTML::h3(_("Please approve or reject this request:"));
+ $loader = new WikiPluginLoader();
+ $BackendInfo = $loader->getPlugin("_BackendInfo");
+ $content = HTML::table(array('border' => 1,
+ 'cellpadding' => 2,
+ 'cellspacing' => 0));
+ $myargs = $args;
+ $BackendInfo->_fixupData($myargs);
+ $content->pushContent($BackendInfo->_showhash("request args",
$myargs));
+ $BackendInfo->_fixupData($moderation);
+ $content->pushContent($BackendInfo->_showhash("moderation data",
$moderation));
+ $approve = Button('submit:ModeratedPage[approve]', _("Approve"),
+ $pass == 'approve' ? 'wikiadmin' : 'button');
+ $reject = Button('submit:ModeratedPage[reject]', _("Reject"),
+ $pass == 'reject' ? 'wikiadmin' : 'button');
+ return HTML::form(array('action' => $request->getPostURL(),
+ 'method' => 'post'),
+ $header,
+ $content,
+ ENABLE_PAGEPERM ? ''
+ : HiddenInputs(array('require_authority_for_post' =>
WIKIAUTH_ADMIN)),
+ HiddenInputs($args),
+ $pass == 'approve' ? HTML::p($approve, $reject)
+ : HTML::p($reject, $approve));
}

@@ -294,4 +338,7 @@ extends WikiPlugin

// $Log$
+// Revision 1.4 2005/01/29 19:52:09 rurban
+// more work on the last part
+//
// Revision 1.3 2004/12/06 19:50:05 rurban
// enable action=remove which is undoable and seeable in RecentChanges: ADODB
ony for now.



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise