[thirdparty-commits] jpeeler: mantis/trunk r56 - in /mantis/trunk: ./ core/
SVN commits to the Digium third-party software repository
thirdparty-commits at lists.digium.com
Tue Jan 20 16:49:00 CST 2009
Author: jpeeler
Date: Tue Jan 20 16:49:00 2009
New Revision: 56
URL: http://svn.digium.com/svn-view/thirdparty?view=rev&rev=56
Log:
This adds the ability for those with licensing privileges to get a CSV dump of all the submitted contribution license data.
Closes SWDAT-17
Added:
mantis/trunk/license_csv.php (with props)
Modified:
mantis/trunk/core/license_api.php
mantis/trunk/license_pending.php
Modified: mantis/trunk/core/license_api.php
URL: http://svn.digium.com/svn-view/thirdparty/mantis/trunk/core/license_api.php?view=diff&rev=56&r1=55&r2=56
==============================================================================
--- mantis/trunk/core/license_api.php (original)
+++ mantis/trunk/core/license_api.php Tue Jan 20 16:49:00 2009
@@ -3,6 +3,7 @@
require_once( $t_core_dir . 'database_api.php' );
require_once( $t_core_dir . 'current_user_api.php' );
+ require_once( $t_core_dir . 'csv_api.php' );
define("LICENSE_NONE", 0);
define("LICENSE_PENDING", 1);
@@ -213,6 +214,51 @@
return $results;
}
+ function get_license_columns() {
+ # this has to be hard coded because db_fetch_array is returning both the associative and numeric array together
+ return array("id", "user_id", "name", "dob", "company", "job_title", "address_city", "address_country", "nationality_country", "email", "date_signed", "license_ver");
+ }
+
+ function get_all_licenses() {
+ $results = array();
+ $sql = "SELECT * from mantis_license_table";
+ $result = db_query($sql);
+
+ while($res = db_fetch_array($result))
+ $results[] = $res;
+
+ return $results;
+ }
+
+ function get_all_licenses_by_csv() {
+ $t_nl = csv_get_newline();
+ $t_sep = csv_get_separator();
+ $t_filename = csv_get_default_filename();
+
+ # Make sure that IE can download the attachments under https.
+ header( 'Pragma: public' );
+
+ header( 'Content-Type: text/plain; name=' . urlencode( $t_filename ) );
+ header( 'Content-Transfer-Encoding: BASE64;' );
+
+ # Added Quotes (") around file name.
+ header( 'Content-Disposition: attachment; filename="' . urlencode( $t_filename ) . '"' );
+
+ $t_all = get_all_licenses();
+ $t_loops = count( get_license_columns() ) - 1;
+
+ echo join($t_sep, get_license_columns() );
+ echo $t_nl;
+
+ foreach($t_all as $t_row) {
+ for($i = 0; $i < $t_loops; $i++) {
+ echo $t_row[$i] . $t_sep;
+ }
+ echo $t_row[$i++]; # last element without trailing comma
+ echo $t_nl;
+ }
+ }
+
function expire_license ( $p_id , $p_reason = '' ) {
$sql = sprintf("UPDATE mantis_license_table SET date_expired = NOW(), reject_reason = '%s' " .
"WHERE id = %s",
Added: mantis/trunk/license_csv.php
URL: http://svn.digium.com/svn-view/thirdparty/mantis/trunk/license_csv.php?view=auto&rev=56
==============================================================================
--- mantis/trunk/license_csv.php (added)
+++ mantis/trunk/license_csv.php Tue Jan 20 16:49:00 2009
@@ -1,0 +1,11 @@
+<?php
+ require_once( 'core.php' );
+
+ $t_core_path = config_get( 'core_path' );
+
+ require_once( $t_core_path . 'license_api.php' );
+ require_once( $t_core_path . 'current_user_api.php' );
+
+ access_ensure_global_level( config_get( 'manage_pending_threshold' ) );
+ get_all_licenses_by_csv();
+?>
Propchange: mantis/trunk/license_csv.php
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mantis/trunk/license_csv.php
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: mantis/trunk/license_csv.php
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: mantis/trunk/license_pending.php
URL: http://svn.digium.com/svn-view/thirdparty/mantis/trunk/license_pending.php?view=diff&rev=56&r1=55&r2=56
==============================================================================
--- mantis/trunk/license_pending.php (original)
+++ mantis/trunk/license_pending.php Tue Jan 20 16:49:00 2009
@@ -82,6 +82,10 @@
</script>
<?php
echo "<br />\n";
+ if ($t_manage) {
+ print_bracket_link( 'license_csv.php', 'CSV export of all license information' );
+ }
+ echo "<br /><br />\n";
echo "<table class=\"width100\" cellspacing=\"1\" cellpadding=\"1\">\n";
$c_query = db_query("SELECT * FROM mantis_license_table WHERE pending = TRUE AND date_expired IS NULL");
@@ -109,7 +113,7 @@
$c_result["user_id"] = user_get_name($c_result["user_id"]);
- foreach(array("id", "user_id", "name", "dob", "company", "job_title", "address_city", "address_country", "nationality_country", "email", "date_signed", "license_ver") as $k) {
+ foreach(get_license_columns() as $k) {
echo " <td>{$c_result[$k]}</td>\n";
}
More information about the thirdparty-commits
mailing list