- if (!empty ($params['prtype'])) {
- $this->addTables('page_restrictions');
- $this->addWhere('page_id=pr_page');
- $this->addWhere('pr_expiry>' . $db->addQuotes($db->timestamp()));
- $this->addWhereFld('pr_type', $params['prtype']);
-
- // Remove the empty string and '*' from the prlevel array
- $prlevel = array_diff($params['prlevel'], array('', '*'));
- if (!empty($prlevel))
- $this->addWhereFld('pr_level', $prlevel);
- if ($params['prfiltercascade'] == 'cascading')
- $this->addWhereFld('pr_cascade', 1);
- if ($params['prfiltercascade'] == 'noncascading')
- $this->addWhereFld('pr_cascade', 0);
-
- $this->addOption('DISTINCT');
+ if ( !empty( $params['prtype'] ) ) {
+ $this->addTables( 'page_restrictions' );
+ $this->addWhere( 'page_id=pr_page' );
+ $this->addWhere( 'pr_expiry>' . $db->addQuotes( $db->timestamp() ) );
+ $this->addWhereFld( 'pr_type', $params['prtype'] );
+
+ if ( isset( $params['prlevel'] ) ) {
+ // Remove the empty string and '*' from the prlevel array
+ $prlevel = array_diff( $params['prlevel'], array( '', '*' ) );
+
+ if ( !empty( $prlevel ) ) {
+ $this->addWhereFld( 'pr_level', $prlevel );
+ }
+ }
+ if ( $params['prfiltercascade'] == 'cascading' ) {
+ $this->addWhereFld( 'pr_cascade', 1 );
+ } elseif ( $params['prfiltercascade'] == 'noncascading' ) {
+ $this->addWhereFld( 'pr_cascade', 0 );
+ }
+
+ $this->addOption( 'DISTINCT' );