r108416 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108415‎ | r108416 | r108417 >
Date:14:27, 9 January 2012
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
work on pagers - added active status to terms and courses, still need to put into place cpde to actually update the values
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.hooks.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCoursePager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrgPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPTermPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/sql/AddExtraFields.sql (modified) (history)
  • /trunk/extensions/EducationProgram/sql/AddStatusFields.sql (added) (history)
  • /trunk/extensions/EducationProgram/sql/EducationProgram.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/sql/AddExtraFields.sql
@@ -5,7 +5,7 @@
66
77 ALTER TABLE /*_*/ep_orgs ADD COLUMN org_courses SMALLINT unsigned NOT NULL;
88 ALTER TABLE /*_*/ep_orgs ADD COLUMN org_mentors SMALLINT unsigned NOT NULL;
9 -ALTER TABLE /*_*/ep_orgs ADD COLUMN org_terms SMALLINT unsigned NOT NULL;
 9+ALTER TABLE /*_*/ep_orgs ADD COLUMN org_terms SMALLIN1T unsigned NOT NULL;
1010 ALTER TABLE /*_*/ep_orgs ADD COLUMN org_students INT unsigned NOT NULL;
1111
1212 CREATE INDEX /*i*/ep_org_courses ON /*_*/ep_orgs (org_courses);
Index: trunk/extensions/EducationProgram/sql/AddStatusFields.sql
@@ -0,0 +1,12 @@
 2+-- SQL for the Education Program extension.
 3+-- Adds additional fields.
 4+-- Licence: GNU GPL v3+
 5+-- Author: Jeroen De Dauw < jeroendedauw@gmail.com >
 6+
 7+ALTER TABLE /*_*/ep_orgs ADD COLUMN org_active TINYINT unsigned NOT NULL default 1;
 8+
 9+CREATE INDEX /*i*/ep_org_active ON /*_*/ep_orgs (org_active);
 10+
 11+ALTER TABLE /*_*/ep_courses ADD COLUMN course_active TINYINT unsigned NOT NULL default 1;
 12+
 13+CREATE INDEX /*i*/ep_course_active ON /*_*/ep_courses (course_active);
\ No newline at end of file
Property changes on: trunk/extensions/EducationProgram/sql/AddStatusFields.sql
___________________________________________________________________
Added: svn:eol-style
114 + native
Index: trunk/extensions/EducationProgram/sql/EducationProgram.sql
@@ -10,6 +10,7 @@
1111 org_city VARCHAR(255) NOT NULL, -- Name of the city where the org is located
1212 org_country VARCHAR(255) NOT NULL, -- Name of the country where the org is located
1313
 14+ org_active TINYINT unsigned NOT NULL, -- If the org has any active terms
1415 org_courses SMALLINT unsigned NOT NULL, -- Amount of courses
1516 org_terms SMALLINT unsigned NOT NULL, -- Amount of terms
1617 org_mentors SMALLINT unsigned NOT NULL, -- Amount of mentors
@@ -21,6 +22,7 @@
2223 CREATE INDEX /*i*/ep_org_courses ON /*_*/ep_orgs (org_courses);
2324 CREATE INDEX /*i*/ep_org_mentors ON /*_*/ep_orgs (org_mentors);
2425 CREATE INDEX /*i*/ep_org_students ON /*_*/ep_orgs (org_students);
 26+CREATE INDEX /*i*/ep_org_active ON /*_*/ep_orgs (org_active);
2527
2628 -- Courses. These describe a specific course, time-independent.
2729 CREATE TABLE IF NOT EXISTS /*_*/ep_courses (
@@ -31,6 +33,7 @@
3234 course_description TEXT NOT NULL, -- Description of the course
3335 course_lang VARCHAR(10) NOT NULL, -- Language (code)
3436
 37+ course_active TINYINT unsigned NOT NULL, -- If the course has any active terms
3538 course_students SMALLINT unsigned NOT NULL -- Amount of students
3639 ) /*$wgDBTableOptions*/;
3740
@@ -38,6 +41,7 @@
3942 CREATE UNIQUE INDEX /*i*/ep_course_name ON /*_*/ep_courses (course_name);
4043 CREATE INDEX /*i*/ep_course_lang ON /*_*/ep_courses (course_lang);
4144 CREATE INDEX /*i*/ep_course_students ON /*_*/ep_courses (course_students);
 45+CREATE INDEX /*i*/ep_course_active ON /*_*/ep_courses (course_active);
4246
4347 -- Terms. These are "instances" of a course in a certain period.
4448 CREATE TABLE IF NOT EXISTS /*_*/ep_terms (
Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php
@@ -36,6 +36,7 @@
3737 'terms',
3838 'mentors',
3939 'students',
 40+ 'active',
4041 );
4142 }
4243
@@ -85,6 +86,9 @@
8687 }
8788
8889 break;
 90+ case 'active':
 91+ $value = wfMsgHtml( 'eporgpager-' . ( $value == '1' ? 'yes' : 'no' ) );
 92+ break;
