Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button to subscribe users to categories selected #6163

Merged
merged 1 commit into from Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/administrator/components/com_kunena/controllers/users.php
Expand Up @@ -1048,6 +1048,59 @@ public function removetopicsubscriptions()
$this->setRedirect(KunenaRoute::_($this->baseurl, false));
}

/**
* Subscribe users to categories selected
*
* @since 5.1.8
*
* @return void
* @throws Exception
* @since Kunena
* @throws null
*/
public function subscribeuserstocategories()
{
if (!Session::checkToken('post'))
{
$this->app->enqueueMessage(Text::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->setRedirect(KunenaRoute::_($this->baseurl, false));

return;
}

$userids = $this->app->input->get('cid', array(), 'post', 'array');
$userids = ArrayHelper::toInteger($userids);
$catids = $this->app->input->get('catid', array(), 'post', 'array');
$catids = ArrayHelper::toInteger($catids);

if (empty($userids))
{
$this->app->enqueueMessage(Text::_('COM_KUNENA_USERS_BATCH_NO_USERS_SELECTED'), 'error');
$this->setRedirect(KunenaRoute::_($this->baseurl, false));

return;
}

if (empty($catids))
{
$this->app->enqueueMessage(Text::_('COM_KUNENA_USERS_BATCH_NO_CATEGORIES_SELECTED'), 'error');
$this->setRedirect(KunenaRoute::_($this->baseurl, false));

return;
}
$categories = KunenaForumCategoryHelper::getCategories($catids);
foreach ($userids as $userid)
{
foreach ($categories as $category)
{
$category->subscribe(true, $userid);
}
}

$this->app->enqueueMessage(Text::_('COM_KUNENA_USERS_ADD_CATEGORIES_SUBSCRIPTIONS_DONE'));
$this->setRedirect(KunenaRoute::_($this->baseurl, false));
}

/**
* Clean social items
*
Expand Down
Expand Up @@ -167,6 +167,7 @@ COM_KUNENA_USERS_SET_MODERATORS_DONE = "The users have been added as moderators.
COM_KUNENA_USER_BANNED_DONE = "The user has been banned successfully"
COM_KUNENA_USER_DELETE_KUNENA_USER_TABLE_FAILED = "The user %s can't be deleted from Kunena user table"
COM_KUNENA_USER_DELETE_JOOMLA_USER_TABLE_FAILED = "The user %s can't be deleted from Joomla user table"
COM_KUNENA_USERS_ADD_CATEGORIES_SUBSCRIPTIONS_DONE = "The subscriptions to categories for users has been added"

; JROOT/administrator/components/com_kunena/controllers/logs.php

Expand Down
Expand Up @@ -1142,6 +1142,7 @@ COM_KUNENA_LOGOUT = "Logout"
COM_KUNENA_MOVE_USERMESSAGES = "Move Messages"
COM_KUNENA_USER_DELETE = "Delete User(s)"
COM_KUNENA_VIEW_USERS_TOOLBAR_ASSIGN_MODERATORS = "Assign Moderator(s)"
COM_KUNENA_VIEW_USERS_TOOLBAR_SUBSCRIBE_USERS_CATEGORIES = "Add subscriptions to categories"

; JROOT/administrator/components/com_kunena/views/tools/tmpl/diagnostics.php

Expand Down
Expand Up @@ -323,6 +323,7 @@ class="element-invisible"><?php echo Text::_('COM_KUNENA_FIELD_LABEL_ALL'); ?></
<?php endif; ?>
</tbody>
</table>
<?php echo $this->loadTemplateFile('subscribecatsusers'); ?>
<?php echo $this->loadTemplateFile('moderators'); ?>
</form>
<div class="clearfix"></div>
Expand Down
@@ -0,0 +1,40 @@
<?php
/**
* Kunena Component
* @package Kunena.Administrator.Users
* @subpackage Users
*
* @copyright Copyright (C) 2008 - 2018 Kunena Team. All rights reserved.
* @license https://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;

?>
<div class="modal hide fade" id="subscribecatsusersModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" role="presentation" class="close" data-dismiss="modal">x</button>
<h3><?php echo Text::_('COM_KUNENA_BATCH_USERS_OPTIONS'); ?></h3>
</div>
<div class="modal-body span11">
<p><?php echo Text::_('COM_KUNENA_BATCH_USERS_TIP'); ?></p>
<div class="control-group">
<div class="controls">
<?php echo $this->modcatlist; ?>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn" type="button" onclick="document.id('catid').value='';" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</button>
<button class="btn btn-primary" type="submit" onclick="Joomla.submitbutton('subscribeuserstocategories');">
<?php echo Text::_('JSUBMIT'); ?>
</button>
</div>
</div>
</div>
</div>
Expand Up @@ -324,6 +324,7 @@ class="element-invisible"><?php echo Text::_('COM_KUNENA_FIELD_LABEL_ALL'); ?></
<?php endif; ?>
</tbody>
</table>
<?php echo $this->loadTemplateFile('subscribecatsusers'); ?>
<?php echo $this->loadTemplateFile('moderators'); ?>
</form>
<div class="clearfix"></div>
Expand Down
@@ -0,0 +1,40 @@
<?php
/**
* Kunena Component
* @package Kunena.Administrator.Users
* @subpackage Users
*
* @copyright Copyright (C) 2008 - 2018 Kunena Team. All rights reserved.
* @license https://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;

?>
<div class="modal hide fade" id="subscribecatsusersModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" role="presentation" class="close" data-dismiss="modal">x</button>
<h3><?php echo Text::_('COM_KUNENA_BATCH_USERS_OPTIONS'); ?></h3>
</div>
<div class="modal-body span11">
<p><?php echo Text::_('COM_KUNENA_BATCH_USERS_TIP'); ?></p>
<div class="control-group">
<div class="controls">
<?php echo $this->modcatlist; ?>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn" type="button" onclick="document.id('catid').value='';" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</button>
<button class="btn btn-primary" type="submit" onclick="Joomla.submitbutton('subscribeuserstocategories');">
<?php echo Text::_('JSUBMIT'); ?>
</button>
</div>
</div>
</div>
</div>
16 changes: 16 additions & 0 deletions src/administrator/components/com_kunena/views/users/view.html.php
Expand Up @@ -99,6 +99,22 @@ protected function setToolbar()
JToolbarHelper::spacer();
JToolbarHelper::custom('removetopicsubscriptions', 'delete.png', 'delete.png', 'COM_KUNENA_REMOVE_TOPICSUBSCRIPTIONS');
JToolbarHelper::spacer();

if (version_compare(JVERSION, '4.0', '>'))
{
HTMLHelper::_('bootstrap.renderModal', 'subscribecatsusersModal');
}
else
{
HTMLHelper::_('bootstrap.modal', 'subscribecatsusersModal');
}

$title = Text::_('COM_KUNENA_VIEW_USERS_TOOLBAR_SUBSCRIBE_USERS_CATEGORIES');
$dhtml = "<button data-toggle=\"modal\" data-target=\"#subscribecatsusersModal\" class=\"btn btn-small\">
<i class=\"icon-checkbox-partial\" title=\"$title\"> </i>
$title</button>";
$bar->appendButton('Custom', $dhtml, 'batch');

$help_url = 'https://docs.kunena.org/en/manual/backend/users';
JToolbarHelper::help('COM_KUNENA', false, $help_url);
}
Expand Down