From d7127eda29b77d637f40a5ad6026463a44a1e77a Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Sun, 30 Jul 2006 10:54:09 +0000 Subject: [PATCH] Allow to browse comments by authors, allow template specific language includes --- docs/NEWS | 242 ++++++++++++++++++++++++- include/functions_comments.inc.php | 166 ++++++++++++++--- include/functions_entries.inc.php | 94 +++++++--- include/functions_installer.inc.php | 19 +- include/functions_permalinks.inc.php | 71 +++++--- include/genpage.inc.php | 34 +++- include/lang.inc.php | 20 +- include/tpl/config_local.inc.php | 94 +++++++++- include/tpl/htaccess_cgi_rewrite.tpl | 1 + include/tpl/htaccess_rewrite.tpl | 1 + index.php | 108 ++++++++--- lang/UTF-8/serendipity_lang_cn.inc.php | 3 +- lang/UTF-8/serendipity_lang_cs.inc.php | 2 +- lang/UTF-8/serendipity_lang_cz.inc.php | 2 +- lang/UTF-8/serendipity_lang_da.inc.php | 2 +- lang/UTF-8/serendipity_lang_de.inc.php | 2 +- lang/UTF-8/serendipity_lang_en.inc.php | 5 +- lang/UTF-8/serendipity_lang_es.inc.php | 2 +- lang/UTF-8/serendipity_lang_fa.inc.php | 2 +- lang/UTF-8/serendipity_lang_fi.inc.php | 2 +- lang/UTF-8/serendipity_lang_fr.inc.php | 2 +- lang/UTF-8/serendipity_lang_is.inc.php | 2 +- lang/UTF-8/serendipity_lang_ja.inc.php | 2 +- lang/UTF-8/serendipity_lang_ko.inc.php | 2 +- lang/UTF-8/serendipity_lang_nl.inc.php | 2 +- lang/UTF-8/serendipity_lang_no.inc.php | 2 +- lang/UTF-8/serendipity_lang_pt.inc.php | 2 +- lang/UTF-8/serendipity_lang_ru.inc.php | 2 +- lang/UTF-8/serendipity_lang_tn.inc.php | 2 +- lang/UTF-8/serendipity_lang_tw.inc.php | 2 +- lang/UTF-8/serendipity_lang_zh.inc.php | 7 +- 31 files changed, 724 insertions(+), 175 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 66d141a..519cdcd 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -1,8 +1,239 @@ # $Id$ +Version 1.1-alpha7() +------------------------------------------------------------------------ + + * Add new template 'comments_by_author' which show comments made + by authors. New permalink structure: + "/comments/[AUTHORNAME]/comments|trackbacks|comments_and_trackbacks/P[PAGENUMBER]/FROM [YYYY-MM-DD]/TO [YYYY-MM-DD]" + (garvinhicking) + + * Add "Comments and Trackbacks" feed feature (stm99..) + + * Add LiveJournal XML importer (garvinhicking) + + * Fix not fetching allow_comments/moderate_comments value when + inside search function. Thanks to stm! (garvinhicking) + + * Add new links to check for upgradable SPARTACUS plugins + (garvinhicking) + + * Add new frontend view "Archive by Authors": /archive/Axx.html to + view the archive listing for specific authors only (like viewing + archive by specific categories only via /archive/Cxx.html etc.) + (garvinhicking) + + * Templating: Add new {$entry.html_title} variable that holds + unescaped HTML code of the Entry's title (garvinhicking) + + * BC-Break / Plugin API change: The serendipity_getTemplate() file + now no longer returns FALSE when a file is not found, but instead + the filename without a path. This is required so that the smarty- + created error message contains the missing filename instead of an + empty '' string. + Plugins based on this function need to make sure that they will + now properly use a file_exists() check on the returned function, + if they want to probe different locations of a file. + All template files containing the string "plugin" will still return + FALSE for the function call, to circumvent problems with spartacus + plugins. + Bottom line: Plugins that use "*plugin*.tpl" filenames or check + via file_exists() on the returned variable are safe. + (garvinhicking) + + * Added arabic (sa) language by Way + + * Add patch to allow entryproperties plugin to define passwords for + specific entries (Falk Döring) + + * Made smarty function "serendipity_printComments" accept to new + parameters: "order" (ASC/DESC) and "limit" (garvinhicking) + + * Comment moderation panel, usability improvement: Blocking authors/ + URLs will lead to the originating page. Thanks to Tanel Raja! + (garvinhicking) + + * Patch mb-functions to better work on foreign/japanese charsets + (thanks to deminy!) + + * Replaced core smarty assign() calls to assign_by_ref() where + appropriate. (Falk Döring, garvinhicking) + TODO: This might introduce oddities! Check thoroughly. + + * Fixed not showing entries in the quicksearch that have the + "no frontpage" entryproperty set (garvinhicking) + + * Fixed sidebar category plugin to show proper category listing + for permission-based restrictions, when "current autho" mode + is selected (garvinhicking) + + * Added experimental XML-engine, for XSLT templating support + (garvinhicking) + + * Added experimental PHP-engine templating support, bypassing + Smarty. Work in progress, mostly proof-of-concept. Might + be changed completely. Read instructions in the + include/template_api.inc.php file. Dedicated to Davey. ;) + (garvinhicking) + + * Support to crop images from within the media database. Pick a + picture in the MDB, go to the property section of that image + and click on the "EDIT" link. (garvinhicking) + + TODO: + - Operate also on PNG, TIFF etc. (currently only JPEG!) + - Support image magick (currently ony gdlib!) + - Currently backup files are scattered around, fix this. + - Interface cleanup + - Add options to only affect the images thumbnail instead + of always saving the whole picture. + - Internationalization! + + * Move the DB charset option to serendipity_config_local.inc.php to + issue propper DB connections instantly. (garvinhicking) + +Version 1.1-alpha6() +------------------------------------------------------------------------ + + * Use possibly existing local PEAR by default. Patch by Davey + (garvinhicking) + + * Add missing indices for the statistics visitor DB tables + (garvinhicking) + + * Add new "custom" property bag type, which can emit any kind of + custom HTML/JS values. Current property bag value can be referenced + by DOM GetElementById('config_plugin_XXX') if you want to emit + specific JavaScript. Can also be used by template configurator for + heavily customized output. (garvinhicking) + + * Fix bug #1494653: Non-Unique index constraint for 'exits' table. + Thanks to Markus Brueckner! (garvinhicking) + +Version 1.1-alpha5() +------------------------------------------------------------------------ + + * Implemented Drag and Drop based plugin configuration panel for + re-ordering plugin layout. Uses JavaScript - works like old + manager when having JS disabled! (garvinhicking) + + * Changed "Auto-Login" via Cookie behaviour to only issue single- + time valid cookies to users and no longer put username/pw into + serialized cookie data. Many thanks to Yasuo Ohgaki for giving + a helping hand! (garvinhicking) + + * Added possibility to hide/temporarily disable Event plugins + (garvinhicking) + + * Added "plugin_api_extension" class, which contains some helper + methods for future use, like re-ordering DB items or checking + valid emails. (Falk Döring) + + * Fix multiple occurences of the string "--" in the entry title to + not mess up HTML display because of weird Firefox interpretation + (Bug #1474290) (garvinhicking) + + * Made "fullfeed" syndication option also support "let the client + decide", via $_GET['fullFeed'] = true/false. (garvinhicking) + + * Added new configuration option to that lets you toggle whether to + comply with RFC2616 on Conditional GET. (Garvinhicking) + + * Support template/theme/style-specific options via "config.inc.php" + file in template directory. Allows values like "background-color", + "header" etc. to be made configurable in the admin screen. + (garvinhicking) + + * Make media manager able to store media properties and many other + enhancements: + + DETAILS: + - Smarty templates for all media-related output + - New DHTML widget for tree navigation + - Store+Retrieve EXIF/XMP/ITPC/ID3 metadata for uploaded files + [new database table] + - Manage custom keywords for media items + - Option for enabling the toolbar in the popup media window + - Plugin API hooks for fetching media metadata (like via + getID3() plugin) + - Make media chooser also return the media ID + - Detect if a file is video, audio, image, document, archive, + binary. Unify image fetching functionality. + - Allow to create directories from the popup media window + - Optionally increase filename (1, 2, 4, 5, ...) when file + already exists + - Restrict file upload by size/dimensions via configuration + options + - Sort media files by all custom property fields + - Search/Filter for specific properties/keywords. + - Enhanced media filter for keywords + - Use entered comments in the "You choose..." picking page + - Integrate new page for viewing images with media properties + through serendipity_admin_image_selector.php?serendipity[image]=X + - Integrate imageselectorplus plugin options for giving a target + to links + - New option for image_Selector to save a specific sized version + (?serendipity[image]=X&serendipity[step]=showItem + &serendipity[resizeWidth]=X&serendipity[resizeHeight]=Y + - Track referrers by image selector and show them on detail + page + - Allow to move directories with files and updating all links + in your entries to those moved items. (MySQL only!) + - Allow to move single images. + (garvinhicking) + + * Create a new index on the plugin DB table, optimize fetching config + values for plugins. Load language file when permissions could not + allow reading the config file. (garvinhicking) + + * Fix blocking site during file requests by writing session data to + disk. Thanks to jgoerzen! (garvinhicking) + + * Make categories sidebar plugin able to only show categories + readable for logged in user (garvinhicking) + + * Fix getting multiple images for directories that were put into + the Acccess List (garvinhicking) + + * Allow to create new groups from existing ones, by editing them + and clicking on "Create new group". (garvinhicking) + + * Statistic plugin update by Shrikee: Graphically display visitors, + bot banning. + + * Deleting a comment that has replies will replace that comment with + a "Comment deleted" reference. Deleting such a comment again will + completely remove it. (garvinhicking, Jabrwock) + + * Added "further links" infobox to Admin interface (garvinhicking) + + * Media manager gallery will use (user-specified) + "admin/img/mime_XXX-YYY.png" images of a template for non-image + mimetypes. (garvinhicking) + + * Allow entryproperties plugin to define which markup plugins are + applied per-entry (garvinhicking) + + * Added links to view an entry in reasonable places (comments / entry + overview) (garvinhicking) + + * Added on-the-fly synchronizing of the Serendipity media database + with the file system (Marty, garvinhicking) + + * Introduce permission setup for media directories (garvinhicking) + + * Added config option for specifying number of entries in the RSS + feed (garvinhicking) + + * Added option whether to issue the "SET NAMES" mysql command + (garvinhicking) + + * Removed config option "XHTML11 compliance" and enabled by default + now (garvinhicking) + Version 1.0.1 () ------------------------------------------------------------------------ - + * Fix multi-authors view only showing first author (garvinhicking) * Fix bug sending comment-notification mails to subscribed users @@ -16,7 +247,7 @@ Version 1.0 (June 15th, 2006) * Insert logic for saving an entry that prevents the iframe for trackbacks/xml-rpc pings to save an entry multiple times upon failure. Many thanks to tharos from the Forums! (garvinhicking) - + * Add smarty parameter $view which can be used to detect what kind of page is being displayed. One of: archives, entry, feed, admin, archives, plugin, categories, authors, search, css, start, 404 @@ -26,12 +257,6 @@ Version 1.0 (June 15th, 2006) * Added polish language translation by CoSTa - * Fix media browser sorting by authorid causing trouble in SQLite - (Sven Oliver Moll) - -Version 1.0-beta3 (May 5th, 2006) ------------------------------------------------------------------------- - * Fix another (minor) XSRF for entry manager, thanks to Geoff Johnson (garvinhicking) @@ -70,6 +295,7 @@ Version 1.0-beta3 (May 5th, 2006) objects (like emoticonchooser). Also replace with and with . (Jay Bertrandt) + Version 1.0-beta2 (March 13th, 2006) ------------------------------------------------------------------------ diff --git a/include/functions_comments.inc.php b/include/functions_comments.inc.php index ea1bb8f..bc7a29f 100644 --- a/include/functions_comments.inc.php +++ b/include/functions_comments.inc.php @@ -2,6 +2,11 @@ # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) # All rights reserved. See LICENSE file for licensing details +if (defined('S9Y_FRAMEWORK_COMMENTS')) { + return; +} +@define('S9Y_FRAMEWORK_COMMENTS', true); + /** * Store the personal details of a commenting user in a cookie (or delete that cookie) * @@ -80,8 +85,7 @@ function serendipity_displayCommentForm($id, $url = '', $comments = NULL, $data $comments = serendipity_fetchComments($id); } - $serendipity['smarty']->assign( - array( + $commentform_data = array( 'commentform_action' => $url, 'commentform_id' => $id, 'commentform_name' => isset($data['name']) ? htmlspecialchars($data['name']) : (isset($serendipity['COOKIE']['name']) ? htmlspecialchars($serendipity['COOKIE']['name']) : ''), @@ -95,9 +99,10 @@ function serendipity_displayCommentForm($id, $url = '', $comments = NULL, $data 'is_allowSubscriptions' => $serendipity['allowSubscriptions'], 'is_moderate_comments' => $moderate_comments, 'commentform_entry' => $entry - ) ); + $serendipity['smarty']->assign($commentform_data); + serendipity_smarty_fetch('COMMENTFORM', 'commentform.tpl'); } @@ -109,9 +114,10 @@ function serendipity_displayCommentForm($id, $url = '', $comments = NULL, $data * @param int How many comments to fetch (empty: all) * @param string How shall comments be ordered (ASC|DESC) * @param boolean Shall non-approved comments be displayed? + * @param string Comment type to fetch * @return array The SQL result of comments */ -function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = false) { +function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = false, $type = 'NORMAL', $where = '') { global $serendipity; $and = ''; @@ -120,6 +126,14 @@ function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = f } else { $limit = ''; } + + if ($type == 'comments' || empty($type)) { + $type = 'NORMAL'; + } elseif ($type == 'trackbacks') { + $type = 'TRACKBACK'; + } elseif ($type == 'comments_and_trackbacks') { + $type = '%'; + } if (!empty($id)) { $and .= " AND co.entry_id = '" . (int)$id ."'"; @@ -128,6 +142,8 @@ function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = f if (!$showAll) { $and .= ' AND co.status = \'approved\''; } + + $and .= $where; if ($serendipity['dbType'] == 'postgres') { $group = ''; @@ -139,9 +155,10 @@ function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = f $query = "SELECT $distinct co.id, - co.entry_id, co.timestamp, co.title, co.email, co.url, co.ip, co.body, co.type, co.subscribed, + co.entry_id, co.timestamp, co.title AS ctitle, co.email, co.url, co.ip, co.body, co.type, co.subscribed, co.author, e.title, + e.timestamp AS entrytimestamp, e.id AS entryid, e.authorid, co.id AS commentid, @@ -149,13 +166,12 @@ function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = f FROM {$serendipity['dbPrefix']}comments co LEFT JOIN {$serendipity['dbPrefix']}entries e ON (co.entry_id = e.id) - WHERE co.type LIKE 'NORMAL' AND co.entry_id > 0 $and + WHERE co.type LIKE '" . $type . "' AND co.entry_id > 0 $and $group ORDER BY - co.id " . ($order != '' ? $order : '') . " + " . ($where != '' ? '' : 'co.id') . " " . ($order != '' ? $order : '') . " $limit"; - - $comments = serendipity_db_query($query); + $comments = serendipity_db_query($query, false, 'assoc'); if (!is_array($comments)) { return array(); @@ -213,7 +229,7 @@ function serendipity_generateCommentList($id, $comments = NULL, $selected = 0, $ * @param string A string repesenting the actual comment (1.1.2.1) * @return string The HTML construct of all comments */ -function serendipity_printComments($comments, $parentid = 0, $depth = 0, $trace = null) { +function serendipity_printComments($comments, $parentid = 0, $depth = 0, $trace = null, $smarty_block = 'COMMENTS', $smarty_file = 'comments.tpl') { global $serendipity; static $_smartyComments; @@ -257,7 +273,8 @@ function serendipity_printComments($comments, $parentid = 0, $depth = 0, $trace if (isset($comment['no_email']) && $comment['no_email']) { $comment['email'] = false; } elseif (!empty($comment['email'])) { - $comment['email'] = htmlspecialchars(str_replace('@', '[at]', $comment['email'])); + $comment['clear_email'] = $comment['email']; + $comment['email'] = htmlspecialchars(str_replace('@', '[at]', $comment['email'])); } $comment['body'] = $comment['comment']; @@ -268,7 +285,7 @@ function serendipity_printComments($comments, $parentid = 0, $depth = 0, $trace $_smartyComments[] = $comment; if ($comment['id'] && $parentid !== VIEWMODE_LINEAR ) { - serendipity_printComments($comments, $comment['id'], ($depth+1), ($trace . $i . '.')); + serendipity_printComments($comments, $comment['id'], ($depth+1), ($trace . $i . '.'), $smarty_block, $smarty_file); } } } @@ -278,10 +295,83 @@ function serendipity_printComments($comments, $parentid = 0, $depth = 0, $trace return true; } - $serendipity['smarty']->assign('comments', $_smartyComments); + $serendipity['smarty']->assign_by_ref('comments', $_smartyComments); unset($_smartyComments); - return serendipity_smarty_fetch('COMMENTS', 'comments.tpl'); + return serendipity_smarty_fetch($smarty_block, $smarty_file); +} + +/** + * Fetches and prints a listing of comments by author + */ +function serendipity_printCommentsByAuthor() { + global $serendipity; + + $type = $serendipity['GET']['commentMode']; + + if ($type == 'comments' || empty($type)) { + $type = 'NORMAL'; + } elseif ($type == 'trackbacks') { + $type = 'TRACKBACK'; + } elseif ($type == 'comments_and_trackbacks') { + $type = '%'; + } + + $sql_where = " AND co.author = '" . serendipity_db_escape_string($serendipity['GET']['viewCommentAuthor']) . "'"; + + if (!empty($serendipity['GET']['commentStartTime'])) { + $sql_where .= " AND co.timestamp >= " . (int)$serendipity['GET']['commentStartTime']; + } + + if (!empty($serendipity['GET']['commentEndTime'])) { + $sql_where .= " AND co.timestamp <= " . (int)$serendipity['GET']['commentEndTime']; + } + + if (empty($serendipity['GET']['page'])) { + $serendipity['GET']['page'] = 1; + } + $sql_limit = $serendipity['fetchLimit'] * ($serendipity['GET']['page']-1) . ',' . $serendipity['fetchLimit']; + $c = serendipity_fetchComments(null, $sql_limit, 'co.entry_id DESC, co.id ASC', false, $type, $sql_where); + + $entry_comments = array(); + foreach($c as $i => $comment) { + if (!isset($entry_comments[$comment['entry_id']])) { + $comment['link'] = serendipity_archiveURL($comment['entry_id'], $comment['title'], 'serendipityHTTPPath', true, array('timestamp' => $comment['entrytimestamp'])); + $entry_comments[$comment['entry_id']] = $comment; + } + $entry_comments[$comment['entry_id']]['comments'][] = $comment; + } + + foreach($entry_comments AS $entry_id => $_data) { + $entry_comments[$entry_id]['tpl_comments'] =& serendipity_printComments($_data['comments'], VIEWMODE_LINEAR, 0, null, 'COMMENTS', 'comments.tpl'); + } + + $serendipity['smarty']->assign_by_ref('comments_by_authors', $entry_comments); + + if (!empty($id)) { + $and .= " AND co.entry_id = '" . (int)$id ."'"; + } + + if (!$showAll) { + $and .= ' AND co.status = \'approved\''; + } + + $cc = serendipity_db_query("SELECT count(co.id) AS counter + FROM {$serendipity['dbPrefix']}comments AS co + WHERE co.entry_id > 0 + AND co.type LIKE '" . $type . "' + AND co.status = 'approved' " . $sql_where . " + GROUP BY co.author", true, 'assoc'); + if (!isset($cc['counter'])) { + $totalComments = 0; + } else { + $totalComments = $cc['counter']; + } + serendipity_printEntryFooter('', $totalComments); + + serendipity_smarty_fetch('ENTRIES', 'comments_by_author.tpl'); + + return true; } /** @@ -310,25 +400,41 @@ function serendipity_deleteComment($id, $entry_id, $type='comments') { /* We have to figure out if the comment we are about to delete, is awaiting approval, if so - we should *not* subtract it from the entries table */ - $sql = serendipity_db_query("SELECT type, status, parent_id FROM {$serendipity['dbPrefix']}comments + $sql = serendipity_db_query("SELECT type, status, parent_id, body FROM {$serendipity['dbPrefix']}comments WHERE entry_id = ". $entry_id ." - AND id = ". $id , true); - - serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}comments - WHERE entry_id = ". $entry_id ." - AND id = ". $id ); - - if ($sql['status'] !== 'pending') { - if (!empty($sql['type']) && $sql['type'] != 'NORMAL') { - $type = 'trackbacks'; - } else { - $type = 'comments'; + AND id = ". $id, true); + + + /* Check to see if the comment has children + * if it does, don't delete, but replace with "*(COMMENT DELETED)*" + to delete a tree, delete children first */ + $has_parent = serendipity_db_query("SELECT count(id) AS count + FROM {$serendipity['dbPrefix']}comments + WHERE parent_id = ". $id . " + LIMIT 1", true); + + if (is_array($has_parent) && isset($has_parent['count']) && $has_parent['count'] > 0 && $sql['body'] != 'COMMENT_DELETED') { + // Comment has childs, so don't delete it. + serendipity_db_query("UPDATE {$serendipity['dbPrefix']}comments + SET body = 'COMMENT_DELETED' + WHERE id = " . $id); + } else { + // Comment has no childs or had already been deleted., it can be safely removed. + serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}comments + WHERE entry_id = ". $entry_id ." + AND id = ". $id); + + if (is_array($sql) && $sql['status'] !== 'pending') { + if (!empty($sql['type']) && $sql['type'] != 'NORMAL') { + $type = 'trackbacks'; + } else { + $type = 'comments'; + } + serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries SET $type = $type-1 WHERE id = ". $entry_id ." $admin"); } - serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries SET $type = $type-1 WHERE id = ". $entry_id); - } - - serendipity_db_query("UPDATE {$serendipity['dbPrefix']}comments SET parent_id = " . (int)$sql['parent_id'] . " WHERE parent_id = " . $id); + serendipity_db_query("UPDATE {$serendipity['dbPrefix']}comments SET parent_id = " . (int)$sql['parent_id'] . " WHERE parent_id = " . $id); + } return true; } else { return false; diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index d320e2e..7e13738 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -2,6 +2,11 @@ # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) # All rights reserved. See LICENSE file for licensing details +if (defined('S9Y_FRAMEWORK_ENTRIES')) { + return; +} +@define('S9Y_FRAMEWORK_ENTRIES', true); + /** * Delete a category or range of categories * @@ -562,10 +567,17 @@ function serendipity_fetchCategories($authorid = null, $name = null, $order = nu } $where = ''; + + if ($authorid === -1 OR $authorid === 0) { + $sql_groupid = '0'; + } else { + $sql_groupid = 'ag.groupid'; + } + if ($authorid != 'all' && is_numeric($authorid)) { $sql_authorid = $authorid; if (!serendipity_checkPermission('adminCategoriesMaintainOthers', $authorid)) { - $where = " WHERE (c.authorid = $authorid OR c.authorid = 0)"; + $where = " WHERE (c.authorid = $authorid OR c.authorid = 0) "; $where .= "OR ( acl.artifact_type = 'category' AND acl.artifact_mode = '" . serendipity_db_escape_string($artifact_mode) . "' @@ -612,7 +624,7 @@ function serendipity_fetchCategories($authorid = null, $name = null, $order = nu LEFT OUTER JOIN {$serendipity['dbPrefix']}authorgroups AS ag ON ag.authorid = $sql_authorid LEFT OUTER JOIN {$serendipity['dbPrefix']}access AS acl - ON (ag.groupid = acl.groupid AND acl.artifact_id = c.categoryid) + ON ($sql_groupid = acl.groupid AND acl.artifact_id = c.categoryid) $where $group"; if (!empty($order)) { @@ -719,6 +731,8 @@ function serendipity_searchEntries($term, $limit = '') { e.id, e.authorid, a.realname AS author, + e.allow_comments, + e.moderate_comments, a.email, e.timestamp, e.comments, @@ -746,14 +760,18 @@ function serendipity_searchEntries($term, $limit = '') { * * The list of total entries is calculated from the serendipity_getTotelEntries() function * + * @param string suffix for URLs + * @param int Amount of total entries * @access public * @see serendipity_getTotalEntries() * @return null */ -function serendipity_printEntryFooter() { +function serendipity_printEntryFooter($suffix = '.html', $totalEntries = null) { global $serendipity; - $totalEntries = serendipity_getTotalEntries(); + if ($totalEntries === null) { + $totalEntries = serendipity_getTotalEntries(); + } $totalPages = ceil($totalEntries / $serendipity['fetchLimit']); if (!isset($serendipity['GET']['page'])) { @@ -767,7 +785,7 @@ function serendipity_printEntryFooter() { if ($serendipity['GET']['page'] > 1) { $uriArguments = $serendipity['uriArguments']; $uriArguments[] = 'P'. ($serendipity['GET']['page'] - 1); - $serendipity['smarty']->assign('footer_prev_page', serendipity_rewriteURL(implode('/', $uriArguments) .'.html')); + $serendipity['smarty']->assign('footer_prev_page', serendipity_rewriteURL(implode('/', $uriArguments) . $suffix)); } $uriArguments = $serendipity['uriArguments']; @@ -775,13 +793,13 @@ function serendipity_printEntryFooter() { $serendipity['smarty']->assign('footer_totalEntries', $totalEntries); $serendipity['smarty']->assign('footer_totalPages', $totalPages); $serendipity['smarty']->assign('footer_currentPage', $serendipity['GET']['page']); - $serendipity['smarty']->assign('footer_pageLink', serendipity_rewriteURL(implode('/', $uriArguments) . '.html')); + $serendipity['smarty']->assign('footer_pageLink', serendipity_rewriteURL(implode('/', $uriArguments) . $suffix)); $serendipity['smarty']->assign('footer_info', sprintf(PAGE_BROWSE_ENTRIES, (int)$serendipity['GET']['page'], $totalPages, $totalEntries)); if ($serendipity['GET']['page'] < $totalPages) { $uriArguments = $serendipity['uriArguments']; $uriArguments[] = 'P'. ($serendipity['GET']['page'] + 1); - $serendipity['smarty']->assign('footer_next_page', serendipity_rewriteURL(implode('/', $uriArguments) .'.html')); + $serendipity['smarty']->assign('footer_next_page', serendipity_rewriteURL(implode('/', $uriArguments) . $suffix)); } } @@ -927,9 +945,13 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); $entry['commURL'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false, array('timestamp' => $entry['timestamp'])); - $entry['rdf_ident'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp'])); + $entry['html_title']= $entry['title']; $entry['title'] = htmlspecialchars($entry['title']); + $entry['title_rdf'] = preg_replace('@-{2,}@', '-', $entry['title']); + $entry['rdf_ident'] = serendipity_archiveURL($entry['id'], $entry['title_rdf'], 'baseURL', true, array('timestamp' => $entry['timestamp'])); + $entry['link_rdf'] = serendipity_rewriteURL(PATH_FEEDS . '/ei_'. $entry['id'] .'.rdf'); + $entry['link_allow_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=enable&serendipity[entry]=' . $entry['id']; $entry['link_deny_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=disable&serendipity[entry]=' . $entry['id']; $entry['allow_comments'] = serendipity_db_bool($entry['allow_comments']); @@ -939,7 +961,6 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm $entry['link_popup_trackbacks'] = $serendipity['serendipityHTTPPath'] .'comment.php?serendipity[entry_id]='. $entry['id'] .'&serendipity[type]=trackbacks'; $entry['link_edit'] = $serendipity['baseURL'] .'serendipity_admin.php?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]='. $entry['id']; $entry['link_trackback'] = $serendipity['baseURL'] .'comment.php?type=trackback&entry_id='. $entry['id']; - $entry['link_rdf'] = serendipity_rewriteURL(PATH_FEEDS . '/ei_'. $entry['id'] .'.rdf'); $entry['link_viewmode_threaded'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] .'?url='. $entry['commURL'] .'&serendipity[cview]='. VIEWMODE_THREADED; $entry['link_viewmode_linear'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] .'?url='. $entry['commURL'] .'&serendipity[cview]='. VIEWMODE_LINEAR; $entry['link_author'] = serendipity_authorURL($authorData); @@ -985,14 +1006,14 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm /* IF WE ARE DISPLAYING A FULL ENTRY */ if (isset($serendipity['GET']['id'])) { - $serendipity['smarty']->assign( - array( - 'comments_messagestack' => (isset($serendipity['messagestack']['comments']) ? (array)$serendipity['messagestack']['comments'] : array()), - 'is_comment_added' => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'true' ? true: false), - 'is_comment_moderate' => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'moderate' ? true: false) - ) + $comment_add_data = array( + 'comments_messagestack' => (isset($serendipity['messagestack']['comments']) ? (array)$serendipity['messagestack']['comments'] : array()), + 'is_comment_added' => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'true' ? true: false), + 'is_comment_moderate' => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'moderate' ? true: false) ); + $serendipity['smarty']->assign($comment_add_data); + serendipity_displayCommentForm( $entry['id'], $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'], @@ -1013,7 +1034,7 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm serendipity_printEntryFooter(); } - $serendipity['smarty']->assign('entries', $dategroup); + $serendipity['smarty']->assign_by_ref('entries', $dategroup); unset($entries, $dategroup); if (isset($serendipity['short_archives']) && $serendipity['short_archives']) { @@ -1086,6 +1107,10 @@ function serendipity_updertEntry($entry) { $newEntry = 0; $exflag = 0; + if (isset($entry['properties'])) { + unset($entry['properties']); + } + if (!is_numeric($entry['timestamp'])) { $entry['timestamp'] = time(); } @@ -1233,7 +1258,7 @@ function serendipity_deleteEntry($id) { serendipity_db_query("DELETE FROM {$serendipity["dbPrefix"]}entrycat WHERE entryid=$id"); serendipity_db_query("DELETE FROM {$serendipity["dbPrefix"]}entryproperties WHERE entryid=$id"); serendipity_db_query("DELETE FROM {$serendipity["dbPrefix"]}comments WHERE entry_id=$id"); - serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}references WHERE entry_id='$id'"); + serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}references WHERE entry_id='$id' AND type = ''"); serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}permalinks WHERE entry_id='$id'"); } @@ -1340,6 +1365,7 @@ function serendipity_updateEntryCategories($postid, $categories) { * * The archives are created according to the current timestamp and show the current year. * $serendipity['GET']['category'] is honoured like in serendipity_fetchEntries() + * $serendipity['GET']['viewAuthor'] is honoured like in serendipity_fetchEntries() * * @access public * @return null @@ -1356,12 +1382,12 @@ function serendipity_printArchives() { $thisYear = date('Y', serendipity_serverOffsetHour()); $thisMonth = date('m', serendipity_serverOffsetHour()); break; - case 'jalali-utf8': + case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; - $lastYear = jalali_date_utf('Y', serendipity_serverOffsetHour($f[0][0])); - $lastMonth = jalali_date_utf('m', serendipity_serverOffsetHour($f[0][0])); - $thisYear = jalali_date_utf('Y', serendipity_serverOffsetHour()); - $thisMonth = jalali_date_utf('m', serendipity_serverOffsetHour()); + $lastYear = persian_date_utf('Y', serendipity_serverOffsetHour($f[0][0])); + $lastMonth = persian_date_utf('m', serendipity_serverOffsetHour($f[0][0])); + $thisYear = persian_date_utf('Y', serendipity_serverOffsetHour()); + $thisMonth = persian_date_utf('m', serendipity_serverOffsetHour()); break; } $max = 0; @@ -1374,6 +1400,12 @@ function serendipity_printArchives() { $cat_get = ''; } + if (isset($serendipity['GET']['viewAuthor'])) { + $author_get = '/A' . (int)$serendipity['GET']['viewAuthor']; + } else { + $author_get = ''; + } + $output = array(); for ($y = $thisYear; $y >= $lastYear; $y--) { $output[$y]['year'] = $y; @@ -1395,10 +1427,10 @@ function serendipity_printArchives() { $s = serendipity_serverOffsetHour(mktime(0, 0, 0, $m, 1, $y), true); $e = serendipity_serverOffsetHour(mktime(23, 59, 59, $m, date('t', $s), $y), true); break; - case 'jalali-utf8': + case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; - $s = serendipity_serverOffsetHour(jalali_mktime(0, 0, 0, $m, 1, $y), true); - $e = serendipity_serverOffsetHour(jalali_mktime(23, 59, 59, $m, date('t', $s), $y), true); + $s = serendipity_serverOffsetHour(persian_mktime(0, 0, 0, $m, 1, $y), true); + $e = serendipity_serverOffsetHour(persian_mktime(23, 59, 59, $m, date('t', $s), $y), true); break; } @@ -1412,7 +1444,8 @@ function serendipity_printArchives() { AND timestamp >= $s AND timestamp <= $e " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . time() : '') - . (!empty($cat_sql) ? ' AND ' . $cat_sql : '') . " + . (!empty($cat_sql) ? ' AND ' . $cat_sql : '') + . (!empty($serendipity['GET']['viewAuthor']) ? ' AND e.authorid = ' . (int)$serendipity['GET']['viewAuthor'] : '') . " GROUP BY ec.entryid", false, 'assoc'); if (is_array($entries)) { $entry_count = count($entries); @@ -1427,14 +1460,15 @@ function serendipity_printArchives() { $data = array(); $data['entry_count'] = $entry_count; - $data['link'] = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m) . $cat_get); - $data['link_summary'] = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m) . $cat_get, true); + $data['link'] = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m) . $cat_get . $author_get); + $data['link_summary'] = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m) . $cat_get . $author_get, true); $data['date'] = $s; $output[$y]['months'][] = $data; } } - $serendipity['smarty']->assign(array('archives' => $output, - 'max_entries' => $max)); + + $serendipity['smarty']->assign_by_ref('archives', $output); + $serendipity['smarty']->assign_by_ref('max_entries', $max); serendipity_smarty_fetch('ARCHIVES', 'entries_archives.tpl', true); } diff --git a/include/functions_installer.inc.php b/include/functions_installer.inc.php index f0553b4..44f3050 100644 --- a/include/functions_installer.inc.php +++ b/include/functions_installer.inc.php @@ -3,6 +3,11 @@ # All rights reserved. See LICENSE file for licensing details +if (defined('S9Y_FRAMEWORK_INSTALLER')) { + return; +} +@define('S9Y_FRAMEWORK_INSTALLER', true); + /** * Convert a PHP Ini setting to a boolean flag * @@ -102,6 +107,9 @@ function serendipity_updateLocalConfig($dbName, $dbPrefix, $dbHost, $dbUser, $db fwrite($configfp, "\t\$serendipity['dbPass'] = '" . addslashes($dbPass) . "';\n"); fwrite($configfp, "\t\$serendipity['dbType'] = '" . addslashes($dbType) . "';\n"); fwrite($configfp, "\t\$serendipity['dbPersistent'] = ". (serendipity_db_bool($dbPersistent) ? 'true' : 'false') .";\n"); + if ($serendipity['dbNames']) { + fwrite($configfp, "\t\$serendipity['dbCharset'] = '" . addslashes(SQL_CHARSET) . "';\n"); + } if (is_array($privateVariables) && count($privateVariables) > 0) { foreach($privateVariables AS $p_idx => $p_val) { @@ -417,6 +425,10 @@ function serendipity_guessInput($type, $name, $value='', $default='') { echo ''; break; + case 'textarea': + echo ''; + break; + default: echo ''; break; @@ -436,9 +448,6 @@ function serendipity_guessInput($type, $name, $value='', $default='') { */ function serendipity_printConfigTemplate($config, $from = false, $noForm = false, $folded = true, $allowToggle = true) { global $serendipity; - if (!isset($serendipity['XHTML11'])) { - $serendipity['XHTML11'] = FALSE; - } if ( $allowToggle ) { ?>