r109985 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109984‎ | r109985 | r109986 >
Date:02:22, 25 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
merge master courses with courses
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.hooks.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.alias.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/api/ApiDeleteEducation.php (modified) (history)
  • /trunk/extensions/EducationProgram/api/ApiInstructor.php (modified) (history)
  • /trunk/extensions/EducationProgram/api/ApiRefreshEducation.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCoursePager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPInstructor.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPMC.php (deleted) (history)
  • /trunk/extensions/EducationProgram/includes/EPMCPager.php (deleted) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPPageObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudent.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEditCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEditMasterCourse.php (deleted) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialInstitution.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialInstitutionHistory.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMasterCourse.php (deleted) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMasterCourseHistory.php (deleted) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMasterCourses.php (deleted) (history)
  • /trunk/extensions/EducationProgram/sql/AddExtraFields.sql (deleted) (history)
  • /trunk/extensions/EducationProgram/sql/AddRevisionObjectId.sql (deleted) (history)
  • /trunk/extensions/EducationProgram/sql/EducationProgram.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.i18n.alias.php
@@ -23,19 +23,15 @@
2424 'Students' => array( 'Students' ),
2525 'Course' => array( 'Course' ),
2626 'Courses' => array( 'Courses' ),
27 - 'MasterCourse' => array( 'MasterCourse' ),
28 - 'MasterCourses' => array( 'MasterCourses' ),
2927 'EducationProgram' => array( 'EducationProgram' ),
3028 'EditCourse' => array( 'EditCourse' ),
3129 'EditInstitution' => array( 'EditInstitution' ),
32 - 'EditMasterCourse' => array( 'EditMasterCourse' ),
3330 'Enroll' => array( 'Enroll' ),
3431 'CampusAmbassadors' => array( 'CampusAmbassadors' ),
3532 'OnlineAmbassadors' => array( 'OnlineAmbassadors' ),
3633 'CampusAmbassador' => array( 'CampusAmbassador' ),
3734 'OnlineAmbassador' => array( 'OnlineAmbassador' ),
3835 'CourseHistory' => array( 'CourseHistory' ),
39 - 'MasterCourseHistory' => array( 'MasterCourseHistory' ),
4036 'InstitutionHistory' => array( 'InstitutionHistory' ),
4137 );
4238
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 @@
1313
1414 org_active TINYINT unsigned NOT NULL, -- If the org has any active courses
1515 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
1719 org_students INT unsigned NOT NULL -- Amount of students
1820 ) /*$wgDBTableOptions*/;
1921
2022 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);
2226 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);
2329 CREATE INDEX /*i*/ep_org_students ON /*_*/ep_orgs (org_students);
24 -CREATE INDEX /*i*/ep_org_active ON /*_*/ep_orgs (org_active);
2530
2631
2732
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 -
5033 -- Courses. These are "instances" of a master course in a certain period.
5134 CREATE TABLE IF NOT EXISTS /*_*/ep_courses (
5235 course_id INT unsigned NOT NULL auto_increment PRIMARY KEY,
5336
54 - course_mc_id INT unsigned NOT NULL, -- Foreign key on ep_mcs.mc_id
5537 course_org_id INT unsigned NOT NULL, -- Foreign key on ep_orgs.org_id. Helper field, not strictly needed.
5638 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
5840 course_start varbinary(14) NOT NULL, -- Start time of the course
5941 course_end varbinary(14) NOT NULL, -- End time of the course
6042 course_description TEXT NOT NULL, -- Description of the course
61 - course_timeline TEXT NOT NULL, -- Timeline for the course
6243 course_online_ambs BLOB NOT NULL, -- List of associated online ambassadors (linking ep_oas.oa_id)
6344 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)
6446 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+
6652 course_students SMALLINT unsigned NOT NULL -- Amount of students
6753 ) /*$wgDBTableOptions*/;
6854
 55+CREATE INDEX /*i*/ep_course_org_id ON /*_*/ep_courses (course_org_id);
6956 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);
7158 CREATE INDEX /*i*/ep_course_start ON /*_*/ep_courses (course_start);
7259 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);
7465 CREATE INDEX /*i*/ep_course_students ON /*_*/ep_courses (course_students);
7566
7667
@@ -91,6 +81,8 @@
9282 CREATE INDEX /*i*/ep_articles_page_id ON /*_*/ep_articles (article_page_id);
9383 CREATE UNIQUE INDEX /*i*/ep_articles_course_page ON /*_*/ep_articles (article_course_id, article_page_id);
9484
 85+
 86+
