Permalink
Browse files

update script to use www.mozilla.org component and automatically sele…

…ct locale
  • Loading branch information...
1 parent 7845728 commit e5d2303d24f7eea5e819670f2c992da1d06c5c65 @pascalchevrel pascalchevrel committed Oct 31, 2012
Showing with 170 additions and 106 deletions.
  1. +70 −24 bugsfiled.php
  2. +3 −3 controller.inc.php
  3. +97 −79 langconfig.php
View
94 bugsfiled.php
@@ -16,11 +16,11 @@
* The Original Code is Bugzilla C3PO.
*
* The Initial Developer of the Original Code is Mozilla.
- *
+ *
* Portions created by the Initial Developer are Copyright (C) 2___
* the Initial Developer. All Rights Reserved.
*
- * Contributor(s): Milos Dinic <milos@mozilla.com>
+ * Contributor(s): Milos Dinic <milos@mozilla.com>, Pascal Chevrel <pascal@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -35,37 +35,64 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
+function dashboardItem($locale, $bugnumber, $description, $tag='') {
+
+ $value = <<<VALUE
+
+'{$bugnumber}'=> array(
+ '{$bugnumber}',
+ '{$description}',
+ '',
+ array('{$locale}'),
+ array('{$tag}'),
+ array(''),
+ ),
+
+VALUE;
+
+ return $value;
+}
$time_start = microtime(true);
-
-include_once "controller.inc.php";
+
+require_once 'controller.inc.php';
// Populate $locales var with a set of locales
// we want to file bugs for
-$locales = clean_explode($_POST['locales'], ',');
+
+if(isset($_POST['all-locales'])) {
+ $locales = $full_languages;
+} elseif (isset($_POST['locales'])) {
+ $locales = clean_explode($_POST['locales'], ',');
+} else {
+ echo 'error: no locale codes';
+ exit;
+}
+
+sort($locales);
// Summary, or title of the bug;
// An locale tag in form of "[ab-CD]" will preceed it
$bugsummary = $_POST['summary'];
// Login info that we'll get via POST
$xml_data_login = array(
- 'login' => $_POST['username'],
+ 'login' => $_POST['username'],
'password' => $_POST['pwd'],
'remember' => 1,
);
// Data we use for bug creation
// All data is provided on front page
$xml_data_create = array (
- 'product' => $_POST['product'],
- 'component' => $_POST['component'],
- 'version' => $_POST['version'],
- 'op_sys' => 'All', // Operating system
- 'rep_platform' => 'All', // Platform
+ 'product' => $_POST['product'],
+ 'component' => $_POST['component'],
+ 'version' => $_POST['version'],
+ 'op_sys' => 'All', // Operating system
+ 'rep_platform' => 'All', // Platform
'status_whiteboard' => $_POST['whiteboard'],
- 'blocked' => $_POST['blocked'],
- 'assigned_to' => $_POST['assign_to'],
+ 'blocked' => $_POST['blocked'],
+ 'assigned_to' => $_POST['assign_to'],
);
// Set the target for our requests
@@ -76,10 +103,10 @@
// Set cURL options
$curlopts = array(
- CURLOPT_URL => $curl_target,
- CURLOPT_POST => true,
+ CURLOPT_URL => $curl_target,
+ CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
- CURLOPT_HTTPHEADER => array( 'Content-Type: text/xml', 'charset=utf-8' )
+ CURLOPT_HTTPHEADER => array( 'Content-Type: text/xml', 'charset=utf-8' )
);
// Initialize cURL
@@ -89,7 +116,7 @@
// Create a request based on data we got from index.php
$request = xmlrpc_encode_request("User.login", $xml_data_login);
curl_setopt($curl_start, CURLOPT_POSTFIELDS, $request);
-curl_setopt($curl_start, CURLOPT_COOKIEJAR, $cookie); // Get the cookie from Bugzilla
+curl_setopt($curl_start, CURLOPT_COOKIEJAR, $cookie); // Get the cookie from Bugzilla
$response = curl_exec($curl_start); // execute
$response = xmlrpc_decode($response); // Decoded response is logged-in user ID
@@ -105,23 +132,42 @@
// which means we're logged in and session has started
// Now we loop through all locales from a $locales var and file a bug for each one
-foreach($locales as $key => $shortcode)
-{
+echo '<pre>';
+
+foreach ($locales as $key => $shortcode) {
// This set of vars needs to be in the loop as it depends on locale code
$xml_data_create['bug_file_loc'] = str_replace('{{{locale}}}', $shortcode, $_POST['url']);
- $xml_data_create['summary'] = str_replace('{{{locale}}}', $shortcode, $_POST['summary']);
- $xml_data_create['description'] = str_replace('{{{locale}}}', $shortcode, $_POST['description']);
-
+ $xml_data_create['summary'] = str_replace('{{{locale}}}', $shortcode, $_POST['summary']);
+ $xml_data_create['description'] = str_replace('{{{locale}}}', $shortcode, $_POST['description']);
+
+ $xml_data_create['bug_file_loc'] = str_replace('{{{lc_locale}}}', strtolower($shortcode), $xml_data_create['bug_file_loc']);
+ $xml_data_create['summary'] = str_replace('{{{lc_locale}}}', strtolower($shortcode), $xml_data_create['summary']);
+ $xml_data_create['description'] = str_replace('{{{lc_locale}}}', strtolower($shortcode), $xml_data_create['description']);
+ $xml_data_create['cf_locale'] = $shortcode . ' / ' . $bugzilla_locales[$shortcode];
+
// Make the request to file a bug
$request = xmlrpc_encode_request("Bug.create", $xml_data_create); // create a request for filing bugs
curl_setopt($curl_start, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl_start, CURLOPT_COOKIEFILE, $cookie);
$buglist_array_item = xmlrpc_decode(curl_exec($curl_start)); // Get the ID of the filed bug
+/*
echo '<br><a href="'. $bugzilla_url . 'show_bug.cgi?id=' . $buglist_array_item['id'] . '">Bug ID=' . $buglist_array_item['id'] . '</a>';
+*/
+ if(isset($_POST['tag'])) {
+ $tag = strip_tags($_POST['tag']);
+ } else {
+ $tag = '';
+ }
+
+ echo dashboardItem($shortcode, $buglist_array_item['id'], strip_tags($xml_data_create['summary']), $tag);
}
+echo '</pre>';
+
curl_close($curl_start);
unlink($cookie);
$time_end = microtime(true);
-$time = $time_end - $time_start;
-echo '<div style="background: #000000; color: #FFFFFF; position: absolute; left: 50%; bottom: 0;"> Script execution time: '.$time.'</div>';
+$time = $time_end - $time_start;
+echo '<!-- Script execution time: '.$time.' -->';
+
+
View
6 controller.inc.php
@@ -5,13 +5,13 @@
// Without this one the script ain't going to work
// we fetch config.cgi based on this one
// also, we use it to create bugs on referring installation
-$bugzilla_url = 'https://landfill.bugzilla.org/bugzilla-3.6-branch/';
+//~ $bugzilla_url = 'https://landfill.bugzilla.org/bugzilla-3.6-branch/';
+//~ $bugzilla_url = 'https://landfill.bugzilla.org/bugzilla-4.0-branch/';
+$bugzilla_url = 'https://bugzilla.mozilla.org/';
// This function explodes a string for a given separator
// and removes whitespaces from created array elements
function clean_explode($input, $separator) {
$input = trim(preg_replace('|\\s*(?:' . preg_quote($separator) . ')\\s*|', $separator, $input));
return explode($separator, $input);
}
-
-?>
View
176 langconfig.php
@@ -1,82 +1,100 @@
<?php
+
$full_languages = array(
- 'af',
- 'ar',
- 'as',
- 'ast',
- 'be',
- 'bg',
- 'bn-IN',
- 'bn-BD',
- 'ca',
- 'cs',
- 'cy',
- 'da',
- 'de',
- 'el',
- 'en-GB',
- 'en-US',
- 'eo',
- 'es-AR',
- 'es-ES',
- 'es-CL',
- 'es-MX',
- 'et',
- 'eu',
- 'fa',
- 'fi',
- 'fr',
- 'fy-NL',
- 'ga-IE',
- 'gd',
- 'gl',
- 'gu-IN',
- 'he',
- 'hi-IN',
- 'hr',
- 'hu',
- 'hy',
- 'hy-AM',
- 'id',
- 'is',
- 'it',
- 'ja',
- 'ka',
- 'kk',
- 'kn',
- 'ko',
- 'ku',
- 'lt',
- 'lv',
- 'mk',
- 'ml',
- 'mr',
- 'nb-NO',
- 'nl',
- 'nn-NO',
- 'oc',
- 'or',
- 'pa-IN',
- 'pl',
- 'pt-BR',
- 'pt-PT',
- 'rm',
- 'ro',
- 'ru',
- 'si',
- 'sk',
- 'sl',
- 'sq',
- 'sr',
- 'sv-SE',
- 'ta',
- 'ta-LK',
- 'te',
- 'th',
- 'tr',
- 'uk',
- 'vi',
- 'zh-CN',
- 'zh-TW',
+'ach', 'af', 'ar', 'as', 'ast', 'be', 'bg', 'bn-IN', 'bn-BD', 'br', 'bs', 'ca', 'cs', 'csb', 'cy', 'da', 'de', 'el', 'eo', 'es-AR', 'es-ES', 'es-CL', 'es-MX', 'et', 'eu', 'fa', 'ff', 'fi', 'fr', 'fy-NL', 'ga-IE', 'gd', 'gl', 'gu-IN', 'he', 'hi-IN', 'hr', 'hu', 'hy-AM', 'id', 'is', 'it', 'ka', 'kk', 'kn', 'km', 'ko', 'ku', 'lij', 'lt', 'lv', 'mai', 'mk', 'ml', 'mn', 'my', 'mr', 'nb-NO', 'nl', 'or', 'pa-IN', 'pl', 'pt-BR', 'pt-PT', 'rm', 'ro', 'ru', 'si', 'sk', 'sl', 'sq', 'sr', 'sv-SE', 'ta', 'ta-LK', 'te', 'th', 'tr', 'uk', 'vi', 'wo', 'zh-CN', 'zh-TW'
+);
+
+$bugzilla_locales = array(
+ 'ach' => 'Acholi',
+ 'af' => 'Afrikaans',
+ 'ar' => 'Arabic',
+ 'as' => 'Assamese',
+ 'ast' => 'Asturian',
+ 'be' => 'Belarusian',
+ 'bg' => 'Bulgarian',
+ 'bn-BD' => 'Bengali (Bangladesh)',
+ 'bn-IN' => 'Bengali (India)',
+ 'br' => 'Breton',
+ 'bs' => 'Bosnian',
+ 'ca' => 'Catalan',
+ 'cs' => 'Czech',
+ 'csb' => 'Kashubian',
+ 'cy' => 'Welsh',
+ 'da' => 'Danish',
+ 'de' => 'German',
+ 'el' => 'Greek',
+ 'en-GB' => 'English (British)',
+ 'eo' => 'Esperanto',
+ 'es-AR' => 'Spanish (Argentina)',
+ 'es-CL' => 'Spanish (Chile)',
+ 'es-ES' => 'Spanish (Spain)',
+ 'es-MX' => 'Spanish (Mexico)',
+ 'et' => 'Estonian',
+ 'eu' => 'Basque',
+ 'fa' => 'Persian',
+ 'ff' => 'Fulah',
+ 'fi' => 'Finnish',
+ 'fr' => 'French',
+ 'fy-NL' => 'Frisian',
+ 'ga-IE' => 'Irish (Ireland)',
+ 'gd' => 'Gaelic (Scotland)',
+ 'gl' => 'Galician',
+ 'gu-IN' => 'Gujarati',
+ 'he' => 'Hebrew',
+ 'hi-IN' => 'Hindi (India)',
+ 'hr' => 'Croatian',
+ 'hu' => 'Hungarian',
+ 'hy-AM' => 'Armenian',
+ 'id' => 'Indonesian',
+ 'is' => 'Icelandic',
+ 'it' => 'Italian',
+ 'ja' => 'Japanese',
+ 'ka' => 'Georgian',
+ 'kk' => 'Kazakh',
+ 'km' => 'Khmer',
+ 'kn' => 'Kannada',
+ 'ko' => 'Korean',
+ 'ku' => 'Kurdish',
+ 'lg' => 'Luganda',
+ 'lij' => 'Ligurian',
+ 'lt' => 'Lithuanian',
+ 'lv' => 'Latvian',
+ 'mai' => 'Maithili',
+ 'mk' => 'Macedonian',
+ 'ml' => 'Malayalam',
+ 'mn' => 'Mongolian',
+ 'mr' => 'Marathi',
+ 'ms' => 'Malay',
+ 'my' => 'Burmese',
+ 'nb-NO' => 'Norwegian (Bokmål)',
+ 'nl' => 'Dutch',
+ 'nn-NO' => 'Norwegian (Nynorsk)',
+ 'nso' => 'Northern Sotho',
+ 'oc' => 'Occitan (Lengadocian)',
+ 'or' => 'Oriya',
+ 'pa-IN' => 'Punjabi',
+ 'pl' => 'Polish',
+ 'pt-BR' => 'Portuguese (Brazilian)',
+ 'pt-PT' => 'Portuguese (Portugal)',
+ 'rm' => 'Romansh',
+ 'ro' => 'Romanian',
+ 'ru' => 'Russian',
+ 'si' => 'Sinhala',
+ 'sk' => 'Slovak',
+ 'sl' => 'Slovenian',
+ 'sq' => 'Albanian',
+ 'sr' => 'Serbian',
+ 'sv-SE' => 'Swedish',
+ 'sw' => 'Swahili',
+ 'ta' => 'Tamil',
+ 'ta-LK' => 'Tamil (Sri Lanka)',
+ 'te' => 'Telugu',
+ 'th' => 'Thai',
+ 'tr' => 'Turkish',
+ 'uk' => 'Ukrainian',
+ 'vi' => 'Vietnamese',
+ 'wo' => 'Wolof',
+ 'zh-CN' => 'Chinese (Simplified)',
+ 'zh-TW' => 'Chinese (Traditional)',
+ 'zu' => 'Zulu',
);
-?>

0 comments on commit e5d2303

Please sign in to comment.