Skip to content

Commit

Permalink
add ability to delete multiple expired news items at once
Browse files Browse the repository at this point in the history
  • Loading branch information
dleffler committed Jan 7, 2017
1 parent 1cfd561 commit 417bf79
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 44 deletions.
1 change: 1 addition & 0 deletions changes-v241.md
Expand Up @@ -23,6 +23,7 @@ Version 2.4.1 - Specific changes from previous version
#### v240patch5 adds these features to v240 previous releases:
- updates/adds/exposes support for mPDF v6.1 and DOMPDF v0.7.0, fixes html2pdf support
- adds separate forms showall_portfolio custom view configuration in addition to show item custom view
- adds ability to delete multiple expired news items at once

#### v240patch5 fixes these issues in v240 previous releases:
- regression fix (v240) `<meta charset...>` tag wasn't properly closed with quote
Expand Down
13 changes: 13 additions & 0 deletions framework/modules/news/controllers/newsController.php
Expand Up @@ -195,6 +195,7 @@ public function showUnpublished() {
'action'=>$this->params['action'],
'src'=>$this->loc->src,
'columns'=>array(
'actupon' => true,
gt('Title')=>'title',
gt('Published On')=>'publish',
gt('Status')=>'unpublish'
Expand All @@ -210,6 +211,18 @@ public function showExpired() {
redirect_to(array('controller'=>'news', 'action'=>'showUnpublished','src'=>$this->params['src']));
}

public function delete_expired() {
if (!empty($this->params['act-upon'])) {
foreach ($this->params['act-upon'] as $item) {
$news = new news(intval($item));
if ($news) {
$news->delete();
}
}
}
expHistory::back();
}

// public function configure() {
// parent::configure();
// assign_to_template(array('sortopts'=>$this->sortopts));
Expand Down
92 changes: 48 additions & 44 deletions framework/modules/news/views/news/showUnpublished.tpl
Expand Up @@ -21,50 +21,54 @@
{if !($config.hidemoduletitle xor $smarty.const.INVERT_HIDE_TITLE)}<{$config.heading_level|default:'h1'}>{$moduletitle} - {"Expired and Unpublished News"|gettext}</{$config.heading_level|default:'h1'}>{/if}
{pagelinks paginate=$page top=1}
{$myloc=serialize($__loc)}
<table id="prods" class="exp-skin-table" width="95%">
<thead>
<tr>
{$page->header_columns}
<th>{'Actions'|gettext}</th>
</tr>
</thead>
<tbody>
{foreach from=$page->records item=item name=listings}
<tr class="{cycle values="odd,even"}">
<td><a href="{link controller=news action=show id=$item->id}" title="{$item->body|summarize:"html":"para"}">{$item->title}</a></td>
<td>{$item->publish_date|format_date:"%B %e, %Y"}</td>
<td>
{if $item->unpublish == 0}
{'Unpublished'|gettext}
{else}
{'Expired'|gettext} - {$item->unpublish|format_date:"%B %e, %Y"}
{/if}
</td>
<td>
{permissions}
<div class="item-actions">
{if $permissions.edit || ($permissions.create && $item->poster == $user->id)}
{if $myloc != $item->location_data}
{if $permissions.manage}
{icon action=merge id=$item->id title="Merge Aggregated Content"|gettext}
{else}
{icon img='arrow_merge.png' title="Merged Content"|gettext}
{/if}
{/if}
{icon action=edit record=$item}
{icon action=copy record=$item}
{form action=delete_expired}
<table id="prods" class="exp-skin-table" width="95%">
<thead>
<tr>
{$page->header_columns}
<th>{'Actions'|gettext}</th>
</tr>
</thead>
<tbody>
{foreach from=$page->records item=item name=listings}
<tr class="{cycle values="odd,even"}">
<td><input type=checkbox name=act-upon[] value={$item->id} /></td>
<td><a href="{link controller=news action=show id=$item->id}" title="{$item->body|summarize:"html":"para"}">{$item->title}</a></td>
<td>{$item->publish_date|format_date:"%B %e, %Y"}</td>
<td>
{if $item->unpublish == 0}
{'Unpublished'|gettext}
{else}
{'Expired'|gettext} - {$item->unpublish|format_date:"%B %e, %Y"}
{/if}
{if $permissions.delete || ($permissions.create && $item->poster == $user->id)}
{icon action=delete record=$item}
{/if}
</div>
{/permissions}
</td>
</tr>
{foreachelse}
<td colspan=3>{'There is no expired news'|gettext}.</td>
{/foreach}
</tbody>
</table>
</td>
<td>
{permissions}
<div class="item-actions">
{if $permissions.edit || ($permissions.create && $item->poster == $user->id)}
{if $myloc != $item->location_data}
{if $permissions.manage}
{icon action=merge id=$item->id title="Merge Aggregated Content"|gettext}
{else}
{icon img='arrow_merge.png' title="Merged Content"|gettext}
{/if}
{/if}
{icon action=edit record=$item}
{icon action=copy record=$item}
{/if}
{if $permissions.delete || ($permissions.create && $item->poster == $user->id)}
{icon action=delete record=$item}
{/if}
</div>
{/permissions}
</td>
</tr>
{foreachelse}
<td colspan=3>{'There is no expired news'|gettext}.</td>
{/foreach}
</tbody>
</table>
{control class=delete type=buttongroup submit="Delete Selected Items"|gettext color=red onclick="return confirm('"|cat:("Are you sure you want to delete these items?"|gettext)|cat:"');"}
{/form}
{pagelinks paginate=$page bottom=1}
</div>

0 comments on commit 417bf79

Please sign in to comment.