2004-12-18 06:06:46 +00:00
< ? php
/********************************************************/
/* code to view and approve new application data */
/********************************************************/
include ( " path.php " );
2005-01-30 00:57:34 +00:00
require ( BASE . " include/incl.php " );
2005-02-04 02:55:50 +00:00
require ( BASE . " include/mail.php " );
2005-01-30 00:57:34 +00:00
require ( BASE . " include/tableve.php " );
2005-02-04 02:55:50 +00:00
require ( BASE . " include/application.php " );
2004-12-18 06:06:46 +00:00
2006-06-17 06:10:10 +00:00
$aClean = array (); //array of user input
$aClean [ 'id' ] = makeSafe ( $_REQUEST [ 'id' ]);
$aClean [ 'sub' ] = makeSafe ( $_REQUEST [ 'sub' ]);
$aClean [ 'add' ] = makeSafe ( $_REQUEST [ 'add' ]);
$aClean [ 'description' ] = makeSafe ( $_REQUEST [ 'description' ]);
$aClean [ 'replyText' ] = makeSafe ( $_REQUEST [ 'replyText' ]);
$aClean [ 'reject' ] = makeSafe ( $_REQUEST [ 'reject' ]);
2005-08-05 22:07:41 +00:00
// deny access if not admin or at least some kind of maintainer
if ( ! $_SESSION [ 'current' ] -> hasPriv ( " admin " ) && ! $_SESSION [ 'current' ] -> isMaintainer ())
2004-12-18 06:06:46 +00:00
{
2006-06-29 16:13:35 +00:00
util_show_error_page ( " Insufficient privileges. " );
2004-12-18 06:06:46 +00:00
exit ;
}
// shows the list of appdata in queue
2006-06-17 06:10:10 +00:00
if ( ! $aClean [ 'id' ])
2004-12-18 06:06:46 +00:00
{
2005-02-04 02:55:50 +00:00
apidb_header ( " Admin Application Data Queue " );
2005-08-05 22:07:41 +00:00
/* retrieve the queued apps */
$hResult = $_SESSION [ 'current' ] -> getAppDataQuery ( " * " , false , true );
2004-12-18 06:06:46 +00:00
2005-01-12 16:22:55 +00:00
if ( ! $hResult || ! mysql_num_rows ( $hResult ))
2004-12-18 06:06:46 +00:00
{
2005-02-04 02:55:50 +00:00
// no appData in queue
2004-12-18 06:06:46 +00:00
echo html_frame_start ( " " , " 90% " );
echo '<p><b>The App Data Queue is empty.</b></p>' , " \n " ;
echo '<p>There is nothing for you to do. Check back later.</p>' , " \n " ;
echo html_frame_end ( " " );
2005-02-04 02:55:50 +00:00
} else
2004-12-18 06:06:46 +00:00
{
//help
echo " <div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td> \n \n " ;
2005-01-10 22:15:44 +00:00
echo " <p>This is a list of application data submitted by users. \n " ;
echo " Please inspect carefully this data before accepting it. \n " ;
2004-12-18 06:06:46 +00:00
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-09 02:22:20 +00:00
echo " <td>Submission Date</td> \n " ;
echo " <td>Submitter</td> \n " ;
echo " <td>Application</td> \n " ;
echo " <td>Version</td> \n " ;
echo " <td>Type</td> \n " ;
echo " <td align= \" center \" >Action</td> \n " ;
2004-12-18 06:06:46 +00:00
echo " </tr> \n \n " ;
$c = 1 ;
2005-01-12 16:22:55 +00:00
while ( $ob = mysql_fetch_object ( $hResult ))
2004-12-18 06:06:46 +00:00
{
2005-02-04 02:55:50 +00:00
if ( $c % 2 == 1 ) { $bgcolor = 'color0' ; } else { $bgcolor = 'color1' ; }
2005-02-20 01:55:53 +00:00
echo " <tr class= \" $bgcolor\ " > \n " ;
2005-06-25 01:22:09 +00:00
echo " <td> " . print_date ( mysqltimestamp_to_unixtimestamp ( $ob -> submitTime )) . " </td> \n " ;
2005-02-20 01:55:53 +00:00
$oUser = new User ( $ob -> submitterId );
echo " <td> " ;
echo $oUser -> sEmail ? " <a href= \" mailto: " . $oUser -> sEmail . " \" > " : " " ;
echo $oUser -> sRealname ;
echo $oUser -> sEmail ? " </a> " : " " ;
echo " </td> \n " ;
2006-06-29 16:07:19 +00:00
echo " <td> " . Application :: lookup_name ( $ob -> appId ) . " </td> \n " ;
echo " <td> " . Version :: lookup_name ( $ob -> versionId ) . " </td> \n " ;
2005-02-04 02:55:50 +00:00
echo " <td> " . $ob -> type . " </td> \n " ;
2005-02-09 02:22:20 +00:00
echo " <td align= \" center \" >[<a href='adminAppDataQueue.php?id= $ob->id '>process</a>]</td> \n " ;
2005-02-04 02:55:50 +00:00
echo " </tr> \n \n " ;
$c ++ ;
2004-12-18 06:06:46 +00:00
}
echo " </table> \n \n " ;
echo html_frame_end ( " " );
2005-02-04 02:55:50 +00:00
}
2004-12-18 06:06:46 +00:00
} else // shows a particular appdata
{
2006-06-17 06:10:10 +00:00
$hResult = $_SESSION [ 'current' ] -> getAppDataQuery ( $aClean [ 'id' ], false , false );
2005-02-04 02:55:50 +00:00
$obj_row = mysql_fetch_object ( $hResult );
2004-12-18 06:06:46 +00:00
2006-06-17 06:10:10 +00:00
if ( ! $aClean [ 'sub' ] == " inside_form " )
2004-12-18 06:06:46 +00:00
{
2005-02-04 02:55:50 +00:00
apidb_header ( " Admin Application Data Queue " );
2004-12-23 01:13:26 +00:00
echo '<form name="qform" action="adminAppDataQueue.php" method="post">' , " \n " ;
2004-12-18 06:06:46 +00:00
// 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 submitted scrrenshot is rejected. \n " ;
echo " It is 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 Application Data Form " , 600 , " " , 0 );
echo " <table width='100%' border=0 cellpadding=2 cellspacing=0> \n " ;
// app name
echo '<tr valign=top><td class=color0><b>App Name</b></td>' , " \n " ;
2006-06-29 16:07:19 +00:00
echo " <td> " . Application :: lookup_name ( $obj_row -> appId ) . " </td></tr> \n " ;
2004-12-18 06:06:46 +00:00
// version
echo '<tr valign=top><td class=color0><b>App Version</b></td>' , " \n " ;
2006-06-29 16:07:19 +00:00
echo " <td> " . Version :: lookup_name ( $obj_row -> versionId ) . " </td></tr> \n " ;
2004-12-18 06:06:46 +00:00
//dataDescription
echo '<tr valign=top><td class=color0><b>Description</b></td>' , " \n " ;
2004-12-23 01:13:26 +00:00
echo '<td><textarea name="description" rows=10 cols=35>' . stripslashes ( $obj_row -> description ) . '</textarea></td></tr>' , " \n " ;
2004-12-18 06:06:46 +00:00
//data
2004-12-23 01:13:26 +00:00
if ( $obj_row -> type == " image " )
2004-12-18 06:06:46 +00:00
{
2005-02-07 23:49:06 +00:00
$oScreenshot = new Screenshot ( $obj_row -> id );
2004-12-18 06:06:46 +00:00
echo '<tr valign=top><td class=color0><b>Submited image</b></td>' , " \n " ;
2004-12-23 01:13:26 +00:00
echo '<td>' ;
2005-02-07 23:49:06 +00:00
$imgSRC = '<img width="' . $oScreenshot -> oThumbnailImage -> width . '" height="' . $oScreenshot -> oThumbnailImage -> height . '" src="../appimage.php?queued=true&id=' . $obj_row -> id . '" />' ;
2004-12-23 01:13:26 +00:00
// generate random tag for popup window
2006-06-29 15:54:29 +00:00
$randName = User :: generate_passwd ( 5 );
2004-12-23 01:13:26 +00:00
// set image link based on user pref
2005-02-07 23:49:06 +00:00
$img = '<a href="javascript:openWin(\'../appimage.php?queued=true&id=' . $obj_row -> id . '\',\'' . $randName . '\',' . $oScreenshot -> oScreenshotImage -> width . ',' . ( $oScreenshot -> oScreenshotImage -> height + 4 ) . ');">' . $imgSRC . '</a>' ;
2005-01-30 23:12:48 +00:00
if ( $_SESSION [ 'current' ] -> isLoggedIn ())
2004-12-23 01:13:26 +00:00
{
if ( $_SESSION [ 'current' ] -> getpref ( " window:screenshot " ) == " no " )
{
2005-02-07 23:49:06 +00:00
$img = '<a href="../appimage.php?queued=true&id=' . $obj_row -> id . '">' . $imgSRC . '</a>' ;
2004-12-23 01:13:26 +00:00
}
}
echo $img ;
echo '</td></tr>' , " \n " ;
} elseif ( $obj_row -> type == " url " )
2004-12-18 06:06:46 +00:00
{
echo '<tr valign=top><td class=color0><b>Submitted link</b></td>' , " \n " ;
2004-12-23 01:13:26 +00:00
echo '<td><textarea name="content" rows=10 cols=35>' . stripslashes ( $obj_row -> url ) . '</textarea></td></tr>' , " \n " ;
2004-12-18 06:06:46 +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 submitted application data here</textarea></td></tr> \n " ;
/* Add button */
echo '<tr valign=top><td class=color3 align=center colspan=2>' , " \n " ;
echo '<input type=submit name=add value=" Add data to this application " class=button /> </td></tr>' , " \n " ;
/* Reject button */
echo '<tr valign=top><td class=color3 align=center colspan=2>' , " \n " ;
echo '<input type=submit name=reject value=" Reject this request " class=button /></td></tr>' , " \n " ;
echo '</table>' , " \n " ;
echo '<input type=hidden name="sub" value="inside_form" />' , " \n " ;
2006-06-17 06:10:10 +00:00
echo '<input type=hidden name="id" value="' . $aClean [ 'id' ] . '" />' , " \n " ;
2004-12-18 06:06:46 +00:00
echo '</form>' ;
2006-06-17 06:10:10 +00:00
} elseif ( $aClean [ 'add' ]) // we accepted the request
2004-12-18 06:06:46 +00:00
{
$statusMessage = " " ;
2005-02-04 02:55:50 +00:00
$goodtogo = 0 ;
2004-12-18 06:06:46 +00:00
2004-12-23 01:13:26 +00:00
if ( $obj_row -> type == " image " )
2004-12-18 06:06:46 +00:00
{
2005-02-07 23:49:06 +00:00
$oScreenshot = new Screenshot ( $obj_row -> id );
2005-02-04 02:55:50 +00:00
$oScreenshot -> unQueue ();
2004-12-18 06:06:46 +00:00
}
2005-02-04 02:55:50 +00:00
elseif ( $obj_row -> type == " url " )
2006-06-24 04:20:32 +00:00
{
$hResult = query_parameters ( " INSERT INTO appData (id, appId, versionId, type, " .
" description, url) VALUES (?, '?', '?', '?', '?', '?') " ,
" null " , $obj_row -> appId , $obj_row -> versionId ,
" url " , $aClean [ 'description' ], $obj_row -> url );
if ( $hResult )
2005-02-04 02:55:50 +00:00
{
$statusMessage = " <p>The application data was successfully added into the database</p> \n " ;
2004-12-18 06:06:46 +00:00
2005-02-04 02:55:50 +00:00
//delete the item from the queue
2006-06-27 19:16:27 +00:00
query_parameters ( " DELETE from appData where id = '?' " , $obj_row -> id );
2005-01-12 16:22:55 +00:00
2005-02-04 02:55:50 +00:00
//Send Status Email
$oUser = new User ( $obj_row -> userId );
if ( $oUser -> sEmail )
{
$sSubject = " Application Data Request Report " ;
2006-06-29 16:07:19 +00:00
$sMsg = " Your submission of an application data for " . Application :: lookup_name ( $obj_row -> appId ) . Version :: lookup_name ( $obj_row -> versionId ) . " has been accepted. " ;
2006-06-17 06:10:10 +00:00
$sMsg .= $aClean [ 'replyText' ];
2005-02-04 02:55:50 +00:00
$sMsg .= " We appreciate your help in making the Application Database better for all users. \r \n " ;
mail_appdb ( $oUser -> sEmail , $sSubject , $sMsg );
}
}
}
redirect ( apidb_fullurl ( " admin/adminAppDataQueue.php " ));
2006-06-17 06:10:10 +00:00
} elseif ( $aClean [ 'reject' ])
2005-02-04 02:55:50 +00:00
{
if ( $obj_row -> type == " image " )
{
2005-02-07 23:49:06 +00:00
$oScreenshot = new Screenshot ( $obj_row -> id );
2005-02-04 02:55:50 +00:00
$oScreenshot -> delete ();
}
elseif ( $obj_row -> type == " url " )
{ // FIXME: use Link class
2005-01-30 23:12:48 +00:00
$oUser = new User ( $obj_row -> userId );
if ( $oUser -> sEmail )
2005-01-12 16:22:55 +00:00
{
2005-01-30 00:57:34 +00:00
$sSubject = " Application Data Request Report " ;
2006-06-29 16:07:19 +00:00
$sMsg = " Your submission of an application data for " . Application :: lookup_name ( $obj_row -> appId ) . Version :: lookup_name ( $obj_row -> versionId ) . " was rejected. " ;
2006-06-17 06:10:10 +00:00
$sMsg .= $aClean [ 'replyText' ];
2005-02-04 02:55:50 +00:00
mail_appdb ( $oUser -> sEmail , $sSubject , $sMsg );
}
//delete main item
2005-08-05 22:07:41 +00:00
if ( $_SESSION [ 'current' ] -> deleteAppData ( $obj_row -> id ))
2005-02-04 02:55:50 +00:00
{
//success
echo " <p>Application data was successfully deleted from the Queue.</p> \n " ;
2005-01-12 16:22:55 +00:00
}
}
2005-02-04 02:55:50 +00:00
redirect ( apidb_fullurl ( " admin/adminAppDataQueue.php " ));
2004-12-18 06:06:46 +00:00
}
}
echo html_frame_end ( " " );
echo html_back_link ( 1 , 'adminAppDataQueue.php' );
apidb_footer ();
?>