From db787a3ab93da0c2141d33f3058f9dc2f34d6f2a Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 17 Dec 2010 20:36:36 +0000 Subject: reorganized the settings views and updated the pages to use new layout git-svn-id: http://code.elgg.org/elgg/trunk@7663 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/notification.php | 2 +- engine/lib/statistics.php | 4 +- engine/lib/users.php | 25 +++-------- engine/lib/usersettings.php | 35 +++++++++------ mod/notifications/start.php | 2 +- pages/settings/account.php | 27 ++++++++++++ pages/settings/index.php | 19 -------- pages/settings/plugins.php | 23 ---------- pages/settings/statistics.php | 15 ++++--- pages/settings/tools.php | 28 ++++++++++++ pages/settings/user.php | 22 ---------- views/default/core/settings/account.php | 15 +++++++ .../core/settings/account/default_access.php | 29 ++++++++++++ views/default/core/settings/account/email.php | 25 +++++++++++ views/default/core/settings/account/language.php | 32 ++++++++++++++ views/default/core/settings/account/name.php | 15 +++++++ .../core/settings/account/notifications.php | 51 ++++++++++++++++++++++ views/default/core/settings/account/password.php | 42 ++++++++++++++++++ views/default/core/settings/statistics.php | 6 +++ .../core/settings/statistics/numentities.php | 47 ++++++++++++++++++++ views/default/core/settings/statistics/online.php | 28 ++++++++++++ views/default/core/settings/tools.php | 25 +++++++++++ views/default/core/settings/tools/plugin.php | 34 +++++++++++++++ views/default/forms/account/settings.php | 1 + views/default/page/elements/topbar.php | 2 +- views/default/user/settings/default_access.php | 29 ------------ views/default/user/settings/email.php | 25 ----------- views/default/user/settings/language.php | 32 -------------- views/default/user/settings/name.php | 15 ------- views/default/user/settings/password.php | 42 ------------------ views/default/usersettings/form.php | 10 ----- views/default/usersettings/main.php | 11 ----- views/default/usersettings/main_opt/plugins.php | 15 ------- views/default/usersettings/main_opt/statistics.php | 13 ------ views/default/usersettings/main_opt/user.php | 13 ------ views/default/usersettings/notifications.php | 51 ---------------------- views/default/usersettings/plugins.php | 25 ----------- views/default/usersettings/plugins_opt/plugin.php | 34 --------------- views/default/usersettings/statistics.php | 9 ---- .../usersettings/statistics_opt/numentities.php | 47 -------------------- .../default/usersettings/statistics_opt/online.php | 28 ------------ views/default/usersettings/user.php | 6 --- 42 files changed, 447 insertions(+), 512 deletions(-) create mode 100644 pages/settings/account.php delete mode 100644 pages/settings/index.php delete mode 100644 pages/settings/plugins.php create mode 100644 pages/settings/tools.php delete mode 100644 pages/settings/user.php create mode 100644 views/default/core/settings/account.php create mode 100644 views/default/core/settings/account/default_access.php create mode 100644 views/default/core/settings/account/email.php create mode 100644 views/default/core/settings/account/language.php create mode 100644 views/default/core/settings/account/name.php create mode 100644 views/default/core/settings/account/notifications.php create mode 100644 views/default/core/settings/account/password.php create mode 100644 views/default/core/settings/statistics.php create mode 100644 views/default/core/settings/statistics/numentities.php create mode 100644 views/default/core/settings/statistics/online.php create mode 100644 views/default/core/settings/tools.php create mode 100644 views/default/core/settings/tools/plugin.php create mode 100644 views/default/forms/account/settings.php delete mode 100644 views/default/user/settings/default_access.php delete mode 100644 views/default/user/settings/email.php delete mode 100644 views/default/user/settings/language.php delete mode 100644 views/default/user/settings/name.php delete mode 100644 views/default/user/settings/password.php delete mode 100644 views/default/usersettings/form.php delete mode 100644 views/default/usersettings/main.php delete mode 100644 views/default/usersettings/main_opt/plugins.php delete mode 100644 views/default/usersettings/main_opt/statistics.php delete mode 100644 views/default/usersettings/main_opt/user.php delete mode 100644 views/default/usersettings/notifications.php delete mode 100644 views/default/usersettings/plugins.php delete mode 100644 views/default/usersettings/plugins_opt/plugin.php delete mode 100644 views/default/usersettings/statistics.php delete mode 100644 views/default/usersettings/statistics_opt/numentities.php delete mode 100644 views/default/usersettings/statistics_opt/online.php delete mode 100644 views/default/usersettings/user.php diff --git a/engine/lib/notification.php b/engine/lib/notification.php index 5a96b9623..5b53a4a10 100644 --- a/engine/lib/notification.php +++ b/engine/lib/notification.php @@ -360,7 +360,7 @@ function notification_init() { register_notification_handler("email", "email_notify_handler"); // Add settings view to user settings & register action - extend_elgg_settings_page('usersettings/notifications', 'usersettings/user'); + elgg_extend_view('forms/account/settings', 'core/settings/account/notifications'); elgg_register_plugin_hook_handler('usersettings:save', 'user', 'notification_user_settings_save'); } diff --git a/engine/lib/statistics.php b/engine/lib/statistics.php index 085584317..578985fd0 100644 --- a/engine/lib/statistics.php +++ b/engine/lib/statistics.php @@ -110,8 +110,8 @@ function get_online_users() { * @return void */ function statistics_init() { - extend_elgg_settings_page('usersettings/statistics_opt/online', 'usersettings/statistics'); - extend_elgg_settings_page('usersettings/statistics_opt/numentities', 'usersettings/statistics'); + elgg_extend_view('core/settings/statistics', 'core/settings/statistics/online'); + elgg_extend_view('core/settings/statistics', 'core/settings/statistics/numentities'); } /// Register init function diff --git a/engine/lib/users.php b/engine/lib/users.php index 076f7b9f7..4e34586a3 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1544,25 +1544,12 @@ function users_init() { elgg_register_widget_type('friends', elgg_echo("friends"), elgg_echo('friends:widget:description')); - // User name change - extend_elgg_settings_page('user/settings/name', 'usersettings/user', 1); - //elgg_register_action("user/name"); - - // User password change - extend_elgg_settings_page('user/settings/password', 'usersettings/user', 1); - //elgg_register_action("user/password"); - - // Add email settings - extend_elgg_settings_page('user/settings/email', 'usersettings/user', 1); - //elgg_register_action("email/save"); - - // Add language settings - extend_elgg_settings_page('user/settings/language', 'usersettings/user', 1); - - // Add default access settings - extend_elgg_settings_page('user/settings/default_access', 'usersettings/user', 1); - - //elgg_register_action("user/language"); + // extend the account settings form + elgg_extend_view('forms/account/settings', 'core/settings/account/name', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/password', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/email', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/language', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/default_access', 100); // Register the user type register_entity_type('user', ''); diff --git a/engine/lib/usersettings.php b/engine/lib/usersettings.php index 1696dd1cd..7192ea0fa 100644 --- a/engine/lib/usersettings.php +++ b/engine/lib/usersettings.php @@ -26,9 +26,12 @@ * @param int $priority Optional priority to govern the appearance in the list. * * @return bool + * @deprecated 1.8 Extend oone of the views in core/settings */ function extend_elgg_settings_page($new_settings_view, $view = 'usersettings/main', $priority = 500) { + // see views: /core/settings + elgg_deprecated_notice("extend_elgg_settings_page has been deprecated. Extend on of the settings views instead", 1.8); return elgg_extend_view($view, $new_settings_view, $priority); } @@ -66,24 +69,28 @@ function usersettings_pagesetup() { function usersettings_page_handler($page) { global $CONFIG; - $path = $CONFIG->path . "pages/settings/index.php"; + if (!isset($page[0])) { + $page[0] = 'user'; + } - if ($page[0]) { - switch ($page[0]) { - case 'user': - $path = $CONFIG->path . "pages/settings/user.php"; - break; - case 'statistics': - $path = $CONFIG->path . "pages/settings/statistics.php"; - break; - case 'plugins': - $path = $CONFIG->path . "pages/settings/plugins.php"; - break; - } + switch ($page[0]) { + case 'statistics': + $path = $CONFIG->path . "pages/settings/statistics.php"; + break; + case 'plugins': + $path = $CONFIG->path . "pages/settings/tools.php"; + break; + case 'user': + default: + $path = $CONFIG->path . "pages/settings/account.php"; + break; } if ($page[1]) { - set_input('username', $page[1]); + $user = get_user_by_username($page[1]); + elgg_set_page_owner_guid($user->guid); + } else { + elgg_set_page_owner_guid(get_loggedin_userid()); } require($path); diff --git a/mod/notifications/start.php b/mod/notifications/start.php index 15b079bda..57099dc4c 100644 --- a/mod/notifications/start.php +++ b/mod/notifications/start.php @@ -18,7 +18,7 @@ function notifications_plugin_init() { // Unset the default notification settings elgg_unregister_plugin_hook_handler('usersettings:save', 'user', 'notification_user-settings_save'); - elgg_unextend_view('usersettings/user', 'usersettings/notifications'); + elgg_unextend_view('core/settings/account', 'core/settings/account/notifications'); // update notifications based on relationships changing elgg_register_event_handler('delete', 'member', 'notifications_relationship_remove'); diff --git a/pages/settings/account.php b/pages/settings/account.php new file mode 100644 index 000000000..88e916658 --- /dev/null +++ b/pages/settings/account.php @@ -0,0 +1,27 @@ +canEdit())) { + set_page_owner(get_loggedin_userid()); +} + +$title = elgg_echo('usersettings:user'); + +$content .= elgg_view('core/settings/account'); + +$params = array( + 'content' => $content, + 'title' => $title, +); +$body = elgg_view_layout('one_sidebar', $params); + +echo elgg_view_page($title, $body); diff --git a/pages/settings/index.php b/pages/settings/index.php deleted file mode 100644 index dbc8c87da..000000000 --- a/pages/settings/index.php +++ /dev/null @@ -1,19 +0,0 @@ -canEdit())) { - set_page_owner(get_loggedin_userid()); -} - -// Forward to the user settings -forward('pg/settings/user/' . elgg_get_page_owner()->username . "/"); \ No newline at end of file diff --git a/pages/settings/plugins.php b/pages/settings/plugins.php deleted file mode 100644 index 657519d38..000000000 --- a/pages/settings/plugins.php +++ /dev/null @@ -1,23 +0,0 @@ -canEdit())) { - set_page_owner(get_loggedin_userid()); -} - -$content = elgg_view_title(elgg_echo("usersettings:plugins")); -$content .= elgg_view("usersettings/plugins", - array('installed_plugins' => get_installed_plugins())); - -$body = elgg_view_layout('one_column_with_sidebar', array('content' => $content)); - -echo elgg_view_page(elgg_echo("usersettings:plugins"), $body); diff --git a/pages/settings/statistics.php b/pages/settings/statistics.php index 741003308..165c31e8e 100644 --- a/pages/settings/statistics.php +++ b/pages/settings/statistics.php @@ -6,7 +6,7 @@ * @subpackage Core */ -// Make sure only valid admin users can see this +// Only logged in users gatekeeper(); // Make sure we don't open a security hole ... @@ -14,9 +14,14 @@ if ((!elgg_get_page_owner()) || (!elgg_get_page_owner()->canEdit())) { set_page_owner(get_loggedin_userid()); } -$content = elgg_view_title(elgg_echo("usersettings:statistics")); -$content .= elgg_view("usersettings/statistics"); +$title = elgg_echo("usersettings:statistics"); -$body = elgg_view_layout('one_column_with_sidebar', array('content' => $content)); +$content = elgg_view("core/settings/statistics"); -echo elgg_view_page(elgg_echo("usersettings:statistics"), $body); +$params = array( + 'content' => $content, + 'title' => $title, +); +$body = elgg_view_layout('one_sidebar', array('content' => $content)); + +echo elgg_view_page($title, $body); diff --git a/pages/settings/tools.php b/pages/settings/tools.php new file mode 100644 index 000000000..e1c247581 --- /dev/null +++ b/pages/settings/tools.php @@ -0,0 +1,28 @@ +canEdit())) { + set_page_owner(get_loggedin_userid()); +} + +$title = elgg_echo("usersettings:plugins"); + +$content = elgg_view("core/settings/tools", + array('installed_plugins' => get_installed_plugins())); + +$params = array( + 'content' => $content, + 'title' => $title, +); +$body = elgg_view_layout('one_sidebar', $params); + +echo elgg_view_page($title, $body); diff --git a/pages/settings/user.php b/pages/settings/user.php deleted file mode 100644 index 2a530548c..000000000 --- a/pages/settings/user.php +++ /dev/null @@ -1,22 +0,0 @@ -canEdit())) { - set_page_owner(get_loggedin_userid()); -} - -$content = elgg_view_title(elgg_echo('usersettings:user')); -$content .= elgg_view("usersettings/form"); - -$body = elgg_view_layout("one_column_with_sidebar", array('content' => $content)); - -echo elgg_view_page(elgg_echo("usersettings:user"), $body); diff --git a/views/default/core/settings/account.php b/views/default/core/settings/account.php new file mode 100644 index 000000000..86afb8ba1 --- /dev/null +++ b/views/default/core/settings/account.php @@ -0,0 +1,15 @@ +'; +$form_body .= '

'; +$form_body .= elgg_view('input/submit', array('value' => elgg_echo('save'))); +$form_body .= '

'; + +echo elgg_view('input/form', array('action' => "action/usersettings/save", 'body' => $form_body)); diff --git a/views/default/core/settings/account/default_access.php b/views/default/core/settings/account/default_access.php new file mode 100644 index 000000000..e7c280198 --- /dev/null +++ b/views/default/core/settings/account/default_access.php @@ -0,0 +1,29 @@ +allow_user_default_access) { + $user = elgg_get_page_owner(); + + if ($user) { + if (false === ($default_access = $user->getPrivateSetting('elgg_default_access'))) { + $default_access = $vars['config']->default_access; + } +?> +
+

+

+ : + 'default_access', 'value' => $default_access)); + + ?> +

+
+ +
+

+

+ : + 'email', 'value' => $user->email)); + + ?> +

+
+ +
+

+

+ + : language; + if ($user->language) { + $value = $user->language; + } + + echo elgg_view("input/pulldown", array('internalname' => 'language', 'value' => $value, 'options_values' => get_installed_translations())); + + ?> + +

+
+ 'name', 'value' => $user->name)); +echo elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $user->guid)); diff --git a/views/default/core/settings/account/notifications.php b/views/default/core/settings/account/notifications.php new file mode 100644 index 000000000..afb142ebe --- /dev/null +++ b/views/default/core/settings/account/notifications.php @@ -0,0 +1,51 @@ + +
+

