Skip to content

Commit

Permalink
Task techjoomla#41 chore: Update default DB engine and charser of the…
Browse files Browse the repository at this point in the history
… tables
  • Loading branch information
ankush-maherwal committed Aug 8, 2019
2 parents 415aeeb + 1daeb5b commit cf6a6ca
Show file tree
Hide file tree
Showing 18 changed files with 765 additions and 115 deletions.
6 changes: 3 additions & 3 deletions plugins/api/tjactivity/tjactivity.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.0" type="plugin" group="api" method="upgrade">
<name>com_api_tjactivity</name>
<version>1.0.0</version>
<creationDate>16th Nov 2018</creationDate>
<version>1.0.1</version>
<creationDate>8th Feb 2019</creationDate>
<author>Techjoomla</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://techjoomla.com</authorUrl>
<copyright>Copyright (C) 2016 - 2018 Techjoomla. All rights reserved.</copyright>
<copyright>Copyright (C) 2016 - 2019 Techjoomla. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<description>PLG_API_TJACTIVITY_DESCRIPTION</description>
<languages>
Expand Down
8 changes: 5 additions & 3 deletions src/activitystream.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
<extension type="component" version="3.0" method="upgrade">
<name>com_activitystream</name>
<!-- The following elements are optional and free of formatting constraints -->
<creationDate>16th Nov 2018</creationDate>
<creationDate>8th Feb 2019</creationDate>
<author>Techjoomla</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://techjoomla.com</authorUrl>
<copyright>Copyright (C) 2016 - 2018 Techjoomla. All rights reserved.</copyright>
<copyright>Copyright (C) 2016 - 2019 Techjoomla. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<!-- The version string is recorded in the components table -->
<version>1.0.0</version>
<version>1.0.1</version>

<!-- The description is optional and defaults to the name -->
<description>COM_ACTIVITYSTREAM_DESCRIPTION</description>
<scriptfile>script.activitystream.php</scriptfile>
Expand Down Expand Up @@ -44,6 +45,7 @@
<folder>controllers</folder>
</files>
<administration>
<menu link="option=com_activitystream" view="activities">com_activitystream</menu>
<languages folder="admin/language">
<language tag="en-GB">/en-GB/en-GB.com_activitystream.sys.ini</language>
<language tag="en-GB">/en-GB/en-GB.com_activitystream.ini</language>
Expand Down
65 changes: 56 additions & 9 deletions src/admin/controllers/activities.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
/**
* @version SVN: <svn_id>
* @package ActivityStream
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
*/
// No direct access to this file
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;

/**
* HelloWorlds Controller
* Activity Stream Controller
*
* @since 0.0.1
*/
Expand All @@ -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))
{
Expand All @@ -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()
{
Expand All @@ -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))
Expand All @@ -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);
Expand All @@ -94,13 +94,60 @@ 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();
}

echo json_encode($result_arr);

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));
}
}
}
}
18 changes: 16 additions & 2 deletions src/admin/language/en-GB/en-GB.com_activitystream.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

81 changes: 62 additions & 19 deletions src/admin/models/activities.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
* @version SVN: <svn_id>
* @package ActivityStream
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved.
Expand Down Expand Up @@ -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.
*
Expand All @@ -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');

Expand All @@ -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
Expand All @@ -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));
Expand Down
1 change: 0 additions & 1 deletion src/admin/models/activity.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
* @version SVN: <svn_id>
* @package ActivityStream
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved.
Expand Down
Loading

0 comments on commit cf6a6ca

Please sign in to comment.