aboutsummaryrefslogtreecommitdiff
path: root/mod/profile/actions
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-04 16:36:48 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-04 16:36:48 +0000
commit88c3d54f0a6ceb0b539af4e922157b101b945542 (patch)
tree476b22df83c386c930b303a12d8a2a79e235bb7d /mod/profile/actions
parent21b799f2e9c3f307497e3f8c10fb547036380d82 (diff)
downloadelgg-88c3d54f0a6ceb0b539af4e922157b101b945542.tar.gz
elgg-88c3d54f0a6ceb0b539af4e922157b101b945542.tar.bz2
Merged interface changes to profile in.
git-svn-id: http://code.elgg.org/elgg/trunk@5284 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/profile/actions')
-rw-r--r--mod/profile/actions/cropicon.php134
-rw-r--r--mod/profile/actions/deletedefaultprofileitem.php44
-rw-r--r--mod/profile/actions/edit.php179
-rw-r--r--mod/profile/actions/editdefault.php66
-rw-r--r--mod/profile/actions/iconupload.php151
-rw-r--r--mod/profile/actions/resetdefaultprofile.php43
6 files changed, 293 insertions, 324 deletions
diff --git a/mod/profile/actions/cropicon.php b/mod/profile/actions/cropicon.php
index f86799ccf..70b8e9288 100644
--- a/mod/profile/actions/cropicon.php
+++ b/mod/profile/actions/cropicon.php
@@ -1,80 +1,74 @@
<?php
+/**
+ * Elgg profile plugin upload new user icon 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-2010
+ * @link http://elgg.com/
+ */
- /**
- * Elgg profile plugin upload new user icon 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-2010
- * @link http://elgg.com/
- */
+gatekeeper();
- gatekeeper();
+$profile_username = get_input('username');
+$profile_owner = get_user_by_username($profile_username);
- $x1 = (int) get_input('x_1',0);
- $y1 = (int) get_input('y_1',0);
- $x2 = (int) get_input('x_2',0);
- $y2 = (int) get_input('y_2',0);
+if (!$profile_owner || !($profile_owner instanceof ElggUser) || !$profile_owner->canEdit()) {
+ register_error(elgg_echo('profile:icon:fail'));
+ forward($_SERVER['HTTP_REFERER']);
+}
+
+$x1 = (int) get_input('x_1',0);
+$y1 = (int) get_input('y_1',0);
+$x2 = (int) get_input('x_2',0);
+$y2 = (int) get_input('y_2',0);
+
+$filehandler = new ElggFile();
+$filehandler->owner_guid = $profile_owner->getGUID();
+$filehandler->setFilename("profile/" . $profile_owner->username . "master" . ".jpg");
+$filename = $filehandler->getFilenameOnFilestore();
- // username is set in form which ensures the page owner is set
- $user = page_owner_entity();
+$topbar = get_resized_image_from_existing_file($filename, 16, 16, true, $x1, $y1, $x2, $y2);
+$tiny = get_resized_image_from_existing_file($filename, 25, 25, true, $x1, $y1, $x2, $y2);
+$small = get_resized_image_from_existing_file($filename, 40, 40, true, $x1, $y1, $x2, $y2);
+$medium = get_resized_image_from_existing_file($filename, 100, 100, true, $x1, $y1, $x2, $y2);
- if (!$user || !$user->canEdit()) {
- register_error(elgg_echo("profile:icon:noaccess"));
- forward();
- }
-
+if ($small !== FALSE && $medium !== FALSE && $tiny !== FALSE) {
$filehandler = new ElggFile();
- $filehandler->owner_guid = $user->getGUID();
- $filehandler->setFilename("profile/" . $user->username . "master" . ".jpg");
- $filename = $filehandler->getFilenameOnFilestore();
-
- $topbar = get_resized_image_from_existing_file($filename,16,16, true, $x1, $y1, $x2, $y2);
- $tiny = get_resized_image_from_existing_file($filename,25,25, true, $x1, $y1, $x2, $y2);
- $small = get_resized_image_from_existing_file($filename,40,40, true, $x1, $y1, $x2, $y2);
- $medium = get_resized_image_from_existing_file($filename,100,100, true, $x1, $y1, $x2, $y2);
+ $filehandler->owner_guid = $profile_owner->getGUID();
+ $filehandler->setFilename("profile/" . $profile_owner->username . "medium.jpg");
+ $filehandler->open("write");
+ $filehandler->write($medium);
+ $filehandler->close();
+ $filehandler->setFilename("profile/" . $profile_owner->username . "small.jpg");
+ $filehandler->open("write");
+ $filehandler->write($small);
+ $filehandler->close();
+ $filehandler->setFilename("profile/" . $profile_owner->username . "tiny.jpg");
+ $filehandler->open("write");
+ $filehandler->write($tiny);
+ $filehandler->close();
+ $filehandler->setFilename("profile/" . $profile_owner->username . "topbar.jpg");
+ $filehandler->open("write");
+ $filehandler->write($topbar);
+ $filehandler->close();
+
+ $profile_owner->x1 = $x1;
+ $profile_owner->x2 = $x2;
+ $profile_owner->y1 = $y1;
+ $profile_owner->y2 = $y2;
- if ($small !== false
- && $medium !== false
- && $tiny !== false) {
-
- $filehandler = new ElggFile();
- $filehandler->owner_guid = $user->getGUID();
- $filehandler->setFilename("profile/" . $user->username . "medium.jpg");
- $filehandler->open("write");
- $filehandler->write($medium);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $user->username . "small.jpg");
- $filehandler->open("write");
- $filehandler->write($small);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $user->username . "tiny.jpg");
- $filehandler->open("write");
- $filehandler->write($tiny);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $user->username . "topbar.jpg");
- $filehandler->open("write");
- $filehandler->write($topbar);
- $filehandler->close();
-
- $user->x1 = $x1;
- $user->x2 = $x2;
- $user->y1 = $y1;
- $user->y2 = $y2;
-
- $user->icontime = time();
-
- system_message(elgg_echo("profile:icon:uploaded"));
-
- } else {
- register_error(elgg_echo("profile:icon:notfound"));
- }
-
- //forward the user back to the upload page to crop
-
- $url = $vars['url'] . "pg/profile/{$user->username}/editicon/";
+ $profile_owner->icontime = time();
+
+ system_message(elgg_echo("profile:icon:uploaded"));
+} else {
+ register_error(elgg_echo("profile:icon:notfound"));
+}
- if (isloggedin()) forward($url);
+//forward the user back to the upload page to crop
+$url = "{$vars['url']}pg/profile/{$profile_owner->username}/edit/icon";
-?>
+if (isloggedin()) {
+ forward($url);
+}
diff --git a/mod/profile/actions/deletedefaultprofileitem.php b/mod/profile/actions/deletedefaultprofileitem.php
index 309816035..b5b2eba84 100644
--- a/mod/profile/actions/deletedefaultprofileitem.php
+++ b/mod/profile/actions/deletedefaultprofileitem.php
@@ -1,25 +1,25 @@
<?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-2010
- * @link http://elgg.com/
- */
-
- global $CONFIG;
+/**
+ * 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-2010
+ * @link http://elgg.com/
+ */
+
+global $CONFIG;
+
+admin_gatekeeper();
- admin_gatekeeper();
+$id = (int)get_input('id');
- $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']);
-?>
+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/edit.php b/mod/profile/actions/edit.php
index bc14cd6e6..4afe4cd47 100644
--- a/mod/profile/actions/edit.php
+++ b/mod/profile/actions/edit.php
@@ -1,95 +1,100 @@
<?php
-
- /**
- * Elgg profile plugin edit 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-2010
- * @link http://elgg.com/
- */
-
- // Load configuration
- global $CONFIG;
-
- gatekeeper();
-
- // Get profile fields
- $input = array();
- $accesslevel = get_input('accesslevel');
- if (!is_array($accesslevel)) $accesslevel = array();
-
- foreach($CONFIG->profile as $shortname => $valuetype) {
- // the decoding is a stop gag to prevent &amp;&amp; showing up in profile fields
- // because it is escaped on both input (get_input()) and output (view:output/text). see #561 and #1405.
- // must decode in utf8 or string corruption occurs. see #1567.
- $value = html_entity_decode(get_input($shortname), ENT_COMPAT, 'UTF-8');
-
- // limit to reasonable sizes.
- if ($valuetype != 'longtext' && elgg_strlen($value) > 250) {
- $error = sprintf(elgg_echo('profile:field_too_long'), elgg_echo("profile:{$shortname}"));
- register_error($error);
- forward($_SERVER['HTTP_REFERER']);
- }
-
- if ($valuetype == 'tags') {
- $value = string_to_tag_array($value);
+/**
+ * Elgg profile plugin edit 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-2010
+ * @link http://elgg.com/
+ */
+
+global $CONFIG;
+gatekeeper();
+
+$profile_username = get_input('username');
+$profile_owner = get_user_by_username($profile_username);
+
+if (!$profile_owner || !$profile_owner->canEdit()) {
+ system_message(elgg_echo("profile:noaccess"));
+ forward($_SERVER['HTTP_REFERER']);
+}
+
+// grab the defined profile field names and their load the values from POST.
+// each field can have its own access, so sort that too.
+$input = array();
+$accesslevel = get_input('accesslevel');
+
+if (!is_array($accesslevel)) {
+ $accesslevel = array();
+}
+
+foreach($CONFIG->profile as $shortname => $valuetype) {
+ // the decoding is a stop gag to prevent &amp;&amp; showing up in profile fields
+ // because it is escaped on both input (get_input()) and output (view:output/text). see #561 and #1405.
+ // must decode in utf8 or string corruption occurs. see #1567.
+ $value = html_entity_decode(get_input($shortname), ENT_COMPAT, 'UTF-8');
+
+ // limit to reasonable sizes.
+ if ($valuetype != 'longtext' && elgg_strlen($value) > 250) {
+ $error = sprintf(elgg_echo('profile:field_too_long'), elgg_echo("profile:{$shortname}"));
+ register_error($error);
+ forward($_SERVER['HTTP_REFERER']);
+ }
+
+ if ($valuetype == 'tags') {
+ $value = string_to_tag_array($value);
+ }
+
+ $input[$shortname] = $value;
+}
+
+// display name is handled separately
+if ($name = strip_tags(get_input('name'))) {
+ if (elgg_strlen($name) > 50) {
+ register_error(elgg_echo('user:name:fail'));
+ } else {
+ $profile_owner->name = $name;
+ // @todo this is weird...giving two notifications?
+ if ($profile_owner->save()) {
+ system_message(elgg_echo('user:name:success'));
+ } else {
+ register_error(elgg_echo('user:name:fail'));
+ }
+ }
+}
+
+// go through custom fields
+if (sizeof($input) > 0) {
+ foreach($input as $shortname => $value) {
+ remove_metadata($profile_owner->guid, $shortname);
+ if (isset($accesslevel[$shortname])) {
+ $access_id = (int) $accesslevel[$shortname];
+ } else {
+ // this should never be executed since the access level should always be set
+ $access_id = ACCESS_DEFAULT;
+ }
+ if (is_array($value)) {
+ $i = 0;
+ foreach($value as $interval) {
+ $i++;
+ $multiple = ($i > 1) ? TRUE : FALSE;
+ create_metadata($profile_owner->guid, $shortname, $interval, 'text', $profile_owner->guid, $access_id, $multiple);
}
-
- $input[$shortname] = $value;
+ } else {
+ create_metadata($profile_owner->getGUID(), $shortname, $value, 'text', $profile_owner->getGUID(), $access_id);
}
+ }
- // Get the page owner to see if the currently logged in user canEdit() the page owner.
-
- $user = page_owner_entity();
- if (!$user) {
- $user = $_SESSION['user'];
+ $profile_owner->save();
- // @todo this doesn't make sense...???
- set_page_owner($user->getGUID());
- }
- if ($user->canEdit()) {
-
- // Save stuff
- if (sizeof($input) > 0)
- foreach($input as $shortname => $value) {
- //$user->$shortname = $value;
- remove_metadata($user->guid, $shortname);
- if (isset($accesslevel[$shortname])) {
- $access_id = (int) $accesslevel[$shortname];
- } else {
- // this should never be executed since the access level should always be set
- $access_id = ACCESS_PRIVATE;
- }
- if (is_array($value)) {
- $i = 0;
- foreach($value as $interval) {
- $i++;
- if ($i == 1) { $multiple = false; } else { $multiple = true; }
- create_metadata($user->guid, $shortname, $interval, 'text', $user->guid, $access_id, $multiple);
- }
- } else {
- create_metadata($user->guid, $shortname, $value, 'text', $user->guid, $access_id);
- }
- }
- $user->save();
-
- // Notify of profile update
- trigger_elgg_event('profileupdate',$user->type,$user);
-
- //add to river
- add_to_river('river/user/default/profileupdate','update',$_SESSION['user']->guid,$_SESSION['user']->guid,get_default_access($_SESSION['user']));
-
- system_message(elgg_echo("profile:saved"));
-
- // Forward to the user's profile
- forward($user->getUrl());
+ // Notify of profile update
+ trigger_elgg_event('profileupdate',$user->type,$user);
- } else {
- // If we can't, display an error
+ //add to river
+ add_to_river('river/user/default/profileupdate','update',$_SESSION['user']->guid,$_SESSION['user']->guid,get_default_access($_SESSION['user']));
- system_message(elgg_echo("profile:noaccess"));
- }
+ system_message(elgg_echo("profile:saved"));
+}
-?>
+forward($profile_owner->getUrl()); \ No newline at end of file
diff --git a/mod/profile/actions/editdefault.php b/mod/profile/actions/editdefault.php
index cf662e9b2..7f5fe0004 100644
--- a/mod/profile/actions/editdefault.php
+++ b/mod/profile/actions/editdefault.php
@@ -1,39 +1,35 @@
<?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-2010
- * @link http://elgg.com/
- */
-
- // Load configuration
- global $CONFIG;
-
- 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'))) {
- set_plugin_setting('user_defined_fields', TRUE, 'profile');
- system_message(elgg_echo('profile:editdefault:success'));
- } else {
- register_error(elgg_echo('profile:editdefault:fail'));
- }
-
+/**
+ * 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-2010
+ * @link http://elgg.com/
+ */
+
+global $CONFIG;
+admin_gatekeeper();
+
+$label = sanitise_string(get_input('label'));
+$type = sanitise_string(get_input('type'));
+
+if (($label) && ($type)){
+ // find next index for new field
+ $n = 0;
+ while (get_plugin_setting("admin_defined_profile_$n", 'profile')) {
+ $n++;
}
- else
+
+ 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']);
-?>
+forward($_SERVER['HTTP_REFERER']); \ No newline at end of file
diff --git a/mod/profile/actions/iconupload.php b/mod/profile/actions/iconupload.php
index f1d290694..a0cb24c3d 100644
--- a/mod/profile/actions/iconupload.php
+++ b/mod/profile/actions/iconupload.php
@@ -1,91 +1,68 @@
<?php
+/**
+ * Elgg profile plugin upload new user icon 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-2010
+ * @link http://elgg.com/
+ */
- /**
- * Elgg profile plugin upload new user icon 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-2010
- * @link http://elgg.com/
- */
+gatekeeper();
- gatekeeper();
-
- $user = page_owner_entity();
- if (!$user)
- $user = $_SESSION['user'];
-
- // If we were given a correct icon
- if (
- (isloggedin()) &&
- ($user) &&
- ($user->canEdit())
- ) {
-
-
- $topbar = get_resized_image_from_uploaded_file('profileicon',16,16, true);
- $tiny = get_resized_image_from_uploaded_file('profileicon',25,25, true);
- $small = get_resized_image_from_uploaded_file('profileicon',40,40, true);
- $medium = get_resized_image_from_uploaded_file('profileicon',100,100, true);
- $large = get_resized_image_from_uploaded_file('profileicon',200,200);
- $master = get_resized_image_from_uploaded_file('profileicon',550,550);
-
- if ($small !== false
- && $medium !== false
- && $large !== false
- && $tiny !== false) {
-
- $filehandler = new ElggFile();
- $filehandler->owner_guid = $user->getGUID();
- $filehandler->setFilename("profile/" . $user->username . "large.jpg");
- $filehandler->open("write");
- $filehandler->write($large);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $user->username . "medium.jpg");
- $filehandler->open("write");
- $filehandler->write($medium);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $user->username . "small.jpg");
- $filehandler->open("write");
- $filehandler->write($small);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $user->username . "tiny.jpg");
- $filehandler->open("write");
- $filehandler->write($tiny);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $user->username . "topbar.jpg");
- $filehandler->open("write");
- $filehandler->write($topbar);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $user->username . "master.jpg");
- $filehandler->open("write");
- $filehandler->write($master);
- $filehandler->close();
-
- $user->icontime = time();
-
- system_message(elgg_echo("profile:icon:uploaded"));
-
- trigger_elgg_event('profileiconupdate',$user->type,$user);
-
- //add to river
- add_to_river('river/user/default/profileiconupdate','update',$user->guid,$user->guid);
-
- } else {
- system_message(elgg_echo("profile:icon:notfound"));
- }
-
- } else {
-
- system_message(elgg_echo("profile:icon:notfound"));
-
- }
-
- //forward the user back to the upload page to crop
-
- $url = "pg/profile/{$user->username}/editicon/";
-
- if (isloggedin()) forward($url);
+$profile_username = get_input('username');
+$profile_owner = get_user_by_username($profile_username);
-?>
+if (!$profile_owner || !($profile_owner instanceof ElggUser) || !$profile_owner->canEdit()) {
+ register_error(elgg_echo('profile:icon:fail'));
+ forward($_SERVER['HTTP_REFERER']);
+}
+
+$profile_owner_guid = $profile_owner->getGUID();
+
+//@todo make this configurable?
+$icon_sizes = array(
+ 'topbar' => array('w'=>16, 'h'=>16, 'square'=>TRUE),
+ 'tiny' => array('w'=>25, 'h'=>25, 'square'=>TRUE),
+ 'small' => array('w'=>40, 'h'=>40, 'square'=>TRUE),
+ 'medium' => array('w'=>100, 'h'=>100, 'square'=>TRUE),
+ 'large' => array('w'=>200, 'h'=>200, 'square'=>FALSE),
+ 'master' => array('w'=>1600, 'h'=>1600, 'square'=>FALSE)
+);
+
+// get the images and save their file handlers into an array
+// so we can do clean up if one fails.
+$files = array();
+foreach ($icon_sizes as $name => $size_info) {
+ $resized = get_resized_image_from_uploaded_file('profileicon', $size_info['w'], $size_info['h'], $size_info['square']);
+
+ if ($resized) {
+ //@todo Make these actual entities. See exts #348.
+ $file = new ElggFile();
+ $file->owner_guid = $profile_owner_guid;
+ $file->setFilename("profile/{$profile_username}{$name}.jpg");
+ $file->open('write');
+ $file->write($resized);
+ $file->close();
+ $files[] = $file;
+ } else {
+ // cleanup on fail
+ foreach ($files as $file) {
+ $file->delete();
+ }
+
+ system_message(elgg_echo('profile:icon:notfound'));
+ forward($_SERVER['HTTP_REFERER']);
+ }
+}
+
+$profile_owner->icontime = time();
+if (trigger_elgg_event('profileiconupdate', $profile_owner->type, $profile_owner)) {
+ // pull this out into the river plugin.
+ //add_to_river('river/user/default/profileiconupdate','update',$user->guid,$user->guid);
+ system_message(elgg_echo("profile:icon:uploaded"));
+}
+
+//forward the user back to the upload page to crop
+forward($_SERVER['HTTP_REFERER']);
diff --git a/mod/profile/actions/resetdefaultprofile.php b/mod/profile/actions/resetdefaultprofile.php
index 2100c95c2..a6c90d4b7 100644
--- a/mod/profile/actions/resetdefaultprofile.php
+++ b/mod/profile/actions/resetdefaultprofile.php
@@ -1,30 +1,27 @@
<?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-2010
- * @link http://elgg.com/
- */
+/**
+ * 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-2010
+ * @link http://elgg.com/
+ */
- // Load configuration
- global $CONFIG;
+global $CONFIG;
+admin_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 = 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++;
+}
- $n++;
- }
+set_plugin_setting('user_defined_fields', FALSE, 'profile');
- set_plugin_setting('user_defined_fields', FALSE, 'profile');
+system_message(elgg_echo('profile:defaultprofile:reset'));
- system_message(elgg_echo('profile:defaultprofile:reset'));
-
- forward($_SERVER['HTTP_REFERER']);
-?>
+forward($_SERVER['HTTP_REFERER']); \ No newline at end of file