Commit f516b06b authored by lphuberdeau's avatar lphuberdeau

[MOD] Add an option to include or not the inherited groups in mailing list,...

[MOD] Add an option to include or not the inherited groups in mailing list, and displaying the inherited groups in the list to make it more obvious
parent 1d496140
......@@ -1443,6 +1443,7 @@ installer/schema/20110308_rss_item_key_tiki.sql -text
installer/schema/20110317_attributes_increase_length_tiki.sql -text
installer/schema/20110411_banner_tiki.sql -text
installer/schema/20110413_blog_post_priv_default_value_tiki.sql -text
installer/schema/20110420_newsletter_optional_group_inclusion_tiki.sql -text
installer/schema/99999999_image_plugins_kill_tiki.php -text
installer/schema/index.php -text
installer/shell.php -text
......
......@@ -1556,6 +1556,7 @@ CREATE TABLE `tiki_newsletter_groups` (
`nlId` int(12) NOT NULL default '0',
`groupName` varchar(255) NOT NULL default '',
`code` varchar(32) default NULL,
`include_groups` char(1) DEFAULT 'y',
PRIMARY KEY (`nlId`,`groupName`)
) ENGINE=MyISAM;
......
ALTER TABLE `tiki_newsletter_groups` ADD COLUMN `include_groups` CHAR(1) DEFAULT 'y';
......@@ -144,10 +144,14 @@ class NlLib extends TikiLib
// Get list of the root groups (groups explicitely subscribed to this newsletter)
//
$groups = array();
$query = "select `groupName` from `tiki_newsletter_groups` where `nlId`=?";
$result = $this->query($query, array((int)$nlId));
while ( $res = $result->fetchRow() ) {
$groups = array_merge($groups, array($res["groupName"]), $userlib->get_including_groups($res["groupName"]));
$query = "select `groupName`,`include_groups` from `tiki_newsletter_groups` where `nlId`=?";
$result = $this->fetchAll($query, array((int)$nlId));
foreach ($result as $res) {
$groups[] = $res['groupName'];
if ($res['include_groups'] == 'y') {
$groups = array_merge($groups, $userlib->get_including_groups($res["groupName"], 'y'));
}
}
// If some groups are subscribed to this newsletter, get the list of users from those groups to be able to add them as subscribers
......@@ -503,12 +507,12 @@ class NlLib extends TikiLib
}
}
function add_group($nlId, $group) {
function add_group($nlId, $group, $include_groups = 'n') {
$query = "delete from `tiki_newsletter_groups` where `nlId`=? and `groupName`=?";
$result = $this->query($query,array((int)$nlId,$group), -1, -1, false);
$code = $this->genRandomString($group);
$query = "insert into `tiki_newsletter_groups`(`nlId`,`groupName`,`code`) values(?,?,?)";
$result = $this->query($query,array((int)$nlId,$group,$code));
$query = "insert into `tiki_newsletter_groups`(`nlId`,`groupName`,`code`,`include_groups`) values(?,?,?,?)";
$result = $this->query($query,array((int)$nlId,$group,$code,$include_groups));
}
function add_included($nlId, $includedId) {
......@@ -730,7 +734,12 @@ class NlLib extends TikiLib
$cant = $this->getOne($query_cant,$bindvars);
$ret = array();
$userlib = TikiLib::lib('user');
while ($res = $result->fetchRow()) {
$res['additional_groups'] = array();
if ($res['include_groups'] == 'y') {
$res['additional_groups'] = $userlib->get_including_groups($res["groupName"], 'y');
}
$ret[] = $res;
}
$retval = array();
......
......@@ -39,7 +39,17 @@
{cycle values="odd,even" print=false}
{section name=ix loop=$groups_g}
<tr class="{cycle}">
<td class="text">{$groups_g[ix].groupName|escape}</td>
<td class="text">
{$groups_g[ix].groupName|escape}
{if count($groups_g[ix].additional_groups)}
<div>
{tr}Groups included through inheritence:{/tr}
{foreach from=$groups_g[ix].additional_groups item=groupName}
{$groupName|escape}
{/foreach}
</div>
{/if}
</td>
<td class="action">
<a class="link" href="tiki-admin_newsletter_subscriptions.php?nlId={$nlId|urlencode}&amp;offset={$offset|urlencode}&amp;sort_mode={$sort_mode|urlencode}&amp;remove={$groups_g[ix].nlId|urlencode}&amp;group={$groups_g[ix].groupName|urlencode}">{icon _id='cross' alt="{tr}Remove{/tr}"}</a>
</td>
......@@ -321,8 +331,13 @@
<option value="{$groups[x]|escape}">{$groups[x]|escape}</option>
{/section}
</select>
<br />
<i>{tr}Including group, group users and emails will be refreshed at each newsletter sending{/tr}</i>
<label>
<input type="checkbox" name="include_groups" value="y"/>
{tr}Including group inheritence{/tr}
</label>
<div>
<i>{tr}Including group, group users and emails will be refreshed at each newsletter sending{/tr}</i>
</div>
</td>
</tr>
<tr>
......
......@@ -135,7 +135,7 @@ if (((isset($_REQUEST["addbatch"]) && isset($_FILES['batch_subscription'])) || (
if (isset($_REQUEST["addgroup"]) && isset($_REQUEST['group']) && $_REQUEST['group'] != "") {
check_ticket('admin-nl-subsriptions');
$nllib->add_group($_REQUEST["nlId"], $_REQUEST['group']);
$nllib->add_group($_REQUEST["nlId"], $_REQUEST['group'], isset($_REQUEST['include_groups']) ? 'y' : 'n');
}
if (isset($_REQUEST["addincluded"]) && isset($_REQUEST['included']) && $_REQUEST['included'] != "") {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment