2004-12-12 03:51:51 +00:00
< ? php
/***********************************************************/
2004-03-15 16:22:00 +00:00
/* this class represents an application incl. all versions */
2004-12-12 03:51:51 +00:00
/***********************************************************/
2005-02-07 23:21:33 +00:00
require_once ( BASE . " include/version.php " );
require_once ( BASE . " include/vendor.php " );
2006-08-30 22:24:05 +00:00
require_once ( BASE . " include/category.php " );
2005-02-11 01:34:16 +00:00
require_once ( BASE . " include/url.php " );
2006-06-17 06:10:10 +00:00
require_once ( BASE . " include/util.php " );
2006-07-07 18:14:53 +00:00
require_once ( BASE . " include/mail.php " );
2006-12-09 05:07:25 +00:00
require_once ( BASE . " include/maintainer.php " );
2007-04-24 23:48:14 +00:00
require_once ( BASE . " include/tableve.php " );
2008-04-14 01:26:37 +02:00
require_once ( BASE . " include/db_filter_ui.php " );
2006-09-27 02:44:16 +00:00
define ( " PLATINUM_RATING " , " Platinum " );
define ( " GOLD_RATING " , " Gold " );
define ( " SILVER_RATING " , " Silver " );
define ( " BRONZE_RATING " , " Bronze " );
define ( " GARBAGE_RATING " , " Garbage " );
2007-01-20 17:41:43 +00:00
define ( " MAINTAINER_REQUEST " , 1 );
define ( " SUPERMAINTAINER_REQUEST " , 2 );
2007-11-13 21:09:38 +01:00
define ( 'MONITOR_REQUEST' , 3 );
2006-09-27 02:44:16 +00:00
2005-02-06 17:49:48 +00:00
/**
* Application class for handling applications .
*/
2004-03-15 16:22:00 +00:00
class Application {
2005-02-06 17:49:48 +00:00
var $iAppId ;
var $iVendorId ;
var $iCatId ;
var $sName ;
var $sKeywords ;
var $sDescription ;
var $sWebpage ;
2007-12-12 22:25:01 +01:00
private $sState ;
2005-02-07 23:21:33 +00:00
var $sSubmitTime ;
2005-02-06 17:49:48 +00:00
var $iSubmitterId ;
var $aVersionsIds ; // an array that contains the versionId of every version linked to this app.
2007-10-23 14:16:00 +02:00
var $aVersions ; // Array of version objects belonging to this app
2007-01-20 17:41:43 +00:00
var $iMaintainerRequest ; /* Temporary variable for tracking maintainer
requests on app submission . Value denotes type of request */
2004-03-15 16:22:00 +00:00
2005-02-06 17:49:48 +00:00
/**
* constructor , fetches the data .
*/
2007-09-24 21:11:29 -04:00
public function Application ( $iAppId = null , $oRow = null )
2004-03-15 16:22:00 +00:00
{
2007-10-23 14:16:00 +02:00
$this -> aVersions = array (); // Should always be an array
2005-02-06 17:49:48 +00:00
// we are working on an existing application
2007-06-10 18:51:33 +00:00
if ( ! $iAppId && ! $oRow )
return ;
if ( ! $oRow )
2005-02-06 17:49:48 +00:00
{
2007-06-10 18:51:33 +00:00
/* fetch this applications information */
$sQuery = " SELECT *
FROM appFamily
WHERE appId = '?' " ;
if ( $hResult = query_parameters ( $sQuery , $iAppId ))
2007-08-03 23:27:25 +00:00
$oRow = query_fetch_object ( $hResult );
2007-06-10 18:51:33 +00:00
}
2007-03-17 23:45:54 +00:00
2007-06-10 18:51:33 +00:00
if ( $oRow )
{
$this -> iAppId = $oRow -> appId ;
$this -> iVendorId = $oRow -> vendorId ;
$this -> iCatId = $oRow -> catId ;
$this -> iSubmitterId = $oRow -> submitterId ;
$this -> sSubmitTime = $oRow -> submitTime ;
$this -> sName = $oRow -> appName ;
$this -> sKeywords = $oRow -> keywords ;
$this -> sDescription = $oRow -> description ;
2007-06-10 23:58:11 +00:00
//TODO: we should move the url to the appData table
// and return an id into the appData table here
$this -> sWebpage = Url :: normalize ( $oRow -> webPage );
2007-12-12 22:25:01 +01:00
$this -> sState = $oRow -> state ;
2007-06-10 18:51:33 +00:00
}
2004-03-15 16:22:00 +00:00
2007-06-10 18:51:33 +00:00
/* fetch versions of this application, if there are any */
$this -> aVersionsIds = array ();
2005-10-26 23:54:43 +00:00
2007-06-10 18:51:33 +00:00
/* only admins can view all versions */
//FIXME: it would be nice to move this permission into the user class as well as keep it generic
if ( $_SESSION [ 'current' ] -> hasPriv ( " admin " ))
{
$hResult = $this -> _internal_retrieve_all_versions ();
} else
{
$hResult = $this -> _internal_retrieve_unqueued_versions ();
}
if ( $hResult )
{
2007-08-03 23:27:25 +00:00
while ( $oRow = query_fetch_object ( $hResult ))
2005-02-06 17:49:48 +00:00
{
2007-06-10 18:51:33 +00:00
$this -> aVersionsIds [] = $oRow -> versionId ;
2005-02-06 17:49:48 +00:00
}
}
2004-03-15 16:22:00 +00:00
}
2007-12-12 22:43:22 +01:00
private function _internal_retrieve_all_versions ( $bIncludeObsolete = TRUE , $bIncludeDeleted = false )
2006-09-26 02:05:55 +00:00
{
2007-09-08 22:52:00 +00:00
if ( ! $bIncludeObsolete )
$sObsolete = " AND obsoleteBy = '0' " ;
else
$sObsolete = " " ;
2007-12-12 22:43:22 +01:00
if ( $bIncludeDeleted )
$sExcludeDeleted = " " ;
else
$sExcludeDeleted = " AND state != 'deleted' " ;
2006-09-26 02:05:55 +00:00
$sQuery = " SELECT versionId FROM appVersion WHERE
2007-12-12 22:43:22 +01:00
appId = '?' $sObsolete $sExcludeDeleted ORDER by versionName " ;
2006-09-26 02:05:55 +00:00
$hResult = query_parameters ( $sQuery , $this -> iAppId );
return $hResult ;
}
2007-09-24 21:11:29 -04:00
private function _internal_retrieve_unqueued_versions ()
2006-09-26 02:05:55 +00:00
{
$sQuery = " SELECT versionId FROM appVersion WHERE
2007-12-12 20:56:04 +01:00
state = 'accepted' AND
2006-09-26 02:05:55 +00:00
appId = '?' " ;
$hResult = query_parameters ( $sQuery , $this -> iAppId );
return $hResult ;
}
2004-03-15 16:22:00 +00:00
2005-02-06 17:49:48 +00:00
/**
* Creates a new application .
*/
2007-09-24 21:11:29 -04:00
public function create ()
2004-03-15 16:22:00 +00:00
{
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> canCreateApplication ())
2007-08-04 02:02:04 +00:00
return false ;
2005-10-26 02:09:49 +00:00
2007-07-31 23:48:22 +00:00
$hResult = query_parameters ( " INSERT INTO appFamily (appName, description, " .
" keywords, webPage, vendorId, catId, " .
" submitTime, submitterId, " .
2007-12-12 22:25:01 +01:00
" state) VALUES ( " .
2007-07-31 23:48:22 +00:00
" '?', '?', '?', '?', '?', '?', ?, '?', '?') " ,
2006-06-24 04:20:32 +00:00
$this -> sName , $this -> sDescription , $this -> sKeywords ,
$this -> sWebpage , $this -> iVendorId , $this -> iCatId ,
2007-07-31 23:48:22 +00:00
" NOW() " , $_SESSION [ 'current' ] -> iUserId ,
2007-12-12 22:25:01 +01:00
$this -> mustBeQueued () ? 'queued' : 'accepted' );
2006-06-24 04:20:32 +00:00
if ( $hResult )
2005-02-06 17:49:48 +00:00
{
2007-08-03 23:27:25 +00:00
$this -> iAppId = query_appdb_insert_id ();
2005-02-06 17:49:48 +00:00
$this -> application ( $this -> iAppId );
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail (); // Only administrators will be mailed as no supermaintainers exist for this app.
2006-12-09 05:07:25 +00:00
/* Submit super maintainer request if asked to */
2007-01-20 17:41:43 +00:00
if ( $this -> iMaintainerRequest == SUPERMAINTAINER_REQUEST )
2006-12-09 05:07:25 +00:00
{
$oMaintainer = new Maintainer ();
$oMaintainer -> iAppId = $this -> iAppId ;
$oMaintainer -> iUserId = $_SESSION [ 'current' ] -> iUserId ;
$oMaintainer -> sMaintainReason = " This user submitted the application; auto-queued. " ;
$oMaintainer -> bSuperMaintainer = 1 ;
$oMaintainer -> create ();
}
2005-02-06 17:49:48 +00:00
return true ;
2005-10-26 02:09:49 +00:00
} else
{
2006-06-24 04:20:32 +00:00
addmsg ( " Error while creating a new application. " , " red " );
2005-02-06 17:49:48 +00:00
return false ;
2005-10-26 02:09:49 +00:00
}
2004-03-15 16:22:00 +00:00
}
2005-02-06 17:49:48 +00:00
/**
* Update application .
* Returns true on success and false on failure .
*/
2007-09-24 21:11:29 -04:00
public function update ( $bSilent = false )
2004-03-15 16:22:00 +00:00
{
2005-02-09 23:49:56 +00:00
$sWhatChanged = " " ;
2005-10-26 02:09:49 +00:00
/* if the user doesn't have permission to modify this application, don't let them */
if ( ! $_SESSION [ 'current' ] -> canModifyApplication ( $this ))
return ;
2005-10-10 02:37:55 +00:00
/* create an instance of ourselves so we can see what has changed */
$oApp = new Application ( $this -> iAppId );
if ( $this -> sName && ( $this -> sName != $oApp -> sName ))
2005-02-06 17:49:48 +00:00
{
2006-07-04 03:43:06 +00:00
if ( ! query_parameters ( " UPDATE appFamily SET appName = '?' WHERE appId = '?' " ,
$this -> sName , $this -> iAppId ))
2005-02-06 17:49:48 +00:00
return false ;
2005-10-10 02:37:55 +00:00
$sWhatChanged .= " Name was changed from " . $oApp -> sName . " to " . $this -> sName . " . \n \n " ;
2005-02-06 17:49:48 +00:00
}
2005-10-10 02:37:55 +00:00
if ( $this -> sDescription && ( $this -> sDescription != $oApp -> sDescription ))
2005-02-06 17:49:48 +00:00
{
2006-07-04 03:43:06 +00:00
if ( ! query_parameters ( " UPDATE appFamily SET description = '?' WHERE appId = '?' " ,
$this -> sDescription , $this -> iAppId ))
2005-02-06 17:49:48 +00:00
return false ;
2005-10-10 02:37:55 +00:00
$sWhatChanged .= " Description was changed from \n " . $oApp -> sDescription . " \n to \n " . $this -> sDescription . " . \n \n " ;
2005-02-06 17:49:48 +00:00
}
2004-03-15 16:22:00 +00:00
2005-10-10 02:37:55 +00:00
if ( $this -> sKeywords && ( $this -> sKeywords != $oApp -> sKeywords ))
2005-02-06 17:49:48 +00:00
{
2006-07-04 03:43:06 +00:00
if ( ! query_parameters ( " UPDATE appFamily SET keywords = '?' WHERE appId = '?' " ,
$this -> sKeywords , $this -> iAppId ))
2005-02-06 17:49:48 +00:00
return false ;
2005-10-10 02:37:55 +00:00
$sWhatChanged .= " Keywords were changed from \n " . $oApp -> sKeywords . " \n to \n " . $this -> sKeywords . " . \n \n " ;
2005-02-06 17:49:48 +00:00
}
2007-10-30 00:09:15 +01:00
if ( $this -> sWebpage != $oApp -> sWebpage )
2005-02-06 17:49:48 +00:00
{
2006-07-04 03:43:06 +00:00
if ( ! query_parameters ( " UPDATE appFamily SET webPage = '?' WHERE appId = '?' " ,
2006-07-10 23:02:03 +00:00
$this -> sWebpage , $this -> iAppId ))
2005-02-06 17:49:48 +00:00
return false ;
2005-10-10 02:37:55 +00:00
$sWhatChanged .= " Web page was changed from " . $oApp -> sWebpage . " to " . $this -> sWebpage . " . \n \n " ;
2005-02-06 17:49:48 +00:00
}
2005-10-10 02:37:55 +00:00
if ( $this -> iVendorId && ( $this -> iVendorId != $oApp -> iVendorId ))
2005-02-06 17:49:48 +00:00
{
2006-07-04 03:43:06 +00:00
if ( ! query_parameters ( " UPDATE appFamily SET vendorId = '?' WHERE appId = '?' " ,
$this -> iVendorId , $this -> iAppId ))
2005-02-06 17:49:48 +00:00
return false ;
2005-10-10 02:37:55 +00:00
$oVendorBefore = new Vendor ( $oApp -> iVendorId );
$oVendorAfter = new Vendor ( $this -> iVendorId );
2006-04-16 16:33:41 +00:00
$sWhatChanged .= " Vendor was changed from " . $oVendorBefore -> sName . " to " . $oVendorAfter -> sName . " . \n \n " ;
2005-02-06 17:49:48 +00:00
}
2005-02-07 23:21:33 +00:00
2005-10-10 02:37:55 +00:00
if ( $this -> iCatId && ( $this -> iCatId != $oApp -> iCatId ))
2005-02-07 23:21:33 +00:00
{
2006-07-04 03:43:06 +00:00
if ( ! query_parameters ( " UPDATE appFamily SET catId = '?' WHERE appId = '?' " ,
$this -> iCatId , $this -> iAppId ))
2005-02-07 23:21:33 +00:00
return false ;
2005-10-10 02:37:55 +00:00
$oCatBefore = new Category ( $oApp -> iCatId );
$oCatAfter = new Category ( $this -> iCatId );
2007-01-06 18:14:36 +00:00
$sWhatChanged .= " Category was changed from " . $oCatBefore -> sName . " to " . $oCatAfter -> sName . " . \n \n " ;
2005-02-07 23:21:33 +00:00
}
2006-01-28 23:04:21 +00:00
if ( $sWhatChanged and ! $bSilent )
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail ( " edit " , $sWhatChanged );
2005-02-06 17:49:48 +00:00
return true ;
2004-03-15 16:22:00 +00:00
}
2007-12-12 22:43:22 +01:00
/**
* Deletes the application from the database .
* and request the deletion of linked elements .
*/
public function purge ()
{
$bSuccess = true ;
/* make sure the current user has the appropriate permission to delete
this application */
if ( ! $_SESSION [ 'current' ] -> canDeleteApplication ( $this ))
return false ;
foreach ( $this -> objectGetChildren ( true ) as $oChild )
{
if ( ! $oChild -> purge ())
$bSuccess = FALSE ;
}
/* Flag the entry as deleted */
$sQuery = " DELETE FROM appFamily
WHERE appId = '?'
LIMIT 1 " ;
if ( ! ( $hResult = query_parameters ( $sQuery , $this -> iAppId )))
$bSuccess = false ;
return $bSuccess ;
}
/**
* Falgs the application as deleted
2005-02-06 17:49:48 +00:00
* and request the deletion of linked elements .
*/
2007-09-24 21:11:29 -04:00
public function delete ()
2004-03-15 16:22:00 +00:00
{
2007-07-26 03:47:34 +00:00
$bSuccess = true ;
2005-10-26 02:09:49 +00:00
/* make sure the current user has the appropriate permission to delete
this application */
if ( ! $_SESSION [ 'current' ] -> canDeleteApplication ( $this ))
return false ;
2005-08-05 22:07:41 +00:00
2007-09-08 22:38:20 +00:00
foreach ( $this -> objectGetChildren () as $oChild )
2005-06-30 01:59:32 +00:00
{
2007-09-08 22:38:20 +00:00
if ( ! $oChild -> delete ())
$bSuccess = FALSE ;
2005-06-30 01:59:32 +00:00
}
2007-12-12 22:43:22 +01:00
/* Flag the entry as deleted */
$sQuery = " UPDATE appFamily SET state = 'deleted'
2006-06-27 19:16:27 +00:00
WHERE appId = '?'
2005-02-06 17:49:48 +00:00
LIMIT 1 " ;
2006-06-27 19:16:27 +00:00
if ( ! ( $hResult = query_parameters ( $sQuery , $this -> iAppId )))
2007-09-08 22:38:20 +00:00
$bSuccess = false ;
2005-06-30 01:59:32 +00:00
2007-07-26 03:47:34 +00:00
return $bSuccess ;
2005-02-06 17:49:48 +00:00
}
2004-03-15 16:22:00 +00:00
2005-02-06 17:49:48 +00:00
/**
* Move application out of the queue .
*/
2007-09-24 21:11:29 -04:00
public function unQueue ()
2005-02-06 17:49:48 +00:00
{
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> canUnQueueApplication ())
return ;
2007-12-12 22:25:01 +01:00
if ( query_parameters ( " UPDATE appFamily SET state = '?', keywords = '?' WHERE appId = '?' " ,
'accepted' , str_replace ( " *** " , " " , $this -> sKeywords ), $this -> iAppId ))
2005-02-06 17:49:48 +00:00
{
2007-12-12 22:25:01 +01:00
$this -> sState = 'accepted' ;
2006-12-31 19:39:41 +00:00
// we send an e-mail to interested people
2005-02-06 17:49:48 +00:00
$this -> mailSubmitter ();
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail ();
2006-12-09 05:07:25 +00:00
/* Unqueue matching super maintainer request */
$hResultMaint = query_parameters ( " SELECT maintainerId FROM appMaintainers WHERE userId = '?' AND appId = '?' " , $this -> iSubmitterId , $this -> iAppId );
2007-08-03 23:27:25 +00:00
if ( $hResultMaint && query_num_rows ( $hResultMaint ))
2006-12-09 05:07:25 +00:00
{
2007-08-03 23:27:25 +00:00
$oMaintainerRow = query_fetch_object ( $hResultMaint );
2006-12-09 05:07:25 +00:00
$oMaintainer = new Maintainer ( $oMaintainerRow -> maintainerId );
$oMaintainer -> unQueue ( " OK " );
}
2005-02-06 17:49:48 +00:00
}
2004-03-15 16:22:00 +00:00
}
2007-09-24 21:11:29 -04:00
public function Reject ()
2005-08-15 03:44:03 +00:00
{
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> canRejectApplication ( $this ))
return ;
2005-08-15 03:44:03 +00:00
// If we are not in the queue, we can't move the application out of the queue.
2007-12-12 22:25:01 +01:00
if ( $this -> sState != 'queued' )
2005-08-15 03:44:03 +00:00
return false ;
2007-12-12 22:25:01 +01:00
if ( query_parameters ( " UPDATE appFamily SET state = '?' WHERE appId = '?' " ,
'rejected' , $this -> iAppId ))
2005-08-15 03:44:03 +00:00
{
2007-12-12 22:25:01 +01:00
$this -> sState = 'rejected' ;
2006-12-31 19:39:41 +00:00
// we send an e-mail to interested people
2005-08-15 03:44:03 +00:00
$this -> mailSubmitter ( " reject " );
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail ( " reject " );
2005-02-06 17:49:48 +00:00
2006-12-31 19:39:41 +00:00
// the application has been rejected
2005-08-15 03:44:03 +00:00
addmsg ( " The application has been rejected. " , " green " );
}
}
2007-07-28 20:08:50 +00:00
2007-12-19 15:06:35 +01:00
public static function objectGetItemsPerPage ( $sState = 'accepted' )
2007-07-28 20:08:50 +00:00
{
$aItemsPerPage = array ( 25 , 50 , 100 , 200 );
$iDefaultPerPage = 25 ;
return array ( $aItemsPerPage , $iDefaultPerPage );
}
2007-09-24 21:11:29 -04:00
public function ReQueue ()
2005-08-15 03:44:03 +00:00
{
2005-10-28 00:11:35 +00:00
if ( ! $_SESSION [ 'current' ] -> canRequeueApplication ( $this ))
2005-08-15 03:44:03 +00:00
return false ;
2007-12-12 22:25:01 +01:00
if ( query_parameters ( " UPDATE appFamily SET state = '?' WHERE appId = '?' " ,
'queued' , $this -> iAppId ))
2005-08-15 03:44:03 +00:00
{
2007-12-12 22:25:01 +01:00
$this -> sState = 'queued' ;
2006-12-31 19:39:41 +00:00
// we send an e-mail to interested people
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail ();
2005-08-15 03:44:03 +00:00
// the application has been re-queued
addmsg ( " The application has been re-queued. " , " green " );
}
}
2007-09-24 21:11:29 -04:00
public function objectGetSubmitterId ()
2007-09-14 23:02:12 -04:00
{
return $this -> iSubmitterId ;
}
2007-09-24 21:11:29 -04:00
public function objectGetMailOptions ( $sAction , $bMailSubmitter , $bParentAction )
2007-09-14 23:02:12 -04:00
{
return new mailOptions ();
}
2007-09-24 21:11:29 -04:00
public function objectGetMail ( $sAction , $bMailSubmitter , $bParentAction )
2007-09-14 23:02:12 -04:00
{
if ( $bMailSubmitter )
{
switch ( $sAction )
{
case " delete " :
$sSubject = " Submitted application deleted " ;
$sMsg = " The application you submitted ( " . $this -> sName .
" ) has been deleted. " ;
break ;
}
$aMailTo = null ;
} else
{
switch ( $sAction )
{
case " delete " :
$sSubject = $this -> sName . " deleted " ;
$sMsg = " The application ' " . $this -> sName . " ' has been deleted. " ;
break ;
}
$aMailTo = User :: get_notify_email_address_list ( $this -> iAppId );
}
return array ( $sSubject , $sMsg , $aMailTo );
}
2007-09-24 21:11:29 -04:00
private function mailSubmitter ( $sAction = " add " )
2004-03-15 16:22:00 +00:00
{
2007-01-04 02:35:01 +00:00
global $aClean ;
if ( ! isset ( $aClean [ 'sReplyText' ]))
2006-12-09 05:07:25 +00:00
$aClean [ 'sReplyText' ] = " " ;
2006-06-17 06:10:10 +00:00
2005-02-06 17:49:48 +00:00
if ( $this -> iSubmitterId )
{
$oSubmitter = new User ( $this -> iSubmitterId );
2005-08-15 03:44:03 +00:00
switch ( $sAction )
2005-02-06 17:49:48 +00:00
{
2005-08-15 03:44:03 +00:00
case " add " :
2006-02-22 02:20:02 +00:00
$sSubject = " Submitted application accepted " ;
2007-06-14 00:52:57 +00:00
$sMsg = " The application you submitted ( " . $this -> sName . " ) has been accepted by " . $_SESSION [ 'current' ] -> sRealname . " . \n " ;
2007-01-04 00:36:44 +00:00
$sMsg .= " Administrator's Response: \n " ;
2005-08-15 03:44:03 +00:00
break ;
case " reject " :
2006-02-22 02:20:02 +00:00
$sSubject = " Submitted application rejected " ;
2006-12-09 04:29:20 +00:00
$sMsg = " The application you submitted ( " . $this -> sName . " ) has been rejected by " . $_SESSION [ 'current' ] -> sRealname . " . " ;
2006-02-22 02:20:02 +00:00
$sMsg .= " Clicking on the link in this email will allow you to modify and resubmit the application. " ;
$sMsg .= " A link to your queue of applications and versions will also show up on the left hand side of the Appdb site once you have logged in. " ;
2007-04-24 23:48:14 +00:00
$sMsg .= APPDB_ROOT . " objectManager.php?sClass=application_queue " .
2008-02-23 12:06:24 +11:00
" &bIsQueue=true&bIsRejected=true&iId= " . $this -> iAppId . " &sTitle= " .
2007-04-24 23:48:14 +00:00
" Edit+Application \n " ;
2006-02-22 02:20:02 +00:00
$sMsg .= " Reason given: \n " ;
2005-08-15 03:44:03 +00:00
break ;
2007-06-14 00:52:57 +00:00
}
2005-08-15 03:44:03 +00:00
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ;
2005-02-06 17:49:48 +00:00
$sMsg .= " We appreciate your help in making the Application Database better for all users. " ;
2007-06-14 00:52:57 +00:00
2005-02-06 17:49:48 +00:00
mail_appdb ( $oSubmitter -> sEmail , $sSubject , $sMsg );
}
2004-03-15 16:22:00 +00:00
}
2004-11-09 22:42:12 +00:00
2006-09-27 02:44:16 +00:00
2007-09-24 21:11:29 -04:00
public static function countWithRating ( $sRating )
2006-09-27 02:44:16 +00:00
{
$sQuery = " SELECT DISTINCT count(appId) as total
FROM appVersion
2007-12-28 22:57:02 +01:00
WHERE rating = '?'
2007-12-12 22:25:01 +01:00
AND state = 'accepted' " ;
2006-09-27 02:44:16 +00:00
if ( $hResult = query_parameters ( $sQuery , $sRating ))
{
2007-08-03 23:27:25 +00:00
$oRow = query_fetch_object ( $hResult );
2006-09-27 02:44:16 +00:00
}
return $oRow -> total ;
}
2007-09-24 21:11:29 -04:00
public static function getWithRating ( $sRating , $iOffset , $iItemsPerPage )
2006-09-27 02:44:16 +00:00
{
$aApps = array ();
2008-02-25 20:25:49 +01:00
$sQuery = " SELECT DISTINCT appVersion.appId, appName
FROM appVersion , appFamily WHERE
appVersion . appId = appFamily . appId
AND
rating = '?'
AND
appVersion . state = 'accepted'
ORDER BY appName ASC LIMIT ? , ? " ;
2006-09-27 02:44:16 +00:00
if ( $hResult = query_parameters ( $sQuery , $sRating , $iOffset , $iItemsPerPage ))
{
2007-08-03 23:27:25 +00:00
while ( $aRow = query_fetch_row ( $hResult ))
2006-09-27 02:44:16 +00:00
{
array_push ( $aApps , $aRow [ 0 ]);
}
}
return $aApps ;
}
2007-09-24 21:11:29 -04:00
private function SendNotificationMail ( $sAction = " add " , $sMsg = null )
2004-12-25 20:03:34 +00:00
{
2007-01-04 02:35:01 +00:00
global $aClean ;
if ( ! isset ( $aClean [ 'sReplyText' ]))
2006-11-25 17:24:44 +00:00
$aClean [ 'sReplyText' ] = " " ;
2006-06-17 06:10:10 +00:00
2005-02-09 23:49:56 +00:00
switch ( $sAction )
2005-02-06 17:49:48 +00:00
{
2005-02-09 23:49:56 +00:00
case " add " :
2007-12-12 22:25:01 +01:00
if ( $this -> sState == 'accepted' ) // Has been accepted.
2005-02-09 23:49:56 +00:00
{
$sSubject = $this -> sName . " has been added by " . $_SESSION [ 'current' ] -> sRealname ;
2007-04-03 02:08:44 +00:00
$sMsg = $this -> objectMakeUrl () . " \n " ;
2005-02-09 23:49:56 +00:00
if ( $this -> iSubmitterId )
{
$oSubmitter = new User ( $this -> iSubmitterId );
$sMsg .= " This application has been submitted by " . $oSubmitter -> sRealname . " . " ;
$sMsg .= " \n " ;
}
2006-07-13 18:54:10 +00:00
if ( $aClean [ 'sReplyText' ])
2006-02-22 02:20:02 +00:00
{
$sMsg .= " Appdb admin reply text: \n " ;
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ; // append the reply text, if there is any
2006-02-22 02:20:02 +00:00
}
2005-02-09 23:49:56 +00:00
addmsg ( " The application was successfully added into the database. " , " green " );
2006-01-28 23:04:21 +00:00
} else
2005-02-06 17:49:48 +00:00
{
2005-02-09 23:49:56 +00:00
$sSubject = $this -> sName . " has been submitted by " . $_SESSION [ 'current' ] -> sRealname ;
$sMsg .= " This application has been queued. " ;
2005-02-06 17:49:48 +00:00
$sMsg .= " \n " ;
2005-08-15 03:44:03 +00:00
addmsg ( " The application you submitted will be added to the database after being reviewed. " , " green " );
2005-02-06 17:49:48 +00:00
}
2005-02-09 23:49:56 +00:00
break ;
case " edit " :
$sSubject = $this -> sName . " has been modified by " . $_SESSION [ 'current' ] -> sRealname ;
2007-04-03 02:08:44 +00:00
$sMsg .= $this -> objectMakeUrl () . " \n " ;
2005-02-09 23:49:56 +00:00
addmsg ( " Application modified. " , " green " );
break ;
2005-08-15 03:44:03 +00:00
case " reject " :
$sSubject = $this -> sName . " has been rejected by " . $_SESSION [ 'current' ] -> sRealname ;
2007-04-24 23:48:14 +00:00
$sMsg .= APPDB_ROOT . " objectManager.php?sClass=application_queue " .
2008-02-23 12:06:24 +11:00
" &bIsQueue=true&bIsRejected=true&iId= " . $this -> iAppId . " &sTitle= " .
2007-04-24 23:48:14 +00:00
" Edit+Application \n " ;
2005-08-15 03:44:03 +00:00
2006-07-13 18:54:10 +00:00
// if sReplyText is set we should report the reason the application was rejected
if ( $aClean [ 'sReplyText' ])
2005-08-15 03:44:03 +00:00
{
$sMsg .= " Reason given: \n " ;
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ; // append the reply text, if there is any
2005-08-15 03:44:03 +00:00
}
addmsg ( " Application rejected. " , " green " );
break ;
2005-02-06 17:49:48 +00:00
}
2006-06-29 15:54:29 +00:00
$sEmail = User :: get_notify_email_address_list ( $this -> iAppId );
2005-02-06 17:49:48 +00:00
if ( $sEmail )
mail_appdb ( $sEmail , $sSubject , $sMsg );
}
2005-10-10 02:37:55 +00:00
2007-10-23 14:16:00 +02:00
public function objectShowPreview ()
{
return TRUE ;
}
2005-10-10 02:37:55 +00:00
/* output a html table and this applications values to the fields for editing */
2007-09-24 21:11:29 -04:00
public function outputEditor ( $sVendorName = " " )
2005-10-10 02:37:55 +00:00
{
HtmlAreaLoaderScript ( array ( " app_editor " ));
2006-07-06 17:27:54 +00:00
echo '<input type="hidden" name="iAppId" value="' . $this -> iAppId . '">' ;
2005-10-16 04:24:37 +00:00
2007-04-24 23:48:14 +00:00
/* Used to distinguish between the first step of entering an application
name and the full editor displayed here */
2008-02-23 12:06:24 +11:00
echo '<input type="hidden" name="bMainAppForm" value="true">' . " \n " ;
2007-04-24 23:48:14 +00:00
2005-10-10 02:37:55 +00:00
echo html_frame_start ( " Application Form " , " 90% " , " " , 0 );
2007-05-02 01:08:22 +00:00
echo " <table class='color0' width='100%' border=0 cellpadding=2 cellspacing=0> \n " ;
2005-10-10 02:37:55 +00:00
echo '<tr valign=top><td class="color0"><b>Application name</b></td>' , " \n " ;
2006-07-06 17:27:54 +00:00
echo '<td><input size="20" type="text" name="sAppName" value="' . $this -> sName . '"></td></tr>' , " \n " ;
2005-10-10 02:37:55 +00:00
// app Category
$w = new TableVE ( " view " );
echo '<tr valign=top><td class="color0"><b>Category</b></td><td>' , " \n " ;
2007-07-23 19:56:43 +00:00
echo $w -> make_option_list ( " iAppCatId " , $this -> iCatId , " appCategory " , " catId " , " catName " );
2005-10-10 02:37:55 +00:00
echo '</td></tr>' , " \n " ;
2007-09-14 23:42:51 -04:00
$oVendor = new vendor ( $this -> iVendorId );
$sVendorHelp = " The developer of the application. " ;
2007-12-12 22:25:01 +01:00
if ( ! $this -> iAppId || $oVendor -> objectGetState () != 'accepted' )
2007-09-14 23:42:51 -04:00
{
if ( ! $this -> iAppId )
{
$sVendorHelp .= " If it is not on the list please add it " .
" using the form below. " ;
} else
{
$sVendorHelp .= " The user added a new one; review " .
" it in the vendor form below or " .
" replace it with an existing one. " ;
}
}
2005-10-10 02:37:55 +00:00
// vendor name
echo '<tr valign=top><td class="color0"><b>Vendor</b></td>' , " \n " ;
2007-09-14 23:42:51 -04:00
echo " <td> $sVendorHelp </td></tr> \n " ;
2005-10-10 02:37:55 +00:00
// alt vendor
$x = new TableVE ( " view " );
echo '<tr valign=top><td class="color0"> </td><td>' , " \n " ;
2007-07-23 19:56:43 +00:00
echo $x -> make_option_list ( " iAppVendorId " ,
$this -> iVendorId , " vendor " , " vendorId " , " vendorName " ,
2007-12-12 22:25:01 +01:00
array ( 'vendor.state' , 'accepted' ));
2005-10-10 02:37:55 +00:00
echo '</td></tr>' , " \n " ;
// url
echo '<tr valign=top><td class="color0"><b>URL</b></td>' , " \n " ;
2006-07-06 17:27:54 +00:00
echo '<td><input size="20" type=text name="sAppWebpage" value="' . $this -> sWebpage . '"></td></tr>' , " \n " ;
2005-10-10 02:37:55 +00:00
echo '<tr valign=top><td class="color0"><b>Keywords</b></td>' , " \n " ;
2007-05-02 01:08:22 +00:00
echo '<td><input size="75%" type="text" name="sAppKeywords" value="' . $this -> sKeywords . '"></td></tr>' , " \n " ;
2005-10-10 02:37:55 +00:00
2008-05-25 07:30:49 +10:00
echo '<tr valign=top><td class="color0"><b>Application description (In your own words)</b></td>' , " \n " ;
2006-07-06 17:27:54 +00:00
echo '<td><p><textarea cols="80" rows="20" id="app_editor" name="shAppDescription">' ;
2005-10-10 02:37:55 +00:00
2006-06-26 00:44:44 +00:00
echo $this -> sDescription . '</textarea></p></td></tr>' , " \n " ;
2005-10-10 02:37:55 +00:00
2006-12-09 05:07:25 +00:00
// Allow user to apply as super maintainer if this is a new app
if ( ! $this -> iAppId )
{
2007-01-20 17:41:43 +00:00
$sMaintainerOptions =
2008-02-23 12:06:24 +11:00
" <input type= \" radio \" name= \" iMaintainerRequest \" value= \" 0 \" > " .
" I would not like to become a maintainer<br> \n " .
2007-01-20 17:41:43 +00:00
" <input type= \" radio \" name= \" iMaintainerRequest \" " .
2008-02-23 12:06:24 +11:00
" value= \" " . MAINTAINER_REQUEST . " \" > " .
" I would like to be a maintainer of the new version only<br> \n " .
2007-01-20 17:41:43 +00:00
" <input type= \" radio \" name= \" iMaintainerRequest \" " .
2008-02-23 12:06:24 +11:00
" value= \" " . SUPERMAINTAINER_REQUEST . " \" > " .
" I would like to be a maintainer of the entire application<br> \n " ;
2007-01-20 17:41:43 +00:00
$sMaintainerOptionsSelected = str_replace (
" value= \" $this->iMaintainerRequest\ " " ,
" value= \" $this->iMaintainerRequest\ " checked = \ " checked \" " ,
$sMaintainerOptions );
echo html_tr ( array (
array ( " <b>Maintainer options</b> " , " class= \" color0 \" " ),
$sMaintainerOptionsSelected ),
" " , " valign= \" top \" " );
2006-12-09 05:07:25 +00:00
}
2005-10-10 02:37:55 +00:00
echo " </table> \n " ;
echo html_frame_end ();
}
2007-09-24 21:11:29 -04:00
public function CheckOutputEditorInput ( $aValues )
2005-10-10 02:37:55 +00:00
{
$errors = " " ;
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'iAppCatId' ]))
2005-10-10 02:37:55 +00:00
$errors .= " <li>Please enter a category for your application.</li> \n " ;
2006-07-08 22:06:28 +00:00
if ( strlen ( $aValues [ 'sAppName' ]) > 200 )
2005-10-10 02:37:55 +00:00
$errors .= " <li>Your application name is too long.</li> \n " ;
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'sAppName' ]))
2005-10-10 02:37:55 +00:00
$errors .= " <li>Please enter an application name.</li> \n " ;
// No vendor entered, and nothing in the list is selected
2007-01-28 23:28:14 +00:00
if ( empty ( $aValues [ 'sVendorName' ]) && ! $aValues [ 'iAppVendorId' ])
2005-10-10 02:37:55 +00:00
$errors .= " <li>Please enter a vendor.</li> \n " ;
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'shAppDescription' ]))
2005-10-10 02:37:55 +00:00
$errors .= " <li>Please enter a description of your application.</li> \n " ;
return $errors ;
}
2007-01-17 03:18:49 +00:00
/* retrieves values from $aValues that were output by outputEditor() */
/* $aValues can be $_REQUEST or any array with the values from outputEditor() */
2007-09-24 21:11:29 -04:00
public function GetOutputEditorValues ( $aValues )
2005-10-10 02:37:55 +00:00
{
2007-10-22 18:58:15 +02:00
if ( $aValues [ 'iAppId' ])
$this -> iAppId = $aValues [ 'iAppId' ];
2006-07-08 22:06:28 +00:00
$this -> sName = $aValues [ 'sAppName' ];
$this -> sDescription = $aValues [ 'shAppDescription' ];
$this -> iCatId = $aValues [ 'iAppCatId' ];
$this -> iVendorId = $aValues [ 'iAppVendorId' ];
$this -> sWebpage = $aValues [ 'sAppWebpage' ];
$this -> sKeywords = $aValues [ 'sAppKeywords' ];
2007-01-20 17:41:43 +00:00
$this -> iMaintainerRequest = $aValues [ 'iMaintainerRequest' ];
2005-10-10 02:37:55 +00:00
}
2006-01-29 04:04:46 +00:00
2007-09-18 14:04:23 +02:00
/**
* Displays the SUB apps that belong to this application .
2007-09-24 21:11:29 -04:00
*/
public function displayBundle ()
2007-09-18 14:04:23 +02:00
{
$hResult = query_parameters ( " SELECT appFamily.appId, appName, description FROM appBundle, appFamily " .
2007-12-12 22:25:01 +01:00
" WHERE appFamily.state = 'accepted' AND bundleId = '?' AND appBundle.appId = appFamily.appId " ,
2007-09-18 14:04:23 +02:00
$this -> iAppId );
if ( ! $hResult || query_num_rows ( $hResult ) == 0 )
{
return ; // do nothing
}
echo html_frame_start ( " " , " 98% " , " " , 0 );
echo " <table width= \" 100% \" border= \" 0 \" cellpadding= \" 3 \" cellspacing= \" 1 \" > \n \n " ;
echo " <tr class= \" color4 \" > \n " ;
echo " <td>Application Name</td> \n " ;
echo " <td>Description</td> \n " ;
echo " </tr> \n \n " ;
for ( $c = 0 ; $ob = query_fetch_object ( $hResult ); $c ++ )
{
$oApp = new application ( $ob -> appId );
//set row color
$bgcolor = ( $c % 2 == 0 ) ? " color0 " : " color1 " ;
//display row
echo " <tr class= \" $bgcolor\ " > \n " ;
echo " <td> " . $oApp -> objectMakeLink () . " </td> \n " ;
echo " <td> " . util_trim_description ( $oApp -> sDescription ) . " </td> \n " ;
echo " </tr> \n \n " ;
}
echo " </table> \n \n " ;
echo html_frame_end ();
}
2007-09-24 21:11:29 -04:00
public function objectGetCustomTitle ( $sAction )
2007-09-18 14:04:23 +02:00
{
switch ( $sAction )
{
2008-06-03 12:19:17 +02:00
case 'delete' :
return 'Delete ' . $this -> sName ;
2007-09-24 21:35:35 -04:00
case " view " :
2008-02-26 13:17:35 +11:00
return $this -> sName ;
2007-09-18 14:04:23 +02:00
default :
return null ;
}
}
2006-01-29 04:04:46 +00:00
/* display this application */
2007-09-24 21:11:29 -04:00
public function display ()
2006-01-29 04:04:46 +00:00
{
/* is this user supposed to view this version? */
if ( ! $_SESSION [ 'current' ] -> canViewApplication ( $this ))
2007-10-24 17:54:13 +02:00
objectManager :: error_exit ( " You do not have permission to view this entry " );
2006-01-29 04:04:46 +00:00
// cat display
2006-07-11 18:53:06 +00:00
$oCategory = new Category ( $this -> iCatId );
$oCategory -> display ( $this -> iAppId );
2006-01-29 04:04:46 +00:00
// set Vendor
$oVendor = new Vendor ( $this -> iVendorId );
// set URL
$appLinkURL = ( $this -> sWebpage ) ? " <a href= \" " . $this -> sWebpage . " \" > " . substr ( stripslashes ( $this -> sWebpage ), 0 , 30 ) . " </a> " : " " ;
// start display application
echo html_frame_start ( " " , " 98% " , " " , 0 );
echo " <tr><td class=color4 valign=top> \n " ;
echo " <table> \n " ;
echo " <tr><td> \n " ;
echo ' <table width="250" border="0" cellpadding="3" cellspacing="1">' , " \n " ;
echo " <tr class=color0 valign=top><td width= \" 100 \" ><b>Name</b></td><td width='100%'> " . $this -> sName . " </td> \n " ;
echo " <tr class= \" color1 \" ><td><b>Vendor</b></td><td> " .
2007-03-13 20:59:45 +00:00
$oVendor -> objectMakeLink () . " \n " ;
2006-01-29 04:04:46 +00:00
echo " </td></tr> \n " ;
// main URL
2007-01-21 18:06:53 +00:00
echo " <tr class= \" color0 \" ><td><b>URL</b></td><td> " . $appLinkURL . " </td></tr> \n " ;
2006-01-29 04:04:46 +00:00
// optional links
2007-01-19 01:42:56 +00:00
if ( $sUrls = url :: display ( NULL , $this -> iAppId ))
echo $sUrls ;
2006-01-29 04:04:46 +00:00
// image
2006-07-21 04:18:28 +00:00
$img = Screenshot :: get_random_screenshot_img ( $this -> iAppId , null , false );
2006-01-29 04:04:46 +00:00
echo " <tr><td align= \" center \" colspan= \" 2 \" > $img </td></tr> \n " ;
2007-01-19 01:42:56 +00:00
2006-01-29 04:04:46 +00:00
echo " </table> \n " ; /* close of name/vendor/bugs/url table */
echo " </td></tr> \n " ;
echo " <tr><td> \n " ;
// Display all supermaintainers maintainers of this application
echo " <table class= \" color4 \" width= \" 250 \" border= \" 1 \" > \n " ;
echo " <tr><td align= \" left \" ><b>Super maintainers:</b></td></tr> \n " ;
2006-07-24 16:20:40 +00:00
$other_maintainers = Maintainer :: getSuperMaintainersUserIdsFromAppId ( $this -> iAppId );
2006-01-29 04:04:46 +00:00
if ( $other_maintainers )
{
echo " <tr><td align= \" left \" ><ul> \n " ;
while ( list ( $index , $userIdValue ) = each ( $other_maintainers ))
{
$oUser = new User ( $userIdValue );
2007-03-31 17:25:12 +00:00
echo " <li> " . $oUser -> objectMakeLink () . " </li> \n " ;
2006-01-29 04:04:46 +00:00
}
echo " </ul></td></tr> \n " ;
} else
{
echo " <tr><td align=right>No maintainers.Volunteer today!</td></tr> \n " ;
}
// Display the app maintainer button
echo ' <tr><td align="center">' ;
if ( $_SESSION [ 'current' ] -> isLoggedIn ())
{
/* are we already a maintainer? */
if ( $_SESSION [ 'current' ] -> isSuperMaintainer ( $this -> iAppId )) /* yep */
{
2006-07-06 17:27:54 +00:00
echo ' <form method="post" name="sMessage" action="maintainerdelete.php"><input type=submit value="Remove yourself as a super maintainer" class="button">' ;
2006-01-29 04:04:46 +00:00
} else /* nope */
{
2008-02-23 12:06:24 +11:00
echo ' <form method="post" name="sMessage" action="objectManager.php?sClass=maintainer&iAppId=' . $this -> iAppId . '&sAction=add&sTitle=' . urlencode ( " Be a Super Maintainer for " . $this -> sName ) . '&sReturnTo=' . urlencode ( $this -> objectMakeUrl ()) . '"><input type="submit" value="Be a super maintainer of this app" class="button" title="Click here to know more about super maintainers.">' ;
2006-01-29 04:04:46 +00:00
}
2006-07-06 17:27:54 +00:00
echo " <input type= \" hidden \" name= \" iAppId \" value= \" " . $this -> iAppId . " \" > " ;
echo " <input type= \" hidden \" name= \" iSuperMaintainer \" value= \" 1 \" > " ; /* set superMaintainer to 1 because we are at the appFamily level */
2006-01-29 04:04:46 +00:00
echo " </form> " ;
if ( $_SESSION [ 'current' ] -> isSuperMaintainer ( $this -> iAppId ) || $_SESSION [ 'current' ] -> hasPriv ( " admin " ))
{
2006-07-07 19:23:58 +00:00
echo ' <form method="post" name="sEdit" action="admin/editAppFamily.php"><input type="hidden" name="iAppId" value="' . $this -> iAppId . '"><input type="submit" value="Edit Application" class="button"></form>' ;
2006-01-29 04:04:46 +00:00
}
if ( $_SESSION [ 'current' ] -> isLoggedIn ())
{
2007-04-19 23:45:15 +00:00
echo '<form method="post" name="sMessage" action="' .
2008-02-23 12:06:24 +11:00
'objectManager.php?sClass=version_queue&iAppId=' . $this -> iAppId
. '&sTitle=Submit+New+Version&sAction=add">' ;
2006-01-29 04:04:46 +00:00
echo '<input type=submit value="Submit new version" class="button">' ;
echo '</form>' ;
}
if ( $_SESSION [ 'current' ] -> hasPriv ( " admin " ))
{
2008-06-03 12:19:17 +02:00
$url = BASE . " objectManager.php?sClass=application&bIsQueue=false&sAction=delete&iId= " . $this -> iAppId ;
2007-09-14 23:02:12 -04:00
echo " <form method= \" post \" name= \" sEdit \" action= \" javascript:self.location = ' " . $url . " ' \" ><input type= \" submit \" value= \" Delete App \" class= \" button \" ></form> " ;
2006-07-06 17:27:54 +00:00
echo ' <form method="post" name="sEdit" action="admin/editBundle.php"><input type="hidden" name="iBundleId" value="' . $this -> iAppId . '"><input type="submit" value="Edit Bundle" class="button"></form>' ;
2006-01-29 04:04:46 +00:00
}
} else
{
2006-07-06 17:27:54 +00:00
echo '<form method="post" action="account.php?sCmd=login"><input type="submit" value="Log in to become a super maintainer" class="button"></form>' ;
2006-01-29 04:04:46 +00:00
}
echo " </td></tr> \n " ;
echo " </table> \n " ; /* close of super maintainers table */
echo " </td></tr> \n " ;
echo " </table> \n " ; /* close the table that contains the whole left hand side of the upper table */
// description
echo " <td class=color2 valign=top width='100%'> \n " ;
2007-04-23 02:33:19 +00:00
echo " <div class='info_container'> \n " ;
echo " \t <div class='title_class'> \n " ;
echo " \t \t Description \n " ;
echo " \t </div> \n " ; // close the 'title_class' div
echo " \t <div class='info_contents'> \n " ;
echo " \t \t " . $this -> sDescription . " \n " ;
echo " \t </div> \n " ; // close the 'info_contents' div
echo " </div> \n " ; // close the 'info_container' div
2006-01-29 04:04:46 +00:00
echo html_frame_end ( " For more details and user comments, view the versions of this application. " );
// display versions
2007-10-23 14:16:00 +02:00
Version :: displayList ( $this -> getVersions ());
2006-01-29 04:04:46 +00:00
// display bundle
2007-09-18 14:04:23 +02:00
$this -> displayBundle ();
2006-01-29 04:04:46 +00:00
}
2005-02-02 02:38:20 +00:00
2007-09-24 21:11:29 -04:00
public static function lookup_name ( $appId )
2006-06-29 16:07:19 +00:00
{
if ( ! $appId ) return null ;
$result = query_parameters ( " SELECT appName FROM appFamily WHERE appId = '?' " ,
$appId );
2007-08-03 23:27:25 +00:00
if ( ! $result || query_num_rows ( $result ) != 1 )
2006-06-29 16:07:19 +00:00
return null ;
2007-08-03 23:27:25 +00:00
$ob = query_fetch_object ( $result );
2006-06-29 16:07:19 +00:00
return $ob -> appName ;
}
2005-10-28 00:11:35 +00:00
2006-12-27 03:26:16 +00:00
/* List applications submitted by a given user */
2007-09-24 21:11:29 -04:00
public static function listSubmittedBy ( $iUserId , $bQueued = true )
2006-12-27 03:26:16 +00:00
{
2007-03-13 20:59:45 +00:00
$hResult = query_parameters ( " SELECT appId, appName, vendorId, description,
submitTime FROM appFamily
WHERE
submitterId = '?'
AND
2007-12-12 22:25:01 +01:00
state = '?'
ORDER BY appId " , $iUserId , $bQueued ? 'queued' : 'accepted');
2006-12-27 03:26:16 +00:00
2007-08-03 23:27:25 +00:00
if ( ! $hResult || ! query_num_rows ( $hResult ))
2006-12-27 03:26:16 +00:00
return false ;
2007-07-23 19:56:43 +00:00
$oTable = new Table ();
$oTable -> SetWidth ( " 100% " );
$oTable -> SetAlign ( " center " );
$oTableRow = new TableRow ();
$oTableRow -> AddTextCell ( " Application " );
$oTableRow -> AddTextCell ( " Description " );
$oTableRow -> AddTextCell ( " Vendor " );
$oTableRow -> AddTextCell ( " Submission Date " );
$oTableRow -> SetClass ( " color4 " );
$oTable -> SetHeader ( $oTableRow );
2006-12-27 03:26:16 +00:00
2007-12-21 21:48:15 +01:00
if ( $bQueued )
$oTableRow -> addTextCell ( " Action " );
2007-08-03 23:27:25 +00:00
for ( $i = 1 ; $oRow = query_fetch_object ( $hResult ); $i ++ )
2007-03-13 20:59:45 +00:00
{
2007-07-23 19:56:43 +00:00
2007-03-13 20:59:45 +00:00
$oVendor = new vendor ( $oRow -> vendorId );
2007-04-03 02:08:44 +00:00
$oApp = new application ( $oRow -> appId );
2007-07-23 19:56:43 +00:00
$oTableRow = new TableRow ();
$oTableRow -> AddTextCell ( $oApp -> objectMakeLink ());
$oTableRow -> AddTextCell ( $oRow -> description );
$oTableRow -> AddTextCell ( $oVendor -> objectMakeLink ());
2007-07-31 23:48:22 +00:00
$oTableRow -> AddTextCell ( print_date ( mysqldatetime_to_unixtimestamp ( $oRow -> submitTime )));
2007-07-23 19:56:43 +00:00
$oTableRow -> SetClass (( $i % 2 ) ? " color0 " : " color1 " );
2007-12-21 21:48:15 +01:00
if ( $bQueued )
{
$oM = new objectManager ( 'application' );
$oM -> setReturnTo ( array_key_exists ( 'REQUEST_URI' , $_SERVER ) ? $_SERVER [ 'REQUEST_URI' ] : " " );
$shDeleteLink = '<a href="' . $oM -> makeUrl ( " delete " , $oApp -> iAppId , " Delete entry " ) . '">delete</a>' ;
$shEditLink = '<a href="' . $oM -> makeUrl ( " edit " , $oApp -> iAppId , " Edit entry " ) . '">edit</a>' ;
$oTableRow -> addTextCell ( " [ $shEditLink ] [ $shDeleteLink ] " );
}
2007-07-23 19:56:43 +00:00
$oTable -> AddRow ( $oTableRow );
2007-03-13 20:59:45 +00:00
}
2006-12-27 03:26:16 +00:00
2007-07-23 19:56:43 +00:00
return $oTable -> GetString ();
2006-12-27 03:26:16 +00:00
}
2007-03-13 00:26:31 +00:00
2007-09-24 21:11:29 -04:00
public function objectMakeUrl ()
2007-03-24 02:04:16 +00:00
{
2008-02-23 12:06:24 +11:00
$sUrl = APPDB_ROOT . " objectManager.php?sClass=application&iId= $this->iAppId " ;
2007-03-24 02:04:16 +00:00
return $sUrl ;
}
2007-09-24 21:11:29 -04:00
public function objectMakeLink ()
2007-03-13 00:26:31 +00:00
{
2007-03-24 02:04:16 +00:00
$sLink = " <a href= \" " . $this -> objectMakeUrl () . " \" > " .
2007-03-13 00:26:31 +00:00
$this -> sName . " </a> " ;
return $sLink ;
}
2007-03-17 23:45:54 +00:00
2008-04-12 21:50:02 +02:00
public static function objectGetDefaultSort ()
{
return 'appId' ;
}
2008-04-14 01:26:37 +02:00
public static function objectGetEntries ( $sState , $iRows = 0 , $iStart = 0 , $sOrderBy = " appId " , $bAscending = TRUE , $oFilters = null )
2007-03-17 23:45:54 +00:00
{
2007-07-28 20:08:50 +00:00
$sLimit = " " ;
2007-11-08 17:32:00 +01:00
$sOrdering = $bAscending ? " ASC " : " DESC " ;
2007-07-28 20:08:50 +00:00
2008-04-14 01:26:37 +02:00
$sExtraTables = '' ;
$sWhereFilter = $oFilters ? $oFilters -> getWhereClause () : '' ;
if ( $sWhereFilter )
{
$sExtraTables = ',appVersion' ;
$sWhereFilter = " AND appVersion.appId = appFamily.appId AND $sWhereFilter " ;
}
2007-07-28 20:08:50 +00:00
/* Should we add a limit clause to the query? */
if ( $iRows || $iStart )
{
$sLimit = " LIMIT ?,? " ;
/* Selecting 0 rows makes no sense , so we assume the user wants to select all of them
after an offset given by iStart */
if ( ! $iRows )
2008-01-20 21:31:15 +01:00
$iRows = application :: objectGetEntriesCount ( $sState );
2007-07-28 20:08:50 +00:00
}
2008-04-14 01:26:37 +02:00
$sQuery = " SELECT DISTINCT(appFamily.appId), appFamily.*, vendor.vendorName AS vendorName FROM appFamily, vendor $sExtraTables WHERE
2007-11-13 19:51:23 +01:00
appFamily . vendorId = vendor . vendorId
AND
2008-04-14 01:26:37 +02:00
appFamily . state = '?' $sWhereFilter " ;
2007-03-17 23:45:54 +00:00
2008-01-20 21:31:15 +01:00
if ( $sState != 'accepted' && ! application :: canEdit ())
2007-03-17 23:45:54 +00:00
{
2007-04-22 00:02:30 +00:00
/* Without global edit rights a user can only view his rejected apps */
2008-01-20 21:31:15 +01:00
if ( $sState != 'rejected' )
2007-04-22 00:02:30 +00:00
return FALSE ;
2007-11-08 17:32:00 +01:00
$sQuery .= " AND appFamily.submitterId = '?' ORDER BY ? ? $sLimit " ;
2007-07-28 20:08:50 +00:00
if ( $sLimit )
{
2007-12-12 22:25:01 +01:00
$hResult = query_parameters ( $sQuery , $sState ,
2007-07-28 20:08:50 +00:00
$_SESSION [ 'current' ] -> iUserId , $sOrderBy ,
2007-11-08 17:32:00 +01:00
$sOrdering , $iStart , $iRows );
2007-07-28 20:08:50 +00:00
} else
{
2007-12-12 22:25:01 +01:00
$hResult = query_parameters ( $sQuery , $sState ,
2007-11-08 17:32:00 +01:00
$_SESSION [ 'current' ] -> iUserId , $sOrderBy ,
$sOrdering );
2007-07-28 20:08:50 +00:00
}
2007-03-17 23:45:54 +00:00
} else
{
2007-11-08 17:32:00 +01:00
$sQuery .= " ORDER BY ? ? $sLimit " ;
2007-07-28 20:08:50 +00:00
if ( $sLimit )
{
2007-12-12 22:25:01 +01:00
$hResult = query_parameters ( $sQuery , $sState , $sOrderBy , $sOrdering ,
2007-07-28 20:08:50 +00:00
$iStart , $iRows );
} else
{
2007-12-12 22:25:01 +01:00
$hResult = query_parameters ( $sQuery , $sState , $sOrderBy , $sOrdering );
2007-07-28 20:08:50 +00:00
}
2007-03-17 23:45:54 +00:00
}
if ( ! $hResult )
return FALSE ;
return $hResult ;
}
2008-04-14 01:26:37 +02:00
public static function objectGetFilterInfo ()
{
$oFilter = new FilterInterface ();
2008-06-12 23:39:04 +02:00
$aCategories = category :: getOrderedList ();
$aCatNames = array ();
$aCatIds = array ();
foreach ( $aCategories as $oCategory )
{
$aCatNames [] = $oCategory -> sName ;
$aCatIds [] = $oCategory -> objectGetId ();
}
2008-04-14 01:26:37 +02:00
$oFilter -> AddFilterInfo ( 'appVersion.rating' , 'Rating' , array ( FILTER_EQUALS , FILTER_LESS_THAN , FILTER_GREATER_THAN ), FILTER_VALUES_ENUM , array ( 'Platinum' , 'Gold' , 'Silver' , 'Bronze' , 'Garbage' ));
2008-06-12 23:39:04 +02:00
$oFilter -> AddFilterInfo ( 'appFamily.catId' , 'Category' , array ( FILTER_EQUALS ), FILTER_VALUES_ENUM , $aCatIds , $aCatNames );
2008-04-14 01:26:37 +02:00
return $oFilter ;
}
2007-11-08 17:32:00 +01:00
public static function objectGetSortableFields ()
{
2007-11-13 19:51:23 +01:00
return array ( 'submitTime' , 'appName' , 'appId' , 'userName' , 'vendorName' );
2007-11-08 17:32:00 +01:00
}
2007-09-24 21:11:29 -04:00
public static function objectGetHeader ()
2007-03-17 23:45:54 +00:00
{
2007-11-08 17:32:00 +01:00
$oTableRow = new TableRowSortable ();
2007-11-13 19:51:23 +01:00
$oTableRow -> AddSortableTextCell ( 'Submission Date' , 'submitTime' );
$oTableRow -> AddTextCell ( 'Submitter' );
$oTableRow -> AddSortableTextCell ( 'Vendor' , 'vendorName' );
$oTableRow -> AddSortableTextCell ( 'Application' , 'appName' );
2007-07-31 01:51:40 +00:00
return $oTableRow ;
2007-03-17 23:45:54 +00:00
}
2007-09-24 21:11:29 -04:00
public function objectGetTableRow ()
2007-03-17 23:45:54 +00:00
{
$oUser = new user ( $this -> iSubmitterId );
$oVendor = new vendor ( $this -> iVendorId );
2007-09-14 23:41:02 -04:00
$sVendor = $oVendor -> objectMakeLink ();
2007-03-17 23:45:54 +00:00
2007-07-23 19:56:43 +00:00
$oTableRow = new TableRow ();
2007-07-31 23:48:22 +00:00
$oTableRow -> AddTextCell ( print_date ( mysqldatetime_to_unixtimestamp ( $this -> sSubmitTime )));
2007-07-23 19:56:43 +00:00
$oTableRow -> AddTextCell ( $oUser -> objectMakeLink ());
$oTableRow -> AddTextCell ( $sVendor );
2007-12-12 22:25:01 +01:00
$oTableRow -> AddTextCell (( $this -> sState == 'accepted' ) ? $this -> objectMakeLink () : $this -> sName );
2007-03-17 23:45:54 +00:00
2007-07-23 19:56:43 +00:00
$oOMTableRow = new OMTableRow ( $oTableRow );
return $oOMTableRow ;
2007-03-17 23:45:54 +00:00
}
2007-12-12 22:25:01 +01:00
public function objectGetState ()
{
return $this -> sState ;
}
2007-09-24 21:11:29 -04:00
public function canEdit ()
2007-03-17 23:45:54 +00:00
{
if ( $_SESSION [ 'current' ] -> hasPriv ( " admin " ))
return TRUE ;
2007-07-24 01:45:19 +00:00
if ( isset ( $this ) && is_object ( $this ) && $this -> iAppId )
2007-04-22 00:02:30 +00:00
{
if ( maintainer :: isUserSuperMaintainer ( $_SESSION [ 'current' ],
$this -> iAppId ))
return TRUE ;
2007-12-12 22:25:01 +01:00
if ( $this -> sState != 'accepted' && $this -> iSubmitterId ==
2007-04-22 00:02:30 +00:00
$_SESSION [ 'current' ] -> iUserId )
2007-09-24 22:08:22 -04:00
{
2007-04-22 00:02:30 +00:00
return TRUE ;
2007-09-24 22:08:22 -04:00
}
2007-04-22 00:02:30 +00:00
return FALSE ;
2007-09-24 22:08:22 -04:00
} else
{
2007-03-17 23:45:54 +00:00
return FALSE ;
2007-09-24 22:08:22 -04:00
}
2007-03-17 23:45:54 +00:00
}
2007-09-24 21:11:29 -04:00
public function mustBeQueued ()
2007-04-21 17:51:42 +00:00
{
if ( $_SESSION [ 'current' ] -> hasPriv ( " admin " ))
return FALSE ;
else
return TRUE ;
}
2007-09-24 21:11:29 -04:00
public function objectDisplayQueueProcessingHelp ()
2007-03-17 23:45:54 +00:00
{
echo " <p>This is the list of applications waiting for your approval, " .
" or to be rejected.</p> \n " ;
echo " <p>To view a submission, click on its name. " .
" From that page you can edit, delete or approve it into the AppDB.</p> \n " ;
}
2007-04-03 00:00:48 +00:00
2007-09-24 21:11:29 -04:00
public function objectDisplayAddItemHelp ()
2007-04-24 23:48:14 +00:00
{
/* We don't display the full help on the page where you only input the app name */
if ( ! $this -> sName )
{
echo " <p>First, please enter the name of the application you wish to add. " ;
echo " This will allow you to determine whether there is already " ;
echo " an entry for it in the database.</p> \n " ;
} else
{
echo " <p>This page is for submitting new applications to be added to the \n " ;
echo " database. The application will be reviewed by an AppDB Administrator, \n " ;
echo " and you will be notified via e-mail if it is added to the database or rejected.</p> \n " ;
echo " <p><h2>Before continuing, please ensure that you have</h2> \n " ;
echo " <ul> \n " ;
echo " <li>Entered a valid version for this application. This is the application \n " ;
echo " version, NOT the Wine version (which goes in the test results section of the template)</li> \n " ;
echo " <li>Tested this application under Wine. There are tens of thousands of applications \n " ;
echo " for Windows, we do not need placeholder entries in the database. Please enter as complete \n " ;
echo " as possible test results in the version template provided below</li> \n " ;
echo " </ul></p> " ;
2007-06-10 01:30:28 +00:00
echo " <p>Having app descriptions just sponsoring the app \n " ;
2008-06-01 12:42:00 +10:00
echo " (yes, some vendors want to use the appdb for this) or saying ‘I haven't tried this app with Wine’ " ;
2007-06-10 01:30:28 +00:00
echo " will not help Wine development or Wine users. Application descriptions should be exactly that and only that, \n " ;
echo " they should not contain any information about how well the app works, just what the app is. The same applies to the \n " ;
echo " version information, it should be only information on what is unique or different about that version of the application, \n " ;
echo " not how well that version works or how great you think a new feature is.</p> \n " ;
echo " <p>When you reach the \" Test Form \" part (What works, What doesn't work, etc) please be detailed \n " ;
echo " about how well it worked and if any workarounds were needed but do NOT paste chunks of terminal output.</p> \n " ;
echo " <p>Please write information in proper English with correct grammar and punctuation!</p> \n " ;
2007-04-24 23:48:14 +00:00
echo " <b><span style= \" color:red \" >Please only submit applications/versions that you have tested. \n " ;
echo " Submissions without test information or not using the provided template will be rejected. \n " ;
echo " If you are unable to see the in-browser editors below, please try Firefox, Mozilla or Opera browsers. \n </span></b> " ;
echo " <p>After your application has been added, you will be able to submit screenshots for it, post " ;
echo " messages in its forums or become a maintainer to help others trying to run the application.</p> " ;
}
}
2007-07-23 19:56:43 +00:00
2008-04-14 01:26:37 +02:00
public static function objectGetEntriesCount ( $sState , $oFilters = null )
2007-04-03 00:00:48 +00:00
{
2008-04-14 01:26:37 +02:00
$sExtraTables = '' ;
$sWhereFilter = $oFilters ? $oFilters -> getWhereClause () : '' ;
if ( $sWhereFilter )
{
$sExtraTables = ',appVersion' ;
$sWhereFilter = " AND appVersion.appId = appFamily.appId AND $sWhereFilter " ;
2008-06-12 23:39:04 +02:00
}
2008-04-14 01:26:37 +02:00
2008-01-20 21:31:15 +01:00
if ( $sState != 'accepted' && ! application :: canEdit ())
2007-04-03 00:00:48 +00:00
{
/* Without edit rights users can only resubmit their rejected entries */
if ( ! $bRejected )
return FALSE ;
2008-04-14 01:26:37 +02:00
$sQuery = " SELECT COUNT(DISTINCT(appFamily.appId)) as count FROM appFamily $sExtraTables WHERE
2007-04-03 00:00:48 +00:00
submitterId = '?'
AND
2008-04-14 01:26:37 +02:00
appFamily . state = '?' $sWhereFilter " ;
2007-04-03 00:00:48 +00:00
$hResult = query_parameters ( $sQuery , $_SESSION [ 'current' ] -> iUserId ,
2007-12-12 22:25:01 +01:00
$sState );
2007-04-03 00:00:48 +00:00
} else
{
2008-04-14 01:26:37 +02:00
$sQuery = " SELECT COUNT(DISTINCT(appFamily.appId)) as count FROM appFamily $sExtraTables WHERE appFamily.state = '?' $sWhereFilter " ;
2007-12-12 22:25:01 +01:00
$hResult = query_parameters ( $sQuery , $sState );
2007-04-03 00:00:48 +00:00
}
if ( ! $hResult )
return FALSE ;
2007-08-03 23:27:25 +00:00
if ( ! $oRow = query_fetch_object ( $hResult ))
2007-04-03 00:00:48 +00:00
return FALSE ;
return $oRow -> count ;
}
2007-04-24 23:48:14 +00:00
2007-12-12 22:43:22 +01:00
public function getVersions ( $bIncludeObsolete = TRUE , $bIncludeDeleted = false )
2007-09-08 22:38:20 +00:00
{
2007-10-23 14:16:00 +02:00
/* If no id is set we cannot query for the versions, but perhaps objects are already cached? */
if ( ! $this -> iAppId )
return $this -> aVersions ;
2007-09-08 22:38:20 +00:00
$aVersions = array ();
2007-12-12 22:43:22 +01:00
$hResult = $this -> _internal_retrieve_all_versions ( $bIncludeObsolete , $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
while ( $oRow = mysql_fetch_object ( $hResult ))
$aVersions [] = new version ( $oRow -> versionId );
return $aVersions ;
}
2007-09-08 22:52:00 +00:00
/* Make a drop - down list of this application ' s versions . Optionally set the default
versionId , a version to exclude and whether to not show obsolete versions */
2007-09-24 21:11:29 -04:00
public function makeVersionDropDownList ( $sVarName , $iCurrentId = null , $iExclude = null , $bIncludeObsolete = TRUE )
2007-09-08 22:52:00 +00:00
{
$sMsg = " <select name= \" $sVarName\ " > \n " ;
foreach ( $this -> getVersions () as $oVersion )
{
2007-12-12 20:56:04 +01:00
if ( $oVersion -> objectGetState () != 'accepted' || $oVersion -> iVersionId == $iExclude ||
2007-09-08 22:52:00 +00:00
( ! $bIncludeObsolete && $oVersion -> iObsoleteBy ))
continue ;
$sMsg .= " <option value= \" " . $oVersion -> iVersionId . " \" " ;
if ( $oVersion -> iVersionId == $iCurrentId )
$sMsg .= " selected= \" selected \" " ;
$sMsg .= " > " . $oVersion -> sName . " </option> \n " ;
}
$sMsg .= " </select> \n " ;
return $sMsg ;
}
2007-12-12 22:43:22 +01:00
public function objectGetChildren ( $bIncludeDeleted = false )
2007-09-08 22:38:20 +00:00
{
$aChildren = array ();
/* Get versions */
2007-12-12 22:43:22 +01:00
foreach ( $this -> getVersions ( true , $bIncludeDeleted ) as $oVersion )
2007-09-08 22:38:20 +00:00
{
2007-12-12 22:43:22 +01:00
$aChildren += $oVersion -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oVersion ;
}
/* Get urls */
$sQuery = " SELECT * FROM appData WHERE type = '?' AND appId = '?' " ;
$hResult = query_parameters ( $sQuery , " url " , $this -> iAppId );
if ( ! $hResult )
return FALSE ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oUrl = new url ( 0 , $oRow );
2007-12-12 22:43:22 +01:00
$aChildren += $oUrl -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oUrl ;
}
/* Get maintainers */
$sQuery = " SELECT * FROM appMaintainers WHERE appId = '?' AND superMaintainer = '?' " ;
$hResult = query_parameters ( $sQuery , $this -> iAppId , '1' );
if ( ! $hResult )
return FALSE ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oMaintainer = new maintainer ( 0 , $oRow );
2007-12-12 22:43:22 +01:00
$aChildren += $oMaintainer -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oMaintainer ;
}
return $aChildren ;
}
2007-09-24 21:11:29 -04:00
public function objectMoveChildren ( $iNewId )
2007-04-24 23:48:14 +00:00
{
/* Keep track of how many children we have moved */
$iCount = 0 ;
foreach ( $this -> aVersionsIds as $iVersionId )
{
$oVersion = new version ( $iVersionId );
$oVersion -> iAppId = $iNewId ;
if ( $oVersion -> update ())
$iCount ++ ;
else
return FALSE ;
}
/* If no errors occured we return the number of moved children */
return $iCount ;
}
2007-04-29 23:00:01 +00:00
2007-09-24 21:11:29 -04:00
public static function allowAnonymousSubmissions ()
2007-04-29 23:00:01 +00:00
{
return FALSE ;
}
2007-06-14 00:50:35 +00:00
2007-11-05 18:38:06 +01:00
function objectAllowPurgingRejected ()
{
return TRUE ;
}
public function objectGetSubmitTime ()
{
return mysqltimestamp_to_unixtimestamp ( $this -> sSubmitTime );
}
2007-09-24 21:11:29 -04:00
public function objectGetId ()
2007-06-14 00:50:35 +00:00
{
return $this -> iAppId ;
}
2007-09-08 22:42:34 +00:00
2007-09-24 21:11:29 -04:00
public function objectShowAddEntry ()
2007-09-08 22:42:34 +00:00
{
return TRUE ;
}
2007-03-17 23:45:54 +00:00
}
2004-11-09 22:42:12 +00:00
?>