Index: trunk/extensions/EducationProgram/sql/AddExtraFields.sql |
— | — | @@ -0,0 +1,32 @@ |
| 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_courses ADD COLUMN course_name VARCHAR(255) NOT NULL; |
| 8 | +CREATE INDEX /*i*/ep_course_name ON /*_*/ep_courses (course_name); |
| 9 | + |
| 10 | +ALTER TABLE /*_*/ep_courses ADD COLUMN course_timeline TEXT NOT NULL; |
| 11 | +ALTER TABLE /*_*/ep_mcs ADD COLUMN mc_timeline TEXT NOT NULL; |
| 12 | + |
| 13 | +-- Articles students are working on. |
| 14 | +CREATE TABLE IF NOT EXISTS /*_*/ep_articles ( |
| 15 | + article_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
| 16 | + |
| 17 | + article_user_id INT unsigned NOT NULL, -- Foreign key on user.user_id |
| 18 | + article_course_id INT unsigned NOT NULL, -- Foreign key on ep_courses.course_id |
| 19 | + article_page_id INT unsigned NOT NULL, -- Foreign key on page.page_id |
| 20 | + |
| 21 | + article_reviewers BLOB NOT NULL -- List of reviewers for this article (linking user.user_id) |
| 22 | +) /*$wgDBTableOptions*/; |
| 23 | + |
| 24 | +CREATE INDEX /*i*/ep_articles_user_id ON /*_*/ep_articles (article_user_id); |
| 25 | +CREATE INDEX /*i*/ep_articles_course_id ON /*_*/ep_articles (article_course_id); |
| 26 | +CREATE INDEX /*i*/ep_articles_page_id ON /*_*/ep_articles (article_page_id); |
| 27 | +CREATE UNIQUE INDEX /*i*/ep_articles_course_page ON /*_*/ep_articles (article_course_id, article_page_id); |
| 28 | + |
| 29 | +ALTER TABLE /*_*/ep_cas ADD COLUMN ca_bio TEXT NOT NULL; |
| 30 | +ALTER TABLE /*_*/ep_cas ADD COLUMN ca_photo VARCHAR(255) NOT NULL; |
| 31 | + |
| 32 | +ALTER TABLE /*_*/ep_oas ADD COLUMN oa_bio TEXT NOT NULL; |
| 33 | +ALTER TABLE /*_*/ep_oas ADD COLUMN oa_photo VARCHAR(255) NOT NULL; |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/sql/EducationProgram.sql |
— | — | @@ -29,8 +29,9 @@ |
30 | 30 | mc_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
31 | 31 | |
32 | 32 | mc_org_id INT unsigned NOT NULL, -- Foreign key on ep_orgs.org_id |
33 | | - mc_name VARCHAR(255) NOT NULL, -- Name of the course |
34 | | - mc_description TEXT NOT NULL, -- Description of the course |
| 33 | + mc_name VARCHAR(255) NOT NULL, -- Name of the master course |
| 34 | + mc_description TEXT NOT NULL, -- Description of the master course |
| 35 | + mc_timeline TEXT NOT NULL, -- Timeline for the master course |
35 | 36 | mc_lang VARCHAR(10) NOT NULL, -- Language (code) |
36 | 37 | mc_instructors BLOB NOT NULL, -- List of associated instructors |
37 | 38 | |
— | — | @@ -57,21 +58,39 @@ |
58 | 59 | course_start varbinary(14) NOT NULL, -- Start time of the course |
59 | 60 | course_end varbinary(14) NOT NULL, -- End time of the course |
60 | 61 | course_description TEXT NOT NULL, -- Description of the course |
61 | | - course_online_ambs BLOB NOT NULL, -- List of associated online ambassadors |
62 | | - course_campus_ambs BLOB NOT NULL, -- List of associated campus ambassadors |
| 62 | + course_timeline TEXT NOT NULL, -- Timeline for the course |
| 63 | + course_online_ambs BLOB NOT NULL, -- List of associated online ambassadors (linking ep_oas.oa_id) |
| 64 | + course_campus_ambs BLOB NOT NULL, -- List of associated campus ambassadors (linking ep_cas.ca_id) |
63 | 65 | course_token VARCHAR(255) NOT NULL, -- Token needed to enroll |
64 | 66 | |
65 | 67 | course_students SMALLINT unsigned NOT NULL -- Amount of students |
66 | 68 | ) /*$wgDBTableOptions*/; |
67 | 69 | |
| 70 | +CREATE INDEX /*i*/ep_course_name ON /*_*/ep_courses (course_name); |
68 | 71 | CREATE INDEX /*i*/ep_course_year ON /*_*/ep_courses (course_year); |
69 | 72 | CREATE INDEX /*i*/ep_course_start ON /*_*/ep_courses (course_start); |
70 | 73 | CREATE INDEX /*i*/ep_course_end ON /*_*/ep_courses (course_end); |
71 | | -CREATE INDEX /*i*/ep_trem_period ON /*_*/ep_courses (course_org_id, course_start, course_end); |
| 74 | +CREATE INDEX /*i*/ep_course_period ON /*_*/ep_courses (course_org_id, course_start, course_end); |
72 | 75 | CREATE INDEX /*i*/ep_course_students ON /*_*/ep_courses (course_students); |
73 | 76 | |
74 | 77 | |
75 | 78 | |
| 79 | +-- Articles students are working on. |
| 80 | +CREATE TABLE IF NOT EXISTS /*_*/ep_articles ( |
| 81 | + article_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
| 82 | + |
| 83 | + article_user_id INT unsigned NOT NULL, -- Foreign key on user.user_id |
| 84 | + article_course_id INT unsigned NOT NULL, -- Foreign key on ep_courses.course_id |
| 85 | + article_page_id INT unsigned NOT NULL, -- Foreign key on page.page_id |
| 86 | + |
| 87 | + article_reviewers BLOB NOT NULL -- List of reviewers for this article (linking user.user_id) |
| 88 | +) /*$wgDBTableOptions*/; |
| 89 | + |
| 90 | +CREATE INDEX /*i*/ep_articles_user_id ON /*_*/ep_articles (article_user_id); |
| 91 | +CREATE INDEX /*i*/ep_articles_course_id ON /*_*/ep_articles (article_course_id); |
| 92 | +CREATE INDEX /*i*/ep_articles_page_id ON /*_*/ep_articles (article_page_id); |
| 93 | +CREATE UNIQUE INDEX /*i*/ep_articles_course_page ON /*_*/ep_articles (article_course_id, article_page_id); |
| 94 | + |
76 | 95 | -- Students. In essence this is an extension to the user table. |
77 | 96 | CREATE TABLE IF NOT EXISTS /*_*/ep_students ( |
78 | 97 | student_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
— | — | @@ -111,7 +130,10 @@ |
112 | 131 | -- Campus ambassadors. In essence this is an extension to the user table. |
113 | 132 | CREATE TABLE IF NOT EXISTS /*_*/ep_cas ( |
114 | 133 | ca_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
115 | | - ca_user_id INT unsigned NOT NULL -- Foreign key on user.user_id |
| 134 | + ca_user_id INT unsigned NOT NULL, -- Foreign key on user.user_id |
| 135 | + |
| 136 | + ca_bio TEXT NOT NULL, -- Bio of the ambassador |
| 137 | + ca_photo VARCHAR(255) NOT NULL -- Name of a photo of the ambassador on commons |
116 | 138 | ) /*$wgDBTableOptions*/; |
117 | 139 | |
118 | 140 | CREATE UNIQUE INDEX /*i*/ep_cas_user_id ON /*_*/ep_cas (ca_user_id); |
— | — | @@ -130,6 +152,9 @@ |
131 | 153 | CREATE TABLE IF NOT EXISTS /*_*/ep_oas ( |
132 | 154 | oa_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
133 | 155 | oa_user_id INT unsigned NOT NULL -- Foreign key on user.user_id |
| 156 | + |
| 157 | + oa_bio TEXT NOT NULL, -- Bio of the ambassador |
| 158 | + oa_photo VARCHAR(255) NOT NULL -- Name of a photo of the ambassador on commons |
134 | 159 | ) /*$wgDBTableOptions*/; |
135 | 160 | |
136 | 161 | CREATE UNIQUE INDEX /*i*/ep_oas_user_id ON /*_*/ep_oas (oa_user_id); |
Index: trunk/extensions/EducationProgram/includes/EPMC.php |
— | — | @@ -44,6 +44,7 @@ |
45 | 45 | |
46 | 46 | 'name' => 'str', |
47 | 47 | 'description' => 'str', |
| 48 | + 'timeline' => 'str', |
48 | 49 | 'lang' => 'str', |
49 | 50 | 'instructors' => 'array', |
50 | 51 | |
— | — | @@ -59,6 +60,7 @@ |
60 | 61 | public static function getDefaults() { |
61 | 62 | return array( |
62 | 63 | 'description' => '', |
| 64 | + 'timeline' => '', |
63 | 65 | |
64 | 66 | 'active' => false, |
65 | 67 | 'students' => 0, |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -85,10 +85,12 @@ |
86 | 86 | 'mc_id' => 'id', |
87 | 87 | 'org_id' => 'id', |
88 | 88 | |
| 89 | + 'name' => 'str', |
89 | 90 | 'year' => 'int', |
90 | 91 | 'start' => 'str', // TS_MW |
91 | 92 | 'end' => 'str', // TS_MW |
92 | 93 | 'description' => 'str', |
| 94 | + 'timeline' => 'str', |
93 | 95 | 'token' => 'str', |
94 | 96 | 'online_ambs' => 'array', |
95 | 97 | 'campus_ambs' => 'array', |
— | — | @@ -103,10 +105,12 @@ |
104 | 106 | */ |
105 | 107 | public static function getDefaults() { |
106 | 108 | return array( |
| 109 | + 'name' => '', |
107 | 110 | 'year' => substr( wfTimestamp( TS_MW ), 0, 4 ), |
108 | 111 | 'start' => wfTimestamp( TS_MW ), |
109 | 112 | 'end' => wfTimestamp( TS_MW ), |
110 | 113 | 'description' => '', |
| 114 | + 'timeline' => '', |
111 | 115 | 'token' => '', |
112 | 116 | 'online_ambs' => array(), |
113 | 117 | 'campus_ambs' => array(), |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -254,6 +254,12 @@ |
255 | 255 | 'epstudentpager-yes' => 'Yes', |
256 | 256 | 'epstudentpager-no' => 'No', |
257 | 257 | |
| 258 | + // Campus ambassador pager |
| 259 | + 'eppager-header-user-id' => 'User', |
| 260 | + |
| 261 | + // Online ambassador pager |
| 262 | + 'epstudentpager-header-user-id' => 'User', |
| 263 | + |
258 | 264 | // Special:EditInstitution |
259 | 265 | 'editinstitution-text' => 'Enter the institution details below and click submit to save your changes.', |
260 | 266 | 'educationprogram-org-edit-name' => 'Institution name', |
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -28,6 +28,15 @@ |
29 | 29 | 'ep_orgs', |
30 | 30 | dirname( __FILE__ ) . '/sql/EducationProgram.sql' |
31 | 31 | ); |
| 32 | + |
| 33 | + $updater->addExtensionUpdate( array( |
| 34 | + 'addField', |
| 35 | + 'ep_courses', |
| 36 | + 'course_name', |
| 37 | + dirname( __FILE__ ) . '/sql/AddExtraFields.sql', |
| 38 | + true |
| 39 | + ) ); |
| 40 | + |
32 | 41 | return true; |
33 | 42 | } |
34 | 43 | |
— | — | @@ -181,6 +190,12 @@ |
182 | 191 | 'EditCourse' => 'ep-course', |
183 | 192 | ); |
184 | 193 | |
| 194 | + $classes = array( |
| 195 | + 'Institution' => 'EPOrg', |
| 196 | + 'Course' => 'EPCourse', |
| 197 | + 'MasterCourse' => 'EPMC', |
| 198 | + ); |
| 199 | + |
185 | 200 | $specialSet = false; |
186 | 201 | $type = false; |
187 | 202 | |
— | — | @@ -201,39 +216,44 @@ |
202 | 217 | $special = SpecialPageFactory::getLocalNameFor( $special ); |
203 | 218 | } |
204 | 219 | |
| 220 | + $identifier = $canonicalSet['view'] === 'Course' ? 'id' : 'name'; |
| 221 | + $exists = $classes[$canonicalSet['view']]::has( array( $identifier => $textParts[1] ) ); |
| 222 | + |
205 | 223 | $viewLinks['view'] = array( |
206 | 224 | 'class' => $type === 'view' ? 'selected' : false, |
207 | 225 | 'text' => wfMsg( 'ep-tab-view' ), |
208 | 226 | 'href' => SpecialPage::getTitleFor( $specialSet['view'], $textParts[1] )->getLocalUrl() |
209 | 227 | ); |
210 | 228 | |
211 | | - if ( $sktemplate->getUser()->isAllowed( $editRights[$canonicalSet['edit']] ) ) { |
212 | | - $viewLinks['edit'] = array( |
213 | | - 'class' => $type === 'edit' ? 'selected' : false, |
214 | | - 'text' => wfMsg( 'ep-tab-edit' ), |
215 | | - 'href' => SpecialPage::getTitleFor( $specialSet['edit'], $textParts[1] )->getLocalUrl() |
| 229 | + if ( $exists ) { |
| 230 | + if ( $sktemplate->getUser()->isAllowed( $editRights[$canonicalSet['edit']] ) ) { |
| 231 | + $viewLinks['edit'] = array( |
| 232 | + 'class' => $type === 'edit' ? 'selected' : false, |
| 233 | + 'text' => wfMsg( 'ep-tab-edit' ), |
| 234 | + 'href' => SpecialPage::getTitleFor( $specialSet['edit'], $textParts[1] )->getLocalUrl() |
| 235 | + ); |
| 236 | + } |
| 237 | + |
| 238 | + $viewLinks['history'] = array( |
| 239 | + 'class' => $type === 'history' ? 'selected' : false, |
| 240 | + 'text' => wfMsg( 'ep-tab-history' ), |
| 241 | + 'href' => '' // TODO |
| 242 | + //SpecialPage::getTitleFor( $specialSet['history'], $textParts[1] )->getLocalUrl() |
216 | 243 | ); |
217 | | - } |
218 | 244 | |
219 | | - $viewLinks['history'] = array( |
220 | | - 'class' => $type === 'history' ? 'selected' : false, |
221 | | - 'text' => wfMsg( 'ep-tab-history' ), |
222 | | - 'href' => '' // TODO |
223 | | - //SpecialPage::getTitleFor( $specialSet['history'], $textParts[1] )->getLocalUrl() |
224 | | - ); |
| 245 | + if ( $canonicalSet['view'] === 'Course' ) { |
| 246 | + $user = $sktemplate->getUser(); |
225 | 247 | |
226 | | - if ( $canonicalSet['view'] === 'Course' ) { |
227 | | - $user = $sktemplate->getUser(); |
| 248 | + if ( $user->isAllowed( 'ep-enroll' ) ) { |
| 249 | + $student = EPStudent::newFromUser( $user ); |
228 | 250 | |
229 | | - if ( $user->isAllowed( 'ep-enroll' ) ) { |
230 | | - $student = EPStudent::newFromUser( $user ); |
231 | | - |
232 | | - if ( $student === false || !$student->hasCourse( array( 'id' => $textParts[1] ) ) ) { |
233 | | - $viewLinks['enroll'] = array( |
234 | | - 'class' => $type === 'enroll' ? 'selected' : false, |
235 | | - 'text' => wfMsg( 'ep-tab-enroll' ), |
236 | | - 'href' => SpecialPage::getTitleFor( 'Enroll', $textParts[1] )->getLocalUrl() |
237 | | - ); |
| 251 | + if ( $student === false || !$student->hasCourse( array( 'id' => $textParts[1] ) ) ) { |
| 252 | + $viewLinks['enroll'] = array( |
| 253 | + 'class' => $type === 'enroll' ? 'selected' : false, |
| 254 | + 'text' => wfMsg( 'ep-tab-enroll' ), |
| 255 | + 'href' => SpecialPage::getTitleFor( 'Enroll', $textParts[1] )->getLocalUrl() |
| 256 | + ); |
| 257 | + } |
238 | 258 | } |
239 | 259 | } |
240 | 260 | } |