From 8ea97091fce1329d31bff4fac43d24770846342d Mon Sep 17 00:00:00 2001 From: "psychoticwolf%carolina.rr.com" Date: Fri, 29 Oct 2004 11:06:56 +0000 Subject: [PATCH] Land the new Approval Queue scripts. Fixes Bug 246941, Bug 255287, Bug 255655, Bug 256086. Basic UI for Bug 255305 done. git-svn-id: svn://10.0.0.236/trunk@164595 18797224-902f-48f8-a5cc-f745e15eee43 --- .../webtools/update/developers/approval.php | 454 ++++++++++++------ .../update/developers/itemoverview.php | 2 +- mozilla/webtools/update/developers/main.php | 2 +- 3 files changed, 310 insertions(+), 148 deletions(-) diff --git a/mozilla/webtools/update/developers/approval.php b/mozilla/webtools/update/developers/approval.php index 1e51d235219..5f44e7a366b 100755 --- a/mozilla/webtools/update/developers/approval.php +++ b/mozilla/webtools/update/developers/approval.php @@ -12,179 +12,341 @@ include"$page_header"; include"inc_sidebar.php"; ?> +Access Denied\n"; + echo"You do not have access to the Approval Queue."; + include"$page_footer"; + echo"\n"; + exit; +} +?> + - -

Extensions/Themes Awaiting Approval

- - - - - - - -\n"; - echo"\n"; - echo"\n"; - echo"\n"; - echo"\n"; - echo"\n"; - echo"\n"; +//Function: process_approval(file, action) +// Reusable function for handling the approval process, file should be the DB URI and action is either approve or deny. +// Returns true on success, false on failure. - } - -?> - -
NameRequested by?Last UpdatedWorks with
$i$row[Name] $row[Version]$row2[UserName] - $row2[UserEmail]$date$row[AppName]"; if($row[OSName] != "ALL") { echo" ($row[OSName])"; } echo"
- $i) {$authors .=", ";} - } -$sql = "SELECT `UserName`, `UserEmail`,`date` FROM `t_approvallog` TA INNER JOIN t_userprofiles TU ON TA.UserID=TU.UserID WHERE `ID`='$id' AND `vID`='$_GET[vid]' AND `action`='Approval?' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - $row = mysql_fetch_array($sql_result); - $requestedby = $row["UserName"]; - $requestedon = $row["date"]; - $requestedbyemail = $row["UserEmail"]; -?> - -

Mozilla Update - Approval Requested:

