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)