Update of /cvsroot/php-blog/serendipity/include
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7315/include
Modified Files:
functions.inc.php functions_comments.inc.php
functions_config.inc.php functions_entries.inc.php
functions_smarty.inc.php plugin_internal.inc.php
Log Message:
- Added ability to define a real name for each author
- Added serendipity_addAuthor() and serendipity_deleteAuthor functions
Version bump
Index: functions_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_config.inc.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- functions_config.inc.php 16 Feb 2005 12:36:19 -0000 1.21
+++ functions_config.inc.php 24 Feb 2005 20:14:22 -0000 1.22
@@ -2,9 +2,27 @@
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
-function serendipity_remove_config_var($name, $authorid = 0) {
+function serendipity_addAuthor($username, $password, $realname, $email, $userlevel=0) {
+ global $serendipity;
+ $password = md5($password);
+ $query = "INSERT INTO {$serendipity['dbPrefix']}authors (username, password, realname, email, userlevel)
+ VALUES ('" . serendipity_db_escape_string($username) . "',
+ '" . serendipity_db_escape_String($password) . "',
+ '" . serendipity_db_escape_String($realname) . "',
+ '" . serendipity_db_escape_String($email) . "',
+ '" . serendipity_db_escape_String($userlevel) . "')";
+ serendipity_db_query($query);
+ return serendipity_db_insert_id('authors', 'authorid');
+}
+
+function serendipity_deleteAuthor($authorid) {
global $serendipity;
+ serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}authors WHERE authorid=" . (int)$authorid ." and userlevel <= ". (int)$serendipity['serendipityUserlevel'] ." LIMIT 1");
+ return true;
+}
+function serendipity_remove_config_var($name, $authorid = 0) {
+ global $serendipity;
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}config where name='" . serendipity_db_escape_string($name) . "' AND authorid = " . (int)$authorid);
}
Index: functions_smarty.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_smarty.inc.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- functions_smarty.inc.php 26 Jan 2005 14:14:02 -0000 1.14
+++ functions_smarty.inc.php 24 Feb 2005 20:14:22 -0000 1.15
@@ -86,7 +86,7 @@
$comments[] =
array(
'email' => $serendipity['POST']['email'],
- 'username' => $serendipity['POST']['name'],
+ 'author' => $serendipity['POST']['name'],
'body' => $serendipity['POST']['comment'],
'url' => $serendipity['POST']['url'],
'parent_id' => $serendipity['POST']['replyTo'],
Index: functions_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_entries.inc.php,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- functions_entries.inc.php 18 Feb 2005 19:48:10 -0000 1.58
+++ functions_entries.inc.php 24 Feb 2005 20:14:22 -0000 1.59
@@ -233,7 +233,7 @@
e.allow_comments,
e.last_modified,
- a.username,
+ a.realname AS author,
a.email
$body
@@ -311,7 +311,7 @@
$querystring = "SELECT
*,
- a.username,
+ a.realname AS author,
a.email
FROM
{$serendipity['dbPrefix']}entries e
@@ -461,7 +461,7 @@
$querystring = "SELECT $distinct
e.id,
e.author,
- a.username,
+ a.realname AS author,
a.email,
ec.categoryid,
e.timestamp,
@@ -598,7 +598,7 @@
$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_username'] = serendipity_rewriteURL(PATH_AUTHORS .'/'. serendipity_makePermalink(PERM_AUTHORS, array('id' => $entry['authorid'], 'title' => $entry['username'])));
+ $entry['link_username'] = serendipity_rewriteURL(PATH_AUTHORS .'/'. serendipity_makePermalink(PERM_AUTHORS, array('id' => $entry['authorid'], 'title' => $entry['author'])));
if (is_array($entry['categories'])) {
foreach ($entry['categories'] as $k => $v) {
@@ -689,7 +689,7 @@
$entryLink = serendipity_archiveURL($id, $entry['title']);
if ($comments == true) {
// Display username as part of the title for easier feed-readability
- $entry['title'] = $entry['username'] . ': ' . $entry['title'];
+ $entry['title'] = $entry['realname'] . ': ' . $entry['title'];
}
// Embed a link to extended entry, if existing
@@ -712,7 +712,7 @@
if (isset($entry['no_email']) && $entry['no_email']) {
$entry['email'] = '';
} elseif (empty($entry['email'])) {
- $query = "select email FROM {$serendipity['dbPrefix']}authors WHERE username = '". serendipity_db_escape_string($entry['username']) ."'";
+ $query = "select email FROM {$serendipity['dbPrefix']}authors WHERE authorid = '". serendipity_db_escape_string($entry['authorid']) ."'";
$results = serendipity_db_query($query);
$entry['email'] = $results[0]['email'];
}
@@ -727,7 +727,7 @@
<entry>
<link href="<?php echo $entryLink; ?>" rel="alternate" title="<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?>" type="text/html" />
<author>
- <name><?php echo serendipity_utf8_encode(htmlspecialchars($entry['username'])); ?></name>
+ <name><?php echo serendipity_utf8_encode(htmlspecialchars($entry['author'])); ?></name>
<email><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])); ?></email>
</author>
@@ -781,7 +781,7 @@
<?php
}
?>
- <author><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['username'])) . ')'; ?></author>
+ <author><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['author'])) . ')'; ?></author>
<content:encoded>
<?php
echo serendipity_utf8_encode(htmlspecialchars($entry['body'].$ext));
@@ -828,7 +828,7 @@
echo $entry['display_dat'];
?>
<dc:publisher><?php echo serendipity_utf8_encode(htmlspecialchars($serendipity['blogTitle'])); ?></dc:publisher>
- <dc:creator><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['username'])) . ')'; ?></dc:creator>
+ <dc:creator><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['author'])) . ')'; ?></dc:creator>
<dc:subject><?php echo serendipity_utf8_encode(htmlspecialchars(implode(', ', $categories))); ?></dc:subject>
<dc:date><?php echo date('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></dc:date>
<wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>
@@ -1117,7 +1117,7 @@
serendipity_plugin_api::hook_event('backend_entryform', $entry);
- if ( (isset($entry['isdraft']) && $entry['isdraft'] == 'true') ||
+ if ( (isset($entry['isdraft']) && $entry['isdraft'] == 'true') ||
(!isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') ) {
$draftD = ' selected="selected"';
} else {
Index: functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions.inc.php,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- functions.inc.php 19 Feb 2005 12:02:41 -0000 1.22
+++ functions.inc.php 24 Feb 2005 20:14:22 -0000 1.23
@@ -147,7 +147,7 @@
$where = "WHERE authorid = '" . (int)$user ."'";
}
- $querystring = "SELECT * FROM {$serendipity['dbPrefix']}authors $where ORDER BY username ASC";
+ $querystring = "SELECT * FROM {$serendipity['dbPrefix']}authors $where ORDER BY realname ASC";
return serendipity_db_query($querystring);
}
Index: plugin_internal.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/plugin_internal.inc.php,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- plugin_internal.inc.php 22 Feb 2005 10:50:36 -0000 1.24
+++ plugin_internal.inc.php 24 Feb 2005 20:14:22 -0000 1.25
@@ -939,11 +939,11 @@
global $serendipity;
switch($name) {
case 'authorid':
- $row_authors = serendipity_db_query("SELECT username, authorid FROM {$serendipity['dbPrefix']}authors");
+ $row_authors = serendipity_db_query("SELECT realname, authorid FROM {$serendipity['dbPrefix']}authors");
$authors = array('all' => ALL_AUTHORS);
if (is_array($row_authors)) {
foreach($row_authors as $row) {
- $authors[$row['authorid']] = $row['username'];
+ $authors[$row['authorid']] = $row['realname'];
}
}
Index: functions_comments.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_comments.inc.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- functions_comments.inc.php 17 Feb 2005 11:46:18 -0000 1.19
+++ functions_comments.inc.php 24 Feb 2005 20:14:22 -0000 1.20
@@ -95,7 +95,7 @@
$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.author AS username,
+ co.author,
e.title,
e.id AS entryid,
e.authorid,
@@ -136,7 +136,7 @@
foreach ($comments as $comment) {
if ($comment['parent_id'] == $parent) {
$i++;
- $retval .= '<option value="' . $comment['id'] . '"'. ($selected == $comment['id'] || (isset($serendipity['POST']['replyTo']) && $comment['id'] == $serendipity['POST']['replyTo']) ? ' selected="selected"' : '') .'>' . str_repeat(' ', $level * 2) . '#' . $indent . $i . ': ' . (empty($comment['username']) ? ANONYMOUS : htmlspecialchars($comment['username'])) . ' ' . ON . ' ' . serendipity_mb('ucfirst', serendipity_strftime(DATE_FORMAT_SHORT, $comment['timestamp'])) . "</option>\n";
+ $retval .= '<option value="' . $comment['id'] . '"'. ($selected == $comment['id'] || (isset($serendipity['POST']['replyTo']) && $comment['id'] == $serendipity['POST']['replyTo']) ? ' selected="selected"' : '') .'>' . str_repeat(' ', $level * 2) . '#' . $indent . $i . ': ' . (empty($comment['author']) ? ANONYMOUS : htmlspecialchars($comment['author'])) . ' ' . ON . ' ' . serendipity_mb('ucfirst', serendipity_strftime(DATE_FORMAT_SHORT, $comment['timestamp'])) . "</option>\n";
$retval .= serendipity_generateCommentList($id, $comments, $selected, $comment['id'], $level + 1, $indent . $i . '.');
}
}
@@ -185,7 +185,6 @@
$comment['email'] = str_replace('@', '[at]', $comment['email']);
}
- $comment['author'] = $comment['username'];
$comment['body'] = $comment['comment'];
$comment['pos'] = $i;
$comment['trace'] = $trace . $i;
|