Permalink
Browse files

fixed Exceptions. DBException and DatabaseException didn't exist

  • Loading branch information...
1 parent f4f7bbf commit 965d176cc556f9e978b02058cfaf6d8de5b44c18 @juanramon juanramon committed Nov 25, 2010
View
@@ -212,7 +212,7 @@
);
osc_sendMail($params);
}
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('We are very sorry but could not save your comment. Try again later.'));
}
View
@@ -26,75 +26,77 @@
$action = osc_readAction();
switch($action) {
- case 'add':
- osc_renderAdminSection('admins/add.php', __('Administrators'), __('Add'));
- break;
- case 'add_post':
- $_POST['s_password'] = sha1($_POST['s_password']);
- try {
- $adminManager->insert($_POST);
+ case 'add':
+ osc_renderAdminSection('admins/add.php', __('Administrators'), __('Add'));
+ break;
+ case 'add_post':
+ $_POST['s_password'] = sha1($_POST['s_password']);
+ try {
+ $adminManager->insert($_POST);
- osc_addFlashMessage(__('The item has been added.'));
- } catch (DatabaseException $e) {
- osc_addFlashMessage( __('The administrator could not be created.') . ' (' . $e->getMessage() . ')');
- }
- osc_redirectTo('admins.php');
- break;
- case 'edit':
- $admin = null;
- if(isset($_GET['id']))
- $adminEdit = $adminManager->findByPrimaryKey ($_GET['id']);
- elseif(isset($_SESSION['adminId']))
- $adminEdit = $adminManager->findByPrimaryKey($_SESSION['adminId']);
- osc_renderAdminSection('admins/edit.php', __('Administrators'), __('Edit'));
- break;
- case 'edit_post':
- $conditions = array('pk_i_id' => $_POST['id']);
- $admin = $adminManager->findByPrimaryKey($_POST['id']);
- unset($_POST['id']);
- if(empty($_POST['s_password'])) {
- unset($_POST['s_password']);
- } else {
- if(sha1($_POST['old_password'])==$admin['s_password']) {
- if($_POST['s_password']==$_POST['s_password2']) {
- $_POST['s_password'] = sha1($_POST['s_password']);
- } else {
- unset($_POST['s_password']);
- osc_addFlashMessage(__('Password didn\'t update. Passwords don\'t match.'));
- }
+ osc_addFlashMessage(__('The item has been added.'));
+ } catch (Exception $e) {
+ osc_addFlashMessage( __('The administrator could not be created.') . ' (' . $e->getMessage() . ')');
+ }
+ osc_redirectTo('admins.php');
+ break;
+ case 'edit':
+ $admin = null;
+ if(isset($_GET['id']))
+ $adminEdit = $adminManager->findByPrimaryKey ($_GET['id']);
+ elseif(isset($_SESSION['adminId']))
+ $adminEdit = $adminManager->findByPrimaryKey($_SESSION['adminId']);
+ osc_renderAdminSection('admins/edit.php', __('Administrators'), __('Edit'));
+ break;
+ case 'edit_post':
+ $conditions = array('pk_i_id' => $_POST['id']);
+ $admin = $adminManager->findByPrimaryKey($_POST['id']);
+ unset($_POST['id']);
+ if(empty($_POST['s_password'])) {
+ unset($_POST['s_password']);
+ } else {
+ if(sha1($_POST['old_password'])==$admin['s_password']) {
+ if($_POST['s_password']==$_POST['s_password2']) {
+ $_POST['s_password'] = sha1($_POST['s_password']);
} else {
unset($_POST['s_password']);
- osc_addFlashMessage(__('Password didn\'t update. "Old password" didn\'t match with our records in the database.'));
+ osc_addFlashMessage(__('Password didn\'t update. Passwords don\'t match.'));
}
+ } else {
+ unset($_POST['s_password']);
+ osc_addFlashMessage(__('Password didn\'t update. "Old password" didn\'t match with our records in the database.'));
}
- unset($_POST['old_password']);
- unset($_POST['s_password2']);
+ }
+ unset($_POST['old_password']);
+ unset($_POST['s_password2']);
- try {
- $adminManager->update($_POST, $conditions);
- } catch (DatabaseException $e) {
- osc_addFlashMessage( __('Error: ') . $e->getMessage());
+ try {
+ $adminManager->update($_POST, $conditions);
+ } catch (Exception $e) {
+ osc_addFlashMessage( __('Error: ') . $e->getMessage());
+ }
+ osc_redirectTo('admins.php');
+ break;
+ case 'delete':
+ $id = osc_paramRequest('id', false);
+ if($id) {
+ // Verification to avoid an administrator trying to remove to itself
+ if(in_array($_SESSION['adminId'], $id)) {
+ osc_addFlashMessage( __('The operation was not completed. You were trying to remove yourself!') );
+ } else {
+ try {
+ $adminManager->delete(array('pk_i_id IN (' . implode(', ', $id) . ')'));
+ } catch (Exception $e) {
+ osc_addFlashMessage( __('Error: ') . $e->getMessage());
+ }
}
- osc_redirectTo('admins.php');
- break;
- case 'delete':
- $id = osc_paramRequest('id', false);
- if($id) {
- // Verification to avoid an administrator trying to remove to itself
- if(in_array($_SESSION['adminId'], $id)) {
- osc_addFlashMessage( __('The operation was not completed. You were trying to remove yourself!') );
- } else {
- try {
- $adminManager->delete(array('pk_i_id IN (' . implode(', ', $id) . ')'));
- } catch (DatabaseException $e) {
- osc_addFlashMessage( __('Error: ') . $e->getMessage());
- }
- }
- }
- osc_redirectTo('admins.php');
- break;
- default:
- $admins = $adminManager->listAll();
+ }
+ osc_redirectTo('admins.php');
+ break;
+ default:
+ $admins = $adminManager->listAll();
+
+ osc_renderAdminSection('admins/index.php', __('Administrators'));
+}
- osc_renderAdminSection('admins/index.php', __('Administrators'));
-}
+?>
@@ -52,7 +52,7 @@
$categoryManager->insert($fields, $aFieldsDescription);
osc_addFlashMessage(__('The category has been added.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('categories.php');
@@ -79,7 +79,7 @@
try {
$categoryManager->updateByPrimaryKey($fields, $aFieldsDescription, $id);
osc_addFlashMessage(__('The item has been updated.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
if( !is_null( $fields['fk_i_parent_id'] ) ) {
@@ -97,7 +97,7 @@
}
}
osc_addFlashMessage(__('The items have been deleted.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('categories.php');
@@ -117,7 +117,7 @@
$msg = __('There was a problem with this page. The ID for the category is not set.') ;
}
osc_addFlashMessage($msg) ;
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('categories.php');
@@ -132,7 +132,7 @@
}
}
osc_addFlashMessage(__('The categories have been enabled.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('categories.php');
@@ -147,7 +147,7 @@
}
}
osc_addFlashMessage(__('Selected categories have been disabled.'));
- } catch (DatabaseException $e) {
+ } catch (Exception $e) {
osc_addFlashMessage(__('Error: ') . $e->getMessage());
}
osc_redirectTo('categories.php');
@@ -170,4 +170,4 @@
osc_renderAdminSection('categories/index.php', __('Categories'));
}
-?>
+?>
Oops, something went wrong.

0 comments on commit 965d176

Please sign in to comment.