Skip to content

Commit

Permalink
Merge pull request #20 from nueckman/patch-3
Browse files Browse the repository at this point in the history
PHP 5.3 compatibility 3
  • Loading branch information
veloper committed Dec 29, 2014
2 parents 4319858 + 52c9306 commit e68d206
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions wpdc/controllers/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public function databaseSubmit() {
return $this->redirectToAction( "database" );
}

if ( empty( $this->db()->getTables() ) ) {
$tables = $this->db()->getTables();
if ( empty( $tables ) ) {
$this->addFlash( "error", 'Database Error: Could not find any tables that start with the "' . $post["table_prefix"] . '" prefix.' );
return $this->redirectToAction( "database" );
}
Expand Down Expand Up @@ -302,7 +303,8 @@ public function beforeRequest() {
$this->redirectToAction( "database" );
}

if ( $this->isTableSelectionsRequired() && empty( $this->getSelectedTableNames() ) ) {
$selectedTableNames = $this->getSelectedTableNames();
if ( $this->isTableSelectionsRequired() && empty( $selectedTableNames ) ) {
$this->addFlash( "error", "At least one table must be selected." );
$this->redirectToAction( "tables" );
}
Expand All @@ -315,6 +317,7 @@ public function beforeRender() {

$this->data["logout_path"] = $this->getActionUrl( "logout" );

$selectedTableNames = $this->getSelectedTableNames();
$this->data["nav"] = array(
"database" => array(
"path" => $this->getActionUrl( "database" ),
Expand All @@ -328,18 +331,20 @@ public function beforeRender() {
),
"change" => array(
"path" => $this->getActionUrl( "changeSetup" ),
"disabled" => empty( $this->getSelectedTableNames() )
"disabled" => empty( $selectedTableNames )
)
);
}

public function isDatabaseConnectionRequired() {
$options = $this->getRequestRoute()["options"];
$route = $this->getRequestRoute();
$options = $route["options"];
return isset( $options["db"] ) ? (bool) $options["db"] : false;
}

public function isTableSelectionsRequired() {
$options = $this->getRequestRoute()["options"];
$route = $this->getRequestRoute();
$options = $route["options"];
return isset( $options["tables"] ) ? (bool) $options["tables"] : false;
}

Expand Down

0 comments on commit e68d206

Please sign in to comment.