Extension talk:DocumentApproval

Multiple approvals not working
I had to make some changes to get multiple approvals to work. Below is the diff to show what I changed.

214a215 > 303,304c304 <              $req_userid = 0; < --- > 306,307c306,307 <                $sql =  "SELECT description FROM ". $dbr->tableName('approval_request'); <                $sql .= " WHERE page_id = ". $pageid. " AND user_id = ". $userid; --- >                $sql =  "SELECT user_id, description FROM ". $dbr->tableName('approval_request'); >                $sql .= " WHERE page_id = ". $pageid; 313,314c313,314 <                    $req_userid = $userid; <                    $req_description = $row[0]; --- >                    $req_userid = $row[0]; >                    $req_description = $row[1]; 563d562 < ?>

Hope that helps. It's a good extension. --Paul 01:27, 12 February 2008 (UTC)

Question about roles
How do I set the roles? And does it work that any user with that role can sign a document or does the user have to be defined as well as the role?

Issue with linefeeds (/n)
I modified the function fnDocumentApproval and moved the assignment of $function inside the if check for $login because when $requests was assigned from splitting $inputs on "\n" the first and last value in the array is blank and thus there is no value for $function = $request[1].

.. FROM .. function fnDocumentApproval( $input, $argv, &$parser ) {

daTableCheck; $requests=split("\n",$input); .. ..  foreach($requests as $request) {       $request=split(";",trim($request)); $login = $request[0]; $function = $request[1]; if ($login != "") {           $counter++; // Gets userid $userid = getUserIDFromUserText($login);

.. TO .. function fnDocumentApproval( $input, $argv, &$parser ) {

daTableCheck; $requests=split("\n",$input); .. ..  foreach($requests as $request) {       $request=split(";",trim($request)); $login = $request[0]; if ($login != "") {           $function = $request[1]; $counter++; // Gets userid $userid = getUserIDFromUserText($login);

--Chris Wolcott, May 2008 (UTC)

Sign Tab displayed incorrectly
If a user is not logged in the sign tab is being displayed. We are currently using Mediawiki 1.12.0 and php 5.2.0

Changed the daSkinTemplateTabs function in the file DocumentApproval.body.php to check if a user is current logged in.

.. FROM ..

function daSkinTemplateTabs( &$skin, &$content_actions ) { global $wgRequest, $wgTitle; $action = $wgRequest->getText( 'action' ); // Check if the user are elegible for singing this page $revisionid = $wgTitle->getLatestRevID; $revision = Revision::newFromID($revisionid); if ($revision) {       //    $revisionid = $revision->getId; $pageid = $revision->getPage; $user = User::newFromSession; $userid = $user->getID; $dbr = wfGetDB( DB_SLAVE ); // Check if this user can sign the document $sql = "SELECT user_id FROM ". $dbr->tableName('approval_request'); $sql .= " WHERE page_id = ". $pageid; $sql .= " AND user_id = ". $userid; $reqUserId = ""; $res = $dbr->query( $sql, __METHOD__ ); if ($dbr->numRows($res)) {               $row = $dbr->fetchRow($res); $reqUserID = $row[0]; }           $dbr->freeResult($res); // If user is elegible for singning, displays the sign tab if ($reqUserID == $userid) {                       $content_actions['sign'] = array(                                'class' => ($action == 'sign') ? 'selected' : false,                                'text' => "sign",                                'href' => $skin->mTitle->getLocalURL( 'action=sign' )                        ); }       }        return true; }

.. TO ..

function daSkinTemplateTabs( &$skin, &$content_actions ) { global $wgRequest, $wgTitle; $action = $wgRequest->getText( 'action' ); // Check if the user are elegible for singing this page $revisionid = $wgTitle->getLatestRevID; $revision = Revision::newFromID($revisionid); if ($revision) {       // $revisionid = $revision->getId; $pageid = $revision->getPage; $user = User::newFromSession; $userid = $user->getID; // MOD - Check if there is a user logged-on if ($userid) { $dbr = wfGetDB( DB_SLAVE ); // Check if this user can sign the document $sql = "SELECT user_id FROM ". $dbr->tableName('approval_request'); $sql .= " WHERE page_id = ". $pageid; $sql .= " AND user_id = ". $userid; $reqUserId = ""; $res = $dbr->query( $sql, __METHOD__ ); if ($dbr->numRows($res)) { $row = $dbr->fetchRow($res); $reqUserID = $row[0]; }

$dbr->freeResult($res); // If user is elegible for singning, displays the sign tab if ($reqUserID == $userid) { $content_actions['sign'] = array(                               'class' => ($action == 'sign') ? 'selected' : false,                                'text' => "sign",                                'href' => $skin->mTitle->getLocalURL( 'action=sign' )); }          }        }        return true; }

--Chris Wolcott 12:48, 27 May 2008 (UTC)

First page save issue
If is added to a new document the I function fnDocumentApproval fails because there is no revision for this page yet (because it has not been saved). Thus I modified fnDocumentApproval to check for a null $revision and return false.

.. FROM .. function fnDocumentApproval( $input, $argv, &$parser ) {

daTableCheck;

$requests=split("\n",$input);

// get document full title $title = $parser->getTitle;

$revision = Revision::newFromTitle($title); $revisionid = $revision->getId; $pageid = $revision->getPage; .. ..

.. TO .. function fnDocumentApproval( $input, $argv, &$parser ) {

daTableCheck;

$requests=split("\n",$input);

// get document full title $title = $parser->getTitle;

$revision = Revision::newFromTitle($title); if (is_null($revision)) return false;

$revisionid = $revision->getId; $pageid = $revision->getPage; .. ..

--Chris Wolcott 09:48, 29 May 2008 (UTC)

An improvement but still not perfect
I have made the above modification in the DocumentApproval.body.php file which does allow me to at least save the newly created page with the approval details included (instead of it not saving as before). However the approval table and sign tab don't appear on the initial save. If I go back into the page and simply hit save page again they appear.

Is there any other fixes for this behaviour? Is this what other people have encountered?

Cameron.moody 23:01, 2 July 2008 (UTC)

I'm having the exact same problem. So far i've not been able to come up with a fix since I can't get the pageID from the uncreated page.

Logging of the approvals?
I can't seem to see anywhere that the actual signing is logged? I have checked under Special:Log but can't find any entries there. I also can't see anything under the page history to indicate that it had been signed. Is this sort of functionality available from somewhere, or can it be added at all?

Cameron.moody 04:38, 2 July 2008 (UTC)

How does an approver know that they have a request to approve a page?
Is there some sort of notification email that is sent? I have done some test pages listing email-confirmed users as approvers but they get no email. I also cannot see anywhere that they are notified of a pending request?

Cam

Return from fnSign hook incorrect
I changed the final else portion of the code to return true. The allows other UnknownHook calls to still execute.

Wolcott 20:36, 14 July 2008 (UTC)

Possible that a notification be sent to confirmed email address?
I am helping set up an internal wiki that only allows access to users with confirmed email addresses. With this extension there does not appear to be any notification.

Is it possible to add something to the code that whenever a page is saved that an email notification is sent to each of the users specified (ie their confirmed email address) to let them know? Ideally with a link to the page or the page title etc.

Enforce Approval as "required". Choose approver by clicking. Email notification

 * 1) Is there a feature that to set "approval" procedure as "required" and the user can't save the page without set approval assigner? no --Jostar 14:05, 9 February 2010 (UTC)
 * 2) Is there a way to let the users to click one of the user from one of predefined user groups instead of to type in the approval markup section? no --Jostar 14:05, 9 February 2010 (UTC)
 * 3) It seems that several users requested email notification before. Is it available yet? no but I like this option and I will think on this --Jostar 14:05, 9 February 2010 (UTC)
 * 4) * Every "sign"-action should be logged (easy to do)
 * 5) * A special page can show "pages waiting to sign" (easy to do) This list has to be checked from every user every day... better version 3:
 * 6) * Once someone added a user to the aproval list, the system sends him a message.

I did your second version because if you have very much pages to sign, getting a message for every single page is not fun. The code is listed below. --Daniel Gerber 09:28, 6 March 2010 (UTC)

Internationalisation
I removed the follwoing code and changed to the other part of the code for Internationalizing. --Jostar 16:19, 9 February 2010 (UTC)

problems with "undefined Variable" due to extension:dpl
using Extension dpl an error accured only on pages usind dpl: 'undefined Variable:$reqUserID' in line 156

I could not find the real reason, but I changed this line (Number 156) to avoid the error message: if ($reqUserID == $userid) { to: if (isset($reqUserID) && $reqUserID == $userid) { # isset avoids error: 'undefined Variable:$reqUserID' occuring with Extension:PDL for example

--Jostar 12:32, 10 February 2010 (UTC)

special page that lists all approval requests
I added a special page, that lists all pages where the user is requested for approval and all pages he already approved. Maybe we could integrate something like this in the next version of the extension? My Code:

File: DocumentApproval.php Class definition in file: DocumentApproval.body.php ";			if (!$not_approved_tab_empty) {				$output .= $not_approved_tab;			}			else{				# = no pending requests for approval				$output = wfMsg('daNotRequested');			}		}		else{ 			# = no requests for approval			$output = wfMsg('daNotRequested');       }        $dbr->freeResult($res);		$output .= ' '. wfMsg('daApprovedPages') .' ';		if (!$approved_tab_empty) {			# generate table with approved pages			$output .= ' ';		}		else {			# procedure if there are no approved pages at all			$output .= wfMsg('daNoPagesApproved');		}		$wgOut->addHTML( $output );	} } Internationalization in file: DocumentApproval.i18n.php  I did only the German and English internationalization. --Daniel Gerber 09:28, 6 March 2010 (UTC)