aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/profile/actions/deletedefaultprofileitem.php26
-rw-r--r--mod/profile/actions/editdefault.php38
-rw-r--r--mod/profile/actions/resetdefaultprofile.php29
-rw-r--r--mod/profile/defaultprofile.php56
-rw-r--r--mod/profile/start.php45
-rw-r--r--mod/profile/views/default/profile/editdefaultprofile.php35
6 files changed, 226 insertions, 3 deletions
diff --git a/mod/profile/actions/deletedefaultprofileitem.php b/mod/profile/actions/deletedefaultprofileitem.php
new file mode 100644
index 000000000..7947c65a1
--- /dev/null
+++ b/mod/profile/actions/deletedefaultprofileitem.php
@@ -0,0 +1,26 @@
+<?php
+ /**
+ * Elgg profile plugin edit default profile action removal
+ *
+ * @package ElggProfile
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ global $CONFIG;
+
+ action_gatekeeper();
+ admin_gatekeeper();
+
+ $id = (int)get_input('id');
+
+ if ( ($id) && (set_plugin_setting("admin_defined_profile_$id", '', 'profile')) &&
+ (set_plugin_setting("admin_defined_profile_type_$id", '', 'profile')))
+ system_message(elgg_echo('profile:editdefault:delete:success'));
+ else
+ register_error(elgg_echo('profile:editdefault:delete:fail'));
+
+ forward($_SERVER['HTTP_REFERER']);
+?> \ No newline at end of file
diff --git a/mod/profile/actions/editdefault.php b/mod/profile/actions/editdefault.php
new file mode 100644
index 000000000..fb6ef0b51
--- /dev/null
+++ b/mod/profile/actions/editdefault.php
@@ -0,0 +1,38 @@
+<?php
+
+ /**
+ * Elgg profile plugin edit default profile action
+ *
+ * @package ElggProfile
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Load configuration
+ global $CONFIG;
+
+ action_gatekeeper();
+ admin_gatekeeper();
+
+ $label = sanitise_string(get_input('label'));
+ $type = sanitise_string(get_input('type'));
+
+ if (($label) && ($type))
+ {
+ $n = 0;
+ while (get_plugin_setting("admin_defined_profile_$n", 'profile')) {$n++;} // find free space
+
+ if ( (set_plugin_setting("admin_defined_profile_$n", $label, 'profile')) &&
+ (set_plugin_setting("admin_defined_profile_type_$n", $type, 'profile')))
+ system_message(elgg_echo('profile:editdefault:success'));
+ else
+ register_error(elgg_echo('profile:editdefault:fail'));
+
+ }
+ else
+ register_error(elgg_echo('profile:editdefault:fail'));
+
+ forward($_SERVER['HTTP_REFERER']);
+?> \ No newline at end of file
diff --git a/mod/profile/actions/resetdefaultprofile.php b/mod/profile/actions/resetdefaultprofile.php
new file mode 100644
index 000000000..7407fe937
--- /dev/null
+++ b/mod/profile/actions/resetdefaultprofile.php
@@ -0,0 +1,29 @@
+<?php
+ /**
+ * Elgg profile plugin edit default profile action
+ *
+ * @package ElggProfile
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Load configuration
+ global $CONFIG;
+
+ action_gatekeeper();
+ admin_gatekeeper();
+
+ $n = 0;
+ while (get_plugin_setting("admin_defined_profile_$n", 'profile')) {
+ set_plugin_setting("admin_defined_profile_$n", '', 'profile');
+ set_plugin_setting("admin_defined_profile_type_$n", '', 'profile');
+
+ $n++;
+ }
+
+ system_message(elgg_echo('profile:defaultprofile:reset'));
+
+ forward($_SERVER['HTTP_REFERER']);
+?> \ No newline at end of file
diff --git a/mod/profile/defaultprofile.php b/mod/profile/defaultprofile.php
new file mode 100644
index 000000000..84f595618
--- /dev/null
+++ b/mod/profile/defaultprofile.php
@@ -0,0 +1,56 @@
+<?php
+ /**
+ * Elgg profile index
+ *
+ * @package ElggProfile
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ admin_gatekeeper();
+ set_context('admin');
+
+ // Set admin user for user block
+ set_page_owner($_SESSION['guid']);
+
+ $title = elgg_view_title(elgg_echo('profile:edit:default'));
+ $form = elgg_view('profile/editdefaultprofile');
+
+
+ set_context('search');
+
+
+ // List form elements
+ $n = 0;
+ $loaded_defaults = array();
+ while ($translation = get_plugin_setting("admin_defined_profile_$n", 'profile'))
+ {
+ $type = get_plugin_setting("admin_defined_profile_type_$n", 'profile');
+ $listing .= elgg_view("profile/", array('value' => $translation));
+
+ $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even';
+
+ $listing .= "<p class=\"{$even_odd}\"><b>$translation: </b>";
+ $listing .= elgg_view("output/{$type}",array('value' => " [$type]"));
+ $listing .= "</p>";
+
+ $n++;
+ }
+
+ $listing .= elgg_view('input/form',
+ array(
+ 'body' => elgg_view('input/submit', array('value' => elgg_echo('profile:resetdefault'))),
+ 'action' => $CONFIG->wwwroot . 'actions/profile/editdefault/reset'
+ )
+ );
+
+ set_context('admin');
+
+
+ page_draw(elgg_echo('profile:edit:default'),elgg_view_layout("two_column_left_sidebar", '', $title . $form . $listing));
+
+?> \ No newline at end of file
diff --git a/mod/profile/start.php b/mod/profile/start.php
index 4d7d59acf..89e70b5ce 100644
--- a/mod/profile/start.php
+++ b/mod/profile/start.php
@@ -48,7 +48,8 @@
);*/
// Register a page handler, so we can have nice URLs
- register_page_handler('profile','profile_page_handler');
+ register_page_handler('profile','profile_page_handler');
+ register_page_handler('defaultprofile','profileedit_page_handler');
register_page_handler('icon','profile_icon_handler');
register_page_handler('iconjs','profile_iconjs_handler');
@@ -113,7 +114,9 @@
if (!$type) $type = 'text';
// Set array
- $loaded_defaults["profile:admin_defined_profile_$n"] = $type;
+ $loaded_defaults["admin_defined_profile_$n"] = $type;
+
+ $n++;
}
if (count($loaded_defaults))
$profile_defaults = $loaded_defaults;
@@ -137,6 +140,38 @@
// Include the standard profile index
include($CONFIG->pluginspath . "profile/index.php");
+ }
+
+ /**
+ * Profile edit page handler
+ *
+ * @param array $page Array of page elements, forwarded by the page handling mechanism
+ */
+ function profileedit_page_handler($page) {
+
+ global $CONFIG;
+
+ // The username should be the file we're getting
+ if (isset($page[0])) {
+ switch ($page[0])
+ {
+ case 'edit' :
+ default: include($CONFIG->pluginspath . "profile/defaultprofile.php");
+ }
+ }
+
+ }
+
+ /**
+ * Pagesetup function
+ *
+ */
+ function profile_pagesetup()
+ {
+ if (get_context() == 'admin' && isadminloggedin()) {
+ global $CONFIG;
+ add_submenu_item(elgg_echo('profile:edit:default'), $CONFIG->wwwroot . 'pg/defaultprofile/edit/');
+ }
}
/**
@@ -227,6 +262,8 @@
// Make sure the profile initialisation function is called on initialisation
register_elgg_event_handler('init','system','profile_init',1);
register_elgg_event_handler('init','system','profile_fields_setup', 10000); // Ensure this runs after other plugins
+
+ register_elgg_event_handler('pagesetup','system','profile_pagesetup');
// Register actions
@@ -234,7 +271,9 @@
register_action("profile/edit",false,$CONFIG->pluginspath . "profile/actions/edit.php");
register_action("profile/iconupload",false,$CONFIG->pluginspath . "profile/actions/iconupload.php");
register_action("profile/cropicon",false,$CONFIG->pluginspath . "profile/actions/cropicon.php");
-
+ register_action("profile/editdefault",false,$CONFIG->pluginspath . "profile/actions/editdefault.php", true);
+ register_action("profile/editdefault/delete",false,$CONFIG->pluginspath . "profile/actions/deletedefaultprofileitem.php", true);
+ register_action("profile/editdefault/reset",false,$CONFIG->pluginspath . "profile/actions/resetdefaultprofile.php", true);
// Define widgets for use in this context
diff --git a/mod/profile/views/default/profile/editdefaultprofile.php b/mod/profile/views/default/profile/editdefaultprofile.php
new file mode 100644
index 000000000..f7ef24456
--- /dev/null
+++ b/mod/profile/views/default/profile/editdefaultprofile.php
@@ -0,0 +1,35 @@
+<?php
+ /**
+ * Elgg profile index
+ *
+ * @package ElggProfile
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $label_text = elgg_echo('profile:label');
+ $type_text = elgg_echo('profile:type');
+
+ $label_control = elgg_view('input/text', array('internalname' => 'label'));
+ $type_control = elgg_view('input/pulldown', array('internalname' => 'type', 'options_values' => array(
+ 'text' => elgg_echo('text'),
+ 'longtext' => elgg_echo('longtext'),
+ 'tags' => elgg_echo('tags'),
+ 'url' => elgg_echo('url'),
+ 'email' => elgg_echo('email')
+ )));
+
+ $submit_control = elgg_view('input/submit', array('internalname' => elgg_echo('save'), 'value' => elgg_echo('save')));
+
+ $formbody = <<< END
+ <div>
+ <p>$label_text: $label_control
+ $type_text: $type_control
+ $submit_control</p>
+ </div>
+END;
+
+ echo elgg_view('input/form', array('body' => $formbody, 'action' => $vars['url'] . 'actions/profile/editdefault'));
+?> \ No newline at end of file