CS, remove/fix unused variables, other stuff detected by CI.
authorJan Schneider <jan@horde.org>
Wed, 22 Dec 2010 10:24:12 +0000 (11:24 +0100)
committerJan Schneider <jan@horde.org>
Wed, 22 Dec 2010 13:58:10 +0000 (14:58 +0100)
framework/Share/lib/Horde/Share/Base.php
framework/Share/lib/Horde/Share/Datatree.php
framework/Share/lib/Horde/Share/Kolab.php
framework/Share/lib/Horde/Share/Object/Datatree.php
framework/Share/lib/Horde/Share/Object/Kolab.php
framework/Share/lib/Horde/Share/Object/Sql/Hierarchical.php
framework/Share/lib/Horde/Share/Sql.php
framework/Share/lib/Horde/Share/Sql/Hierarchical.php

index 934ad85..f93e87b 100644 (file)
@@ -346,7 +346,7 @@ abstract class Horde_Share_Base
         }
 
         $shares = $this->getShares($shares);
-        if (is_null($sort_by)) {
+        if (is_null($params['sort_by'])) {
             $this->_sortList = $shares;
             uasort($shares, array($this, '_sortShares'));
             $this->_sortList = null;
@@ -434,14 +434,13 @@ abstract class Horde_Share_Base
      *
      * @param Horde_Share_Object $share  The new share object.
      *
-     * @return boolean
      * @throws Horde_Share_Exception
      */
     public function addShare(Horde_Share_Object $share)
     {
         // Run the results through the callback, if configured.
         $this->runCallback('add', array($share));
-        $result = $this->_addShare($share);
+        $this->_addShare($share);
 
         /* Store new share in the caches. */
         $id = $share->getId();
@@ -451,8 +450,6 @@ abstract class Horde_Share_Base
 
         /* Reset caches that depend on unknown criteria. */
         $this->_listcache = array();
-
-        return $result;
     }
 
     /**
@@ -486,7 +483,7 @@ abstract class Horde_Share_Base
         /* Reset caches that depend on unknown criteria. */
         $this->_listcache = array();
 
-        return $this->_removeShare($share);
+        $this->_removeShare($share);
     }
 
     /**
@@ -494,7 +491,6 @@ abstract class Horde_Share_Base
      *
      * @param Horde_Share_Object $share  The share to remove.
      *
-     * @return boolean
      * @throws Horde_Share_Exception
      */
     abstract protected function _removeShare(Horde_Share_Object $share);
@@ -576,6 +572,7 @@ abstract class Horde_Share_Base
      */
     public function toDriverCharset($data)
     {
+        return $data;
     }
 
     /**
index ec79b5b..e6ce040 100644 (file)
@@ -228,7 +228,7 @@ class Horde_Share_Datatree extends Horde_Share_Base
      */
     protected function _addShare(Horde_Share_Object $share)
     {
-        return $this->_datatree->add($share->datatreeObject);
+        Horde_Exception_Pear::catchError($this->_datatree->add($share->datatreeObject));
     }
 
     /**
@@ -238,7 +238,7 @@ class Horde_Share_Datatree extends Horde_Share_Base
      */
     protected function _removeShare(Horde_Share_Object $share)
     {
-        return $this->_datatree->remove($share->datatreeObject);
+        Horde_Exception_Pear::catchError($this->_datatree->remove($share->datatreeObject));
     }
 
     /**
@@ -308,7 +308,8 @@ class Horde_Share_Datatree extends Horde_Share_Base
                             array('field' => 'key', 'op' => 'IN', 'test' => array_keys($groups)),
                             array('field' => 'value', 'op' => '&', 'test' => $perm)));
                 }
-            } catch (Horde_Group_Exception $e) {}
+            } catch (Horde_Group_Exception $e) {
+            }
         } else {
             $criteria = array(
                 'AND' => array(
index 044b3f5..c671705 100644 (file)
@@ -243,7 +243,7 @@ class Horde_Share_Kolab extends Horde_Share_Base
      */
     protected function _addShare(Horde_Share_Object $share)
     {
-        return $share->save();
+        $share->save();
     }
 
     /**
@@ -253,8 +253,7 @@ class Horde_Share_Kolab extends Horde_Share_Base
      */
     protected function _removeShare(Horde_Share_Object $share)
     {
-        $share_id = $share->getName();
-        $result = $share->delete();
+        $share->delete();
     }
 
     /**
@@ -299,7 +298,7 @@ class Horde_Share_Kolab extends Horde_Share_Base
 
         /* The value does not matter here as the share will rewrite it */
         $share->set('name', '');
-        $result = $this->addShare($share);
+        $this->addShare($share);
 
         return $share;
     }