+ +

+ + + $v) { +?> + + + + + + +
: +$k) { + $val = "yes"; + } else { + $val = "no"; + } + + echo elgg_view('input/radio', array( + 'internalname' => "method[$k]", + 'value' => $val, + 'options' => array( + elgg_echo('option:yes') => 'yes', + elgg_echo('option:no') => 'no' + ), + )); + +?> +
+

\ No newline at end of file diff --git a/views/default/core/settings/account/password.php b/views/default/core/settings/account/password.php new file mode 100644 index 000000000..0bd7f38f8 --- /dev/null +++ b/views/default/core/settings/account/password.php @@ -0,0 +1,42 @@ + +
+

+ + guid == get_loggedin_userid()) { + ?> +

+ : + 'current_password')); + ?> +

+ + +

+ : + 'password')); + ?> +

+ +

+ : 'password2')); + ?> +

+
+ +
+

+ + $entry) { + foreach ($entry as $a => $b) { + + //This function controls the alternating class + $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; + + if ($a == "__base__") { + $a = elgg_echo("item:{$k}"); + if (empty($a)) { + $a = $k; + } + } else { + $a = elgg_echo("item:{$k}:{$a}"); + if (empty($a)) { + $a = "$k $a"; + } + } + echo <<< END + + + + +END; + } + } + ?> +
{$a}:{$b}
+
+guid, "login", "", 'user', '', 1); + +if ($log) { + $logged_in = $log[0]->time_created; +} + +?> +
+

+ + + + + + +
name; ?>
email; ?>
time_created); ?>
+
\ No newline at end of file diff --git a/views/default/core/settings/tools.php b/views/default/core/settings/tools.php new file mode 100644 index 000000000..8f5ee4af6 --- /dev/null +++ b/views/default/core/settings/tools.php @@ -0,0 +1,25 @@ +".elgg_view('output/longtext', array('value' => elgg_echo("usersettings:plugins:description"))).""; + +$limit = get_input('limit', 10); +$offset = get_input('offset', 0); + +// Get the installed plugins +$installed_plugins = $vars['installed_plugins']; +$count = count($installed_plugins); + +// Display list of plugins +$n = 0; +foreach ($installed_plugins as $plugin => $data) { + if (is_plugin_enabled($plugin)) { + echo elgg_view("core/settings/tools/plugin", array('plugin' => $plugin, 'details' => $data)); + } +} \ No newline at end of file diff --git a/views/default/core/settings/tools/plugin.php b/views/default/core/settings/tools/plugin.php new file mode 100644 index 000000000..981d8d937 --- /dev/null +++ b/views/default/core/settings/tools/plugin.php @@ -0,0 +1,34 @@ + +
+

