function delete(&$pks) { $db = $this->getDbo(); JArrayHelper::toInteger($pks); for ($i = 0; $i < count($pks); $i++) { $query = 'SELECT filename FROM #__igallery_img WHERE id = ' . (int) $pks[$i]; $db->setQuery($query); $photo = $db->loadObject(); $query = 'SELECT filename FROM #__igallery_img WHERE filename = ' . $db->Quote($photo->filename); $db->setQuery($query); $db->query(); $numRows = $db->getNumRows(); $deleteOrig = $numRows > 1 ? false : true; igFileHelper::deleteImage($photo->filename, $deleteOrig); $query = 'DELETE FROM #__igallery_img WHERE id = ' . (int) $pks[$i]; $db->setQuery($query); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } $commentsPath = JPATH_SITE . '/components/com_jcomments/jcomments.php'; if (file_exists($commentsPath)) { require_once $commentsPath; JCommentsModel::deleteComments((int) $pks[$i], 'com_igallery'); } $alPath = JPATH_SITE . '/components/com_alratings/classes/alratings.php'; if (file_exists($alPath)) { require_once $alPath; ALRatings::deleteRating('com_igallery', (int) $pks[$i]); } } $row = $this->getTable('igallery_img'); $row->reorder('gallery_id = ' . JRequest::getInt('catid', 0)); return true; }
function delete(&$pks) { $db = $this->getDbo(); $id = is_array($pks) ? (int) $pks[0] : (int) $pks; $query = 'SELECT * FROM #__igallery WHERE id = ' . (int) $id; $db->setQuery($query); $category = $db->loadObject(); if (strlen($category->menu_image_filename) > 2) { $query = 'SELECT menu_image_filename FROM #__igallery WHERE menu_image_filename = ' . $this->_db->Quote($category->menu_image_filename); $db->setQuery($query); $db->query(); $numRows = $db->getNumRows(); $deleteOrig = $numRows > 1 ? false : true; igFileHelper::deleteImage($category->menu_image_filename, $deleteOrig); } $query = 'SELECT id, filename FROM #__igallery_img WHERE gallery_id = ' . (int) $id; $db->setQuery($query); $photoList = $db->loadObjectList(); for ($i = 0; $i < count($photoList); $i++) { $photo = $photoList[$i]; $query = 'SELECT filename FROM #__igallery_img WHERE filename = ' . $db->Quote($photo->filename); $db->setQuery($query); $db->query(); $numRows = $db->getNumRows(); $deleteOrig = $numRows > 1 ? false : true; igFileHelper::deleteImage($photo->filename, $deleteOrig); $query = 'DELETE FROM #__igallery_img WHERE id = ' . (int) $photo->id; $db->setQuery($query); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } $commentsPath = JPATH_SITE . '/components/com_jcomments/jcomments.php'; if (file_exists($commentsPath)) { require_once $commentsPath; JCommentsModel::deleteComments((int) $photo->id, 'com_igallery'); } $alPath = JPATH_SITE . '/components/com_alratings/classes/alratings.php'; if (file_exists($alPath)) { require_once $alPath; ALRatings::deleteRating('com_igallery', (int) $photo->id); } } $query = 'DELETE FROM #__igallery WHERE id = ' . (int) $id; $db->setQuery($query); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } $query = 'UPDATE #__igallery SET parent = 0 WHERE parent = ' . (int) $id; $db->setQuery($query); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } $row = $this->getTable('igallery'); $row->reorder('parent = ' . (int) $category->parent); return true; }