index b6bb852..ac5cbb6 100644 (file)
@@ -165,7 +165,7 @@ class Horde_Share_Object_Datatree extends Horde_Share_Object
      * @return Horde_Perms_Permission  Permission object that represents the
      *                           permissions on this share
      */
-    function getPermission()
+    public function getPermission()
     {
         $perm = new Horde_Perms_Permission($this->datatreeObject->getName());
         $perm->data = isset($this->datatreeObject->data['perm'])
index 1fd4bf7..a97fb1c 100644 (file)
@@ -149,7 +149,7 @@ class Horde_Share_Object_Kolab extends Horde_Share_Object implements Serializabl
             $this->_folder = $folder;
             $this->_folder_name = $folder->name;
         } else {
-           throw new Horde_Share_Exception(Horde_Share_Translation::t("The share has already been initialized!"));
+            throw new Horde_Share_Exception(Horde_Share_Translation::t("The share has already been initialized!"));
         }
     }
 
index f1dc236..73d6bc8 100644 (file)
@@ -127,7 +127,7 @@ class Horde_Share_Object_Sql_Hierarchical extends Horde_Share_Object_Sql
         }
 
         /* Now we can reset the children's parent */
-        foreach($children as $child) {
+        foreach ($children as $child) {
             $child->setParent($this);
         }
 
index e57fe31..ce4b5ce 100644 (file)
@@ -225,7 +225,7 @@ class Horde_Share_Sql extends Horde_Share_Base
             throw new Horde_Share_Exception($e->getMessage());
         }
         if (!$results) {
-            $this->_logger->err(sprintf('Share name %s not found', $name));
+            $this->_logger->err(sprintf('Share id %s not found', $id));
             throw new Horde_Exception_NotFound();
         }
         $data = $this->_fromDriverCharset($results);
@@ -290,7 +290,7 @@ class Horde_Share_Sql extends Horde_Share_Base
         }
 
         $sharelist = array();
-        foreach ($shares as $id => $data) {
+        foreach ($shares as $data) {
             $this->_getSharePerms($data);
             $sharelist[$data['share_name']] = $this->_createObject($data);
         }
@@ -353,7 +353,7 @@ class Horde_Share_Sql extends Horde_Share_Base
         }
 
         $sharelist = array();
-        foreach ($shares as $id => $data) {
+        foreach ($shares as $data) {
             $this->_getSharePerms($data);
             $sharelist[$data['share_name']] = $this->_createObject($data);
         }
@@ -455,7 +455,7 @@ class Horde_Share_Sql extends Horde_Share_Base
         }
 
         $sharelist = array();
