[mod] Sharing lists between administrators

3rd party code for phpList

[mod] Sharing lists between administrators

Postby brosulo » 8:09am, Wed 06 May, 2009

Hi all,
Is it possible to share lists between administrators? I want adminA and adminB both sending mail to the same list, and also each one sending to its private lists.
brosulo
PL Nut
 
Posts: 16
Joined: 8:21am, Thu 15 May, 2008
Location: italy

Re: Sharing lists between administrators

Postby H2B2 » 9:44pm, Wed 06 May, 2009

I don't think you can share list ownership other than by sharing the same admin login/password for the lists you want shared.

There was a feature request regarding admin groups with shared access to lists. Unfortunately this ticket has been closed, but I guess you could re-open it, or file a new feature request: http://mantis.phplist.com/view.php?id=2483

EDIT: See also http://mantis.phplist.com/view.php?id=15314
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Re: Sharing lists between administrators

Postby TomP » 3:15am, Sat 30 May, 2009

I had to rebuild my entire site because of the security whole in PHPList. So I decided to address some of the things that buged me like sharing lists. It’s a simple solution. I’m not a PHP programmer. But I’ve been programming for 30 years and it seemed simple enough to create a way to make “public” lists. I use the superadmin create and maintain the list and lets the plain admins utilize the lists. But the mod described below will allow the creator of the list to edit the list and any admin can send to it. If the public check box is checked.

Disclaimer again - it's just a hack and I don't have any idea how this will effect the rest of the system. The PHP code is way over my head. But I've been programming long enough to wing-it.

Good luck - Feel free to improve and post that's what Open Source is all about !

1. Add a column to the list table called public_send
• Integer
• Not null
• Unsigned
• Zerrofill
• Default value = 0

2. Below are the changes to \admin\send.php:

<?php
require_once dirname(__FILE__).'/accesscheck.php';

$access = accessLevel("send");
switch ($access) {
case "owner":
$subselect = " where public_send = 1 or owner = ".$_SESSION["logindetails"]["id"];
$ownership = ' and owner = '.$_SESSION["logindetails"]["id"];
break;
case "all":
$subselect = "";
$ownership = '';
break;
case "none":
default:
$subselect = " where id = 0";
$ownership = " and id = 0";
break;
}

# handle commandline
if ($GLOBALS["commandline"]) {
# error_reporting(63);
$cline = parseCline();
reset($cline);
if (!$cline || !is_array($cline) || !$cline["s"] || !$cline["l"]) {
clineUsage("-s subject -l list [-f from] < message");
exit;
}

$listnames = explode(" ",$cline["l"]);
$listids = array();
foreach ($listnames as $listname) {
if (!is_numeric($listname)) {
$listid = Sql_Fetch_Array_Query(sprintf('select * from %s where name = "%s"',
$tables["list"],$listname));
if ($listid["id"]) {
$listids[$listid["id"]] = $listname;
}
} else {
$listid = Sql_Fetch_Array_Query(sprintf('select * from %s where id = %d',
$tables["list"],$listname));
if ($listid["id"]) {
$listids[$listid["id"]] = $listid["name"];
}
}
}

$_POST["targetlist"] = array();
foreach ($listids as $key => $val) {
$_POST["targetlist"][$key] = "signup";
$lists .= '"'.$val.'"' . " ";
}

if ($cline["f"]) {
$_POST["from"] = $cline["f"];
} else {
$_POST["from"] = getConfig("message_from_name") . ' '.getConfig("message_from_address");
}
$_POST["subject"] = $cline["s"];
$_POST["send"] = "1";
$_POST["footer"] = getConfig("messagefooter");
while (!feof (STDIN)) {
$_POST["message"] .= fgets(STDIN, 4096);
}

# print clineSignature();
# print "Sending message with subject ".$_POST["subject"]. " to ". $lists."\n";
}
ob_start();
include "send_core.php";

if ($done) {
if ($GLOBALS["commandline"]) {
ob_end_clean();
print clineSignature();
print "Message with subject ".$_POST["subject"]. " was sent to ". $lists."\n";
exit;
}
return;
}

/*if (!$_GET["id"]) {
Sql_Query(sprintf('insert into %s (subject,status,entered)
values("(no subject)","draft",now())',$GLOBALS["tables"]["message"]));
$id = Sql_Insert_id();
Redirect("send&id=$id");
}
*/
$list_content = '
<p>'.$GLOBALS['I18N']->get('selectlists').':</p>
<ul>
<li><input type=checkbox name="targetlist[all]"
';
if (isset($_POST["targetlist"]["all"]) && $_POST["targetlist"]["all"])
$list_content .= "checked";
$list_content .= '>'.$GLOBALS['I18N']->get('alllists').'</li>';

$list_content .= '<li><input type=checkbox name="targetlist[allactive]"
';
if (isset($_POST["targetlist"]["allactive"]) && $_POST["targetlist"]["allactive"])
$list_content .= "checked";
$list_content .= '>'.$GLOBALS['I18N']->get('All Active Lists').'</li>';

