From 3974d0fc0e0ff422b7fa40746b315a8f56bce43c Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 11 Aug 2011 14:21:05 +0200 Subject: [PATCH 01/27] Name old language folders correctly --- .../language/{german => de_DE}/auth_lang.php | 0 .../{german => de_DE}/datamapper_lang.php | 0 .../form_validation_lang.php | 0 .../language/{english => de_DE}/index.html | 0 .../language/{german => de_DE}/jobs_lang.php | 0 .../{german => de_DE}/projects_lang.php | 0 .../{german => de_DE}/settings_lang.php | 0 .../language/{english => en_EN}/auth_lang.php | 0 .../{english => en_EN}/datamapper_lang.php | 0 .../form_validation_lang.php | 0 .../language/{german => en_EN}/index.html | 0 .../language/{english => en_EN}/jobs_lang.php | 0 .../{english => en_EN}/projects_lang.php | 0 .../{english => en_EN}/settings_lang.php | 0 .../language/english/admin/servers_lang.php | 43 ------------------- 15 files changed, 43 deletions(-) rename application/language/{german => de_DE}/auth_lang.php (100%) rename application/language/{german => de_DE}/datamapper_lang.php (100%) rename application/language/{german => de_DE}/form_validation_lang.php (100%) rename application/language/{english => de_DE}/index.html (100%) rename application/language/{german => de_DE}/jobs_lang.php (100%) rename application/language/{german => de_DE}/projects_lang.php (100%) rename application/language/{german => de_DE}/settings_lang.php (100%) rename application/language/{english => en_EN}/auth_lang.php (100%) rename application/language/{english => en_EN}/datamapper_lang.php (100%) rename application/language/{english => en_EN}/form_validation_lang.php (100%) rename application/language/{german => en_EN}/index.html (100%) rename application/language/{english => en_EN}/jobs_lang.php (100%) rename application/language/{english => en_EN}/projects_lang.php (100%) rename application/language/{english => en_EN}/settings_lang.php (100%) delete mode 100644 application/language/english/admin/servers_lang.php diff --git a/application/language/german/auth_lang.php b/application/language/de_DE/auth_lang.php similarity index 100% rename from application/language/german/auth_lang.php rename to application/language/de_DE/auth_lang.php diff --git a/application/language/german/datamapper_lang.php b/application/language/de_DE/datamapper_lang.php similarity index 100% rename from application/language/german/datamapper_lang.php rename to application/language/de_DE/datamapper_lang.php diff --git a/application/language/german/form_validation_lang.php b/application/language/de_DE/form_validation_lang.php similarity index 100% rename from application/language/german/form_validation_lang.php rename to application/language/de_DE/form_validation_lang.php diff --git a/application/language/english/index.html b/application/language/de_DE/index.html similarity index 100% rename from application/language/english/index.html rename to application/language/de_DE/index.html diff --git a/application/language/german/jobs_lang.php b/application/language/de_DE/jobs_lang.php similarity index 100% rename from application/language/german/jobs_lang.php rename to application/language/de_DE/jobs_lang.php diff --git a/application/language/german/projects_lang.php b/application/language/de_DE/projects_lang.php similarity index 100% rename from application/language/german/projects_lang.php rename to application/language/de_DE/projects_lang.php diff --git a/application/language/german/settings_lang.php b/application/language/de_DE/settings_lang.php similarity index 100% rename from application/language/german/settings_lang.php rename to application/language/de_DE/settings_lang.php diff --git a/application/language/english/auth_lang.php b/application/language/en_EN/auth_lang.php similarity index 100% rename from application/language/english/auth_lang.php rename to application/language/en_EN/auth_lang.php diff --git a/application/language/english/datamapper_lang.php b/application/language/en_EN/datamapper_lang.php similarity index 100% rename from application/language/english/datamapper_lang.php rename to application/language/en_EN/datamapper_lang.php diff --git a/application/language/english/form_validation_lang.php b/application/language/en_EN/form_validation_lang.php similarity index 100% rename from application/language/english/form_validation_lang.php rename to application/language/en_EN/form_validation_lang.php diff --git a/application/language/german/index.html b/application/language/en_EN/index.html similarity index 100% rename from application/language/german/index.html rename to application/language/en_EN/index.html diff --git a/application/language/english/jobs_lang.php b/application/language/en_EN/jobs_lang.php similarity index 100% rename from application/language/english/jobs_lang.php rename to application/language/en_EN/jobs_lang.php diff --git a/application/language/english/projects_lang.php b/application/language/en_EN/projects_lang.php similarity index 100% rename from application/language/english/projects_lang.php rename to application/language/en_EN/projects_lang.php diff --git a/application/language/english/settings_lang.php b/application/language/en_EN/settings_lang.php similarity index 100% rename from application/language/english/settings_lang.php rename to application/language/en_EN/settings_lang.php diff --git a/application/language/english/admin/servers_lang.php b/application/language/english/admin/servers_lang.php deleted file mode 100644 index a470790..0000000 --- a/application/language/english/admin/servers_lang.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/* - * Headings - */ -$lang['location'] = 'Location'; -$lang['owner'] = 'Owner'; -$lang['actions'] = 'Actions'; -$lang['technical_info'] = 'Technical information'; -$lang['hardware_os'] = 'Hardware & OS'; -$lang['scattport_stats'] = 'ScattPort statistics'; - -/* - * server status - */ -$lang['busy'] = 'busy'; -$lang['offline'] = 'offline'; -$lang['available'] = 'available'; - -$lang['workload'] = 'Workload'; -$lang['completed_jobs'] = 'Completed jobs'; \ No newline at end of file From a3ee0f784c4edd2d6555017b6f34a14426bd860b Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 11 Aug 2011 14:22:44 +0200 Subject: [PATCH 02/27] Form validation for user related stuff --- application/config/form_validation.php | 157 ++++++++++++++++++------- 1 file changed, 115 insertions(+), 42 deletions(-) diff --git a/application/config/form_validation.php b/application/config/form_validation.php index 550e298..c4e6266 100644 --- a/application/config/form_validation.php +++ b/application/config/form_validation.php @@ -1,45 +1,118 @@ array( - array( - 'field' => 'username', - 'label' => _('Username'), - 'rules' => 'trim|required|min_length[4]|max_length[20]|unique[users.username]', - ), - array( - 'field' => 'password', - 'label' => _('Password'), - 'rules' => 'required|min_length[6]|matches[password_confirm]', - ), - array( - 'field' => 'password_confirm', - 'label' => _('Confirm password'), - ), - array( - 'field' => 'firstname', - 'label' => _('First name'), - 'rules' => 'trim|required|max_length[50]', - ), - array( - 'field' => 'lastname', - 'label' => _('Last name'), - 'rules' => 'trim|required|max_length[50]', - ), - array( - 'field' => 'email', - 'label' => _('Email address'), - 'rules' => 'trim|required|valid_email', - ), - array( - 'field' => 'institution', - 'label' => _('Institution'), - 'rules' => 'trim|max_length[100]', - ), - array( - 'field' => 'phone', - 'label' => _('Phone number'), - 'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]', - ) +/** + * Rules for creating users. + * + * @var array + */ +$config['users/create'] = array( + array( + 'field' => 'username', + 'label' => _('Username'), + 'rules' => 'required|min_length[4]|max_length[20]|unique[users.username]|trim', + ), + array( + 'field' => 'email', + 'label' => _('Email address'), + 'rules' => 'required|valid_email|trim', + ), + array( + 'field' => 'password', + 'label' => _('Password'), + 'rules' => 'required|min_length[6]|matches[password_confirm]', + ), + array( + 'field' => 'password_confirm', + 'label' => _('Confirm password'), + ), + array( + 'field' => 'firstname', + 'label' => _('First name'), + 'rules' => 'required|max_length[50]|trim', + ), + array( + 'field' => 'lastname', + 'label' => _('Last name'), + 'rules' => 'required|max_length[50]|trim', + ), + array( + 'field' => 'institution', + 'label' => _('Institution'), + 'rules' => 'max_length[100]|trim', + ), + array( + 'field' => 'phone', + 'label' => _('Phone number'), + 'rules' => 'regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]|trim', ) -); \ No newline at end of file +); + +/** + * Rules for editing users. + * + * @var array + */ +$config['users/edit'] = array( + array( + 'field' => 'firstname', + 'label' => _('First name'), + 'rules' => 'required|max_length[50]|trim', + ), + array( + 'field' => 'lastname', + 'label' => _('Last name'), + 'rules' => 'required|max_length[50]|trim', + ), + array( + 'field' => 'email', + 'label' => _('Email address'), + 'rules' => 'required|valid_email|trim', + ), + array( + 'field' => 'institution', + 'label' => _('Institution'), + 'rules' => 'max_length[100]|trim', + ), + array( + 'field' => 'phone', + 'label' => _('Phone number'), + 'rules' => 'regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]|trim', + ) +); + +/** + * Rules for the settings page. + * + * @var array + */ +$config['settings/index'] = array( + array( + 'field' => 'firstname', + 'label' => _('First name'), + 'rules' => 'required|max_length[50]|trim', + ), + array( + 'field' => 'lastname', + 'label' => _('Last name'), + 'rules' => 'required|max_length[50]|trim', + ), + array( + 'field' => 'email', + 'label' => _('Email address'), + 'rules' => 'required|valid_email|trim', + ), + array( + 'field' => 'institution', + 'label' => _('Institution'), + 'rules' => 'max_length[100]|trim', + ), + array( + 'field' => 'phone', + 'label' => _('Phone number'), + 'rules' => 'regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]|trim', + ) +); + +/* End of file form_validation.php */ +/* Location: ./application/config/form_validation.php */ + From 12a357fe17b08b8b3f8a8a20474eef70f2c44c23 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 11 Aug 2011 14:23:30 +0200 Subject: [PATCH 03/27] Make settings page working --- application/controllers/admin/users.php | 75 +------------------------ application/controllers/settings.php | 28 ++++++--- application/views/user/settings.php | 51 ++++++++++++----- assets/css/style.css | 7 ++- 4 files changed, 64 insertions(+), 97 deletions(-) diff --git a/application/controllers/admin/users.php b/application/controllers/admin/users.php index 2f63c9f..65d12ee 100644 --- a/application/controllers/admin/users.php +++ b/application/controllers/admin/users.php @@ -15,6 +15,7 @@ class Users extends CI_Controller { parent::__construct(); $this->load->library('form_validation'); $this->load->model('user'); + $this->load->config('form_validation'); } /** @@ -29,49 +30,6 @@ class Users extends CI_Controller { * Allows admins to create a new user. */ public function create() { - $config = array( - array( - 'field' => 'username', - 'label' => _('Username'), - 'rules' => 'trim|required|min_length[4]|max_length[20]|unique[users.username]', - ), - array( - 'field' => 'password', - 'label' => _('Password'), - 'rules' => 'required|min_length[6]|matches[password_confirm]', - ), - array( - 'field' => 'password_confirm', - 'label' => _('Confirm password'), - ), - array( - 'field' => 'firstname', - 'label' => _('First name'), - 'rules' => 'trim|required|max_length[50]', - ), - array( - 'field' => 'lastname', - 'label' => _('Last name'), - 'rules' => 'trim|required|max_length[50]', - ), - array( - 'field' => 'email', - 'label' => _('Email address'), - 'rules' => 'trim|required|valid_email', - ), - array( - 'field' => 'institution', - 'label' => _('Institution'), - 'rules' => 'trim|max_length[100]', - ), - array( - 'field' => 'phone', - 'label' => _('Phone number'), - 'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]', - ) - ); - $this->form_validation->set_rules($config); - if ($this->form_validation->run() === true) { $username = $this->input->post('username'); @@ -103,36 +61,7 @@ class Users extends CI_Controller { show_404(); } - $config = array( - array( - 'field' => 'firstname', - 'label' => _('First name'), - 'rules' => 'trim|required|max_length[50]', - ), - array( - 'field' => 'lastname', - 'label' => _('Last name'), - 'rules' => 'trim|required|max_length[50]', - ), - array( - 'field' => 'email', - 'label' => _('Email address'), - 'rules' => 'trim|required|valid_email', - ), - array( - 'field' => 'institution', - 'label' => _('Institution'), - 'rules' => 'trim|max_length[100]', - ), - array( - 'field' => 'phone', - 'label' => _('Phone number'), - 'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]', - ) - ); - $this->form_validation->set_rules($config); - - if ($this->form_validation->run() === true) { + if ($this->form_validation->run('users/edit') === true) { $data = array( 'email' => $this->input->post('email'), 'firstname' => $this->input->post('firstname'), diff --git a/application/controllers/settings.php b/application/controllers/settings.php index d694efa..8c8f65b 100644 --- a/application/controllers/settings.php +++ b/application/controllers/settings.php @@ -33,20 +33,30 @@ class Settings extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('program'); + $this->load->library('form_validation'); } /** * Show a list of all available programs. */ public function index() { - $profile = $this->user->profile(); - $profile_fields = array( - array('firstname', _('First name'), 'text'), - array('lastname', _('Last name'), 'text'), - array('intitution', _('Institution'), 'text'), - ); - $tpl['profile'] = $profile; - $tpl['profile_fields'] = $profile_fields; - $this->load->view('user/settings', $tpl); + $user = $this->access->getCurrentUser(); + + if ($this->form_validation->run() === true) { + $data = array( + 'email' => $this->input->post('email'), + 'firstname' => $this->input->post('firstname'), + 'lastname' => $this->input->post('lastname'), + 'institution' => $this->input->post('institution'), + 'phone' => $this->input->post('phone') + ); + + if ($this->user->update($user['id'], $data)) { + $this->messages->add(_("Settings saved successfully"), 'success'); + redirect('settings', 303); + } + } + + $this->load->view('user/settings', $user); } } diff --git a/application/views/user/settings.php b/application/views/user/settings.php index 3914891..ce2a767 100644 --- a/application/views/user/settings.php +++ b/application/views/user/settings.php @@ -1,7 +1,7 @@ load->view('header');?>
-
+

@@ -13,27 +13,45 @@
    -
  • - +
    - + + +
    +
  • +
  • + +
    + + +
    +
  • +
  • + +
    + + +
    +
  • +
  • + +
    + + +
    +
  • +
  • + +
    + +
  • -
    -
  • - -
    - -
    -

  • @@ -41,6 +59,11 @@
+
+

+ +

+
diff --git a/assets/css/style.css b/assets/css/style.css index 99d1102..78e5df6 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -470,11 +470,16 @@ html ul.tabs li.active, html ul.tabs li.active a:hover { /*--Makes sure that th } .tab_container { + margin: 0 0 20px; + padding: 15px 15px 0 15px; border: 1px solid #e8e8e8; border-top: none; overflow: hidden; background: #fff; } .tab_content { - padding: 20px; + padding: 0; +} +.tab_buttons { + padding: 0; } From 29042dd010898cb515be64a3a8129396b0b143f1 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 11 Aug 2011 14:25:42 +0200 Subject: [PATCH 04/27] Oops, en_US not en_EN ;-) --- application/language/{en_EN => en_US}/auth_lang.php | 0 application/language/{en_EN => en_US}/datamapper_lang.php | 0 application/language/{en_EN => en_US}/form_validation_lang.php | 0 application/language/{en_EN => en_US}/index.html | 0 application/language/{en_EN => en_US}/jobs_lang.php | 0 application/language/{en_EN => en_US}/projects_lang.php | 0 application/language/{en_EN => en_US}/settings_lang.php | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename application/language/{en_EN => en_US}/auth_lang.php (100%) rename application/language/{en_EN => en_US}/datamapper_lang.php (100%) rename application/language/{en_EN => en_US}/form_validation_lang.php (100%) rename application/language/{en_EN => en_US}/index.html (100%) rename application/language/{en_EN => en_US}/jobs_lang.php (100%) rename application/language/{en_EN => en_US}/projects_lang.php (100%) rename application/language/{en_EN => en_US}/settings_lang.php (100%) diff --git a/application/language/en_EN/auth_lang.php b/application/language/en_US/auth_lang.php similarity index 100% rename from application/language/en_EN/auth_lang.php rename to application/language/en_US/auth_lang.php diff --git a/application/language/en_EN/datamapper_lang.php b/application/language/en_US/datamapper_lang.php similarity index 100% rename from application/language/en_EN/datamapper_lang.php rename to application/language/en_US/datamapper_lang.php diff --git a/application/language/en_EN/form_validation_lang.php b/application/language/en_US/form_validation_lang.php similarity index 100% rename from application/language/en_EN/form_validation_lang.php rename to application/language/en_US/form_validation_lang.php diff --git a/application/language/en_EN/index.html b/application/language/en_US/index.html similarity index 100% rename from application/language/en_EN/index.html rename to application/language/en_US/index.html diff --git a/application/language/en_EN/jobs_lang.php b/application/language/en_US/jobs_lang.php similarity index 100% rename from application/language/en_EN/jobs_lang.php rename to application/language/en_US/jobs_lang.php diff --git a/application/language/en_EN/projects_lang.php b/application/language/en_US/projects_lang.php similarity index 100% rename from application/language/en_EN/projects_lang.php rename to application/language/en_US/projects_lang.php diff --git a/application/language/en_EN/settings_lang.php b/application/language/en_US/settings_lang.php similarity index 100% rename from application/language/en_EN/settings_lang.php rename to application/language/en_US/settings_lang.php From 1e4adc74fb1358fc3b4800071c925af7f903b836 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 11 Aug 2011 15:22:05 +0200 Subject: [PATCH 05/27] HTML5! --- application/views/auth/login.php | 95 ++++++++++++++++---------------- application/views/header.php | 8 ++- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/application/views/auth/login.php b/application/views/auth/login.php index fef9817..430e6e3 100644 --- a/application/views/auth/login.php +++ b/application/views/auth/login.php @@ -1,60 +1,63 @@ - - + + - + - ScattPort | Login +ScattPort | <?=_('Login');?> - - - - - - + + + + + + -
+
-
-

Scattport Login

+
+

Scattport

-

- " . $e . "

"; - if (isset($notice)) - foreach ($notice as $n) - echo "
" . $n . "
"; - if (isset($success)) - foreach ($success as $s) - echo "
" . $s . "
"; - ?> -

+" . $e . "

"; + if (isset($notice)) + foreach ($notice as $n) + echo "

" . $n . "

"; +?> +
+
    +
  • + +
    + + +
    +
  • +
  • + +
    + + +
    +
  • +
  • +
    + +
    +
  • +
+
-
-
    -
  • - -
    -
  • -
  • - -
    -
  • -
  • -
    - -
    -
  • -
-
- -

Passwort vergessen?

-
+

+
+ diff --git a/application/views/header.php b/application/views/header.php index 415ef81..09dd637 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -1,7 +1,8 @@ - - + + + - + ScattPort @@ -17,6 +18,7 @@ var SITE_URL = ''; + +
  • +
    + /> + +
    +
  • diff --git a/assets/css/form.css b/assets/css/form.css index 83aab14..2a290a3 100644 --- a/assets/css/form.css +++ b/assets/css/form.css @@ -62,4 +62,8 @@ p.success { p.error, p.req { color: #d8122d; font-weight: normal; -} \ No newline at end of file +} + +p.success strong, p.error strong, p.req strong { + text-transform: uppercase; +} From 6de1d1850a2932a955f5834add690228676411aa Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 11 Aug 2011 17:46:10 +0200 Subject: [PATCH 07/27] Add a small cross to close notifications --- application/views/global/notifications.php | 49 ++++++----------- assets/css/style.css | 62 ++++++++++++---------- 2 files changed, 51 insertions(+), 60 deletions(-) diff --git a/application/views/global/notifications.php b/application/views/global/notifications.php index a77456f..22a43b3 100644 --- a/application/views/global/notifications.php +++ b/application/views/global/notifications.php @@ -1,33 +1,16 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -if (is_array($messages)): - foreach ($messages as $type => $msgs): - if (count($msgs > 0)): - foreach ($msgs as $message): - echo ('
    ' . $message . '
    '); - endforeach; - endif; - endforeach; -endif; + $msgs): + if (count($msgs > 0)): + foreach ($msgs as $message): +?> +
    + + X +
    + diff --git a/assets/css/style.css b/assets/css/style.css index 78e5df6..041e3c1 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -21,39 +21,47 @@ p { margin: 0px 0px 20px 0px; line-height: 18px;} ul { margin: 5px 0px 15px 0px; padding: 0px;} li { margin-left: 20px;} -div.notice { - margin: 0 0 15px; - padding: 0 10px; - background: #fffbcc; - border: 1px solid #e6db55; - line-height: 25px; - color: #222; -} - -div.success { - margin: 0 0 15px; - padding: 0 10px; - background: #d1ecb8; - border: 1px solid #81c445; - line-height: 25px; - color: #222; -} - -div.error { - margin: 0 0 15px; - padding: 0 10px; - background: #ffebe8; - border: 1px solid #f0baa2; - line-height: 25px; - color: #222; -} - .editable { background: #fffbcc; } .clear { clear:both;} +/* Notifications */ + +#notifications div { + margin: 0 0 15px; + padding: 0 10px; + line-height: 25px; + color: #222; +} + +#notifications div a.cross { + float: right; + background: url(../images/icons/cross-small.png) right center no-repeat; + width: 16px; + height: 25px; +} + +#notifications div a.cross span { + display: none; +} + +div.notice { + background: #fffbcc; + border: 1px solid #e6db55; +} + +div.success { + background: #d1ecb8; + border: 1px solid #81c445; +} + +div.error { + background: #ffebe8; + border: 1px solid #f0baa2; +} + /* Header */ #header { From 353c87087241fd43e8adad1e31e893901e6d1c3e Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 11 Aug 2011 17:54:06 +0200 Subject: [PATCH 08/27] Fix project selection for HTML5 --- assets/css/style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/css/style.css b/assets/css/style.css index 041e3c1..e3f5d8b 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -86,7 +86,6 @@ div.error { #header .status { float: left; line-height: 45px; - padding: 12px 20px; } #header .menu { From 78c71b7ae99b1ce5f313a5719def0907625bb938 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 11 Aug 2011 19:05:31 +0200 Subject: [PATCH 09/27] Move settings to auth controller --- application/config/form_validation.php | 37 ++++++----- application/controllers/auth.php | 40 +++++------- application/controllers/settings.php | 62 ------------------- application/views/{user => auth}/settings.php | 2 +- application/views/header.php | 2 +- application/views/user/index.html | 10 --- 6 files changed, 38 insertions(+), 115 deletions(-) delete mode 100644 application/controllers/settings.php rename application/views/{user => auth}/settings.php (96%) delete mode 100755 application/views/user/index.html diff --git a/application/config/form_validation.php b/application/config/form_validation.php index e3339a1..8f779ed 100644 --- a/application/config/form_validation.php +++ b/application/config/form_validation.php @@ -122,31 +122,36 @@ $config['users/edit'] = array( * * @var array */ -$config['settings/index'] = array( +$config['auth/settings'] = array( array( - 'field' => 'firstname', - 'label' => _('First name'), - 'rules' => 'required|max_length[50]|trim', + 'field' => 'firstname', + 'label' => _('First name'), + 'rules' => 'required|max_length[50]|trim', ), array( - 'field' => 'lastname', - 'label' => _('Last name'), - 'rules' => 'required|max_length[50]|trim', + 'field' => 'lastname', + 'label' => _('Last name'), + 'rules' => 'required|max_length[50]|trim', ), array( - 'field' => 'email', - 'label' => _('Email address'), - 'rules' => 'required|valid_email|trim', + 'field' => 'email', + 'label' => _('Email address'), + 'rules' => 'required|valid_email|trim', ), array( - 'field' => 'institution', - 'label' => _('Institution'), - 'rules' => 'max_length[100]|trim', + 'field' => 'institution', + 'label' => _('Institution'), + 'rules' => 'max_length[100]|trim', ), array( - 'field' => 'phone', - 'label' => _('Phone number'), - 'rules' => 'regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]|trim', + 'field' => 'phone', + 'label' => _('Phone number'), + 'rules' => 'regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]|trim', + ), + array( + 'field' => 'new_password', + 'label' => _('New password'), + 'rules' => 'min_length[6]|matches[new_password_confirm]', ), ); diff --git a/application/controllers/auth.php b/application/controllers/auth.php index 9ecff75..e8bd34a 100644 --- a/application/controllers/auth.php +++ b/application/controllers/auth.php @@ -106,14 +106,9 @@ class Auth extends CI_Controller { * Allows users to edit their settings. */ public function settings() { - if (!$this->access->loggedIn()) { - redirect('auth/login', 'refresh'); - } + $user = $this->access->getCurrentUser(); - // validate the form - $this->form_validation->set_rules('new_password', _('New password'), 'min_length[' . $this->config->item('min_password_length', 'auth') . ']|max_length[' . $this->config->item('max_password_length', 'access') . ']|matches[new_password_confirm]'); - - if ($this->form_validation->run() == true) { + if ($this->form_validation->run() === true) { // change password if needed if ($this->input->post('new_password') != '') { $username = $this->session->userdata('username'); @@ -124,27 +119,22 @@ class Auth extends CI_Controller { } } - // update user - $updateData = array( - 'firstname' => $this->input->post('firstname'), - 'lastname' => $this->input->post('lastname'), - 'institution' => $this->input->post('institution'), - 'phone' => $this->input->post('phone'), - 'email' => $this->input->post('email'), + // update users table + $data = array( + 'email' => $this->input->post('email'), + 'firstname' => $this->input->post('firstname'), + 'lastname' => $this->input->post('lastname'), + 'institution' => $this->input->post('institution'), + 'phone' => $this->input->post('phone') ); - $this->access->updateUser($this->session->userdata('user_id'), $updateData); - // output JSON data - $this->output->set_content_type('application/json') - ->set_output(json_encode(array('success' => true))); - } else { - $data['success'] = true; - $data['data'] = $this->access->getCurrentUser(); - - // output JSON data - $this->output->set_content_type('application/json') - ->set_output(json_encode($data)); + if ($this->user->update($user['id'], $data)) { + $this->messages->add(_("Settings saved successfully"), 'success'); + redirect('auth/settings', 303); + } } + + $this->load->view('auth/settings', $user); } /** diff --git a/application/controllers/settings.php b/application/controllers/settings.php deleted file mode 100644 index 8c8f65b..0000000 --- a/application/controllers/settings.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/** - * @author Karsten Heiken - */ -class Settings extends CI_Controller { - - /** - * Constructor. - */ - public function __construct() { - parent::__construct(); - $this->load->model('program'); - $this->load->library('form_validation'); - } - - /** - * Show a list of all available programs. - */ - public function index() { - $user = $this->access->getCurrentUser(); - - if ($this->form_validation->run() === true) { - $data = array( - 'email' => $this->input->post('email'), - 'firstname' => $this->input->post('firstname'), - 'lastname' => $this->input->post('lastname'), - 'institution' => $this->input->post('institution'), - 'phone' => $this->input->post('phone') - ); - - if ($this->user->update($user['id'], $data)) { - $this->messages->add(_("Settings saved successfully"), 'success'); - redirect('settings', 303); - } - } - - $this->load->view('user/settings', $user); - } -} diff --git a/application/views/user/settings.php b/application/views/auth/settings.php similarity index 96% rename from application/views/user/settings.php rename to application/views/auth/settings.php index ce2a767..4195485 100644 --- a/application/views/user/settings.php +++ b/application/views/auth/settings.php @@ -1,7 +1,7 @@ load->view('header');?>
    - +

    diff --git a/application/views/header.php b/application/views/header.php index 09dd637..0eda012 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -29,7 +29,7 @@
    - +
    diff --git a/application/views/user/index.html b/application/views/user/index.html deleted file mode 100755 index c942a79..0000000 --- a/application/views/user/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - 403 Forbidden - - - -

    Directory access is forbidden.

    - - - \ No newline at end of file From dfba3049f1187a0bd8f7be5ee7de7fdf77dcad2c Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Mon, 15 Aug 2011 00:54:56 +0200 Subject: [PATCH 10/27] Delete lang.po files for now --- .../language/locale/de_DE/LC_MESSAGES/lang.po | 74 ------------------- .../language/locale/en_US/LC_MESSAGES/lang.po | 67 ----------------- 2 files changed, 141 deletions(-) delete mode 100644 application/language/locale/de_DE/LC_MESSAGES/lang.po delete mode 100644 application/language/locale/en_US/LC_MESSAGES/lang.po diff --git a/application/language/locale/de_DE/LC_MESSAGES/lang.po b/application/language/locale/de_DE/LC_MESSAGES/lang.po deleted file mode 100644 index 6584152..0000000 --- a/application/language/locale/de_DE/LC_MESSAGES/lang.po +++ /dev/null @@ -1,74 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-08-10 21:25+0200\n" -"PO-Revision-Date: 2011-08-10 22:00+0200\n" -"Last-Translator: Karsten Heiken \n" -"Language-Team: German <>\n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n!=1);\n" - -msgid "Users" -msgstr "Benutzer" - -msgid "Available users" -msgstr "Alle verfügbaren Benutzer" - -msgid "Username" -msgstr "Benutzername" - -msgid "Full name" -msgstr "Vollständiger Name" - -msgid "Actions" -msgstr "Aktionen" - -msgid "Edit" -msgstr "Bearbeiten" - -msgid "Delete" -msgstr "Löschen" - -msgid "Create new user" -msgstr "Neuen Benutzer erstellen" - -msgid "Edit user '%s'" -msgstr "Benutzer »%s« bearbeiten" - -msgid "Required information" -msgstr "Erforderliche Angaben" - -msgid "Optional information" -msgstr "Optionale Angaben" - -msgid "Email address" -msgstr "E-Mail-Adresse" - -msgid "First name" -msgstr "Vorname" - -msgid "Last name" -msgstr "Nachname" - -msgid "Institution" -msgstr "Institution" - -msgid "Phone number" -msgstr "Telefonnummer" - -msgid "Language" -msgstr "Sprache" - -msgid "Example" -msgstr "Beispiel" - -msgid "Save" -msgstr "Speichern" - -msgid "Cancel" -msgstr "Abbrechen" - diff --git a/application/language/locale/en_US/LC_MESSAGES/lang.po b/application/language/locale/en_US/LC_MESSAGES/lang.po deleted file mode 100644 index cba01f1..0000000 --- a/application/language/locale/en_US/LC_MESSAGES/lang.po +++ /dev/null @@ -1,67 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-08-10 21:25+0200\n" -"PO-Revision-Date: 2011-08-10 22:00+0200\n" -"Last-Translator: Karsten Heiken \n" -"Language-Team: English <>\n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n!=1);\n" - -msgid "users" -msgstr "Users" - -msgid "available_users" -msgstr "Available users" - -msgid "username" -msgstr "Username" - -msgid "realname" -msgstr "Name" - -msgid "options" -msgstr "Options" - -msgid "user_edit" -msgstr "Edit" - -msgid "user_create" -msgstr "Create new user" - -msgid "user_delete" -msgstr "Delete" - -msgid "create_user" -msgstr "Create a new user" - -msgid "edit_user" -msgstr "Edit user" - -msgid "field_username" -msgstr "Username" - -msgid "field_password" -msgstr "Password" - -msgid "field_password_confirm" -msgstr "Confirm password" - -msgid "field_firstname" -msgstr "First name" - -msgid "field_lastname" -msgstr "Last name" - -msgid "field_email" -msgstr "Email address" - -msgid "field_institution" -msgstr "Institution" - -msgid "field_phone" -msgstr "Phone number" From 086631fe74c3f3c38c96230774052288d2919d2b Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Mon, 15 Aug 2011 00:58:12 +0200 Subject: [PATCH 11/27] Clean-up user administration --- application/controllers/admin/users.php | 9 ++++----- application/models/user.php | 1 - application/views/admin/users/create.php | 13 ++++++------- application/views/admin/users/edit.php | 10 +++------- .../views/admin/users/{index.php => list.php} | 2 +- 5 files changed, 14 insertions(+), 21 deletions(-) rename application/views/admin/users/{index.php => list.php} (100%) diff --git a/application/controllers/admin/users.php b/application/controllers/admin/users.php index 65d12ee..43e568e 100644 --- a/application/controllers/admin/users.php +++ b/application/controllers/admin/users.php @@ -15,7 +15,6 @@ class Users extends CI_Controller { parent::__construct(); $this->load->library('form_validation'); $this->load->model('user'); - $this->load->config('form_validation'); } /** @@ -23,7 +22,7 @@ class Users extends CI_Controller { */ public function index() { $data['users'] = $this->user->getAll(); - $this->load->view('admin/users/index', $data); + $this->load->view('admin/users/list', $data); } /** @@ -41,7 +40,7 @@ class Users extends CI_Controller { ); if ($this->user->register($username, $this->input->post('password'), $this->input->post('email'), $data)) { - $this->messages->add(sprintf(_("The user '%s' was created"), $username), 'success'); + $this->messages->add(sprintf(_("The user '%s' has been created successfully"), $username), 'success'); redirect('admin/users', 303); } } @@ -71,7 +70,7 @@ class Users extends CI_Controller { ); if ($this->user->update($user['id'], $data)) { - $this->messages->add(sprintf(_("The user '%s' was updated"), $user['username']), 'success'); + $this->messages->add(sprintf(_("The user '%s' has been updated successfully"), $user['username']), 'success'); redirect('admin/users', 303); } } @@ -91,7 +90,7 @@ class Users extends CI_Controller { show_404(); } else { $this->user->delete($user['id']); - $this->messages->add(_("The selected user was deleted"), 'success'); + $this->messages->add(_("The selected user has been deleted successfully"), 'success'); redirect('admin/users', 303); } } diff --git a/application/models/user.php b/application/models/user.php index c8bea8f..2942dc6 100644 --- a/application/models/user.php +++ b/application/models/user.php @@ -251,7 +251,6 @@ class User extends CI_Model { if ($this->storeSalt) { $data['salt'] = $salt; } - print_r($data); $this->db->insert('users', array_merge($data, $additionalData)); diff --git a/application/views/admin/users/create.php b/application/views/admin/users/create.php index 9b88113..24bf724 100644 --- a/application/views/admin/users/create.php +++ b/application/views/admin/users/create.php @@ -12,6 +12,7 @@
    • + *
      @@ -20,6 +21,7 @@
    • + *
      @@ -27,6 +29,7 @@
    • + *
      @@ -34,6 +37,7 @@
    • + *
      @@ -41,6 +45,7 @@
    • + *
      @@ -48,6 +53,7 @@
    • + *
      @@ -71,13 +77,6 @@
    • -
    • - -
      - - -
      -

    diff --git a/application/views/admin/users/edit.php b/application/views/admin/users/edit.php index 5e02f10..9e4ed0b 100644 --- a/application/views/admin/users/edit.php +++ b/application/views/admin/users/edit.php @@ -12,6 +12,7 @@

    • + *
      @@ -19,6 +20,7 @@
    • + *
      @@ -26,6 +28,7 @@
    • + *
      @@ -49,13 +52,6 @@
    • -
    • - -
      - - -
      -

    diff --git a/application/views/admin/users/index.php b/application/views/admin/users/list.php similarity index 100% rename from application/views/admin/users/index.php rename to application/views/admin/users/list.php index 814dd39..3b73738 100644 --- a/application/views/admin/users/index.php +++ b/application/views/admin/users/list.php @@ -16,6 +16,7 @@ + @@ -27,7 +28,6 @@ - From 1e4587d5142eec7cc10fb24f31ed62a6a5d32749 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Mon, 15 Aug 2011 00:59:31 +0200 Subject: [PATCH 12/27] FIXME in MY_Session class --- application/libraries/MY_Session.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/libraries/MY_Session.php b/application/libraries/MY_Session.php index 9beff5c..e2b93de 100644 --- a/application/libraries/MY_Session.php +++ b/application/libraries/MY_Session.php @@ -72,6 +72,7 @@ class MY_Session extends CI_Session { $cookieData[$val] = $this->userdata[$val]; } + // FIXME Severity: Notice / Message: Undefined index: user_id $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->now, 'user_id' => $this->userdata['user_id'], 'session_id' => $newSessionID), array('session_id' => $oldSessionID)); // update users table if user is logged in From 5439add88a0ab98a9ddd0020c5d025187a55c7d4 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Mon, 15 Aug 2011 01:00:13 +0200 Subject: [PATCH 13/27] Fix admin links in dashboard --- application/views/dashboard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/dashboard.php b/application/views/dashboard.php index 13258f0..37ad1e1 100644 --- a/application/views/dashboard.php +++ b/application/views/dashboard.php @@ -21,7 +21,7 @@

    - +

    From 639f59378eac6733761b7c2a9c7146e7b7c6eef5 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Mon, 15 Aug 2011 01:02:12 +0200 Subject: [PATCH 14/27] Use ->isAdmin() in footer, instead of comparing the session data --- application/views/footer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/views/footer.php b/application/views/footer.php index 82678ca..0687b6c 100644 --- a/application/views/footer.php +++ b/application/views/footer.php @@ -1,12 +1,12 @@
      -
    • +
    • +
    @@ -15,6 +16,7 @@
    • + *
      @@ -22,6 +24,7 @@
    • + *
      @@ -29,6 +32,7 @@
    • + *
      @@ -59,9 +63,34 @@
    +
    +
      +
    • + +
      + + +
      +
    • +
    • + +
      + + +
      +
    • +
    • + +
      + + +
      +
    • +
    +

    - +

    From c2787d5260dadb2fface2ebb2fdaf60e377f54d2 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Tue, 16 Aug 2011 02:10:32 +0200 Subject: [PATCH 19/27] Fix bug with missing userID in sessions --- application/libraries/MY_Session.php | 45 ++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/application/libraries/MY_Session.php b/application/libraries/MY_Session.php index e2b93de..90fd5d6 100644 --- a/application/libraries/MY_Session.php +++ b/application/libraries/MY_Session.php @@ -23,6 +23,44 @@ class MY_Session extends CI_Session { return sha1(uniqid(microtime() . $this->CI->input->ip_address(), true)); } + /** + * Writes the session data. + * + * @see CI_Session::sess_write() + */ + public function sess_write() { + // are we saving custom data to the DB? If not, all we do is update the cookie + if ($this->sess_use_database === false) { + $this->_set_cookie(); + return; + } + + // set the custom userdata, the session data we will set in a second + $customUserdata = $this->userdata; + $cookieUserdata = array(); + + // before continuing, we need to determine if there is any custom data to deal with. + foreach (array('session_id', 'user_id', 'ip_address', 'user_agent', 'last_activity') as $val) { + unset($customUserdata[$val]); + $cookieUserdata[$val] = $this->userdata[$val]; + } + + // did we find any custom data? If not, we turn the empty array into a string + if (count($customUserdata) === 0) { + $customUserdata = ''; + } else { + // serialize the custom data array so we can store it + $customUserdata = $this->_serialize($customUserdata); + } + + // run the update query + $this->CI->db->where('session_id', $this->userdata['session_id']); + $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_id' => $this->userdata['user_id'], 'user_data' => $customUserdata)); + + // write the cookie. + $this->_set_cookie($cookieUserdata); + } + /** * Creates a new session. * @@ -33,7 +71,8 @@ class MY_Session extends CI_Session { 'session_id' => $this->generateHash(), 'ip_address' => $this->CI->input->ip_address(), 'user_agent' => substr($this->CI->input->user_agent(), 0, 50), - 'last_activity' => $this->now + 'last_activity' => $this->now, + 'user_id' => null, ); // save data to the DB if needed @@ -61,6 +100,7 @@ class MY_Session extends CI_Session { $this->userdata['session_id'] = $newSessionID; $this->userdata['last_activity'] = $this->now; + $this->userdata['user_id'] = array_key_exists('user_id', $this->userdata) ? $this->userdata['user_id'] : null; $cookieData = null; @@ -72,11 +112,10 @@ class MY_Session extends CI_Session { $cookieData[$val] = $this->userdata[$val]; } - // FIXME Severity: Notice / Message: Undefined index: user_id $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->now, 'user_id' => $this->userdata['user_id'], 'session_id' => $newSessionID), array('session_id' => $oldSessionID)); // update users table if user is logged in - if (array_key_exists('user_id', $this->userdata) && $this->userdata['user_id'] > 0) { + if (array_key_exists('user_id', $this->userdata) && !is_null($this->userdata['user_id'])) { $this->CI->db->update('users', array('last_activity' => $this->now), array('id' => $this->userdata['user_id'])); } } From e59cb9386a3a486d76c3506847f6314598c3102e Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 18 Aug 2011 03:25:01 +0200 Subject: [PATCH 20/27] CSS clean-up and fixes --- assets/css/form.css | 26 ++++-- assets/css/login.css | 22 +++-- assets/css/style.css | 189 ++++++++++++++++++++++++++++++++++++++----- assets/css/table.css | 18 ++++- 4 files changed, 223 insertions(+), 32 deletions(-) diff --git a/assets/css/form.css b/assets/css/form.css index 38cb201..4ab4f73 100644 --- a/assets/css/form.css +++ b/assets/css/form.css @@ -1,4 +1,5 @@ -/* Form Style */ +@CHARSET "UTF-8"; +/* Form styles */ form ul li { margin: 0 0 15px; @@ -50,10 +51,25 @@ select.drop { border: 1px solid #d2d2d2; } -input.short { width: 20%;} -input.medium { width: 45%;} -input.long { width:70%;} -input.max { width: 95%;} +input.short { + width: 20%; +} + +input.medium { + width: 45%; +} + +input.long { + width: 70%; +} + +input.max { + width: 95%; +} + +table input { + margin: 0 !important; +} p.success { color: #008000; diff --git a/assets/css/login.css b/assets/css/login.css index 40c0895..3950461 100644 --- a/assets/css/login.css +++ b/assets/css/login.css @@ -12,11 +12,23 @@ body { background: #404040; } -a { color: #0088cc; text-decoration: none;} -a:hover { text-decoration: underline;} -a img { border: none;} +a { + color: #08c; + text-decoration: none; +} -p { margin: 0px 0px 20px 0px; line-height: 18px;} +a:hover { + text-decoration: underline; +} + +a img { + border: none; +} + +p { + margin: 0 0 20px 0; + line-height: 18px; +} #box { margin: 40px auto; @@ -36,4 +48,4 @@ p { margin: 0px 0px 20px 0px; line-height: 18px;} .light { color: #ccc; text-transform: none; -} \ No newline at end of file +} diff --git a/assets/css/style.css b/assets/css/style.css index e3f5d8b..e770c31 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -1,3 +1,5 @@ +@CHARSET "UTF-8"; + * { margin: 0; padding: 0; @@ -12,20 +14,40 @@ body { /* Styles */ -a { color: #0088cc; text-decoration: none;} -a:hover { text-decoration: underline;} -a img { border: none;} +a { + color: #0088cc; + text-decoration: none; +} -p { margin: 0px 0px 20px 0px; line-height: 18px;} +a:hover { + text-decoration: underline; +} -ul { margin: 5px 0px 15px 0px; padding: 0px;} -li { margin-left: 20px;} +a img { + border: none; +} + +p { + margin: 0 0 20px 0; + line-height: 18px; +} + +ul { + margin: 5px 0 15px 0; + padding: 0; +} + +li { + margin-left: 20px; +} .editable { background: #fffbcc; } -.clear { clear:both;} +.clear { + clear: both; +} /* Notifications */ @@ -292,15 +314,22 @@ div.error { clear: both; } -#footer .left { float: left;} -#footer .right { float: right;} +#footer .left { + float: left; +} + +#footer .right { + float: right; +} /* Buttons */ + .buttons { float: left; padding-bottom: 20px; clear: both; } + a.button { color: #6e6e6e; font: bold 12px Helvetica, Arial, sans-serif; @@ -322,22 +351,28 @@ a.button { -moz-border-radius: 2px; margin-right: 10px; } + a.button.locked { color: #333; border-color: #999; - -moz-box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2) -webkit-box-shadow:0 2px 5px rgba(0, 0, 0, 0.2); + -moz-box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); + -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); } + a.button:hover { color: #333; border-color: #999; - -moz-box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2) -webkit-box-shadow:0 2px 5px rgba(0, 0, 0, 0.2); + -moz-box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); + -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); } + a.button:active { color: #000; border-color: #444; } + a.left { -webkit-border-top-right-radius: 0; -moz-border-radius-topright: 0; @@ -347,6 +382,7 @@ a.left { border-bottom-right-radius: 0; margin: 0; } + a.middle { border-radius: 0; -webkit-border-radius: 0; @@ -355,8 +391,12 @@ a.middle { margin: 0; border-left: solid 1px rgba(255, 255, 255, 0); } + a.middle:hover, -a.right:hover { border-left: solid 1px #999 } +a.right:hover { + border-left: solid 1px #999; +} + a.right { -webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0; @@ -367,68 +407,83 @@ a.right { border-left: solid 1px #f3f3f3; border-left: solid 1px rgba(255, 255, 255, 0); } + a.big { font-size: 16px; padding: 10px 15px; } + a.supersize { font-size: 20px; padding: 15px 20px; } + a.save { background: url(../images/icons/tick.png) 10px center no-repeat #f3f3f3; padding-left: 30px; } + a.add { background: url(../images/icons/plus-circle.png) 10px center no-repeat #f3f3f3; padding-left: 30px; } + a.delete { background: url(../images/button-sprite.png) 10px -59px no-repeat #f3f3f3; padding-left: 30px; } + a.flag { background: url(../images/button-sprite.png) 10px -94px no-repeat #f3f3f3; padding-left: 30px; } + a.cancel { background: url(../images/icons/slash.png) 10px center no-repeat #f3f3f3; padding-left: 30px; } + a.up { background: url(../images/button-sprite.png) 13px -131px no-repeat #f3f3f3; width: 18px; } + a.down { background: url(../images/button-sprite.png) 13px -166px no-repeat #f3f3f3; width: 18px; } + a.save-big { background: url(../images/button-sprite.png) 15px 13px no-repeat #f3f3f3; font-size: 16px; padding: 10px 15px 10px 35px; } + a.add-big { background: url(../images/button-sprite.png) 15px -21px no-repeat #f3f3f3; font-size: 16px; padding: 10px 15px 10px 35px; } + a.delete-big { background: url(../images/button-sprite.png) 15px -55px no-repeat #f3f3f3; font-size: 16px; padding: 10px 15px 10px 35px; } + a.flag-big { background: url(../images/button-sprite.png) 15px -90px no-repeat #f3f3f3; font-size: 16px; padding: 10px 15px 10px 35px; } + a.up-big { background: url(../images/button-sprite.png) 15px -126px no-repeat #f3f3f3; width: 18px; font-size: 16px; padding: 10px 15px; } + a.down-big { background: url(../images/button-sprite.png) 15px -161px no-repeat #f3f3f3; width: 18px; @@ -443,24 +498,26 @@ ul.tabs { padding: 0; float: left; list-style: none; - height: 27px; /*--Set height of tabs--*/ + height: 27px; /* Set height of tabs */ border-bottom: 1px solid #e8e8e8; border-left: 1px solid #e8e8e8; width: 100%; } + ul.tabs li { float: left; margin: 0; padding: 0; - height: 26px; /*--Subtract 1px from the height of the unordered list--*/ - line-height: 26px; /*--Vertically aligns the text within the tab--*/ + height: 26px; /* Subtract 1px from the height of the unordered list */ + line-height: 26px; /* Vertically aligns the text within the tab */ border: 1px solid #e8e8e8; border-left: none; - margin-bottom: -1px; /*--Pull the list item down 1px--*/ + margin-bottom: -1px; /* Pull the list item down 1px */ overflow: hidden; position: relative; background: #e0e0e0 url('../images/navigation-off.gif'); } + ul.tabs li a { text-decoration: none; color: #000; @@ -468,12 +525,15 @@ ul.tabs li a { padding: 1px 21px; outline: none; } + ul.tabs li a:hover { background: #f0f0f0; } -html ul.tabs li.active, html ul.tabs li.active a:hover { /*--Makes sure that the active tab does not listen to the hover properties--*/ + +html ul.tabs li.active, +html ul.tabs li.active a:hover { background: #fff; - border-bottom: 1px solid #fff; /*--Makes the active tab look like it's connected with its content--*/ + border-bottom: 1px solid #fff; /* Makes the active tab look like it's connected with its content */ } .tab_container { @@ -484,9 +544,102 @@ html ul.tabs li.active, html ul.tabs li.active a:hover { /*--Makes sure that th overflow: hidden; background: #fff; } + .tab_content { padding: 0; } + .tab_buttons { padding: 0; } + +/* JTip styles */ + +.form_info a, +.form_info a:active, +.form_info a:visited { + background-color: #d2d2d2; + font-size: 12px; + font-weight: bold; + margin-left: -3px; + padding: 4px; + color: #fff; + text-decoration: none; +} + +.form_info a:hover { + color: #000; + text-decoration: none; +} + +#JT_arrow_left { + background: url(../images/arrow-left.gif) left top no-repeat; + position: absolute; + z-index: 101; + left: -11px; + height: 23px; + width: 10px; + top: -3px; +} + +#JT_arrow_right { + background: url(../images/arrow-right.gif) left top no-repeat; + position: absolute; + z-index: 101; + height: 23px; + width: 11px; + top: -2px; +} + +#JT { + position: absolute; + z-index: 100; + border: 1px solid #ccc; + background-color: #fff; + margin-top: 5px; + font-size: 85%; +} + +#JT_copy { + padding: 5px; + color: #666; +} + +.JT_loader { + background: url(../images/ajax-loader.gif) center center no-repeat; + width: 100%; + height: 12px; +} + +#JT_close_left { + background-color: #ccc; + text-align: left; + padding-left: 4px; + padding-bottom: 2px; + padding-top: 1px; + font-weight: bold; + color: #000; +} + +#JT_close_right { + background-color: #ccc; + text-align: left; + padding-left: 4px; + padding-bottom: 2px; + padding-top: 1px; + font-weight: bold; + color: #000; +} + +#JT_copy p { + margin: 3px 0; +} + +#JT_copy img { + padding: 1px; + border: 1px solid #ccc; +} + +.jTip { + cursor: help; +} diff --git a/assets/css/table.css b/assets/css/table.css index d4b3833..5010dc6 100644 --- a/assets/css/table.css +++ b/assets/css/table.css @@ -1,4 +1,5 @@ -/* Table Style */ +@CHARSET "UTF-8"; +/* Table styles */ table { width: 99%; @@ -26,9 +27,17 @@ table td { border-bottom: 1px solid #d2d2d2; } -table td span.active { color: #55a34a;} -table td span.pending { color: #c5a059;} -table td span.closed { color: #a02b2b;} +table td span.active { + color: #55a34a; +} + +table td span.pending { + color: #c5a059; +} + +table td span.closed { + color: #a02b2b; +} table .odd { background: #f6f6f6; @@ -45,6 +54,7 @@ table .hover { table tbody tr:nth-child(even) { background: #fff; } + table tbody tr:nth-child(odd) { background: #f6f6f6; } From f33dadafae397bff92a66cf4d56b7247fedcd868 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 18 Aug 2011 03:26:06 +0200 Subject: [PATCH 21/27] Add a simple admin controller --- application/core/Admin_Controller.php | 44 +++++++++++++++++++++++++++ application/core/MY_Controller.php | 20 ------------ 2 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 application/core/Admin_Controller.php delete mode 100644 application/core/MY_Controller.php diff --git a/application/core/Admin_Controller.php b/application/core/Admin_Controller.php new file mode 100644 index 0000000..c114413 --- /dev/null +++ b/application/core/Admin_Controller.php @@ -0,0 +1,44 @@ + +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +/** + * Simple controller for admin pages. + * + * @author Eike Foken + */ +class Admin_Controller extends CI_Controller { + + /** + * Calls the parent constructor. + */ + public function __construct() { + parent::__construct(); + + if (!$this->access->isAdmin()) { + show_error(_('Shove off, this is for admins.')); + } + } +} + +/* End of file Admin_Controller.php */ +/* Location: ./application/core/Admin_Controller.php */ diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php deleted file mode 100644 index e425238..0000000 --- a/application/core/MY_Controller.php +++ /dev/null @@ -1,20 +0,0 @@ - -*/ -class MY_Controller extends CI_Controller { - - /** - * Calls the parent constructor and loads the relevant language file. - */ - public function __construct() { - parent::__construct(); - - // load relevant language file - $this->lang->load(strtolower($this->router->class)); - } - -} \ No newline at end of file From 16a7adc0d9526ee54e020f94bac4674512176032 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 18 Aug 2011 03:29:20 +0200 Subject: [PATCH 22/27] Add jTip --- application/views/header.php | 1 + assets/images/ajax-loader.gif | Bin 0 -> 1844 bytes assets/images/arrow-left.gif | Bin 0 -> 102 bytes assets/images/arrow-right.gif | Bin 0 -> 102 bytes assets/js/jtip.js | 158 ++++++++++++++++++++++++++++++++++ 5 files changed, 159 insertions(+) create mode 100644 assets/images/ajax-loader.gif create mode 100644 assets/images/arrow-left.gif create mode 100644 assets/images/arrow-right.gif create mode 100644 assets/js/jtip.js diff --git a/application/views/header.php b/application/views/header.php index 0eda012..964f0a8 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -14,6 +14,7 @@ + diff --git a/assets/images/ajax-loader.gif b/assets/images/ajax-loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..b5ed0ce8000c0a90f7a51335622ba87c958f7c81 GIT binary patch literal 1844 zcmb8wZBSF$83*voz31lM+?V7KkqyW?Ap}iAV!~U9;@X=4g1}N>6?Stzmo29Ixgl#@qhQwXfH`Vb(_8(drriN@x6Dp z#L2?9Q)W6{lfzF`Ds8*Z> zz_aPQuw8oUYBC3TZ=IkPvazC68%Q4|&8lA`b^ieR*hxNF`BD zf2|d(KV}zewik-Oo!>m3ojaHoAA?d*?m&%FmPc21ebBBn7M5w;2T+zPlerzuS#|a# zL)|I{3&bqvGLzuLxFX36uktg3kPye}17B z5vLwswp}1^eqx%=l^@lS&WEQ@hA-~Yd@tdXv{D6J3V_LDG^Nt&AGT@^Dh+S<9XQfK zXZ3e>lp30Ky3@LqTtFbDdU-@*e=bt;hIhS>(zcFf#wQR={XnnH03yd|%WFBwXPCRc z4c_TWdwLg+hkm;D+uF4-{PEzkQOifn!mhnpab<-?f1B+ra9@h8`f(w!a6hTf&}bS= zKWKGVHb)(HAJz3AiCO{Rfq-T|;MXc2z#%1_-tZ|UbugK+W~(j9*U_03lny-zBXe2;7`w z)i6XU!6+16YJx;YczKOK)m66kwOApwrWgH^|aaVU+5;u+VAR> zYeESke?tWi@(B|mR4C*Off4T>D9h{x?c2&q1jI%`dQB49DO=SLftuxoUe=&W)gg&| zN;x6_-k4Y{iWLWqNq$*0c5jDyPb4q>*f~q1`2De`nc8;CRo$eAD`?s^j011N=T}l| z##*Cgg4;j)#wKPcehGo6BUmG!&+bRK7|;Y51{D&o#ZW}-5j8)}oQPH{RxMETP`*%y zTZCvx3CvLBqpO*7Q#Le-MS0#WZdC}B1j9^KeW~ewNAcSZK$`e|Z zG+%?`Ti`&948!)VYN$X>z5mrLXH#8#PWF%*%Y?PXzwp#D@dKv3;w3@i8vD|gFhR$M zi(to_k=n^RL#kfPr0g5+{W1jqQ$}v3HF#p)isbc!9;YFfv#o5pNeJ)=xvvl@QUXPQ>=nYN?f4T@Dyw_zycB~z?EKWD3o i##-Ul*quUH%0sE2R)D@^8`;{oWfbSvB>O+2<@yf6PyWet1_o;YKk+K% literal 0 HcmV?d00001 diff --git a/assets/js/jtip.js b/assets/js/jtip.js new file mode 100644 index 0000000..d023e8f --- /dev/null +++ b/assets/js/jtip.js @@ -0,0 +1,158 @@ +/* + * JTip + * By Cody Lindley (http://www.codylindley.com) + * Under an Attribution, Share Alike License + * JTip is built on top of the very light weight jquery library. + */ + +/** + * On page load (as soon as it's ready) call JT_init + */ +$(document).ready(JT_init); + +/** + * Initializes JTip. + */ +function JT_init() { + $('a.jTip').hover(function() { + JT_show(this.href, this.id, this.name); + }, function() { + $('#JT').remove(); + }).click(function() { + return false; + }); +} + +/** + * Shows a tooltip. + * + * @param url + * @param linkId + * @param title + */ +function JT_show(url, linkId, title) { + if (title == false) title = ' '; + + var de = document.documentElement; + var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; + var hasArea = w - getAbsoluteLeft(linkId); + + var clickElementY = getAbsoluteTop(linkId) - 3; // set y position + var clickElementX = 0; + + var queryString = url.replace(/^[^\?]+\??/,''); + var params = parseQuery(queryString); + + if (params['width'] === undefined) { + params['width'] = 250; + } + if (params['link'] !== undefined) { + $('#' + linkId).bind('click', function() { + window.location = params['link']; + }); + $('#' + linkId).css('cursor','pointer'); + } + + if (hasArea > (params['width'] * 1) + 75) { + $('body').append('
    ' + title + '
    '); // right side + var arrowOffset = getElementWidth(linkId) + 11; + clickElementX = getAbsoluteLeft(linkId) + arrowOffset; // set x position + } else { + $('body').append('
    ' + title + '
    '); // left side + clickElementX = getAbsoluteLeft(linkId) - ((params['width']*1) + 15); //set x position + } + + $('#JT').css({ left: clickElementX + 'px', top: clickElementY + 'px' }); + $('#JT').show(); + $('#JT_copy').load(url); +} + +/** + * Gets the width of the tooltip. + * + * @param objectId + * @returns + */ +function getElementWidth(objectId) { + x = document.getElementById(objectId); + return x.offsetWidth; +} + +/** + * No description yet. + * + * @param objectId + * @returns + */ +function getAbsoluteLeft(objectId) { + // get an object left position from the upper left viewport corner + o = document.getElementById(objectId); + // get left position from the parent object + oLeft = o.offsetLeft; + // parse the parent hierarchy up to the document element + while (o.offsetParent != null) { + oParent = o.offsetParent; // get parent object reference + oLeft += oParent.offsetLeft; // add parent left position + o = oParent; + } + return oLeft; +} + +/** + * No description yet. + * + * @param objectId + * @returns + */ +function getAbsoluteTop(objectId) { + // get an object top position from the upper left viewport corner + o = document.getElementById(objectId); + // get top position from the parent object + oTop = o.offsetTop; + // parse the parent hierarchy up to the document element + while (o.offsetParent != null) { + oParent = o.offsetParent; // get parent object reference + oTop += oParent.offsetTop; // add parent top position + o = oParent; + } + return oTop; +} + +/** + * No description yet. + * + * @param query + */ +function parseQuery(query) { + var params = new Object(); + if (!query) { + return params; // return empty object + } + var pairs = query.split(/[;&]/); + + for (var i = 0; i < pairs.length; i++) { + var keyValue = pairs[i].split('='); + if (!keyValue || keyValue.length != 2) { + continue; + } + var key = unescape(keyValue[0]); + var val = unescape(keyValue[1]); + + val = val.replace(/\+/g, ' '); + params[key] = val; + } + return params; +} + +/** + * No description yet. + * + * @param event + */ +function blockEvents(event) { + if (event.target) { + event.preventDefault(); + } else { + event.returnValue = false; + } +} From 3e495b62f375fda468dbda761af47e6b7e5baa8f Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 18 Aug 2011 03:34:47 +0200 Subject: [PATCH 23/27] Error 403 if permission is denied --- application/core/Admin_Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/core/Admin_Controller.php b/application/core/Admin_Controller.php index c114413..48b34ce 100644 --- a/application/core/Admin_Controller.php +++ b/application/core/Admin_Controller.php @@ -35,7 +35,7 @@ class Admin_Controller extends CI_Controller { parent::__construct(); if (!$this->access->isAdmin()) { - show_error(_('Shove off, this is for admins.')); + show_error(_('Shove off, this is for admins.'), 403); } } } From 401812acbd84485d24a431884916c7674584e8a3 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 18 Aug 2011 04:13:04 +0200 Subject: [PATCH 24/27] Remove use of MySQL transactions --- application/models/user.php | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/application/models/user.php b/application/models/user.php index d70574d..91b50dc 100644 --- a/application/models/user.php +++ b/application/models/user.php @@ -1,4 +1,4 @@ -getUserByID($id); - $this->db->trans_begin(); - if (array_key_exists('username', $data) && $this->checkUsername($data['username']) && $user['username'] !== $data['username']) { - $this->db->trans_rollback(); - $this->access->setError('account_creation_duplicate_username'); + $this->messages->add(_('The entered username is already in use.'), 'error'); return false; } @@ -432,32 +431,18 @@ class User extends CI_Model { $this->db->update('users', $data, array('id' => $id)); } - if ($this->db->trans_status() === false) { - $this->db->trans_rollback(); - return false; - } - - $this->db->trans_commit(); - return true; + return $this->db->affected_rows() > 0; } /** - * Deletes the specified user. + * Deletes a specified user. * - * @return boolean + * @param string $id + * @return boolean Returns TRUE if the deletion was successful. */ public function delete($id) { - $this->db->trans_begin(); - $this->db->delete('users', array('id' => $id)); - - if ($this->db->trans_status() === false) { - $this->db->trans_rollback(); - return false; - } - - $this->db->trans_commit(); - return true; + return $this->db->affected_rows() > 0; } /** From 2903b367f150c9fc722836e766faf88788ecc581 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 18 Aug 2011 04:15:06 +0200 Subject: [PATCH 25/27] Add new model for program parameters --- application/controllers/ajax.php | 8 +- application/models/parameter.php | 140 +++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 application/models/parameter.php diff --git a/application/controllers/ajax.php b/application/controllers/ajax.php index fdbe9bd..c89a3d3 100644 --- a/application/controllers/ajax.php +++ b/application/controllers/ajax.php @@ -58,12 +58,10 @@ class Ajax extends CI_Controller { /** * Sorts a programs parameters. - * - * @param string $id */ - public function sort_parameters($programId) { - $this->load->model('program'); - $this->program->sortParameters($this->input->post('parameters'), $programId); + public function sort_parameters() { + $this->load->model('parameter'); + $this->parameter->sort($this->input->post('parameters')); } } \ No newline at end of file diff --git a/application/models/parameter.php b/application/models/parameter.php new file mode 100644 index 0000000..ac519c9 --- /dev/null +++ b/application/models/parameter.php @@ -0,0 +1,140 @@ + + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * Model for parameters. + * + * Each program has many parameters used for configuration of trials. + * + * @author Eike Foken + */ +class Parameter extends CI_Model { + + /** + * Contains the possible types for parameters. + * + * @var array + */ + private $availableTypes = array('boolean', 'integer', 'float', 'string', 'array'); + + /** + * Calls the parent constructor. + */ + public function __construct() { + parent::__construct(); + } + + /** + * Gets all available parameters for a program. + * + * @param string $programId + * @return array + */ + public function getAll($programId) { + return $this->db->order_by('sort_number ASC') + ->get_where('parameters', array('program_id' => $programId))->result_array(); + } + + /** + * Gets a specific parameter. + * + * @param string $id + */ + public function getById($id) { + return $this->db->get_where('parameters', array('id' => $id))->row_array(); + } + + /** + * Gets the possible parameter types. + */ + public function getTypes() { + return $this->availableTypes; + } + + /** + * Creates a new parameter. + * + * @param array $data + * @return mixed Returns the ID of the created parameter, or FALSE if + * the insert was unsuccessful. + */ + public function create($data) { + $this->load->helper('hash'); + + if (!isset($data['program_id'])) { + return false; + } + + do { // generate unique hash + $data['id'] = random_hash('16'); + } while ($this->db->where('id', $data['id'])->from('parameters')->count_all_results() > 0); + + // put new parameter to the end + $data['sort_number'] = $this->db->select_max('sort_number') + ->get_where('parameters', array('program_id' => $data['program_id'])) + ->row()->sort_number + 1; + + $this->db->insert('parameters', $data); + return $this->db->affected_rows() > 0 ? $data['id'] : false; + } + + /** + * Updates a parameter. + * + * @param array $data + * @param string $id + * @return boolean Returns TRUE if the update was successful. + */ + public function update($data, $id) { + $this->db->update('parameters', $data, array('id' => $id)); + return $this->db->affected_rows() == 1; + } + + /** + * Deletes a specified parameter. + * + * @param string $id + * @return boolean Returns TRUE if the deletion was successful. + */ + public function delete($id) { + $this->db->delete('parameters', array('id' => $id)); + return $this->db->affected_rows() == 1; + } + + /** + * Saves the order of an array of parameters. + * + * @param array $parameters + * @return boolean Returns TRUE if the new order was successfully saved. + */ + public function sort($parameters) { + foreach ($parameters as $number => $id) { + $this->db->update('parameters', array('sort_number' => $number), array('id' => $id)); + } + + return $this->db->affected_rows() > 0; + } +} + +/* End of file parameter.php */ +/* Location: ./application/models/parameter.php */ From c3732969539ff19ec808f1a32cb3a56992e94df2 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 18 Aug 2011 04:16:43 +0200 Subject: [PATCH 26/27] Implement program parameter management --- application/config/form_validation.php | 77 +++++++--- application/controllers/admin/parameters.php | 133 ++++++++++++++++++ application/controllers/admin/programs.php | 4 +- application/models/program.php | 12 +- application/views/admin/parameters/create.php | 73 ++++++++++ application/views/admin/parameters/edit.php | 74 ++++++++++ application/views/admin/programs/edit.php | 10 +- application/views/admin/programs/list.php | 2 +- 8 files changed, 343 insertions(+), 42 deletions(-) create mode 100644 application/controllers/admin/parameters.php create mode 100644 application/views/admin/parameters/create.php create mode 100644 application/views/admin/parameters/edit.php diff --git a/application/config/form_validation.php b/application/config/form_validation.php index 2a24c08..116dff5 100644 --- a/application/config/form_validation.php +++ b/application/config/form_validation.php @@ -36,6 +36,44 @@ $config['auth/forgot_password'] = array( ), ); +/** +* Rules for the settings page. +* +* @var array +*/ +$config['auth/settings'] = array( + array( + 'field' => 'firstname', + 'label' => _('First name'), + 'rules' => 'required|max_length[50]|trim', + ), + array( + 'field' => 'lastname', + 'label' => _('Last name'), + 'rules' => 'required|max_length[50]|trim', + ), + array( + 'field' => 'email', + 'label' => _('Email address'), + 'rules' => 'required|valid_email|trim', + ), + array( + 'field' => 'institution', + 'label' => _('Institution'), + 'rules' => 'max_length[100]|trim', + ), + array( + 'field' => 'phone', + 'label' => _('Phone number'), + 'rules' => 'regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]|trim', + ), + array( + 'field' => 'new_password', + 'label' => _('New password'), + 'rules' => 'min_length[6]|matches[new_password_confirm]', + ), +); + /** * Rules for creating users. * @@ -131,40 +169,35 @@ $config['programs/edit'] = array( ); /** - * Rules for the settings page. + * Rules for creating parameters. * * @var array */ -$config['auth/settings'] = array( +$config['parameters/create'] = array( array( - 'field' => 'firstname', - 'label' => _('First name'), - 'rules' => 'required|max_length[50]|trim', + 'field' => 'name', + 'label' => _('Name'), + 'rules' => 'required|max_length[255]|trim', ), array( - 'field' => 'lastname', - 'label' => _('Last name'), - 'rules' => 'required|max_length[50]|trim', + 'field' => 'readable', + 'label' => _('Human-readable name'), + 'rules' => 'required|max_length[100]|trim', ), array( - 'field' => 'email', - 'label' => _('Email address'), - 'rules' => 'required|valid_email|trim', + 'field' => 'unit', + 'label' => _('Name'), + 'rules' => 'max_length[20]|trim', ), array( - 'field' => 'institution', - 'label' => _('Institution'), - 'rules' => 'max_length[100]|trim', + 'field' => 'default_value', + 'label' => _('Default value'), + 'rules' => 'max_length[255]|trim', ), array( - 'field' => 'phone', - 'label' => _('Phone number'), - 'rules' => 'regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]|trim', - ), - array( - 'field' => 'new_password', - 'label' => _('New password'), - 'rules' => 'min_length[6]|matches[new_password_confirm]', + 'field' => 'type', + 'label' => _('Type'), + 'rules' => 'required|max_length[20]|trim', ), ); diff --git a/application/controllers/admin/parameters.php b/application/controllers/admin/parameters.php new file mode 100644 index 0000000..ca4289f --- /dev/null +++ b/application/controllers/admin/parameters.php @@ -0,0 +1,133 @@ + + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +require_once APPPATH . 'core/Admin_Controller.php'; + +/** + * + * @author Eike Foken + */ +class Parameters extends Admin_Controller { + + /** + * Calls the parent constructor. + */ + public function __construct() { + parent::__construct(); + $this->load->model('parameter'); + $this->load->model('program'); + } + + /** + * Allows admins to create a new parameter. + * + * @param string $programId + */ + public function create($programId = '') { + $program = $this->program->getByID($programId); + + if (empty($programId) || !isset($program['id'])) { + show_404(); + } + + if ($this->form_validation->run('parameters/create') === true) { + $paramName = $this->input->post('name'); + + $data = array( + 'program_id' => $program['id'], + 'name' => $paramName, + 'readable' => $this->input->post('readable'), + 'unit' => $this->input->post('unit'), + 'description' => $this->input->post('description'), + 'type' => $this->input->post('type'), + 'default_value' => $this->input->post('default_value'), + ); + + if ($this->parameter->create($data)) { + $this->messages->add(sprintf(_("The parameter '%s' has been successfully created."), $paramName), 'success'); + redirect('admin/programs/edit/' . $program['id'], 303); + } + } + + $data = array(); // empty the data array + $data['types'] = $this->parameter->getTypes(); + $data['program'] = $program; + + $this->load->view('admin/parameters/create', $data); + } + + /** + * Allows admins to edit a parameter. + * + * @param string $id + */ + public function edit($id = '') { + $parameter = $this->parameter->getByID($id); + + if (empty($id) || !isset($parameter['id'])){ + show_404(); + } + + if ($this->form_validation->run('parameters/create') === true) { + $data = array( + 'name' => $this->input->post('name'), + 'readable' => $this->input->post('readable'), + 'unit' => $this->input->post('unit'), + 'description' => $this->input->post('description'), + 'type' => $this->input->post('type'), + 'default_value' => $this->input->post('default_value'), + ); + + if ($this->parameter->update($data, $id)) { + $this->messages->add(sprintf(_("The parameter '%s' has been successfully updated."), $parameter['name']), 'success'); + redirect('admin/programs/edit/' . $parameter['program_id'], 303); + } + } + + $data = array(); // empty the data array + $data['types'] = $this->parameter->getTypes(); + $data['parameter'] = $parameter; + + $this->load->view('admin/parameters/edit', $data); + } + + /** + * Allows admins to delete a parameter. + * + * @param string $id + */ + public function delete($id = '') { + $parameter = $this->parameter->getByID($id); + + if (empty($id) || !isset($parameter['id'])) { + show_404(); + } else { + if ($this->parameter->delete($parameter['id'])) { + $this->messages->add(_('The selected parameter has been successfully deleted.'), 'success'); + } + redirect('admin/programs/edit/' . $parameter['program_id'], 303); + } + } +} + +/* End of file parameters.php */ +/* Location: ./application/controllers/admin/parameters.php */ diff --git a/application/controllers/admin/programs.php b/application/controllers/admin/programs.php index c7703c0..f613959 100644 --- a/application/controllers/admin/programs.php +++ b/application/controllers/admin/programs.php @@ -13,6 +13,7 @@ class Programs extends CI_Controller { parent::__construct(); $this->load->library('form_validation'); $this->load->model('program'); + $this->load->model('parameter'); } /** @@ -43,8 +44,9 @@ class Programs extends CI_Controller { } $data['program'] = $program; - $data['parameters'] = $this->program->getParameters($program['id']); + $data['parameters'] = $this->parameter->getAll($program['id']); $this->load->view('admin/programs/edit', $data); } + } \ No newline at end of file diff --git a/application/models/program.php b/application/models/program.php index 2a1e9d8..905979e 100644 --- a/application/models/program.php +++ b/application/models/program.php @@ -119,19 +119,9 @@ class Program extends CI_Model { * @return array The parameters */ public function getParameters($id) { - $query = $this->db->order_by('order ASC') + $query = $this->db->order_by('sort_number ASC') ->get_where('parameters', array('program_id' => $id)); return $query->result_array(); } - - /** - * - * @param string $programId - */ - public function sortParameters($order, $programId) { - foreach ($order as $key => $value) { - $this->db->update('parameters', array('order' => $key), array('id' => $value)); - } - } } diff --git a/application/views/admin/parameters/create.php b/application/views/admin/parameters/create.php new file mode 100644 index 0000000..2aca436 --- /dev/null +++ b/application/views/admin/parameters/create.php @@ -0,0 +1,73 @@ +load->view('header');?> + +
    + +
    +

    +
    + +
    +
    +
      +
    • + + * +
      + + +
      +
    • +
    • + + * +
      + + +
      +
    • +
    • + +
      + + +
      +
    • +
    • + +
      + + +
      +
    • +
    • + + * +
      + + +
      +
    • +
    • + +
      + + +
      +
    • +
    +

    + +

    +
    +
    +
    + +load->view('footer');?> \ No newline at end of file diff --git a/application/views/admin/parameters/edit.php b/application/views/admin/parameters/edit.php new file mode 100644 index 0000000..1c233b4 --- /dev/null +++ b/application/views/admin/parameters/edit.php @@ -0,0 +1,74 @@ +load->view('header');?> + +
    + +
    +

    +
    + +
    +
    +
      +
    • + + * +
      + + +
      +
    • +
    • + + * +
      + + +
      +
    • +
    • + +
      + + +
      +
    • +
    • + +
      + + +
      +
    • +
    • + + * +
      + + +
      +
    • +
    • + +
      + + +
      +
    • +
    +

    + + +

    +
    +
    +
    + +load->view('footer');?> \ No newline at end of file diff --git a/application/views/admin/programs/edit.php b/application/views/admin/programs/edit.php index a713d62..825665b 100644 --- a/application/views/admin/programs/edit.php +++ b/application/views/admin/programs/edit.php @@ -4,11 +4,7 @@ $(document).ready(function() { $('#parameters').tableDnD({ onDrop: function(table, row) { - /*var rows = table.tBodies[0].rows; - for (var i = 0; i < rows.length; i++) { - $(rows[i]).children().find('input[type=hidden]').val(i + 1); - }*/ - $.post(SITE_URL + 'ajax/sort_parameters/', $.tableDnD.serialize()); + $.post(SITE_URL + 'ajax/sort_parameters', $.tableDnD.serialize()); }, dragHandle: 'drag_handle' }); @@ -61,7 +57,7 @@ $(document).ready(function() { - | + |

    - +

    diff --git a/application/views/admin/programs/list.php b/application/views/admin/programs/list.php index e4f091f..19f9e1f 100644 --- a/application/views/admin/programs/list.php +++ b/application/views/admin/programs/list.php @@ -29,7 +29,7 @@ -

    +

    From bb2af33af8800011ac5cf2b10c2f96393e8bc6b6 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 18 Aug 2011 04:53:02 +0200 Subject: [PATCH 27/27] PHPDoc and clean-up in user and group models --- application/models/group.php | 27 +++++----- application/models/user.php | 101 ++++++++++++++++++++++------------- 2 files changed, 78 insertions(+), 50 deletions(-) diff --git a/application/models/group.php b/application/models/group.php index ba0d4e5..433bc0e 100644 --- a/application/models/group.php +++ b/application/models/group.php @@ -8,41 +8,40 @@ class Group extends CI_Model { /** - * Constructor. + * Calls the parent constructor. */ public function __construct() { parent::__construct(); } /** - * get + * Gets all groups. * - * @return object + * @return array */ public function get() { return $this->db->get('groups')->result_array(); } /** - * getGroupByID + * Gets a specific group. * - * @return object + * @param string $id + * @return array */ - public function getGroupByID($id) { - $this->db->where('id', $id); - return $this->db->get('groups')->row_array(); + public function getByID($id) { + return $this->db->get_where('groups', array('id' => $id))->row_array(); } /** - * getGroupByName + * Gets a specific group by it's name. * - * @return object + * @param string $name + * @return array */ - public function getGroupByName($name) { - $this->db->where('name', $name); - return $this->db->get('groups')->row_array(); + public function getByName($name) { + return $this->db->get_where('groups', array('name' => $name))->row_array(); } - } /* End of file group.php */ diff --git a/application/models/user.php b/application/models/user.php index 91b50dc..8f75d11 100644 --- a/application/models/user.php +++ b/application/models/user.php @@ -7,6 +7,20 @@ */ class User extends CI_Model { + /** + * Should the salt be stored in the database? + * + * @var boolean + */ + private $storeSalt; + + /** + * Contains the salt length. + * + * @var integer + */ + private $saltLength; + /** * Contains the forgotten password key. * @@ -104,7 +118,7 @@ class User extends CI_Model { $new = $this->hashPassword($new, $result->salt); if ($dbPassword === $old) { - // store the new password and reset the remember code so all remembered instances have to re-login + // reset the remember code so all remembered instances have to re-login $data = array('password' => $new, 'remember_code' => ''); $this->db->update('users', $data, array('username' => $username)); @@ -130,6 +144,7 @@ class User extends CI_Model { /** * Checks entered emails. * + * @param string $email * @return boolean */ public function checkEmail($email = '') { @@ -142,6 +157,7 @@ class User extends CI_Model { /** * Inserts a forgotten password key. * + * @param string $email * @return boolean */ public function forgottenPassword($email = '') { @@ -159,8 +175,10 @@ class User extends CI_Model { } /** - * Forgotten Password Complete + * Completes the forgotten password procedure. * + * @param string $code + * @param boolean $salt * @return string */ public function forgottenPasswordComplete($code, $salt = false) { @@ -175,7 +193,7 @@ class User extends CI_Model { $data = array( 'password' => $this->hashPassword($password, $salt), - 'forgotten_password_code' => null + 'forgotten_password_code' => null, ); $this->db->update('users', $data, array('forgotten_password_code' => $code)); @@ -186,15 +204,18 @@ class User extends CI_Model { } /** - * profile + * Gets a users profile. * - * @return boolean|object + * @param string $username + * @param boolean $isCode + * @return mixed */ public function profile($username = '', $isCode = false) { if (empty($username)) { @$username = $this->session->userdata('username'); - if(empty($username)) - return FALSE; + if (empty($username)) { + return false; + } } $this->db->select('users.*, groups.name AS `group`, groups.description AS `group_description`'); @@ -208,7 +229,7 @@ class User extends CI_Model { $query = $this->db->limit(1)->get('users'); - return $query->num_rows > 0 ? $query->row() : false; + return $query->num_rows() > 0 ? $query->row_array() : false; } /** @@ -259,8 +280,11 @@ class User extends CI_Model { } /** - * login + * Validates the given password against the username. * + * @param string $username + * @param string $password + * @param boolean $remember * @return boolean */ public function login($username, $password, $remember = false) { @@ -300,8 +324,11 @@ class User extends CI_Model { } /** - * get + * Gets users. * + * @param mixed $group + * @param integer $limit + * @param integer $offset * @return object */ public function get($group = false, $limit = null, $offset = null) { @@ -332,6 +359,7 @@ class User extends CI_Model { /** * Returns the number of users. * + * @param mixed $group * @return integer The number of users */ public function count($group = false) { @@ -346,6 +374,7 @@ class User extends CI_Model { /** * Gets a user by ID. * + * @param string $id * @return array */ public function getUserByID($id = false) { @@ -353,59 +382,58 @@ class User extends CI_Model { return false; } - $this->db->where('users.id', $id); - $this->db->limit(1); + $this->db->where('users.id', $id)->limit(1); return $this->get()->row_array(); } /** - * getUserByEmail + * Gets a user by email. * - * @return object + * @param string $email + * @return array */ public function getUserByEmail($email) { - $this->db->where('users.email', $email); - $this->db->limit(1); + $this->db->where('users.email', $email)->limit(1); return $this->get()->row_array(); } /** - * getUserByUsername + * Gets a user by username. * - * @return object + * @param string $username + * @return array */ public function getUserByUsername($username) { - $this->db->where('users.username', $username); - $this->db->limit(1); - return $this->get(); + $this->db->where('users.username', $username)->limit(1); + return $this->get()->row_array(); } /** - * getNewestUsers + * Gets a specified number of new users. * - * @return object + * @param integer $limit + * @return array */ public function getNewestUsers($limit = 10) { - $this->db->order_by('users.created_on DESC'); - $this->db->limit($limit); - return $this->get(); + $this->db->order_by('users.created_on DESC')->limit($limit); + return $this->get()->result_array(); } /** - * getUsersGroup + * Gets a users group. * - * @return object + * @param string $id + * @return array */ public function getUsersGroup($id = false) { // if no ID was passed use the current users ID $id || $id = $this->session->userdata('user_id'); - $user = $this->db->select('group_id')->where('id', $id)->get('users') - ->row(); + $user = $this->db->select('group_id')->where('id', $id)->get('users')->row(); return $this->db->select('name, description') - ->where('id', $user->group_id)->get('groups')->row(); + ->where('id', $user->group_id)->get('groups')->row_array(); } /** @@ -446,9 +474,10 @@ class User extends CI_Model { } /** - * updateLastLogin + * Updates a users last login time. * - * @return boolean + * @param string $id + * @return boolean Returns TRUE if the update was successful. */ public function updateLastLogin($id) { $this->db->update('users', array('last_login' => now()), array('id' => $id)); @@ -456,7 +485,7 @@ class User extends CI_Model { } /** - * loginRemembedUser + * Logs a remembed user in. * * @return boolean */ @@ -497,8 +526,9 @@ class User extends CI_Model { } /** - * rememberUser + * Remembers a user. * + * @param string $id * @return boolean */ private function rememberUser($id) { @@ -527,7 +557,6 @@ class User extends CI_Model { } return false; } - } /* End of file user.php */