Add option to delete() to check the owner of the first search of reshares

remotes/origin/stable45
Michael Gapczynski 13 years ago
parent 0e9ab5cf2a
commit 82dea705d4
  1. 15
      lib/public/share.php

@ -707,15 +707,22 @@ class Share {
/** /**
* @brief Delete all reshares of an item * @brief Delete all reshares of an item
* @param int Id of item to delete * @param int Id of item to delete
* @param bool If true, exclude the parent from the delete * @param bool If true, exclude the parent from the delete (optional)
* @param string The user that the parent was shared with (optinal)
*/ */
private static function delete($parent, $excludeParent = false) { private static function delete($parent, $excludeParent = false, $uidOwner = null) {
$ids = array($parent); $ids = array($parent);
$parents = array($parent); $parents = array($parent);
while (!empty($parents)) { while (!empty($parents)) {
$parents = "'".implode("','", $parents)."'"; $parents = "'".implode("','", $parents)."'";
$query = \OC_DB::prepare('SELECT id FROM *PREFIX*share WHERE parent IN ('.$parents.')'); // Check the owner on the first search of reshares, useful for finding and deleting the reshares by a single user of a group share
$result = $query->execute(); if (count($ids) == 1 && isset($uidOwner)) {
$query = \OC_DB::prepare('SELECT id FROM *PREFIX*share WHERE parent IN ('.$parents.') AND uid_owner = ?');
$result = $query->execute(array($uidOwner));
} else {
$query = \OC_DB::prepare('SELECT id FROM *PREFIX*share WHERE parent IN ('.$parents.')');
$result = $query->execute();
}
// Reset parents array, only go through loop again if items are found // Reset parents array, only go through loop again if items are found
$parents = array(); $parents = array();
while ($item = $result->fetchRow()) { while ($item = $result->fetchRow()) {

Loading…
Cancel
Save