$result = Sql_query("SELECT * FROM $tables[list] $subselect");
while ($row = Sql_fetch_array($result)) {
# check whether this message has been marked to send to a list (when editing)
$checked = 0;
if ($_GET["id"]) {
$sendtolist = Sql_Query(sprintf('select * from %s where
messageid = %d and listid = %d',$tables["listmessage"],$_GET["id"],$row["id"]));
$checked = Sql_Affected_Rows();
}
$list_content .= sprintf('<li><input type=checkbox name="targetlist[%d]" value="%d" ',$row["id"],$row["id"]);
if ($checked || (isset($_POST["targetlist"][$row["id"]]) && $_POST["targetlist"][$row["id"]]))
$list_content .= "checked";
$list_content .= ">".stripslashes($row["name"]);
if ($row["active"])
$list_content .= ' (<font color=red>'.$GLOBALS['I18N']->get('listactive').'</font>)';
else
$list_content .= ' (<font color=red>'.$GLOBALS['I18N']->get('listnotactive').'</font>)';

$desc = nl2br(stripslashes($row["description"]));

$list_content .= "<br>$desc</li>";
$some = 1;
}
$list_content .= '</ul>';

if (USE_LIST_EXCLUDE) {
$list_content .= '
<hr/><h1>'.$GLOBALS['I18N']->get('selectexcludelist').'</h1><p>'.$GLOBALS['I18N']->get('excludelistexplain').'</p>
<ul>';

$dbdata = Sql_Fetch_Row_Query(sprintf('select data from %s where name = "excludelist" and id = %d',
$GLOBALS["tables"]["messagedata"],$_GET["id"]));
$excluded_lists = explode(",",$dbdata[0]);

$result = Sql_query(sprintf('SELECT * FROM %s %s',$GLOBALS["tables"]["list"],$subselect));
while ($row = Sql_fetch_array($result)) {
$checked = in_array($row["id"],$excluded_lists);
$list_content .= sprintf('<li><input type=checkbox name="excludelist[%d]" value="%d" ',$row["id"],$row["id"]);
if ($checked || isset($_POST["excludelist"][$row["id"]]))
$list_content .= "checked";
$list_content .= ">".stripslashes($row["name"]);
if ($row["active"])
$list_content .= ' (<font color=red>'.$GLOBALS['I18N']->get('listactive').'</font>)';
else
$list_content .= ' (<font color=red>'.$GLOBALS['I18N']->get('listnotactive').'</font>)';

$desc = nl2br(stripslashes($row["description"]));

$list_content .= "<br>$desc</li>";
}
$list_content .= '</ul>';
}

if (!$some)
$list_content = $GLOBALS['I18N']->get('nolistsavailable');

$list_content .= '


<p><input type=submit name=send value="'.$GLOBALS['I18N']->get('sendmessage').'">
</form>

';

if (isset($show_lists) && $show_lists) {
print $list_content;
} else {
print '</form>';
}
3. Below are the changes to admin\editlist.php:

<?php

require_once 'accesscheck.php';

if ($GLOBALS["require_login"] && !isSuperUser()) {
$access = accessLevel("list");
switch ($access) {
case "owner":
$subselect = " where owner = ".$_SESSION["logindetails"]["id"];
if ($id) {
Sql_Query("select id from ".$tables["list"]. $subselect . " and id = $id");
if (!Sql_Affected_Rows()) {
Fatal_Error($GLOBALS['I18N']->get('You do not have enough priviliges to view this page'));
return;
}
}
break;
case "all":
$subselect = ""; break;
case "none":
default:
if ($id) {
Fatal_Error($GLOBALS['I18N']->get('You do not have enough priviliges to view this page'));
return;
}
$subselect = " where id = 0";
break;
}
}

if (!empty($_GET['id'])) {
$id = sprintf('%d',$_GET["id"]);
} else {
$id = 0;
}
if ($id)
echo "<br />".PageLink2("members",$GLOBALS['I18N']->get('Members of this list'),"id=$id");
echo "<hr />";

if (isset($_POST["save"]) && isset($_POST["listname"]) && $_POST["listname"]) {
if ($GLOBALS["require_login"] && !isSuperUser())
$owner = $_SESSION["logindetails"]["id"];
if (!isset($_POST["active"])) $_POST["active"] = 0;

if (isset($_POST["public_send"]))
{
$_POST["public_send"] = 1;
}
else
{
$_POST["public_send"] = 0;
}

$_POST['listname'] = removeXss($_POST['listname']);

if ($id) {
$query = sprintf('update %s set name="%s",description="%s",
active=%d,public_send=%d,listorder=%d,prefix = "%s", owner = %d, rssfeed = "%s"
where id=%d',$tables["list"],addslashes($_POST["listname"]),
addslashes($_POST["description"]),$_POST["active"],$_POST["public_send"],$_POST["listorder"],
$_POST["prefix"],$_POST["owner"],$_POST["rssfeed"],$id);
} else {
$query = sprintf('insert into %s
(name,description,entered,listorder,owner,prefix,rssfeed,active,public_send)
values("%s","%s",now(),%d,%d,"%s","%s",%d,%d)',
$tables["list"],addslashes($_POST["listname"]),addslashes($_POST["description"]),
$_POST["listorder"],$_POST["owner"],$_POST["prefix"],$_POST["rssfeed"],$_POST["active"],$_POST["public_send"]);
}
# print $query;
$result = Sql_Query($query);
if (!$id)
$id = sql_insert_id();
Redirect('list');
echo "<br><font color=red size=+1>" . $GLOBALS['I18N']->get('Record Saved') . ": $id</font><br>";
}

if (!empty($id)) {
$result = Sql_Query("SELECT * FROM $tables[list] where id = $id");
$list = Sql_Fetch_Array($result);
} else {
$list = array(
'name' => '',
'rssfeed' => '',
'active' => 0,
'listorder' => 0,
'description' => '',

);
}
ob_end_flush();

?>

<?php echo formStart()?>
<input type=hidden name=id value="<?php echo $id ?>">
<table border=0>
<tr><td><?php echo $GLOBALS['I18N']->get('List name'); ?>:</td><td><input type=text name="listname" value="<?php echo htmlspecialchars(StripSlashes($list["name"]))?>"></td></tr>
<tr><td><?php echo $GLOBALS['I18N']->get('Check this box to make this list active (listed)'); ?></td><td><input type="checkbox" name="active" value="1" <?php echo $list["active"] ? 'checked' : ""; ?>></td></tr>
<tr><td>Check this box to make this list public</td><td><input type="checkbox" name="public_send" value="1" <?php echo $list["public_send"] ? 'checked' : ""; ?>></td></tr>
<tr><td><?php echo $GLOBALS['I18N']->get('Order for listing'); ?></td><td><input type=text name="listorder" value="<?php echo $list["listorder"] ?>" size="5"></td></tr>
<!--tr><td><?php echo $GLOBALS['I18N']->get('Subject Prefix'); ?></td><td><input type=text name="prefix" value="<?php echo $list["prefix"]; ?>" size="5"></td></tr-->
<?php if ($GLOBALS["require_login"] && (isSuperUser() || accessLevel("editlist") == "all")) {
print '<tr><td>' . $GLOBALS['I18N']->get('Owner') . '</td><td><select name="owner">';
$admins = $GLOBALS["admin_auth"]->listAdmins();
foreach ($admins as $adminid => $adminname) {
printf ('<option value="%d" %s>%s</option>',$adminid,$adminid == $list["owner"]? "selected":"",$adminname);
}
print '</select></td></tr>';
} else {
print '<input type=hidden name="owner" value="'.$_SESSION["logindetails"]["id"].'">';
}
if (ENABLE_RSS) {
if (!empty($list["rssfeed"])) {
$validate = sprintf('(<a href="http://feedvalidator.org/check?url=%s" target="_blank">%s</a>)',urlencode($list["rssfeed"]),$GLOBALS['I18N']->get('validate'));
$viewitems = PageLink2("viewrss&id=".$id,$GLOBALS['I18N']->get('View Items'));
} else {
$validate = '';
$viewitems = '';
}
printf('<tr><td>%s %s %s</td><td><input type=text name="rssfeed" value="%s" size=50></td></tr>',
$GLOBALS['I18N']->get('RSS Source'), $validate,$viewitems,htmlspecialchars($list["rssfeed"]));
}

?>
<tr><td colspan=2><?php echo $GLOBALS['I18N']->get('List Description'); ?></td></tr>
<tr><td colspan=2><textarea name="description" cols="55" rows="15"><?php echo htmlspecialchars(StripSlashes($list["description"])) ?></textarea></td></tr>
<tr><td align="center"><input type="submit" name="save" value="<?php echo $GLOBALS['I18N']->get('Save'); ?>"></td><td align="right"><input type="reset"></td></tr>
</table>
</form>
TomP
phpLister
 
Posts: 7
Joined: 4:40am, Fri 13 Feb, 2009

Re: Sharing lists between administrators

Postby TomP » 9:09pm, Sun 27 Dec, 2009

Just wondering, has anyone else tried playing with this?

Tom
TomP
phpLister
 
Posts: 7
Joined: 4:40am, Fri 13 Feb, 2009

Re: [mod] Sharing lists between administrators

Postby luvecor » 10:39am, Wed 03 Aug, 2011

i tried but without much success
luvecor
phpList newbie
 
Posts: 3
Joined: 10:14am, Mon 01 Aug, 2011

Re: [mod] Sharing lists between administrators

Postby Blisk » 6:49pm, Mon 07 Nov, 2011

I can use that too if someone manage to make a plugin or MOD
Blisk
phpLister
 
Posts: 10
Joined: 10:31am, Mon 07 Nov, 2011


Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: No registered users and 3 guests