8993 }
9094
9195 return $value;
@@ -103,7 +107,7 @@
104108 'mentors',
105109 'students',
106110 'terms',
107 - 'terms',
 111+ 'active',
108112 );
109113 }
110114
@@ -123,6 +127,15 @@
124128 'options' => efEpGetCountryOptions( $this->getLanguage()->getCode() ),
125129 'value' => ''
126130 ),
 131+ 'active' => array(
 132+ 'type' => 'select',
 133+ 'options' => array(
 134+ '' => '',
 135+ wfMsg( 'eporgpager-yes' ) => '1',
 136+ wfMsg( 'eporgpager-no' ) => '0',
 137+ ),
 138+ 'value' => '1',
 139+ ),
127140 );
128141 }
129142
Index: trunk/extensions/EducationProgram/includes/EPTermPager.php
@@ -160,7 +160,7 @@
161161 array( '' => '' ),
162162 EPTerm::getStatuses()
163163 ),
164 - 'value' => '',
 164+ 'value' => 'current',
165165 );
166166
167167 return $options;
Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -44,6 +44,7 @@
4545 'city' => 'str',
4646 'country' => 'str',
4747
 48+ 'active' => 'bool',
4849 'courses' => 'int',
4950 'terms' => 'int',
5051 'mentors' => 'int',
@@ -61,6 +62,7 @@
6263 'city' => '',
6364 'country' => '',
6465
 66+ 'active' => false,
6567 'courses' => 0,
6668 'terms' => 0,
6769 'mentors' => 0,
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php
@@ -32,6 +32,7 @@
3333 'name',
3434 'org_id',
3535 'students',
 36+ 'active',
3637 );
3738 }
3839
@@ -74,6 +75,9 @@
7576 case 'students':
7677 $value = htmlspecialchars( $this->getLanguage()->formatNum( $value ) );
7778 break;
 79+ case 'active':
 80+ $value = wfMsgHtml( 'epcoursepager-' . ( $value == '1' ? 'yes' : 'no' ) );
 81+ break;
7882 }
7983
8084 return $value;
@@ -92,6 +96,7 @@
9397 return array(
9498 'name',
9599 'students',
 100+ 'active',
96101 );
97102 }
98103
@@ -110,6 +115,15 @@
111116 'value' => '',
112117 'datatype' => 'int',
113118 ),
 119+ 'active' => array(
 120+ 'type' => 'select',
 121+ 'options' => array(
 122+ '' => '',
 123+ wfMsg( 'epcoursepager-yes' ) => '1',
 124+ wfMsg( 'epcoursepager-no' ) => '0',
 125+ ),
 126+ 'value' => '1',
 127+ ),
114128 );
115129 }
116130
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -38,6 +38,7 @@
3939 'description' => 'str',
4040 'lang' => 'str',
4141
 42+ 'active' => 'bool',
4243 'students' => 'int',
4344 );
4445 }
@@ -49,6 +50,9 @@
5051 public static function getDefaults() {
5152 return array(
5253 'description' => '',
 54+
 55+ 'active' => false,
 56+ 'students' => 0,
5357 );
5458 }
5559
@@ -168,7 +172,7 @@
169173 *
170174 * @since 0.1
171175 *
172 - * @param array $orgs
 176+ * @param array $courses
173177 *
174178 * @return array
175179 */
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -138,12 +138,20 @@
139139 'eporgpager-header-mentors' => 'Ambassadors',
140140 'eporgpager-header-students' => 'Students',
141141 'eporgpager-header-terms' => 'Terms',
 142+ 'eporgpager-header-active' => 'Active',
 143+ 'eporgpager-filter-active' => 'Active courses',
 144+ 'eporgpager-yes' => 'Yes',
 145+ 'eporgpager-no' => 'No',
142146
143147 // Course pager
144148 'epcoursepager-header-name' => 'Name',
145149 'epcoursepager-header-org-id' => 'Institution',
146150 'epcoursepager-filter-org-id' => 'Institution',
147151 'epcoursepager-header-students' => 'Students',
 152+ 'epcoursepager-header-active' => 'Active',
 153+ 'epcoursepager-filter-active' => 'Active terms',
 154+ 'epcoursepager-yes' => 'Yes',
 155+ 'epcoursepager-no' => 'No',
148156
149157 // Term pager
150158 'eptermpager-header-id' => 'Id',
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php
@@ -37,6 +37,14 @@
3838 true
3939 ) );
4040
 41+ $updater->addExtensionUpdate( array(
 42+ 'addField',
 43+ 'ep_orgs',
 44+ 'org_active',
 45+ dirname( __FILE__ ) . '/sql/AddStatusFields.sql',
 46+ true
 47+ ) );
 48+
4149 return true;
4250 }
4351

Status & tagging log