From 8fd2a44050d37c4960acbc0159f060e9d9baf5ee Mon Sep 17 00:00:00 2001 From: james Date: Wed, 6 Dec 2006 18:22:31 +0000 Subject: [PATCH] Add a configurable character limit on project title length, default is 100 characters --- db/db.update.32.sql | 2 ++ register_participants_project.php | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/db/db.update.32.sql b/db/db.update.32.sql index 35dd0cf..4e08082 100644 --- a/db/db.update.32.sql +++ b/db/db.update.32.sql @@ -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); + diff --git a/register_participants_project.php b/register_participants_project.php index a540518..4b9b95b 100644 --- a/register_participants_project.php +++ b/register_participants_project.php @@ -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 "\n"; echo "id\">\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "
".i18n("Project Title").": title\" />".REQUIREDFIELD."
".i18n("Project Title").": title\" />".REQUIREDFIELD; + if($config['participant_project_title_charmax']) + echo i18n("(Max %1 characters)",array($config['participant_project_title_charmax'])); + echo "
".i18n("Age Category").": "; echo i18n($agecategories[$projectcategories_id]['category']); echo " (".i18n("Grades %1-%2",array($agecategories[$projectcategories_id]['mingrade'],$agecategories[$projectcategories_id]['maxgrade'])).")";