Skip to content

Commit

Permalink
Merge pull request #102 from techjoomla/release-1.0.2
Browse files Browse the repository at this point in the history
Release 1.0.2
  • Loading branch information
coolbung authored Aug 23, 2018
2 parents 74f4ada + a0b2e5a commit 99ceb91
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 deletions.
64 changes: 64 additions & 0 deletions tjreports/administrator/controllers/tjreports.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,68 @@ public function setRedirect($url, $msg = null,$type = null)

parent::setRedirect($url, $msg, $type);
}

/**
* Discover installed plugins
*
* @return JModel
*
* @since 1.6
*/
public function discover()
{
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjreports/models');
JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables');

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('element');
$query->from($db->quoteName('#__extensions'));
$query->where($db->quoteName('type') . "=" . $db->quote('plugin'));
$query->where($db->quoteName('folder') . "=" . $db->quote('tjreports'));
$db->setQuery($query);
$allPlugins = $db->loadColumn();

$query = $db->getQuery(true);
$query->select('plugin');
$query->from($db->quoteName('#__tj_reports'));
$db->setQuery($query);
$tjReportsPlugins = $db->loadColumn();

$discoverPlugins = array_diff($allPlugins, $tjReportsPlugins);

$count = 0;

foreach ($discoverPlugins as $value)
{
$model = JModelLegacy::getInstance('Reports', 'TjreportsModel');
$pluginName = $value;
$reportTable = JTable::getInstance('Tjreport', 'TjreportsTable');
$details = $model->getPluginInstallationDetail($pluginName);
$reportTable->load(array('plugin' => $pluginName, 'userid' => 0));

if (!$reportTable->id)
{
$data = array();
$data['title'] = $details['title'];
$data['plugin'] = $pluginName;
$data['alias'] = $pluginName;
$data['client'] = $details['client'];
$data['parent'] = 0;
$data['default'] = 1;

$reportTable->save($data);
$count++;
}
}

$message = JText::_('COM_TJREPORTS_NOTHING_TO_DISCOVER_PLUGINS');

if ($count > 0)
{
$message = JText::sprintf(JText::_('COM_TJREPORTS_DISCOVER_NEW_PLUGINS'), $count);
}

$this->setRedirect('index.php?option=com_tjreports', $message);
}
}
15 changes: 10 additions & 5 deletions tjreports/administrator/views/tjreports/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ protected function addToolBar()

JToolBarHelper::title($name, 'list');

if ($this->canDo->get('core.delete'))
{
JToolBarHelper::deleteList('', 'tjreports.delete');
}

if ($this->canDo->get('core.create'))
{
JToolBarHelper::addNew('tjreport.add');
Expand All @@ -88,9 +83,19 @@ protected function addToolBar()
JToolBarHelper::editList('tjreport.edit');
}

if ($this->canDo->get('core.delete'))
{
JToolBarHelper::deleteList('', 'tjreports.delete');
}

if ($this->canDo->get('core.admin'))
{
JToolBarHelper::preferences('com_tjreports');
}

if ($this->canDo->get('core.create'))
{
JToolBarHelper::custom('tjreports.discover', 'refresh', 'refresh', 'JLIB_INSTALLER_DISCOVER', false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,7 @@ COM_TJREPORTS_DELETE_QUERY="Delete Query"
COM_TJREPORTS_SAVE_QUERY="Save Query"
COM_TJREPORTS_ENTER_TITLE="Enter title for the Query"
COM_TJREPORTS_QUERY_DELETE_SUCCESS="Query deleted successfully."

;Added in v1.0.2
COM_TJREPORTS_NOTHING_TO_DISCOVER_PLUGINS="Nothing to discover"
COM_TJREPORTS_DISCOVER_NEW_PLUGINS="%d new plugin(s) discovered"
2 changes: 1 addition & 1 deletion tjreports/tjreports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<author>Parth Lawate</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>http://techjoomla.com</authorUrl>
<version>1.0.1</version>
<version>1.0.2</version>
<description>This component is used to access all the report at single place.</description>

<install> <!-- Runs on install -->
Expand Down

0 comments on commit 99ceb91

Please sign in to comment.