Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9843
Modified Files:
serendipity_functions.inc.php
Log Message:
- superuser sees all categories, no matter who owns them. That way they
can change post categories as needed.
- editors see their categories and all categories for users at levels less
than their own. I.e. a level 1 user sees categories that are:
- all users
- their own
- all categories private to level 0 users
- When saving an edited entry, the user stays as the original poster.
- When editing a post, if the category of the post is NOT in the user's
list, the category is locked and cannot be changed.
The language files have a new define for CANNOT_EDIT_CATEGORY. I used
babelfish to get german, french and spanish translations, I made a weak,
half-english attempt at Czech, Dutch and Danish. Someone please fix them
later.
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.254
retrieving revision 1.255
diff -u -d -r1.254 -r1.255
--- serendipity_functions.inc.php 17 Apr 2004 11:30:42 -0000 1.254
+++ serendipity_functions.inc.php 23 Apr 2004 16:12:03 -0000 1.255
@@ -690,8 +690,12 @@
$authorid = ((isset($serendipity['authorid']) && !empty($serendipity['GET']['adminModule'])) ? $serendipity['authorid'] : 1);
}
+ if ($serendipity['serendipityUserlevel'] == USERLEVEL_ADMIN) {
+ $authorid = 'all';
+ }
+
if ($authorid != 'all') {
- $where = " WHERE (c.authorid = $authorid OR c.authorid = 0)";
+ $where = " WHERE (c.authorid = $authorid OR c.authorid = 0) OR a.userlevel < ".$serendipity['serendipityUserlevel'];
} else {
$where = '';
}
@@ -1911,10 +1915,6 @@
}
$entry['exflag'] = $exflag;
- $entry['author'] = $serendipity['user'];
- if (!isset($entry['authorid']) || empty($entry['authorid'])) {
- $entry['authorid'] = $serendipity['authorid'];
- }
if (!is_numeric($entry['id'])) {
/* we need to insert */
@@ -1922,6 +1922,12 @@
unset($entry['id']);
$entry['comments'] = 0;
+ // New entries need an author
+ $entry['author'] = $serendipity['user'];
+ if (!isset($entry['authorid']) || empty($entry['authorid'])) {
+ $entry['authorid'] = $serendipity['authorid'];
+ }
+
$res = serendipity_db_insert('entries', $entry);
if ($res)
@@ -2026,20 +2032,38 @@
$allow_comments = '';
}
- $n = "\n";
- $cat_list = '<select name="serendipity[categoryid]">' . $n;
- $cat_list .= ' <option value="0">[' . NO_CATEGORY . ']</option>' . $n;
- if (is_array($cats)) {
+ if (isset($entry['categoryid']) && $entry['categoryid'] != 0) {
+ $edit_cat=0;
+ if (is_array($cats)) {
foreach ($cats as $cat_data) {
- $selected = (isset($entry['categoryid']) && $cat_data['categoryid'] == $entry['categoryid'] ? ' selected="selected"' : '');
- $cat_list .= ' <option value="' . $cat_data['categoryid'] . '" ' . $selected . '>'
- . htmlspecialchars($cat_data['category_name'])
- . ' - '
- . htmlspecialchars($cat_data['category_description'])
- . '</option>' . $n;
+ if ($cat_data['categoryid'] == $entry['categoryid'] ) {
+ $edit_cat = 1;
+ }
+ }
}
+ } else {
+ $edit_cat=1;
+ }
+
+ $n = "\n";
+ if ($edit_cat) {
+ $cat_list = '<select name="serendipity[categoryid]">' . $n;
+ $cat_list .= ' <option value="0">[' . NO_CATEGORY . ']</option>' . $n;
+ if (is_array($cats)) {
+ foreach ($cats as $cat_data) {
+ $selected = (isset($entry['categoryid']) && $cat_data['categoryid'] == $entry['categoryid'] ? ' selected="selected"' : '');
+ $cat_list .= ' <option value="' . $cat_data['categoryid'] . '" ' . $selected . '>'
+ . htmlspecialchars($cat_data['category_name'])
+ . ' - '
+ . htmlspecialchars($cat_data['category_description'])
+ . '</option>' . $n;
+ }
+ }
+ $cat_list .= '</select>' . $n;
+ } else {
+ $cat_list = CANNOT_EDIT_CATEGORY . $n;
+ $cat_list .= '<input type="hidden" name="serendipity[categoryid]" value="' . $entry['categoryid'] . '" />' . $n;
}
- $cat_list .= '</select>' . $n;
$hidden = '';
foreach($hiddens as $key => $value) {
|