function onAfterRoute() { $legacyFile = JPATH_ROOT . '/components/com_jcomments/jcomments.legacy.php'; if (!is_file($legacyFile)) { return; } include_once $legacyFile; $mainframe = JFactory::getApplication('site'); $mainframe->getRouter(); $document = JFactory::getDocument(); if ($document->getType() == 'html') { if ($mainframe->isAdmin()) { $document->addStyleSheet(JURI::base() . 'components/com_jcomments/assets/icon.css?v=2'); $option = JAdministratorHelper::findOption(); $task = JRequest::getCmd('task'); $type = JRequest::getCmd('type', '', 'post'); // remove comments if content item deleted from trash if ($option == 'com_trash' && $task == 'delete' && $type == 'content') { $cid = JRequest::getVar('cid', array(0), 'post', 'array'); JArrayHelper::toInteger($cid, array(0)); include_once JPATH_ROOT . '/components/com_jcomments/jcomments.php'; JCommentsModel::deleteComments($cid, 'com_content'); } } else { $option = JRequest::getCmd('option'); if ($option == 'com_content' || $option == 'com_alphacontent' || $option == 'com_multicategories') { include_once JCOMMENTS_BASE . '/jcomments.class.php'; include_once JCOMMENTS_BASE . '/jcomments.config.php'; include_once JCOMMENTS_HELPERS . '/system.php'; // include JComments CSS if ($this->params->get('disable_template_css', 0) == 0) { $document->addStyleSheet(JCommentsSystemPluginHelper::getCSS()); $language = JFactory::getLanguage(); if ($language->isRTL()) { $rtlCSS = JCommentsSystemPluginHelper::getCSS(true); if ($rtlCSS != '') { $document->addStyleSheet($rtlCSS); } } } if (!defined('JCOMMENTS_CSS')) { define('JCOMMENTS_CSS', 1); } // include JComments JavaScript library $document->addScript(JCommentsSystemPluginHelper::getCoreJS()); if (!defined('JOOMLATUNE_AJAX_JS')) { $document->addScript(JCommentsSystemPluginHelper::getAjaxJS()); define('JOOMLATUNE_AJAX_JS', 1); } if (!defined('JCOMMENTS_JS')) { define('JCOMMENTS_JS', 1); } } } } }
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 onContentAfterDelete($context, $data) { if ($context == 'com_content.article') { require_once JPATH_ROOT . '/components/com_jcomments/models/jcomments.php'; JCommentsModel::deleteComments((int) $table->id, 'com_content'); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->delete(); $query->from($db->quoteName('#__jcomments_subscriptions')); $query->where($db->quoteName('object_id') . ' = ' . (int) $data->id); $query->where($db->quoteName('object_group') . ' = ' . $db->Quote('com_content')); $db->setQuery($query); $db->execute(); } }
/** * @deprecated As of version 2.2.0.0 * @see JCommentsModel::deleteComments */ function deleteComments($object_id, $object_group = 'com_content') { JCommentsModel::deleteComments($object_id, $object_group); 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; }