+ +
+ $plugin, 'entity' => find_plugin_usersettings($plugin, $user_guid), 'prefix' => 'user')) ?> +
+
+ elgg_get_site_url() . 'pg/settings/', + 'href' => elgg_get_site_url() . "pg/settings/user/{$user->username}", 'text' => '' . elgg_echo('settings'), 'class' => 'alt', )); diff --git a/views/default/user/settings/default_access.php b/views/default/user/settings/default_access.php deleted file mode 100644 index e7c280198..000000000 --- a/views/default/user/settings/default_access.php +++ /dev/null @@ -1,29 +0,0 @@ -allow_user_default_access) { - $user = elgg_get_page_owner(); - - if ($user) { - if (false === ($default_access = $user->getPrivateSetting('elgg_default_access'))) { - $default_access = $vars['config']->default_access; - } -?> -
-

-

- : - 'default_access', 'value' => $default_access)); - - ?> -

-
- -
-

-

- : - 'email', 'value' => $user->email)); - - ?> -

-
- -
-

-

- - : language; - if ($user->language) { - $value = $user->language; - } - - echo elgg_view("input/pulldown", array('internalname' => 'language', 'value' => $value, 'options_values' => get_installed_translations())); - - ?> - -

-
- 'name', 'value' => $user->name)); -echo elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $user->guid)); diff --git a/views/default/user/settings/password.php b/views/default/user/settings/password.php deleted file mode 100644 index 0bd7f38f8..000000000 --- a/views/default/user/settings/password.php +++ /dev/null @@ -1,42 +0,0 @@ - -
-

