aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-23 16:27:05 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-23 16:27:05 +0000
commit737394eb15a2ef0c1f5a085d7f5958d2f3e66b89 (patch)
treed3d3d9f880e9ffd63b73d9f3ab83c1ce0fda825f
parentdc28ff0bed2216d97e24b1286c68190c843cb684 (diff)
downloadelgg-737394eb15a2ef0c1f5a085d7f5958d2f3e66b89.tar.gz
elgg-737394eb15a2ef0c1f5a085d7f5958d2f3e66b89.tar.bz2
Refs #76: User settings page (to Elgg Classic standard). Committing some work before shutting down for the day.
git-svn-id: https://code.elgg.org/elgg/trunk@1068 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/plugins.php36
-rw-r--r--engine/lib/usersettings.php51
-rw-r--r--engine/start.php1
-rw-r--r--languages/en.php20
-rw-r--r--usersettings/index.php26
-rw-r--r--usersettings/plugins/index.php22
-rw-r--r--usersettings/statistics/index.php22
-rw-r--r--usersettings/user/index.php22
-rw-r--r--views/default/admin/main_opt/plugins.php2
-rw-r--r--views/default/admin/main_opt/site.php2
-rw-r--r--views/default/admin/main_opt/statistics.php2
-rw-r--r--views/default/admin/main_opt/user.php2
-rw-r--r--views/default/object/plugin.php5
-rw-r--r--views/default/usersettings/main.php16
-rw-r--r--views/default/usersettings/main_opt/plugins.php19
-rw-r--r--views/default/usersettings/main_opt/statistics.php17
-rw-r--r--views/default/usersettings/main_opt/user.php17
-rw-r--r--views/default/usersettings/plugins.php43
-rw-r--r--views/default/usersettings/plugins_opt/plugin.php38
-rw-r--r--views/default/usersettings/statistics.php16
-rw-r--r--views/default/usersettings/user.php3
21 files changed, 375 insertions, 7 deletions
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index c3f1d0d25..073869a52 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -171,6 +171,42 @@
return false;
}
+
+ /**
+ * Find the plugin settings for a user.
+ *
+ * @param string $plugin_name Plugin name.
+ * @param int $user_guid The guid who's settings to retrieve.
+ */
+ function find_plugin_usersettings($plugin_name = "", $user_guid = 0)
+ {
+ $plugin_name = sanitise_string($plugin_name);
+ $user_guid = (int)$user_guid;
+
+ if (!$plugin_name)
+ $plugin_name = get_plugin_name();
+
+ if ($user_guid == 0) $user_guid = $_SESSION['user']->guid;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ return false;
+ }
/**
* Set a setting for a plugin.
diff --git a/engine/lib/usersettings.php b/engine/lib/usersettings.php
new file mode 100644
index 000000000..487ea9230
--- /dev/null
+++ b/engine/lib/usersettings.php
@@ -0,0 +1,51 @@
+<?php
+ /**
+ * Elgg user settings functions.
+ * Functions for adding and manipulating options on the user settings panel.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ /**
+ * Register a user settings page with the admin panel.
+ * This function extends the view "usersettings/main" with the provided view. This view should provide a description
+ * and either a control or a link to.
+ *
+ * Usage:
+ * - To add a control to the main admin panel then extend usersettings/main
+ * - To add a control to a new page create a page which renders a view usersettings/subpage (where subpage is your new page -
+ * nb. some pages already exist that you can extend), extend the main view to point to it, and add controls to your
+ * new view.
+ *
+ * At the moment this is essentially a wrapper around extend_view.
+ *
+ * @param string $new_settings_view The view associated with the control you're adding
+ * @param string $view The view to extend, by default this is 'usersettings/main'.
+ * @param int $priority Optional priority to govern the appearance in the list.
+ */
+ function extend_elgg_settings_page( $new_settings_view, $view = 'usersettings/main', $priority = 500)
+ {
+ return extend_view($view, $new_settings_view, $priority);
+ }
+
+ /**
+ * Initialise the admin page.
+ */
+ function usersettings_init()
+ {
+ // Add plugin main menu option (last)
+ extend_elgg_settings_page('usersettings/main_opt/statistics', 'usersettings/main');
+ extend_elgg_settings_page('usersettings/main_opt/user', 'usersettings/main');
+ extend_elgg_settings_page('usersettings/main_opt/plugins', 'usersettings/main', 999); // Always last
+
+ }
+
+ /// Register init function
+ register_elgg_event_handler('init','system','usersettings_init');
+
+?> \ No newline at end of file
diff --git a/engine/start.php b/engine/start.php
index 3d59b1894..174c8f8b4 100644
--- a/engine/start.php
+++ b/engine/start.php
@@ -119,7 +119,6 @@
asort($files);
// Include them
-
foreach($files as $file) {
if (isset($CONFIG->debug) && $CONFIG->debug) error_log("Loading $file...");
if (!@include_once($file))
diff --git a/languages/en.php b/languages/en.php
index fbeb84678..d5f45176d 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -281,6 +281,26 @@
'admin:user:ban:yes' => "User banned.",
'admin:user:delete:no' => "Can not delete user",
'admin:user:delete:yes' => "User deleted",
+
+ /**
+ * User settings
+ */
+ 'usersettings:description' => "The user settings panel allows you to control all your personal settings, from user management to how plugins behave. Choose an option below to get started.",
+
+ 'usersettings:statistics' => "Your statistics",
+ 'usersettings:statistics:description' => "This panel will allow you to view statistics about you.",
+ 'usersettings:statistics:opt:description' => "View statistical information about users and objects on your site.",
+ 'usersettings:statistics:opt:linktext' => "View statistics...",
+
+ 'usersettings:user' => "Your settings",
+ 'usersettings:user:opt:description' => "This allows you to control user settings.",
+ 'usersettings:user:opt:linktext' => "Configure your user settings...",
+
+ 'usersettings:plugins' => "Tools",
+ 'usersettings:plugins:opt:description' => "Configure settings for your active tools.",
+ 'usersettings:plugins:opt:linktext' => "Configure your tools...",
+
+ 'usersettings:plugins:description' => "This panel allows you to control and configure the personal settings for the tools installed by your system administrator.",
/**
diff --git a/usersettings/index.php b/usersettings/index.php
new file mode 100644
index 000000000..47cf9caba
--- /dev/null
+++ b/usersettings/index.php
@@ -0,0 +1,26 @@
+<?php
+ /**
+ * Elgg user settings system index
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Get the Elgg framework
+ require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+ // Make sure only valid users can see this
+ gatekeeper();
+
+
+
+ /// Default settings
+
+
+ // Display main admin menu
+ page_draw(elgg_echo("admin"),elgg_view_layout("one_column", elgg_view("usersettings/main")));
+?> \ No newline at end of file
diff --git a/usersettings/plugins/index.php b/usersettings/plugins/index.php
new file mode 100644
index 000000000..d9c5de6fb
--- /dev/null
+++ b/usersettings/plugins/index.php
@@ -0,0 +1,22 @@
+<?php
+ /**
+ * Elgg user settings functions.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Get the Elgg framework
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ // Make sure only valid admin users can see this
+ gatekeeper();
+
+
+ // Display main admin menu
+ page_draw(elgg_echo("usersettings:plugins"),elgg_view_layout("one_column",elgg_view("usersettings/plugins")));
+?> \ No newline at end of file
diff --git a/usersettings/statistics/index.php b/usersettings/statistics/index.php
new file mode 100644
index 000000000..303838a81
--- /dev/null
+++ b/usersettings/statistics/index.php
@@ -0,0 +1,22 @@
+<?php
+ /**
+ * Elgg user settings functions.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Get the Elgg framework
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ // Make sure only valid admin users can see this
+ gatekeeper();
+
+
+ // Display main admin menu
+ page_draw(elgg_echo("usersettings:statistics"),elgg_view_layout("one_column",elgg_view("usersettings/statistics")));
+?> \ No newline at end of file
diff --git a/usersettings/user/index.php b/usersettings/user/index.php
new file mode 100644
index 000000000..274e86e9b
--- /dev/null
+++ b/usersettings/user/index.php
@@ -0,0 +1,22 @@
+<?php
+ /**
+ * Elgg user settings functions.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Get the Elgg framework
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ // Make sure only valid admin users can see this
+ gatekeeper();
+
+
+ // Display main admin menu
+ page_draw(elgg_echo("usersettings:user"),elgg_view_layout("one_column",elgg_view("usersettings/user")));
+?> \ No newline at end of file
diff --git a/views/default/admin/main_opt/plugins.php b/views/default/admin/main_opt/plugins.php
index f110007a8..64b6dade9 100644
--- a/views/default/admin/main_opt/plugins.php
+++ b/views/default/admin/main_opt/plugins.php
@@ -15,5 +15,5 @@
<div class="admin-menu-option">
<h2><?php echo elgg_echo('admin:plugins'); ?> </h2>
<p><?php echo elgg_echo('admin:plugins:opt:description'); ?><br />
- <a href="<?php echo $CONFIG->wwwroot . "admin/plugins/"; ?>"><?php echo elgg_echo('admin:plugins:opt:linktext'); ?></a></p>
+ <a href="<?php echo $CONFIG->wwwroot . "pg/admin/plugins/"; ?>"><?php echo elgg_echo('admin:plugins:opt:linktext'); ?></a></p>
</div> \ No newline at end of file
diff --git a/views/default/admin/main_opt/site.php b/views/default/admin/main_opt/site.php
index 40373e647..258c6647a 100644
--- a/views/default/admin/main_opt/site.php
+++ b/views/default/admin/main_opt/site.php
@@ -13,5 +13,5 @@
<div class="admin-menu-option">
<h2><?php echo elgg_echo('admin:site'); ?> </h2>
<p><?php echo elgg_echo('admin:site:opt:description'); ?><br />
- <a href="<?php echo $CONFIG->wwwroot . "admin/site/"; ?>"><?php echo elgg_echo('admin:site:opt:linktext'); ?></a></p>
+ <a href="<?php echo $CONFIG->wwwroot . "pg/admin/site/"; ?>"><?php echo elgg_echo('admin:site:opt:linktext'); ?></a></p>
</div> \ No newline at end of file
diff --git a/views/default/admin/main_opt/statistics.php b/views/default/admin/main_opt/statistics.php
index da37decf6..524fe2963 100644
--- a/views/default/admin/main_opt/statistics.php
+++ b/views/default/admin/main_opt/statistics.php
@@ -13,5 +13,5 @@
<div class="admin-menu-option">
<h2><?php echo elgg_echo('admin:statistics'); ?> </h2>
<p><?php echo elgg_echo('admin:statistics:opt:description'); ?><br />
- <a href="<?php echo $CONFIG->wwwroot . "admin/statistics/"; ?>"><?php echo elgg_echo('admin:statistics:opt:linktext'); ?></a></p>
+ <a href="<?php echo $CONFIG->wwwroot . "pg/admin/statistics/"; ?>"><?php echo elgg_echo('admin:statistics:opt:linktext'); ?></a></p>
</div>
diff --git a/views/default/admin/main_opt/user.php b/views/default/admin/main_opt/user.php
index 8505098fd..416cca6ea 100644
--- a/views/default/admin/main_opt/user.php
+++ b/views/default/admin/main_opt/user.php
@@ -13,5 +13,5 @@
<div class="admin-menu-option">
<h2><?php echo elgg_echo('admin:user'); ?> </h2>
<p><?php echo elgg_echo('admin:user:opt:description'); ?><br />
- <a href="<?php echo $CONFIG->wwwroot . "admin/user/"; ?>"><?php echo elgg_echo('admin:user:opt:linktext'); ?></a></p>
+ <a href="<?php echo $CONFIG->wwwroot . "pg/admin/user/"; ?>"><?php echo elgg_echo('admin:user:opt:linktext'); ?></a></p>
</div> \ No newline at end of file
diff --git a/views/default/object/plugin.php b/views/default/object/plugin.php
index edaf1f0db..12e22bd15 100644
--- a/views/default/object/plugin.php
+++ b/views/default/object/plugin.php
@@ -12,13 +12,14 @@
$entity = $vars['entity'];
$plugin = $vars['plugin'];
-
+ $prefix = $vars['prefix']; // Do we want to show admin settings (default) or user settings
+
?>
<div>
<form action="<?php echo $vars['url']; ?>action/plugins/settings/save" method="post">
<?php
- echo elgg_view("settings/{$plugin}/edit",$vars);
+ echo elgg_view("{$prefix}settings/{$plugin}/edit",$vars);
?>
<p>
diff --git a/views/default/usersettings/main.php b/views/default/usersettings/main.php
new file mode 100644
index 000000000..1b0ed11e8
--- /dev/null
+++ b/views/default/usersettings/main.php
@@ -0,0 +1,16 @@
+<?php
+ /**
+ * Elgg user main settings page.
+ * Functions for adding and manipulating options on the user settings panel.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Description of what's going on
+ echo "<p>" . nl2br(elgg_echo("usersettings:description")) . "</p>";
+?> \ No newline at end of file
diff --git a/views/default/usersettings/main_opt/plugins.php b/views/default/usersettings/main_opt/plugins.php
new file mode 100644
index 000000000..7a5030579
--- /dev/null
+++ b/views/default/usersettings/main_opt/plugins.php
@@ -0,0 +1,19 @@
+<?php
+ /**
+ * Elgg plugin sub-component on the main menu.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ global $CONFIG;
+?>
+<div class="admin-menu-option">
+ <h2><?php echo elgg_echo('usersettings:plugins'); ?> </h2>
+ <p><?php echo elgg_echo('usersettings:plugins:opt:description'); ?><br />
+ <a href="<?php echo $CONFIG->wwwroot . "pg/usersettings/plugins/"; ?>"><?php echo elgg_echo('usersettings:plugins:opt:linktext'); ?></a></p>
+</div> \ No newline at end of file
diff --git a/views/default/usersettings/main_opt/statistics.php b/views/default/usersettings/main_opt/statistics.php
new file mode 100644
index 000000000..973c4f7ce
--- /dev/null
+++ b/views/default/usersettings/main_opt/statistics.php
@@ -0,0 +1,17 @@
+<?php
+ /**
+ * Elgg satistics sub-component on the main menu.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+?>
+<div class="admin-menu-option">
+ <h2><?php echo elgg_echo('usersettings:statistics'); ?> </h2>
+ <p><?php echo elgg_echo('usersettings:statistics:opt:description'); ?><br />
+ <a href="<?php echo $CONFIG->wwwroot . "pg/usersettings/statistics/"; ?>"><?php echo elgg_echo('usersettings:statistics:opt:linktext'); ?></a></p>
+</div>
diff --git a/views/default/usersettings/main_opt/user.php b/views/default/usersettings/main_opt/user.php
new file mode 100644
index 000000000..77d3340e3
--- /dev/null
+++ b/views/default/usersettings/main_opt/user.php
@@ -0,0 +1,17 @@
+<?php
+ /**
+ * Elgg user sub-component on the main menu.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+?>
+<div class="admin-menu-option">
+ <h2><?php echo elgg_echo('usersettings:user'); ?> </h2>
+ <p><?php echo elgg_echo('usersettings:user:opt:description'); ?><br />
+ <a href="<?php echo $CONFIG->wwwroot . "pg/usersettings/user/"; ?>"><?php echo elgg_echo('usersettings:user:opt:linktext'); ?></a></p>
+</div> \ No newline at end of file
diff --git a/views/default/usersettings/plugins.php b/views/default/usersettings/plugins.php
new file mode 100644
index 000000000..730950178
--- /dev/null
+++ b/views/default/usersettings/plugins.php
@@ -0,0 +1,43 @@
+<?php
+ /**
+ * Elgg plugin specific user settings.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Description of what's going on
+ echo "<p>" . nl2br(elgg_echo("usersettings:plugins:description")) . "</p>";
+
+ $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 (($n>=$offset) && ($n < $offset+$limit))
+ echo elgg_view("usersettings/plugins_opt/plugin", array('plugin' => $plugin, 'details' => $data));
+
+ $n++;
+ }
+
+ // Diplay nav
+ if ($count)
+ {
+ echo elgg_view('navigation/pagination',array(
+ 'baseurl' => $_SERVER['REQUEST_URI'],
+ 'offset' => $offset,
+ 'count' => $count,
+ ));
+ }
+?> \ No newline at end of file
diff --git a/views/default/usersettings/plugins_opt/plugin.php b/views/default/usersettings/plugins_opt/plugin.php
new file mode 100644
index 000000000..228245efd
--- /dev/null
+++ b/views/default/usersettings/plugins_opt/plugin.php
@@ -0,0 +1,38 @@
+<?php
+ /**
+ * Elgg plugin manifest class
+ *
+ * This file renders a plugin for the admin screen, including active/deactive, manifest details & display plugin
+ * settings.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+
+ $plugin = $vars['plugin'];
+ $details = $vars['details'];
+
+ $active = $details['active'];
+ $manifest = $details['manifest'];
+
+ $user_guid = $details['user_guid'];
+ if ($user_guid) $user_guid = $_SESSION['user']->guid;
+?>
+<div id="plugin_details" class="<?php if ($active) echo "active"; else "not-active" ?>">
+ <div><h2><?php echo $plugin; ?></h2></div>
+
+ <?php if ($manifest) { ?>
+ <div><?php echo $manifest['description'] ?></div>
+ <?php } ?>
+
+ <?php if (elgg_view("usersettings/{$plugin}/edit")) { ?>
+ <div id="<?php echo $plugin; ?>_settings">
+ <?php echo elgg_view("object/plugin", array('plugin' => $plugin, 'entity' => find_plugin_usersettings($plugin, $user_guid), 'prefix' => 'user')) ?>
+ </div>
+ <?php } ?>
+</div> \ No newline at end of file
diff --git a/views/default/usersettings/statistics.php b/views/default/usersettings/statistics.php
new file mode 100644
index 000000000..f01e48bc8
--- /dev/null
+++ b/views/default/usersettings/statistics.php
@@ -0,0 +1,16 @@
+<?php
+ /**
+ * Elgg settings specific user settings.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ global $CONFIG;
+
+ echo "<p>" . nl2br(elgg_echo("usersettings:statistics:description")) . "</p>";
+?> \ No newline at end of file
diff --git a/views/default/usersettings/user.php b/views/default/usersettings/user.php
new file mode 100644
index 000000000..15c5adc7f
--- /dev/null
+++ b/views/default/usersettings/user.php
@@ -0,0 +1,3 @@
+<?php
+
+?> \ No newline at end of file