9587 -- Students. In essence this is an extension to the user table.
9688 CREATE TABLE IF NOT EXISTS /*_*/ep_students (
9789 student_id INT unsigned NOT NULL auto_increment PRIMARY KEY,
@@ -107,6 +99,8 @@
108100 CREATE INDEX /*i*/ep_students_last_active ON /*_*/ep_students (student_last_active);
109101 CREATE INDEX /*i*/ep_students_active_enroll ON /*_*/ep_students (student_active_enroll);
110102
 103+
 104+
111105 -- Links the students with their courses.
112106 CREATE TABLE IF NOT EXISTS /*_*/ep_students_per_course (
113107 spc_student_id INT unsigned NOT NULL, -- Foreign key on ep_students.student_id
@@ -138,6 +132,8 @@
139133
140134 CREATE UNIQUE INDEX /*i*/ep_cas_user_id ON /*_*/ep_cas (ca_user_id);
141135
 136+
 137+
142138 -- Links the campus ambassadors with all their orgs.
143139 CREATE TABLE IF NOT EXISTS /*_*/ep_cas_per_org (
144140 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 @@
6262
6363 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-institution-mcs' ) ) );
6464
65 - EPMC::displayPager( $this->getContext(), array( 'org_id' => $org->getId() ) );
 65+ EPCourse::displayPager( $this->getContext(), array( 'org_id' => $org->getId() ) );
6666
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' ) ) );
6969
70 - EPMC::displayAddNewControl( $this->getContext(), array( 'org' => $org->getId() ) );
 70+ EPCourse::displayAddNewControl( $this->getContext(), array( 'org' => $org->getId() ) );
7171 }
7272 }
7373 }
Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php
@@ -100,13 +100,6 @@
101101 htmlspecialchars( $org )
102102 );
103103
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 -
111104 $lang = $this->getLanguage();
112105
113106 $stats['year'] = htmlspecialchars( $lang->formatNum( $course->getField( 'year' ), true ) );
Index: trunk/extensions/EducationProgram/specials/SpecialEditCourse.php
@@ -32,15 +32,15 @@
3333 protected function getFormFields() {
3434 $fields = parent::getFormFields();
3535
36 - $courseOptions = EPMC::getMasterCourseOptions();
 36+ $orgOptions = EPOrg::getOrgOptions();
3737
3838 $fields['mc_id'] = array (
3939 'type' => 'select',
4040 'label-message' => 'ep-course-edit-mastercourse',
4141 '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' );
4545 },
4646 );
4747
Index: trunk/extensions/EducationProgram/specials/SpecialInstitutionHistory.php
@@ -19,7 +19,7 @@
2020 * @since 0.1
2121 */
2222 public function __construct() {
23 - parent::__construct( 'InstitutionHistory', 'EPMC', 'name', 'Institution' );
 23+ parent::__construct( 'InstitutionHistory', 'EPOrg', 'name', 'Institution' );
2424 }
2525
2626 }
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( '&#160;' );
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( '&#160;' );
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( '&#160;' );
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 @@
122122 * @since 0.1
123123 *
124124 * @param IContextSource $context
125 - * @param EPMC|null $course
 125+ * @param EPCourse|null $course
