Index: trunk/extensions/EducationProgram/EducationProgram.i18n.alias.php |
— | — | @@ -23,19 +23,15 @@ |
24 | 24 | 'Students' => array( 'Students' ), |
25 | 25 | 'Course' => array( 'Course' ), |
26 | 26 | 'Courses' => array( 'Courses' ), |
27 | | - 'MasterCourse' => array( 'MasterCourse' ), |
28 | | - 'MasterCourses' => array( 'MasterCourses' ), |
29 | 27 | 'EducationProgram' => array( 'EducationProgram' ), |
30 | 28 | 'EditCourse' => array( 'EditCourse' ), |
31 | 29 | 'EditInstitution' => array( 'EditInstitution' ), |
32 | | - 'EditMasterCourse' => array( 'EditMasterCourse' ), |
33 | 30 | 'Enroll' => array( 'Enroll' ), |
34 | 31 | 'CampusAmbassadors' => array( 'CampusAmbassadors' ), |
35 | 32 | 'OnlineAmbassadors' => array( 'OnlineAmbassadors' ), |
36 | 33 | 'CampusAmbassador' => array( 'CampusAmbassador' ), |
37 | 34 | 'OnlineAmbassador' => array( 'OnlineAmbassador' ), |
38 | 35 | 'CourseHistory' => array( 'CourseHistory' ), |
39 | | - 'MasterCourseHistory' => array( 'MasterCourseHistory' ), |
40 | 36 | 'InstitutionHistory' => array( 'InstitutionHistory' ), |
41 | 37 | ); |
42 | 38 | |
Index: trunk/extensions/EducationProgram/sql/AddExtraFields.sql |
— | — | @@ -1,32 +0,0 @@ |
2 | | - |
3 | | -ALTER TABLE /*_*/ep_courses ADD COLUMN course_name VARCHAR(255) NOT NULL; |
4 | | -CREATE INDEX /*i*/ep_course_name ON /*_*/ep_courses (course_name); |
5 | | - |
6 | | -ALTER TABLE /*_*/ep_courses ADD COLUMN course_timeline TEXT NOT NULL; |
7 | | -ALTER TABLE /*_*/ep_mcs ADD COLUMN mc_timeline TEXT NOT NULL; |
8 | | - |
9 | | -CREATE TABLE IF NOT EXISTS /*_*/ep_articles ( |
10 | | - article_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
11 | | - |
12 | | - article_user_id INT unsigned NOT NULL, -- Foreign key on user.user_id |
13 | | - article_course_id INT unsigned NOT NULL, -- Foreign key on ep_courses.course_id |
14 | | - article_page_id INT unsigned NOT NULL, -- Foreign key on page.page_id |
15 | | - |
16 | | - article_reviewers BLOB NOT NULL -- List of reviewers for this article (linking user.user_id) |
17 | | -) /*$wgDBTableOptions*/; |
18 | | - |
19 | | -CREATE INDEX /*i*/ep_articles_user_id ON /*_*/ep_articles (article_user_id); |
20 | | -CREATE INDEX /*i*/ep_articles_course_id ON /*_*/ep_articles (article_course_id); |
21 | | -CREATE INDEX /*i*/ep_articles_page_id ON /*_*/ep_articles (article_page_id); |
22 | | -CREATE UNIQUE INDEX /*i*/ep_articles_course_page ON /*_*/ep_articles (article_course_id, article_page_id); |
23 | | - |
24 | | -ALTER TABLE /*_*/ep_cas ADD COLUMN ca_bio TEXT NOT NULL; |
25 | | -ALTER TABLE /*_*/ep_cas ADD COLUMN ca_photo VARCHAR(255) NOT NULL; |
26 | | - |
27 | | -ALTER TABLE /*_*/ep_oas ADD COLUMN oa_bio TEXT NOT NULL; |
28 | | -ALTER TABLE /*_*/ep_oas ADD COLUMN oa_photo VARCHAR(255) NOT NULL; |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/sql/AddRevisionObjectId.sql |
— | — | @@ -1,7 +0,0 @@ |
2 | | - |
3 | | -ALTER TABLE /*_*/ep_revisions ADD COLUMN rev_object_id INT unsigned NOT NULL; |
4 | | -CREATE INDEX /*i*/ep_revisions_object_id ON /*_*/ep_revisions (rev_object_id); |
Index: trunk/extensions/EducationProgram/sql/EducationProgram.sql |
— | — | @@ -12,65 +12,55 @@ |
13 | 13 | |
14 | 14 | org_active TINYINT unsigned NOT NULL, -- If the org has any active courses |
15 | 15 | org_courses SMALLINT unsigned NOT NULL, -- Amount of courses |
16 | | - org_mcs SMALLINT unsigned NOT NULL, -- Amount of master courses |
| 16 | + org_instructors SMALLINT unsigned NOT NULL -- Amount of instructors |
| 17 | + org_online_ambs INT unsigned NOT NULL -- Amount of online ambassadors |
| 18 | + org_campus_ambs INT unsigned NOT NULL -- Amount of campus ambassadors |
17 | 19 | org_students INT unsigned NOT NULL -- Amount of students |
18 | 20 | ) /*$wgDBTableOptions*/; |
19 | 21 | |
20 | 22 | CREATE UNIQUE INDEX /*i*/ep_org_name ON /*_*/ep_orgs (org_name); |
21 | | -CREATE INDEX /*i*/ep_org_mcs ON /*_*/ep_orgs (org_mcs); |
| 23 | +CREATE INDEX /*i*/ep_org_city ON /*_*/ep_orgs (org_city); |
| 24 | +CREATE INDEX /*i*/ep_org_country ON /*_*/ep_orgs (org_country); |
| 25 | +CREATE INDEX /*i*/ep_org_active ON /*_*/ep_orgs (org_active); |
22 | 26 | CREATE INDEX /*i*/ep_org_courses ON /*_*/ep_orgs (org_courses); |
| 27 | +CREATE INDEX /*i*/ep_org_online_ambs ON /*_*/ep_orgs (org_online_ambs); |
| 28 | +CREATE INDEX /*i*/ep_org_campus_ambs ON /*_*/ep_orgs (org_campus_ambs); |
23 | 29 | CREATE INDEX /*i*/ep_org_students ON /*_*/ep_orgs (org_students); |
24 | | -CREATE INDEX /*i*/ep_org_active ON /*_*/ep_orgs (org_active); |
25 | 30 | |
26 | 31 | |
27 | 32 | |
28 | | -CREATE TABLE IF NOT EXISTS /*_*/ep_mcs ( |
29 | | - mc_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
30 | | - |
31 | | - mc_org_id INT unsigned NOT NULL, -- Foreign key on ep_orgs.org_id |
32 | | - mc_name VARCHAR(255) NOT NULL, -- Name of the master course |
33 | | - mc_description TEXT NOT NULL, -- Description of the master course |
34 | | - mc_timeline TEXT NOT NULL, -- Timeline for the master course |
35 | | - mc_lang VARCHAR(10) NOT NULL, -- Language (code) |
36 | | - mc_instructors BLOB NOT NULL, -- List of associated instructors |
37 | | - |
38 | | - mc_active TINYINT unsigned NOT NULL, -- If the master course has any active courses |
39 | | - mc_students SMALLINT unsigned NOT NULL -- Amount of students |
40 | | -) /*$wgDBTableOptions*/; |
41 | | - |
42 | | -CREATE INDEX /*i*/ep_mc_org_id ON /*_*/ep_mcs (mc_org_id); |
43 | | -CREATE UNIQUE INDEX /*i*/ep_mc_name ON /*_*/ep_mcs (mc_name); |
44 | | -CREATE INDEX /*i*/ep_mc_lang ON /*_*/ep_mcs (mc_lang); |
45 | | -CREATE INDEX /*i*/ep_mc_students ON /*_*/ep_mcs (mc_students); |
46 | | -CREATE INDEX /*i*/ep_mc_active ON /*_*/ep_mcs (mc_active); |
47 | | - |
48 | | - |
49 | | - |
50 | 33 | -- Courses. These are "instances" of a master course in a certain period. |
51 | 34 | CREATE TABLE IF NOT EXISTS /*_*/ep_courses ( |
52 | 35 | course_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
53 | 36 | |
54 | | - course_mc_id INT unsigned NOT NULL, -- Foreign key on ep_mcs.mc_id |
55 | 37 | course_org_id INT unsigned NOT NULL, -- Foreign key on ep_orgs.org_id. Helper field, not strictly needed. |
56 | 38 | course_name VARCHAR(255) NOT NULL, -- Name of the course |
57 | | - course_year SMALLINT unsigned NOT NULL, -- Year in which the course takes place |
| 39 | + course_mc VARCHAR(255) NOT NULL, -- Name of the master course |
58 | 40 | course_start varbinary(14) NOT NULL, -- Start time of the course |
59 | 41 | course_end varbinary(14) NOT NULL, -- End time of the course |
60 | 42 | course_description TEXT NOT NULL, -- Description of the course |
61 | | - course_timeline TEXT NOT NULL, -- Timeline for the course |
62 | 43 | course_online_ambs BLOB NOT NULL, -- List of associated online ambassadors (linking ep_oas.oa_id) |
63 | 44 | course_campus_ambs BLOB NOT NULL, -- List of associated campus ambassadors (linking ep_cas.ca_id) |
| 45 | + course_instructors BLOB NOT NULL, -- List of associated instructors (linking ep_instructors.instructor_id) |
64 | 46 | course_token VARCHAR(255) NOT NULL, -- Token needed to enroll |
65 | | - |
| 47 | + course_field VARCHAR(255) NOT NULL, -- Field of study |
| 48 | + course_level VARCHAR(255) NOT NULL, -- Study level |
| 49 | + course_term VARCHAR(255) NOT NULL, -- Academic term |
| 50 | + course_lang VARCHAR(10) NOT NULL, -- Language (code) |
| 51 | + |
66 | 52 | course_students SMALLINT unsigned NOT NULL -- Amount of students |
67 | 53 | ) /*$wgDBTableOptions*/; |
68 | 54 | |
| 55 | +CREATE INDEX /*i*/ep_course_org_id ON /*_*/ep_courses (course_org_id); |
69 | 56 | CREATE INDEX /*i*/ep_course_name ON /*_*/ep_courses (course_name); |
70 | | -CREATE INDEX /*i*/ep_course_year ON /*_*/ep_courses (course_year); |
| 57 | +CREATE INDEX /*i*/ep_course_mc ON /*_*/ep_courses (course_mc); |
71 | 58 | CREATE INDEX /*i*/ep_course_start ON /*_*/ep_courses (course_start); |
72 | 59 | CREATE INDEX /*i*/ep_course_end ON /*_*/ep_courses (course_end); |
73 | | -CREATE INDEX /*i*/ep_course_period ON /*_*/ep_courses (course_org_id, course_start, course_end); |
| 60 | +CREATE INDEX /*i*/ep_course_token ON /*_*/ep_courses (course_token); |
| 61 | +CREATE INDEX /*i*/ep_course_field ON /*_*/ep_courses (course_field); |
| 62 | +CREATE INDEX /*i*/ep_course_level ON /*_*/ep_courses (course_level); |
| 63 | +CREATE INDEX /*i*/ep_course_term ON /*_*/ep_courses (course_term); |
| 64 | +CREATE INDEX /*i*/ep_course_lang ON /*_*/ep_courses (course_lang); |
74 | 65 | CREATE INDEX /*i*/ep_course_students ON /*_*/ep_courses (course_students); |
75 | 66 | |
76 | 67 | |
— | — | @@ -91,6 +81,8 @@ |
92 | 82 | CREATE INDEX /*i*/ep_articles_page_id ON /*_*/ep_articles (article_page_id); |
93 | 83 | CREATE UNIQUE INDEX /*i*/ep_articles_course_page ON /*_*/ep_articles (article_course_id, article_page_id); |
94 | 84 | |
| 85 | + |
| 86 | + |
95 | 87 | -- Students. In essence this is an extension to the user table. |
96 | 88 | CREATE TABLE IF NOT EXISTS /*_*/ep_students ( |
97 | 89 | student_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
— | — | @@ -107,6 +99,8 @@ |
108 | 100 | CREATE INDEX /*i*/ep_students_last_active ON /*_*/ep_students (student_last_active); |
109 | 101 | CREATE INDEX /*i*/ep_students_active_enroll ON /*_*/ep_students (student_active_enroll); |
110 | 102 | |
| 103 | + |
| 104 | + |
111 | 105 | -- Links the students with their courses. |
112 | 106 | CREATE TABLE IF NOT EXISTS /*_*/ep_students_per_course ( |
113 | 107 | spc_student_id INT unsigned NOT NULL, -- Foreign key on ep_students.student_id |
— | — | @@ -138,6 +132,8 @@ |
139 | 133 | |
140 | 134 | CREATE UNIQUE INDEX /*i*/ep_cas_user_id ON /*_*/ep_cas (ca_user_id); |
141 | 135 | |
| 136 | + |
| 137 | + |
142 | 138 | -- Links the campus ambassadors with all their orgs. |
143 | 139 | CREATE TABLE IF NOT EXISTS /*_*/ep_cas_per_org ( |
144 | 140 | cpo_ca_id INT unsigned NOT NULL, -- Foreign key on ep_cas.ca_id |
Index: trunk/extensions/EducationProgram/specials/SpecialMasterCourseHistory.php |
— | — | @@ -1,25 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Special page for listing the history of a master course. |
6 | | - * |
7 | | - * @since 0.1 |
8 | | - * |
9 | | - * @file SpecialMasterCourseHistory.php |
10 | | - * @ingroup EducationProgram |
11 | | - * |
12 | | - * @licence GNU GPL v3 or later |
13 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
14 | | - */ |
15 | | -class SpecialMasterCourseHistory extends SpecialEPHistory { |
16 | | - |
17 | | - /** |
18 | | - * Constructor. |
19 | | - * |
20 | | - * @since 0.1 |
21 | | - */ |
22 | | - public function __construct() { |
23 | | - parent::__construct( 'MasterCourseHistory', 'EPMC', 'name', 'MasterCourse' ); |
24 | | - } |
25 | | - |
26 | | -} |
Index: trunk/extensions/EducationProgram/specials/SpecialMasterCourses.php |
— | — | @@ -1,46 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Page listing all master courses in a pager with filter control. |
6 | | - * Also has a form for adding new items for those with matching privileges. |
7 | | - * |
8 | | - * @since 0.1 |
9 | | - * |
10 | | - * @file SpecialMasterCourses.php |
11 | | - * @ingroup EducationProgram |
12 | | - * |
13 | | - * @licence GNU GPL v3 or later |
14 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | | - */ |
16 | | -class SpecialMasterCourses extends SpecialEPPage { |
17 | | - |
18 | | - /** |
19 | | - * Constructor. |
20 | | - * |
21 | | - * @since 0.1 |
22 | | - */ |
23 | | - public function __construct() { |
24 | | - parent::__construct( 'MasterCourses' ); |
25 | | - } |
26 | | - |
27 | | - /** |
28 | | - * Main method. |
29 | | - * |
30 | | - * @since 0.1 |
31 | | - * |
32 | | - * @param string|null $arg |
33 | | - */ |
34 | | - public function execute( $subPage ) { |
35 | | - parent::execute( $subPage ); |
36 | | - |
37 | | - if ( $this->subPage === '' ) { |
38 | | - $this->displayNavigation(); |
39 | | - EPMC::displayAddNewRegion( $this->getContext() ); |
40 | | - EPMC::displayPager( $this->getContext() ); |
41 | | - } |
42 | | - else { |
43 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'MasterCourse', $this->subPage )->getLocalURL() ); |
44 | | - } |
45 | | - } |
46 | | - |
47 | | -} |
Index: trunk/extensions/EducationProgram/specials/SpecialMasterCourse.php |
— | — | @@ -1,213 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Shows the info for a single master course, with management and |
6 | | - * enrollment controls depending on the user and his rights. |
7 | | - * |
8 | | - * @since 0.1 |
9 | | - * |
10 | | - * @file SpecialMasterCourse.php |
11 | | - * @ingroup EducationProgram |
12 | | - * |
13 | | - * @licence GNU GPL v3 or later |
14 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | | - */ |
16 | | -class SpecialMasterCourse extends SpecialEPPage { |
17 | | - |
18 | | - /** |
19 | | - * Constructor. |
20 | | - * |
21 | | - * @since 0.1 |
22 | | - */ |
23 | | - public function __construct() { |
24 | | - parent::__construct( 'MasterCourse', '', false ); |
25 | | - } |
26 | | - |
27 | | - /** |
28 | | - * Main method. |
29 | | - * |
30 | | - * @since 0.1 |
31 | | - * |
32 | | - * @param string $subPage |
33 | | - */ |
34 | | - public function execute( $subPage ) { |
35 | | - parent::execute( $subPage ); |
36 | | - |
37 | | - $out = $this->getOutput(); |
38 | | - |
39 | | - if ( trim( $subPage ) === '' ) { |
40 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'MasterCourses' )->getLocalURL() ); |
41 | | - } |
42 | | - else { |
43 | | - $out->setPageTitle( wfMsgExt( 'ep-mc-title', 'parsemag', $this->subPage ) ); |
44 | | - |
45 | | - $masterCourse = EPMC::selectRow( null, array( 'name' => $this->subPage ) ); |
46 | | - |
47 | | - if ( $masterCourse === false ) { |
48 | | - $this->displayNavigation(); |
49 | | - |
50 | | - if ( $this->getUser()->isAllowed( 'ep-mc' ) ) { |
51 | | - $out->addWikiMsg( 'ep-mc-create', $this->subPage ); |
52 | | - EPMC::displayAddNewRegion( $this->getContext(), array( 'name' => $this->subPage ) ); |
53 | | - } |
54 | | - else { |
55 | | - $out->addWikiMsg( 'ep-mc-none', $this->subPage ); |
56 | | - } |
57 | | - } |
58 | | - else { |
59 | | - $this->displayNavigation(); |
60 | | - |
61 | | - $this->displaySummary( $masterCourse ); |
62 | | - |
63 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-mc-description' ) ) ); |
64 | | - |
65 | | - $out->addHTML( $this->getOutput()->parse( $masterCourse->getField( 'description' ) ) ); |
66 | | - |
67 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-mc-courses' ) ) ); |
68 | | - |
69 | | - EPCourse::displayPager( $this->getContext(), array( 'mc_id' => $masterCourse->getId() ) ); |
70 | | - |
71 | | - if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
72 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-mc-add-course' ) ) ); |
73 | | - |
74 | | - EPCourse::displayAddNewControl( $this->getContext(), array( 'mc' => $masterCourse->getId() ) ); |
75 | | - } |
76 | | - } |
77 | | - } |
78 | | - } |
79 | | - |
80 | | - /** |
81 | | - * Gets the summary data. |
82 | | - * |
83 | | - * @since 0.1 |
84 | | - * |
85 | | - * @param EPMC $masterCourse |
86 | | - * |
87 | | - * @return array |
88 | | - */ |
89 | | - protected function getSummaryData( EPDBObject $masterCourse ) { |
90 | | - $stats = array(); |
91 | | - |
92 | | - $stats['name'] = htmlspecialchars( $masterCourse->getField( 'name' ) ); |
93 | | - |
94 | | - $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $masterCourse->getField( 'org_id' ) ) ); |
95 | | - |
96 | | - $stats['org'] = Linker::linkKnown( |
97 | | - SpecialPage::getTitleFor( 'Institution', $org ), |
98 | | - htmlspecialchars( $org ) |
99 | | - ); |
100 | | - |
101 | | - $stats['status'] = wfMsgHtml( $masterCourse->getField( 'active' ) ? 'ep-mc-active' : 'ep-mc-inactive' ); |
102 | | - |
103 | | - $lang = $this->getLanguage(); |
104 | | - |
105 | | - $stats['students'] = htmlspecialchars( $lang->formatNum( $masterCourse->getField( 'students' ) ) ); |
106 | | - |
107 | | - $courseCount = EPCourse::count( array( 'mc_id' => $masterCourse->getId() ) ); |
108 | | - $stats['courses'] = htmlspecialchars( $lang->formatNum( $courseCount ) ); |
109 | | - |
110 | | - if ( $courseCount > 0 ) { |
111 | | - $stats['courses'] = Linker::linkKnown( |
112 | | - SpecialPage::getTitleFor( 'Courses' ), |
113 | | - $stats['courses'], |
114 | | - array(), |
115 | | - array( 'mc_id' => $masterCourse->getId() ) |
116 | | - ); |
117 | | - } |
118 | | - |
119 | | - $stats['instructors'] = $this->getInstructorsList( $masterCourse ) . $this->getInstructorControls( $masterCourse ); |
120 | | - |
121 | | - return $stats; |
122 | | - } |
123 | | - |
124 | | - /** |
125 | | - * Returns a list with the instructors for the provided course |
126 | | - * or a message indicating there are none. |
127 | | - * |
128 | | - * @since 0.1 |
129 | | - * |
130 | | - * @param EPMC $masterCourse |
131 | | - * |
132 | | - * @return string |
133 | | - */ |
134 | | - protected function getInstructorsList( EPMC $masterCourse ) { |
135 | | - $instructors = $masterCourse->getInstructors(); |
136 | | - |
137 | | - if ( count( $instructors ) > 0 ) { |
138 | | - $instList = array(); |
139 | | - |
140 | | - foreach ( $instructors as /* EPInstructor */ $instructor ) { |
141 | | - $instList[] = $instructor->getUserLink() . $instructor->getToolLinks( $this->getContext(), $masterCourse ); |
142 | | - } |
143 | | - |
144 | | - if ( false ) { // count( $instructors ) == 1 |
145 | | - $html = $instList[0]; |
146 | | - } |
147 | | - else { |
148 | | - $html = '<ul><li>' . implode( '</li><li>', $instList ) . '</li></ul>'; |
149 | | - } |
150 | | - } |
151 | | - else { |
152 | | - $html = wfMsgHtml( 'ep-mc-no-instructors' ); |
153 | | - } |
154 | | - |
155 | | - return Html::rawElement( |
156 | | - 'div', |
157 | | - array( 'id' => 'ep-mc-instructors' ), |
158 | | - $html |
159 | | - ); |
160 | | - } |
161 | | - |
162 | | - /** |
163 | | - * Returns instructor addition controls for the course if the |
164 | | - * current user has the right permissions. |
165 | | - * |
166 | | - * @since 0.1 |
167 | | - * |
168 | | - * @param EPMC $masterCourse |
169 | | - * |
170 | | - * @return string |
171 | | - */ |
172 | | - protected function getInstructorControls( EPMC $masterCourse ) { |
173 | | - $user = $this->getUser(); |
174 | | - $links = array(); |
175 | | - |
176 | | - if ( ( $user->isAllowed( 'ep-instructor' ) || $user->isAllowed( 'ep-beinstructor' ) ) |
177 | | - && !in_array( $user->getId(), $masterCourse->getField( 'instructors' ) ) |
178 | | - ) { |
179 | | - $links[] = Html::element( |
180 | | - 'a', |
181 | | - array( |
182 | | - 'href' => '#', |
183 | | - 'class' => 'ep-add-instructor', |
184 | | - 'data-mcid' => $masterCourse->getId(), |
185 | | - 'data-mcname' => $masterCourse->getField( 'name' ), |
186 | | - 'data-mode' => 'self', |
187 | | - ), |
188 | | - wfMsg( 'ep-mc-become-instructor' ) |
189 | | - ); |
190 | | - } |
191 | | - |
192 | | - if ( $user->isAllowed( 'ep-instructor' ) ) { |
193 | | - $links[] = Html::element( |
194 | | - 'a', |
195 | | - array( |
196 | | - 'href' => '#', |
197 | | - 'class' => 'ep-add-instructor', |
198 | | - 'data-mcid' => $masterCourse->getId(), |
199 | | - 'data-mcname' => $masterCourse->getField( 'name' ), |
200 | | - ), |
201 | | - wfMsg( 'ep-mc-add-instructor' ) |
202 | | - ); |
203 | | - } |
204 | | - |
205 | | - if ( count( $links ) > 0 ) { |
206 | | - $this->getOutput()->addModules( 'ep.instructor' ); |
207 | | - return '<br />' . $this->getLanguage()->pipeList( $links ); |
208 | | - } |
209 | | - else { |
210 | | - return ''; |
211 | | - } |
212 | | - } |
213 | | - |
214 | | -} |
Index: trunk/extensions/EducationProgram/specials/SpecialEditMasterCourse.php |
— | — | @@ -1,92 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Addition and modification interface for master courses. |
6 | | - * |
7 | | - * @since 0.1 |
8 | | - * |
9 | | - * @file SpecialEditMasterCourse.php |
10 | | - * @ingroup EducationProgram |
11 | | - * |
12 | | - * @licence GNU GPL v3 or later |
13 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
14 | | - */ |
15 | | -class SpecialEditMasterCourse extends SpecialEPFormPage { |
16 | | - |
17 | | - /** |
18 | | - * Constructor. |
19 | | - * |
20 | | - * @since 0.1 |
21 | | - */ |
22 | | - public function __construct() { |
23 | | - parent::__construct( 'EditMasterCourse', 'ep-mc', 'EPMC', 'MasterCourses', 'MasterCourse' ); |
24 | | - } |
25 | | - |
26 | | - /** |
27 | | - * (non-PHPdoc) |
28 | | - * @see SpecialEPFormPage::getFormFields() |
29 | | - * @return array |
30 | | - */ |
31 | | - protected function getFormFields() { |
32 | | - $fields = parent::getFormFields(); |
33 | | - |
34 | | - $fields['name'] = array ( |
35 | | - 'type' => 'text', |
36 | | - 'label-message' => 'ep-mc-edit-name', |
37 | | - 'maxlength' => 255, |
38 | | - 'required' => true, |
39 | | - 'validation-callback' => function ( $value, array $alldata = null ) { |
40 | | - return strlen( $value ) < 5 ? wfMsgExt( 'ep-mc-invalid-name', 'parsemag', 5 ) : true; |
41 | | - } , |
42 | | - ); |
43 | | - |
44 | | - $orgOptions = EPOrg::getOrgOptions(); |
45 | | - |
46 | | - $fields['org_id'] = array ( |
47 | | - 'type' => 'select', |
48 | | - 'label-message' => 'ep-mc-edit-org', |
49 | | - 'required' => true, |
50 | | - 'options' => $orgOptions, |
51 | | - 'validation-callback' => function ( $value, array $alldata = null ) use ( $orgOptions ) { |
52 | | - return in_array( (int)$value, array_values( $orgOptions ) ) ? true : wfMsg( 'ep-mc-invalid-org' ); |
53 | | - } , |
54 | | - ); |
55 | | - |
56 | | - $fields['description'] = array ( |
57 | | - 'type' => 'textarea', |
58 | | - 'label-message' => 'ep-mc-edit-description', |
59 | | - 'required' => true, |
60 | | - 'validation-callback' => function ( $value, array $alldata = null ) { |
61 | | - return strlen( $value ) < 10 ? wfMsgExt( 'ep-mc-invalid-description', 'parsemag', 10 ) : true; |
62 | | - } , |
63 | | - 'rows' => 10, |
64 | | - 'cssclass' => 'wiki-editor-input', |
65 | | - 'id' => 'wpTextbox1' |
66 | | - ); |
67 | | - |
68 | | - $fields['timeline'] = array ( |
69 | | - 'type' => 'textarea', |
70 | | - 'label-message' => 'ep-mc-edit-timeline', |
71 | | - 'required' => true, |
72 | | - 'validation-callback' => function ( $value, array $alldata = null ) { |
73 | | - return strlen( $value ) < 10 ? wfMsgExt( 'ep-mc-invalid-description', 'parsemag', 10 ) : true; |
74 | | - } , |
75 | | - 'rows' => 10, |
76 | | - //'cssclass' => 'wiki-editor-input', |
77 | | - ); |
78 | | - |
79 | | - return $this->processFormFields( $fields ); |
80 | | - } |
81 | | - |
82 | | - /** |
83 | | - * (non-PHPdoc) |
84 | | - * @see SpecialEPFormPage::getNewData() |
85 | | - */ |
86 | | - protected function getNewData() { |
87 | | - return array( |
88 | | - 'org_id' => $this->getRequest()->getVal( 'neworg' ), |
89 | | - 'name' => $this->getRequest()->getVal( 'newname' ), |
90 | | - ); |
91 | | - } |
92 | | - |
93 | | -} |
Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php |
— | — | @@ -61,12 +61,12 @@ |
62 | 62 | |
63 | 63 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-institution-mcs' ) ) ); |
64 | 64 | |
65 | | - EPMC::displayPager( $this->getContext(), array( 'org_id' => $org->getId() ) ); |
| 65 | + EPCourse::displayPager( $this->getContext(), array( 'org_id' => $org->getId() ) ); |
66 | 66 | |
67 | | - if ( $this->getUser()->isAllowed( 'ep-mc' ) ) { |
68 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-institution-add-mc' ) ) ); |
| 67 | + if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
| 68 | + $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-institution-add-course' ) ) ); |
69 | 69 | |
70 | | - EPMC::displayAddNewControl( $this->getContext(), array( 'org' => $org->getId() ) ); |
| 70 | + EPCourse::displayAddNewControl( $this->getContext(), array( 'org' => $org->getId() ) ); |
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php |
— | — | @@ -100,13 +100,6 @@ |
101 | 101 | htmlspecialchars( $org ) |
102 | 102 | ); |
103 | 103 | |
104 | | - $masterCourse = EPMC::selectFieldsRow( 'name', array( 'id' => $course->getField( 'mc_id' ) ) ); |
105 | | - |
106 | | - $stats['mastercourse'] = Linker::linkKnown( |
107 | | - SpecialPage::getTitleFor( 'MasterCourse', $masterCourse ), |
108 | | - htmlspecialchars( $masterCourse ) |
109 | | - ); |
110 | | - |
111 | 104 | $lang = $this->getLanguage(); |
112 | 105 | |
113 | 106 | $stats['year'] = htmlspecialchars( $lang->formatNum( $course->getField( 'year' ), true ) ); |
Index: trunk/extensions/EducationProgram/specials/SpecialEditCourse.php |
— | — | @@ -32,15 +32,15 @@ |
33 | 33 | protected function getFormFields() { |
34 | 34 | $fields = parent::getFormFields(); |
35 | 35 | |
36 | | - $courseOptions = EPMC::getMasterCourseOptions(); |
| 36 | + $orgOptions = EPOrg::getOrgOptions(); |
37 | 37 | |
38 | 38 | $fields['mc_id'] = array ( |
39 | 39 | 'type' => 'select', |
40 | 40 | 'label-message' => 'ep-course-edit-mastercourse', |
41 | 41 | 'required' => true, |
42 | | - 'options' => $courseOptions, |
43 | | - 'validation-callback' => function ( $value, array $alldata = null ) use ( $courseOptions ) { |
44 | | - return in_array( (int)$value, array_values( $courseOptions ) ) ? true : wfMsg( 'ep-course-invalid-course' ); |
| 42 | + 'options' => $orgOptions, |
| 43 | + 'validation-callback' => function ( $value, array $alldata = null ) use ( $orgOptions ) { |
| 44 | + return in_array( (int)$value, array_values( $orgOptions ) ) ? true : wfMsg( 'ep-course-invalid-course' ); |
45 | 45 | }, |
46 | 46 | ); |
47 | 47 | |
Index: trunk/extensions/EducationProgram/specials/SpecialInstitutionHistory.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * @since 0.1 |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | | - parent::__construct( 'InstitutionHistory', 'EPMC', 'name', 'Institution' ); |
| 23 | + parent::__construct( 'InstitutionHistory', 'EPOrg', 'name', 'Institution' ); |
24 | 24 | } |
25 | 25 | |
26 | 26 | } |
Index: trunk/extensions/EducationProgram/includes/EPMCPager.php |
— | — | @@ -1,176 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Master course pager. |
6 | | - * |
7 | | - * @since 0.1 |
8 | | - * |
9 | | - * @file EPMCPager.php |
10 | | - * @ingroup EductaionProgram |
11 | | - * |
12 | | - * @licence GNU GPL v3 or later |
13 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
14 | | - */ |
15 | | -class EPMCPager extends EPPager { |
16 | | - |
17 | | - /** |
18 | | - * Constructor. |
19 | | - * |
20 | | - * @param IContextSource $context |
21 | | - * @param array $conds |
22 | | - */ |
23 | | - public function __construct( IContextSource $context, array $conds = array() ) { |
24 | | - parent::__construct( $context, $conds, 'EPMC' ); |
25 | | - } |
26 | | - |
27 | | - /** |
28 | | - * (non-PHPdoc) |
29 | | - * @see EPPager::getFields() |
30 | | - */ |
31 | | - public function getFields() { |
32 | | - return array( |
33 | | - 'name', |
34 | | - 'org_id', |
35 | | - 'students', |
36 | | - 'active', |
37 | | - ); |
38 | | - } |
39 | | - |
40 | | - /** |
41 | | - * (non-PHPdoc) |
42 | | - * @see TablePager::getRowClass() |
43 | | - */ |
44 | | - function getRowClass( $row ) { |
45 | | - return 'ep-course-row'; |
46 | | - } |
47 | | - |
48 | | - /** |
49 | | - * (non-PHPdoc) |
50 | | - * @see TablePager::getTableClass() |
51 | | - */ |
52 | | - public function getTableClass() { |
53 | | - return 'TablePager ep-courses'; |
54 | | - } |
55 | | - |
56 | | - /** |
57 | | - * (non-PHPdoc) |
58 | | - * @see EPPager::getFormattedValue() |
59 | | - */ |
60 | | - protected function getFormattedValue( $name, $value ) { |
61 | | - switch ( $name ) { |
62 | | - case 'name': |
63 | | - $value = Linker::linkKnown( |
64 | | - SpecialPage::getTitleFor( 'MasterCourse', $value ), |
65 | | - htmlspecialchars( $value ) |
66 | | - ); |
67 | | - break; |
68 | | - case 'org_id': |
69 | | - $value = EPOrg::selectRow( 'name', array( 'id' => $value ) )->getField( 'name' ); |
70 | | - |
71 | | - $value = Linker::linkKnown( |
72 | | - SpecialPage::getTitleFor( 'Institution', $value ), |
73 | | - htmlspecialchars( $value ) |
74 | | - ); |
75 | | - break; |
76 | | - case 'students': |
77 | | - $value = htmlspecialchars( $this->getLanguage()->formatNum( $value ) ); |
78 | | - break; |
79 | | - case 'active': |
80 | | - $value = wfMsgHtml( 'epmcpager-' . ( $value == '1' ? 'yes' : 'no' ) ); |
81 | | - break; |
82 | | - } |
83 | | - |
84 | | - return $value; |
85 | | - } |
86 | | - |
87 | | - function getDefaultSort() { |
88 | | - $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
89 | | - return $c::getPrefixedField( 'name' ); |
90 | | - } |
91 | | - |
92 | | - /** |
93 | | - * (non-PHPdoc) |
94 | | - * @see EPPager::getSortableFields() |
95 | | - */ |
96 | | - protected function getSortableFields() { |
97 | | - return array( |
98 | | - 'name', |
99 | | - 'students', |
100 | | - 'active', |
101 | | - ); |
102 | | - } |
103 | | - |
104 | | - /** |
105 | | - * (non-PHPdoc) |
106 | | - * @see EPPager::getFilterOptions() |
107 | | - */ |
108 | | - protected function getFilterOptions() { |
109 | | - return array( |
110 | | - 'org_id' => array( |
111 | | - 'type' => 'select', |
112 | | - 'options' => array_merge( |
113 | | - array( '' => '' ), |
114 | | - EPOrg::getOrgOptions( EPOrg::select( array( 'name', 'id' ) ) ) |
115 | | - ), |
116 | | - 'value' => '', |
117 | | - 'datatype' => 'int', |
118 | | - ), |
119 | | - 'active' => array( |
120 | | - 'type' => 'select', |
121 | | - 'options' => array( |
122 | | - '' => '', |
123 | | - wfMsg( 'epmcpager-yes' ) => '1', |
124 | | - wfMsg( 'epmcpager-no' ) => '0', |
125 | | - ), |
126 | | - 'value' => '', |
127 | | - ), |
128 | | - ); |
129 | | - } |
130 | | - |
131 | | - /** |
132 | | - * (non-PHPdoc) |
133 | | - * @see EPPager::getControlLinks() |
134 | | - */ |
135 | | - protected function getControlLinks( EPDBObject $item ) { |
136 | | - $links = parent::getControlLinks( $item ); |
137 | | - |
138 | | - $links[] = $value = Linker::linkKnown( |
139 | | - SpecialPage::getTitleFor( 'MasterCourse', $item->getField( 'name' ) ), |
140 | | - wfMsgHtml( 'view' ) |
141 | | - ); |
142 | | - |
143 | | - if ( $this->getUser()->isAllowed( 'ep-mc' ) ) { |
144 | | - $links[] = $value = Linker::linkKnown( |
145 | | - SpecialPage::getTitleFor( 'EditMasterCourse', $item->getField( 'name' ) ), |
146 | | - wfMsgHtml( 'edit' ), |
147 | | - array(), |
148 | | - array( 'wpreturnto' => $this->getTitle()->getText() ) |
149 | | - ); |
150 | | - |
151 | | - $links[] = $this->getDeletionLink( |
152 | | - ApiDeleteEducation::getTypeForClassName( $this->className ), |
153 | | - $item->getId() |
154 | | - ); |
155 | | - } |
156 | | - |
157 | | - return $links; |
158 | | - } |
159 | | - |
160 | | - /** |
161 | | - * (non-PHPdoc) |
162 | | - * @see EPPager::getMultipleItemActions() |
163 | | - */ |
164 | | - protected function getMultipleItemActions() { |
165 | | - $actions = parent::getMultipleItemActions(); |
166 | | - |
167 | | - if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
168 | | - $actions[wfMsg( 'ep-pager-delete-selected' )] = array( |
169 | | - 'class' => 'ep-pager-delete-selected', |
170 | | - 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->className ) |
171 | | - ); |
172 | | - } |
173 | | - |
174 | | - return $actions; |
175 | | - } |
176 | | - |
177 | | -} |
Index: trunk/extensions/EducationProgram/includes/EPMC.php |
— | — | @@ -1,497 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Class representing a single master course. |
6 | | - * These describe a specific course, time-independent. |
7 | | - * |
8 | | - * @since 0.1 |
9 | | - * |
10 | | - * @file EPMC.php |
11 | | - * @ingroup EducationProgram |
12 | | - * |
13 | | - * @licence GNU GPL v3 or later |
14 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | | - */ |
16 | | -class EPMC extends EPPageObject { |
17 | | - |
18 | | - /** |
19 | | - * Field for caching the linked org. |
20 | | - * |
21 | | - * @since 0.1 |
22 | | - * @var EPOrg|false |
23 | | - */ |
24 | | - protected $org = false; |
25 | | - |
26 | | - /** |
27 | | - * Field for caching the instructors. |
28 | | - * |
29 | | - * @since 0.1 |
30 | | - * @var {array of EPInstructor}|false |
31 | | - */ |
32 | | - protected $instructors = false; |
33 | | - |
34 | | - /** |
35 | | - * @see parent::getFieldTypes |
36 | | - * |
37 | | - * @since 0.1 |
38 | | - * |
39 | | - * @return array |
40 | | - */ |
41 | | - protected static function getFieldTypes() { |
42 | | - return array( |
43 | | - 'id' => 'id', |
44 | | - 'org_id' => 'id', |
45 | | - |
46 | | - 'name' => 'str', |
47 | | - 'description' => 'str', |
48 | | - 'timeline' => 'str', |
49 | | - 'lang' => 'str', |
50 | | - 'instructors' => 'array', |
51 | | - |
52 | | - 'active' => 'bool', |
53 | | - 'students' => 'int', |
54 | | - ); |
55 | | - } |
56 | | - |
57 | | - /** |
58 | | - * (non-PHPdoc) |
59 | | - * @see EPDBObject::getDefaults() |
60 | | - */ |
61 | | - public static function getDefaults() { |
62 | | - return array( |
63 | | - 'description' => '', |
64 | | - 'timeline' => '', |
65 | | - |
66 | | - 'active' => false, |
67 | | - 'students' => 0, |
68 | | - 'instructors' => array(), |
69 | | - ); |
70 | | - } |
71 | | - |
72 | | - /** |
73 | | - * (non-PHPdoc) |
74 | | - * @see EPDBObject::loadSummaryFields() |
75 | | - */ |
76 | | - public function loadSummaryFields( $summaryFields = null ) { |
77 | | - if ( is_null( $summaryFields ) ) { |
78 | | - $summaryFields = array( 'students', 'active' ); |
79 | | - } |
80 | | - else { |
81 | | - $summaryFields = (array)$summaryFields; |
82 | | - } |
83 | | - |
84 | | - $fields = array(); |
85 | | - |
86 | | - if ( in_array( 'students', $summaryFields ) ) { |
87 | | - $termIds = EPCourse::selectFields( 'id', array( 'mc_id' => $this->getId() ) ); |
88 | | - |
89 | | - if ( count( $termIds ) > 0 ) { |
90 | | - $fields['students'] = wfGetDB( DB_SLAVE )->select( |
91 | | - 'ep_students_per_course', |
92 | | - 'COUNT(*) AS rowcount', |
93 | | - array( 'spc_course_id' => $termIds ) |
94 | | - ); |
95 | | - |
96 | | - $fields['students'] = $fields['students']->fetchObject()->rowcount; |
97 | | - } |
98 | | - else { |
99 | | - $fields['students'] = 0; |
100 | | - } |
101 | | - } |
102 | | - |
103 | | - if ( in_array( 'active', $summaryFields ) ) { |
104 | | - $now = wfGetDB( DB_SLAVE )->addQuotes( wfTimestampNow() ); |
105 | | - |
106 | | - $fields['active'] = EPCourse::has( array( |
107 | | - 'mc_id' => $this->getId(), |
108 | | - 'end >= ' . $now, |
109 | | - 'start <= ' . $now, |
110 | | - ) ); |
111 | | - } |
112 | | - |
113 | | - $this->setFields( $fields ); |
114 | | - } |
115 | | - |
116 | | - /** |
117 | | - * (non-PHPdoc) |
118 | | - * @see EPDBObject::removeFromDB() |
119 | | - */ |
120 | | - public function removeFromDB() { |
121 | | - $id = $this->getId(); |
122 | | - |
123 | | - if ( $this->updateSummaries ) { |
124 | | - $this->loadFields( array( 'org_id' ) ); |
125 | | - $orgId = $this->getField( 'org_id', false ); |
126 | | - } |
127 | | - |
128 | | - $success = parent::removeFromDB(); |
129 | | - |
130 | | - if ( $success ) { |
131 | | - foreach ( EPCourse::select( 'id', array( 'mc_id' => $id ) ) as /* EPCourse */ $course ) { |
132 | | - $course->setUpdateSummaries( false ); |
133 | | - $success = $course->removeFromDB() && $success; |
134 | | - } |
135 | | - } |
136 | | - |
137 | | - if ( $this->updateSummaries && $orgId !== false ) { |
138 | | - EPOrg::updateSummaryFields( array( 'mcs', 'students', 'courses', 'active' ), array( 'id' => $orgId ) ); |
139 | | - } |
140 | | - |
141 | | - return $success; |
142 | | - } |
143 | | - |
144 | | - /** |
145 | | - * (non-PHPdoc) |
146 | | - * @see EPDBObject::insertIntoDB() |
147 | | - */ |
148 | | - protected function insertIntoDB() { |
149 | | - $success = parent::insertIntoDB(); |
150 | | - |
151 | | - if ( $this->updateSummaries ) { |
152 | | - EPOrg::updateSummaryFields( array( 'mcs', 'active' ), array( 'id' => $this->getField( 'org_id' ) ) ); |
153 | | - } |
154 | | - |
155 | | - return $success; |
156 | | - } |
157 | | - |
158 | | - /** |
159 | | - * (non-PHPdoc) |
160 | | - * @see EPDBObject::updateInDB() |
161 | | - */ |
162 | | - protected function updateInDB() { |
163 | | - $oldOrgId = $this->hasField( 'org_id' ) ? self::selectFieldsRow( 'org_id', array( 'id' => $this->getId() ) ) : false; |
164 | | - |
165 | | - $success = parent::updateInDB(); |
166 | | - |
167 | | - if ( $this->updateSummaries && $success && $oldOrgId !== false && $oldOrgId !== $this->getField( 'org_id' ) ) { |
168 | | - $conds = array( 'id' => array( $oldOrgId, $this->getField( 'org_id' ) ) ); |
169 | | - EPCourse::updateSummaryFields( 'org_id', array( 'mc_id' => $this->getId() ) ); |
170 | | - EPOrg::updateSummaryFields( array( 'mcs', 'students', 'courses', 'active' ), $conds ); |
171 | | - } |
172 | | - |
173 | | - return $success; |
174 | | - } |
175 | | - |
176 | | - /** |
177 | | - * Returns the org associated with this course. |
178 | | - * |
179 | | - * @since 0.1 |
180 | | - * |
181 | | - * @param string|array|null $fields |
182 | | - * |
183 | | - * @return EPOrg |
184 | | - */ |
185 | | - public function getOrg( $fields = null ) { |
186 | | - if ( $this->org === false ) { |
187 | | - $this->org = EPOrg::selectRow( $fields, array( 'id' => $this->getField( 'org_id' ) ) ); |
188 | | - } |
189 | | - |
190 | | - return $this->org; |
191 | | - } |
192 | | - |
193 | | - /** |
194 | | - * Returns a list of courses in an array that can be fed to select inputs. |
195 | | - * |
196 | | - * @since 0.1 |
197 | | - * |
198 | | - * @param array|null $masterCourses |
199 | | - * |
200 | | - * @return array |
201 | | - */ |
202 | | - public static function getMasterCourseOptions( array /* EPMC */ $masterCourses = null ) { |
203 | | - $options = array(); |
204 | | - |
205 | | - if ( is_null( $masterCourses ) ) { |
206 | | - $masterCourses = self::select( array( 'name', 'id' ) ); |
207 | | - } |
208 | | - |
209 | | - foreach ( $masterCourses as /* EPMC */ $masterCourse ) { |
210 | | - $options[$masterCourse->getField( 'name' )] = $masterCourse->getId(); |
211 | | - } |
212 | | - |
213 | | - return $options; |
214 | | - } |
215 | | - |
216 | | - /** |
217 | | - * Adds a control to add a new course to the provided context. |
218 | | - * Additional arguments can be provided to set the default values for the control fields. |
219 | | - * |
220 | | - * @since 0.1 |
221 | | - * |
222 | | - * @param IContextSource $context |
223 | | - * @param array $args |
224 | | - * |
225 | | - * @return boolean |
226 | | - */ |
227 | | - public static function displayAddNewControl( IContextSource $context, array $args = array() ) { |
228 | | - if ( !$context->getUser()->isAllowed( 'ep-mc' ) ) { |
229 | | - return false; |
230 | | - } |
231 | | - |
232 | | - $out = $context->getOutput(); |
233 | | - |
234 | | - $out->addHTML( Html::openElement( |
235 | | - 'form', |
236 | | - array( |
237 | | - 'method' => 'post', |
238 | | - 'action' => SpecialPage::getTitleFor( 'EditMasterCourse' )->getLocalURL(), |
239 | | - ) |
240 | | - ) ); |
241 | | - |
242 | | - $out->addHTML( '<fieldset>' ); |
243 | | - |
244 | | - $out->addHTML( '<legend>' . wfMsgHtml( 'ep-mcs-addnew' ) . '</legend>' ); |
245 | | - |
246 | | - $out->addHTML( Html::element( 'p', array(), wfMsg( 'ep-mcs-namedoc' ) ) ); |
247 | | - |
248 | | - $out->addHTML( Html::element( 'label', array( 'for' => 'neworg' ), wfMsg( 'ep-mcs-neworg' ) ) ); |
249 | | - |
250 | | - $out->addHTML( ' ' ); |
251 | | - |
252 | | - $select = new XmlSelect( |
253 | | - 'neworg', |
254 | | - 'neworg', |
255 | | - array_key_exists( 'org', $args ) ? $args['org'] : false |
256 | | - ); |
257 | | - |
258 | | - $select->addOptions( EPOrg::getOrgOptions() ); |
259 | | - $out->addHTML( $select->getHTML() ); |
260 | | - |
261 | | - $out->addHTML( ' ' ); |
262 | | - |
263 | | - $out->addHTML( Xml::inputLabel( |
264 | | - wfMsg( 'ep-mcs-newname' ), |
265 | | - 'newname', |
266 | | - 'newname', |
267 | | - false, |
268 | | - array_key_exists( 'name', $args ) ? $args['name'] : false |
269 | | - ) ); |
270 | | - |
271 | | - $out->addHTML( ' ' ); |
272 | | - |
273 | | - $out->addHTML( Html::input( |
274 | | - 'addneworg', |
275 | | - wfMsg( 'ep-courses-add' ), |
276 | | - 'submit' |
277 | | - ) ); |
278 | | - |
279 | | - $out->addHTML( Html::hidden( 'isnew', 1 ) ); |
280 | | - |
281 | | - $out->addHTML( '</fieldset></form>' ); |
282 | | - |
283 | | - return true; |
284 | | - } |
285 | | - |
286 | | - /** |
287 | | - * Adds a control to add a new master course to the provided context |
288 | | - * or show a message if this is not possible for some reason. |
289 | | - * |
290 | | - * @since 0.1 |
291 | | - * |
292 | | - * @param IContextSource $context |
293 | | - * @param array $args |
294 | | - */ |
295 | | - public static function displayAddNewRegion( IContextSource $context, array $args = array() ) { |
296 | | - if ( EPOrg::has() ) { |
297 | | - self::displayAddNewControl( $context, $args ); |
298 | | - } |
299 | | - elseif ( $context->getUser()->isAllowed( 'ep-org' ) ) { |
300 | | - $context->getOutput()->addWikiMsg( 'ep-courses-addorgfirst' ); |
301 | | - } |
302 | | - } |
303 | | - |
304 | | - /** |
305 | | - * Display a pager with courses. |
306 | | - * |
307 | | - * @since 0.1 |
308 | | - * |
309 | | - * @param IContextSource $context |
310 | | - * @param array $conditions |
311 | | - */ |
312 | | - public static function displayPager( IContextSource $context, array $conditions = array() ) { |
313 | | - $pager = new EPMCPager( $context, $conditions ); |
314 | | - |
315 | | - if ( $pager->getNumRows() ) { |
316 | | - $context->getOutput()->addHTML( |
317 | | - $pager->getFilterControl() . |
318 | | - $pager->getNavigationBar() . |
319 | | - $pager->getBody() . |
320 | | - $pager->getNavigationBar() . |
321 | | - $pager->getMultipleItemControl() |
322 | | - ); |
323 | | - } |
324 | | - else { |
325 | | - $context->getOutput()->addHTML( $pager->getFilterControl( true ) ); |
326 | | - $context->getOutput()->addWikiMsg( 'ep-mcs-noresults' ); |
327 | | - } |
328 | | - } |
329 | | - |
330 | | - /** |
331 | | - * Returns the instructors as a list of EPInstructor objects. |
332 | | - * |
333 | | - * @since 0.1 |
334 | | - * |
335 | | - * @return array of EPInstructor |
336 | | - */ |
337 | | - public function getInstructors() { |
338 | | - if ( $this->instructors === false ) { |
339 | | - $this->instructors = array(); |
340 | | - |
341 | | - foreach ( $this->getField( 'instructors' ) as $userId ) { |
342 | | - $this->instructors[] = EPInstructor::newFromId( $userId ); |
343 | | - } |
344 | | - } |
345 | | - |
346 | | - return $this->instructors; |
347 | | - } |
348 | | - |
349 | | - /** |
350 | | - * (non-PHPdoc) |
351 | | - * @see EPDBObject::setField() |
352 | | - */ |
353 | | - public function setField( $name, $value ) { |
354 | | - if ( $name === 'instructors' ) { |
355 | | - $this->instructors = false; |
356 | | - } |
357 | | - elseif ( $name === 'org_id' ) { |
358 | | - $this->org = false; |
359 | | - } |
360 | | - |
361 | | - parent::setField( $name, $value ); |
362 | | - } |
363 | | - |
364 | | - /** |
365 | | - * Adds a number of instructors to this course, |
366 | | - * by default also saving the course and only |
367 | | - * logging the adittion of the instructors. |
368 | | - * |
369 | | - * @since 0.1 |
370 | | - * |
371 | | - * @param array|integer $newInstructors |
372 | | - * @param string $message |
373 | | - * @param boolean $save |
374 | | - * @param boolean $log |
375 | | - * |
376 | | - * @return boolean Success indicator |
377 | | - */ |
378 | | - public function addInstructors( $newInstructors, $message = '', $save = true, $log = true ) { |
379 | | - $instructors = $this->getField( 'instructors' ); |
380 | | - $addedInstructors = array(); |
381 | | - |
382 | | - foreach ( (array)$newInstructors as $userId ) { |
383 | | - if ( !is_integer( $userId ) ) { |
384 | | - throw new MWException( 'Provided user id is not an integer' ); |
385 | | - } |
386 | | - |
387 | | - if ( !in_array( $userId, $instructors ) ) { |
388 | | - $instructors[] = $userId; |
389 | | - $addedInstructors[] = $userId; |
390 | | - } |
391 | | - } |
392 | | - |
393 | | - if ( count( $addedInstructors ) > 0 ) { |
394 | | - $this->setField( 'instructors', $instructors ); |
395 | | - |
396 | | - $success = true; |
397 | | - |
398 | | - if ( $save ) { |
399 | | - $this->disableLogging(); |
400 | | - $success = $this->writeToDB(); |
401 | | - $this->enableLogging(); |
402 | | - } |
403 | | - |
404 | | - if ( $success && $log ) { |
405 | | - $this->logInstructorChange( 'add', $addedInstructors, $message ); |
406 | | - } |
407 | | - |
408 | | - return $success; |
409 | | - } |
410 | | - else { |
411 | | - return true; |
412 | | - } |
413 | | - } |
414 | | - |
415 | | - /** |
416 | | - * Remove a number of instructors to this course, |
417 | | - * by default also saving the course and only |
418 | | - * logging the removal of the instructors. |
419 | | - * |
420 | | - * @since 0.1 |
421 | | - * |
422 | | - * @param array|integer $sadInstructors |
423 | | - * @param string $message |
424 | | - * @param boolean $save |
425 | | - * @param boolean $log |
426 | | - * |
427 | | - * @return boolean Success indicator |
428 | | - */ |
429 | | - public function removeInstructors( $sadInstructors, $message = '', $save = true, $log = true ) { |
430 | | - $removedInstructors = array(); |
431 | | - $remaimingInstructors = array(); |
432 | | - $sadInstructors = (array)$sadInstructors; |
433 | | - |
434 | | - foreach ( $this->getField( 'instructors' ) as $userId ) { |
435 | | - if ( in_array( $userId, $sadInstructors ) ) { |
436 | | - $removedInstructors[] = $userId; |
437 | | - } |
438 | | - else { |
439 | | - $remaimingInstructors[] = $userId; |
440 | | - } |
441 | | - } |
442 | | - |
443 | | - if ( count( $removedInstructors ) > 0 ) { |
444 | | - $this->setField( 'instructors', $remaimingInstructors ); |
445 | | - |
446 | | - $success = true; |
447 | | - |
448 | | - if ( $save ) { |
449 | | - $this->disableLogging(); |
450 | | - $success = $this->writeToDB(); |
451 | | - $this->enableLogging(); |
452 | | - } |
453 | | - |
454 | | - if ( $success && $log ) { |
455 | | - $this->logInstructorChange( 'remove', $removedInstructors, $message ); |
456 | | - } |
457 | | - |
458 | | - return $success; |
459 | | - } |
460 | | - else { |
461 | | - return true; |
462 | | - } |
463 | | - } |
464 | | - |
465 | | - /** |
466 | | - * Log a change of the instructors of the course. |
467 | | - * |
468 | | - * @since 0.1 |
469 | | - * |
470 | | - * @param string $action |
471 | | - * @param array $instructors |
472 | | - * @param string $message |
473 | | - */ |
474 | | - protected function logInstructorChange( $action, array $instructors, $message ) { |
475 | | - $names = array(); |
476 | | - |
477 | | - foreach ( $instructors as $userId ) { |
478 | | - $names[] = EPInstructor::newFromId( $userId )->getName(); |
479 | | - } |
480 | | - |
481 | | - $info = array( |
482 | | - 'type' => 'instructor', |
483 | | - 'subtype' => $action, |
484 | | - 'title' => $this->getTitle(), |
485 | | - 'parameters' => array( |
486 | | - '4::instructorcount' => count( $names ), |
487 | | - '5::instructors' => $GLOBALS['wgLang']->listToText( $names ) |
488 | | - ), |
489 | | - ); |
490 | | - |
491 | | - if ( $message !== '' ) { |
492 | | - $info['comment'] = $message; |
493 | | - } |
494 | | - |
495 | | - EPUtils::log( $info ); |
496 | | - } |
497 | | - |
498 | | -} |
Index: trunk/extensions/EducationProgram/includes/EPInstructor.php |
— | — | @@ -121,26 +121,26 @@ |
122 | 122 | * @since 0.1 |
123 | 123 | * |
124 | 124 | * @param IContextSource $context |
125 | | - * @param EPMC|null $course |
| 125 | + * @param EPCourse|null $course |
126 | 126 | * |
127 | 127 | * @return string |
128 | 128 | */ |
129 | | - public function getToolLinks( IContextSource $context, EPMC $masterCourse = null ) { |
| 129 | + public function getToolLinks( IContextSource $context, EPCourse $course = null ) { |
130 | 130 | $links = array(); |
131 | 131 | |
132 | 132 | $links[] = Linker::userTalkLink( $this->getUser()->getId(), $this->getUser()->getName() ); |
133 | 133 | |
134 | 134 | $links[] = Linker::link( SpecialPage::getTitleFor( 'Contributions', $this->getUser()->getName() ), wfMsgHtml( 'contribslink' ) ); |
135 | 135 | |
136 | | - if ( !is_null( $masterCourse ) && |
| 136 | + if ( !is_null( $course ) && |
137 | 137 | ( $context->getUser()->isAllowed( 'ep-instructor' ) || $this->getUser()->getId() == $context->getUser()->getId() ) ) { |
138 | 138 | $links[] = Html::element( |
139 | 139 | 'a', |
140 | 140 | array( |
141 | 141 | 'href' => '#', |
142 | 142 | 'class' => 'ep-instructor-remove', |
143 | | - 'data-mcid' => $masterCourse->getId(), |
144 | | - 'data-mcname' => $masterCourse->getField( 'name' ), |
| 143 | + 'data-courseid' => $course->getId(), |
| 144 | + 'data-coursename' => $course->getField( 'name' ), |
145 | 145 | 'data-userid' => $this->getUser()->getId(), |
146 | 146 | 'data-username' => $this->getUser()->getName(), |
147 | 147 | 'data-bestname' => $this->getName(), |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | public function getFields() { |
32 | 32 | return array( |
33 | 33 | 'id', |
34 | | - 'mc_id', |
| 34 | + 'org_id', |
35 | 35 | 'year', |
36 | 36 | 'start', |
37 | 37 | 'end', |
— | — | @@ -66,11 +66,11 @@ |
67 | 67 | htmlspecialchars( $this->getLanguage()->formatNum( $value, true ) ) |
68 | 68 | ); |
69 | 69 | break; |
70 | | - case 'mc_id': |
71 | | - $value = EPMC::selectRow( 'name', array( 'id' => $value ) )->getField( 'name' ); |
| 70 | + case 'org_id': |
| 71 | + $value = EPOrg::selectRow( 'name', array( 'id' => $value ) )->getField( 'name' ); |
72 | 72 | |
73 | 73 | $value = Linker::linkKnown( |
74 | | - SpecialPage::getTitleFor( 'MasterCourse', $value ), |
| 74 | + SpecialPage::getTitleFor( 'Institution', $value ), |
75 | 75 | htmlspecialchars( $value ) |
76 | 76 | ); |
77 | 77 | break; |
— | — | @@ -127,28 +127,16 @@ |
128 | 128 | protected function getFilterOptions() { |
129 | 129 | $options = array(); |
130 | 130 | |
131 | | - if ( !array_key_exists( 'mc_id', $this->conds ) ) { |
132 | | - $options['mc_id'] = array( |
133 | | - 'type' => 'select', |
134 | | - 'options' => array_merge( |
135 | | - array( '' => '' ), |
136 | | - EPMC::getMasterCourseOptions( EPMC::select( array( 'name', 'id' ) ) ) |
137 | | - ), |
138 | | - 'value' => '', |
139 | | - 'datatype' => 'int', |
140 | | - ); |
| 131 | + $options['org_id'] = array( |
| 132 | + 'type' => 'select', |
| 133 | + 'options' => array_merge( |
| 134 | + array( '' => '' ), |
| 135 | + EPOrg::getOrgOptions( EPOrg::select( array( 'name', 'id' ) ) ) |
| 136 | + ), |
| 137 | + 'value' => '', |
| 138 | + 'datatype' => 'int', |
| 139 | + ); |
141 | 140 | |
142 | | - $options['org_id'] = array( |
143 | | - 'type' => 'select', |
144 | | - 'options' => array_merge( |
145 | | - array( '' => '' ), |
146 | | - EPOrg::getOrgOptions( EPOrg::select( array( 'name', 'id' ) ) ) |
147 | | - ), |
148 | | - 'value' => '', |
149 | | - 'datatype' => 'int', |
150 | | - ); |
151 | | - } |
152 | | - |
153 | 141 | $years = EPCourse::selectFields( 'year', array(), array( 'DISTINCT' ), array(), true ); |
154 | 142 | asort( $years, SORT_NUMERIC ); |
155 | 143 | $years = array_merge( array( '' ), $years ); |
Index: trunk/extensions/EducationProgram/includes/EPStudent.php |
— | — | @@ -91,7 +91,6 @@ |
92 | 92 | $dbw->commit(); |
93 | 93 | |
94 | 94 | foreach ( $courses as /* EPCourse */ $course ) { |
95 | | - EPMC::updateSummaryFields( 'students', array( 'id' => $course->getField( 'mc_id' ) ) ); |
96 | 95 | EPOrg::updateSummaryFields( 'students', array( 'id' => $course->getField( 'org_id' ) ) ); |
97 | 96 | EPCourse::updateSummaryFields( 'students', array( 'id' => $course->getId() ) ); |
98 | 97 | } |
— | — | @@ -161,66 +160,6 @@ |
162 | 161 | } |
163 | 162 | |
164 | 163 | /** |
165 | | - * Returns the master courses this student is linked to (via courses). |
166 | | - * |
167 | | - * @since 0.1 |
168 | | - * |
169 | | - * @param string|null|array $fields |
170 | | - * @param array $conditions |
171 | | - * @param array $courseConditions |
172 | | - * |
173 | | - * @return array of EPMC |
174 | | - */ |
175 | | - public function getMasterCourses( $fields = null, array $conditions = array(), array $courseConditions = array() ) { |
176 | | - $mcIds = array_reduce( |
177 | | - $this->getCourses( 'course_id', $courseConditions ), |
178 | | - function( array $ids, EPCourse $term ) { |
179 | | - $ids[] = $term->getField( 'mc_id' ); |
180 | | - return $ids; |
181 | | - }, |
182 | | - array() |
183 | | - ); |
184 | | - |
185 | | - if ( count( $mcIds ) < 1 ) { |
186 | | - return array(); |
187 | | - } |
188 | | - |
189 | | - $conditions['id'] = array_unique( $mcIds ); |
190 | | - |
191 | | - return EPMC::select( $fields, $conditions ); |
192 | | - } |
193 | | - |
194 | | - /** |
195 | | - * Returns the master courses this student is currently enrolled in. |
196 | | - * |
197 | | - * @since 0.1 |
198 | | - * |
199 | | - * @param string|null|array $fields |
200 | | - * @param array $conditions |
201 | | - * |
202 | | - * @return array of EPMC |
203 | | - */ |
204 | | - public function getCurrentMasterCourses( $fields = null, array $conditions = array() ) { |
205 | | - $conditions['active'] = 1; |
206 | | - return $this->getMasterCourses( $fields, $conditions ); |
207 | | - } |
208 | | - |
209 | | - /** |
210 | | - * Returns the master courses this student was previously enrolled in. |
211 | | - * |
212 | | - * @since 0.1 |
213 | | - * |
214 | | - * @param string|null|array $fields |
215 | | - * @param array $conditions |
216 | | - * |
217 | | - * @return array of EPMC |
218 | | - */ |
219 | | - public function getPassedMasterCourses( $fields = null, array $conditions = array() ) { |
220 | | - $conditions['active'] = 0; |
221 | | - return $this->getMasterCourses( $fields, $conditions ); |
222 | | - } |
223 | | - |
224 | | - /** |
225 | 164 | * Returns the courses this student is enrolled in. |
226 | 165 | * |
227 | 166 | * @since 0.1 |
Index: trunk/extensions/EducationProgram/includes/EPOrg.php |
— | — | @@ -14,14 +14,6 @@ |
15 | 15 | class EPOrg extends EPPageObject { |
16 | 16 | |
17 | 17 | /** |
18 | | - * Cached array of the linked EPMC objects. |
19 | | - * |
20 | | - * @since 0.1 |
21 | | - * @var array|false |
22 | | - */ |
23 | | - protected $mcs = false; |
24 | | - |
25 | | - /** |
26 | 18 | * Cached array of the linked EPCourse objects. |
27 | 19 | * |
28 | 20 | * @since 0.1 |
— | — | @@ -46,8 +38,10 @@ |
47 | 39 | |
48 | 40 | 'active' => 'bool', |
49 | 41 | 'courses' => 'int', |
50 | | - 'mcs' => 'int', |
51 | 42 | 'students' => 'int', |
| 43 | + 'instructors' => 'int', |
| 44 | + 'campus_ambs' => 'int', |
| 45 | + 'online_ambs' => 'int', |
52 | 46 | ); |
53 | 47 | } |
54 | 48 | |
— | — | @@ -63,8 +57,10 @@ |
64 | 58 | |
65 | 59 | 'active' => false, |
66 | 60 | 'courses' => 0, |
67 | | - 'mcs' => 0, |
68 | 61 | 'students' => 0, |
| 62 | + 'instructors' => 0, |
| 63 | + 'campus_ambs' => 0, |
| 64 | + 'online_ambs' => 0, |
69 | 65 | ); |
70 | 66 | } |
71 | 67 | |
— | — | @@ -97,10 +93,6 @@ |
98 | 94 | $fields['courses'] = EPCourse::count( array( 'org_id' => $this->getId() ) ); |
99 | 95 | } |
100 | 96 | |
101 | | - if ( in_array( 'mcs', $summaryFields ) ) { |
102 | | - $fields['mcs'] = EPMC::count( array( 'org_id' => $this->getId() ) ); |
103 | | - } |
104 | | - |
105 | 97 | $dbr = wfGetDB( DB_SLAVE ); |
106 | 98 | |
107 | 99 | if ( in_array( 'students', $summaryFields ) ) { |
— | — | @@ -146,8 +138,8 @@ |
147 | 139 | if ( $success ) { |
148 | 140 | $success = wfGetDB( DB_MASTER )->delete( 'ep_cas_per_org', array( 'cpo_org_id' => $id ) ) && $success; |
149 | 141 | |
150 | | - foreach ( EPMC::select( 'id', array( 'org_id' => $id ) ) as /* EPMC */ $masterCourse ) { |
151 | | - $success = $masterCourse->removeFromDB() && $success; |
| 142 | + foreach ( EPCourse::select( 'id', array( 'org_id' => $id ) ) as /* EPCourse */ $course ) { |
| 143 | + $success = $course->removeFromDB() && $success; |
152 | 144 | } |
153 | 145 | } |
154 | 146 | |
— | — | @@ -257,23 +249,6 @@ |
258 | 250 | } |
259 | 251 | |
260 | 252 | /** |
261 | | - * Retruns the master courses linked to this org. |
262 | | - * |
263 | | - * @since 0.1 |
264 | | - * |
265 | | - * @param array|null $fields |
266 | | - * |
267 | | - * @return array of EPMC |
268 | | - */ |
269 | | - public function getMasterCourses( array $fields = null ) { |
270 | | - if ( $this->mcs === false ) { |
271 | | - $this->mcs = EPMC::select( $fields, array( 'org_id' => $this->getId() ) ); |
272 | | - } |
273 | | - |
274 | | - return $this->mcs; |
275 | | - } |
276 | | - |
277 | | - /** |
278 | 253 | * Retruns the courses linked to this org. |
279 | 254 | * |
280 | 255 | * @since 0.1 |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -14,14 +14,6 @@ |
15 | 15 | class EPCourse extends EPPageObject { |
16 | 16 | |
17 | 17 | /** |
18 | | - * Field for caching the linked master course. |
19 | | - * |
20 | | - * @since 0.1 |
21 | | - * @var EPMC|false |
22 | | - */ |
23 | | - protected $mc = false; |
24 | | - |
25 | | - /** |
26 | 18 | * Field for caching the linked org. |
27 | 19 | * |
28 | 20 | * @since 0.1 |
— | — | @@ -38,6 +30,14 @@ |
39 | 31 | protected $students = false; |
40 | 32 | |
41 | 33 | /** |
| 34 | + * Field for caching the instructors. |
| 35 | + * |
| 36 | + * @since 0.1 |
| 37 | + * @var {array of EPInstructor}|false |
| 38 | + */ |
| 39 | + protected $instructors = false; |
| 40 | + |
| 41 | + /** |
42 | 42 | * Returns a list of statuses a term can have. |
43 | 43 | * Keys are messages, values are identifiers. |
44 | 44 | * |
— | — | @@ -82,18 +82,20 @@ |
83 | 83 | protected static function getFieldTypes() { |
84 | 84 | return array( |
85 | 85 | 'id' => 'id', |
86 | | - 'mc_id' => 'id', |
87 | 86 | 'org_id' => 'id', |
88 | 87 | |
89 | 88 | 'name' => 'str', |
90 | | - 'year' => 'int', |
91 | 89 | 'start' => 'str', // TS_MW |
92 | 90 | 'end' => 'str', // TS_MW |
93 | 91 | 'description' => 'str', |
94 | | - 'timeline' => 'str', |
95 | 92 | 'token' => 'str', |
96 | 93 | 'online_ambs' => 'array', |
97 | 94 | 'campus_ambs' => 'array', |
| 95 | + 'field' => 'str', |
| 96 | + 'level' => 'str', |
| 97 | + 'term' => 'str', |
| 98 | + 'lang' => 'str', |
| 99 | + 'mc' => 'str', |
98 | 100 | |
99 | 101 | 'students' => 'int', |
100 | 102 | ); |
— | — | @@ -106,15 +108,18 @@ |
107 | 109 | public static function getDefaults() { |
108 | 110 | return array( |
109 | 111 | 'name' => '', |
110 | | - 'year' => substr( wfTimestamp( TS_MW ), 0, 4 ), |
111 | 112 | 'start' => wfTimestamp( TS_MW ), |
112 | 113 | 'end' => wfTimestamp( TS_MW ), |
113 | 114 | 'description' => '', |
114 | | - 'timeline' => '', |
115 | 115 | 'token' => '', |
116 | 116 | 'online_ambs' => array(), |
117 | 117 | 'campus_ambs' => array(), |
118 | | - |
| 118 | + 'field' => '', |
| 119 | + 'level' => '', |
| 120 | + 'term' => '', |
| 121 | + 'lang' => '', |
| 122 | + 'mc' => '', |
| 123 | + |
119 | 124 | 'students' => 0, |
120 | 125 | ); |
121 | 126 | } |
— | — | @@ -217,7 +222,6 @@ |
218 | 223 | |
219 | 224 | if ( $success && $this->updateSummaries ) { |
220 | 225 | EPOrg::updateSummaryFields( array( 'courses', 'active' ), array( 'id' => $this->getField( 'org_id' ) ) ); |
221 | | - EPMC::updateSummaryFields( 'active', array( 'id' => $this->getField( 'mc_id' ) ) ); |
222 | 226 | } |
223 | 227 | |
224 | 228 | return $success; |
— | — | @@ -239,7 +243,6 @@ |
240 | 244 | $success = parent::removeFromDB(); |
241 | 245 | |
242 | 246 | if ( $success && $this->updateSummaries ) { |
243 | | - EPMC::updateSummaryFields( 'students', array( 'id' => $courseId ) ); |
244 | 247 | EPOrg::updateSummaryFields( array( 'courses', 'students', 'active' ), array( 'id' => $orgId ) ); |
245 | 248 | } |
246 | 249 | |
— | — | @@ -257,17 +260,8 @@ |
258 | 261 | protected function updateInDB() { |
259 | 262 | if ( $this->updateSummaries ) { |
260 | 263 | $oldOrgId = $this->hasField( 'org_id' ) ? self::selectFieldsRow( 'org_id', array( 'id' => $this->getId() ) ) : false; |
261 | | - $oldCourseId = $this->hasField( 'mc_id' ) ? self::selectFieldsRow( 'mc_id', array( 'id' => $this->getId() ) ) : false; |
262 | 264 | } |
263 | 265 | |
264 | | - if ( $this->hasField( 'mc_id' ) ) { |
265 | | - $oldCourseId = self::selectFieldsRow( 'mc_id', array( 'id' => $this->getId() ) ); |
266 | | - |
267 | | - if ( $this->getField( 'mc_id' ) !== $oldCourseId ) { |
268 | | - $this->setField( 'org_id', EPCourse::selectFieldsRow( 'org_id', array( 'id' => $this->getField( 'mc_id' ) ) ) ); |
269 | | - } |
270 | | - } |
271 | | - |
272 | 266 | $success = parent::updateInDB(); |
273 | 267 | |
274 | 268 | if ( $this->updateSummaries && $success ) { |
— | — | @@ -275,34 +269,12 @@ |
276 | 270 | $conds = array( 'id' => array( $oldOrgId, $this->getField( 'org_id' ) ) ); |
277 | 271 | EPOrg::updateSummaryFields( array( 'courses', 'students', 'active' ), $conds ); |
278 | 272 | } |
279 | | - |
280 | | - if ( $oldCourseId !== false && $oldCourseId !== $this->getField( 'org_id' ) ) { |
281 | | - $conds = array( 'id' => array( $oldCourseId, $this->getField( 'mc_id' ) ) ); |
282 | | - EPMC::updateSummaryFields( array( 'active', 'students' ), $conds ); |
283 | | - } |
284 | 273 | } |
285 | 274 | |
286 | 275 | return $success; |
287 | 276 | } |
288 | 277 | |
289 | 278 | /** |
290 | | - * Returns the master course associated with this course. |
291 | | - * |
292 | | - * @since 0.1 |
293 | | - * |
294 | | - * @param string|array|null $fields |
295 | | - * |
296 | | - * @return EPMC |
297 | | - */ |
298 | | - public function getMasterCourse( $fields = null ) { |
299 | | - if ( $this->mc === false ) { |
300 | | - $this->mc = EPMC::selectRow( $fields, array( 'id' => $this->loadAndGetField( 'mc_id' ) ) ); |
301 | | - } |
302 | | - |
303 | | - return $this->mc; |
304 | | - } |
305 | | - |
306 | | - /** |
307 | 279 | * Returns the org associated with this term. |
308 | 280 | * |
309 | 281 | * @since 0.1 |
— | — | @@ -380,12 +352,12 @@ |
381 | 353 | $out->addHTML( Html::element( 'label', array( 'for' => 'newmc' ), wfMsg( 'ep-courses-newmastercourse' ) ) ); |
382 | 354 | |
383 | 355 | $select = new XmlSelect( |
384 | | - 'newmc', |
385 | | - 'newmc', |
386 | | - array_key_exists( 'mc', $args ) ? $args['mc'] : false |
| 356 | + 'neworg', |
| 357 | + 'neworg', |
| 358 | + array_key_exists( 'org', $args ) ? $args['org'] : false |
387 | 359 | ); |
388 | 360 | |
389 | | - $select->addOptions( EPMC::getMasterCourseOptions() ); |
| 361 | + $select->addOptions( EPOrg::getOrgOptions() ); |
390 | 362 | $out->addHTML( $select->getHTML() ); |
391 | 363 | |
392 | 364 | $out->addHTML( ' ' . Xml::inputLabel( wfMsg( 'ep-courses-newyear' ), 'newyear', 'newyear', 10 ) ); |
— | — | @@ -413,11 +385,11 @@ |
414 | 386 | * @param array $args |
415 | 387 | */ |
416 | 388 | public static function displayAddNewRegion( IContextSource $context, array $args = array() ) { |
417 | | - if ( EPMC::has() ) { |
| 389 | + if ( EPOrg::has() ) { |
418 | 390 | EPCourse::displayAddNewControl( $context, $args ); |
419 | 391 | } |
420 | 392 | elseif ( $context->getUser()->isAllowed( 'ep-course' ) ) { |
421 | | - $context->getOutput()->addWikiMsg( 'ep-courses-addmastercoursefirst' ); |
| 393 | + $context->getOutput()->addWikiMsg( 'ep-courses-addorgfirst' ); |
422 | 394 | } |
423 | 395 | } |
424 | 396 | |
— | — | @@ -466,4 +438,169 @@ |
467 | 439 | return $status; |
468 | 440 | } |
469 | 441 | |
| 442 | + /** |
| 443 | + * Returns the instructors as a list of EPInstructor objects. |
| 444 | + * |
| 445 | + * @since 0.1 |
| 446 | + * |
| 447 | + * @return array of EPInstructor |
| 448 | + */ |
| 449 | + public function getInstructors() { |
| 450 | + if ( $this->instructors === false ) { |
| 451 | + $this->instructors = array(); |
| 452 | + |
| 453 | + foreach ( $this->getField( 'instructors' ) as $userId ) { |
| 454 | + $this->instructors[] = EPInstructor::newFromId( $userId ); |
| 455 | + } |
| 456 | + } |
| 457 | + |
| 458 | + return $this->instructors; |
| 459 | + } |
| 460 | + |
| 461 | + /** |
| 462 | + * (non-PHPdoc) |
| 463 | + * @see EPDBObject::setField() |
| 464 | + */ |
| 465 | + public function setField( $name, $value ) { |
| 466 | + if ( $name === 'instructors' ) { |
| 467 | + $this->instructors = false; |
| 468 | + } |
| 469 | + |
| 470 | + parent::setField( $name, $value ); |
| 471 | + } |
| 472 | + |
| 473 | + /** |
| 474 | + * Adds a number of instructors to this course, |
| 475 | + * by default also saving the course and only |
| 476 | + * logging the adittion of the instructors. |
| 477 | + * |
| 478 | + * @since 0.1 |
| 479 | + * |
| 480 | + * @param array|integer $newInstructors |
| 481 | + * @param string $message |
| 482 | + * @param boolean $save |
| 483 | + * @param boolean $log |
| 484 | + * |
| 485 | + * @return boolean Success indicator |
| 486 | + */ |
| 487 | + public function addInstructors( $newInstructors, $message = '', $save = true, $log = true ) { |
| 488 | + $instructors = $this->getField( 'instructors' ); |
| 489 | + $addedInstructors = array(); |
| 490 | + |
| 491 | + foreach ( (array)$newInstructors as $userId ) { |
| 492 | + if ( !is_integer( $userId ) ) { |
| 493 | + throw new MWException( 'Provided user id is not an integer' ); |
| 494 | + } |
| 495 | + |
| 496 | + if ( !in_array( $userId, $instructors ) ) { |
| 497 | + $instructors[] = $userId; |
| 498 | + $addedInstructors[] = $userId; |
| 499 | + } |
| 500 | + } |
| 501 | + |
| 502 | + if ( count( $addedInstructors ) > 0 ) { |
| 503 | + $this->setField( 'instructors', $instructors ); |
| 504 | + |
| 505 | + $success = true; |
| 506 | + |
| 507 | + if ( $save ) { |
| 508 | + $this->disableLogging(); |
| 509 | + $success = $this->writeToDB(); |
| 510 | + $this->enableLogging(); |
| 511 | + } |
| 512 | + |
| 513 | + if ( $success && $log ) { |
| 514 | + $this->logInstructorChange( 'add', $addedInstructors, $message ); |
| 515 | + } |
| 516 | + |
| 517 | + return $success; |
| 518 | + } |
| 519 | + else { |
| 520 | + return true; |
| 521 | + } |
| 522 | + } |
| 523 | + |
| 524 | + /** |
| 525 | + * Remove a number of instructors to this course, |
| 526 | + * by default also saving the course and only |
| 527 | + * logging the removal of the instructors. |
| 528 | + * |
| 529 | + * @since 0.1 |
| 530 | + * |
| 531 | + * @param array|integer $sadInstructors |
| 532 | + * @param string $message |
| 533 | + * @param boolean $save |
| 534 | + * @param boolean $log |
| 535 | + * |
| 536 | + * @return boolean Success indicator |
| 537 | + */ |
| 538 | + public function removeInstructors( $sadInstructors, $message = '', $save = true, $log = true ) { |
| 539 | + $removedInstructors = array(); |
| 540 | + $remaimingInstructors = array(); |
| 541 | + $sadInstructors = (array)$sadInstructors; |
| 542 | + |
| 543 | + foreach ( $this->getField( 'instructors' ) as $userId ) { |
| 544 | + if ( in_array( $userId, $sadInstructors ) ) { |
| 545 | + $removedInstructors[] = $userId; |
| 546 | + } |
| 547 | + else { |
| 548 | + $remaimingInstructors[] = $userId; |
| 549 | + } |
| 550 | + } |
| 551 | + |
| 552 | + if ( count( $removedInstructors ) > 0 ) { |
| 553 | + $this->setField( 'instructors', $remaimingInstructors ); |
| 554 | + |
| 555 | + $success = true; |
| 556 | + |
| 557 | + if ( $save ) { |
| 558 | + $this->disableLogging(); |
| 559 | + $success = $this->writeToDB(); |
| 560 | + $this->enableLogging(); |
| 561 | + } |
| 562 | + |
| 563 | + if ( $success && $log ) { |
| 564 | + $this->logInstructorChange( 'remove', $removedInstructors, $message ); |
| 565 | + } |
| 566 | + |
| 567 | + return $success; |
| 568 | + } |
| 569 | + else { |
| 570 | + return true; |
| 571 | + } |
| 572 | + } |
| 573 | + |
| 574 | + /** |
| 575 | + * Log a change of the instructors of the course. |
| 576 | + * |
| 577 | + * @since 0.1 |
| 578 | + * |
| 579 | + * @param string $action |
| 580 | + * @param array $instructors |
| 581 | + * @param string $message |
| 582 | + */ |
| 583 | + protected function logInstructorChange( $action, array $instructors, $message ) { |
| 584 | + $names = array(); |
| 585 | + |
| 586 | + foreach ( $instructors as $userId ) { |
| 587 | + $names[] = EPInstructor::newFromId( $userId )->getName(); |
| 588 | + } |
| 589 | + |
| 590 | + $info = array( |
| 591 | + 'type' => 'instructor', |
| 592 | + 'subtype' => $action, |
| 593 | + 'title' => $this->getTitle(), |
| 594 | + 'parameters' => array( |
| 595 | + '4::instructorcount' => count( $names ), |
| 596 | + '5::instructors' => $GLOBALS['wgLang']->listToText( $names ) |
| 597 | + ), |
| 598 | + ); |
| 599 | + |
| 600 | + if ( $message !== '' ) { |
| 601 | + $info['comment'] = $message; |
| 602 | + } |
| 603 | + |
| 604 | + EPUtils::log( $info ); |
| 605 | + } |
| 606 | + |
470 | 607 | } |
Index: trunk/extensions/EducationProgram/includes/EPPageObject.php |
— | — | @@ -23,15 +23,6 @@ |
24 | 24 | 'edit-right' => 'ep-course', |
25 | 25 | 'identifier' => 'id', |
26 | 26 | ), |
27 | | - 'EPMC' => array( |
28 | | - 'pages' => array( |
29 | | - 'view' => 'MasterCourse', |
30 | | - 'edit' => 'EditMasterCourse', |
31 | | - 'history' => 'MasterCourseHistory', |
32 | | - ), |
33 | | - 'edit-right' => 'ep-mc', |
34 | | - 'identifier' => 'name', |
35 | | - ), |
36 | 27 | 'EPOrg' => array( |
37 | 28 | 'pages' => array( |
38 | 29 | 'view' => 'Institution', |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -233,16 +233,6 @@ |
234 | 234 | 'eporgpager-yes' => 'Yes', |
235 | 235 | 'eporgpager-no' => 'No', |
236 | 236 | |
237 | | - // Master course pager |
238 | | - 'epmcpager-header-name' => 'Name', |
239 | | - 'epmcpager-header-org-id' => 'Institution', |
240 | | - 'epmcpager-filter-org-id' => 'Institution', |
241 | | - 'epmcpager-header-students' => 'Students', |
242 | | - 'epmcpager-header-active' => 'Active', |
243 | | - 'epmcpager-filter-active' => 'Active courses', |
244 | | - 'epmcpager-yes' => 'Yes', |
245 | | - 'epmcpager-no' => 'No', |
246 | | - |
247 | 237 | // Course pager |
248 | 238 | 'epcoursepager-header-id' => 'Id', |
249 | 239 | 'epcoursepager-header-mc-id' => 'Master course', |
Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -65,8 +65,6 @@ |
66 | 66 | |
67 | 67 | $wgAutoloadClasses['EPCourse'] = dirname( __FILE__ ) . '/includes/EPCourse.php'; |
68 | 68 | $wgAutoloadClasses['EPCoursePager'] = dirname( __FILE__ ) . '/includes/EPCoursePager.php'; |
69 | | -$wgAutoloadClasses['EPMC'] = dirname( __FILE__ ) . '/includes/EPMC.php'; |
70 | | -$wgAutoloadClasses['EPMCPager'] = dirname( __FILE__ ) . '/includes/EPMCPager.php'; |
71 | 69 | $wgAutoloadClasses['EPDBObject'] = dirname( __FILE__ ) . '/includes/EPDBObject.php'; |
72 | 70 | $wgAutoloadClasses['EPInstructor'] = dirname( __FILE__ ) . '/includes/EPInstructor.php'; |
73 | 71 | $wgAutoloadClasses['EPLogFormatter'] = dirname( __FILE__ ) . '/includes/EPLogFormatter.php'; |
— | — | @@ -89,7 +87,6 @@ |
90 | 88 | $wgAutoloadClasses['SpecialCourses'] = dirname( __FILE__ ) . '/specials/SpecialCourses.php'; |
91 | 89 | $wgAutoloadClasses['SpecialEditCourse'] = dirname( __FILE__ ) . '/specials/SpecialEditCourse.php'; |
92 | 90 | $wgAutoloadClasses['SpecialEditInstitution'] = dirname( __FILE__ ) . '/specials/SpecialEditInstitution.php'; |
93 | | -$wgAutoloadClasses['SpecialEditMasterCourse'] = dirname( __FILE__ ) . '/specials/SpecialEditMasterCourse.php'; |
94 | 91 | $wgAutoloadClasses['SpecialEducationProgram'] = dirname( __FILE__ ) . '/specials/SpecialEducationProgram.php'; |
95 | 92 | $wgAutoloadClasses['SpecialEPFormPage'] = dirname( __FILE__ ) . '/specials/SpecialEPFormPage.php'; |
96 | 93 | $wgAutoloadClasses['SpecialEPPage'] = dirname( __FILE__ ) . '/specials/SpecialEPPage.php'; |
— | — | @@ -98,8 +95,6 @@ |
99 | 96 | $wgAutoloadClasses['SpecialMyCourses'] = dirname( __FILE__ ) . '/specials/SpecialMyCourses.php'; |
100 | 97 | $wgAutoloadClasses['SpecialStudent'] = dirname( __FILE__ ) . '/specials/SpecialStudent.php'; |
101 | 98 | $wgAutoloadClasses['SpecialStudents'] = dirname( __FILE__ ) . '/specials/SpecialStudents.php'; |
102 | | -$wgAutoloadClasses['SpecialMasterCourse'] = dirname( __FILE__ ) . '/specials/SpecialMasterCourse.php'; |
103 | | -$wgAutoloadClasses['SpecialMasterCourses'] = dirname( __FILE__ ) . '/specials/SpecialMasterCourses.php'; |
104 | 99 | $wgAutoloadClasses['SpecialEnroll'] = dirname( __FILE__ ) . '/specials/SpecialEnroll.php'; |
105 | 100 | $wgAutoloadClasses['SpecialCAs'] = dirname( __FILE__ ) . '/specials/SpecialCAs.php'; |
106 | 101 | $wgAutoloadClasses['SpecialOAs'] = dirname( __FILE__ ) . '/specials/SpecialOAs.php'; |
— | — | @@ -107,7 +102,6 @@ |
108 | 103 | $wgAutoloadClasses['SpecialOA'] = dirname( __FILE__ ) . '/specials/SpecialOA.php'; |
109 | 104 | $wgAutoloadClasses['SpecialEPHistory'] = dirname( __FILE__ ) . '/specials/SpecialEPHistory.php'; |
110 | 105 | $wgAutoloadClasses['SpecialCourseHistory'] = dirname( __FILE__ ) . '/specials/SpecialCourseHistory.php'; |
111 | | -$wgAutoloadClasses['SpecialMasterCourseHistory'] = dirname( __FILE__ ) . '/specials/SpecialMasterCourseHistory.php'; |
112 | 106 | $wgAutoloadClasses['SpecialInstitutionHistory'] = dirname( __FILE__ ) . '/specials/SpecialInstitutionHistory.php'; |
113 | 107 | |
114 | 108 | // Special pages |
— | — | @@ -118,19 +112,15 @@ |
119 | 113 | $wgSpecialPages['Students'] = 'SpecialStudents'; |
120 | 114 | $wgSpecialPages['Course'] = 'SpecialCourse'; |
121 | 115 | $wgSpecialPages['Courses'] = 'SpecialCourses'; |
122 | | -$wgSpecialPages['MasterCourse'] = 'SpecialMasterCourse'; |
123 | | -$wgSpecialPages['MasterCourses'] = 'SpecialMasterCourses'; |
124 | 116 | $wgSpecialPages['EducationProgram'] = 'SpecialEducationProgram'; |
125 | 117 | $wgSpecialPages['EditCourse'] = 'SpecialEditCourse'; |
126 | 118 | $wgSpecialPages['EditInstitution'] = 'SpecialEditInstitution'; |
127 | | -$wgSpecialPages['EditMasterCourse'] = 'SpecialEditMasterCourse'; |
128 | 119 | $wgSpecialPages['Enroll'] = 'SpecialEnroll'; |
129 | 120 | $wgSpecialPages['CampusAmbassadors'] = 'SpecialCAs'; |
130 | 121 | $wgSpecialPages['OnlineAmbassadors'] = 'SpecialOAs'; |
131 | 122 | $wgSpecialPages['CampusAmbassador'] = 'SpecialCA'; |
132 | 123 | $wgSpecialPages['OnlineAmbassador'] = 'SpecialOA'; |
133 | 124 | $wgSpecialPages['CourseHistory'] = 'SpecialCourseHistory'; |
134 | | -$wgSpecialPages['MasterCourseHistory'] = 'SpecialMasterCourseHistory'; |
135 | 125 | $wgSpecialPages['InstitutionHistory'] = 'SpecialInstitutionHistory'; |
136 | 126 | |
137 | 127 | $wgSpecialPageGroups['MyCourses'] = 'education'; |
— | — | @@ -140,25 +130,20 @@ |
141 | 131 | $wgSpecialPageGroups['Students'] = 'education'; |
142 | 132 | $wgSpecialPageGroups['Course'] = 'education'; |
143 | 133 | $wgSpecialPageGroups['Courses'] = 'education'; |
144 | | -$wgSpecialPageGroups['MasterCourse'] = 'education'; |
145 | | -$wgSpecialPageGroups['MasterCourses'] = 'education'; |
146 | 134 | $wgSpecialPageGroups['EducationProgram'] = 'education'; |
147 | 135 | $wgSpecialPageGroups['EditCourse'] = 'education'; |
148 | 136 | $wgSpecialPageGroups['EditInstitution'] = 'education'; |
149 | | -$wgSpecialPageGroups['EditMasterCourse'] = 'education'; |
150 | 137 | $wgSpecialPageGroups['CampusAmbassadors'] = 'education'; |
151 | 138 | $wgSpecialPageGroups['OnlineAmbassadors'] = 'education'; |
152 | 139 | $wgSpecialPageGroups['CampusAmbassador'] = 'education'; |
153 | 140 | $wgSpecialPageGroups['OnlineAmbassador'] = 'education'; |
154 | 141 | $wgSpecialPageGroups['CourseHistory'] = 'education'; |
155 | | -$wgSpecialPageGroups['MasterCourseHistory'] = 'education'; |
156 | 142 | $wgSpecialPageGroups['InstitutionHistory'] = 'education'; |
157 | 143 | |
158 | 144 | // DB object classes |
159 | 145 | $egEPDBObjects = array(); |
160 | 146 | $egEPDBObjects['EPRevision'] = array( 'table' => 'ep_revisions', 'prefix' => 'rev_' ); |
161 | 147 | $egEPDBObjects['EPOrg'] = array( 'table' => 'ep_orgs', 'prefix' => 'org_' ); |
162 | | -$egEPDBObjects['EPMC'] = array( 'table' => 'ep_mcs', 'prefix' => 'mc_' ); |
163 | 148 | $egEPDBObjects['EPCourse'] = array( 'table' => 'ep_courses', 'prefix' => 'course_' ); |
164 | 149 | $egEPDBObjects['EPStudent'] = array( 'table' => 'ep_students', 'prefix' => 'student_' ); |
165 | 150 | $egEPDBObjects['EPOA'] = array( 'table' => 'ep_oas', 'prefix' => 'oa_' ); |
— | — | @@ -180,7 +165,6 @@ |
181 | 166 | // Logging |
182 | 167 | $wgLogTypes[] = 'institution'; |
183 | 168 | $wgLogTypes[] = 'course'; |
184 | | -$wgLogTypes[] = 'mc'; |
185 | 169 | $wgLogTypes[] = 'student'; |
186 | 170 | $wgLogTypes[] = 'ambassador'; |
187 | 171 | $wgLogTypes[] = 'instructor'; |
— | — | @@ -188,14 +172,13 @@ |
189 | 173 | if ( array_key_exists( 'LogFormatter', $wgAutoloadLocalClasses ) ) { |
190 | 174 | $wgLogActionsHandlers['institution/*'] = 'EPLogFormatter'; |
191 | 175 | $wgLogActionsHandlers['course/*'] = 'EPLogFormatter'; |
192 | | - $wgLogActionsHandlers['mc/*'] = 'EPLogFormatter'; |
193 | 176 | $wgLogActionsHandlers['student/*'] = 'EPLogFormatter'; |
194 | 177 | $wgLogActionsHandlers['ambassador/*'] = 'EPLogFormatter'; |
195 | 178 | $wgLogActionsHandlers['instructor/*'] = 'EPLogFormatter'; |
196 | 179 | } |
197 | 180 | else { |
198 | 181 | // Compatibility with MediaWiki 1.18. |
199 | | - foreach ( array( 'institution', 'course', 'mc' ) as $type ) { |
| 182 | + foreach ( array( 'institution', 'course' ) as $type ) { |
200 | 183 | foreach ( array( 'add', 'remove', 'update' ) as $action ) { |
201 | 184 | $wgLogActionsHandlers[$type . '/' . $action] = 'EPHooks::formatLogEntry'; |
202 | 185 | } |
— | — | @@ -213,7 +196,6 @@ |
214 | 197 | // Compatibility with MediaWiki 1.18. |
215 | 198 | $wgLogNames['institution'] = 'log-name-institution'; |
216 | 199 | $wgLogNames['course'] = 'log-name-course'; |
217 | | - $wgLogNames['mc'] = 'log-name-mc'; |
218 | 200 | $wgLogNames['student'] = 'log-name-student'; |
219 | 201 | $wgLogNames['ambassador'] = 'log-name-ambassador'; |
220 | 202 | $wgLogNames['instructor'] = 'log-name-instructor'; |
— | — | @@ -221,7 +203,6 @@ |
222 | 204 | // Compatibility with MediaWiki 1.18. |
223 | 205 | $wgLogHeaders['institution'] = 'log-header-institution'; |
224 | 206 | $wgLogHeaders['course'] = 'log-header-course'; |
225 | | - $wgLogHeaders['mc'] = 'log-header-mc'; |
226 | 207 | $wgLogHeaders['student'] = 'log-header-student'; |
227 | 208 | $wgLogHeaders['ambassador'] = 'log-header-ambassador'; |
228 | 209 | $wgLogHeaders['instructor'] = 'log-header-instructor'; |
— | — | @@ -230,7 +211,6 @@ |
231 | 212 | // Rights |
232 | 213 | $wgAvailableRights[] = 'ep-org'; // Manage orgs |
233 | 214 | $wgAvailableRights[] = 'ep-course'; // Manage courses |
234 | | -$wgAvailableRights[] = 'ep-mc'; // Manage master courses |
235 | 215 | $wgAvailableRights[] = 'ep-token'; // See enrollment tokens |
236 | 216 | $wgAvailableRights[] = 'ep-enroll'; // Enroll as a student |
237 | 217 | $wgAvailableRights[] = 'ep-remstudent'; // Disassociate students from terms |
— | — | @@ -245,7 +225,6 @@ |
246 | 226 | $wgGroupPermissions['*']['ep-enroll'] = true; |
247 | 227 | $wgGroupPermissions['*']['ep-org'] = false; |
248 | 228 | $wgGroupPermissions['*']['ep-course'] = false; |
249 | | -$wgGroupPermissions['*']['ep-mc'] = false; |
250 | 229 | $wgGroupPermissions['*']['ep-token'] = false; |
251 | 230 | $wgGroupPermissions['*']['ep-remstudent'] = false; |
252 | 231 | $wgGroupPermissions['*']['ep-online'] = false; |
— | — | @@ -257,7 +236,6 @@ |
258 | 237 | |
259 | 238 | $wgGroupPermissions['epstaff']['ep-org'] = true; |
260 | 239 | $wgGroupPermissions['epstaff']['ep-course'] = true; |
261 | | -$wgGroupPermissions['epstaff']['ep-mc'] = true; |
262 | 240 | $wgGroupPermissions['epstaff']['ep-token'] = true; |
263 | 241 | $wgGroupPermissions['epstaff']['ep-enroll'] = true; |
264 | 242 | $wgGroupPermissions['epstaff']['ep-remstudent'] = true; |
— | — | @@ -270,7 +248,6 @@ |
271 | 249 | |
272 | 250 | $wgGroupPermissions['epadmin']['ep-org'] = true; |
273 | 251 | $wgGroupPermissions['epadmin']['ep-course'] = true; |
274 | | -$wgGroupPermissions['epadmin']['ep-mc'] = true; |
275 | 252 | $wgGroupPermissions['epadmin']['ep-token'] = true; |
276 | 253 | $wgGroupPermissions['epadmin']['ep-enroll'] = true; |
277 | 254 | $wgGroupPermissions['epadmin']['ep-remstudent'] = true; |
— | — | @@ -283,13 +260,11 @@ |
284 | 261 | |
285 | 262 | $wgGroupPermissions['eponlineamb']['ep-org'] = true; |
286 | 263 | $wgGroupPermissions['eponlineamb']['ep-course'] = true; |
287 | | -$wgGroupPermissions['eponlineamb']['ep-mc'] = true; |
288 | 264 | $wgGroupPermissions['eponlineamb']['ep-token'] = true; |
289 | 265 | $wgGroupPermissions['eponlineamb']['ep-beonline'] = true; |
290 | 266 | |
291 | 267 | $wgGroupPermissions['epcampamb']['ep-org'] = true; |
292 | 268 | $wgGroupPermissions['epcampamb']['ep-course'] = true; |
293 | | -$wgGroupPermissions['epcampamb']['ep-mc'] = true; |
294 | 269 | $wgGroupPermissions['epcampamb']['ep-token'] = true; |
295 | 270 | $wgGroupPermissions['epcampamb']['ep-becampus'] = true; |
296 | 271 | |
Index: trunk/extensions/EducationProgram/api/ApiRefreshEducation.php |
— | — | @@ -24,7 +24,6 @@ |
25 | 25 | protected static $typeMap = array( |
26 | 26 | 'org' => 'EPOrg', |
27 | 27 | 'course' => 'EPCourse', |
28 | | - 'mc' => 'EPMC', |
29 | 28 | ); |
30 | 29 | |
31 | 30 | public function execute() { |
Index: trunk/extensions/EducationProgram/api/ApiInstructor.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | $this->dieUsageMsg( array( 'badaccess-groups' ) ); |
39 | 39 | } |
40 | 40 | |
41 | | - $masterCourse = EPMC::selectRow( array( 'id', 'name', 'instructors' ), array( 'id' => $params['mcid'] ) ); |
| 41 | + $masterCourse = EPCourse::selectRow( array( 'id', 'name', 'instructors' ), array( 'id' => $params['mcid'] ) ); |
42 | 42 | |
43 | 43 | if ( $masterCourse === false ) { |
44 | 44 | $this->dieUsage( wfMsg( 'ep-addinstructor-invalid-course' ), 'invalid-course' ); |
Index: trunk/extensions/EducationProgram/api/ApiDeleteEducation.php |
— | — | @@ -24,7 +24,6 @@ |
25 | 25 | protected static $typeMap = array( |
26 | 26 | 'org' => 'EPOrg', |
27 | 27 | 'course' => 'EPCourse', |
28 | | - 'mc' => 'EPMC', |
29 | 28 | ); |
30 | 29 | |
31 | 30 | /** |
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -29,22 +29,14 @@ |
30 | 30 | dirname( __FILE__ ) . '/sql/EducationProgram.sql' |
31 | 31 | ); |
32 | 32 | |
33 | | - $updater->addExtensionUpdate( array( |
34 | | - 'addField', |
35 | | - 'ep_courses', |
36 | | - 'course_name', |
37 | | - dirname( __FILE__ ) . '/sql/AddExtraFields.sql', |
38 | | - true |
39 | | - ) ); |
| 33 | +// $updater->addExtensionUpdate( array( |
| 34 | +// 'addField', |
| 35 | +// 'ep_courses', |
| 36 | +// 'course_name', |
| 37 | +// dirname( __FILE__ ) . '/sql/AddExtraFields.sql', |
| 38 | +// true |
| 39 | +// ) ); |
40 | 40 | |
41 | | - $updater->addExtensionUpdate( array( |
42 | | - 'addField', |
43 | | - 'ep_revisions', |
44 | | - 'rev_object_id', |
45 | | - dirname( __FILE__ ) . '/sql/AddRevisionObjectId.sql', |
46 | | - true |
47 | | - ) ); |
48 | | - |
49 | 41 | return true; |
50 | 42 | } |
51 | 43 | |
— | — | @@ -180,11 +172,6 @@ |
181 | 173 | 'history' => 'InstitutionHistory', |
182 | 174 | ), |
183 | 175 | array( |
184 | | - 'view' => 'MasterCourse', |
185 | | - 'edit' => 'EditMasterCourse', |
186 | | - 'history' => 'MasterCourseHistory', |
187 | | - ), |
188 | | - array( |
189 | 176 | 'view' => 'Course', |
190 | 177 | 'edit' => 'EditCourse', |
191 | 178 | 'history' => 'CourseHistory', |
— | — | @@ -194,14 +181,12 @@ |
195 | 182 | |
196 | 183 | $editRights = array( |
197 | 184 | 'EditInstitution' => 'ep-org', |
198 | | - 'EditMasterCourse' => 'ep-mc', |
199 | 185 | 'EditCourse' => 'ep-course', |
200 | 186 | ); |
201 | 187 | |
202 | 188 | $classes = array( |
203 | 189 | 'Institution' => 'EPOrg', |
204 | 190 | 'Course' => 'EPCourse', |
205 | | - 'MasterCourse' => 'EPMC', |
206 | 191 | ); |
207 | 192 | |
208 | 193 | $specialSet = false; |