-        foreach ($shares as $id => $data) {
+        foreach ($shares as $data) {
             $this->_getSharePerms($data);
             $sharelist[$data['share_name']] = $this->_createObject($data);
         }
@@ -480,6 +480,8 @@ class Horde_Share_Sql extends Horde_Share_Base
      */
     protected function _listShares($userid, array $params = array())
     {
+        // We overwrite listShares(), this method is only implemented because
+        // it's abstract in the base class.
     }
 
     /**
@@ -563,7 +565,7 @@ class Horde_Share_Sql extends Horde_Share_Base
      */
     protected function _addShare(Horde_Share_Object $share)
     {
-        return $share->save();
+        $share->save();
     }
 
     /**
@@ -587,8 +589,6 @@ class Horde_Share_Sql extends Horde_Share_Base
                 throw new Horde_Share_Exception($e->getMessage());
             }
         }
-
-        return true;
     }
 
     /**
@@ -635,7 +635,7 @@ class Horde_Share_Sql extends Horde_Share_Base
             $where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_creator', '&', $perm) . ')';
 
             // (name == perm_creator and val & $perm)
-            $where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_default',  '&', $perm) . ')';
+            $where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_default', '&', $perm) . ')';
 
             // (name == perm_users and key == $userid and val & $perm)
             $query .= ' LEFT JOIN ' . $this->_table . '_users u ON u.share_id = s.share_id';
@@ -686,10 +686,10 @@ class Horde_Share_Sql extends Horde_Share_Base
      */
     protected function _fromDriverCharset($data)
     {
-        foreach ($data as $key => $value) {
+        foreach ($data as $key => &$value) {
             if (substr($key, 0, 9) == 'attribute') {
-                $data[$key] = Horde_String::convertCharset(
-                    $data[$key], $this->_db->getOption('charset'), 'UTF-8');
+                $value = Horde_String::convertCharset(
+                    $value, $this->_db->getOption('charset'), 'UTF-8');
             }
         }
 
@@ -707,10 +707,10 @@ class Horde_Share_Sql extends Horde_Share_Base
             return $data;
         }
 
-        foreach ($data as $key => $value) {
+        foreach ($data as $key => &$value) {
             if (substr($key, 0, 9) == 'attribute') {
-                $data[$key] = Horde_String::convertCharset(
-                    $data[$key], 'UTF-8', $this->_db->getOption('charset'));
+                $value = Horde_String::convertCharset(
+                    $value, 'UTF-8', $this->_db->getOption('charset'));
             }
         }
 
index 6b213e0..50d35df 100644 (file)
@@ -161,8 +161,9 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql
      * @return string  The criteria string for fetching this user's shares.
      * @throws Horde_Share_Exception
      */
-    public function getShareCriteria($userid, $perm = Horde_Perms::SHOW, $attributes = null,
-                                     $parent = null, $allLevels = true)
+    public function getShareCriteria($userid, $perm = Horde_Perms::SHOW,
+                                     $attributes = null, $parent = null,
+                                     $allLevels = true)
     {
         static $criteria = array();
 
@@ -171,7 +172,7 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql
         } else {
             $parent_id = $parent;
         }
-        $key = hash('sha1', serialize(array($userid, $perm, $parent_id, $allLevels, $attributes, $ignorePerms)));
+        $key = hash('sha1', serialize(array($userid, $perm, $parent_id, $allLevels, $attributes)));
         if (isset($criteria[$key])) {
             return $criteria[$key];
         }
@@ -190,7 +191,7 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql
                 $where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_creator', '&', $perm) . ')';
 
                 // (name == perm_creator and val & $perm)
-                $where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_default',  '&', $perm) . ')';
+                $where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_default', '&', $perm) . ')';
 
                 // (name == perm_users and key == $userid and val & $perm)
                 $query .= ' LEFT JOIN ' . $this->_table . '_users u ON u.share_id = s.share_id';
@@ -412,7 +413,7 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql
         return $all_shares;
     }
 
-   /**
+    /**
      * Removes a share from the shares system permanently. This will recursively
      * delete all child shares as well.
      *
@@ -426,14 +427,13 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql
         $children = $share->getChildren(null, null, true);
 
         /* Remove share from the caches. */
-        $id = $share->getId();
         $this->_cache = array();
         $this->_listCache = array();
         foreach ($children as $child) {
-            $result = $this->_removeShare($child);
+            $this->_removeShare($child);
         }
 
-        return $this->_removeShare($share);
+        $this->_removeShare($share);
     }
 
     /**
@@ -537,7 +537,7 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql
             . $this->getShareCriteria($userid, $perm, $attributes, $parent, $allLevels);
 
         try {
-            $result = $this->_db->selectValue($query);
+            $this->_db->selectValue($query);
         } catch (Horde_Db_Exception $e) {
             throw new Horde_Share_Exception($e);
         }