r107525 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107524‎ | r107525 | r107526 >
Date:20:43, 28 December 2011
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
some work on ernrollment page
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.alias.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEnroll.php (modified) (history)
  • /trunk/extensions/EducationProgram/sql/EducationProgram.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.i18n.alias.php
@@ -28,5 +28,6 @@
2929 'EducationProgram' => array( 'EducationProgram' ),
3030 'EditCourse' => array( 'EditCourse' ),
3131 'EditInstitution' => array( 'EditInstitution' ),
 32+ 'EditTerm' => array( 'EditTerm' ),
3233 'Enroll' => array( 'Enroll' ),
3334 );
Index: trunk/extensions/EducationProgram/sql/EducationProgram.sql
@@ -38,6 +38,7 @@
3939 CREATE INDEX /*i*/ep_term_year ON /*_*/ep_terms (term_year);
4040 CREATE INDEX /*i*/ep_term_start ON /*_*/ep_terms (term_start);
4141 CREATE INDEX /*i*/ep_term_end ON /*_*/ep_terms (term_end);
 42+CREATE UNIQUE INDEX /*i*/ep_trem_period ON /*_*/ep_terms (term_org_id, term_start, term_start);
4243
4344 -- Students. In essence this is an extension to the user table.
4445 CREATE TABLE IF NOT EXISTS /*_*/ep_students (
@@ -94,4 +95,4 @@
9596 CREATE INDEX /*i*/ep_revision_deleted ON /*_*/ep_revisions (rev_deleted);
9697
9798 -- TODO: figure out how to best do logging.
\ No newline at end of file
 99+-- Can the core stuff be used in a sane way for this?
Index: trunk/extensions/EducationProgram/specials/SpecialEnroll.php
@@ -19,7 +19,7 @@
2020 * @since 0.1
2121 */
2222 public function __construct() {
23 - parent::__construct( 'Enroll', 'epstudent', false );
 23+ parent::__construct( 'Enroll', '', false );
2424 }
2525
2626 /**
@@ -32,9 +32,82 @@
3333 public function execute( $subPage ) {
3434 parent::execute( $subPage );
3535
 36+ $args = explode( '/', $this->subPage, 2 );
 37+
 38+ if ( !ctype_digit( $args[0] ) ) {
 39+ $this->showWarning( wfMessage( $args[0] === '' ? 'ep-enroll-no-id' : 'ep-enroll-invalid-id' ) );
 40+ }
 41+ elseif ( count( $args ) === 1 ) {
 42+ // TODO: might want to have an input here
 43+ $this->showWarning( wfMessage( 'ep-enroll-no-token' ) );
 44+ }
 45+ elseif ( count( $args ) === 2 ) {
 46+ $term = EPTerm::selectRow( null, array(
 47+ 'id' => $args[0],
 48+ 'token' => strtolower( $args[1] )
 49+ ) );
 50+
 51+ if ( $term === false ) {
 52+ $this->showWarning( wfMessage( 'ep-enroll-invalid-token' ) );
 53+ }
 54+ else {
 55+ if ( $this->getUser()->isLoggedIn() ) {
 56+ if ( $this->getUser()->isAllowed( 'epstudent' ) ) {
 57+ $this->showEntrollmentForm( $term );
 58+ }
 59+ else {
 60+ $this->showWarning( wfMessage( 'ep-enroll-not-allowed' ) );
 61+ }
 62+ }
 63+ else {
 64+ $this->showSignupLink( $term );
 65+ }
 66+ }
 67+ }
 68+
 69+ }
 70+
 71+ /**
 72+ *
 73+ *
 74+ * @param EPTerm $term
 75+ *
 76+ * @since 0.1
 77+ */
 78+ protected function showSignupLink( EPTerm $term ) {
3679 $out = $this->getOutput();
37 -
38 - // TODO: AUTH
 80+
 81+ $out->addWikiMsg( 'ep-enroll-login-first' );
 82+
 83+ $out->addHTML( Linker::linkKnown(
 84+ SpecialPage::getTitleFor( 'UserLogin' ),
 85+ wfMsgHtml( 'ep-enroll-login-and-entroll' ),
 86+ array(),
 87+ array(
 88+ 'returnto' => $this->getTitle( $this->subPage )->getFullText()
 89+ )
 90+ ) );
 91+
 92+ $out->addHTML( Linker::linkKnown(
 93+ SpecialPage::getTitleFor( 'UserLogin' ),
 94+ wfMsgHtml( 'ep-enroll-signup-and-entroll' ),
 95+ array(),
 96+ array(
 97+ 'returnto' => $this->getTitle( $this->subPage )->getFullText(),
 98+ 'type' => 'signup'
 99+ )
 100+ ) );
39101 }
 102+
 103+ /**
 104+ *
 105+ *
 106+ * @since 0.1
 107+ *
 108+ * @param EPTerm $term
 109+ */
 110+ protected function showEntrollmentForm( EPTerm $term ) {
 111+
 112+ }
40113
41114 }
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -190,6 +190,16 @@
191191 'specialterm-summary-token' => 'Enrollment token',
192192 'ep-term-nav-edit' => 'Edit this term',
193193
 194+ // Special:Enroll
 195+ 'ep-enroll-login-first' => 'Before you can enroll in this course, you need to login.',
 196+ 'ep-enroll-login-and-entroll' => 'Login with an existing account & enroll',
 197+ 'ep-enroll-signup-and-entroll' => 'Create a new account & enroll',
 198+ 'ep-enroll-not-allowed' => 'Your account is not allowed to enroll',
 199+ 'ep-enroll-invalid-id' => 'The term you tried to enroll for does not exist. A list of existing terms can be found [[Special:Terms|here]].',
 200+ 'ep-enroll-no-id' => 'You need to specify a term to enroll for. A list of existing terms can be found [[Special:Terms|here]].',
 201+ 'ep-enroll-no-token' => 'You need to provide the token needed to enroll for this term.',
 202+ 'ep-enroll-invalid-token' => 'The token you provided is invalid.',
 203+
194204 // Navigation links
195205 'ep-nav-orgs' => 'Institution list',
196206 'ep-nav-courses' => 'Courses list',

Status & tagging log