From 2d8607fae92e083a431d476f670acdbc1cfdc947 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Fri, 7 Mar 2014 15:38:14 +0100 Subject: [PATCH] don't assign variables in if condition --- lib/private/share/share.php | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 3471514c48..ae7b6f5fbc 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -556,8 +556,8 @@ class Share extends \OC\Share\Constants { * @return Returns true on success or false on failure */ public static function unshare($itemType, $itemSource, $shareType, $shareWith) { - if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(), - self::FORMAT_NONE, null, 1)) { + $item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(),self::FORMAT_NONE, null, 1); + if (!empty($item)) { self::unshareItem($item); return true; } @@ -605,7 +605,8 @@ class Share extends \OC\Share\Constants { * Unsharing from self is not allowed for items inside collections */ public static function unshareFromSelf($itemType, $itemTarget) { - if ($item = self::getItemSharedWith($itemType, $itemTarget)) { + $item = self::getItemSharedWith($itemType, $itemTarget); + if (!empty($item)) { if ((int)$item['share_type'] === self::SHARE_TYPE_GROUP) { // Insert an extra row for the group share and set permission // to 0 to prevent it from showing up for the user @@ -746,22 +747,20 @@ class Share extends \OC\Share\Constants { * @return \OCP\Share_Backend */ public static function setExpirationDate($itemType, $itemSource, $date) { - if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), - self::FORMAT_NONE, null, -1, false)) { - if (!empty($items)) { - if ($date == '') { - $date = null; - } else { - $date = new \DateTime($date); - } - $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `expiration` = ? WHERE `id` = ?'); - $query->bindValue(1, $date, 'datetime'); - foreach ($items as $item) { - $query->bindValue(2, (int) $item['id']); - $query->execute(); - } - return true; + $items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), self::FORMAT_NONE, null, -1, false); + if (!empty($items)) { + if ($date == '') { + $date = null; + } else { + $date = new \DateTime($date); } + $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `expiration` = ? WHERE `id` = ?'); + $query->bindValue(1, $date, 'datetime'); + foreach ($items as $item) { + $query->bindValue(2, (int) $item['id']); + $query->execute(); + } + return true; } return false; }