From: Michael J. Rubinsky Date: Wed, 19 May 2010 19:38:34 +0000 (-0400) Subject: more Horde_Share change tracking X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d6f829118e43c678b1c0b3469d45eff54b5488d6;p=horde.git more Horde_Share change tracking --- diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index b3a782330..f500b3daa 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -151,7 +151,7 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical // gallery object just to increment/decrement one value in the table. // TODO: Change this - should always use the appropriate object, not // direct manipulation of the share table... - $sql = 'UPDATE ' . $this->_shareOb->_table + $sql = 'UPDATE ' . $this->_shareOb->getTable() . ' SET attribute_images = attribute_images ' . ($add ? ' + ' : ' - ') . $images . ' WHERE share_id = ' . ($gallery_id ? $gallery_id : $this->id); @@ -172,7 +172,7 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical $GLOBALS['cache']->expire('Ansel_Gallery' . $id); } - return $this->_shareOb->_write_db->exec($sql); + return $this->_shareOb->getWriteDb()->exec($sql); } /** @@ -359,7 +359,7 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical throw new Horde_Exception(sprintf(_("Access denied copying photos to \"%s\"."), $gallery->get('name'))); } - $db = $this->_shareOb->_write_db; + $db = $this->_shareOb->getWriteDb(); $imgCnt = 0; foreach ($images as $imageId) { $img = &$this->getImage($imageId); @@ -375,7 +375,7 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical // go through Ansel_Tags::writeTags() - this saves us a SELECT query // for each tag - just write the data into the DB ourselves. $tags = $img->getTags(); - $query = $this->_shareOb->_write_db->prepare('INSERT INTO ansel_images_tags (image_id, tag_id) VALUES(' . $newId . ',?);'); + $query = $this->_shareOb->getWriteDb()->prepare('INSERT INTO ansel_images_tags (image_id, tag_id) VALUES(' . $newId . ',?);'); if (is_a($query, 'PEAR_Error')) { throw new Horde_Exception($query->getMessage()); } @@ -420,7 +420,7 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical */ public function setImageOrder($imageId, $pos) { - return $this->_shareOb->_write_db->exec('UPDATE ansel_images SET image_sort = ' . (int)$pos . ' WHERE image_id = ' . (int)$imageId); + return $this->_shareOb->getWriteDb()->exec('UPDATE ansel_images SET image_sort = ' . (int)$pos . ' WHERE image_id = ' . (int)$imageId); } /** @@ -908,10 +908,12 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical /* Update the backend, but only this current change */ if ($update) { - $db = $this->_shareOb->_write_db; + $db = $this->_shareOb->getWriteDb(); // Manually convert the charset since we're not going through save() + // @TODO: Look at this usage - maybe each app's share object should + // have this method or just keep it public? $data = $this->_shareOb->_toDriverCharset(array($driver_key => $value)); - $query = $db->prepare('UPDATE ' . $this->_shareOb->_table . ' SET ' . $driver_key . ' = ? WHERE share_id = ?', null, MDB2_PREPARE_MANIP); + $query = $db->prepare('UPDATE ' . $this->_shareOb->getTable() . ' SET ' . $driver_key . ' = ? WHERE share_id = ?', null, MDB2_PREPARE_MANIP); if ($GLOBALS['conf']['ansel_cache']['usecache']) { $GLOBALS['cache']->expire('Ansel_Gallery' . $this->id); } diff --git a/ansel/lib/GalleryMode/Date.php b/ansel/lib/GalleryMode/Date.php index 4254107e3..f3c294b06 100644 --- a/ansel/lib/GalleryMode/Date.php +++ b/ansel/lib/GalleryMode/Date.php @@ -453,7 +453,7 @@ class Ansel_GalleryMode_Date { } /* Bulk update the images to their new gallery_id */ - $result = $this->_gallery->_shareOb->getWriteDb()->exec('UPDATE ansel_images SET gallery_id = ' . $gallery->id . ' WHERE image_id IN (' . implode(',', $ids) . ')'); + $result = $this->_gallery->getShareOb()->getWriteDb()->exec('UPDATE ansel_images SET gallery_id = ' . $gallery->id . ' WHERE image_id IN (' . implode(',', $ids) . ')'); if (is_a($result, 'PEAR_Error')) { return $result; } @@ -526,10 +526,10 @@ class Ansel_GalleryMode_Date { } catch (VFS_Exception $e) {} /* Delete from SQL. */ - $this->_gallery->_shareOb->getWriteDb()->exec('DELETE FROM ansel_images WHERE image_id = ' . (int)$image->id); + $this->_gallery->getShareOb()->getWriteDb()->exec('DELETE FROM ansel_images WHERE image_id = ' . (int)$image->id); /* Remove any attributes */ - $this->_gallery->_shareOb->getWriteDb()->exec('DELETE FROM ansel_image_attributes WHERE image_id = ' . (int)$image->id); + $this->_gallery->getShareOb()->getWriteDb()->exec('DELETE FROM ansel_image_attributes WHERE image_id = ' . (int)$image->id); if (!$isStack) { $this->_gallery->updateImageCount(1, false, $image_gallery); @@ -976,7 +976,7 @@ class Ansel_Gallery_Date { */ function countChildren($perm = Horde_Perms::SHOW, $allLevels = true) { - return $this->_gallery->_shareOb->countShares(Horde_Auth::getAuth(), $perm, null, $this, $allLevels); + return $this->_gallery->getShareOb()->countShares(Horde_Auth::getAuth(), $perm, null, $this, $allLevels); } /** @@ -1000,7 +1000,7 @@ class Ansel_Gallery_Date { */ function getParent() { - return $this->_gallery->_shareOb->getParent($this); + return $this->_gallery->getShareOb()->getParent($this); } /** diff --git a/ansel/lib/GalleryMode/Normal.php b/ansel/lib/GalleryMode/Normal.php index 3af6b6dac..7c2737143 100644 --- a/ansel/lib/GalleryMode/Normal.php +++ b/ansel/lib/GalleryMode/Normal.php @@ -191,7 +191,7 @@ class Ansel_GalleryMode_Normal { } } - $result = $this->_gallery->_shareOb->getWriteDb()->exec('UPDATE ansel_images SET gallery_id = ' . $gallery->id . ' WHERE image_id IN (' . implode(',', $ids) . ')'); + $result = $this->_gallery->getShareOb()->getWriteDb()->exec('UPDATE ansel_images SET gallery_id = ' . $gallery->id . ' WHERE image_id IN (' . implode(',', $ids) . ')'); if ($result instanceof PEAR_Error) { throw new Ansel_Exception($result->getMessage()); } @@ -244,10 +244,10 @@ class Ansel_GalleryMode_Normal { } catch (VFS_Exception $e) {} /* Delete from SQL. */ - $this->_gallery->_shareOb->getWriteDb()->exec('DELETE FROM ansel_images WHERE image_id = ' . (int)$image->id); + $this->_gallery->getShareOb()->getWriteDb()->exec('DELETE FROM ansel_images WHERE image_id = ' . (int)$image->id); /* Remove any attributes */ - $this->_gallery->_shareOb->getWriteDb()->exec('DELETE FROM ansel_image_attributes WHERE image_id = ' . (int)$image->id); + $this->_gallery->getShareOb()->getWriteDb()->exec('DELETE FROM ansel_image_attributes WHERE image_id = ' . (int)$image->id); if (!$isStack) { $this->_gallery->updateImageCount(1, false); diff --git a/folks/lib/Friends/shared.php b/folks/lib/Friends/shared.php index a85388715..27590ad50 100644 --- a/folks/lib/Friends/shared.php +++ b/folks/lib/Friends/shared.php @@ -130,10 +130,10 @@ class Folks_Friends_shared extends Folks_Friends_sql { } $query = 'DELETE FROM ' . $this->_params['friends'] - . ' WHERE user_uid = ' . $share->_shareOb->_write_db->quote($this->_user) - . ' AND group_id = ' . $share->_shareOb->_write_db->quote($share->getId()); + . ' WHERE user_uid = ' . $share->getShareOb()->getWriteDb()->quote($this->_user) + . ' AND group_id = ' . $share->getShareOb()->getWriteDb()->quote($share->getId()); - $result = $share->_shareOb->_write_db->exec($query); + $result = $share->getShareOb()->getWriteDb()->exec($query); if ($result instanceof PEAR_Error) { return $result; }