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 @@ - -
-Form->create('User'); ?> -
- - Form->input('username'); - echo $this->Form->input('password'); - echo $this->Form->input('role', array( - 'options' => array('admin' => 'Admin', 'author' => 'Author') - )); - ?> -
-Form->end(__('Submit')); ?> -
- diff --git a/web/api/app/View/Users/json/add.ctp b/web/api/app/View/Users/json/add.ctp new file mode 100644 index 000000000..ac802f9a9 --- /dev/null +++ b/web/api/app/View/Users/json/add.ctp @@ -0,0 +1,2 @@ +echo json_encode($message); +echo json_encode($user); diff --git a/web/api/app/View/View/Monitors/json/edit.ctp b/web/api/app/View/Users/json/edit.ctp similarity index 50% rename from web/api/app/View/View/Monitors/json/edit.ctp rename to web/api/app/View/Users/json/edit.ctp index 77d2dd08b..ac802f9a9 100644 --- a/web/api/app/View/View/Monitors/json/edit.ctp +++ b/web/api/app/View/Users/json/edit.ctp @@ -1,2 +1,2 @@ echo json_encode($message); -echo json_encode($monitor); +echo json_encode($user); diff --git a/web/api/app/View/Users/login.ctp b/web/api/app/View/Users/login.ctp deleted file mode 100644 index 335ad3108..000000000 --- a/web/api/app/View/Users/login.ctp +++ /dev/null @@ -1,13 +0,0 @@ -
-Session->flash('auth'); ?> -Form->create('User'); ?> -
- - - - Form->input('username'); - echo $this->Form->input('password'); - ?> -
-Form->end(__('Login')); ?> -
diff --git a/web/api/app/View/View/Monitors/xml/edit.ctp b/web/api/app/View/Users/xml/add.ctp similarity index 100% rename from web/api/app/View/View/Monitors/xml/edit.ctp rename to web/api/app/View/Users/xml/add.ctp diff --git a/web/api/app/View/Users/xml/edit.ctp b/web/api/app/View/Users/xml/edit.ctp new file mode 100644 index 000000000..09fb8979a --- /dev/null +++ b/web/api/app/View/Users/xml/edit.ctp @@ -0,0 +1,2 @@ +$xml = Xml::fromArray(array('response' => $message)); +echo $xml->asXML(); diff --git a/web/api/app/View/View/Configs/json/edit.ctp b/web/api/app/View/View/Configs/json/edit.ctp deleted file mode 100644 index 75fa758bd..000000000 --- a/web/api/app/View/View/Configs/json/edit.ctp +++ /dev/null @@ -1 +0,0 @@ -echo json_encode($config); diff --git a/web/api/app/View/View/Configs/json/index.ctp b/web/api/app/View/View/Configs/json/index.ctp deleted file mode 100644 index 86edf870a..000000000 --- a/web/api/app/View/View/Configs/json/index.ctp +++ /dev/null @@ -1 +0,0 @@ -echo json_encode($configs); diff --git a/web/api/app/View/View/Configs/json/view.ctp b/web/api/app/View/View/Configs/json/view.ctp deleted file mode 100644 index 75fa758bd..000000000 --- a/web/api/app/View/View/Configs/json/view.ctp +++ /dev/null @@ -1 +0,0 @@ -echo json_encode($config); diff --git a/web/api/app/View/View/Configs/xml/index.ctp b/web/api/app/View/View/Configs/xml/index.ctp deleted file mode 100644 index b13a76093..000000000 --- a/web/api/app/View/View/Configs/xml/index.ctp +++ /dev/null @@ -1,2 +0,0 @@ -$xml = Xml::fromArray(array('response' => $configs)); -echo $xml->asXML(); diff --git a/web/api/app/View/View/Configs/xml/view.ctp b/web/api/app/View/View/Configs/xml/view.ctp deleted file mode 100644 index 7987d32e7..000000000 --- a/web/api/app/View/View/Configs/xml/view.ctp +++ /dev/null @@ -1,2 +0,0 @@ -$xml = Xml::fromArray(array('response' => $config)); -echo $xml->asXML(); diff --git a/web/api/app/View/View/Emails/html/default.ctp b/web/api/app/View/View/Emails/html/default.ctp deleted file mode 100644 index e2bff19c0..000000000 --- a/web/api/app/View/View/Emails/html/default.ctp +++ /dev/null @@ -1,25 +0,0 @@ - - ' . $line . "