- - -
-
-"> -"> -"> -"> -"> -
-  name          
-  author(s)     
-  id            
-  version       
-  supported apps:
-                
-  requested by: 
-  requested on: 
-  
-  ">Install Now (KB)
-  Download
-  
-  Comments: 
-  
-   
-
-
-«« Return to Approval Queue -
- -"; - - //Firstly, log the comments and action taken.. -$_POST["userid"] = $_SESSION["uid"]; +$userid = $_SESSION["uid"]; +$sql = "SELECT TM.ID, `Name`, `vID` from `t_main` TM INNER JOIN `t_version` TV ON TM.ID = TV.ID WHERE TV.URI = '$file' ORDER BY `vID` ASC"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + while ($row = mysql_fetch_array($sql_result)) { + $id = $row["ID"]; + $vid = $row["vID"]; + $name = $row["Name"]; -$sql = "INSERT INTO `t_approvallog` (`ID`, `vID`, `UserID`, `action`, `date`, `comments`) VALUES ('$_POST[id]', '$_POST[vid]', '$_POST[userid]', '$action', NOW(NULL), '$_POST[comments]');"; -$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); +global $installation, $uninstallation, $newchrome, $appworks, $visualerrors, $allelementsthemed, $cleanprofile, $worksasdescribed, $testbuild, $testos, $comments; + $sql2 = "INSERT INTO `t_approvallog` (`ID`, `vID`, `UserID`, `action`, `date`, `Installation`, `Uninstallation`, `NewChrome`, `AppWorks`, `VisualErrors`, `AllElementsThemed`, `CleanProfile`, `WorksAsDescribed`, `TestBuild`, `TestOS`, `comments`) VALUES ('$id', '$vid', '$userid', '$action_comment', NOW(NULL), '$installation', '$uninstallation', '$newchrome', '$appworks', '$visualerrors', '$allelementsthemed', '$cleanprofile', '$worksasdescribed', '$testbuild', '$testos', '$comments');"; + $sql_result2 = mysql_query($sql2, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + if ($sql_result2) {} else { $operations_failed=="true";} + } + if ($sql_result) {} else { $operations_failed=="true";} -//Secondly, let's move the file to it's new home in /ftp/ for staging... -$sql = "SELECT `Type`,`Name`,`Version`,`URI` from `t_main` TM INNER JOIN t_version TV ON TM.ID=TV.ID WHERE `vID`='$_POST[vid]' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - $row = mysql_fetch_array($sql_result); - $uri = $row["URI"]; - $filename = str_replace ("http://$sitehostname", "$websitepath", $uri); - if (file_exists($filename)) { -if ($row["Type"]=="T") {$type="themes";} else if ($row["Type"]=="E") {$type="extensions";} -$name = str_replace(" ","_",$row["Name"]); -$path = strtolower("$type/$name"); -//http://mozupdates.psychoticwolf.net/files/approval/chatzilla-0.9.63c-ff.xpi - $destination = str_replace("/files/approval",strtolower("/files/ftp/$path"),$filename); +//Secondly, If Stage 1 was successful (and we're approving the file), let's move the file to it's new home in /ftp/ for staging... +$filename = str_replace ("http://$sitehostname/developers/approvalfile.php", "$repositorypath/approval", $file); +if ($action=="approve") { + if (file_exists($filename)) { + if ($type=="T") {$type="themes";} else if ($type=="E") {$type="extensions";} + $path = strtolower("$type/$name"); + $destination = str_replace("approval",strtolower("ftp/$path"),$filename); + $dirpath = "$repositorypath/ftp/$path"; + if (!file_exists($dirpath)) { + mkdir($dirpath,0755); + } + if (rename("$filename", "$destination")) { + //Rename Successfull + } else { + //Rename Unsuccessfull + $operations_failed=="true"; + } + //$ftpurl defined in config.php + $uri = str_replace("$repositorypath/ftp","$ftpurl","$destination"); + } -$dirpath = "$websitepath/files/ftp/$path"; -if (!file_exists($dirpath)) { -mkdir($dirpath,0775); -} -if (!file_exists($destination)) { -rename("$filename", "$destination"); -} +} else if ($action=="deny") { + //We're denying approval on this item, delete the file and set URI to null. + if (file_exists($filename)) {unlink($filename); } + $uri = ""; -$newurl = "http://ftp.mozilla.org/pub/mozilla.org"; -$uri = str_replace("$websitepath/files/ftp","$newurl","$destination"); } //Thirdly, update version record... -$sql = "UPDATE `t_version` SET `URI`='$uri', `approved`='$approved' WHERE `ID`='$_POST[id]' AND `URI`='$row[URI]' LIMIT 5"; +$sql = "UPDATE `t_version` SET `URI`='$uri', `approved`='$approved', `DateUpdated`=NOW(NULL) WHERE `URI`='$file'"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - + if ($sql_result) {} else { $operations_failed=="true";} @include"mail_approval.php"; -echo"Processing Request...
\n"; -echo"Approval Flag set to $action, for $_POST[name] $_POST[version]
\n"; -echo"E-Mail sent to requestee informing them of the action taken along with your comments
\n"; -echo"«« Return to Approval Queue"; -echo""; +if ($operations_failed=="true") { return false; } else { return true; } + +} + +echo"

Processing changes to approval queue, please wait...

\n"; +//echo"
"; print_r($_POST); echo"
\n"; + +for ($i=1; $_POST["maxvid"]>=$i; $i++) { +$type = $_POST["type_$i"]; +$testos = $_POST["testos_$i"]; +$testbuild = $_POST["testbuild_$i"]; +$comments = $_POST["comments_$i"]; +$approval = $_POST["approval_$i"]; +$file = $_POST["file_$i"]; + +if ($_POST["installation_$i"]) { $installation = $_POST["installation_$i"]; } else { $installation = "NO";} +if ($_POST["uninstallation_$i"]) { $uninstallation = $_POST["uninstallation_$i"]; } else { $uninstallation = "NO";} +if ($_POST["appworks_$i"]) { $appworks = $_POST["appworks_$i"]; } else { $appworks = "NO";} +if ($_POST["cleanprofile_$i"]) { $cleanprofile = $_POST["cleanprofile_$i"]; } else { $cleanprofile = "NO";} + +if ($type=="E") { +if ($_POST["newchrome_$i"]) { $newchrome = $_POST["newchrome_$i"]; } else { $newchrome = "NO";} +if ($_POST["worksasdescribed_$i"]) { $worksasdescribed = $_POST["worksasdescribed_$i"]; } else { $worksasdescribed = "NO";} +} else if ($type=="T") { +if ($_POST["visualerrors_$i"]) { $visualerrors = $_POST["visualerrors_$i"]; } else { $visualerrors = "NO";} +if ($_POST["allelementsthemed_$i"]) { $allelementsthemed = $_POST["allelementsthemed_$i"]; } else { $allelementsthemed = "NO";} +} + +if ($approval !="noaction") { +//echo"$i - $file $testos $testbuild $comments $approval
\n"; +//echo"$type - $installation $uninstallation $appworks $cleanprofile $newchrome $worksasdescribed $visualerrors $allelementsthemed
\n"; + +if ($type=="T") { + if ($approval=="YES") { + if ($installation=="YES" and $uninstallation=="YES" and $appworks=="YES" and $cleanprofile=="YES" and $visualerrors=="YES" and $allelementsthemed=="YES" and $testos and $testbuild) { + $approval_result = process_approval($type, $file, "approve"); + } + } else { + if ($testos and $testbuild) { + $approval_result = process_approval($type, $file, "deny"); + } + + } + +} else if ($type=="E") { + if ($approval=="YES") { + if ($installation=="YES" and $uninstallation=="YES" and $appworks=="YES" and $cleanprofile=="YES" and $newchrome=="YES" and $worksasdescribed=="YES" and $testos and $testbuild) { + $approval_result = process_approval($type, $file, "approve"); + } + } else { + if ($testos and $testbuild) { + $approval_result = process_approval($type, $file, "deny"); + } + } +} + +//Approval for this file was successful, print the output message. +$name = $_POST["name_$i"]; +$version = $_POST["version_$i"]; +if ($approval_result) { + if ($approval=="YES") { + echo"$name $version was granted approval
\n"; + } else if ($approval=="NO") { + echo"$name $version was denied approval
\n"; + } + +} + + +} + +} } ?> +

Extensions/Themes Awaiting Approval

+
Approval Log History
+ + + $j) { $authors .=", "; } + } + $categories = ""; $j=""; + $sql2 = "SELECT `CatName` from `t_categoryxref` TCX INNER JOIN `t_categories` TC ON TCX.CategoryID = TC.CategoryID WHERE TCX.ID='$row[ID]' ORDER BY `CatName` ASC"; + $sql_result2 = mysql_query($sql2, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + while ($row2 = mysql_fetch_array($sql_result2)) { $j++; + $categories .="$row2[CatName]"; if (mysql_num_rows($sql_result2) > $j) { $categories .=", "; } + } + + $sql2 = "SELECT `UserName`,`UserEmail`,`date` FROM `t_approvallog` TA INNER JOIN `t_userprofiles` TU ON TA.UserID = TU.UserID WHERE `ID`='$row[ID]' AND `vID`='$row[vID]' and `action`='Approval?' ORDER BY `date` DESC LIMIT 1"; + $sql_result2 = mysql_query($sql2, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + $row2 = mysql_fetch_array($sql_result2); + if ($row2[date]) {$date = $row2[date]; } else { $date = $row[DateUpdated]; } + $date = date("l, F d, Y, g:i:sa", strtotime("$date")); + echo"\n"; + + if ($type=="T") { + $installink = "javascript:void(InstallTrigger.installChrome(InstallTrigger.SKIN,'$row[URI]','$row[Name] $row[Version]'))"; + } else if ($type=="E") { + $installink = "javascript:void(InstallTrigger.install({'$row[Name] $row[Version]':'$row[URI]'}))"; + } + + echo"\n"; + echo"\n"; + if ($row2[UserName]) { + echo"\n"; + } else { + echo"\n"; + } + echo"\n"; + echo"\n"; + echo"\n"; + +//Approval Form for this Extension Item + echo"\n"; + echo"\n"; + + echo"\n"; + } + +echo"\n"; +?> + "0") { ?> + + + + + +

$row[Name] $row[Version] by $authors

( Install Now ) $row[Description] ($categories)
Requested by: $row2[UserName] on $date
Works with: "; + $sql3 = "SELECT `shortname`, `MinAppVer`, `MaxAppVer` FROM `t_version` TV INNER JOIN `t_applications` TA ON TV.AppID = TA.AppID WHERE `URI`='$row[URI]' ORDER BY `AppName` ASC"; + $sql_result3 = mysql_query($sql3, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + while ($row3 = mysql_fetch_array($sql_result3)) { + echo"".ucwords($row3[shortname])." $row3[MinAppVer]-$row3[MaxAppVer] \n"; + } + if($row[OSName] != "ALL") { echo" ($row[OSName])"; } + echo"
\n"; + echo"Install? \n"; + echo"Uninstall? \n"; + echo"App Works? \n"; + echo"Clean Profile? \n"; +if ($type=="E") { + echo"New Chrome? \n"; + echo"Works? \n"; +} else if ($type=="T") { + echo"Visual Errors? \n"; + echo"Theme Complete? \n"; +} + echo"
\n"; + echo"\n"; + echo"\n"; + echo"\n"; + echo"\n"; + echo"Tested On: OSes: \n"; + echo"Apps: \n"; + echo"Comments: "; + echo"
\n"; + echo"Approve? Deny? No Action? \n"; + echo"
  
No items are pending approval at this time
+ + + +

Approval History Log

+Incomplete Basic UI for the Approval History Log. Bug 255305. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \n"; + } +?> +
IDvIDuIDActionDateInstall?Unistall?New Chrome?App Works?Visual Errors?All Elements Themed?Clean Profile?Works As Described?Test Build:Test OS:Comments:
$i.$id$vid$userid$action$date$installation$uninstallation$newchrome$appworks$visualerrors$allelementsthemed$cleanprofile$worksasdescribed$testbuild$testos$comments
+ + diff --git a/mozilla/webtools/update/developers/itemoverview.php b/mozilla/webtools/update/developers/itemoverview.php index 1d7c2489330..f098bd115dc 100755 --- a/mozilla/webtools/update/developers/itemoverview.php +++ b/mozilla/webtools/update/developers/itemoverview.php @@ -58,7 +58,7 @@ echo"Categories: $categories
\n";

Listed Versions

"Pending Approval", "YES"=>"Approved", "NO"=>"Disabled"); +$approved_array = array("?"=>"Pending Approval", "YES"=>"Approved", "NO"=>"Denied", "DISABLED"=>"Disabled"); $sql = "SELECT vID, TV.Version, URI, OSName, approved FROM `t_version` TV INNER JOIN t_os TOS ON TOS.OSID = TV.OSID WHERE `ID`='$id' GROUP BY `URI` ORDER BY `Version`"; diff --git a/mozilla/webtools/update/developers/main.php b/mozilla/webtools/update/developers/main.php index 02d086d20d1..d5735fec489 100755 --- a/mozilla/webtools/update/developers/main.php +++ b/mozilla/webtools/update/developers/main.php @@ -18,7 +18,7 @@ if ($_SESSION["level"] == "admin" or $_SESSION["level"] == "moderator") { $sql ="SELECT TM.ID FROM `t_main` TM INNER JOIN `t_version` TV ON TM.ID = TV.ID -WHERE `approved` = '?' ORDER BY TV.DateUpdated ASC"; +WHERE `approved` = '?' GROUP BY `URI` ORDER BY TV.DateUpdated ASC"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); $num_result = mysql_num_rows($sql_result); ?>