aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/admin/plugins/activate.php3
-rw-r--r--actions/admin/plugins/deactivate.php3
-rw-r--r--actions/admin/site/update_advanced.php2
-rw-r--r--actions/avatar/remove.php34
-rw-r--r--actions/avatar/revert.php15
-rw-r--r--actions/comments/delete.php17
-rw-r--r--actions/friends/collections/add.php3
-rw-r--r--actions/plugins/settings/save.php2
-rw-r--r--actions/plugins/usersettings/save.php2
-rw-r--r--actions/profile/edit.php38
-rw-r--r--actions/river/delete.php21
-rw-r--r--actions/widgets/add.php3
12 files changed, 91 insertions, 52 deletions
diff --git a/actions/admin/plugins/activate.php b/actions/admin/plugins/activate.php
index 286cf5a4f..5234a4ca5 100644
--- a/actions/admin/plugins/activate.php
+++ b/actions/admin/plugins/activate.php
@@ -47,7 +47,8 @@ if (count($activated_guids) === 1) {
$url .= "?$query";
}
$plugin = get_entity($plugin_guids[0]);
- forward("$url#{$plugin->getID()}");
+ $id = $css_id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID());
+ forward("$url#$id");
} else {
// forward to top of page with a failure so remove any #foo
$url = $_SERVER['HTTP_REFERER'];
diff --git a/actions/admin/plugins/deactivate.php b/actions/admin/plugins/deactivate.php
index e7ce65625..354f4717d 100644
--- a/actions/admin/plugins/deactivate.php
+++ b/actions/admin/plugins/deactivate.php
@@ -46,7 +46,8 @@ if (count($plugin_guids) == 1) {
$url .= "?$query";
}
$plugin = get_entity($plugin_guids[0]);
- forward("$url#{$plugin->getID()}");
+ $id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID());
+ forward("$url#$id");
} else {
forward(REFERER);
}
diff --git a/actions/admin/site/update_advanced.php b/actions/admin/site/update_advanced.php
index 897a2f983..0fd8d1f35 100644
--- a/actions/admin/site/update_advanced.php
+++ b/actions/admin/site/update_advanced.php
@@ -53,8 +53,6 @@ if ($site = elgg_get_site_entity()) {
$user_default_access = (get_input('allow_user_default_access')) ? 1 : 0;
set_config('allow_user_default_access', $user_default_access, $site->getGUID());
- set_config('view', get_input('view'), $site->getGUID());
-
$debug = get_input('debug');
if ($debug) {
set_config('debug', $debug, $site->getGUID());
diff --git a/actions/avatar/remove.php b/actions/avatar/remove.php
new file mode 100644
index 000000000..cd38e456a
--- /dev/null
+++ b/actions/avatar/remove.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Avatar remove action
+ */
+
+$guid = get_input('guid');
+$user = get_entity($guid);
+if ($user) {
+ // Delete all icons from diskspace
+ $icon_sizes = elgg_get_config('icon_sizes');
+ foreach ($icon_sizes as $name => $size_info) {
+ $file = new ElggFile();
+ $file->owner_guid = $guid;
+ $file->setFilename("profile/{$guid}{$name}.jpg");
+ $filepath = $file->getFilenameOnFilestore();
+ if (!$file->delete()) {
+ elgg_log("Avatar file remove failed. Remove $filepath manually, please.", 'WARNING');
+ }
+ }
+
+ // Remove crop coords
+ unset($user->x1);
+ unset($user->x2);
+ unset($user->y1);
+ unset($user->y2);
+
+ // Remove icon
+ unset($user->icontime);
+ system_message(elgg_echo('avatar:remove:success'));
+} else {
+ register_error(elgg_echo('avatar:remove:fail'));
+}
+
+forward(REFERER);
diff --git a/actions/avatar/revert.php b/actions/avatar/revert.php
deleted file mode 100644
index 8cff40a68..000000000
--- a/actions/avatar/revert.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-/**
- * Avatar revert action
- */
-
-$guid = get_input('guid');
-$user = get_entity($guid);
-if ($user) {
- unset($user->icontime);
- system_message(elgg_echo('avatar:revert:success'));
-} else {
- register_error(elgg_echo('avatar:revert:fail'));
-}
-
-forward(REFERER);
diff --git a/actions/comments/delete.php b/actions/comments/delete.php
index f8458a152..f2c058ff4 100644
--- a/actions/comments/delete.php
+++ b/actions/comments/delete.php
@@ -12,19 +12,12 @@ if (!elgg_is_logged_in()) {
// Make sure we can get the comment in question
$annotation_id = (int) get_input('annotation_id');
-if ($comment = elgg_get_annotation_from_id($annotation_id)) {
-
- $entity = get_entity($comment->entity_guid);
-
- if ($comment->canEdit()) {
- $comment->delete();
- system_message(elgg_echo("generic_comment:deleted"));
- forward($entity->getURL());
- }
-
+$comment = elgg_get_annotation_from_id($annotation_id);
+if ($comment && $comment->canEdit()) {
+ $comment->delete();
+ system_message(elgg_echo("generic_comment:deleted"));
} else {
- $url = "";
+ register_error(elgg_echo("generic_comment:notdeleted"));
}
-register_error(elgg_echo("generic_comment:notdeleted"));
forward(REFERER); \ No newline at end of file
diff --git a/actions/friends/collections/add.php b/actions/friends/collections/add.php
index 1e2bc1d5c..9dc17b37e 100644
--- a/actions/friends/collections/add.php
+++ b/actions/friends/collections/add.php
@@ -20,8 +20,7 @@ if ($id) {
$result = update_access_collection($id, $friends);
if ($result) {
system_message(elgg_echo("friends:collectionadded"));
- // go to the collections page
- forward("pg/collections/" . get_loggedin_user()->username);
+ forward("collections/" . elgg_get_logged_in_user_entity()->username);
} else {
register_error(elgg_echo("friends:nocollectionname"));
forward(REFERER);
diff --git a/actions/plugins/settings/save.php b/actions/plugins/settings/save.php
index e94127f7c..581a2f9ec 100644
--- a/actions/plugins/settings/save.php
+++ b/actions/plugins/settings/save.php
@@ -3,7 +3,7 @@
* Saves global plugin settings.
*
* This action can be overriden for a specific plugin by creating the
- * settings/<plugin_id>/save action in that plugin.
+ * <plugin_id>/settings/save action in that plugin.
*
* @uses array $_REQUEST['params'] A set of key/value pairs to save to the ElggPlugin entity
* @uses int $_REQUEST['plugin_id'] The ID of the plugin
diff --git a/actions/plugins/usersettings/save.php b/actions/plugins/usersettings/save.php
index 71ad2ad7b..f6b8ab0b6 100644
--- a/actions/plugins/usersettings/save.php
+++ b/actions/plugins/usersettings/save.php
@@ -3,7 +3,7 @@
* Saves user-specific plugin settings.
*
* This action can be overriden for a specific plugin by creating the
- * settings/<plugin_id>/save action in that plugin.
+ * <plugin_id>/usersettings/save action in that plugin.
*
* @uses array $_REQUEST['params'] A set of key/value pairs to save to the ElggPlugin entity
* @uses int $_REQUEST['plugin_id'] The id of the plugin
diff --git a/actions/profile/edit.php b/actions/profile/edit.php
index 8ca60f246..b6d73ff2d 100644
--- a/actions/profile/edit.php
+++ b/actions/profile/edit.php
@@ -51,7 +51,7 @@ foreach ($profile_fields as $shortname => $valuetype) {
if ($valuetype == 'tags') {
$value = string_to_tag_array($value);
}
-
+
$input[$shortname] = $value;
}
@@ -71,24 +71,30 @@ if (sizeof($input) > 0) {
foreach ($input as $shortname => $value) {
$options = array(
'guid' => $owner->guid,
- 'metadata_name' => $shortname
+ 'metadata_name' => $shortname,
+ 'limit' => false
);
elgg_delete_metadata($options);
- 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($owner->guid, $shortname, $interval, 'text', $owner->guid, $access_id, $multiple);
+
+ if(!is_null($value) && ($value !== '')){
+ // only create metadata for non empty values (0 is allowed) to prevent metadata records with empty string values #4858
+
+ 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($owner->guid, $shortname, $interval, 'text', $owner->guid, $access_id, $multiple);
+ }
+ } else {
+ create_metadata($owner->getGUID(), $shortname, $value, 'text', $owner->getGUID(), $access_id);
}
- } else {
- create_metadata($owner->getGUID(), $shortname, $value, 'text', $owner->getGUID(), $access_id);
}
}
diff --git a/actions/river/delete.php b/actions/river/delete.php
new file mode 100644
index 000000000..0d8297932
--- /dev/null
+++ b/actions/river/delete.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * River item delete action
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+$id = get_input('id', false);
+
+if ($id !== false && elgg_is_admin_logged_in()) {
+ if (elgg_delete_river(array('id' => $id))) {
+ system_message(elgg_echo('river:delete:success'));
+ } else {
+ register_error(elgg_echo('river:delete:fail'));
+ }
+} else {
+ register_error(elgg_echo('river:delete:fail'));
+}
+
+forward(REFERER);
diff --git a/actions/widgets/add.php b/actions/widgets/add.php
index f65d11134..d7b2f291c 100644
--- a/actions/widgets/add.php
+++ b/actions/widgets/add.php
@@ -9,6 +9,7 @@
$owner_guid = get_input('owner_guid');
$handler = get_input('handler');
$context = get_input('context');
+$show_access = (bool)get_input('show_access', true);
$column = get_input('column', 1);
$default_widgets = get_input('default_widgets', 0);
@@ -29,7 +30,7 @@ if (!empty($owner_guid)) {
$widget->move($column, 0);
// send widget html for insertion
- echo elgg_view_entity($widget);
+ echo elgg_view_entity($widget, array('show_access' => $show_access));
//system_message(elgg_echo('widgets:add:success'));
forward(REFERER);