Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit e993ba4

Browse files
authored
Merge pull request #53 from paustian/4.0
All features implemented
2 parents c230caf + 50a22b6 commit e993ba4

File tree

110 files changed

+3391
-5677
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+3391
-5677
lines changed
File renamed without changes.

lib/EZComments/Api/Admin.php renamed to Api/Admin.php

Lines changed: 39 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function getUsedModules()
2727

2828
$tables = DBUtil::getTables();
2929

30-
$table = $tables['EZComments'];
30+
$table = $tables['EZComments'];
3131
$column = $tables['EZComments_column'];
3232

3333
// TODO Port to DBUtil
@@ -49,7 +49,7 @@ public function getUsedModules()
4949
*
5050
* Used to clean up orphaned comments.
5151
*
52-
* @param $args[module] the module for which to delete for
52+
* @param $args [module] the module for which to delete for
5353
* @return boolean sucess status
5454
*/
5555
public function deleteall($args)
@@ -64,18 +64,18 @@ public function deleteall($args)
6464
}
6565

6666
// get tables
67-
$tables = DBUtil::getTables();
68-
$column = $tables['EZComments_column'];
67+
$tables = DBUtil::getTables();
68+
$column = $tables['EZComments_column'];
6969
// construct where clause and delete...
70-
$where = "WHERE $column[modname] = '$args[module]'";
70+
$where = "WHERE $column[modname] = '$args[module]'";
7171

72-
return DBUtil::deleteWhere('EZComments',$where);
72+
return DBUtil::deleteWhere('EZComments', $where);
7373
}
7474

7575
/**
7676
* Delete an item
7777
*
78-
* @param $args['id'] ID of the item
78+
* @param $args ['id'] ID of the item
7979
* @return bool true on success, false on failure
8080
*/
8181
public function delete($args)
@@ -94,10 +94,10 @@ public function delete($args)
9494

9595
// Security check
9696
$securityCheck = ModUtil::apiFunc('EZComments', 'user', 'checkPermission',
97-
array('module' => '',
98-
'objectid' => '',
99-
'commentid' => $args['id'],
100-
'level' => ACCESS_DELETE));
97+
array('module' => '',
98+
'objectid' => '',
99+
'commentid' => $args['id'],
100+
'level' => ACCESS_DELETE));
101101
if (!$securityCheck) {
102102
return LogUtil::registerPermissionError(ModUtil::url('EZComments', 'admin', 'main'));
103103
}
@@ -117,9 +117,9 @@ public function delete($args)
117117
/**
118118
* Update an item
119119
*
120-
* @param $args['id'] the ID of the item
121-
* @param $args['subject'] the new subject of the item
122-
* @param $args['comment'] the new text of the item
120+
* @param $args ['id'] the ID of the item
121+
* @param $args ['subject'] the new subject of the item
122+
* @param $args ['comment'] the new text of the item
123123
* @return bool true on success, false on failure
124124
*/
125125
public function update($args)
@@ -133,8 +133,8 @@ public function update($args)
133133
}
134134

135135
// optional arguments
136-
if (!isset($args['anonname'])) $args['anonname'] = '';
137-
if (!isset($args['anonmail'])) $args['anonmail'] = '';
136+
if (!isset($args['anonname'])) $args['anonname'] = '';
137+
if (!isset($args['anonmail'])) $args['anonmail'] = '';
138138
if (!isset($args['anonwebsite'])) $args['anonwebsite'] = '';
139139

140140
// Get the item
@@ -146,10 +146,10 @@ public function update($args)
146146

147147
// Security check.
148148
$securityCheck = ModUtil::apiFunc('EZComments', 'user', 'checkPermission',
149-
array('module' => '',
150-
'objectid' => '',
151-
'commentid' => (int)$args['id'],
152-
'level' => ACCESS_EDIT));
149+
array('module' => '',
150+
'objectid' => '',
151+
'commentid' => (int)$args['id'],
152+
'level' => ACCESS_EDIT));
153153

154154
if (!$securityCheck) {
155155
return LogUtil::registerPermissionError(ModUtil::url('EZComments', 'admin', 'main'));
@@ -171,8 +171,8 @@ public function update($args)
171171
/**
172172
* Delete an item
173173
*
174-
* @param $args['purgerejected'] Purge all rejected comments
175-
* @param $args['purgepending'] Purge all pending comments
174+
* @param $args ['purgerejected'] Purge all rejected comments
175+
* @param $args ['purgepending'] Purge all pending comments
176176
* @return bool true on success, false on failure
177177
*/
178178
public function purge($args)
@@ -191,8 +191,8 @@ public function purge($args)
191191
}
192192

193193
// Get datbase setup
194-
$tables = DBUtil::getTables();
195-
$column = $tables['EZComments_column'];
194+
$tables = DBUtil::getTables();
195+
$column = $tables['EZComments_column'];
196196

197197
if ((bool)$purgerejected) {
198198
$where = "WHERE $column[status] = '2'";
@@ -215,15 +215,15 @@ public function purge($args)
215215
/**
216216
* Update an item status
217217
*
218-
* @param $args['id'] the ID of the item
219-
* @param $args['status'] the new status of the item
218+
* @param $args ['id'] the ID of the item
219+
* @param $args ['status'] the new status of the item
220220
* @return bool true on success, false on failure
221221
*/
222222
public function updatestatus($args)
223223
{
224224
// get arguments
225-
$id = $args['id'];
226-
$status = $args['status'];
225+
$id = $args['id'];
226+
$status = $args['status'];
227227

228228
// Argument check
229229
if (isset($id) && !is_numeric($id) && isset($status) && !is_numeric($status)) {
@@ -239,10 +239,10 @@ public function updatestatus($args)
239239

240240
// Security check.
241241
$securityCheck = ModUtil::apiFunc('EZComments', 'user', 'checkPermission',
242-
array('module' => '',
243-
'objectid' => '',
244-
'commentid' => $id,
245-
'level' => ACCESS_EDIT));
242+
array('module' => '',
243+
'objectid' => '',
244+
'commentid' => $id,
245+
'level' => ACCESS_EDIT));
246246

247247
if (!$securityCheck) {
248248
return LogUtil::registerPermissionError(ModUtil::url('EZComments', 'admin', 'main'));
@@ -273,12 +273,12 @@ public function updatestatus($args)
273273
$renderer->assign('modifyurl', ModUtil::url('EZComments', 'user', 'modify', array('id' => $item['id']), null, null, true));
274274

275275
ModUtil::apiFunc('Mailer', 'user', 'sendmessage',
276-
array('toaddress' => $owner['email'],
277-
'toname' => $owner['uname'],
278-
'fromaddress' => System::getVar('adminmail'),
279-
'fromname' => System::getVar('sitename'),
280-
'subject' => $this->__('A new comment was entered'),
281-
'body' => $renderer->fetch('ezcomments_mail_newcomment.tpl')));
276+
array('toaddress' => $owner['email'],
277+
'toname' => $owner['uname'],
278+
'fromaddress' => System::getVar('adminmail'),
279+
'fromname' => System::getVar('sitename'),
280+
'subject' => $this->__('A new comment was entered'),
281+
'body' => $renderer->fetch('ezcomments_mail_newcomment.tpl')));
282282
}
283283
}
284284
return true;
@@ -297,40 +297,4 @@ public function countitems($args)
297297
{
298298
return ModUtil::apiFunc('EZComments', 'user', 'countitems', $args);
299299
}
300-
301-
/**
302-
* Get available admin panel links
303-
*
304-
* @author Mark West
305-
* @return array array of admin links
306-
*/
307-
public function getLinks()
308-
{
309-
$links = array();
310-
311-
if (SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
312-
$links[] = array('url' => ModUtil::url('EZComments', 'admin', 'main'),
313-
'text' => $this->__('View comments'),
314-
'class' => 'z-icon-es-view');
315-
$links[] = array('url' => ModUtil::url('EZComments', 'admin', 'stats'),
316-
'text' => $this->__('Comment statistics'),
317-
'class' => 'z-icon-es-cubes');
318-
$links[] = array('url' => ModUtil::url('EZComments', 'admin', 'modifyconfig'),
319-
'text' => $this->__('Settings'),
320-
'class' => 'z-icon-es-config',
321-
'links' => array(
322-
array('url' => ModUtil::url('EZComments', 'admin', 'modifyconfig'),
323-
'text' => $this->__('Settings')),
324-
array('url' => ModUtil::url('EZComments', 'admin', 'cleanup'),
325-
'text' => $this->__('Delete orphaned comments')),
326-
array('url' => ModUtil::url('EZComments', 'admin', 'migrate'),
327-
'text' => $this->__('Migrate comments')),
328-
array('url' => ModUtil::url('EZComments', 'admin', 'purge'),
329-
'text' => $this->__('Purge comments')),
330-
array('url' => ModUtil::url('EZComments', 'admin', 'applyrules'),
331-
'text' => $this->__('Re-apply moderation rules'))
332-
));
333-
}
334-
return $links;
335-
}
336-
}
300+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