- - guid == get_loggedin_userid()) { - ?> -

- : - 'current_password')); - ?> -

- - -

- : - 'password')); - ?> -

- -

- : 'password2')); - ?> -

-
-".elgg_view('input/submit', array('value' => elgg_echo('save'), 'class' => 'submit-button usersettings_save')); - -echo elgg_view('input/form', array('action' => "action/usersettings/save", 'body' => $form_body)); \ No newline at end of file diff --git a/views/default/usersettings/main.php b/views/default/usersettings/main.php deleted file mode 100644 index d1cf85448..000000000 --- a/views/default/usersettings/main.php +++ /dev/null @@ -1,11 +0,0 @@ - elgg_echo("usersettings:description"))); diff --git a/views/default/usersettings/main_opt/plugins.php b/views/default/usersettings/main_opt/plugins.php deleted file mode 100644 index ab5743d36..000000000 --- a/views/default/usersettings/main_opt/plugins.php +++ /dev/null @@ -1,15 +0,0 @@ - - \ No newline at end of file diff --git a/views/default/usersettings/main_opt/statistics.php b/views/default/usersettings/main_opt/statistics.php deleted file mode 100644 index 0f3872143..000000000 --- a/views/default/usersettings/main_opt/statistics.php +++ /dev/null @@ -1,13 +0,0 @@ - - diff --git a/views/default/usersettings/main_opt/user.php b/views/default/usersettings/main_opt/user.php deleted file mode 100644 index d9f2b5677..000000000 --- a/views/default/usersettings/main_opt/user.php +++ /dev/null @@ -1,13 +0,0 @@ - - \ No newline at end of file diff --git a/views/default/usersettings/notifications.php b/views/default/usersettings/notifications.php deleted file mode 100644 index afb142ebe..000000000 --- a/views/default/usersettings/notifications.php +++ /dev/null @@ -1,51 +0,0 @@ - -
-

