Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29170
Modified Files:
serendipity_lang.inc.php serendipity_plugin_api.php
serendipity_sidebar_items.php
serendipity_admin_plugins.inc.php serendipity_admin.php
Log Message:
multi-user #4
Index: serendipity_admin.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- serendipity_admin.php 21 Mar 2004 16:35:31 -0000 1.34
+++ serendipity_admin.php 4 Apr 2004 16:23:29 -0000 1.35
@@ -26,7 +26,7 @@
?>
</head>
-<body id="serendipity_admin_page">
+<body id="serendipity_admin_page" onload="if (self.Spawnnugget) { Spawnnugget(); }">
<div id="serendipity_banner">
<h1><?php echo (isset($serendipity['blogTitle']) ? $serendipity['blogTitle'] : ''); ?></h1>
<?php
@@ -37,6 +37,7 @@
<?php
}
?>
+ <h2>[<?php printf(USER_SELF_INFO, $serendipity['authorid'], $serendipity['serendipityUser'], $serendipity['serendipityUserlevel']); ?>]</h2>
</div>
<table id="mainpane">
<tr valign="top">
@@ -61,6 +62,7 @@
} else {
?>
<td id="serendipityLeftSideBar">
+<?php if ($serendipity['serendipityUserlevel'] >= USERLEVEL_CHIEF) { ?>
<div class="serendipitySideBarItem">
<div class="serendipitySideBarTitle"><?php echo APPEARANCE; ?>:</div>
<div class="serendipitySideBarContent">
@@ -68,11 +70,14 @@
• <a href="?serendipity[adminModule]=plugins"><?php echo CONFIGURE_PLUGINS; ?></a><br />
</div>
</div>
-
+<?php } ?>
<div class="serendipitySideBarItem">
<div class="serendipitySideBarTitle"><?php echo ADMIN; ?></div>
<div class="serendipitySideBarContent">
• <a href="?serendipity[adminModule]=installer"><?php echo CONFIGURATION; ?></a><br />
+<?php if ($serendipity['serendipityUserlevel'] >= USERLEVEL_CHIEF) { ?>
+ • <a href="?serendipity[adminModule]=users"><?php echo MANAGE_USERS; ?></a><br />
+<?php } ?>
• <a href="?serendipity[adminModule]=interop"><?php echo IMPORT_EXPORT_ENTRIES; ?></a><br />
</div>
</div>
@@ -110,6 +115,10 @@
include S9Y_INCLUDE_PATH . 'serendipity_admin_plugins.inc.php';
break;
+ case 'users':
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_users.inc.php';
+ break;
+
case 'interop':
include S9Y_INCLUDE_PATH . 'serendipity_admin_interop.inc.php';
break;
Index: serendipity_plugin_api.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_plugin_api.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- serendipity_plugin_api.php 23 Mar 2004 16:11:34 -0000 1.16
+++ serendipity_plugin_api.php 4 Apr 2004 16:23:29 -0000 1.17
@@ -54,7 +54,7 @@
* of the same class, then the persistent state will be copied.
* This allows the user to clone a plugin.
*/
- function create_plugin_instance($plugin_class_id, $copy_from_instance = null, $default_placement = 'right')
+ function create_plugin_instance($plugin_class_id, $copy_from_instance = null, $default_placement = 'right', $authorid = '0')
{
global $serendipity;
@@ -70,13 +70,13 @@
$nextidx = 0;
}
- serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}plugins (name, sort_order, placement) values ('$key', $nextidx, '$default_placement')");
+ serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}plugins (name, sort_order, placement, authorid) values ('$key', $nextidx, '$default_placement', '$authorid')");
/* Check for multiple dependencies */
$plugin =& serendipity_plugin_api::load_plugin($key);
$bag = new serendipity_property_bag;
$plugin->introspect($bag);
- $plugin->register_dependencies(false);
+ $plugin->register_dependencies(false, $authorid);
return $key;
}
@@ -254,6 +254,10 @@
}
$p =& new $class_name($instance_id);
+
+ $sql = "SELECT authorid from {$serendipity['dbPrefix']}plugins WHERE name = '" . $instance_id . "'";
+ $owner = serendipity_db_query($sql, true);
+ $p->serendipity_owner = $owner[0];
return $p;
}
@@ -273,6 +277,24 @@
return serendipity_db_query($sql);
}
+ function update_plugin_owner($name, $authorid)
+ {
+ global $serendipity;
+
+ if (empty($authorid) && $authorid != '0') {
+ return;
+ }
+
+ $admin = '';
+ if ($serendipity['serendipityUserlevel'] < USERLEVEL_ADMIN) {
+ $admin = " AND (authorid = 0 OR authorid = {$serendipity['authorid']})";
+ }
+
+ $sql = "UPDATE {$serendipity['dbPrefix']}plugins SET authorid='$authorid' WHERE name='$name' $admin";
+
+ return serendipity_db_query($sql);
+ }
+
function generate_plugins($side, $tagname = 'div')
{
$plugins = serendipity_plugin_api::enum_plugins($side);
@@ -439,6 +461,7 @@
class serendipity_plugin {
var $instance = null;
+ var $protected = false;
var $wrap_class = 'serendipitySideBarItem';
var $title_class = 'serendipitySideBarTitle';
var $content_class = 'serendipitySideBarContent';
@@ -468,6 +491,9 @@
// 'foo bar'
// )
// );
+
+ $this->protected = FALSE; // If set to TRUE, only allows the owner of the plugin to modify its configuration
+
return true;
}
@@ -524,7 +550,7 @@
return true;
}
- function register_dependencies($remove = false)
+ function register_dependencies($remove = false, $authorid = '0')
{
global $serendipity;
@@ -548,9 +574,9 @@
$exists = serendipity_plugin_api::exists($dependency);
if (!$exists) {
if (strncmp($dependency, 'serendipity_event_', 18) == 0) {
- $keys[] = serendipity_plugin_api::create_plugin_instance($dependency, null, 'event');
+ $keys[] = serendipity_plugin_api::create_plugin_instance($dependency, null, 'event', $authorid);
} else {
- $keys[] = serendipity_plugin_api::create_plugin_instance($dependency);
+ $keys[] = serendipity_plugin_api::create_plugin_instance($dependency, null, 'right', $authorid);
}
} else {
$keys[] = $exists;
Index: serendipity_lang.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_lang.inc.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- serendipity_lang.inc.php 21 Mar 2004 16:35:32 -0000 1.10
+++ serendipity_lang.inc.php 4 Apr 2004 16:23:29 -0000 1.11
@@ -8,6 +8,7 @@
} elseif (IS_installed === false || (defined('IS_up2date') && IS_up2date === false)) { /* -- Auto-Guess -- */
// If no config file is loaded, language includes are not available.
// Now include one. Try to auto-guess the language by looking up the HTTP_ACCEPT_LANGUAGE.
+ $serendipty['autolang'] = 'en';
$supported_languages = array('en', 'da', 'de', 'es');
$possible_languages = explode(',', (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : ''));
if (is_array($possible_languages)) {
@@ -15,12 +16,13 @@
$preferred_language = preg_replace('@^([^\-_;]*)_?.*$@', '\1', $lang);
if (in_array($preferred_language, $supported_languages)) {
@include_once(S9Y_INCLUDE_PATH . 'lang/serendipity_lang_' . $preferred_language . '.inc.php');
+ $serendipity['autolang'] = $preferred_language;
break;
} // endif
} // endforeach
} // endif
} //endif
-
+
// Do fallback to english
if ((defined('serendipity_LANG_LOADED') && serendipity_LANG_LOADED === true) || IS_installed === false || (defined('IS_up2date') && IS_up2date === false)) {
@include_once(S9Y_INCLUDE_PATH .'lang/serendipity_lang_en.inc.php');
@@ -29,3 +31,4 @@
/* vim: set sts=4 ts=4 expandtab : */
?>
+
Index: serendipity_admin_plugins.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_plugins.inc.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- serendipity_admin_plugins.inc.php 21 Mar 2004 16:35:31 -0000 1.20
+++ serendipity_admin_plugins.inc.php 4 Apr 2004 16:23:29 -0000 1.21
@@ -8,6 +8,10 @@
include_once S9Y_INCLUDE_PATH . 'serendipity_plugin_api.php';
include_once S9Y_INCLUDE_PATH . 'serendipity_sidebar_items.php';
+if ($serendipity['serendipityUserlevel'] < USERLEVEL_CHIEF) {
+ return;
+}
+
function show_plugins($event_only = false)
{
global $serendipity;
@@ -44,6 +48,7 @@
}
?>
</select>
+ <input type="checkbox" name="serendipity[all_authors]" value="true" checked="checked" id="all_authors" /><label for="all_authors"><?php echo ALL_AUTHORS; ?></label>
<input name="NEW" value="<?php echo ADD_PLUGIN; ?>" type="submit" />
<br />
<br />
@@ -56,7 +61,7 @@
<?php
if (!$event_only) {
?>
- <th><?php echo PLACEMENT; ?></th>
+ <th colspan="2"><?php echo PLACEMENT; ?></th>
<?php
}
?>
@@ -98,7 +103,7 @@
$title = serendipity_plugin_api::get_plugin_title($plugin, ' ');
- if ($bag->is_set('configuration')) {
+ if ($bag->is_set('configuration') && ($plugin->protected === FALSE || $plugin_data['authorid'] == '0' || $plugin_data['authorid'] == $serendipity['authorid'] || $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN)) {
$url = '?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $key;
$desc = '<a href="' . $url . '">' . $desc . '</a>';
$name = '<a href="' . $url . '">' . $name . '</a>';
@@ -121,14 +126,29 @@
<tr>
<td style="border-bottom: 1px solid #000000">
<div>
+ <?php if ($plugin_data['authorid'] == '0' || $plugin_data['authorid'] == $serendipity['authorid'] || $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN) { ?>
<input type="checkbox" name="serendipity[plugin_to_remove][]" value="<?php echo $plugin_data['name']; ?>">
+ <?php } else { ?>
+
+ <?php } ?>
</div>
</td>
<td style="border-bottom: 1px solid #000000"><?php echo $title; ?></td>
<td style="border-bottom: 1px solid #000000"><?php echo $desc; ?></td>
<td style="border-bottom: 1px solid #000000" nowrap="nowrap">
- <div><?php echo $place . $moveup . $movedown; ?></div>
+ <div>
+ <?php
+ if ($plugin_data['authorid'] == $serendipity['authorid'] || $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN) {
+ ownership($plugin_data['authorid'], $plugin_data['name']);
+ } else {
+ ownership($plugin_data['authorid'], $plugin_data['name'], true);
+ }
+ ?>
+ </div>
+ </td>
+ <td style="border-bottom: 1px solid #000000" nowrap="nowrap">
+ <div><?php echo $place . $moveup . $movedown;?></div>
</td>
</tr>
<?php
@@ -146,6 +166,40 @@
<?php
}
+function ownership($authorid, $name, $readonly = false) {
+ global $serendipity;
+
+ static $users = array();
+ if (empty($users)) {
+ $users = serendipity_fetchUsers();
+ }
+
+ if (!$readonly) {
+?>
+<select name="serendipity[ownership][<?php echo $name; ?>]">
+ <option value="0"><?php echo ALL_AUTHORS; ?></option>
+<?php
+ }
+
+ foreach($users AS $user) {
+ if ($readonly && $user['authorid'] == $authorid) {
+ $username = htmlentities($user['username']);
+ } elseif (!$readonly) {
+?>
+ <option value="<?php echo $user['authorid']; ?>"<?php echo ($user['authorid'] == $authorid ? ' selected="selected"' : ''); ?>><?php echo htmlentities($user['username']); ?></option>
+<?php
+ }
+ }
+
+ if (!$readonly) {
+?>
+</select>
+<?php
+ } else {
+ echo (empty($username) ? ALL_AUTHORS : $username);
+ }
+}
+
function placement_box($name, $val)
{
static $opts = array(
@@ -206,6 +260,10 @@
/* configure a specific instance */
$plugin =& serendipity_plugin_api::load_plugin($_GET['serendipity']['plugin_to_conf']);
+ if (!($plugin->protected === FALSE || $plugin->serendipity_owner == '0' || $plugin->serendipity_owner == $serendipity['authorid'] || $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN)) {
+ return;
+ }
+
$bag = new serendipity_property_bag;
$plugin->introspect($bag);
$name = htmlentities($bag->get('name'));
@@ -374,12 +432,12 @@
<tr>
<td colspan="2">
<div>
- <textarea name="serendipity[plugin][<?php echo $config_item; ?>]" rows="20" cols="80"><?php echo $hvalue; ?></textarea>
+ <textarea style="width: 100%" id="nugget" name="serendipity[plugin][<?php echo $config_item; ?>]" rows="20" cols="80"><?php echo $hvalue; ?></textarea>
</div>
</td>
</tr>
<?php
- serendipity_emit_htmlarea_code("document.forms['serendipityPluginConfigure']['serendipity[plugin][$config_item]']");
+ serendipity_emit_htmlarea_code('nugget', 'nugget');
break;
}
}
@@ -400,21 +458,35 @@
addslashes($plugin_name),
addslashes($placement)
);
+
+ serendipity_plugin_api::update_plugin_owner(
+ addslashes($plugin_name),
+ addslashes($_POST['serendipity']['ownership'][$plugin_name])
+ );
}
}
if (isset($_POST['NEW']) && $_POST['serendipity']['plugin_to_add'] != '0') {
+ $authorid = $serendipity['authorid'];
+ if (isset($_POST['serendipity']['all_authors']) && $_POST['serendipity']['all_authors'] == 'true') {
+ $authorid = '0';
+ }
+
if (isset($_POST['serendipity']['event_plugin'])) {
- $inst = serendipity_plugin_api::create_plugin_instance($_POST['serendipity']['plugin_to_add'], null, 'event');
+ $inst = serendipity_plugin_api::create_plugin_instance($_POST['serendipity']['plugin_to_add'], null, 'event', $authorid);
} else {
- $inst = serendipity_plugin_api::create_plugin_instance($_POST['serendipity']['plugin_to_add']);
+ $inst = serendipity_plugin_api::create_plugin_instance($_POST['serendipity']['plugin_to_add'], null, 'right', $authorid);
}
/* TODO: redirect to configuration for that instance */
}
if (isset($_POST['REMOVE'])) {
foreach ($_POST['serendipity']['plugin_to_remove'] as $key) {
- serendipity_plugin_api::remove_plugin_instance($key);
+ $plugin =& serendipity_plugin_api::load_plugin($key);
+
+ if ($plugin->serendipity_owner == '0' || $plugin->serendipity_owner == $serendipity['authorid'] || $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN) {
+ serendipity_plugin_api::remove_plugin_instance($key);
+ }
}
}
Index: serendipity_sidebar_items.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_sidebar_items.php,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- serendipity_sidebar_items.php 1 Apr 2004 14:19:01 -0000 1.52
+++ serendipity_sidebar_items.php 4 Apr 2004 16:23:29 -0000 1.53
@@ -436,6 +436,8 @@
'markup',
)
);
+
+ $this->protected = TRUE; // If set to TRUE, only allows the owner of the plugin to modify its configuration
}
function introspect_config_item($name, &$propbag)
@@ -514,7 +516,8 @@
function generate_content(&$title) {
global $serendipity;
- $categories = serendipity_fetchCategories($this->get_config('authorid'));
+ $which_category = $this->get_config('authorid');
+ $categories = serendipity_fetchCategories(empty($which_category) ? 'all' : $which_category);
$title = CATEGORIES;
$html = '';
|