aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/deprecated-1.8.php150
-rw-r--r--engine/lib/plugins.php104
2 files changed, 183 insertions, 71 deletions
diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php
index 67e150173..684e8f9b3 100644
--- a/engine/lib/deprecated-1.8.php
+++ b/engine/lib/deprecated-1.8.php
@@ -2946,4 +2946,154 @@ function isloggedin() {
function isadminloggedin() {
elgg_deprecated_notice('isadminloggedin() is deprecated by elgg_is_admin_logged_in()', 1.8);
return elgg_is_admin_logged_in();
+}
+
+
+/**
+ * Loads plugins
+ *
+ * @deprecate 1.8 Use elgg_load_plugins()
+ *
+ * @return bool
+ */
+function load_plugins() {
+ elgg_deprecated_notice('load_plugins() is deprecated by elgg_load_plugins()', 1.8);
+ return elgg_load_plugins();
+}
+
+/**
+ * Find the plugin settings for a user.
+ *
+ * @param string $plugin_id Plugin name.
+ * @param int $user_guid The guid who's settings to retrieve.
+ *
+ * @deprecated 1.8 Use elgg_get_all_plugin_user_settings() or ElggPlugin->getAllUserSettings()
+ * @return StdClass Object with all user settings.
+ */
+function find_plugin_usersettings($plugin_id = null, $user_guid = 0) {
+ elgg_deprecated_notice('find_plugin_usersettings() is deprecated by elgg_get_all_plugin_user_settings()', 1.8);
+
+ $settings = elgg_get_all_plugin_user_settings($user_guid, $plugin_id);
+ $return = false;
+
+ if ($settings) {
+ $return = new stdClass;
+
+ foreach ($settings as $k => $v) {
+ $return->$k = $v;
+ }
+ }
+
+ return $return;
+}
+
+/**
+ * Set a user specific setting for a plugin.
+ *
+ * @param string $name The name - note, can't be "title".
+ * @param mixed $value The value.
+ * @param int $user_guid Optional user.
+ * @param string $plugin_id Optional plugin name, if not specified then it
+ * is detected from where you are calling from.
+ *
+ * @return bool
+ * @deprecated 1.8 Use elgg_set_plugin_user_setting() or ElggPlugin->setUserSetting()
+ */
+function set_plugin_usersetting($name, $value, $user_guid = 0, $plugin_id = "") {
+ elgg_deprecated_notice('find_plugin_usersettings() is deprecated by elgg_get_all_plugin_user_settings()', 1.8);
+ return elgg_set_plugin_user_setting($name, $value, $user_guid, $plugin_id);
+}
+
+/**
+ * Clears a user-specific plugin setting
+ *
+ * @param str $name Name of the plugin setting
+ * @param int $user_guid Defaults to logged in user
+ * @param str $plugin_id Defaults to contextual plugin name
+ *
+ * @deprecated 1.8 Use elgg_unset_plugin_user_setting or ElggPlugin->unsetUserSetting().
+ * @return bool Success
+ */
+function clear_plugin_usersetting($name, $user_guid = 0, $plugin_id = '') {
+ elgg_deprecated_notice('clear_plugin_usersetting() is deprecated by elgg_unset_plugin_usersetting()', 1.8);
+ return elgg_unset_plugin_user_setting($name, $user_guid, $plugin_id);
+}
+
+/**
+ * Get a user specific setting for a plugin.
+ *
+ * @param string $name The name.
+ * @param int $user_guid Guid of owning user
+ * @param string $plugin_id Optional plugin name, if not specified
+ * it is detected from where you are calling.
+ *
+ * @deprecated 1.8 Use elgg_get_plugin_user_setting() or ElggPlugin->getUserSetting()
+ * @return mixed
+ */
+function get_plugin_usersetting($name, $user_guid = 0, $plugin_id = "") {
+ elgg_deprecated_notice('get_plugin_usersetting() is deprecated by elgg_get_plugin_user_setting()', 1.8);
+ return elgg_get_plugin_user_setting($name, $user_guid, $plugin_id);
+}
+
+
+/**
+ * Set a setting for a plugin.
+ *
+ * @param string $name The name - note, can't be "title".
+ * @param mixed $value The value.
+ * @param string $plugin_id Optional plugin name, if not specified
+ * then it is detected from where you are calling from.
+ *
+ * @deprecated 1.8 Use elgg_set_plugin_setting() or ElggPlugin->setSetting()
+ * @return int|false
+ */
+function set_plugin_setting($name, $value, $plugin_id = null) {
+ elgg_deprecated_notice('set_plugin_setting() is deprecated by elgg_set_plugin_setting()', 1.8);
+ return elgg_set_plugin_setting($name, $value, $plugin_id);
+}
+
+/**
+ * Get setting for a plugin.
+ *
+ * @param string $name The name.
+ * @param string $plugin_id Optional plugin name, if not specified
+ * then it is detected from where you are calling from.
+ *
+ * @deprecated 1.8 Use elgg_get_plugin_setting() or ElggPlugin->getSetting()
+ * @return mixed
+ */
+function get_plugin_setting($name, $plugin_id = "") {
+ elgg_deprecated_notice('get_plugin_setting() is deprecated by elgg_get_plugin_setting()', 1.8);
+ return elgg_get_plugin_setting($name, $plugin_id);
+}
+
+/**
+ * Clear a plugin setting.
+ *
+ * @param string $name The name.
+ * @param string $plugin_id Optional plugin name, if not specified
+ * then it is detected from where you are calling from.
+ *
+ * @deprecated 1.8 Use elgg_unset_plugin_setting() or ElggPlugin->unsetSetting()
+ * @return bool
+ */
+function clear_plugin_setting($name, $plugin_id = "") {
+ elgg_deprecated_notice('clear_plugin_setting() is deprecated by elgg_unset_plugin_setting()', 1.8);
+ return elgg_unset_plugin_setting($name, $plugin_id);
+}
+
+
+/**
+ * Unsets all plugin settings for a plugin.
+ *
+ * @param string $plugin_id Optional plugin name, if not specified
+ * then it is detected from where you are calling from.
+ *
+ * @return bool
+ * @deprecated 1.8 Use elgg_unset_all_plugin_settings() or ElggPlugin->unsetAllSettings()
+ * @since 1.7.0
+ */
+function clear_all_plugin_settings($plugin_id = "") {
+ elgg_deprecated_notice('clear_all_plugin_settings() is deprecated by elgg_unset_all_plugin_setting()', 1.8);
+ return elgg_unset_all_plugin_settings($plugin_id);
} \ No newline at end of file
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index 1605ed76f..fc3dc8006 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -177,18 +177,18 @@ function elgg_generate_plugin_entities() {
/**
* Returns an ElggPlugin object with the path $path.
*
- * @param string $id The id (dir name) of the plugin. NOT the guid.
+ * @param string $plugin_id The id (dir name) of the plugin. NOT the guid.
* @return mixed ElggPlugin or false.
*/
-function elgg_get_plugin_from_id($id) {
- $id = sanitize_string($id);
+function elgg_get_plugin_from_id($plugin_id) {
+ $plugin_id = sanitize_string($plugin_id);
$db_prefix = get_config('dbprefix');
$options = array(
'type' => 'object',
'subtype' => 'plugin',
'joins' => array("JOIN {$db_prefix}objects_entity oe on oe.guid = e.guid"),
- 'wheres' => array("oe.title = '$id'"),
+ 'wheres' => array("oe.title = '$plugin_id'"),
'limit' => 1
);
@@ -476,19 +476,6 @@ function elgg_reindex_plugin_priorities() {
}
/**
- * Loads plugins
- *
- * @deprecate 1.8
- *
- * @return bool
- */
-function load_plugins() {
- elgg_deprecated_notice('load_plugins() is deprecated by elgg_load_plugins()', 1.8);
-
- return elgg_load_plugins();
-}
-
-/**
* Namespaces a string to be used as a private setting for a plugin.
*
* @param string $type The type of value: user_setting or internal.
@@ -783,51 +770,26 @@ function elgg_get_calling_plugin_entity() {
}
/**
- * Find the plugin settings for a user.
+ * Returns an array of all plugin settings for a user.
*
- * @param string $plugin_id Plugin name.
- * @param int $user_guid The guid who's settings to retrieve.
+ * @param mixed $user_guid The user GUID or null for the currently logged in user.
+ * @param string $plugin_id The plugin ID
+ * @return array
*
- * @return StdClass Object with all user settings.
+ * @since 1.8
*/
-function find_plugin_usersettings($plugin_id = null, $user_guid = 0) {
- $plugin_id = sanitise_string($plugin_id);
- $user_guid = (int)$user_guid;
- $db_prefix = elgg_get_config('dbprefix');
- $ps_prefix = elgg_namespace_plugin_private_setting('user_setting', "$plugin_id:");
- $ps_prefix_len = strlen($ps_prefix);
-
- if (!$plugin_id) {
- $plugin_id = elgg_get_calling_plugin_id();
- }
-
- if ($user_guid == 0) {
- $user_guid = elgg_get_logged_in_user_guid();
+function elgg_get_all_plugin_user_settings($user_guid = null, $plugin_id = null) {
+ if ($plugin_id) {
+ $plugin = elgg_get_plugin_from_id($plugin_id);
+ } else {
+ $plugin = elgg_get_calling_plugin_entity();
}
- // Get private settings for user
- $q = "SELECT * FROM {$db_prefix}private_settings
- WHERE entity_guid = $user_guid
- AND name LIKE '$ps_prefix$plugin_id'";
-
- $private_settings = get_data($q);
- if ($private_settings) {
- $return = new stdClass;
-
- foreach ($private_settings as $setting) {
- $name = substr($setting->name, $ps_prefix_len);
- $value = $setting->value;
-
- // @todo why?
- if (strpos($key, $ps_prefix) === 0) {
- $return->$name = $value;
- }
- }
-
- return $return;
+ if (!$plugin instanceof ElggPlugin) {
+ return false;
}
- return false;
+ return $plugin->getAllUserSettings($user_guid);
}
/**
@@ -841,7 +803,7 @@ function find_plugin_usersettings($plugin_id = null, $user_guid = 0) {
*
* @return bool
*/
-function set_plugin_usersetting($name, $value, $user_guid = 0, $plugin_id = "") {
+function elgg_set_plugin_user_setting($name, $value, $user_guid = null, $plugin_id = null) {
if ($plugin_id) {
$plugin = elgg_get_plugin_from_id($plugin_id);
} else {
@@ -856,7 +818,7 @@ function set_plugin_usersetting($name, $value, $user_guid = 0, $plugin_id = "")
}
/**
- * Clears a user-specific plugin setting
+ * Unsets a user-specific plugin setting
*
* @param str $name Name of the plugin setting
* @param int $user_guid Defaults to logged in user
@@ -864,7 +826,7 @@ function set_plugin_usersetting($name, $value, $user_guid = 0, $plugin_id = "")
*
* @return bool Success
*/
-function clear_plugin_usersetting($name, $user_guid = 0, $plugin_id = '') {
+function elgg_unset_plugin_user_setting($name, $user_guid = null, $plugin_id = null) {
if ($plugin_id) {
$plugin = elgg_get_plugin_from_id($plugin_id);
} else {
@@ -875,7 +837,7 @@ function clear_plugin_usersetting($name, $user_guid = 0, $plugin_id = '') {
return false;
}
- return $plugin->removeUserSetting($name, $user_guid);
+ return $plugin->unsetUserSetting($name, $user_guid);
}
/**
@@ -888,7 +850,7 @@ function clear_plugin_usersetting($name, $user_guid = 0, $plugin_id = '') {
*
* @return mixed
*/
-function get_plugin_usersetting($name, $user_guid = 0, $plugin_id = "") {
+function elgg_get_plugin_user_setting($name, $user_guid = null, $plugin_id = null) {
if ($plugin_id) {
$plugin = elgg_get_plugin_from_id($plugin_id);
} else {
@@ -912,7 +874,7 @@ function get_plugin_usersetting($name, $user_guid = 0, $plugin_id = "") {
*
* @return int|false
*/
-function set_plugin_setting($name, $value, $plugin_id = null) {
+function elgg_set_plugin_setting($name, $value, $plugin_id = null) {
if ($plugin_id) {
$plugin = elgg_get_plugin_from_id($plugin_id);
} else {
@@ -935,7 +897,7 @@ function set_plugin_setting($name, $value, $plugin_id = null) {
*
* @return mixed
*/
-function get_plugin_setting($name, $plugin_id = "") {
+function elgg_get_plugin_setting($name, $plugin_id = null) {
if ($plugin_id) {
$plugin = elgg_get_plugin_from_id($plugin_id);
} else {
@@ -950,7 +912,7 @@ function get_plugin_setting($name, $plugin_id = "") {
}
/**
- * Clear a plugin setting.
+ * Unsets a plugin setting.
*
* @param string $name The name.
* @param string $plugin_id Optional plugin name, if not specified
@@ -958,7 +920,7 @@ function get_plugin_setting($name, $plugin_id = "") {
*
* @return bool
*/
-function clear_plugin_setting($name, $plugin_id = "") {
+function elgg_unset_plugin_setting($name, $plugin_id = null) {
if ($plugin_id) {
$plugin = elgg_get_plugin_from_id($plugin_id);
} else {
@@ -969,30 +931,30 @@ function clear_plugin_setting($name, $plugin_id = "") {
return false;
}
- return $plugin->removeSetting($name);
+ return $plugin->unsetSetting($name);
}
/**
- * Clear all plugin settings.
+ * Unsets all plugin settings for a plugin.
*
* @param string $plugin_id Optional plugin name, if not specified
* then it is detected from where you are calling from.
*
* @return bool
- * @since 1.7.0
+ * @since 1.8
*/
-function clear_all_plugin_settings($plugin_id = "") {
+function elgg_unset_all_plugin_settings($plugin_id = null) {
if ($plugin_id) {
$plugin = elgg_get_plugin_from_id($plugin_id);
} else {
$plugin = elgg_get_calling_plugin_entity();
}
- if ($plugin) {
- $plugin->removeAllSettings();
+ if (!$plugin) {
+ return false;
}
- return false;
+ return $plugin->unsetAllSettings();
}
/**