diff --git a/.gitignore b/.gitignore index 953d1a5..493397e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ application/config/config.php application/config/database.php application/logs/* uploads/* +*.mo diff --git a/application/controllers/users.php b/application/controllers/users.php index e5acb80..c710934 100644 --- a/application/controllers/users.php +++ b/application/controllers/users.php @@ -67,7 +67,7 @@ class Users extends MY_Controller { array( 'field' => 'phone', 'label' => 'lang:field_phone', - 'rules' => 'trim|regex_match[/^\+\d{2,4}\w\d{2,4}\w\d{3,10}+$/i]', + 'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]', ) ); $this->form_validation->set_rules($config); @@ -127,7 +127,7 @@ class Users extends MY_Controller { array( 'field' => 'phone', 'label' => 'lang:field_phone', - //'rules' => 'trim|regex_match[/^\+\d{2,4}\w\d{2,4}\w\d{3,10}+$/i]', + 'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]', ) ); $this->form_validation->set_rules($config); @@ -156,12 +156,14 @@ class Users extends MY_Controller { * @param integer $id */ public function delete($id = '') { - if (!is_array($this->user->getUserByID())) { - show_404(); - } + $user = $this->user->getUserByID($id); - $this->user->delete($id); - $this->messages->add('The selected user was deleted', 'success'); - redirect('users', 200); + if (!isset($user) || !is_array($user) || !isset($user['id'])) { + show_404(); + } else { + $this->user->delete($user['id']); + $this->messages->add('The selected user was deleted', 'success'); + redirect('users', 200); + } } } \ No newline at end of file diff --git a/application/core/MY_Lang.php b/application/core/MY_Lang.php index bede557..5716079 100644 --- a/application/core/MY_Lang.php +++ b/application/core/MY_Lang.php @@ -7,11 +7,68 @@ */ class MY_Lang extends CI_Lang { + var $_gettext_language; + var $_gettext_domain; + var $_gettext_path; + /** * Calls the parent constructor. */ public function __construct() { parent::__construct(); + $this->_gettext_domain = 'lang'; + log_message('debug', "Gettext Class Initialized"); + + $this->load_gettext(); + } + + /** + * This method overides the original load method. It's duty is loading the + * domain files by config or by default internal settings. + * + * @param string $user_lang + */ + public function load_gettext($user_lang = false) { + if ($user_lang) { + $this->_gettext_language = $user_lang; + } else { + $this->_gettext_language = 'en_US'; + } + log_message('debug', 'The gettext language was set by parameter: ' . $this->_gettext_language); + + putenv("LC_ALL=$this->_gettext_language"); + setlocale(LC_ALL, $this->_gettext_language . ".utf8"); + + // set the path of .po files + $this->_gettext_path = APPPATH . 'language/locale'; + log_message('debug', 'Gettext Class path chosen is: ' . $this->_gettext_path); + + $filename = $this->_gettext_path . '/' . $this->_gettext_language . '/LC_MESSAGES/' . $this->_gettext_domain . '.mo'; + $mtime = filemtime($filename); + + $newFilename = $this->_gettext_path . '/' . $this->_gettext_language . '/LC_MESSAGES/' . $this->_gettext_domain . '_' . $mtime . '.mo'; + + if (!file_exists($newFilename)) { + $dir = scandir(dirname($filename)); + foreach ($dir as $file) { + // remove all the old files + if (!in_array($file, array('.', '..', $this->_gettext_domain . '.po', $this->_gettext_domain . '.mo'))) { + @unlink(dirname($filename) . '/' . $file); + } + } + + @copy($filename, $newFilename); + } + + $newDomain = $this->_gettext_domain . '_' . $mtime; + + bindtextdomain($newDomain, $this->_gettext_path); + bind_textdomain_codeset($newDomain, "UTF-8"); + textdomain($newDomain); + + log_message('debug', 'The gettext domain chosen is: '. $this->_gettext_domain); + + return true; } /** @@ -79,4 +136,7 @@ class MY_Lang extends CI_Lang { log_message('debug', 'Language file loaded: language/' . $idiom . '/' . $langfile); return true; } -} \ No newline at end of file +} + +/* End of file MY_Lang.php */ +/* Location: ./application/libraries/MY_Lang.php */ diff --git a/application/language/locale/de_DE/LC_MESSAGES/lang.po b/application/language/locale/de_DE/LC_MESSAGES/lang.po new file mode 100644 index 0000000..6584152 --- /dev/null +++ b/application/language/locale/de_DE/LC_MESSAGES/lang.po @@ -0,0 +1,74 @@ +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 new file mode 100644 index 0000000..cba01f1 --- /dev/null +++ b/application/language/locale/en_US/LC_MESSAGES/lang.po @@ -0,0 +1,67 @@ +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" diff --git a/application/views/admin/users/index.php b/application/views/admin/users/index.php index 50ee331..9857848 100644 --- a/application/views/admin/users/index.php +++ b/application/views/admin/users/index.php @@ -3,7 +3,7 @@
-

+

@@ -17,15 +17,15 @@ - | + | diff --git a/application/views/header.php b/application/views/header.php index d246b99..c64c76e 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -59,17 +59,6 @@
  • Neues Projekt
  • -session->userdata('group') == 'admins'): -?> -
  • Administration - -
  • -
    diff --git a/assets/js/scattport.js b/assets/js/scattport.js index 04f7cff..9b09d82 100644 --- a/assets/js/scattport.js +++ b/assets/js/scattport.js @@ -1,5 +1,5 @@ /** - * + * Gets the queued notifications. */ function getNotifications() { $.get(SITE_URL + 'ajax/get_notifications', function(data) { @@ -9,6 +9,19 @@ function getNotifications() { }); } +/** + * Asks the user if he is sure to delete an item. + * + * @param url + */ +function deleteConfirm(url) { + var answer = confirm('Are you sure?'); + + if (answer) { + window.location = url; + } +} + /** * Saves the changes done by in-place edit. *