diff --git a/plugins/api/tjactivity/tjactivity.xml b/plugins/api/tjactivity/tjactivity.xml index 9dd4036..c700ecb 100755 --- a/plugins/api/tjactivity/tjactivity.xml +++ b/plugins/api/tjactivity/tjactivity.xml @@ -1,12 +1,12 @@ com_api_tjactivity - 1.0.0 - 16th Nov 2018 + 1.0.1 + 8th Feb 2019 Techjoomla extensions@techjoomla.com https://techjoomla.com - Copyright (C) 2016 - 2018 Techjoomla. All rights reserved. + Copyright (C) 2016 - 2019 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL PLG_API_TJACTIVITY_DESCRIPTION diff --git a/src/activitystream.xml b/src/activitystream.xml index 22bd567..2bb1b90 100755 --- a/src/activitystream.xml +++ b/src/activitystream.xml @@ -2,14 +2,15 @@ com_activitystream - 16th Nov 2018 + 8th Feb 2019 Techjoomla extensions@techjoomla.com https://techjoomla.com - Copyright (C) 2016 - 2018 Techjoomla. All rights reserved. + Copyright (C) 2016 - 2019 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 1.0.0 + 1.0.1 + COM_ACTIVITYSTREAM_DESCRIPTION script.activitystream.php @@ -44,6 +45,7 @@ controllers + com_activitystream /en-GB/en-GB.com_activitystream.sys.ini /en-GB/en-GB.com_activitystream.ini diff --git a/src/admin/controllers/activities.php b/src/admin/controllers/activities.php index f0da7e7..8a5224e 100755 --- a/src/admin/controllers/activities.php +++ b/src/admin/controllers/activities.php @@ -1,6 +1,5 @@ * @package ActivityStream * @author Techjoomla * @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved. @@ -8,9 +7,10 @@ */ // No direct access to this file defined('_JEXEC') or die; +use Joomla\Utilities\ArrayHelper; /** - * HelloWorlds Controller + * Activity Stream Controller * * @since 0.0.1 */ @@ -25,7 +25,7 @@ class ActivityStreamControllerActivities extends JControllerAdmin * * @return object The model. * - * @since 1.6 + * @since 0.0.1 */ public function getModel($name = 'Activity', $prefix = 'ActivityStreamModel', $config = array('ignore_request' => true)) { @@ -39,7 +39,7 @@ public function getModel($name = 'Activity', $prefix = 'ActivityStreamModel', $c * * @return object activities * - * @since 1.6 + * @since 0.0.1 */ public function getActivities() { @@ -55,7 +55,7 @@ public function getActivities() $ActivityStreamModelActivities = $this->getModel('Activities'); $jinput = JFactory::getApplication()->input; - $type = $jinput->get("type", '', 'STRING'); + $type = $jinput->get("type", '', 'STRING'); // Return result related to specified activity type if (empty($type)) @@ -68,11 +68,11 @@ public function getActivities() jexit(); } - $actor_id = $jinput->get('actor_id', '', 'CMD'); + $actor_id = $jinput->get('actor_id', '', 'CMD'); $object_id = $jinput->get('object_id', '', 'CMD'); $target_id = $jinput->get('target_id', '', 'STRING'); $from_date = $jinput->get('from_date', ''); - $limit = $jinput->get('limit') ? $jinput->get('limit'): 0; + $limit = $jinput->get('limit') ? $jinput->get('limit'): 0; // Set model state $ActivityStreamModelActivities->setState("type", $type); @@ -94,8 +94,8 @@ public function getActivities() } else { - $result_arr['success'] = true; - $result_arr['data'] = $result; + $result_arr['success'] = true; + $result_arr['data'] = $result; $result_arr['data']['total'] = $ActivityStreamModelActivities->getTotal(); } @@ -103,4 +103,51 @@ public function getActivities() jexit(); } + + /** + * Function to delete the activity + * + * @return void + * + * @since 1.0.1 + */ + public function delete() + { + $input = JFactory::getApplication()->input; + $client = $input->get('client', '', 'STRING'); + $id = JFactory::getApplication()->input->get('cid', array(), 'array'); + + if (!is_array($id) || count($id) < 1) + { + JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); + } + else + { + // Get the model. + $model = $this->getModel('activity'); + + // Make sure the item ids are integers + jimport('joomla.utilities.arrayhelper'); + ArrayHelper::toInteger($id); + + // Remove the activity. + if ($model->delete($id)) + { + $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($id))); + } + else + { + $this->setMessage($model->getError()); + } + + if (isset($client)) + { + $this->setRedirect(JRoute::_('index.php?option=com_activitystream&view=activities&client=' . $client, false)); + } + else + { + $this->setRedirect(JRoute::_('index.php?option=com_activitystream&view=activities', false)); + } + } + } } diff --git a/src/admin/language/en-GB/en-GB.com_activitystream.ini b/src/admin/language/en-GB/en-GB.com_activitystream.ini index 83cccd6..c31b8a3 100755 --- a/src/admin/language/en-GB/en-GB.com_activitystream.ini +++ b/src/admin/language/en-GB/en-GB.com_activitystream.ini @@ -7,6 +7,7 @@ COM_ACTIVITYSTREAM_DESCRIPTION="Activity Stream Component" COM_ACTIVITYSTREAM_ADMINISTRATION="Activity Stream - Administration" COM_ACTIVITYSTREAM_ACTIVITY_CREATED_DATE="Created Date" COM_ACTIVITYSTREAM_ACTIVITY_UPDATED_DATE="Updated Date" +COM_ACTIVITYSTREAM_ACTIVITY_ID="ID" COM_ACTIVITYSTREAM_ACTIVITY_ACTOR="Actor" COM_ACTIVITYSTREAM_ACTIVITY_ACTOR_ID="Actor Id" COM_ACTIVITYSTREAM_ACTIVITY_OBJECT="Object" @@ -31,8 +32,21 @@ COM_ACTIVITYSTREAM_ACTIVITY_ADDED="Activity added/updated successfully" COM_ACTIVITYSTREAM_ACTIVITY_DELETED="Activity deleted successfully" COM_ACTIVITYSTREAM_ACTIVITY_NOT_DELETED="Unable to delete activity" COM_ACTIVITYSTREAM_LOAD_MORE_ACTIVITIES="Load More Activities" -COM_ACTIVITYSTREAM_ACTIVITY_ID="Id" +COM_ACTIVITYSTREAM_N_ITEMS_DELETED="%d activity successfully deleted" +COM_ACTIVITYSTREAM_FILTER_SEARCH="Search Activities" +COM_ACTIVITYSTREAM_FILTER_SEARCH_DESC="Search in activity type. Prefix with Client: or Activity type: to search for a particular activity type." +COM_ACTIVITYSTREAM_ID_ASC="Id ascending" +COM_ACTIVITYSTREAM_ID_DESC="Id descending" +COM_ACTIVITYSTREAM_STATE_ASC="State ascending" +COM_ACTIVITYSTREAM_STATE_DESC="State descending" +COM_ACTIVITYSTREAM_TYPE_ASC="Type ascending" +COM_ACTIVITYSTREAM_TYPE_DESC="Type descending" +COM_ACTIVITYSTREAM_CREATED_DATE_ASC="Created Date ascending" +COM_ACTIVITYSTREAM_CREATED_DATE_DESC="Created date descending" +COM_ACTIVITYSTREAM_UPDATED_DATE_ASC="Updated date ascending" +COM_ACTIVITYSTREAM_UPDATED_DATE_DESC="Updated date descending" +COM_ACTIVITYSTREAM_SEARCH_FILTER="- Select Activity Type -" -; Since v1.0.1 +; Since 1.0.1 COM_ACTIVITYSTREAM_CONFIGURATION="Activity Stream Configuration" diff --git a/src/admin/models/activities.php b/src/admin/models/activities.php index 9622992..cad4fcf 100755 --- a/src/admin/models/activities.php +++ b/src/admin/models/activities.php @@ -1,6 +1,5 @@ * @package ActivityStream * @author Techjoomla * @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved. @@ -46,6 +45,47 @@ public function __construct($config = array()) parent::__construct($config); } + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + * @since 1.0.1 + */ + protected function populateState($ordering = 'id', $direction = 'desc') + { + // Initialise variables. + $jinput = JFactory::getApplication()->input; + + // Client filter + $extension = $jinput->get("client", '', 'STRING'); + $this->setState('extension', $extension); + + // Set activities limit + $listlimit = $jinput->input->get('limit', '', 'INT'); + + if ($listlimit != '' || $listlimit == '0') + { + $this->setState('list.limit', $listlimit); + } + + // Load filter published + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + // Load the filter search + $search = $this->getUserStateFromRequest($this->context . 'filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + /** * Method to build an SQL query to load the list data. * @@ -61,6 +101,14 @@ protected function getListQuery() $query->select($this->getState('list.select', '*')) ->from($db->quoteName('#__tj_activities')); + // Filter by client + $extension = $this->getState('extension'); + + if (!empty($extension)) + { + $query->where($db->quoteName('client') . ' = ' . $db->quote($extension)); + } + // Filter: like / search $search = $this->getState('filter.search'); @@ -71,23 +119,29 @@ protected function getListQuery() } // Filter by published state - $published = $this->getState('filter.state'); + $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where('state = ' . (int) $published); } - $type = $this->getState('type'); - $from_date = $this->getState('from_date'); - $limit = $this->getState('limit'); + $listlimit = $this->getState('list.limit'); + + // Default pagination for first page load + if ($listlimit == '' && $listlimit != '0') + { + $listlimit = 20; + } - $result_arr = array(); + $this->setState('list.limit', $listlimit); + + $type = $this->getState('filter.activitytype'); // Return result related to specified activity type if (!empty($type) && $type != 'all') { - $query->where($db->quoteName('type') . ' IN (' . $type . ')'); + $query->where($db->quoteName('type') . ' = ' . $db->quote($type)); } // Get all filters @@ -101,19 +155,8 @@ protected function getListQuery() } } - // Return results from specified date - if (!empty($from_date)) - { - $query->where($db->quoteName('created_date') . ' >= ' . $from_date); - } - - if ($limit != 0) - { - $query->setLimit($limit); - } - // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering', 'created_date'); + $orderCol = $this->state->get('list.ordering', 'created_date'); $orderDirn = $this->state->get('list.direction', 'desc'); $query->order($db->escape($orderCol) . ' ' . $db->escape($orderDirn)); diff --git a/src/admin/models/activity.php b/src/admin/models/activity.php index 45a0def..b971659 100755 --- a/src/admin/models/activity.php +++ b/src/admin/models/activity.php @@ -1,6 +1,5 @@ * @package ActivityStream * @author Techjoomla * @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved. diff --git a/src/admin/models/fields/activitytype.php b/src/admin/models/fields/activitytype.php new file mode 100644 index 0000000..03286c7 --- /dev/null +++ b/src/admin/models/fields/activitytype.php @@ -0,0 +1,72 @@ + + * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved. + * @license GNU General Public License version 2 or later. + */ + +// No direct access. +defined('_JEXEC') or die(); + +JFormHelper::loadFieldClass('list'); + +/** + * Supports an HTML select list of courses + * + * @since 1.0.1 + */ +class JFormFieldActivityType extends JFormFieldList +{ + /** + * The form field type. + * + * @var string + * @since 1.0.1 + */ + protected $type = 'activitytype'; + + /** + * Fiedd to decide if options are being loaded externally and from xml + * + * @var integer + * @since 1.0.1 + */ + protected $loadExternally = 0; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + * + * @since 1.0.1 + */ + protected function getOptions() + { + $db = JFactory::getDbo(); + $client = JFactory::getApplication()->input->get('client', '', 'STRING'); + $query = $db->getQuery(true); + + $query->select('distinct l.type') + ->from($db->quoteName('#__tj_activities') . 'as l') + ->where($db->quoteName('client') . ' = ' . $db->quote($client)); + $query->order($db->escape('l.type ASC')); + $db->setQuery($query); + + // Send filter values + $activityType = $db->loadObjectList(); + $options = array(); + $options[] = JHtml::_('select.option', 'all', JText::_('COM_ACTIVITYSTREAM_SEARCH_FILTER')); + + foreach ($activityType as $type) + { + $temp = implode("_", explode('.', $type->type)); + $filterValue = $client . '_activity_type_' . $temp; + $filterText = strtoupper($filterValue); + $options[] = JHtml::_('select.option', $type->type, JText::_($filterText)); + } + + return $options; + } +} diff --git a/src/admin/models/forms/filter_activities.xml b/src/admin/models/forms/filter_activities.xml index 275df45..7d8a4da 100755 --- a/src/admin/models/forms/filter_activities.xml +++ b/src/admin/models/forms/filter_activities.xml @@ -4,7 +4,8 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/admin/sql/install.mysql.utf8.sql b/src/admin/sql/install.mysql.utf8.sql index 29bb68f..c7d5d01 100755 --- a/src/admin/sql/install.mysql.utf8.sql +++ b/src/admin/sql/install.mysql.utf8.sql @@ -7,7 +7,9 @@ CREATE TABLE IF NOT EXISTS `#__tj_activities` ( `target` text(900), `target_id` text(900), `type` text(900), + `client` varchar(20), `template` text, + `default_theme` varchar(20), `formatted_text` text, `access` tinyint(2) DEFAULT 1, `state` tinyint(2) DEFAULT 1, diff --git a/src/admin/sql/updates/mysql/0.0.1.sql b/src/admin/sql/updates/mysql/0.0.1.sql deleted file mode 100755 index e69de29..0000000 diff --git a/src/admin/sql/updates/mysql/1.0.1.sql b/src/admin/sql/updates/mysql/1.0.1.sql new file mode 100755 index 0000000..529b85f --- /dev/null +++ b/src/admin/sql/updates/mysql/1.0.1.sql @@ -0,0 +1,2 @@ +ALTER TABLE `#__tj_activities` add column `client` varchar(20) DEFAULT NULL; +ALTER TABLE `#__tj_activities` add column `default_theme` varchar(20) DEFAULT NULL; diff --git a/src/admin/views/activities/tmpl/default.php b/src/admin/views/activities/tmpl/default.php index 875ed15..af0ae04 100755 --- a/src/admin/views/activities/tmpl/default.php +++ b/src/admin/views/activities/tmpl/default.php @@ -1,6 +1,5 @@ * @package ActivityStream * @author Techjoomla * @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved. @@ -12,47 +11,17 @@ JHtml::_('formbehavior.chosen', 'select'); $sortFields = $this->getSortFields(); -$listOrder = $this->escape($this->state->get('list.ordering')); -$listDirn = $this->escape($this->state->get('list.direction')); +$listOrder = $this->escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); ?> -
+
-
+
$this) - ); + echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
-
-
- - pagination->getLimitBox(); ?> -
-
- - -
-
- - -
-
items) && empty($this->items['error'])) : ?> @@ -61,20 +30,20 @@ - + @@ -96,11 +65,6 @@ - @@ -113,6 +77,11 @@ + @@ -132,8 +101,6 @@
- - - + - + - + - + + +
id); ?> - - id; ?> - - state, $i, 'activities.', true, 'cb'); ?> updated_date; ?> + + id; ?> + +
- - diff --git a/src/admin/views/activities/view.html.php b/src/admin/views/activities/view.html.php index ea6ab04..d637741 100755 --- a/src/admin/views/activities/view.html.php +++ b/src/admin/views/activities/view.html.php @@ -1,6 +1,5 @@ * @package ActivityStream * @author Techjoomla * @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved. @@ -11,28 +10,31 @@ defined('_JEXEC') or die; /** - * HelloWorlds View + * ActivityStream View * * @since 0.0.1 */ class ActivityStreamViewActivities extends JViewLegacy { + protected $input; + /** - * Display the Hello World view + * Display the ActivityStream view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * - * @return void + * @return mixed A string if successful, otherwise an Error object. */ + public function display($tpl = null) { // To show all types of activity in list view - $activitiesModel = $this->getModel(); + $activitiesModel = $this->getModel(); $activitiesModel->setState("type", 'all'); - - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); + $this->input = JFactory::getApplication()->input; + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); @@ -60,20 +62,29 @@ public function display($tpl = null) */ protected function addToolBar() { - $title = JText::_('Activity Stream'); + $title = JText::_('Activity Stream'); + $languageFile = JFactory::getLanguage(); + $extension = JFactory::getApplication()->input->get('client', '', 'STRING'); + $base_dir = JPATH_BASE; - if ($this->pagination->total) + // Load the language file for particular extension + + if ($extension) { - $title .= "(" . $this->pagination->total . ")"; + $languageFile->load($extension, $base_dir); } - JToolBarHelper::title($title, 'activity'); - JToolBarHelper::deleteList('', 'activities.delete'); - JToolBarHelper::editList('activity.edit'); + /*if ($this->pagination->total) + { + $title .= "(" . $this->pagination->total . ")"; + }*/ + + JToolBarHelper::title($title, 'list'); JToolBarHelper::addNew('activity.add'); + JToolBarHelper::editList('activity.edit'); JToolBarHelper::publish('activity.publish'); JToolBarHelper::unpublish('activity.publish'); - JToolBarHelper::save2copy('activity.save2copy'); + JToolBarHelper::deleteList('', 'activities.delete'); } /** @@ -84,9 +95,9 @@ protected function addToolBar() protected function getSortFields() { return array( - 'id' => JText::_('COM_ACTIVITYSTREAM_ACTIVITY_ID'), - 'state' => JText::_('COM_ACTIVITYSTREAM_ACTIVITY_STATE'), - 'type' => JText::_('COM_ACTIVITYSTREAM_ACTIVITY_TYPE'), + 'id' => JText::_('COM_ACTIVITYSTREAM_ACTIVITY_ID'), + 'state' => JText::_('COM_ACTIVITYSTREAM_ACTIVITY_STATE'), + 'type' => JText::_('COM_ACTIVITYSTREAM_ACTIVITY_TYPE'), 'created_date' => JText::_('COM_ACTIVITYSTREAM_ACTIVITY_CREATED_DATE'), 'updated_date' => JText::_('COM_ACTIVITYSTREAM_ACTIVITY_UPDATED_DATE') ); diff --git a/src/build/bump.php b/src/build/bump.php new file mode 100755 index 0000000..5942c04 --- /dev/null +++ b/src/build/bump.php @@ -0,0 +1,404 @@ + -c + * + * Examples: + * - php build/bump.php -v 3.6.0-dev + * - php build/bump.php -v 3.6.0-beta1 + * - php build/bump.php -v 3.6.0-beta1-dev + * - php build/bump.php -v 3.6.0-beta2 + * - php build/bump.php -v 3.6.0-rc1 + * - php build/bump.php -v 3.6.0 + * - php build/bump.php -v 3.6.0 -c Unicorn + * - php build/bump.php -v 3.6.0 -c "Custom Codename" + * - /usr/bin/php /path/to/joomla-cms/build/bump.php -v 3.7.0 + * + * @package Techjoomla.Build + * + * @author Techjoomla + * @copyright Copyright (C) 2010 - 2018 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +/** + * Display the use of command + * + * @param string $command The command name + * + * @return void + */ +function usage($command) +{ + echo PHP_EOL; + echo 'Usage: php ' . $command . ' [options]' . PHP_EOL; + echo PHP_TAB . '[options]:' . PHP_EOL; + echo PHP_TAB . PHP_TAB . '-v :' . PHP_TAB . 'Version (ex: 3.6.0-dev, 3.6.0-beta1, 3.6.0-beta1-dev, 3.6.0-rc1, 3.6.0)' . PHP_EOL; + echo PHP_TAB . PHP_TAB . '-c :' . PHP_TAB . 'Codename [optional] (ex: Unicorn)' . PHP_EOL; + echo PHP_EOL; +} + +// Constants. +const PHP_TAB = "\t"; + +// File paths. THe version file path (If applicable) +$versionFile = 'PATH_OF_VERSION_FILE'; + +// This file will vary from component to component +$coreXmlFiles = array( + '/src/activitystream.xml', + '/src/plugins/privacy/activitystream/activitystream.xml', +); + +$antJobFile = '/build.xml'; + +$readMeFiles = array( + '/README.md', + '/README.txt', +); + +// Change copyright date exclusions. Some systems may try to scan the .git directory, exclude it. +$directoryLoopExcludeDirectories = array( + '/.git', + '/.gitlab', + '/scripts/ansible-deploy', + '/scripts/gulp', + '/src/packages/com_jlike', + '/tests/codeception', +); + +$directoryLoopExcludeFiles = array( + '.gitignore', + '/build/bump.php', + '/scripts/phing/build.xml', +); + +// Check arguments (exit if incorrect cli arguments). +$opts = getopt("v:c:"); + +if (empty($opts['v'])) +{ + usage($argv[0]); + die(); +} + +// Check version string (exit if not correct). +$versionParts = explode('-', $opts['v']); + +if (!preg_match('#^[0-9]+\.[0-9]+\.[0-9]+$#', $versionParts[0])) +{ + usage($argv[0]); + die(); +} + +if (isset($versionParts[1]) && !preg_match('#(dev|alpha|beta|rc)[0-9]*#', $versionParts[1])) +{ + usage($argv[0]); + die(); +} + +if (isset($versionParts[2]) && $versionParts[2] !== 'dev') +{ + usage($argv[0]); + die(); +} + +// Make sure we use the correct language and timezone. +setlocale(LC_ALL, 'en_GB'); +date_default_timezone_set('Asia/Kolkata'); + +// Make sure file and folder permissions are set correctly. +umask(022); + +// Get version dev status. +$dev_status = 'Stable'; + +if (!isset($versionParts[1])) +{ + $versionParts[1] = ''; +} +else +{ + if (preg_match('#^dev#', $versionParts[1])) + { + $dev_status = 'Development'; + } + elseif (preg_match('#^alpha#', $versionParts[1])) + { + $dev_status = 'Alpha'; + } + elseif (preg_match('#^beta#', $versionParts[1])) + { + $dev_status = 'Beta'; + } + elseif (preg_match('#^rc#', $versionParts[1])) + { + $dev_status = 'Release Candidate'; + } +} + +if (!isset($versionParts[2])) +{ + $versionParts[2] = ''; +} +else +{ + $dev_status = 'Development'; +} + +// Set version properties. +$versionSubParts = explode('.', $versionParts[0]); + +$version = array( + 'main' => $versionSubParts[0] . '.' . $versionSubParts[1], + 'major' => $versionSubParts[0], + 'minor' => $versionSubParts[1], + 'patch' => $versionSubParts[2], + 'extra' => (!empty($versionParts[1]) ? $versionParts[1] : '') . + (!empty($versionParts[2]) ? (!empty($versionParts[1]) ? '-' : '') . $versionParts[2] : ''), + 'release' => $versionSubParts[0] . '.' . $versionSubParts[1] . '.' . $versionSubParts[2], + 'dev_devel' => $versionSubParts[2] . (!empty($versionParts[1]) ? '-' . + $versionParts[1] : '') . (!empty($versionParts[2]) ? '-' . $versionParts[2] : ''), + 'dev_status' => $dev_status, + 'build' => '', + 'reldate' => date('j-F-Y'), + 'reltime' => date('H:i'), + 'reltz' => 'GMT', + 'credate' => date('jS M Y') + ); + +// Version Codename. +if (!empty($opts['c'])) +{ + $version['codename'] = trim($opts['c']); +} + +// Prints version information. +echo PHP_EOL; +echo 'Version data:' . PHP_EOL; +echo '- Main:' . PHP_TAB . PHP_TAB . PHP_TAB . $version['main'] . PHP_EOL; +echo '- Release:' . PHP_TAB . PHP_TAB . $version['release'] . PHP_EOL; +echo '- Full:' . PHP_TAB . PHP_TAB . PHP_TAB . $version['main'] . '.' . $version['dev_devel'] . PHP_EOL; +echo '- Build:' . PHP_TAB . PHP_TAB . $version['build'] . PHP_EOL; +echo '- Dev Level:' . PHP_TAB . PHP_TAB . $version['dev_devel'] . PHP_EOL; +echo '- Dev Status:' . PHP_TAB . PHP_TAB . $version['dev_status'] . PHP_EOL; +echo '- Release date:' . PHP_TAB . PHP_TAB . $version['reldate'] . PHP_EOL; +echo '- Release time:' . PHP_TAB . PHP_TAB . $version['reltime'] . PHP_EOL; +echo '- Release timezone:' . PHP_TAB . $version['reltz'] . PHP_EOL; +echo '- Creation date:' . PHP_TAB . $version['credate'] . PHP_EOL; + +if (!empty($version['codename'])) +{ + echo '- Codename:' . PHP_TAB . PHP_TAB . $version['codename'] . PHP_EOL; +} + +echo PHP_EOL; + +$rootPath = dirname(__DIR__); + +// Updates the version in version class. +if (file_exists($rootPath . $versionFile)) +{ + $fileContents = file_get_contents($rootPath . $versionFile); + $fileContents = preg_replace("#MAJOR_VERSION\s*=\s*[^;]*#", "MAJOR_VERSION = " . $version['major'], $fileContents); + $fileContents = preg_replace("#MINOR_VERSION\s*=\s*[^;]*#", "MINOR_VERSION = " . $version['minor'], $fileContents); + $fileContents = preg_replace("#PATCH_VERSION\s*=\s*[^;]*#", "PATCH_VERSION = " . $version['patch'], $fileContents); + $fileContents = preg_replace("#EXTRA_VERSION\s*=\s*'[^\']*'#", "EXTRA_VERSION = '" . $version['extra'] . "'", $fileContents); + $fileContents = preg_replace("#RELEASE\s*=\s*'[^\']*'#", "RELEASE = '" . $version['main'] . "'", $fileContents); + $fileContents = preg_replace("#DEV_LEVEL\s*=\s*'[^\']*'#", "DEV_LEVEL = '" . $version['dev_devel'] . "'", $fileContents); + $fileContents = preg_replace("#DEV_STATUS\s*=\s*'[^\']*'#", "DEV_STATUS = '" . $version['dev_status'] . "'", $fileContents); + $fileContents = preg_replace("#BUILD\s*=\s*'[^\']*'#", "BUILD = '" . $version['build'] . "'", $fileContents); + $fileContents = preg_replace("#RELDATE\s*=\s*'[^\']*'#", "RELDATE = '" . $version['reldate'] . "'", $fileContents); + $fileContents = preg_replace("#RELTIME\s*=\s*'[^\']*'#", "RELTIME = '" . $version['reltime'] . "'", $fileContents); + $fileContents = preg_replace("#RELTZ\s*=\s*'[^\']*'#", "RELTZ = '" . $version['reltz'] . "'", $fileContents); + + if (!empty($version['codename'])) + { + $fileContents = preg_replace("#CODENAME\s*=\s*'[^\']*'#", "CODENAME = '" . $version['codename'] . "'", $fileContents); + } + + file_put_contents($rootPath . $versionFile, $fileContents); +} + +// + TJ - chanages +// Prints TJ specific information. +$author = 'Techjoomla'; +$authorEmail = 'extensions@techjoomla.com'; +$authorUrl = 'https://techjoomla.com'; +$license = 'http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL'; +$copyright = 'Copyright (C) 2010 - 2018 Techjoomla. All rights reserved.'; + +echo PHP_EOL; + +echo 'Techjoomla copyright info to be added in xml:' . PHP_EOL; +echo '- author:' . PHP_TAB . PHP_TAB . PHP_TAB . $author . PHP_EOL; +echo '- authorEmail:' . PHP_TAB . PHP_TAB . PHP_TAB . $authorEmail . PHP_EOL; +echo '- authorUrl:' . PHP_TAB . PHP_TAB . PHP_TAB . $authorUrl . PHP_EOL; +echo '- license:' . PHP_TAB . PHP_TAB . PHP_TAB . $license . PHP_EOL; +echo '- copyright:' . PHP_TAB . PHP_TAB . PHP_TAB . $copyright . PHP_EOL; + +echo PHP_EOL; + +// + TJ - chanages - end + +// Updates the version and creation date in core xml files. +foreach ($coreXmlFiles as $coreXmlFile) +{ + if (file_exists($rootPath . $coreXmlFile)) + { + // @echo 'Processed xml file: ' .$rootPath . $coreXmlFile . PHP_EOL; + + $fileContents = file_get_contents($rootPath . $coreXmlFile); + + $fileContents = preg_replace('#[^<]*#', '' . $version['main'] . + '.' . $version['dev_devel'] . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $version['credate'] . '', $fileContents + ); + + // + TJ - chanages + $fileContents = preg_replace('#[^<]*#', '' . + $author . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $authorEmail . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $authorUrl . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $license . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $copyright . '', $fileContents + ); + + // + TJ - chanages - end + + file_put_contents($rootPath . $coreXmlFile, $fileContents); + } +} + +// Updates the version for the `phpdoc` task in the Ant job file. +if (file_exists($rootPath . $antJobFile)) +{ + $fileContents = file_get_contents($rootPath . $antJobFile); + $fileContents = preg_replace('##', '', $fileContents + ); + file_put_contents($rootPath . $antJobFile, $fileContents); +} + +// Updates the version in readme files. +foreach ($readMeFiles as $readMeFile) +{ + if (file_exists($rootPath . $readMeFile)) + { + $fileContents = file_get_contents($rootPath . $readMeFile); + $fileContents = preg_replace('#Joomla! [0-9]+\.[0-9]+ (|\[)version#', 'Joomla! ' . $version['main'] . ' $1version', $fileContents); + $fileContents = preg_replace('#Joomla_[0-9]+\.[0-9]+_version#', 'Joomla_' . $version['main'] . '_version', $fileContents); + file_put_contents($rootPath . $readMeFile, $fileContents); + } +} + +// Updates the copyright date in core files. +$changedFilesCopyrightDate = 0; +$changedFilesSinceVersion = 0; +$year = date('Y'); +$directory = new \RecursiveDirectoryIterator($rootPath); +$iterator = new \RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST); + +foreach ($iterator as $file) +{ + if ($file->isFile()) + { + $filePath = $file->getPathname(); + $relativePath = str_replace($rootPath, '', $filePath); + + // Exclude certain extensions. + if (preg_match('#\.(png|jpeg|jpg|gif|bmp|ico|webp|svg|woff|woff2|ttf|eot)$#', $filePath)) + { + continue; + } + + // Exclude certain files. + if (in_array($relativePath, $directoryLoopExcludeFiles)) + { + continue; + } + + // Exclude certain directories. + $continue = true; + + foreach ($directoryLoopExcludeDirectories as $excludeDirectory) + { + if (preg_match('#^' . preg_quote($excludeDirectory) . '#', $relativePath)) + { + $continue = false; + break; + } + } + + if ($continue) + { + $changeSinceVersion = false; + $changeCopyrightDate = false; + + // Load the file. + $fileContents = file_get_contents($filePath); + + // Check if need to change the copyright date. + if (preg_match('#2010\s+-\s+[0-9]{4}\s+Techjoomla.\s+All\s+rights#', $fileContents) + && !preg_match('#2010\s+-\s+' . $year . '\s+Techjoomla.\s+All\s+rights#', $fileContents)) + { + $changeCopyrightDate = true; + $fileContents = preg_replace('#2010\s+-\s+[0-9]{4}\s+Techjoomla.\s+All\s+rights#', '2010 - ' . + $year . ' Techjoomla. All rights', $fileContents + ); + $changedFilesCopyrightDate++; + } + + // Check if need to change the since version. + if ($relativePath !== '/build/bump.php' && preg_match('#__DEPLOY_VERSION__#', $fileContents)) + { + $changeSinceVersion = true; + $fileContents = preg_replace('#__DEPLOY_VERSION__#', $version['release'], $fileContents); + $changedFilesSinceVersion++; + } + + // Save the file. + if ($changeCopyrightDate || $changeSinceVersion) + { + file_put_contents($filePath, $fileContents); + } + + // @echo 'Processed file: ' . $filePath . PHP_EOL; + } + } +} + +if ($changedFilesCopyrightDate > 0 || $changedFilesSinceVersion > 0) +{ + if ($changedFilesCopyrightDate > 0) + { + echo '- Copyright Date changed in ' . $changedFilesCopyrightDate . ' files.' . PHP_EOL; + } + + if ($changedFilesSinceVersion > 0) + { + echo '- Since Version changed in ' . $changedFilesSinceVersion . ' files.' . PHP_EOL; + } + + echo PHP_EOL; +} + +echo 'Version bump complete!' . PHP_EOL; + diff --git a/src/media/scripts/activities.jQuery.js b/src/media/scripts/activities.jQuery.js index a2b92ee..7ffb8f9 100755 --- a/src/media/scripts/activities.jQuery.js +++ b/src/media/scripts/activities.jQuery.js @@ -33,6 +33,7 @@ let object_id = techjoomla.jQuery(ele).attr("tj-activitystream-object-id"); let target_id = techjoomla.jQuery(ele).attr("tj-activitystream-target-id"); let from_date = techjoomla.jQuery(ele).attr("tj-activitystream-from-date"); + let filter_condition = techjoomla.jQuery(ele).attr("tj-activitystream-filter-condition"); let limit = techjoomla.jQuery(ele).attr("tj-activitystream-limit"); let start = techjoomla.jQuery(ele).attr("start"); let url = root_url+"index.php?option=com_activitystream&task=activities.getActivities"; @@ -61,6 +62,10 @@ { url += "&limit="+limit; } + if (typeof filter_condition != 'undefined') + { + url += "&filter_condition="+filter_condition; + } techjoomla.jQuery.ajax({ url: url+"&start="+start, diff --git a/src/plugins/privacy/activitystream/activitystream.xml b/src/plugins/privacy/activitystream/activitystream.xml index 6eca3d5..8d08e61 100644 --- a/src/plugins/privacy/activitystream/activitystream.xml +++ b/src/plugins/privacy/activitystream/activitystream.xml @@ -1,12 +1,12 @@ plg_privacy_activitystream - 1.0.0 - 16th Nov 2018 + 1.0.1 + 8th Feb 2019 Techjoomla extensions@techjoomla.com https://techjoomla.com - Copyright (C) 2016 - 2018 Techjoomla. All rights reserved. + Copyright (C) 2016 - 2019 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL PLG_PRIVACY_ACTIVITYSTREAM_XML_DESCRIPTION diff --git a/src/site/controllers/activities.php b/src/site/controllers/activities.php index 03f48e9..e20da02 100755 --- a/src/site/controllers/activities.php +++ b/src/site/controllers/activities.php @@ -74,6 +74,7 @@ public function getActivities() $from_date = $jinput->get('from_date', ''); $start = $jinput->get('start', '0'); $limit = $jinput->get('limit'); + $filter_condition = $jinput->get('filter_condition', '', 'STRING'); // Set model state $ActivityStreamModelActivities->setState("type", $type); @@ -85,6 +86,7 @@ public function getActivities() $ActivityStreamModelActivities->setState("access", "1"); $ActivityStreamModelActivities->setState("state", '1'); $ActivityStreamModelActivities->setState("list.start", $start); + $ActivityStreamModelActivities->setState("filter_condition", $filter_condition); $result['results'] = $ActivityStreamModelActivities->getItems(); diff --git a/src/site/models/activities.php b/src/site/models/activities.php index 2fe4229..d6989b1 100755 --- a/src/site/models/activities.php +++ b/src/site/models/activities.php @@ -86,6 +86,7 @@ protected function getListQuery() $from_date = $this->getState('from_date'); $limit = $this->getState('list.limit'); $start = $this->getState('list.start'); + $filter_condition = $this->getState('filter_condition'); $result_arr = array(); @@ -99,15 +100,51 @@ protected function getListQuery() // Get all filters $filters = $this->get('filter_fields'); - foreach ($filters as $filter) + // Default filter condition AND support + if ($filter_condition != 'any') { - $filterValue = $this->getState($filter); + foreach ($filters as $filter) + { + $filterValue = $this->getState($filter); + + if (!empty($filterValue) && $filter != 'type') + { + $filterValue = $this->activityStreamActivitiesHelper->buildActivityFilterQuery($filterValue); + $query->where($db->quoteName($filter) . ' IN (' . $filterValue . ')'); + } + } + } + else + { + // Filter condition OR support + $whereClause = array(); - if (!empty($filterValue) && $filter != 'type') + foreach ($filters as $filter) { - $filterValue = $this->activityStreamActivitiesHelper->buildActivityFilterQuery($filterValue); - $query->where($db->quoteName($filter) . ' IN (' . $filterValue . ')'); + $filterValue = $this->getState($filter); + + if (!empty($filterValue) && $filter != 'type') + { + $filterValue = $this->activityStreamActivitiesHelper->buildActivityFilterQuery($filterValue); + $conditionFilters = array('target_id', 'object_id', 'actor_id'); + + if (!in_array($filter, $conditionFilters)) + { + $query->where($db->quoteName($filter) . ' IN (' . $filterValue . ')'); + } + else + { + $whereClause[] = $db->quoteName($filter) . " IN (" . $filterValue . ")"; + } + } } + + if (!empty($whereClause)) + { + $whereClause = '(' . implode(' OR ', $whereClause) . ')'; + } + + $query->where($whereClause); } // Return results from specified date