+
+ $this->loadData();
+ }
+
+ /**
+ * Loads the current state of protection into the object.
+ */
+ function loadData() {
+ global $wgRequest, $wgUser;
+ global $wgRestrictionLevels;
+
+ $this->mCascade = $this->mTitle->areRestrictionsCascading();
+
+ $this->mReason = $wgRequest->getText( 'mwProtect-reason' );
+ $this->mReasonSelection = $wgRequest->getText( 'wpProtectReasonSelection' );
+ $this->mCascade = $wgRequest->getBool( 'mwProtect-cascade', $this->mCascade );
+
+ foreach( $this->mApplicableTypes as $action ) {
+ // @todo FIXME: This form currently requires individual selections,
+ // but the db allows multiples separated by commas.
+
+ // Pull the actual restriction from the DB
+ $this->mRestrictions[$action] = implode( '', $this->mTitle->getRestrictions( $action ) );
+
+ if ( !$this->mRestrictions[$action] ) {
+ // No existing expiry
+ $existingExpiry = '';
+ } else {
+ $existingExpiry = $this->mTitle->getRestrictionExpiry( $action );
+ }
+ $this->mExistingExpiry[$action] = $existingExpiry;
+
+ $requestExpiry = $wgRequest->getText( "mwProtect-expiry-$action" );
+ $requestExpirySelection = $wgRequest->getVal( "wpProtectExpirySelection-$action" );
+
+ if ( $requestExpiry ) {
+ // Custom expiry takes precedence
+ $this->mExpiry[$action] = $requestExpiry;
+ $this->mExpirySelection[$action] = 'othertime';
+ } elseif ( $requestExpirySelection ) {
+ // Expiry selected from list
+ $this->mExpiry[$action] = '';
+ $this->mExpirySelection[$action] = $requestExpirySelection;
+ } elseif ( $existingExpiry == 'infinity' ) {
+ // Existing expiry is infinite, use "infinite" in drop-down
+ $this->mExpiry[$action] = '';
+ $this->mExpirySelection[$action] = 'infinite';
+ } elseif ( $existingExpiry ) {
+ // Use existing expiry in its own list item
+ $this->mExpiry[$action] = '';
+ $this->mExpirySelection[$action] = $existingExpiry;
+ } else {
+ // Final default: infinite
+ $this->mExpiry[$action] = '';
+ $this->mExpirySelection[$action] = 'infinite';
+ }