diff --git a/web/api/app/Controller/UsersController.php b/web/api/app/Controller/UsersController.php index 502a929ff..8e4f016e9 100644 --- a/web/api/app/Controller/UsersController.php +++ b/web/api/app/Controller/UsersController.php @@ -12,7 +12,7 @@ class UsersController extends AppController { * * @var array */ - public $components = array('RequestHandler', 'Paginator'); + public $components = array( 'Paginator', 'RequestHandler'); public function beforeFilter() { parent::beforeFilter(); @@ -20,7 +20,7 @@ class UsersController extends AppController { global $user; # We already tested for auth in appController, so we just need to test for specific permission $canView = (!$user) || ($user['System'] != 'None'); - if ( !$canView ) { + if (!$canView) { throw new UnauthorizedException(__('Insufficient Privileges')); return; } @@ -30,14 +30,13 @@ class UsersController extends AppController { * index method * * @return void - * This also creates a thumbnail for each user. */ public function index() { $this->User->recursive = 0; global $user; # We should actually be able to list our own user, but I'm not bothering at this time. - if ( $user['System'] == 'None' ) { + if ($user['System'] == 'None' ) { throw new UnauthorizedException(__('Insufficient Privileges')); return; } @@ -59,12 +58,12 @@ class UsersController extends AppController { global $user; # We can view ourselves $canView = ($user['System'] != 'None') or ($user['Id'] == $id); - if ( !$canView ) { + if (!$canView) { throw new UnauthorizedException(__('Insufficient Privileges')); return; } - if ( !$this->User->exists($id) ) { + if (!$this->User->exists($id)) { throw new NotFoundException(__('Invalid user')); } @@ -83,22 +82,34 @@ class UsersController extends AppController { * @return void */ public function add() { - if ( $this->request->is('post') ) { + ZM\Debug(1, "in add"); + if ($this->request->is('post')) { + ZM\Debug(1, "is post"); global $user; - if ( $user['System'] != 'Edit' ) { + if ($user['System'] != 'Edit') { throw new UnauthorizedException(__('Insufficient Privileges')); return; } - $this->User->create(); - if ( $this->User->save($this->request->data) ) { - return $this->flash(__('The user has been saved.'), array('action' => 'index')); - } - $this->Session->setFlash( - __('The user could not be saved. Please, try again.') - ); - } + $this->User->create(); + if ($this->User->save($this->request->data)) { + $message = 'Saved'; + } else { + $message = 'Error'; + // if there is a validation message, use it + if (!$this->User->validates()) { + $message = $this->User->validationErrors; + } + } + } else { + $message = 'Add without post data'; + } + $this->set(array( + 'user' => $this->User, + 'message' => $message, + '_serialize' => array('message') + )); } /** @@ -113,20 +124,23 @@ class UsersController extends AppController { global $user; $canEdit = ($user['System'] == 'Edit') or (($user['Id'] == $id) and ZM_USER_SELF_EDIT); - if ( !$canEdit ) { + if (!$canEdit) { throw new UnauthorizedException(__('Insufficient Privileges')); return; } - if ( !$this->User->exists($id) ) { + if (!$this->User->exists($id)) { throw new NotFoundException(__('Invalid user')); } - if ( $this->request->is('post') || $this->request->is('put') ) { + if ($this->request->is('post') || $this->request->is('put')) { if ( $this->User->save($this->request->data) ) { $message = 'Saved'; } else { $message = 'Error'; + if (!$this->User->validates()) { + $message = $this->User->validationErrors; + } } } else { # What is this doing? Resetting the request data? I understand clearing the password field @@ -161,7 +175,7 @@ class UsersController extends AppController { throw new NotFoundException(__('Invalid user')); } $this->request->allowMethod('post', 'delete'); - if ( $this->User->delete() ) { + if ($this->User->delete()) { $message = 'The user has been deleted.'; } else { $message = 'The user could not be deleted. Please, try again.'; diff --git a/web/api/app/View/Users/add.ctp b/web/api/app/View/Users/add.ctp deleted file mode 100644 index fc374d5ca..000000000 --- a/web/api/app/View/Users/add.ctp +++ /dev/null @@ -1,15 +0,0 @@ - -
- : - '{$url}'" - ); ?> -
- 0): - echo $this->element('exception_stack_trace'); -endif; -?> diff --git a/web/api/app/View/View/Errors/error500.ctp b/web/api/app/View/View/Errors/error500.ctp deleted file mode 100644 index 518b9ee77..000000000 --- a/web/api/app/View/View/Errors/error500.ctp +++ /dev/null @@ -1,28 +0,0 @@ - - -- : - -
- 0): - echo $this->element('exception_stack_trace'); -endif; -?> diff --git a/web/api/app/View/View/Events/json/index.ctp b/web/api/app/View/View/Events/json/index.ctp deleted file mode 100644 index d54386749..000000000 --- a/web/api/app/View/View/Events/json/index.ctp +++ /dev/null @@ -1,5 +0,0 @@ -Paginator->params(); - echo json_encode($array); -?> diff --git a/web/api/app/View/View/Events/json/view.ctp b/web/api/app/View/View/Events/json/view.ctp deleted file mode 100644 index b320feb4d..000000000 --- a/web/api/app/View/View/Events/json/view.ctp +++ /dev/null @@ -1 +0,0 @@ -echo json_encode($event); diff --git a/web/api/app/View/View/Events/xml/index.ctp b/web/api/app/View/View/Events/xml/index.ctp deleted file mode 100644 index af960238f..000000000 --- a/web/api/app/View/View/Events/xml/index.ctp +++ /dev/null @@ -1,2 +0,0 @@ -$xml = Xml::fromArray(array('response' => $events)); -echo $xml->asXML(); diff --git a/web/api/app/View/View/Events/xml/view.ctp b/web/api/app/View/View/Events/xml/view.ctp deleted file mode 100644 index 7f64e422f..000000000 --- a/web/api/app/View/View/Events/xml/view.ctp +++ /dev/null @@ -1,2 +0,0 @@ -$xml = Xml::fromArray(array('response' => $event)); -echo $xml->asXML(); diff --git a/web/api/app/View/View/Helper/AppHelper.php b/web/api/app/View/View/Helper/AppHelper.php deleted file mode 100644 index 9097d33f0..000000000 --- a/web/api/app/View/View/Helper/AppHelper.php +++ /dev/null @@ -1,33 +0,0 @@ - - - - -This email was sent using the CakePHP Framework
- - \ No newline at end of file diff --git a/web/api/app/View/View/Layouts/Emails/text/default.ctp b/web/api/app/View/View/Layouts/Emails/text/default.ctp deleted file mode 100644 index ee624de45..000000000 --- a/web/api/app/View/View/Layouts/Emails/text/default.ctp +++ /dev/null @@ -1,21 +0,0 @@ - -fetch('content'); ?> - -This email was sent using the CakePHP Framework, http://cakephp.org. diff --git a/web/api/app/View/View/Layouts/ajax.ctp b/web/api/app/View/View/Layouts/ajax.ctp deleted file mode 100644 index 0f9a4fb62..000000000 --- a/web/api/app/View/View/Layouts/ajax.ctp +++ /dev/null @@ -1,19 +0,0 @@ - -fetch('content'); ?> diff --git a/web/api/app/View/View/Layouts/default.ctp b/web/api/app/View/View/Layouts/default.ctp deleted file mode 100644 index 38dececbc..000000000 --- a/web/api/app/View/View/Layouts/default.ctp +++ /dev/null @@ -1,65 +0,0 @@ - - - - - Html->charset(); ?> -- - 1) Help me configure it - 2) I don't / can't use URL rewriting -
- --=')): - echo ''; - echo __d('cake_dev', 'Your version of PHP is 5.2.8 or higher.'); - echo ''; - else: - echo ''; - echo __d('cake_dev', 'Your version of PHP is too low. You need PHP 5.2.8 or higher to use CakePHP.'); - echo ''; - endif; -?> -
-- '; - echo __d('cake_dev', 'Your tmp directory is writable.'); - echo ''; - else: - echo ''; - echo __d('cake_dev', 'Your tmp directory is NOT writable.'); - echo ''; - endif; - ?> -
-- '; - echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', ''. $settings['engine'] . 'Engine', 'APP/Config/core.php'); - echo ''; - else: - echo ''; - echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', 'APP/Config/core.php'); - echo ''; - endif; - ?> -
-
- ';
- echo __d('cake_dev', 'Your database configuration file is present.');
- $filePresent = true;
- echo '';
- else:
- echo '';
- echo __d('cake_dev', 'Your database configuration file is NOT present.');
- echo '
';
- echo __d('cake_dev', 'Rename %s to %s', 'APP/Config/database.php.default', 'APP/Config/database.php');
- echo '';
- endif;
- ?>
-
- isConnected()):
- echo '';
- echo __d('cake_dev', 'CakePHP is able to connect to the database.');
- echo '';
- else:
- echo '';
- echo __d('cake_dev', 'CakePHP is NOT able to connect to the database.');
- echo '
';
- echo $errorMsg;
- echo '';
- endif;
- ?>
-
--enable-unicode-properties
when configuring');
- echo '';
- endif;
-?>
-
-
- ';
- echo __d('cake_dev', 'DebugKit plugin is present');
- echo '';
- else:
- echo '';
- echo __d('cake_dev', 'DebugKit is not installed. It will help you inspect and debug different aspects of your application.');
- echo '
';
- echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit'));
- echo '';
- endif;
- ?>
-
-
-To change its layout, edit: %s.
-You can also add some CSS styles for your pages at: %s.',
- 'APP/View/Pages/home.ctp', 'APP/View/Layouts/default.ctp', 'APP/webroot/css');
-?>
-
- Html->link( - sprintf('%s %s', __d('cake_dev', 'New'), __d('cake_dev', 'CakePHP 2.0 Docs')), - 'http://book.cakephp.org/2.0/en/', - array('target' => '_blank', 'escape' => false) - ); - ?> -
-- Html->link( - __d('cake_dev', 'The 15 min Blog Tutorial'), - 'http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/blog.html', - array('target' => '_blank', 'escape' => false) - ); - ?> -
- - --
- -
-- -
- -