- -

- - - $v) { -?> - - - - - - -
: -$k) { - $val = "yes"; - } else { - $val = "no"; - } - - echo elgg_view('input/radio', array( - 'internalname' => "method[$k]", - 'value' => $val, - 'options' => array( - elgg_echo('option:yes') => 'yes', - elgg_echo('option:no') => 'no' - ), - )); - -?> -
-

\ No newline at end of file diff --git a/views/default/usersettings/plugins.php b/views/default/usersettings/plugins.php deleted file mode 100644 index c4df9e26b..000000000 --- a/views/default/usersettings/plugins.php +++ /dev/null @@ -1,25 +0,0 @@ -".elgg_view('output/longtext', array('value' => elgg_echo("usersettings:plugins:description"))).""; - -$limit = get_input('limit', 10); -$offset = get_input('offset', 0); - -// Get the installed plugins -$installed_plugins = $vars['installed_plugins']; -$count = count($installed_plugins); - -// Display list of plugins -$n = 0; -foreach ($installed_plugins as $plugin => $data) { - if (is_plugin_enabled($plugin)) { - echo elgg_view("usersettings/plugins_opt/plugin", array('plugin' => $plugin, 'details' => $data)); - } -} \ No newline at end of file diff --git a/views/default/usersettings/plugins_opt/plugin.php b/views/default/usersettings/plugins_opt/plugin.php deleted file mode 100644 index 981d8d937..000000000 --- a/views/default/usersettings/plugins_opt/plugin.php +++ /dev/null @@ -1,34 +0,0 @@ - -
-

- -
- $plugin, 'entity' => find_plugin_usersettings($plugin, $user_guid), 'prefix' => 'user')) ?> -
-
- \ No newline at end of file diff --git a/views/default/usersettings/statistics_opt/numentities.php b/views/default/usersettings/statistics_opt/numentities.php deleted file mode 100644 index 10d2b7c68..000000000 --- a/views/default/usersettings/statistics_opt/numentities.php +++ /dev/null @@ -1,47 +0,0 @@ - -
-

- - $entry) { - foreach ($entry as $a => $b) { - - //This function controls the alternating class - $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; - - if ($a == "__base__") { - $a = elgg_echo("item:{$k}"); - if (empty($a)) { - $a = $k; - } - } else { - $a = elgg_echo("item:{$k}:{$a}"); - if (empty($a)) { - $a = "$k $a"; - } - } - echo <<< END - - - - -END; - } - } - ?> -
{$a}:{$b}
-
-guid, "login", "", 'user', '', 1); - -if ($log) { - $logged_in = $log[0]->time_created; -} - -?> -
-

- - - - - - -
name; ?>
email; ?>
time_created); ?>
-
\ No newline at end of file diff --git a/views/default/usersettings/user.php b/views/default/usersettings/user.php deleted file mode 100644 index c6a56a14e..000000000 --- a/views/default/usersettings/user.php +++ /dev/null @@ -1,6 +0,0 @@ - \ No newline at end of file -- cgit v1.2.3