126126 *
127127 * @return string
128128 */
129 - public function getToolLinks( IContextSource $context, EPMC $masterCourse = null ) {
 129+ public function getToolLinks( IContextSource $context, EPCourse $course = null ) {
130130 $links = array();
131131
132132 $links[] = Linker::userTalkLink( $this->getUser()->getId(), $this->getUser()->getName() );
133133
134134 $links[] = Linker::link( SpecialPage::getTitleFor( 'Contributions', $this->getUser()->getName() ), wfMsgHtml( 'contribslink' ) );
135135
136 - if ( !is_null( $masterCourse ) &&
 136+ if ( !is_null( $course ) &&
137137 ( $context->getUser()->isAllowed( 'ep-instructor' ) || $this->getUser()->getId() == $context->getUser()->getId() ) ) {
138138 $links[] = Html::element(
139139 'a',
140140 array(
141141 'href' => '#',
142142 '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' ),
145145 'data-userid' => $this->getUser()->getId(),
146146 'data-username' => $this->getUser()->getName(),
147147 'data-bestname' => $this->getName(),
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php
@@ -30,7 +30,7 @@
3131 public function getFields() {
3232 return array(
3333 'id',
34 - 'mc_id',
 34+ 'org_id',
3535 'year',
3636 'start',
3737 'end',
@@ -66,11 +66,11 @@
6767 htmlspecialchars( $this->getLanguage()->formatNum( $value, true ) )
6868 );
6969 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' );
7272
7373 $value = Linker::linkKnown(
74 - SpecialPage::getTitleFor( 'MasterCourse', $value ),
 74+ SpecialPage::getTitleFor( 'Institution', $value ),
7575 htmlspecialchars( $value )
7676 );
7777 break;
@@ -127,28 +127,16 @@
128128 protected function getFilterOptions() {
129129 $options = array();
130130
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+ );
141140
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 -
153141 $years = EPCourse::selectFields( 'year', array(), array( 'DISTINCT' ), array(), true );
154142 asort( $years, SORT_NUMERIC );
155143 $years = array_merge( array( '' ), $years );
Index: trunk/extensions/EducationProgram/includes/EPStudent.php
@@ -91,7 +91,6 @@
9292 $dbw->commit();
9393
9494 foreach ( $courses as /* EPCourse */ $course ) {
95 - EPMC::updateSummaryFields( 'students', array( 'id' => $course->getField( 'mc_id' ) ) );
9695 EPOrg::updateSummaryFields( 'students', array( 'id' => $course->getField( 'org_id' ) ) );
9796 EPCourse::updateSummaryFields( 'students', array( 'id' => $course->getId() ) );
9897 }
@@ -161,66 +160,6 @@
162161 }
163162
164163 /**
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 - /**
225164 * Returns the courses this student is enrolled in.
226165 *
227166 * @since 0.1
Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -14,14 +14,6 @@
1515 class EPOrg extends EPPageObject {
1616
1717 /**
18 - * Cached array of the linked EPMC objects.
19 - *
20 - * @since 0.1
21 - * @var array|false
22 - */
23 - protected $mcs = false;
24 -
25 - /**
2618 * Cached array of the linked EPCourse objects.
2719 *
2820 * @since 0.1
@@ -46,8 +38,10 @@
4739
4840 'active' => 'bool',
4941 'courses' => 'int',
50 - 'mcs' => 'int',
5142 'students' => 'int',
 43+ 'instructors' => 'int',
 44+ 'campus_ambs' => 'int',
 45+ 'online_ambs' => 'int',
5246 );
5347 }
5448
@@ -63,8 +57,10 @@
6458
6559 'active' => false,
6660 'courses' => 0,
67 - 'mcs' => 0,
6861 'students' => 0,
 62+ 'instructors' => 0,
 63+ 'campus_ambs' => 0,
 64+ 'online_ambs' => 0,
6965 );
7066 }
7167
@@ -97,10 +93,6 @@
9894 $fields['courses'] = EPCourse::count( array( 'org_id' => $this->getId() ) );
9995 }
10096
101 - if ( in_array( 'mcs', $summaryFields ) ) {
102 - $fields['mcs'] = EPMC::count( array( 'org_id' => $this->getId() ) );
103 - }
104 -
10597 $dbr = wfGetDB( DB_SLAVE );
10698
10799 if ( in_array( 'students', $summaryFields ) ) {
@@ -146,8 +138,8 @@
147139 if ( $success ) {
148140 $success = wfGetDB( DB_MASTER )->delete( 'ep_cas_per_org', array( 'cpo_org_id' => $id ) ) && $success;
149141
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;
152144 }
153145 }
154146
@@ -257,23 +249,6 @@
258250 }
259251
260252 /**
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 - /**
278253 * Retruns the courses linked to this org.
279254 *
280255 * @since 0.1
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -14,14 +14,6 @@
1515 class EPCourse extends EPPageObject {
1616
1717 /**
18 - * Field for caching the linked master course.
19 - *
20 - * @since 0.1
21 - * @var EPMC|false
22 - */
23 - protected $mc = false;
24 -
25 - /**
2618 * Field for caching the linked org.
2719 *
2820 * @since 0.1
@@ -38,6 +30,14 @@
3931 protected $students = false;
4032
4133 /**
 34+ * Field for caching the instructors.
 35+ *
 36+ * @since 0.1
 37+ * @var {array of EPInstructor}|false
 38+ */
 39+ protected $instructors = false;
 40+
 41+ /**
4242 * Returns a list of statuses a term can have.
4343 * Keys are messages, values are identifiers.
4444 *
@@ -82,18 +82,20 @@
8383 protected static function getFieldTypes() {
8484 return array(
8585 'id' => 'id',
86 - 'mc_id' => 'id',
8786 'org_id' => 'id',
8887
8988 'name' => 'str',
90 - 'year' => 'int',
9189 'start' => 'str', // TS_MW
9290 'end' => 'str', // TS_MW
9391 'description' => 'str',
94 - 'timeline' => 'str',
9592 'token' => 'str',
9693 'online_ambs' => 'array',
9794 'campus_ambs' => 'array',
 95+ 'field' => 'str',
 96+ 'level' => 'str',
 97+ 'term' => 'str',
 98+ 'lang' => 'str',
 99+ 'mc' => 'str',
98100
99101 'students' => 'int',
100102 );
@@ -106,15 +108,18 @@
107109 public static function getDefaults() {
108110 return array(
109111 'name' => '',
110 - 'year' => substr( wfTimestamp( TS_MW ), 0, 4 ),
111112 'start' => wfTimestamp( TS_MW ),
112113 'end' => wfTimestamp( TS_MW ),
113114 'description' => '',
114 - 'timeline' => '',
115115 'token' => '',
116116 'online_ambs' => array(),
117117 'campus_ambs' => array(),
118 -
 118+ 'field' => '',
 119+ 'level' => '',
 120+ 'term' => '',
 121+ 'lang' => '',
 122+ 'mc' => '',
 123+
119124 'students' => 0,
120125 );
121126 }
@@ -217,7 +222,6 @@
218223
219224 if ( $success && $this->updateSummaries ) {
220225 EPOrg::updateSummaryFields( array( 'courses', 'active' ), array( 'id' => $this->getField( 'org_id' ) ) );
221 - EPMC::updateSummaryFields( 'active', array( 'id' => $this->getField( 'mc_id' ) ) );
222226 }
223227
224228 return $success;
@@ -239,7 +243,6 @@
240244 $success = parent::removeFromDB();
241245
242246 if ( $success && $this->updateSummaries ) {
243 - EPMC::updateSummaryFields( 'students', array( 'id' => $courseId ) );
244247 EPOrg::updateSummaryFields( array( 'courses', 'students', 'active' ), array( 'id' => $orgId ) );
245248 }
246249
@@ -257,17 +260,8 @@
258261 protected function updateInDB() {
259262 if ( $this->updateSummaries ) {
260263 $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;
262264 }
263265
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 -
272266 $success = parent::updateInDB();
273267
274268 if ( $this->updateSummaries && $success ) {
@@ -275,34 +269,12 @@
276270 $conds = array( 'id' => array( $oldOrgId, $this->getField( 'org_id' ) ) );
277271 EPOrg::updateSummaryFields( array( 'courses', 'students', 'active' ), $conds );
278272 }
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 - }
284273 }
285274
286275 return $success;
287276 }
288277
289278 /**
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 - /**
307279 * Returns the org associated with this term.
308280 *
309281 * @since 0.1
@@ -380,12 +352,12 @@
381353 $out->addHTML( Html::element( 'label', array( 'for' => 'newmc' ), wfMsg( 'ep-courses-newmastercourse' ) ) );
382354
383355 $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
387359 );
388360
389 - $select->addOptions( EPMC::getMasterCourseOptions() );
 361+ $select->addOptions( EPOrg::getOrgOptions() );
390362 $out->addHTML( $select->getHTML() );
391363
392364 $out->addHTML( '&#160;' . Xml::inputLabel( wfMsg( 'ep-courses-newyear' ), 'newyear', 'newyear', 10 ) );
@@ -413,11 +385,11 @@
414386 * @param array $args
415387 */
416388 public static function displayAddNewRegion( IContextSource $context, array $args = array() ) {
417 - if ( EPMC::has() ) {
 389+ if ( EPOrg::has() ) {
418390 EPCourse::displayAddNewControl( $context, $args );
419391 }
420392 elseif ( $context->getUser()->isAllowed( 'ep-course' ) ) {
421 - $context->getOutput()->addWikiMsg( 'ep-courses-addmastercoursefirst' );
 393+ $context->getOutput()->addWikiMsg( 'ep-courses-addorgfirst' );
422394 }
423395 }
424396
@@ -466,4 +438,169 @@
467439 return $status;
468440 }
469441
 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+
470607 }
Index: trunk/extensions/EducationProgram/includes/EPPageObject.php
@@ -23,15 +23,6 @@
2424 'edit-right' => 'ep-course',
2525 'identifier' => 'id',
2626 ),
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 - ),
3627 'EPOrg' => array(
3728 'pages' => array(
3829 'view' => 'Institution',
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -233,16 +233,6 @@
234234 'eporgpager-yes' => 'Yes',
235235 'eporgpager-no' => 'No',
236236
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 -
247237 // Course pager
248238 'epcoursepager-header-id' => 'Id',
249239 'epcoursepager-header-mc-id' => 'Master course',
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -65,8 +65,6 @@
6666
6767 $wgAutoloadClasses['EPCourse'] = dirname( __FILE__ ) . '/includes/EPCourse.php';
6868 $wgAutoloadClasses['EPCoursePager'] = dirname( __FILE__ ) . '/includes/EPCoursePager.php';
69 -$wgAutoloadClasses['EPMC'] = dirname( __FILE__ ) . '/includes/EPMC.php';
70 -$wgAutoloadClasses['EPMCPager'] = dirname( __FILE__ ) . '/includes/EPMCPager.php';
7169 $wgAutoloadClasses['EPDBObject'] = dirname( __FILE__ ) . '/includes/EPDBObject.php';
7270 $wgAutoloadClasses['EPInstructor'] = dirname( __FILE__ ) . '/includes/EPInstructor.php';
7371 $wgAutoloadClasses['EPLogFormatter'] = dirname( __FILE__ ) . '/includes/EPLogFormatter.php';
@@ -89,7 +87,6 @@
9088 $wgAutoloadClasses['SpecialCourses'] = dirname( __FILE__ ) . '/specials/SpecialCourses.php';
9189 $wgAutoloadClasses['SpecialEditCourse'] = dirname( __FILE__ ) . '/specials/SpecialEditCourse.php';
9290 $wgAutoloadClasses['SpecialEditInstitution'] = dirname( __FILE__ ) . '/specials/SpecialEditInstitution.php';
93 -$wgAutoloadClasses['SpecialEditMasterCourse'] = dirname( __FILE__ ) . '/specials/SpecialEditMasterCourse.php';
9491 $wgAutoloadClasses['SpecialEducationProgram'] = dirname( __FILE__ ) . '/specials/SpecialEducationProgram.php';
9592 $wgAutoloadClasses['SpecialEPFormPage'] = dirname( __FILE__ ) . '/specials/SpecialEPFormPage.php';
9693 $wgAutoloadClasses['SpecialEPPage'] = dirname( __FILE__ ) . '/specials/SpecialEPPage.php';
@@ -98,8 +95,6 @@
9996 $wgAutoloadClasses['SpecialMyCourses'] = dirname( __FILE__ ) . '/specials/SpecialMyCourses.php';
10097 $wgAutoloadClasses['SpecialStudent'] = dirname( __FILE__ ) . '/specials/SpecialStudent.php';
10198 $wgAutoloadClasses['SpecialStudents'] = dirname( __FILE__ ) . '/specials/SpecialStudents.php';
102 -$wgAutoloadClasses['SpecialMasterCourse'] = dirname( __FILE__ ) . '/specials/SpecialMasterCourse.php';
103 -$wgAutoloadClasses['SpecialMasterCourses'] = dirname( __FILE__ ) . '/specials/SpecialMasterCourses.php';
10499 $wgAutoloadClasses['SpecialEnroll'] = dirname( __FILE__ ) . '/specials/SpecialEnroll.php';
105100 $wgAutoloadClasses['SpecialCAs'] = dirname( __FILE__ ) . '/specials/SpecialCAs.php';
106101 $wgAutoloadClasses['SpecialOAs'] = dirname( __FILE__ ) . '/specials/SpecialOAs.php';
@@ -107,7 +102,6 @@
108103 $wgAutoloadClasses['SpecialOA'] = dirname( __FILE__ ) . '/specials/SpecialOA.php';
109104 $wgAutoloadClasses['SpecialEPHistory'] = dirname( __FILE__ ) . '/specials/SpecialEPHistory.php';
110105 $wgAutoloadClasses['SpecialCourseHistory'] = dirname( __FILE__ ) . '/specials/SpecialCourseHistory.php';
111 -$wgAutoloadClasses['SpecialMasterCourseHistory'] = dirname( __FILE__ ) . '/specials/SpecialMasterCourseHistory.php';
112106 $wgAutoloadClasses['SpecialInstitutionHistory'] = dirname( __FILE__ ) . '/specials/SpecialInstitutionHistory.php';
113107
114108 // Special pages
@@ -118,19 +112,15 @@
119113 $wgSpecialPages['Students'] = 'SpecialStudents';
120114 $wgSpecialPages['Course'] = 'SpecialCourse';
121115 $wgSpecialPages['Courses'] = 'SpecialCourses';
122 -$wgSpecialPages['MasterCourse'] = 'SpecialMasterCourse';
123 -$wgSpecialPages['MasterCourses'] = 'SpecialMasterCourses';
124116 $wgSpecialPages['EducationProgram'] = 'SpecialEducationProgram';
125117 $wgSpecialPages['EditCourse'] = 'SpecialEditCourse';
126118 $wgSpecialPages['EditInstitution'] = 'SpecialEditInstitution';
127 -$wgSpecialPages['EditMasterCourse'] = 'SpecialEditMasterCourse';
128119 $wgSpecialPages['Enroll'] = 'SpecialEnroll';
129120 $wgSpecialPages['CampusAmbassadors'] = 'SpecialCAs';
130121 $wgSpecialPages['OnlineAmbassadors'] = 'SpecialOAs';
131122 $wgSpecialPages['CampusAmbassador'] = 'SpecialCA';
132123 $wgSpecialPages['OnlineAmbassador'] = 'SpecialOA';
133124 $wgSpecialPages['CourseHistory'] = 'SpecialCourseHistory';
134 -$wgSpecialPages['MasterCourseHistory'] = 'SpecialMasterCourseHistory';
135125 $wgSpecialPages['InstitutionHistory'] = 'SpecialInstitutionHistory';
136126
137127 $wgSpecialPageGroups['MyCourses'] = 'education';
@@ -140,25 +130,20 @@
141131 $wgSpecialPageGroups['Students'] = 'education';
142132 $wgSpecialPageGroups['Course'] = 'education';
143133 $wgSpecialPageGroups['Courses'] = 'education';
144 -$wgSpecialPageGroups['MasterCourse'] = 'education';
145 -$wgSpecialPageGroups['MasterCourses'] = 'education';
146134 $wgSpecialPageGroups['EducationProgram'] = 'education';
147135 $wgSpecialPageGroups['EditCourse'] = 'education';
148136 $wgSpecialPageGroups['EditInstitution'] = 'education';
149 -$wgSpecialPageGroups['EditMasterCourse'] = 'education';
150137 $wgSpecialPageGroups['CampusAmbassadors'] = 'education';
151138 $wgSpecialPageGroups['OnlineAmbassadors'] = 'education';
152139 $wgSpecialPageGroups['CampusAmbassador'] = 'education';
153140 $wgSpecialPageGroups['OnlineAmbassador'] = 'education';
154141 $wgSpecialPageGroups['CourseHistory'] = 'education';
155 -$wgSpecialPageGroups['MasterCourseHistory'] = 'education';
156142 $wgSpecialPageGroups['InstitutionHistory'] = 'education';
157143
158144 // DB object classes
159145 $egEPDBObjects = array();
160146 $egEPDBObjects['EPRevision'] = array( 'table' => 'ep_revisions', 'prefix' => 'rev_' );
161147 $egEPDBObjects['EPOrg'] = array( 'table' => 'ep_orgs', 'prefix' => 'org_' );
162 -$egEPDBObjects['EPMC'] = array( 'table' => 'ep_mcs', 'prefix' => 'mc_' );
163148 $egEPDBObjects['EPCourse'] = array( 'table' => 'ep_courses', 'prefix' => 'course_' );
164149 $egEPDBObjects['EPStudent'] = array( 'table' => 'ep_students', 'prefix' => 'student_' );
165150 $egEPDBObjects['EPOA'] = array( 'table' => 'ep_oas', 'prefix' => 'oa_' );
@@ -180,7 +165,6 @@
181166 // Logging
182167 $wgLogTypes[] = 'institution';
183168 $wgLogTypes[] = 'course';
184 -$wgLogTypes[] = 'mc';
185169 $wgLogTypes[] = 'student';
186170 $wgLogTypes[] = 'ambassador';
187171 $wgLogTypes[] = 'instructor';
@@ -188,14 +172,13 @@
189173 if ( array_key_exists( 'LogFormatter', $wgAutoloadLocalClasses ) ) {
190174 $wgLogActionsHandlers['institution/*'] = 'EPLogFormatter';
191175 $wgLogActionsHandlers['course/*'] = 'EPLogFormatter';
192 - $wgLogActionsHandlers['mc/*'] = 'EPLogFormatter';
193176 $wgLogActionsHandlers['student/*'] = 'EPLogFormatter';
194177 $wgLogActionsHandlers['ambassador/*'] = 'EPLogFormatter';
195178 $wgLogActionsHandlers['instructor/*'] = 'EPLogFormatter';
196179 }
197180 else {
198181 // Compatibility with MediaWiki 1.18.
199 - foreach ( array( 'institution', 'course', 'mc' ) as $type ) {
 182+ foreach ( array( 'institution', 'course' ) as $type ) {
200183 foreach ( array( 'add', 'remove', 'update' ) as $action ) {
201184 $wgLogActionsHandlers[$type . '/' . $action] = 'EPHooks::formatLogEntry';
202185 }
@@ -213,7 +196,6 @@
214197 // Compatibility with MediaWiki 1.18.
215198 $wgLogNames['institution'] = 'log-name-institution';
216199 $wgLogNames['course'] = 'log-name-course';
217 - $wgLogNames['mc'] = 'log-name-mc';
218200 $wgLogNames['student'] = 'log-name-student';
219201 $wgLogNames['ambassador'] = 'log-name-ambassador';
220202 $wgLogNames['instructor'] = 'log-name-instructor';
@@ -221,7 +203,6 @@
222204 // Compatibility with MediaWiki 1.18.
223205 $wgLogHeaders['institution'] = 'log-header-institution';
224206 $wgLogHeaders['course'] = 'log-header-course';
225 - $wgLogHeaders['mc'] = 'log-header-mc';
226207 $wgLogHeaders['student'] = 'log-header-student';
227208 $wgLogHeaders['ambassador'] = 'log-header-ambassador';
228209 $wgLogHeaders['instructor'] = 'log-header-instructor';
@@ -230,7 +211,6 @@
231212 // Rights
232213 $wgAvailableRights[] = 'ep-org'; // Manage orgs
233214 $wgAvailableRights[] = 'ep-course'; // Manage courses
234 -$wgAvailableRights[] = 'ep-mc'; // Manage master courses
235215 $wgAvailableRights[] = 'ep-token'; // See enrollment tokens
236216 $wgAvailableRights[] = 'ep-enroll'; // Enroll as a student
237217 $wgAvailableRights[] = 'ep-remstudent'; // Disassociate students from terms
@@ -245,7 +225,6 @@
246226 $wgGroupPermissions['*']['ep-enroll'] = true;
247227 $wgGroupPermissions['*']['ep-org'] = false;
248228 $wgGroupPermissions['*']['ep-course'] = false;
249 -$wgGroupPermissions['*']['ep-mc'] = false;
250229 $wgGroupPermissions['*']['ep-token'] = false;
251230 $wgGroupPermissions['*']['ep-remstudent'] = false;
252231 $wgGroupPermissions['*']['ep-online'] = false;
@@ -257,7 +236,6 @@
258237
259238 $wgGroupPermissions['epstaff']['ep-org'] = true;
260239 $wgGroupPermissions['epstaff']['ep-course'] = true;
261 -$wgGroupPermissions['epstaff']['ep-mc'] = true;
262240 $wgGroupPermissions['epstaff']['ep-token'] = true;
263241 $wgGroupPermissions['epstaff']['ep-enroll'] = true;
264242 $wgGroupPermissions['epstaff']['ep-remstudent'] = true;
@@ -270,7 +248,6 @@
271249
272250 $wgGroupPermissions['epadmin']['ep-org'] = true;
273251 $wgGroupPermissions['epadmin']['ep-course'] = true;
274 -$wgGroupPermissions['epadmin']['ep-mc'] = true;
275252 $wgGroupPermissions['epadmin']['ep-token'] = true;
276253 $wgGroupPermissions['epadmin']['ep-enroll'] = true;
277254 $wgGroupPermissions['epadmin']['ep-remstudent'] = true;
@@ -283,13 +260,11 @@
284261
285262 $wgGroupPermissions['eponlineamb']['ep-org'] = true;
286263 $wgGroupPermissions['eponlineamb']['ep-course'] = true;
287 -$wgGroupPermissions['eponlineamb']['ep-mc'] = true;
288264 $wgGroupPermissions['eponlineamb']['ep-token'] = true;
289265 $wgGroupPermissions['eponlineamb']['ep-beonline'] = true;
290266
291267 $wgGroupPermissions['epcampamb']['ep-org'] = true;
292268 $wgGroupPermissions['epcampamb']['ep-course'] = true;
293 -$wgGroupPermissions['epcampamb']['ep-mc'] = true;
294269 $wgGroupPermissions['epcampamb']['ep-token'] = true;
295270 $wgGroupPermissions['epcampamb']['ep-becampus'] = true;
296271
Index: trunk/extensions/EducationProgram/api/ApiRefreshEducation.php
@@ -24,7 +24,6 @@
2525 protected static $typeMap = array(
2626 'org' => 'EPOrg',
2727 'course' => 'EPCourse',
28 - 'mc' => 'EPMC',
2928 );
3029
3130 public function execute() {
Index: trunk/extensions/EducationProgram/api/ApiInstructor.php
@@ -37,7 +37,7 @@
3838 $this->dieUsageMsg( array( 'badaccess-groups' ) );
3939 }
4040
41 - $masterCourse = EPMC::selectRow( array( 'id', 'name', 'instructors' ), array( 'id' => $params['mcid'] ) );
 41+ $masterCourse = EPCourse::selectRow( array( 'id', 'name', 'instructors' ), array( 'id' => $params['mcid'] ) );
4242
4343 if ( $masterCourse === false ) {
4444 $this->dieUsage( wfMsg( 'ep-addinstructor-invalid-course' ), 'invalid-course' );
Index: trunk/extensions/EducationProgram/api/ApiDeleteEducation.php
@@ -24,7 +24,6 @@
2525 protected static $typeMap = array(
2626 'org' => 'EPOrg',
2727 'course' => 'EPCourse',
28 - 'mc' => 'EPMC',
2928 );
3029
3130 /**
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php
@@ -29,22 +29,14 @@
3030 dirname( __FILE__ ) . '/sql/EducationProgram.sql'
3131 );
3232
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+// ) );
4040
41 - $updater->addExtensionUpdate( array(
42 - 'addField',
43 - 'ep_revisions',
44 - 'rev_object_id',
45 - dirname( __FILE__ ) . '/sql/AddRevisionObjectId.sql',
46 - true
47 - ) );
48 -
4941 return true;
5042 }
5143
@@ -180,11 +172,6 @@
181173 'history' => 'InstitutionHistory',
182174 ),
183175 array(
184 - 'view' => 'MasterCourse',
185 - 'edit' => 'EditMasterCourse',
186 - 'history' => 'MasterCourseHistory',
187 - ),
188 - array(
189176 'view' => 'Course',
190177 'edit' => 'EditCourse',
191178 'history' => 'CourseHistory',
@@ -194,14 +181,12 @@
195182
196183 $editRights = array(
197184 'EditInstitution' => 'ep-org',
198 - 'EditMasterCourse' => 'ep-mc',
199185 'EditCourse' => 'ep-course',
200186 );
201187
202188 $classes = array(
203189 'Institution' => 'EPOrg',
204190 'Course' => 'EPCourse',
205 - 'MasterCourse' => 'EPMC',
206191 );
207192
208193 $specialSet = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r109989follow up to r109985; fixed stuff I missed initially and replaced year field ...jeroendedauw02:47, 25 January 2012
r109991follow up r109985 r109989; updated messages and field namesjeroendedauw03:05, 25 January 2012

Status & tagging log