[thirdparty-commits] jpeeler: mantis/trunk r45 - in /mantis/trunk: ./ core/
SVN commits to the Digium third-party software repository
thirdparty-commits at lists.digium.com
Wed Jan 7 21:59:24 CST 2009
Author: jpeeler
Date: Wed Jan 7 21:59:23 2009
New Revision: 45
URL: http://svn.digium.com/view/thirdparty?view=rev&rev=45
Log:
Adds functionality to maintain multiple versions of the contributor license including signing, viewing, and approving.
Modified:
mantis/trunk/config_license.php
mantis/trunk/core/file_api.php
mantis/trunk/core/license_api.php
mantis/trunk/license_agreement.php
mantis/trunk/license_pending.php
mantis/trunk/view_license_agreement.php
Modified: mantis/trunk/config_license.php
URL: http://svn.digium.com/view/thirdparty/mantis/trunk/config_license.php?view=diff&rev=45&r1=44&r2=45
==============================================================================
--- mantis/trunk/config_license.php (original)
+++ mantis/trunk/config_license.php Wed Jan 7 21:59:23 2009
@@ -27,12 +27,10 @@
"Thanks,\r\n\r\n" .
"Digium, Inc.";
-
+$g_license_title = "Digium Open Source Software Project Submission Agreement";
$g_license = array(
- "version" => "3.0",
- "title" => "Digium Open Source Software Project Submission Agreement",
- "text" => "<p>*****************************************************************************************************************************</p>
+ "3.0" => "<p>*****************************************************************************************************************************</p>
IMPORTANT - PLEASE READ CAREFULLY: <br />
<p style=\"text-index: 25px;\">This document (\"Agreement\") constitutes a legal agreement. By signing this Agreement below, You, either an individual or the
organization indicated below (\"You\"), agree to be legally bound. You may want to consult an attorney before signing. You
@@ -71,7 +69,6 @@
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF MERCHANTABILITY, or FITNESS
FOR A PARTICULAR PURPOSE. You acknowledge that the decision to include the Submission in any code base is entirely the
decision of Digium, and this Agreement does not guarantee that the Submissions will be included in any code base. The parties
-agree that any facsimile copy of this Agreement will be binding upon the parties to the same effect as originals.</p>",
- "formatted" => true
+agree that any facsimile copy of this Agreement will be binding upon the parties to the same effect as originals.</p>"
);
?>
Modified: mantis/trunk/core/file_api.php
URL: http://svn.digium.com/view/thirdparty/mantis/trunk/core/file_api.php?view=diff&rev=45&r1=44&r2=45
==============================================================================
--- mantis/trunk/core/file_api.php (original)
+++ mantis/trunk/core/file_api.php Wed Jan 7 21:59:23 2009
@@ -165,7 +165,8 @@
$row = $t_attachment_rows[$i];
extract( $row, EXTR_PREFIX_ALL, 'v' );
- $t_license_status = license_on_file_for_upload( $v_id );
+ $t_license = license_on_file_for_upload( $v_id, true );
+ $t_license_status = license_status( $t_license );
$c_sql = sprintf("SELECT user_id FROM mantis_bug_history_table WHERE " .
"bug_id = %d AND old_value = '%s' AND type = 9",
@@ -238,18 +239,19 @@
}
if($t_license_status !== false) {
+ $license_ver = $t_license["license_ver"];
switch($t_license_status) {
case LICENSE_NONE:
- PRINT " [<div style='display: inline; background: #d8d8d8;'><font color=\"yellow\">License NONE</font></div>]";
+ echo " [<div style='display: inline; background: #d8d8d8;'><font color=\"yellow\">License NONE (v$license_ver)</font></div>]";
break;
case LICENSE_ACCEPTED:
- PRINT " [<font color=\"green\">License OK</font>]";
+ echo " [<font color=\"green\">License OK (v$license_ver)</font>]";
break;
case LICENSE_PENDING:
- PRINT " [<font color=\"orange\">License PENDING</font>]";
+ echo " [<font color=\"orange\">License PENDING (v$license_ver)</font>]";
break;
case LICENSE_REJECTED:
- PRINT " [<font color=\"red\">License REJECTED</font>]";
+ echo " [<font color=\"red\">License REJECTED (v$license_ver)</font>]";
break;
default: break;
}
Modified: mantis/trunk/core/license_api.php
URL: http://svn.digium.com/view/thirdparty/mantis/trunk/core/license_api.php?view=diff&rev=45&r1=44&r2=45
==============================================================================
--- mantis/trunk/core/license_api.php (original)
+++ mantis/trunk/core/license_api.php Wed Jan 7 21:59:23 2009
@@ -9,8 +9,8 @@
define("LICENSE_ACCEPTED", 2);
define("LICENSE_REJECTED", 3);
- function license_on_file ( $p_id ) {
- $t_license = config_get( "license" );
+ function license_on_file ( $p_id, $p_license_ver = NULL ) {
+ $t_license = get_license( $p_license_ver );
$sql = sprintf("SELECT * FROM mantis_license_table WHERE user_id = %s AND license_ver = '%s' AND date_expired IS NULL",
db_prepare_int( $p_id ),
@@ -24,19 +24,39 @@
return db_fetch_array($result);
}
- function license_on_file_for_time( $p_timestamp , $p_user_id) {
- $sql = sprintf("SELECT * FROM mantis_license_table WHERE date_signed < '%s'" .
- "AND (date_expired IS NULL OR date_expired > '%s') AND user_id = '%d' LIMIT 1",
+ function license_on_file_for_time( $p_timestamp , $p_user_id, $p_license_ver) {
+ $sql = sprintf("SELECT * FROM mantis_license_table WHERE (date_expired IS NULL OR date_expired > '%s') " .
+ "AND user_id = '%d' AND license_ver = '%s' AND pending=0",
db_prepare_string($p_timestamp),
+ $p_user_id, $p_license_ver);
+
+ $result = db_query($sql);
+
+ if (!db_num_rows($result)) {
+ // This is not ideal. Nevertheless, check since just because there
+ // are no approved licenses doesn't mean there are no signed ones.
+ $sql = sprintf("SELECT * FROM mantis_license_table WHERE (date_expired IS NULL OR date_expired > '%s') " .
+ "AND user_id = '%d' AND license_ver = '%s' AND pending=1",
db_prepare_string($p_timestamp),
- $p_user_id);
-
- $result = db_query($sql);
-
- if (!db_num_rows($result))
- return false;
+ $p_user_id, $p_license_ver);
+ $result = db_query($sql);
+
+ if (!db_num_rows($result)) {
+ return false;
+ }
+ }
return db_fetch_array($result);
+ }
+
+ function license_status( $p_result ) {
+ if (!$p_result)
+ return LICENSE_NONE;
+
+ if ($p_result["pending"] && !is_null($p_result["date_expired"]))
+ return LICENSE_REJECTED;
+
+ return $p_result["pending"] ? LICENSE_PENDING : LICENSE_ACCEPTED;
}
function license_on_file_for_upload ( $p_upload_id , $return_license=false ) {
@@ -50,6 +70,7 @@
$result = db_fetch_array($result);
$c_user_id = $result["user_id"];
+ $c_license_ver = $result["license_ver"];
$sql = sprintf("SELECT * FROM mantis_bug_file_table WHERE id = %s",
db_prepare_int( $p_upload_id ));
@@ -61,27 +82,21 @@
$result = db_fetch_array($result);
- $result = license_on_file_for_time($result["date_added"], $c_user_id);
+ $result = license_on_file_for_time($result["date_added"], $c_user_id, $c_license_ver);
if ($result && $return_license)
return $result;
- if (!$result)
- return LICENSE_NONE;
-
- if ($result["pending"] && !is_null($result["date_expired"]))
- return LICENSE_REJECTED;
-
- return $result["pending"] ? LICENSE_PENDING : LICENSE_ACCEPTED;
- }
-
- function submit_license ( $post ) {
+ return license_status( $result );
+ }
+
+ function submit_license ( $post, $p_license_ver ) {
extract($post, EXTR_PREFIX_ALL, "p");
- if ( license_on_file( $p_id ) )
- return false;
-
- $t_license = config_get( "license" );
+ if ( license_on_file( $p_id, $p_license_ver ) )
+ return false;
+
+ $t_license = get_license( $p_license_ver );
// format date for database (YYYY-MM-DD)
$fulldob = "$p_dob_year-$p_dob_month-$p_dob_day";
@@ -118,10 +133,7 @@
}
function accept_license ( $p_id ) {
- $t_license = config_get("license");
-
- $sql = sprintf("UPDATE mantis_license_table SET pending = FALSE " .
- "WHERE id = %d", $p_id );
+ $sql = sprintf("UPDATE mantis_license_table SET pending = FALSE WHERE id = %d", $p_id );
$result = db_query($sql);
@@ -139,7 +151,7 @@
function submit_upload_info ( $p_id, $p_upload_id ) {
$license = license_on_file( $p_id );
- $t_license = config_get("license");
+ $t_license = get_license();
$sql = sprintf("INSERT INTO mantis_license_uploads_table VALUES" .
"('', %s, %s, %s, '%s', NOW())",
@@ -219,4 +231,25 @@
return 0;
}
+
+ function get_license( $p_version = NULL ) {
+ $t_license = config_get("license");
+ $t_title = config_get("license_title");
+
+ if ($p_version && !array_key_exists($p_version, $t_license)) {
+ return false;
+ }
+
+ if (!$p_version) {
+ $p_version = max(array_keys($t_license));
+ }
+
+ $tmp = array(
+ "version" => $p_version,
+ "title" => $t_title,
+ "text" => $t_license[$p_version],
+ "formatted" => "true"
+ );
+ return $tmp;
+ }
?>
Modified: mantis/trunk/license_agreement.php
URL: http://svn.digium.com/view/thirdparty/mantis/trunk/license_agreement.php?view=diff&rev=45&r1=44&r2=45
==============================================================================
--- mantis/trunk/license_agreement.php (original)
+++ mantis/trunk/license_agreement.php Wed Jan 7 21:59:23 2009
@@ -32,7 +32,8 @@
require_once($t_core_path . "current_user_api.php");
require_once($t_core_path . "license_api.php");
- $t_license = config_get( "license" );
+ $ver_request = $_GET["version"];
+ $t_license = get_license($ver_request);
auth_ensure_user_authenticated();
@@ -41,7 +42,7 @@
if($t_user_id == user_get_id_by_name("Anonymous"))
goback("You must create your own account to sign a license");
- if (license_on_file($t_user_id))
+ if (license_on_file($t_user_id, $ver_request))
goback("You already have a license on file, no need to sign another one!");
session_start();
@@ -51,7 +52,7 @@
if (count($_POST) > 0 && isset($_SESSION["public_key"])) {
foreach(array("name", "address_street", "address_city", "address_country", "nationality_country", "telephone", "dob_month", "dob_day", "dob_year") as $f)
if (!isset($_POST[$f]) || !strlen(trim($_POST[$f]))) {
- //echo "DEBUG: setting error on $f<br>";
+ echo "DEBUG: setting error on $f<br>";
$input_errors[$f] = true;
}
@@ -60,7 +61,7 @@
if(!count($input_errors)) {
$_POST["id"] = $t_user_id;
- if(!submit_license($_POST))
+ if(!submit_license($_POST, $ver_request))
$str = "There was an error in your license submittion, please try again later...";
else
$str = "Congrats " . user_get_name($t_user_id) . ", your contributors license has been submitted!<br />\n" .
Modified: mantis/trunk/license_pending.php
URL: http://svn.digium.com/view/thirdparty/mantis/trunk/license_pending.php?view=diff&rev=45&r1=44&r2=45
==============================================================================
--- mantis/trunk/license_pending.php (original)
+++ mantis/trunk/license_pending.php Wed Jan 7 21:59:23 2009
@@ -88,7 +88,7 @@
if (db_num_rows($c_query)) {
$columns = array("ID", "Username", "Real name", "Company", "Job title",
- "City", "Country", "E-mail", "Date signed");
+ "City", "Country", "E-mail", "Date signed", "Version");
if ($t_manage)
$columns = array_merge($columns, array("Accept", "Reject"));
@@ -109,7 +109,7 @@
$c_result["user_id"] = user_get_name($c_result["user_id"]);
- foreach(array("id", "user_id", "name", "company", "job_title", "address_city", "address_country", "email", "date_signed") as $k) {
+ foreach(array("id", "user_id", "name", "company", "job_title", "address_city", "address_country", "email", "date_signed", "license_ver") as $k) {
echo " <td>{$c_result[$k]}</td>\n";
}
Modified: mantis/trunk/view_license_agreement.php
URL: http://svn.digium.com/view/thirdparty/mantis/trunk/view_license_agreement.php?view=diff&rev=45&r1=44&r2=45
==============================================================================
--- mantis/trunk/view_license_agreement.php (original)
+++ mantis/trunk/view_license_agreement.php Wed Jan 7 21:59:23 2009
@@ -2,11 +2,17 @@
require_once("core.php");
- $t_license = config_get( "license" );
+ $ver_request = $_GET["version"];
+ $t_license = get_license( $ver_request );
html_page_top1();
html_page_top2();
+ if (!$t_license) {
+ echo "Error: Version $ver_request is invalid.";
+ html_page_bottom1( __FILE__ );
+ exit;
+ }
?>
<br />
<table class="width100" cellspacing="1">
More information about the thirdparty-commits
mailing list