\n"; -endforeach; -?> \ No newline at end of file diff --git a/web/api/app/View/View/Emails/text/default.ctp b/web/api/app/View/View/Emails/text/default.ctp deleted file mode 100644 index 090b5c403..000000000 --- a/web/api/app/View/View/Emails/text/default.ctp +++ /dev/null @@ -1,19 +0,0 @@ - - \ No newline at end of file diff --git a/web/api/app/View/View/Errors/error400.ctp b/web/api/app/View/View/Errors/error400.ctp deleted file mode 100644 index 4c3850b28..000000000 --- a/web/api/app/View/View/Errors/error400.ctp +++ /dev/null @@ -1,31 +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 @@ - - - - - <?php echo $title_for_layout; ?> - - - fetch('content'); ?> - -

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(); ?> - - <?php echo $cakeDescription ?>: - <?php echo $title_for_layout; ?> - - Html->meta('icon'); - - echo $this->Html->css('cake.generic'); - - echo $this->fetch('meta'); - echo $this->fetch('css'); - echo $this->fetch('script'); - ?> - - -
- -
- - Session->flash(); ?> - - fetch('content'); ?> -
- -
- element('sql_dump'); ?> - - diff --git a/web/api/app/View/View/Layouts/error.ctp b/web/api/app/View/View/Layouts/error.ctp deleted file mode 100644 index e9d738178..000000000 --- a/web/api/app/View/View/Layouts/error.ctp +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Html->charset(); ?> - - <?php echo $cakeDescription ?>: - <?php echo $title_for_layout; ?> - - Html->meta('icon'); - - echo $this->Html->css('cake.generic'); - - echo $this->fetch('meta'); - echo $this->fetch('css'); - echo $this->fetch('script'); - ?> - - -
- -
- - Session->flash(); ?> - - fetch('content'); ?> -
- -
- element('sql_dump'); ?> - - diff --git a/web/api/app/View/View/Layouts/flash.ctp b/web/api/app/View/View/Layouts/flash.ctp deleted file mode 100644 index cd79f5008..000000000 --- a/web/api/app/View/View/Layouts/flash.ctp +++ /dev/null @@ -1,37 +0,0 @@ - - - - -Html->charset(); ?> -<?php echo $page_title; ?> - - - - - - - -

- - diff --git a/web/api/app/View/View/Layouts/js/default.ctp b/web/api/app/View/View/Layouts/js/default.ctp deleted file mode 100644 index 7239b5dae..000000000 --- a/web/api/app/View/View/Layouts/js/default.ctp +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/web/api/app/View/View/Layouts/rss/default.ctp b/web/api/app/View/View/Layouts/rss/default.ctp deleted file mode 100644 index 26d875eda..000000000 --- a/web/api/app/View/View/Layouts/rss/default.ctp +++ /dev/null @@ -1,14 +0,0 @@ -Rss->document( - $this->Rss->channel( - array(), $channel, $this->fetch('content') - ) -); -?> diff --git a/web/api/app/View/View/Layouts/xml/default.ctp b/web/api/app/View/View/Layouts/xml/default.ctp deleted file mode 100644 index fbd5ee0c3..000000000 --- a/web/api/app/View/View/Layouts/xml/default.ctp +++ /dev/null @@ -1 +0,0 @@ -fetch('content'); ?> diff --git a/web/api/app/View/View/Logs/json/index.ctp b/web/api/app/View/View/Logs/json/index.ctp deleted file mode 100644 index 32cbd51f8..000000000 --- a/web/api/app/View/View/Logs/json/index.ctp +++ /dev/null @@ -1,5 +0,0 @@ -Paginator->params(); - echo json_encode($array); -?> diff --git a/web/api/app/View/View/Monitors/json/index.ctp b/web/api/app/View/View/Monitors/json/index.ctp deleted file mode 100644 index facf965d4..000000000 --- a/web/api/app/View/View/Monitors/json/index.ctp +++ /dev/null @@ -1 +0,0 @@ -echo json_encode($monitors); diff --git a/web/api/app/View/View/Monitors/json/view.ctp b/web/api/app/View/View/Monitors/json/view.ctp deleted file mode 100644 index acfced9d0..000000000 --- a/web/api/app/View/View/Monitors/json/view.ctp +++ /dev/null @@ -1 +0,0 @@ -echo json_encode($monitor); diff --git a/web/api/app/View/View/Monitors/xml/index.ctp b/web/api/app/View/View/Monitors/xml/index.ctp deleted file mode 100644 index 37afc918b..000000000 --- a/web/api/app/View/View/Monitors/xml/index.ctp +++ /dev/null @@ -1,2 +0,0 @@ -$xml = Xml::fromArray(array('response' => $monitors)); -echo $xml->asXML(); diff --git a/web/api/app/View/View/Monitors/xml/view.ctp b/web/api/app/View/View/Monitors/xml/view.ctp deleted file mode 100644 index b33c6e79a..000000000 --- a/web/api/app/View/View/Monitors/xml/view.ctp +++ /dev/null @@ -1,2 +0,0 @@ -$xml = Xml::fromArray(array('response' => $monitor)); -echo $xml->asXML(); diff --git a/web/api/app/View/View/Pages/home.ctp b/web/api/app/View/View/Pages/home.ctp deleted file mode 100644 index 082cc99b0..000000000 --- a/web/api/app/View/View/Pages/home.ctp +++ /dev/null @@ -1,233 +0,0 @@ - -

-

- -

- 0): - Debugger::checkSecurityKeys(); -endif; -?> - -

- - 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; - ?> -

-getMessage(); - if (method_exists($connectionError, 'getAttributes')): - $attributes = $connectionError->getAttributes(); - if (isset($errorMsg['message'])): - $errorMsg .= '
' . $attributes['message']; - endif; - 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; - ?> -

- -'; - echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.'); - echo '
'; - echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding --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) - ); - ?> -

- -

-

-

-

- -

-

- -

-

- -

- -