Add a configurable character limit on project title length, default is 100 characters

This commit is contained in:
james 2006-12-06 18:22:31 +00:00
parent 319c5d6720
commit 8fd2a44050
2 changed files with 15 additions and 2 deletions

View File

@ -1,3 +1,5 @@
INSERT INTO `config` (category,ord,var,val,description,year) VALUES ('Participant Registration','1050','participant_mentor','yes','Ask for mentorship information (yes/no)',-1);
ALTER TABLE `projectcategories` ADD `category_shortform` VARCHAR( 3 ) NOT NULL AFTER `category` ;
UPDATE `config` SET `description` = 'C=Category ID, c=Category Shortform, D=Division ID, d=Division Shortform, N=2 digit Number' WHERE `var` = 'project_num_format';
INSERT INTO `config` (category,ord,var,val,description,year) VALUES ('Participant Registration','1150','participant_project_title_charmax','100','The maximum number of characters acceptable in the project title (Max 255)',-1);

View File

@ -92,8 +92,16 @@ echo mysql_error();
else
$summarycountok=1;
if($config['participant_project_title_charmax'] && strlen(stripslashes($_POST['title']))>$config['participant_project_title_charmax']) //0 for no limit, eg 255 database field limit
{
$title=substr(stripslashes($_POST['title']),0,$config['participant_project_title_charmax']);
echo error(i18n("Project title truncated to %1 characters",array($config['participant_project_title_charmax'])));
}
else
$title=stripslashes($_POST['title']);
mysql_query("UPDATE projects SET ".
"title='".mysql_escape_string(stripslashes($_POST['title']))."', ".
"title='".mysql_escape_string($title)."', ".
"projectdivisions_id='".$_POST['projectdivisions_id']."', ".
"language='".mysql_escape_string(stripslashes($_POST['language']))."', ".
"req_table='".mysql_escape_string(stripslashes($_POST['req_table']))."', ".
@ -189,7 +197,10 @@ function countwords()
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"$projectinfo->id\">\n";
echo "<table>\n";
echo "<tr><td>".i18n("Project Title").": </td><td><input type=\"text\" name=\"title\" size=\"50\" value=\"$projectinfo->title\" />".REQUIREDFIELD."</td></tr>\n";
echo "<tr><td>".i18n("Project Title").": </td><td><input type=\"text\" name=\"title\" size=\"50\" value=\"$projectinfo->title\" />".REQUIREDFIELD;
if($config['participant_project_title_charmax'])
echo i18n("(Max %1 characters)",array($config['participant_project_title_charmax']));
echo "</td></tr>\n";
echo "<tr><td>".i18n("Age Category").": </td><td>";
echo i18n($agecategories[$projectcategories_id]['category']);
echo " (".i18n("Grades %1-%2",array($agecategories[$projectcategories_id]['mingrade'],$agecategories[$projectcategories_id]['maxgrade'])).")";