]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #3743 returning bool instead of int when setting a private setting
authorCash Costello <cash.costello@gmail.com>
Sat, 8 Oct 2011 22:33:37 +0000 (18:33 -0400)
committerCash Costello <cash.costello@gmail.com>
Sat, 8 Oct 2011 22:33:37 +0000 (18:33 -0400)
engine/classes/ElggPlugin.php
engine/lib/plugins.php
engine/lib/private_settings.php

index 4aee1e8984a3a3da8be58bebb14aa6593a49d08e..c4d6ec0340b55c09d6eae50f839bd87afd4cf925 100644 (file)
@@ -264,8 +264,6 @@ class ElggPlugin extends ElggObject {
        /**
         * Returns a plugin setting
         *
-        * @todo These need to be namespaced
-        *
         * @param string $name The setting name
         * @return mixed
         */
@@ -318,7 +316,6 @@ class ElggPlugin extends ElggObject {
         * Set a plugin setting for the plugin
         *
         * @todo This will only work once the plugin has a GUID.
-        * @todo These need to be namespaced.
         *
         * @param string $name  The name to set
         * @param string $value The value to set
@@ -329,13 +326,6 @@ class ElggPlugin extends ElggObject {
                if (!$this->guid) {
                        return false;
                }
-               // Hook to validate setting
-               $value = elgg_trigger_plugin_hook('setting', 'plugin', array(
-                       'plugin_id' => $this->pluginID,
-                       'plugin' => $this,
-                       'name' => $name,
-                       'value' => $value
-               ), $value);
 
                return $this->set($name, $value);
        }
@@ -902,7 +892,9 @@ class ElggPlugin extends ElggObject {
        }
 
        /**
-        * Save a value to private settings.
+        * Save a value as private setting or attribute.
+        *
+        * Attributes include title and description.
         *
         * @param string $name  Name
         * @param mixed  $value Value
@@ -920,6 +912,14 @@ class ElggPlugin extends ElggObject {
 
                        return true;
                } else {
+                       // Hook to validate setting
+                       $value = elgg_trigger_plugin_hook('setting', 'plugin', array(
+                               'plugin_id' => $this->pluginID,
+                               'plugin' => $this,
+                               'name' => $name,
+                               'value' => $value
+                       ), $value);
+
                        return $this->setPrivateSetting($name, $value);
                }
        }
index 853e5663dfc11edf606c399575de08b440928a2e..a9e8b21bc9df9ea64b447c236f489d895c85db96 100644 (file)
@@ -894,7 +894,7 @@ function elgg_get_plugin_user_setting($name, $user_guid = null, $plugin_id = nul
  * @param string $plugin_id Optional plugin name, if not specified
  *                          then it is detected from where you are calling from.
  *
- * @return int|false
+ * @return bool
  * @since 1.8.0
  */
 function elgg_set_plugin_setting($name, $value, $plugin_id = null) {
index ab90cca96c39e84fbcc0f511a46db1533694686e..95b1afa57e32223acef5a37042e4527be4da5435 100644 (file)
@@ -335,7 +335,7 @@ function get_all_private_settings($entity_guid) {
  * @param string $name        The name of the setting
  * @param string $value       The value of the setting
  *
- * @return mixed The setting ID, or false on failure
+ * @return bool
  * @see get_private_setting()
  * @see get_all_private_settings()
  * @see remove_private_setting()
@@ -358,10 +358,8 @@ function set_private_setting($entity_guid, $name, $value) {
                (entity_guid, name, value) VALUES
                ($entity_guid, '$name', '$value')
                ON DUPLICATE KEY UPDATE value='$value'");
-       if ($result === 0) {
-               return true;
-       }
-       return $result;
+
+       return $result !== false;
 }
 
 /**
@@ -370,7 +368,7 @@ function set_private_setting($entity_guid, $name, $value) {
  * @param int    $entity_guid The Entity GUID
  * @param string $name        The name of the setting
  *
- * @return true|false depending on success
+ * @return bool
  * @see get_private_setting()
  * @see get_all_private_settings()
  * @see set_private_setting()
@@ -390,8 +388,8 @@ function remove_private_setting($entity_guid, $name) {
        $name = sanitise_string($name);
 
        return delete_data("DELETE from {$CONFIG->dbprefix}private_settings
-               where name = '{$name}'
-               and entity_guid = {$entity_guid}");
+               WHERE name = '{$name}'
+               AND entity_guid = {$entity_guid}");
 }
 
 /**
@@ -399,7 +397,7 @@ function remove_private_setting($entity_guid, $name) {
  *
  * @param int $entity_guid The Entity GUID
  *
- * @return true|false depending on success
+ * @return bool
  * @see get_private_setting()
  * @see get_all_private_settings()
  * @see set_private_setting()
@@ -417,5 +415,5 @@ function remove_all_private_settings($entity_guid) {
        }
 
        return delete_data("DELETE from {$CONFIG->dbprefix}private_settings
-               where entity_guid = {$entity_guid}");
+               WHERE entity_guid = {$entity_guid}");
 }