Add option to automatically connect family members
This commit is contained in:
parent
2975a830fc
commit
64baf4332f
3 changed files with 118 additions and 78 deletions
|
@ -62,6 +62,12 @@ function getGlobalOptions() {
|
|||
*/
|
||||
"newuser_default_family" => 1,
|
||||
|
||||
/* Automatically make family members shoppers for each other
|
||||
0 = manual connections
|
||||
1 = auto connect family members
|
||||
*/
|
||||
"auto_connect_family_members" => 1,
|
||||
|
||||
/* Whether or not whom an item is reserved/bought by is hidden. */
|
||||
"anonymous_purchasing" => 0,
|
||||
|
||||
|
|
114
src/index.php
114
src/index.php
|
@ -223,49 +223,81 @@ while ($row = $stmt->fetch()) {
|
|||
$ranks[] = $row;
|
||||
}
|
||||
|
||||
$stmt = $smarty->dbh()->prepare("SELECT u.userid, u.fullname, u.comment, u.list_stamp, ISNULL(sub.subscriber) AS is_unsubscribed, COUNT(i.itemid) AS itemcount " .
|
||||
"FROM {$opt["table_prefix"]}shoppers s " .
|
||||
"INNER JOIN {$opt["table_prefix"]}users u ON u.userid = s.mayshopfor " .
|
||||
"LEFT OUTER JOIN {$opt["table_prefix"]}items i ON u.userid = i.userid " .
|
||||
"LEFT OUTER JOIN {$opt["table_prefix"]}subscriptions sub ON sub.publisher = u.userid AND sub.subscriber = ? " .
|
||||
"WHERE s.shopper = ? " .
|
||||
"AND pending = 0 " .
|
||||
"GROUP BY u.userid, u.fullname, u.list_stamp " .
|
||||
"ORDER BY u.fullname");
|
||||
$stmt->bindParam(1, $userid, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $userid, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$shoppees = array();
|
||||
while ($row = $stmt->fetch()) {
|
||||
if ($row['list_stamp'] == 0) {
|
||||
$row['list_stamp'] = '-';
|
||||
if (!$opt["auto_connect_family_members"]) {
|
||||
# When family members are not automatic shoppers
|
||||
$stmt = $smarty->dbh()->prepare("SELECT u.userid, u.fullname, u.comment, u.list_stamp, ISNULL(sub.subscriber) AS is_unsubscribed, COUNT(i.itemid) AS itemcount " .
|
||||
"FROM {$opt["table_prefix"]}shoppers s " .
|
||||
"INNER JOIN {$opt["table_prefix"]}users u ON u.userid = s.mayshopfor " .
|
||||
"LEFT OUTER JOIN {$opt["table_prefix"]}items i ON u.userid = i.userid " .
|
||||
"LEFT OUTER JOIN {$opt["table_prefix"]}subscriptions sub ON sub.publisher = u.userid AND sub.subscriber = ? " .
|
||||
"WHERE s.shopper = ? " .
|
||||
"AND pending = 0 " .
|
||||
"GROUP BY u.userid, u.fullname, u.list_stamp " .
|
||||
"ORDER BY u.fullname");
|
||||
$stmt->bindParam(1, $userid, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $userid, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$shoppees = array();
|
||||
while ($row = $stmt->fetch()) {
|
||||
if ($row['list_stamp'] == 0) {
|
||||
$row['list_stamp'] = '-';
|
||||
}
|
||||
else {
|
||||
$listStampDate = new DateTime($row['list_stamp']);
|
||||
$row['list_stamp'] = $listStampDate->format($opt["date_format"]);
|
||||
}
|
||||
$shoppees[] = $row;
|
||||
}
|
||||
else {
|
||||
$listStampDate = new DateTime($row['list_stamp']);
|
||||
$row['list_stamp'] = $listStampDate->format($opt["date_format"]);
|
||||
}
|
||||
$shoppees[] = $row;
|
||||
}
|
||||
|
||||
$stmt = $smarty->dbh()->prepare("SELECT DISTINCT u.userid, u.fullname, s.pending " .
|
||||
"FROM {$opt["table_prefix"]}memberships mymem " .
|
||||
"INNER JOIN {$opt["table_prefix"]}memberships others " .
|
||||
"ON others.familyid = mymem.familyid AND others.userid <> ? " .
|
||||
"INNER JOIN {$opt["table_prefix"]}users u " .
|
||||
"ON u.userid = others.userid " .
|
||||
"LEFT OUTER JOIN {$opt["table_prefix"]}shoppers s " .
|
||||
"ON s.mayshopfor = others.userid AND s.shopper = ? " .
|
||||
"WHERE mymem.userid = ? " .
|
||||
"AND (s.pending IS NULL OR s.pending = 1) " .
|
||||
"AND u.approved = 1 " .
|
||||
"ORDER BY u.fullname");
|
||||
$stmt->bindParam(1, $userid, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $userid, PDO::PARAM_INT);
|
||||
$stmt->bindParam(3, $userid, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$prospects = array();
|
||||
while ($row = $stmt->fetch()) {
|
||||
$prospects[] = $row;
|
||||
$stmt = $smarty->dbh()->prepare("SELECT DISTINCT u.userid, u.fullname, s.pending " .
|
||||
"FROM {$opt["table_prefix"]}memberships mymem " .
|
||||
"INNER JOIN {$opt["table_prefix"]}memberships others " .
|
||||
"ON others.familyid = mymem.familyid AND others.userid <> ? " .
|
||||
"INNER JOIN {$opt["table_prefix"]}users u " .
|
||||
"ON u.userid = others.userid " .
|
||||
"LEFT OUTER JOIN {$opt["table_prefix"]}shoppers s " .
|
||||
"ON s.mayshopfor = others.userid AND s.shopper = ? " .
|
||||
"WHERE mymem.userid = ? " .
|
||||
"AND (s.pending IS NULL OR s.pending = 1) " .
|
||||
"AND u.approved = 1 " .
|
||||
"ORDER BY u.fullname");
|
||||
$stmt->bindParam(1, $userid, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $userid, PDO::PARAM_INT);
|
||||
$stmt->bindParam(3, $userid, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$prospects = array();
|
||||
while ($row = $stmt->fetch()) {
|
||||
$prospects[] = $row;
|
||||
}
|
||||
} else {
|
||||
# When family members are automatically connected as shoppers
|
||||
$stmt = $smarty->dbh()->prepare("SELECT u.userid, u.fullname, u.comment, u.list_stamp, ISNULL(sub.subscriber) AS is_unsubscribed, COUNT(i.itemid) AS itemcount " .
|
||||
"FROM {$opt["table_prefix"]}users u " .
|
||||
"JOIN {$opt["table_prefix"]}memberships m ON u.userid = m.userid " .
|
||||
"LEFT JOIN {$opt["table_prefix"]}items i ON u.userid = i.userid " .
|
||||
"LEFT JOIN {$opt["table_prefix"]}subscriptions sub ON sub.publisher = u.userid AND sub.subscriber = ? " .
|
||||
"WHERE m.familyid IN ( " .
|
||||
"SELECT familyid " .
|
||||
"FROM {$opt["table_prefix"]}memberships " .
|
||||
"WHERE userid = ? " .
|
||||
") " .
|
||||
"AND u.userid != ? " .
|
||||
"GROUP BY u.userid, u.fullname");
|
||||
$stmt->bindParam(1, $userid, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $userid, PDO::PARAM_INT);
|
||||
$stmt->bindParam(3, $userid, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$shoppees = array();
|
||||
while ($row = $stmt->fetch()) {
|
||||
if ($row['list_stamp'] == 0) {
|
||||
$row['list_stamp'] = '-';
|
||||
}
|
||||
else {
|
||||
$listStampDate = new DateTime($row['list_stamp']);
|
||||
$row['list_stamp'] = $listStampDate->format($opt["date_format"]);
|
||||
}
|
||||
$shoppees[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = $smarty->dbh()->prepare("SELECT messageid, u.fullname, message, created " .
|
||||
|
|
|
@ -433,43 +433,45 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
</div> <!-- card body -->
|
||||
</div> <!-- card -->
|
||||
</div> <!-- col -->
|
||||
<div class="col mb-3">
|
||||
<div class="card h-100">
|
||||
<div class="card-header">Available People To Shopping For</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="colheader">Name</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$prospects item=row}
|
||||
<tr>
|
||||
<td>{$row.fullname|escape:'htmlall'}</td>
|
||||
<td align="right" nowrap>
|
||||
{if $row.pending}
|
||||
<a href="index.php?action=cancel&shopfor={$row.userid}"><img class="theme-image" data-light-src="images/delete-light.png" data-dark-src="images/delete-dark.png" src="images/delete-light.png" border="0" alt="Cancel" title="Cancel" /></a>
|
||||
{else}
|
||||
<a href="index.php?action=request&shopfor={$row.userid}">
|
||||
{if $opt.shop_requires_approval}
|
||||
<img class="theme-image" data-light-src="images/cloud-add-light.png" data-dark-src="images/cloud-add-dark.png" src="images/cloud-add-light.png" border="0" alt="Request" title="Request" />
|
||||
{else}
|
||||
<img class="theme-image" data-light-src="images/cloud-add-light.png" data-dark-src="images/cloud-add-dark.png" src="images/cloud-add-light.png" border="0" alt="Add" title="Add" />
|
||||
{/if}
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- table-responsive -->
|
||||
</div> <!-- card body -->
|
||||
</div> <!-- card -->
|
||||
</div> <!-- col -->
|
||||
{if !$opt.auto_connect_family_members}
|
||||
<div class="col mb-3">
|
||||
<div class="card h-100">
|
||||
<div class="card-header">Available People To Shopping For</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="colheader">Name</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$prospects item=row}
|
||||
<tr>
|
||||
<td>{$row.fullname|escape:'htmlall'}</td>
|
||||
<td align="right" nowrap>
|
||||
{if $row.pending}
|
||||
<a href="index.php?action=cancel&shopfor={$row.userid}"><img class="theme-image" data-light-src="images/delete-light.png" data-dark-src="images/delete-dark.png" src="images/delete-light.png" border="0" alt="Cancel" title="Cancel" /></a>
|
||||
{else}
|
||||
<a href="index.php?action=request&shopfor={$row.userid}">
|
||||
{if $opt.shop_requires_approval}
|
||||
<img class="theme-image" data-light-src="images/cloud-add-light.png" data-dark-src="images/cloud-add-dark.png" src="images/cloud-add-light.png" border="0" alt="Request" title="Request" />
|
||||
{else}
|
||||
<img class="theme-image" data-light-src="images/cloud-add-light.png" data-dark-src="images/cloud-add-dark.png" src="images/cloud-add-light.png" border="0" alt="Add" title="Add" />
|
||||
{/if}
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- table-responsive -->
|
||||
</div> <!-- card body -->
|
||||
</div> <!-- card -->
|
||||
</div> <!-- col -->
|
||||
{/if}
|
||||
<div class="col mb-3">
|
||||
<div class="card h-100">
|
||||
<div class="card-header">Messages</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue