aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/entities.php8
-rw-r--r--engine/lib/users.php39
2 files changed, 42 insertions, 5 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index b434f8f7f..5a794024b 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1485,7 +1485,8 @@
if ($entity->canEdit()) {
if ($reason)
- $entity->disable_reason = $reason;
+ create_metadata($guid, 'disable_reason', $reason,'', 0, 2);
+ //$entity->disable_reason = $reason;
$res = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='no' where guid={$guid}");
@@ -1517,7 +1518,10 @@
access_show_hidden_entities($access_status);
- return update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='yes' where guid={$guid}");
+ $result = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='yes' where guid={$guid}");
+ $entity->clearMetaData('disable_reason');
+
+ return $result;
}
}
}
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 66696ea07..252464d20 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -541,7 +541,7 @@
}
-/**
+ /**
* Obtains a list of objects owned by a user's friends
*
* @param int $user_guid The GUID of the user to get the friends of
@@ -771,8 +771,10 @@
$offset = (int)$offset;
$time = time() - $seconds;
+
+ $access = get_access_sql_suffix("e");
- $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid where u.last_action >= {$time} order by u.last_action desc limit {$offset},{$limit}";
+ $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid where u.last_action >= {$time} and $access order by u.last_action desc limit {$offset},{$limit}";
return get_data($query, "entity_row_to_elggstar");
}
@@ -1154,6 +1156,33 @@
$time = time();
update_data("update {$CONFIG->dbprefix}users_entity set prev_last_action = last_action, last_action = {$time} where guid = {$user_guid}");
+ }
+
+ /**
+ * A permissions plugin hook that grants access to users if they are newly created - allows
+ * for email activation.
+ *
+ * TODO: Do this in a better way!
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params
+ */
+ function new_user_enable_permissions_check($hook, $entity_type, $returnvalue, $params)
+ {
+ $entity = $params['entity'];
+ $user = $params['user'];
+ if (($entity) && ($entity instanceof ElggUser))
+ {
+ if (
+ (($entity->disable_reason == 'new_user') || (
+ $entity->last_action == 0 && $entity->last_login == 0
+ ))
+ && (!isloggedin()))
+ return true;
+
+ }
}
/**
@@ -1228,7 +1257,11 @@
register_plugin_hook('usersettings:save','user','users_settings_save');
register_plugin_hook('search','all','search_list_users_by_name');
-
+
+
+ // Handle a special case for newly created users when the user is not logged in
+ // TODO: handle this better!
+ //register_plugin_hook('permissions_check','user','new_user_enable_permissions_check');
}
/**