r107001 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107000‎ | r107001 | r107002 >
Date:22:52, 21 December 2011
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
implemented deletion of linked stuff
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPDBObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPTerm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -43,6 +43,26 @@
4444 }
4545
4646 /**
 47+ * (non-PHPdoc)
 48+ * @see EPDBObject::removeFromDB()
 49+ */
 50+ public function removeFromDB() {
 51+ $id = $this->getId();
 52+
 53+ $success = parent::removeFromDB();
 54+
 55+ if ( $success ) {
 56+ $success = wfGetDB( DB_MASTER )->delete( 'ep_mentors_per_org', array( 'mpo_org_id' => $id ) ) && $success;
 57+
 58+ foreach ( EPCourse::select( 'id', array( 'org_id' => $id ) ) as /* EPCourse */ $course ) {
 59+ $success = $course->removeFromDB() && $success;
 60+ }
 61+ }
 62+
 63+ return $success;
 64+ }
 65+
 66+ /**
4767 * Returns a list of orgs in an array that can be fed to select inputs.
4868 *
4969 * @since 0.1
Index: trunk/extensions/EducationProgram/includes/EPTerm.php
@@ -43,5 +43,21 @@
4444 'end' => wfTimestamp( TS_MW ),
4545 );
4646 }
 47+
 48+ /**
 49+ * (non-PHPdoc)
 50+ * @see EPDBObject::removeFromDB()
 51+ */
 52+ public function removeFromDB() {
 53+ $id = $this->getId();
 54+
 55+ $success = parent::removeFromDB();
 56+
 57+ if ( $success ) {
 58+ $success = wfGetDB( DB_MASTER )->delete( 'ep_students_per_term', array( 'spt_term_id' => $id ) ) && $success;
 59+ }
 60+
 61+ return $success;
 62+ }
4763
4864 }
Index: trunk/extensions/EducationProgram/includes/EPDBObject.php
@@ -732,7 +732,7 @@
733733 * @return array of self
734734 */
735735 public static function select( $fields = null, array $conditions = array(), array $options = array(), array $joinConds = array() ) {
736 - $result = static::selectFields( $fields, $conditions, $options, $joinConds );
 736+ $result = static::selectFields( $fields, $conditions, $options, $joinConds, false );
737737
738738 $objects = array();
739739
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -42,6 +42,24 @@
4343 }
4444
4545 /**
 46+ * (non-PHPdoc)
 47+ * @see EPDBObject::removeFromDB()
 48+ */
 49+ public function removeFromDB() {
 50+ $id = $this->getId();
 51+
 52+ $success = parent::removeFromDB();
 53+
 54+ if ( $success ) {
 55+ foreach ( EPTerm::select( 'id', array( 'course_id' => $id ) ) as /* EPTerm */ $term ) {
 56+ $success = $term->removeFromDB() && $success;
 57+ }
 58+ }
 59+
 60+ return $success;
 61+ }
 62+
 63+ /**
4664 * Returns a list of courses in an array that can be fed to select inputs.
4765 *
4866 * @since 0.1

Status & tagging log