forked from services/mlmmj-light-web-ecg
Added display of list owners and list descriptions on index page, Added save function for list description
This commit is contained in:
38
index.php
38
index.php
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
# Scan loading time
|
||||
$time_start = microtime(true);
|
||||
|
||||
require("init.php");
|
||||
|
||||
if (!isset($_SESSION["auth"]) || $_SESSION["auth"] != 1)
|
||||
@@ -27,16 +30,40 @@ if (isset($lists))
|
||||
}
|
||||
|
||||
$lists_new = [];
|
||||
|
||||
# Iterate through all lists
|
||||
foreach($lists as $list)
|
||||
{
|
||||
# If list is in array of owned lists
|
||||
if (!in_array($list, $_SESSION["array_lists_owned"]))
|
||||
{
|
||||
$lists_new[$list] = 0;
|
||||
$lists_new[$list]["iamowner"] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lists_new[$list] = 1;
|
||||
$lists_new[$list]["iamowner"] = 1;
|
||||
}
|
||||
|
||||
# Get the owners of the list and put them into the array
|
||||
$owners = explode("\n", trim(shell_exec("/usr/bin/mlmmj-list -o -L $lists_path/$domain/$list")));
|
||||
$lists_new[$list]["owners"] = $owners;
|
||||
|
||||
# Check whether there is a listdescription file
|
||||
if (file_exists("$lists_path/$domain/$list/control/listdescription") && @file_get_contents("$lists_path/$domain/$list/control/listdescription") != "")
|
||||
{
|
||||
// Get list description
|
||||
$listdescription = file_get_contents("$lists_path/$domain/$list/control/listdescription");
|
||||
// Remove trailing empty symbols
|
||||
$listdescription = trim($listdescription);
|
||||
}
|
||||
else
|
||||
{
|
||||
# Set listdescription to none
|
||||
$listdescription = "none";
|
||||
}
|
||||
|
||||
# Add the listdescription to the array
|
||||
$lists_new[$list]["description"] = $listdescription;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -44,11 +71,18 @@ else
|
||||
$lists = NULL;
|
||||
}
|
||||
|
||||
# Scan loading time
|
||||
$time_end = microtime(true);
|
||||
|
||||
# Calculate loading time
|
||||
$loadingtime = round(($time_end - $time_start), 2);
|
||||
|
||||
$smarty->assign("headline", $headline);
|
||||
$smarty->assign("web_url", $web_url);
|
||||
$smarty->assign("lists", $lists_new);
|
||||
$smarty->assign("domain", $domain);
|
||||
$smarty->assign("username", $_SESSION["username"]);
|
||||
$smarty->assign("loadingtime", $loadingtime);
|
||||
$smarty->display("index.tpl");
|
||||
|
||||
?>
|
||||
|
||||
1
info.svg
Normal file
1
info.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" enable-background="new 0 0 64 64"><path d="m32 2c-16.568 0-30 13.432-30 30s13.432 30 30 30 30-13.432 30-30-13.432-30-30-30m5 49.75h-10v-24h10v24m-5-29.5c-2.761 0-5-2.238-5-5s2.239-5 5-5c2.762 0 5 2.238 5 5s-2.238 5-5 5" fill="#dddddd"/></svg>
|
||||
|
After Width: | Height: | Size: 303 B |
@@ -58,13 +58,19 @@
|
||||
</tr>
|
||||
|
||||
{foreach $lists as $list}
|
||||
{if $list == 1}
|
||||
{if $list.iamowner == 1}
|
||||
<tr>
|
||||
<td>
|
||||
✓
|
||||
</td>
|
||||
<td>
|
||||
<a href="edit_list.php?list_name={$list@key}">{$list@key}</a>
|
||||
<div class="tooltip">
|
||||
<img src="info.svg" width=15 height=15>
|
||||
<span class="help_add_list">
|
||||
<strong>Description</strong><br />{$list.description}<br /><br /><strong>List owner(s)</strong><br />{foreach $list.owners as $owner}{$owner}<br />{/foreach}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
@@ -94,18 +100,26 @@
|
||||
</tr>
|
||||
|
||||
{foreach $lists as $list}
|
||||
{if $list == 0}
|
||||
{if $list.iamowner == 0}
|
||||
<tr>
|
||||
<td>
|
||||
✗
|
||||
</td>
|
||||
<td>
|
||||
{$list@key}
|
||||
<div class="tooltip">
|
||||
<img src="info.svg" width=15 height=15>
|
||||
<span class="help_add_list">
|
||||
<strong>Description</strong><br />{$list.description}<br /><br /><strong>List owner(s)</strong><br />{foreach $list.owners as $owner}{$owner}<br />{/foreach}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</table>
|
||||
<br />
|
||||
<span>Loading time: {$loadingtime} seconds</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -19,6 +19,7 @@ function trim_array($arr)
|
||||
|
||||
$list_name = isset( $_POST["list_name"] ) ? $_POST["list_name"] : NULL;
|
||||
$prefix = isset ( $_POST["prefix"] ) ? $_POST["prefix"] : NULL;
|
||||
$listdescription = isset ( $_POST["listdescription"] ) ? $_POST["listdescription"] : NULL;
|
||||
$new_subscribers = isset ( $_POST["subscribers"] ) ? $_POST["subscribers"] : NULL;
|
||||
$moderators = isset ( $_POST["moderators"] ) ? $_POST["moderators"] : NULL;
|
||||
|
||||
@@ -158,11 +159,18 @@ if ($moderators !== NULL)
|
||||
}
|
||||
}
|
||||
|
||||
# Add prefix to the respective file
|
||||
if ($prefix !== NULL)
|
||||
{
|
||||
file_put_contents("$lists_path/$domain/$list_name/control/prefix", "$prefix");
|
||||
}
|
||||
|
||||
# Add listdescription to the respective file
|
||||
if ($listdescription !== NULL)
|
||||
{
|
||||
file_put_contents("$lists_path/$domain/$list_name/control/listdescription", "$listdescription");
|
||||
}
|
||||
|
||||
# The following code section is for audit log only
|
||||
|
||||
# -------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user