Update of /cvsroot/phpwiki/phpwiki/lib/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32042
Modified Files:
WikiAdminChmod.php WikiPoll.php
Log Message:
enabled require_all check in WikiPoll
better handling of <20 min visiting client: display results so far
Index: WikiAdminChmod.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/WikiAdminChmod.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -2 -b -p -d -r1.1 -r1.2
--- WikiAdminChmod.php 23 Feb 2004 21:30:25 -0000 1.1
+++ WikiAdminChmod.php 24 Feb 2004 03:21:40 -0000 1.2
@@ -22,5 +22,6 @@ rcs_id('$Id$');
/**
- * Set individual PagePermissions
+ * Set individual PagePermissions, simplifying effective ACLs to
+ * unix-like rwxr--r--+ permissions. (as in cygwin)
*
* Usage: <?plugin WikiAdminChmod ?> or called via WikiAdminSelect
@@ -168,5 +169,6 @@ extends WikiPlugin_WikiAdminSelect
function chmodForm(&$header, $post_args) {
- $header->pushContent(HTML::p(HTML::em(_("This plugin is currently under development and does not work!"))));
+ $header->pushContent(
+ HTML::p(HTML::em(_("This plugin is currently under development and does not work!"))));
$header->pushContent(_("Chmod to permission:"));
$header->pushContent(HTML::input(array('name' => 'admin_chmod[perm]',
@@ -189,4 +191,8 @@ extends WikiPlugin_WikiAdminSelect
// $Log$
+// Revision 1.2 2004/02/24 03:21:40 rurban
+// enabled require_all check in WikiPoll
+// better handling of <20 min visiting client: display results so far
+//
// Revision 1.1 2004/02/23 21:30:25 rurban
// more PagePerm stuff: (working against 1.4.0)
Index: WikiPoll.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/WikiPoll.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -2 -b -p -d -r1.1 -r1.2
--- WikiPoll.php 24 Feb 2004 02:45:45 -0000 1.1
+++ WikiPoll.php 24 Feb 2004 03:21:46 -0000 1.2
@@ -39,5 +39,4 @@ rcs_id('$Id$');
*
* TODO:
- * check all required buttons if require_all
* admin page (view and reset statistics)
*
@@ -145,7 +144,11 @@ extends WikiPlugin
$poll = $page->get("poll");
$ip = $_SERVER['REMOTE_ADDR'];
- if (isset($poll['ip'][$ip]) and ((time() - $poll['ip'][$ip]) < 20*60))
- //todo: view at least the result or disable the Go button
- return HTML::strong(_("Sorry! You must wait at least 20 minutes until you can vote again!"));
+ $disable_submit = false;
+ if (isset($poll['ip'][$ip]) and ((time() - $poll['ip'][$ip]) < 20*60)) {
+ //view at least the result or disable the Go button
+ $html = HTML(HTML::strong(_("Sorry! You must wait at least 20 minutes until you can vote again!")));
+ $html->pushContent($this->doPoll(&$page, &$request, $request->getArg('answer'),true));
+ return $html;
+ }
$poll['ip'][$ip] = time();
@@ -155,13 +158,20 @@ extends WikiPlugin
unset($poll['ip'][$ip]);
}
- $page->set("poll",$poll);
+ $html = HTML::form(array('action' => $request->getPostURL(),
+ 'method' => 'POST'));
- if ($request->isPost() and $request->getArg('answer')) {
+ if ($request->isPost()) {
+ // checkme: check if all answers are answered
+ if ($request->getArg('answer') and
+ ($args['require_all'] and
+ count($request->getArg('answer')) == count($question))) {
+ $page->set("poll",$poll);
// update statistics and present them the user
return $this->doPoll(&$page, &$request, $request->getArg('answer'));
+ } else {
+ $html->pushContent(HTML::p(HTML::strong(_("You must answer all questions!"))));
+ }
}
- $html = HTML::form(array('action' => $request->getPostURL(),
- 'method' => 'POST'));
$init = isset($question[0]) ? 0 : 1;
for ($i = $init; $i <= count($question); $i++) {
@@ -193,4 +203,5 @@ extends WikiPlugin
}
}
+ if (!$disable_submit)
$html->pushContent(HTML::p(
HTML::input(array('type' => 'submit',
@@ -200,8 +211,10 @@ extends WikiPlugin
'name' => "reset",
'value' => _("Reset")))));
+ else
+ $html->pushContent(HTML::p(),HTML::strong(_("Sorry! You must wait at least 20 minutes until you can vote again!")));
return $html;
}
- function doPoll($page, $request, $answers) {
+ function doPoll($page, $request, $answers, $readonly = false) {
$question = $this->_args['question'];
$answer = $this->_args['answer'];
@@ -216,4 +229,5 @@ extends WikiPlugin
trigger_error(fmt("missing %s for %s","answer"."[$i]","question"."[$i]"),
E_USER_ERROR);
+ if (!$readonly)
$page->set('poll',$poll);
$a = $answer[$i];
@@ -224,5 +238,8 @@ extends WikiPlugin
if ($answers[$i])
$checkbox->setAttr('checked',1);
+ if (!$readonly)
list($percent,$count,$all) = $this->storeResult(&$page, $i, $answers[$i] ? 1 : 0);
+ else
+ list($percent,$count,$all) = $this->getResult(&$page, $i, 1);
$result = sprintf(_(" %d%% selected this (%d/%d)"),$percent,$count,$all);
$html->pushContent(HTML::tr(HTML::th(array('colspan' => 3,'align'=>'left'),$q)));
@@ -233,4 +250,5 @@ extends WikiPlugin
$html->pushContent(HTML::tr(HTML::th(array('colspan' => 3,'align'=>'left'),$q)));
$row = HTML();
+ if (!$readonly)
$this->storeResult(&$page,$i,$answers[$i]);
for ($j=0; $j <= count($a); $j++) {
@@ -251,5 +269,9 @@ extends WikiPlugin
}
}
- return HTML($html,HTML::p(_("Thanks for participating!")));
+ if (!$readonly)
+ return HTML(HTML::h3(_("The result of this poll so far:")),$html,HTML::p(_("Thanks for participating!")));
+ else
+ return HTML(HTML::h3(_("The result of this poll so far:")),$html);
+
}
@@ -278,6 +300,7 @@ extends WikiPlugin
// $Log$
-// Revision 1.1 2004/02/24 02:45:45 rurban
-// a new toy, first version without admin page and check if all questions are asked
+// Revision 1.2 2004/02/24 03:21:46 rurban
+// enabled require_all check in WikiPoll
+// better handling of <20 min visiting client: display results so far
//
//
|