getPath( 'admin_html' ) ); switch ($task) { case "new": editComment( $option, 0 ); break; case "edit": editComment( $option, $cid[0] ); break; case 'editA': editComment( $option, intval( $id ) ); break; case "save": saveComment( $option ); break; case "remove": removeComments( $cid, $option ); break; case "publish": publishComments( $cid, 1, $option ); break; case "unpublish": publishComments( $cid, 0, $option ); break; case "settings": showConfig( $option ); break; case "savesettings": saveConfig ( $option ); break; default: showComments( $option ); break; } /** * @param option * @return list of comments */ function showComments ( $option ) { global $database, $mainframe; $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', 10 ); $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); $search = $database->getEscaped( trim( strtolower( $search ) ) ); $where = array(); if ($search) { $where[] = "LOWER(comments) LIKE '%$search%'"; } $database->setQuery( "SELECT count(*) FROM #__comment AS a" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") ); $total = $database->loadResult(); echo $database->getErrorMsg(); include_once( "includes/pageNavigation.php" ); $pageNav = new mosPageNav( $total, $limitstart, $limit ); $database->setQuery( "SELECT c.title, a.* FROM #__comment as a" . "\n LEFT JOIN #__content AS c ON a.articleid = c.id" . (count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "") . "\n ORDER BY a.id DESC" . "\n LIMIT $pageNav->limitstart,$pageNav->limit" ); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } HTML_comment::showComments( $option, $rows, $search, $pageNav ); } /** * @param option * @param id * @return edit box for article or new comment box */ function editComment( $option, $uid ) { global $database, $my; $row = new moscomment( $database ); $row->load( $uid ); $contentitem[] = mosHTML::makeOption( '0', 'Select Content Item' ); // @RawSQLUse, trivial_implementation, SELECT $database->setQuery( "SELECT id AS value, title AS text FROM #__content ORDER BY title" ); $contentitem = array_merge( $contentitem, $database->loadObjectList() ); if (count( $contentitem ) < 1) { mosRedirect( "index2.php?option=com_sections&scope=content", 'You must add sections first.' ); } $clist = mosHTML::selectList( $contentitem, 'articleid', 'class="inputbox" size="1"', 'value', 'text', intval( $row->articleid ) ); if ($uid) { $row->checkout( $my->id ); } else { $row->published = 0; } $publist = mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published ); HTML_comment::editComment( $option, $row, $clist, $publist ); } /** * @param option * @return saves comment */ function saveComment( $option ) { global $database; $row = new moscomment( $database ); if (!$row->bind( $_POST )) { echo "\n"; exit(); } $row->startdate = date( "Y-m-d H:i:s" ); $row->ip = getenv('REMOTE_ADDR'); if (!$row->store()) { echo "\n"; exit(); } $row->updateOrder( "articleid='$row->articleid'" ); mosRedirect( "index2.php?option=$option" ); } /** * @param cid * @param publish * @param option * @return publishes / unpublishes article comment */ function publishComments( $cid=null, $publish=1, $option ) { global $database; if (!is_array( $cid ) || count( $cid ) < 1) { $action = $publish ? 'publish' : 'unpublish'; echo "\n"; exit; } $cids = implode( ',', $cid ); // @RawSQLUse, trivial_implementation, UPDATE $database->setQuery( "UPDATE #__comment SET published='$publish' WHERE id IN ($cids)" ); if (!$database->query()) { echo "\n"; exit(); } mosRedirect( "index2.php?option=$option" ); } /** * @param option * @return builds admin configuration options */ function showConfig( $option ) { global $mosConfig_absolute_path, $database, $mosConfig_mailfrom; require($mosConfig_absolute_path."/administrator/components/com_comment/config.comment.php"); ?>
startPane( "_comment" ); $gbtabs->startTab(T_('General'),"General-page"); ?>
:
:
:
:
endTab(); $gbtabs->startTab(T_('Notification'),"Notification-page"); ?>
:
:
endTab(); $gbtabs->startTab(T_('Admin'),"Admin-page"); ?>
:
endTab(); $gbtabs->endPane(); ?>
auto_publish_comments); $allow_anonymous_entries = mosGetParam($_POST, 'allow_anonymous_entries', $config->allow_anonymous_entries); $notify_new_entries = mosGetParam($_POST, 'notify_new_entries', $config->notify_new_entries); $mcselections = mosGetParam($_POST, 'mcselections', ''); $allow_comments_in_sections = is_array($mcselections) ? implode(',', $mcselections) : $config->allow_comments_in_sections; $comments_per_page = mosGetParam($_POST, 'comments_per_page', $config->comments_per_page); $admin_comments_length = mosGetParam($_POST, 'admin_comments_length', $config->admin_comments_length); unset($config); $configfile = "components/com_comment/config.comment.php"; @chmod ($configfile, 0766); $permission = is_writable($configfile); if (!$permission) { $mosmsg = "Config file not writeable!"; mosRedirect("index2.php?option=$option&act=config",$mosmsg); break; } $config = ""; if ($fp = fopen("$configfile", "w")) { fputs($fp, $config, strlen($config)); fclose ($fp); } mosRedirect("index2.php?option=$option&task=settings", T_('Settings saved')); } /** * @param cid * @param option * @return deletes selected article */ function removeComments( $cid, $option ) { global $database; if (count( $cid )) { $cids = implode( ',', $cid ); // @RawSQLUse, trivial_implementation, DELETE $database->setQuery( "DELETE FROM #__comment WHERE id IN ($cids)" ); if (!$database->query()) { echo "\n"; } } mosRedirect( "index2.php?option=$option" ); }