Block/EZCommentsBlock.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* EZComments
4+
*
5+
* @copyright (C) EZComments Development Team
6+
* @link https://github.com/zikula-modules/EZComments
7+
* @license See license.txt
8+
*/
9+
namespace Zikula\EZCommentsModule\Block;
10+
11+
use Zikula\BlocksModule\AbstractBlockHandler;
12+
use Zikula\EZCommentsModule\Block\Form\EZCommentsBlockType;
13+
14+
class EZCommentsBlock extends AbstractBlockHandler
15+
{
16+
/**
17+
* display block
18+
*
19+
* @param array $blockinfo a blockinfo structure
20+
* @return output the rendered bock
21+
*/
22+
public function display(array $properties)
23+
{
24+
if (!$this->hasPermission('ZikulaEZComments:EZCommentsBlock:', $properties['bid'] . '::', ACCESS_OVERVIEW)) {
25+
return '';
26+
}
27+
28+
$currentUserApi = $this->get('zikula_users_module.current_user');
29+
if (!$currentUserApi->isLoggedIn()) {
30+
return '';
31+
}
32+
33+
// set default values for all params which are not properly set
34+
$defaults = $this->getDefaults();
35+
$properties = array_merge($defaults, $properties);
36+
37+
$ezCommentsRepository = $this->get('zikula_ezcomments_module.ezcomments_module_repository');
38+
39+
//return the desired items based upon how the properties have been set
40+
$items = $ezCommentsRepository->getLatestComments($properties);
41+
42+
return $this->renderView("@ZikulaEZCommentsModule\Block\list_latest_comments.html.twig",
43+
[ 'items' => $items,
44+
'days' => $properties['numdays'],
45+
'showdate' => $properties['showdate'] == 'yes',
46+
'showuser' => $properties['showuser'] == 'yes',
47+
'linksuer' => $properties['linkuser'] == 'yes']);
48+
}
49+
50+
public function getFormClassName(){
51+
return EZCommentsBlockType::class;
52+
}
53+
54+
public function getFormTemplate()
55+
{
56+
return '@ZikulaEZCommentsModule/Block/options_modify.html.twig';
57+
}
58+
59+
public function getDefaults(){
60+
return [
61+
'numcomments' => 5,
62+
'numdays' => 14,
63+
'showdate' => 'yes',
64+
'showuser' => 'yes',
65+
'linkuser' => 'no'
66+
];
67+
}
68+
69+
}

0 commit comments

Comments
 (0)