2004-12-12 03:51:51 +00:00
< ? php
/********************************************************/
2004-11-09 22:41:18 +00:00
/* code to View and approve new application maintainers */
2004-12-12 03:51:51 +00:00
/********************************************************/
2004-11-09 22:41:18 +00:00
include ( " path.php " );
2005-01-30 00:57:34 +00:00
require ( BASE . " include/incl.php " );
require ( BASE . " include/tableve.php " );
require ( BASE . " include/category.php " );
require ( BASE . " include/maintainer.php " );
2005-02-07 04:31:26 +00:00
require ( BASE . " include/application.php " );
2005-01-30 00:57:34 +00:00
require ( BASE . " include/mail.php " );
2004-11-09 22:41:18 +00:00
2006-06-17 06:10:10 +00:00
$aClean = array (); //array of filtered user input
$aClean [ 'sub' ] = makeSafe ( $_REQUEST [ 'sub' ] );
$aClean [ 'queueId' ] = makeSafe ( $_REQUEST [ 'queueId' ] );
$aClean [ 'add' ] = makeSafe ( $_REQUEST [ 'add' ] );
$aClean [ 'reject' ] = makeSafe ( $_REQUEST 'reject' ] );
$aClean [ 'replyText' ] = makeSafe ( $_REQUEST [ 'replyText' ] );
2005-01-30 23:12:48 +00:00
if ( ! $_SESSION [ 'current' ] -> hasPriv ( " admin " ))
2004-11-09 22:41:18 +00:00
{
2004-12-29 20:21:31 +00:00
errorpage ( " Insufficient privileges. " );
2004-11-09 22:41:18 +00:00
exit ;
}
2006-06-17 06:10:10 +00:00
if ( $aClean [ 'sub' ])
2004-11-09 22:41:18 +00:00
{
2006-06-17 06:10:10 +00:00
if ( $aClean [ 'queueId' ])
2004-11-09 22:41:18 +00:00
{
//get data
$query = " SELECT queueId, appId, versionId, " .
2004-12-10 00:18:01 +00:00
" userId, maintainReason, superMaintainer, " .
2004-11-09 22:41:18 +00:00
" UNIX_TIMESTAMP(submitTime) as submitTime " .
2006-06-17 06:10:10 +00:00
" FROM appMaintainerQueue WHERE queueId = " . $aClean [ 'queueId' ] . " ; " ;
2005-01-12 16:22:55 +00:00
$result = query_appdb ( $query );
2004-11-09 22:41:18 +00:00
$ob = mysql_fetch_object ( $result );
2005-01-30 23:12:48 +00:00
$oUser = new User ( $ob -> userId );
2004-11-09 22:41:18 +00:00
mysql_free_result ( $result );
}
else
{
//error no Id!
2004-12-16 02:46:36 +00:00
errorpage ( " <p><b>QueueId Not Found!</b></p> " );
2004-11-09 22:41:18 +00:00
}
//process according to which request was submitted and optionally the sub flag
2006-06-17 06:10:10 +00:00
if ( ! $aClean [ 'add' ] && ! $aClean [ 'reject' ] && $aClean [ 'queueId' ])
2004-11-09 22:41:18 +00:00
{
2004-12-16 02:46:36 +00:00
apidb_header ( " Admin Maintainer Queue " );
echo '<form name="qform" action="adminMaintainerQueue.php" method="post" enctype="multipart/form-data">' , " \n " ;
2004-11-09 22:41:18 +00:00
$x = new TableVE ( " view " );
//help
echo " <div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td> \n \n " ;
echo " Please enter an accurate and personalized reply anytime a maintainer request is rejected. \n " ;
echo " Its not polite to reject someones attempt at trying to help out without explaining why. \n " ;
echo " </td></tr></table></div> \n \n " ;
//view application details
echo html_frame_start ( " New Maintainer Form " , 600 , " " , 0 );
echo " <table width='100%' border=0 cellpadding=2 cellspacing=0> \n " ;
// Show the other maintainers of this application, if there are any
echo '<tr valign=top><td class=color0><b>Other maintainers of this app:</b></td>' , " \n " ;
2004-12-10 00:18:01 +00:00
$foundMaintainers = false ;
$firstDisplay = true ; /* if false we need to fix up table rows appropriately */
2005-07-31 17:53:11 +00:00
$other_users = getMaintainersUserIdsFromAppIdVersionId ( $ob -> versionId );
2004-11-09 22:41:18 +00:00
if ( $other_users )
{
2004-12-10 00:18:01 +00:00
$foundMaintainers = true ;
2005-08-01 00:39:07 +00:00
while ( list ( $index , $userIdValue ) = each ( $other_users ))
2004-11-09 22:41:18 +00:00
{
2005-01-30 23:12:48 +00:00
$oUser = new User ( $userIdValue );
2004-12-10 00:18:01 +00:00
if ( $firstDisplay )
{
2005-01-30 23:12:48 +00:00
echo " <td> " . $oUser -> sRealname . " </td></tr> \n " ;
2004-12-10 00:18:01 +00:00
$firstDisplay = false ;
} else
{
2005-01-30 23:12:48 +00:00
echo " <tr><td class= \" color0 \" ></td><td> " . $oUser -> sRealname . " </td></tr> \n " ;
2004-12-10 00:18:01 +00:00
}
2004-11-09 22:41:18 +00:00
}
2004-12-10 00:18:01 +00:00
}
$other_users = getSuperMaintainersUserIdsFromAppId ( $ob -> appId );
if ( $other_users )
{
$foundMaintainers = true ;
2005-08-01 00:39:07 +00:00
while ( list ( $index , $userIdValue ) = each ( $other_users ))
2004-12-10 00:18:01 +00:00
{
2005-01-30 23:12:48 +00:00
$oUser = new User ( $userIdValue );
2004-12-10 00:18:01 +00:00
if ( $firstDisplay )
{
2005-01-30 23:12:48 +00:00
echo " <td> " . $oUser -> sRealname . " *</td></tr> \n " ;
2004-12-10 00:18:01 +00:00
$firstDisplay = false ;
} else
{
2005-01-30 23:12:48 +00:00
echo " <tr><td class= \" color0 \" ></td><td> " . $oUser -> sRealname . " *</td></tr> \n " ;
2004-12-10 00:18:01 +00:00
}
}
}
if ( ! $foundMaintainers )
2004-11-09 22:41:18 +00:00
{
echo " <td>No other maintainers</td></tr> \n " ;
}
// Show which other apps the user maintains
2005-01-30 23:12:48 +00:00
echo '<tr valign="top"><td class="color0"><b>This user also maintains these apps:</b></td>' , " \n " ;
2004-11-09 22:41:18 +00:00
2004-12-10 00:18:01 +00:00
$firstDisplay = true ;
2004-11-09 22:41:18 +00:00
$other_apps = getAppsFromUserId ( $ob -> userId );
if ( $other_apps )
{
2004-12-10 00:18:01 +00:00
while ( list ( $index , list ( $appIdOther , $versionIdOther , $superMaintainerOther )) = each ( $other_apps ))
2004-11-09 22:41:18 +00:00
{
2005-02-07 04:31:26 +00:00
$oApp = new Application ( $appIdOther );
2006-01-23 02:56:31 +00:00
$oVersion = new Version ( $versionIdOther );
2004-12-10 00:18:01 +00:00
if ( $firstDisplay )
{
$firstDisplay = false ;
if ( $superMaintainerOther )
2005-02-07 04:31:26 +00:00
echo " <td> " . $oApp -> sName . " *</td></tr> \n " ;
2004-12-10 00:18:01 +00:00
else
2005-02-07 04:31:26 +00:00
echo " <td> " . $oApp -> sName . " " . $oVersion -> sName . " </td></tr> \n " ;
2004-12-10 00:18:01 +00:00
} else
{
if ( $superMaintainerOther )
2005-02-07 04:31:26 +00:00
echo " <td class=color0></td><td> " . $oApp -> sName . " *</td></tr> \n " ;
2004-12-10 00:18:01 +00:00
else
2005-02-07 04:31:26 +00:00
echo " <td class=color0></td><td> " . $oApp -> sName . " " . $oVersion -> sName . " </td></tr> \n " ;
2004-12-10 00:18:01 +00:00
}
2004-11-09 22:41:18 +00:00
}
} else
{
echo " <td>User maintains no other applications</td></tr> \n " ;
}
2005-02-07 04:31:26 +00:00
$oApp = new Application ( $ob -> appId );
2006-01-23 02:12:40 +00:00
$oVersion = new Version ( $ob -> versionId );
2005-02-07 04:31:26 +00:00
2004-11-09 22:41:18 +00:00
//app name
echo '<tr valign=top><td class=color0><b>App Name</b></td>' , " \n " ;
2005-02-07 04:31:26 +00:00
echo " <td> " . $oApp -> sName . " </td></tr> \n " ;
2004-11-09 22:41:18 +00:00
//version
echo '<tr valign=top><td class=color0><b>App Version</b></td>' , " \n " ;
2005-02-07 04:31:26 +00:00
echo " <td> " . $oVersion -> sName . " </td></tr> \n " ;
2004-11-09 22:41:18 +00:00
//maintainReason
echo '<tr valign=top><td class=color0><b>Maintainer request reason</b></td>' , " \n " ;
2005-02-07 04:31:26 +00:00
echo '<td><textarea name="maintainReason" rows=10 cols=35>' . $ob -> maintainReason . '</textarea></td></tr>' , " \n " ;
2004-11-09 22:41:18 +00:00
//email response
echo '<tr valign=top><td class=color0><b>Email reply</b></td>' , " \n " ;
echo " <td><textarea name='replyText' rows=10 cols=35>Enter a personalized reason for acceptance or rejection of the users maintainer request here</textarea></td></tr> \n " ;
/* Add button */
echo '<tr valign=top><td class=color3 align=center colspan=2>' , " \n " ;
2004-12-14 02:35:16 +00:00
echo '<input type=submit name=add value=" Add maintainer to this application " class=button /> </td></tr>' , " \n " ;
2004-11-09 22:41:18 +00:00
/* Reject button */
echo '<tr valign=top><td class=color3 align=center colspan=2>' , " \n " ;
2004-12-14 02:35:16 +00:00
echo '<input type=submit name=reject value=" Reject this request " class=button /></td></tr>' , " \n " ;
2004-11-09 22:41:18 +00:00
echo '</table>' , " \n " ;
2004-12-14 02:35:16 +00:00
echo '<input type=hidden name="sub" value="inside_form" />' , " \n " ;
2006-06-17 06:10:10 +00:00
echo '<input type=hidden name="queueId" value="' . $aClean [ 'queueId' ] . '" />' , " \n " ;
2004-11-09 22:41:18 +00:00
echo html_frame_end ( " " );
echo html_back_link ( 1 , 'adminMaintainerQueue.php' );
2004-12-16 02:46:36 +00:00
echo " </form> " ;
apidb_footer ();
exit ;
2004-11-09 22:41:18 +00:00
}
2006-06-17 06:10:10 +00:00
else if ( $aClean [ 'add' ] && $aClean [ 'queueId' ])
2004-11-09 22:41:18 +00:00
{
2005-07-31 17:53:11 +00:00
/* create a new user object for the maintainer */
$maintainerUser = new User ( $ob -> userId );
/* add the user as a maintainer and return the statusMessage */
$statusMessage = $maintainerUser -> addAsMaintainer ( $ob -> appId , $ob -> versionId ,
$ob -> superMaintainer ,
2006-06-17 06:10:10 +00:00
$aClean [ 'queueId' ]);
2005-07-31 17:53:11 +00:00
//done
addmsg ( " <p><b> $statusMessage </b></p> " , 'green' );
2004-11-09 22:41:18 +00:00
}
2006-06-17 06:10:10 +00:00
else if (( $aClean [ 'reject' ] || ( $aClean [ 'sub' ] == 'reject' )) && $aClean [ 'queueId' ])
2004-11-09 22:41:18 +00:00
{
2005-01-30 23:12:48 +00:00
$sEmail = $oUser -> sEmail ;
2005-01-30 00:57:34 +00:00
if ( $sEmail )
2004-11-09 22:41:18 +00:00
{
2005-02-07 04:31:26 +00:00
$oApp = new Application ( $ob -> appId );
2005-10-31 01:29:37 +00:00
$oVersion = new Version ( $ob -> versionId );
2005-01-30 00:57:34 +00:00
$sSubject = " Application Maintainer Request Report " ;
2005-02-07 04:31:26 +00:00
$sMsg = " Your application to be the maintainer of " . $oApp -> sName . " " . $oVersion -> sName . " was rejected. " ;
2006-06-17 06:10:10 +00:00
$sMsg .= $aClean [ 'replyText' ];
2005-01-30 00:57:34 +00:00
$sMsg .= " " ;
$sMsg .= " -The AppDB admins \n " ;
2004-11-09 22:41:18 +00:00
2005-01-30 00:57:34 +00:00
mail_appdb ( $sEmail , $sSubject , $sMsg );
2004-11-09 22:41:18 +00:00
}
//delete main item
2006-06-17 06:10:10 +00:00
$query = " DELETE from appMaintainerQueue where queueId = " . $aClean [ 'queueId' ] . " ; " ;
2005-01-12 16:22:55 +00:00
$result = query_appdb ( $query , " unable to delete selected maintainer application " );
2004-11-17 23:03:32 +00:00
echo html_frame_start ( " Delete maintainer application " , 400 , " " , 0 );
2005-01-12 16:22:55 +00:00
if ( $result )
2004-11-09 22:41:18 +00:00
{
//success
echo " <p>Maintainer application was successfully deleted from the Queue.</p> \n " ;
}
echo html_frame_end ( " " );
echo html_back_link ( 1 , 'adminMaintainerQueue.php' );
}
else
{
//error no sub!
2004-12-16 02:46:36 +00:00
addmsg ( '<p><b>Internal Routine Not Found!</b></p>' , 'red' );
2004-11-09 22:41:18 +00:00
}
}
2004-12-16 02:46:36 +00:00
/* display the list of all outstanding maintainer requests */
2004-11-09 22:41:18 +00:00
{
2004-12-16 02:46:36 +00:00
apidb_header ( " Admin Maintainer Queue " );
echo '<form name="qform" action="adminMaintainerQueue.php" method="post" enctype="multipart/form-data">' , " \n " ;
2004-11-09 22:41:18 +00:00
//get available maintainers
$query = " SELECT queueId, appId, versionId, " .
" userId, maintainReason, " .
2004-12-10 00:18:01 +00:00
" superMaintainer, " .
2005-02-20 01:55:53 +00:00
" submitTime as submitTime " .
2004-11-09 22:41:18 +00:00
" from appMaintainerQueue; " ;
2005-01-12 16:22:55 +00:00
$result = query_appdb ( $query );
2004-11-09 22:41:18 +00:00
if ( ! $result || ! mysql_num_rows ( $result ))
{
//no apps in queue
echo html_frame_start ( " " , " 90% " );
echo '<p><b>The Maintainer Queue is empty.</b></p>' , " \n " ;
echo '<p>There is nothing for you to do. Check back later.</p>' , " \n " ;
echo html_frame_end ( " " );
}
else
{
//help
echo " <div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td> \n \n " ;
echo " <p>This is a list of users that are asking to become application maintainers. \n " ;
echo " Please read carefully the reasons they give for wanting to be an application maintainer. \n " ;
echo " </td></tr></table></div> \n \n " ;
//show applist
echo html_frame_start ( " " , " 90% " , " " , 0 );
echo " <table width='100%' border=0 cellpadding=3 cellspacing=0> \n \n " ;
echo " <tr class=color4> \n " ;
2005-02-07 23:55:03 +00:00
echo " <td>Submission Date</td> \n " ;
echo " <td>Application Name</td> \n " ;
echo " <td>Version</td> \n " ;
echo " <td>Super maintainer?</td> \n " ;
echo " <td>Submitter</td> \n " ;
echo " <td>Action</td> \n " ;
2004-11-09 22:41:18 +00:00
echo " </tr> \n \n " ;
$c = 1 ;
while ( $ob = mysql_fetch_object ( $result ))
{
2005-01-30 23:12:48 +00:00
$oUser = new User ( $ob -> userId );
2005-02-07 04:31:26 +00:00
$oApp = new Application ( $ob -> appId );
$oVersion = new Version ( $ob -> versionId );
2004-11-09 22:41:18 +00:00
if ( $c % 2 == 1 ) { $bgcolor = 'color0' ; } else { $bgcolor = 'color1' ; }
echo " <tr class= $bgcolor > \n " ;
2005-02-20 01:55:53 +00:00
echo " <td> " . print_date ( mysqldatetime_to_unixtimestamp ( $ob -> submitTime )) . " </td> \n " ;
2005-02-07 04:31:26 +00:00
echo " <td> " . $oApp -> sName . " </td> \n " ;
2004-12-10 00:18:01 +00:00
if ( $ob -> superMaintainer )
{
echo " <td>N/A</td> \n " ;
echo " <td>Yes</td> \n " ;
} else
{
2005-02-07 23:55:03 +00:00
echo " <td> " . $oVersion -> sName . " </td> \n " ;
2004-12-10 00:18:01 +00:00
echo " <td>No</td> \n " ;
}
2005-02-07 23:55:03 +00:00
echo " <td><a href= \" mailto: " . $oUser -> sEmail . " \" > " . $oUser -> sRealname . " </a></td> \n " ;
echo " <td>[<a href= \" adminMaintainerQueue.php?sub=view&queueId= $ob->queueId\ " > answer </ a > ] </ td > \n " ;
2004-11-09 22:41:18 +00:00
echo " </tr> \n \n " ;
$c ++ ;
}
echo " </table> \n \n " ;
echo html_frame_end ( " " );
2004-12-16 02:46:36 +00:00
echo " </form> " ;
apidb_footer ();
2004-11-09 22:41:18 +00:00
}
}
?>