aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/profile/fields/add.php (renamed from mod/profile/actions/editdefault.php)0
-rw-r--r--actions/profile/fields/delete.php (renamed from mod/profile/actions/deletedefaultprofileitem.php)8
-rw-r--r--actions/profile/fields/reorder.php (renamed from mod/profile/actions/reorder.php)0
-rw-r--r--actions/profile/fields/reset.php20
-rw-r--r--engine/lib/admin.php8
-rw-r--r--mod/profile/actions/editfield.php15
-rw-r--r--mod/profile/actions/resetdefaultprofile.php22
-rw-r--r--mod/profile/start.php15
-rw-r--r--mod/profile/views/default/admin/appearance/defaultprofile.php47
-rw-r--r--mod/profile/views/default/profile/edit.php80
-rw-r--r--vendors/jquery/jquery.jeditable.mini.js (renamed from mod/profile/vendor/jquery.jeditable.mini.js)0
-rw-r--r--views/default/admin/appearance/profile_fields.php21
-rw-r--r--views/default/admin/appearance/profile_fields/list.php (renamed from mod/profile/views/default/profile/editdefaultprofileitems.php)33
-rw-r--r--views/default/forms/profile/fields/add.php (renamed from mod/profile/views/default/profile/editdefaultprofile.php)2
-rw-r--r--views/default/forms/profile/fields/reset.php10
15 files changed, 91 insertions, 190 deletions
diff --git a/mod/profile/actions/editdefault.php b/actions/profile/fields/add.php
index 96e878402..96e878402 100644
--- a/mod/profile/actions/editdefault.php
+++ b/actions/profile/fields/add.php
diff --git a/mod/profile/actions/deletedefaultprofileitem.php b/actions/profile/fields/delete.php
index 6791d2c46..38d8b8379 100644
--- a/mod/profile/actions/deletedefaultprofileitem.php
+++ b/actions/profile/fields/delete.php
@@ -5,8 +5,6 @@
* @package ElggProfile
*/
-global $CONFIG;
-
$id = get_input('id');
$fieldlist = get_plugin_setting('user_defined_fields', 'profile');
@@ -18,9 +16,9 @@ $fieldlist = str_replace("{$id},", "", $fieldlist);
$fieldlist = str_replace(",{$id}", "", $fieldlist);
$fieldlist = str_replace("{$id}", "", $fieldlist);
-if (($id) && (set_plugin_setting("admin_defined_profile_$id", '', 'profile')) &&
- (set_plugin_setting("admin_defined_profile_type_$id", '', 'profile')) &&
- set_plugin_setting('user_defined_fields',$fieldlist,'profile')) {
+if (($id) && (clear_plugin_setting("admin_defined_profile_$id", 'profile')) &&
+ (clear_plugin_setting("admin_defined_profile_type_$id", 'profile')) &&
+ set_plugin_setting('user_defined_fields', $fieldlist, 'profile')) {
system_message(elgg_echo('profile:editdefault:delete:success'));
} else {
register_error(elgg_echo('profile:editdefault:delete:fail'));
diff --git a/mod/profile/actions/reorder.php b/actions/profile/fields/reorder.php
index a30e97bac..a30e97bac 100644
--- a/mod/profile/actions/reorder.php
+++ b/actions/profile/fields/reorder.php
diff --git a/actions/profile/fields/reset.php b/actions/profile/fields/reset.php
new file mode 100644
index 000000000..2cf54b563
--- /dev/null
+++ b/actions/profile/fields/reset.php
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Reset profile fields action
+ *
+ */
+
+$fieldlist = get_plugin_setting('user_defined_fields', 'profile');
+if ($fieldlist) {
+ $fieldlistarray = explode(',', $fieldlist);
+ foreach ($fieldlistarray as $listitem) {
+ clear_plugin_setting("admin_defined_profile_{$listitem}", 'profile');
+ clear_plugin_setting("admin_defined_profile_type_{$listitem}", 'profile');
+ }
+}
+
+set_plugin_setting('user_defined_fields', FALSE, 'profile');
+
+system_message(elgg_echo('profile:defaultprofile:reset'));
+
+forward(REFERER); \ No newline at end of file
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index a5f7e1f88..0a2158d45 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -126,6 +126,11 @@ function admin_init() {
elgg_register_action('admin/plugins/simple_update_states', '', 'admin');
+ elgg_register_action('profile/fields/reset', '', 'admin');
+ elgg_register_action('profile/fields/add', '', 'admin');
+ elgg_register_action('profile/fields/delete', '', 'admin');
+ elgg_register_action('profile/fields/reorder', '', 'admin');
+
// admin area overview and basic site settings
elgg_add_admin_submenu_item('overview', elgg_echo('admin:overview'));
@@ -153,6 +158,9 @@ function admin_init() {
// handled in the admin sidemenu so we don't have to generate this on every page load.
//elgg_add_admin_submenu_item('plugin_settings', elgg_echo('admin:plugin_settings'));
+ // default profile fields admin item
+ elgg_add_admin_submenu_item('profile_fields', elgg_echo('admin:profile:fields'), 'appearance');
+
register_page_handler('admin', 'admin_settings_page_handler');
}
diff --git a/mod/profile/actions/editfield.php b/mod/profile/actions/editfield.php
deleted file mode 100644
index b3bd887ef..000000000
--- a/mod/profile/actions/editfield.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-/**
- * Elgg profile plugin edit default profile action
- *
- * @package ElggProfile
- */
-
-$field = get_input('field');
-$text = get_input('value');
-
-set_plugin_setting("admin_defined_profile_{$field}",$text,'profile');
-
-echo $text;
-
-exit; \ No newline at end of file
diff --git a/mod/profile/actions/resetdefaultprofile.php b/mod/profile/actions/resetdefaultprofile.php
deleted file mode 100644
index 3ada044e8..000000000
--- a/mod/profile/actions/resetdefaultprofile.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-/**
- * Elgg profile plugin edit default profile action
- *
- * @package ElggProfile
- */
-
-global $CONFIG;
-
-if ($fieldlist = get_plugin_setting('user_defined_fields', 'profile')) {
- $fieldlistarray = explode(',', $fieldlist);
- foreach($fieldlistarray as $listitem) {
- set_plugin_setting("admin_defined_profile_{$listitem}", '', 'profile');
- set_plugin_setting("admin_defined_profile_type_{$listitem}", '', 'profile');
- }
-}
-
-set_plugin_setting('user_defined_fields', FALSE, 'profile');
-
-system_message(elgg_echo('profile:defaultprofile:reset'));
-
-forward(REFERER); \ No newline at end of file
diff --git a/mod/profile/start.php b/mod/profile/start.php
index 8ae16cfb5..eb34bf748 100644
--- a/mod/profile/start.php
+++ b/mod/profile/start.php
@@ -47,9 +47,6 @@ function profile_init() {
// allow ECML in parts of the profile
elgg_register_plugin_hook_handler('get_views', 'ecml', 'profile_ecml_views_hook');
-
- // default profile fields admin item
- elgg_add_admin_submenu_item('defaultprofile', elgg_echo('profile:edit:default'), 'appearance');
}
/**
@@ -137,18 +134,6 @@ function profile_page_handler($page) {
case 'edit':
require $CONFIG->path . 'pages/profile/edit.php';
return;
- /*
- $layout = 'one_column_with_sidebar';
-
- if (!$user || !$user->canEdit()) {
- register_error(elgg_echo("profile:noaccess"));
- forward();
- }
-
- $content = profile_get_user_edit_content($user, $page);
- $content = elgg_view_layout($layout, array('content' => $content));
- *
- */
break;
default:
diff --git a/mod/profile/views/default/admin/appearance/defaultprofile.php b/mod/profile/views/default/admin/appearance/defaultprofile.php
deleted file mode 100644
index b63525bf1..000000000
--- a/mod/profile/views/default/admin/appearance/defaultprofile.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * Elgg profile - Admin area: edit default profile fields
- *
- * @package ElggProfile
- */
-
-$title = elgg_view_title(elgg_echo('profile:edit:default'));
-$form = elgg_view('profile/editdefaultprofile');
-
-// List form elements
-$n = 0;
-$loaded_defaults = array();
-$items = array();
-if ($fieldlist = get_plugin_setting('user_defined_fields', 'profile')) {
- $fieldlistarray = explode(',', $fieldlist);
- foreach($fieldlistarray as $listitem) {
- if ($translation = get_plugin_setting("admin_defined_profile_{$listitem}", 'profile')) {
- $item = new stdClass;
- $item->translation = $translation;
- $item->shortname = $listitem;
- $item->name = "admin_defined_profile_{$listitem}";
- $item->type = get_plugin_setting("admin_defined_profile_type_{$listitem}", 'profile');
- $items[] = $item;
- }
- }
-}
-
-$listing = elgg_view('profile/editdefaultprofileitems',array('items' => $items, 'fieldlist' => $fieldlist));
-
-$resetlisting = elgg_view('input/form',
- array (
- 'body' => elgg_view('input/submit', array('value' => elgg_echo('profile:resetdefault'), 'class' => 'action-button disabled')),
- 'action' => 'action/profile/editdefault/reset'
- )
- );
-
-$body = <<<__HTML
-$title
-$form
-$listing
-<div class="default_profile_reset">
- $resetlisting
-</div>
-__HTML;
-
-echo $body;
diff --git a/mod/profile/views/default/profile/edit.php b/mod/profile/views/default/profile/edit.php
deleted file mode 100644
index 2e3ec24a4..000000000
--- a/mod/profile/views/default/profile/edit.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-/**
- * Elgg profile edit form
- *
- * @package ElggProfile
- *
- * @uses $vars['entity'] The user entity
- * @uses $vars['profile'] Profile items from $CONFIG->profile, defined in profile/start.php for now
- */
-?>
-<form action="<?php echo elgg_get_site_url(); ?>action/profile/edit" method="post" id="edit_profile" class="margin-top">
-<?php echo elgg_view('input/securitytoken') ?>
-
- <p><label>
- <?php echo elgg_echo('user:name:label'); ?></label>
- <?php
- echo elgg_view('input/text',array('internalname' => 'name', 'value' => elgg_get_page_owner()->name));
- ?>
- </p>
-
-<?php
- if (is_array($vars['config']->profile) && sizeof($vars['config']->profile) > 0)
- foreach($vars['config']->profile as $shortname => $valtype) {
- if ($metadata = get_metadata_byname($vars['entity']->guid, $shortname)) {
- if (is_array($metadata)) {
- $value = '';
- foreach($metadata as $md) {
- if (!empty($value)) $value .= ', ';
- $value .= $md->value;
- $access_id = $md->access_id;
- }
- } else {
- $value = $metadata->value;
- $access_id = $metadata->access_id;
- }
- } else {
- $value = '';
- $access_id = ACCESS_DEFAULT;
- }
-
- if ($shortname == 'description') { // change label positioning to allow for additional longtext field controls
-?>
- <p>
- <label>
- <?php echo elgg_echo("profile:{$shortname}") ?></label>
- <?php echo elgg_view("input/{$valtype}",array(
- 'internalname' => $shortname,
- 'value' => $value,
- )); ?>
-
- <?php echo elgg_view('input/access',array('internalname' => 'accesslevel['.$shortname.']', 'value' => $access_id)); ?>
- </p>
-<?php
- } else {
-?>
-
- <p>
- <label>
- <?php echo elgg_echo("profile:{$shortname}") ?><br />
- <?php echo elgg_view("input/{$valtype}",array(
- 'internalname' => $shortname,
- 'value' => $value,
- )); ?>
- </label>
- <?php echo elgg_view('input/access',array('internalname' => 'accesslevel['.$shortname.']', 'value' => $access_id)); ?>
- </p>
-
-<?php
- }
-
- }
-
-?>
-
- <p>
- <input type="hidden" name="username" value="<?php echo elgg_get_page_owner()->username; ?>" />
- <input type="submit" class="submit-button" value="<?php echo elgg_echo("save"); ?>" />
- </p>
-
-</form> \ No newline at end of file
diff --git a/mod/profile/vendor/jquery.jeditable.mini.js b/vendors/jquery/jquery.jeditable.mini.js
index 6c867383a..6c867383a 100644
--- a/mod/profile/vendor/jquery.jeditable.mini.js
+++ b/vendors/jquery/jquery.jeditable.mini.js
diff --git a/views/default/admin/appearance/profile_fields.php b/views/default/admin/appearance/profile_fields.php
new file mode 100644
index 000000000..f20bbaeb6
--- /dev/null
+++ b/views/default/admin/appearance/profile_fields.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Admin area: edit default profile fields
+ */
+
+$title = elgg_view_title(elgg_echo('admin:profile:fields'));
+
+$add = elgg_view_form('profile/fields/add', array(), array());
+$list = elgg_view('admin/appearance/profile_fields/list');
+$reset = elgg_view_form('profile/fields/reset', array(), array());
+
+$body = <<<__HTML
+$title
+$add
+$list
+<div class="default_profile_reset">
+ $reset
+</div>
+__HTML;
+
+echo $body;
diff --git a/mod/profile/views/default/profile/editdefaultprofileitems.php b/views/default/admin/appearance/profile_fields/list.php
index 29ce7f138..bbd6dccd2 100644
--- a/mod/profile/views/default/profile/editdefaultprofileitems.php
+++ b/views/default/admin/appearance/profile_fields/list.php
@@ -1,6 +1,28 @@
-<script language="javascript" type="text/javascript" src="<?php echo elgg_get_site_url()?>mod/profile/vendor/jquery.jeditable.mini.js"></script>
+<?php
+
+
+// List form elements
+$n = 0;
+$loaded_defaults = array();
+$items = array();
+if ($fieldlist = get_plugin_setting('user_defined_fields', 'profile')) {
+ $fieldlistarray = explode(',', $fieldlist);
+ foreach($fieldlistarray as $listitem) {
+ if ($translation = get_plugin_setting("admin_defined_profile_{$listitem}", 'profile')) {
+ $item = new stdClass;
+ $item->translation = $translation;
+ $item->shortname = $listitem;
+ $item->name = "admin_defined_profile_{$listitem}";
+ $item->type = get_plugin_setting("admin_defined_profile_type_{$listitem}", 'profile');
+ $items[] = $item;
+ }
+ }
+}
+?>
+
+<script language="javascript" type="text/javascript" src="<?php echo elgg_get_site_url()?>vendors/jquery/jquery.jeditable.mini.js"></script>
<script language="javascript" type="text/javascript">
-var reorderURL = '<?php echo elgg_add_action_tokens_to_url(elgg_get_site_url() . 'action/profile/editdefault/reorder', FALSE); ?>';
+var reorderURL = '<?php echo elgg_add_action_tokens_to_url(elgg_get_site_url() . 'action/profile/fields/reorder', FALSE); ?>';
function sortCallback(event, ui) {
var orderArr = $('#sortable_profile_fields').sortable('toArray');
var orderStr = orderArr.join(',');
@@ -25,7 +47,7 @@ $(document).ready(function() {
$cancel = elgg_echo('cancel');
$edit_url = elgg_add_action_tokens_to_url(elgg_get_site_url()."action/profile/editdefault/editfield", FALSE);
- foreach($vars['items'] as $item) {
+ foreach($items as $item) {
echo <<< END
<script language="javascript" type="text/javascript">
@@ -49,7 +71,7 @@ END;
echo elgg_view("profile/", array('value' => $item->translation));
//$even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even';
- $url = elgg_add_action_tokens_to_url(elgg_get_site_url()."action/profile/editdefault/delete?id={$item->shortname}");
+ $url = elgg_add_action_tokens_to_url(elgg_get_site_url()."action/profile/fields/delete?id={$item->shortname}");
echo "<li id=\"{$item->shortname}\"><div class='delete-button'><a href=\"$url\">" . elgg_echo('delete') . "</a></div>";
echo "<img width='16' height='16' class='handle' alt='move' title='Drag here to reorder this item' src='".elgg_get_site_url()."mod/profile/graphics/drag-handle.png'/>";
echo "<b class=\"profile_field_editable\"><span class=\"{$item->shortname}_editable\">$item->translation</span></b>: [".elgg_echo($item->type)."]";
@@ -62,4 +84,5 @@ END;
</div>
<div id="tempList"></div>
-<input name="sortableListOrder" type="hidden" id="sortableListOrder" value="<?php echo $vars['fieldlist']; ?>" />
+<input name="sortableListOrder" type="hidden" id="sortableListOrder" value="<?php echo $fieldlist; ?>" />
+
diff --git a/mod/profile/views/default/profile/editdefaultprofile.php b/views/default/forms/profile/fields/add.php
index 7d701af11..50d1600fd 100644
--- a/mod/profile/views/default/profile/editdefaultprofile.php
+++ b/views/default/forms/profile/fields/add.php
@@ -26,4 +26,4 @@ $formbody = <<< END
END;
echo "<p class='margin-top'>" . elgg_echo('profile:explainchangefields') . "</p>";
-echo elgg_view('input/form', array('body' => $formbody, 'action' => 'action/profile/editdefault'));
+echo $formbody;
diff --git a/views/default/forms/profile/fields/reset.php b/views/default/forms/profile/fields/reset.php
new file mode 100644
index 000000000..1661b2fa3
--- /dev/null
+++ b/views/default/forms/profile/fields/reset.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Reset profile fields form
+ */
+
+$params = array(
+ 'value' => elgg_echo('profile:resetdefault'),
+ 'class' => 'action-button disabled',
+);
+echo elgg_view('input/submit', $params);