forked from techjoomla/com_activitystream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task techjoomla#41 chore: Update default DB engine and charser of the…
… tables
- Loading branch information
Showing
18 changed files
with
765 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
@@ -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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ | ||
|
@@ -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,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)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
@@ -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)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
Oops, something went wrong.