From fab18eb0c79d1e5edbf0b3fe13bcc39bf7cab428 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 29 Nov 2007 18:38:06 +0000 Subject: [PATCH] Add enabled and website (for help) to external sources Update source editor Make downloader only check enabled source Make downloader check for username/password before attempting Add extra instructions --- admin/award_download.php | 9 +++++++-- config/award_sources.php | 17 +++++++++++++++-- db/db.code.version.txt | 2 +- db/db.update.71.sql | 4 ++++ 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 db/db.update.71.sql diff --git a/admin/award_download.php b/admin/award_download.php index afbd66ca..a7095202 100644 --- a/admin/award_download.php +++ b/admin/award_download.php @@ -42,8 +42,13 @@ require_once("xml.inc.php"); foreach($_GET['check'] AS $checksource) { $checksource=intval($checksource); - $q=mysql_query("SELECT * FROM award_sources WHERE id='$checksource'"); + $q=mysql_query("SELECT * FROM award_sources WHERE id='$checksource' AND enabled='yes'"); $r=mysql_fetch_object($q); + if(!($r->username && $r->password)) { + echo error(i18n("Username and Password are not set for source '%1'. Please set them in the SFIAB Configuration/External Award Sources editor first",array($r->name))); + continue; + + } echo i18n("Checking %1 for awards...",array($r->name)); echo "
"; @@ -313,7 +318,7 @@ echo mysql_error(); else $links=true; - $q=mysql_query("SELECT * FROM award_sources ORDER BY name"); + $q=mysql_query("SELECT * FROM award_sources WHERE enabled='yes' ORDER BY name"); echo ""; echo ""; echo ""; diff --git a/config/award_sources.php b/config/award_sources.php index 2fc98e43..c7602db7 100644 --- a/config/award_sources.php +++ b/config/award_sources.php @@ -32,8 +32,18 @@ $editor=new TableEditor("award_sources", - array("name"=>"Name", - "url"=>"URL", + array( + "enabled"=>"Enabled?", + "name"=>"Name", + "website"=>"Help URL", + "username"=>"Username", + ) + , + array( + "enabled"=>"Enabled?", + "name"=>"Name", + "url"=>"Source URL", + "website"=>"Help URL", "username"=>"Username", "password"=>"Password" ) @@ -44,5 +54,8 @@ $editor->setRecordType("Award Source"); $editor->execute(); + echo "
"; + echo i18n("Open the 'Help URL' in your browser to see if the award source applies to your fair and to obtain the username/password for the source if it does."); + send_footer(); ?> diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 2bbd69c2..39f5b693 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -70 +71 diff --git a/db/db.update.71.sql b/db/db.update.71.sql new file mode 100644 index 00000000..2db55973 --- /dev/null +++ b/db/db.update.71.sql @@ -0,0 +1,4 @@ +ALTER TABLE `award_sources` ADD `enabled` ENUM( 'no', 'yes' ) DEFAULT 'no' NOT NULL ; +ALTER TABLE `award_sources` ADD `website` VARCHAR( 255 ) NOT NULL AFTER `url` ; +INSERT INTO `award_sources` VALUES ('', 'Sci-Tech Ontario', 'http://www.scitechontario.org/awarddownloader/index.php', 'http://www.scitechontario.org/awarddownloader/help.php', '', '', 'no'); +INSERT INTO `award_sources` VALUES ('', 'Youth Science Foundation', 'https://secure.ysf-fsj.ca/awarddownloader/index.php', 'http://apps.ysf-fsj.ca/awarddownloader/help.php', '', '', 'no');
".i18n("Source Name")."".i18n("Source Location URL")."