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)

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)