Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
debuggroup.php000064400000014331151156223110007417 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('UsersHelperDebug', JPATH_ADMINISTRATOR .
'/components/com_users/helpers/debug.php');
/**
* Methods supporting a list of User ACL permissions
*
* @since 1.6
*/
class UsersModelDebuggroup extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 3.6.0
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.title',
'component', 'a.name',
'a.lft',
'a.id',
'level_start', 'level_end', 'a.level',
);
}
parent::__construct($config);
}
/**
* Get a list of the actions.
*
* @return array
*
* @since 1.6
*/
public function getDebugActions()
{
$component = $this->getState('filter.component');
return UsersHelperDebug::getDebugActions($component);
}
/**
* Override getItems method.
*
* @return array
*
* @since 1.6
*/
public function getItems()
{
$groupId = $this->getState('group_id');
if (($assets = parent::getItems()) && $groupId)
{
$actions = $this->getDebugActions();
foreach ($assets as &$asset)
{
$asset->checks = array();
foreach ($actions as $action)
{
$name = $action[0];
$asset->checks[$name] = JAccess::checkGroup($groupId, $name,
$asset->name);
}
}
}
return $assets;
}
/**
* 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.6
*/
protected function populateState($ordering = 'a.lft', $direction
= 'asc')
{
$app = JFactory::getApplication('administrator');
// Adjust the context to support modal layouts.
$layout = $app->input->get('layout',
'default');
if ($layout)
{
$this->context .= '.' . $layout;
}
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('group_id',
$this->getUserStateFromRequest($this->context .
'.group_id', 'group_id', 0, 'int', false));
$levelStart = $this->getUserStateFromRequest($this->context .
'.filter.level_start', 'filter_level_start',
'', 'cmd');
$this->setState('filter.level_start', $levelStart);
$value = $this->getUserStateFromRequest($this->context .
'.filter.level_end', 'filter_level_end', '',
'cmd');
if ($value > 0 && $value < $levelStart)
{
$value = $levelStart;
}
$this->setState('filter.level_end', $value);
$this->setState('filter.component',
$this->getUserStateFromRequest($this->context .
'.filter.component', 'filter_component', '',
'string'));
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('group_id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' .
$this->getState('filter.level_start');
$id .= ':' . $this->getState('filter.level_end');
$id .= ':' . $this->getState('filter.component');
return parent::getStoreId($id);
}
/**
* Get the group being debugged.
*
* @return JObject
*
* @since 1.6
*/
public function getGroup()
{
$groupId = (int) $this->getState('group_id');
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('id, title')
->from('#__usergroups')
->where('id = ' . $groupId);
$db->setQuery($query);
try
{
$group = $db->loadObject();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
return $group;
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.name, a.title, a.level, a.lft, a.rgt'
)
);
$query->from($db->quoteName('#__assets', 'a'));
// Filter the items over the search string if set.
if ($this->getState('filter.search'))
{
// Escape the search token.
$search = $db->quote('%' . str_replace(' ',
'%',
$db->escape(trim($this->getState('filter.search')), true) .
'%'));
// Compile the different search clauses.
$searches = array();
$searches[] = 'a.name LIKE ' . $search;
$searches[] = 'a.title LIKE ' . $search;
// Add the clauses to the query.
$query->where('(' . implode(' OR ', $searches) .
')');
}
// Filter on the start and end levels.
$levelStart = (int) $this->getState('filter.level_start');
$levelEnd = (int) $this->getState('filter.level_end');
if ($levelEnd > 0 && $levelEnd < $levelStart)
{
$levelEnd = $levelStart;
}
if ($levelStart > 0)
{
$query->where('a.level >= ' . $levelStart);
}
if ($levelEnd > 0)
{
$query->where('a.level <= ' . $levelEnd);
}
// Filter the items over the component if set.
if ($this->getState('filter.component'))
{
$component = $this->getState('filter.component');
$query->where('(a.name = ' . $db->quote($component) .
' OR a.name LIKE ' . $db->quote($component . '.%') .
')');
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.lft')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
}
debuguser.php000064400000013701151156223110007241 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('UsersHelperDebug', JPATH_ADMINISTRATOR .
'/components/com_users/helpers/debug.php');
/**
* Methods supporting a list of User ACL permissions
*
* @since 1.6
*/
class UsersModelDebugUser extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 3.6.0
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.title',
'component', 'a.name',
'a.lft',
'a.id',
'level_start', 'level_end', 'a.level',
);
}
parent::__construct($config);
}
/**
* Get a list of the actions.
*
* @return array
*
* @since 1.6
*/
public function getDebugActions()
{
$component = $this->getState('filter.component');
return UsersHelperDebug::getDebugActions($component);
}
/**
* Override getItems method.
*
* @return array
*
* @since 1.6
*/
public function getItems()
{
$userId = $this->getState('user_id');
$user = JFactory::getUser($userId);
if (($assets = parent::getItems()) && $userId)
{
$actions = $this->getDebugActions();
foreach ($assets as &$asset)
{
$asset->checks = array();
foreach ($actions as $action)
{
$name = $action[0];
$asset->checks[$name] = $user->authorise($name,
$asset->name);
}
}
}
return $assets;
}
/**
* 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.6
*/
protected function populateState($ordering = 'a.lft', $direction
= 'asc')
{
$app = JFactory::getApplication('administrator');
// Adjust the context to support modal layouts.
$layout = $app->input->get('layout',
'default');
if ($layout)
{
$this->context .= '.' . $layout;
}
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('user_id',
$this->getUserStateFromRequest($this->context . '.user_id',
'user_id', 0, 'int', false));
$levelStart = $this->getUserStateFromRequest($this->context .
'.filter.level_start', 'filter_level_start',
'', 'cmd');
$this->setState('filter.level_start', $levelStart);
$value = $this->getUserStateFromRequest($this->context .
'.filter.level_end', 'filter_level_end', '',
'cmd');
if ($value > 0 && $value < $levelStart)
{
$value = $levelStart;
}
$this->setState('filter.level_end', $value);
$this->setState('filter.component',
$this->getUserStateFromRequest($this->context .
'.filter.component', 'filter_component', '',
'string'));
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('user_id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' .
$this->getState('filter.level_start');
$id .= ':' . $this->getState('filter.level_end');
$id .= ':' . $this->getState('filter.component');
return parent::getStoreId($id);
}
/**
* Get the user being debugged.
*
* @return JUser
*
* @since 1.6
*/
public function getUser()
{
$userId = $this->getState('user_id');
return JFactory::getUser($userId);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.name, a.title, a.level, a.lft, a.rgt'
)
);
$query->from($db->quoteName('#__assets', 'a'));
// Filter the items over the search string if set.
if ($this->getState('filter.search'))
{
// Escape the search token.
$search = $db->quote('%' . str_replace(' ',
'%',
$db->escape(trim($this->getState('filter.search')), true) .
'%'));
// Compile the different search clauses.
$searches = array();
$searches[] = 'a.name LIKE ' . $search;
$searches[] = 'a.title LIKE ' . $search;
// Add the clauses to the query.
$query->where('(' . implode(' OR ', $searches) .
')');
}
// Filter on the start and end levels.
$levelStart = (int) $this->getState('filter.level_start');
$levelEnd = (int) $this->getState('filter.level_end');
if ($levelEnd > 0 && $levelEnd < $levelStart)
{
$levelEnd = $levelStart;
}
if ($levelStart > 0)
{
$query->where('a.level >= ' . $levelStart);
}
if ($levelEnd > 0)
{
$query->where('a.level <= ' . $levelEnd);
}
// Filter the items over the component if set.
if ($this->getState('filter.component'))
{
$component = $this->getState('filter.component');
$query->where('(a.name = ' . $db->quote($component) .
' OR a.name LIKE ' . $db->quote($component . '.%') .
')');
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.lft')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
}
fields/groupparent.php000064400000005277151156223110011101 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Helper\UserGroupsHelper;
FormHelper::loadFieldClass('list');
/**
* User Group Parent field..
*
* @since 1.6
*/
class JFormFieldGroupParent extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'GroupParent';
/**
* Method to clean the Usergroup Options from all children starting by a
given father
*
* @param array $userGroupsOptions The usergroup options to clean
* @param integer $fatherId The father ID to start with
*
* @return array The cleaned field options
*
* @since 3.9.4
*/
private function cleanOptionsChildrenByFather($userGroupsOptions,
$fatherId)
{
foreach ($userGroupsOptions as $userGroupsOptionsId =>
$userGroupsOptionsData)
{
if ((int) $userGroupsOptionsData->parent_id === (int) $fatherId)
{
unset($userGroupsOptions[$userGroupsOptionsId]);
$userGroupsOptions =
$this->cleanOptionsChildrenByFather($userGroupsOptions,
$userGroupsOptionsId);
}
}
return $userGroupsOptions;
}
/**
* Method to get the field options.
*
* @return array The field option objects
*
* @since 1.6
*/
protected function getOptions()
{
$options = UserGroupsHelper::getInstance()->getAll();
$currentGroupId = $this->form->getValue('id');
// Prevent to set yourself as parent
if ($currentGroupId)
{
unset($options[$currentGroupId]);
}
// We should not remove any groups when we are creating a new group
if (!is_null($currentGroupId))
{
// Prevent parenting direct children and children of children of this
item.
$options = $this->cleanOptionsChildrenByFather($options,
$currentGroupId);
}
$options = array_values($options);
$isSuperAdmin = Factory::getUser()->authorise('core.admin');
// Pad the option text with spaces using depth level as a multiplier.
for ($i = 0, $n = count($options); $i < $n; $i++)
{
// Show groups only if user is super admin or group is not super admin
if ($isSuperAdmin || !Access::checkGroup($options[$i]->id,
'core.admin'))
{
$options[$i]->value = $options[$i]->id;
$options[$i]->text = str_repeat('- ',
$options[$i]->level) . $options[$i]->title;
}
else
{
unset($options[$i]);
}
}
// Merge any additional options in the XML definition.
return array_merge(parent::getOptions(), $options);
}
}
fields/levels.php000064400000001465151156223110010020 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* Access Levels field.
*
* @since 3.6.0
*/
class JFormFieldLevels extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.6.0
*/
protected $type = 'Levels';
/**
* Method to get the field options.
*
* @return array The field option objects
*
* @since 3.6.0
*/
protected function getOptions()
{
// Merge any additional options in the XML definition.
return array_merge(parent::getOptions(),
UsersHelperDebug::getLevelsOptions());
}
}
forms/config_domain.xml000064400000001165151156223110011210
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="name"
type="text"
label="COM_USERS_CONFIG_FIELD_DOMAIN_NAME_LABEL"
description="COM_USERS_CONFIG_FIELD_DOMAIN_NAME_DESC"
required="true"
/>
<field
name="rule"
type="list"
label="COM_USERS_CONFIG_FIELD_DOMAIN_RULE_LABEL"
description="COM_USERS_CONFIG_FIELD_DOMAIN_RULE_DESC"
required="true"
default="0"
filter="integer"
>
<option
value="1">COM_USERS_CONFIG_FIELD_DOMAIN_RULE_OPTION_ALLOW</option>
<option
value="0">COM_USERS_CONFIG_FIELD_DOMAIN_RULE_OPTION_DISALLOW</option>
</field>
</fieldset>
</form>
forms/fields/user.xml000064400000000357151156223110010642 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields name="params"
label="COM_FIELDS_FIELD_BASIC_LABEL">
<fieldset name="basic">
<field
name="display"
type="hidden"
default="2"
/>
</fieldset>
</fields>
</form>
forms/filter_debuggroup.xml000064400000003577151156223110012135
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_ASSETS"
description="COM_USERS_SEARCH_IN_ASSETS"
hint="JSEARCH_FILTER"
/>
<field
name="component"
type="Components"
label="COM_USERS_FILTER_COMPONENT_LABEL"
description="COM_USERS_FILTER_COMPONENT_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_COMPONENT</option>
</field>
<field
name="level_start"
type="Levels"
label="COM_USERS_FILTER_LEVEL_START_LABEL"
description="COM_USERS_FILTER_LEVEL_START_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_LEVEL_START</option>
</field>
<field
name="level_end"
type="Levels"
label="COM_USERS_FILTER_LEVEL_END_LABEL"
description="COM_USERS_FILTER_LEVEL_END_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_LEVEL_END</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
onchange="this.form.submit();"
default="a.lft ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.title
ASC">COM_USERS_HEADING_ASSET_TITLE_ASC</option>
<option value="a.title
DESC">COM_USERS_HEADING_ASSET_TITLE_DESC</option>
<option value="a.name
ASC">COM_USERS_HEADING_ASSET_NAME_ASC</option>
<option value="a.name
DESC">COM_USERS_HEADING_ASSET_NAME_DESC</option>
<option value="a.lft
ASC">COM_USERS_HEADING_LFT_ASC</option>
<option value="a.lft
DESC">COM_USERS_HEADING_LFT_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_debuguser.xml000064400000003572151156223110011752
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_ASSETS"
description="COM_USERS_SEARCH_IN_ASSETS"
hint="JSEARCH_FILTER"
/>
<field
name="component"
type="Components"
label="COM_USERS_FILTER_COMPONENT_LABEL"
description="COM_USERS_FILTER_COMPONENT_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_COMPONENT</option>
</field>
<field
name="level_start"
type="Levels"
label="COM_USERS_FILTER_LEVEL_START_LABEL"
description="COM_USERS_FILTER_LEVEL_START_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_LEVEL_START</option>
</field>
<field
name="level_end"
type="Levels"
label="COM_USERS_FILTER_LEVEL_END_LABEL"
description="COM_USERS_FILTER_LEVEL_END_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_LEVEL_END</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
onchange="this.form.submit();"
default="a.lft ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.title
ASC">COM_USERS_HEADING_ASSET_TITLE_ASC</option>
<option value="a.title
DESC">COM_USERS_HEADING_ASSET_TITLE_DESC</option>
<option value="a.name
ASC">COM_USERS_HEADING_ASSET_NAME_ASC</option>
<option value="a.name
DESC">COM_USERS_HEADING_ASSET_NAME_DESC</option>
<option value="a.lft
ASC">COM_USERS_HEADING_LFT_ASC</option>
<option value="a.lft
DESC">COM_USERS_HEADING_LFT_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_groups.xml000064400000003705151156223110011302
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset name="group">
<field
name="context"
type="fieldcontexts"
onchange="this.form.submit();"
/>
</fieldset>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
description="COM_FIELDS_GROUPS_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
class="js-stools-search-string"
/>
<field
name="state"
type="status"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="access"
type="accesslevel"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_ACCESS</option>
</field>
<field
name="language"
type="contentlanguage"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.ordering ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.access
ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="a.access
DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="a.language
ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="a.language
DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_levels.xml000064400000002166151156223110011255
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_ACCESS_LEVELS"
description="COM_USERS_SEARCH_IN_LEVEL_NAME"
hint="JSEARCH_FILTER"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.ordering ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.title
ASC">COM_USERS_HEADING_LEVEL_NAME_ASC</option>
<option value="a.title
DESC">COM_USERS_HEADING_LEVEL_NAME_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_notes.xml000064400000004256151156223110011115 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_USER_NOTES"
description="COM_USERS_SEARCH_IN_NOTE_TITLE"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
extension="com_users"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_CATEGORY</option>
</field>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.review_time DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.subject
ASC">COM_USERS_HEADING_SUBJECT_ASC</option>
<option value="a.subject
DESC">COM_USERS_HEADING_SUBJECT_DESC</option>
<option value="c.title
ASC">COM_USERS_HEADING_CATEGORY_ASC</option>
<option value="c.title
DESC">COM_USERS_HEADING_CATEGORY_DESC</option>
<option value="u.name
ASC">COM_USERS_HEADING_USER_ASC</option>
<option value="u.name
DESC">COM_USERS_HEADING_USER_DESC</option>
<option value="a.review_time
ASC">COM_USERS_HEADING_REVIEW_ASC</option>
<option value="a.review_time
DESC">COM_USERS_HEADING_REVIEW_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_users.xml000064400000006175151156223110011130 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_USERS"
description="COM_USERS_SEARCH_IN_NAME"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="userstate"
label="COM_USERS_FILTER_STATE"
description="COM_USERS_FILTER_STATE_DESC"
onchange="this.form.submit();"
>
<option value="">COM_USERS_FILTER_STATE</option>
</field>
<field
name="active"
type="useractive"
label="COM_USERS_FILTER_ACTIVE"
description="COM_USERS_FILTER_ACTIVE_DESC"
onchange="this.form.submit();"
>
<option value="">COM_USERS_FILTER_ACTIVE</option>
</field>
<field
name="group_id"
type="usergrouplist"
label="COM_USERS_FILTER_GROUP"
description="COM_USERS_FILTER_GROUP_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_FILTER_USERGROUP</option>
</field>
<field
name="lastvisitrange"
type="lastvisitdaterange"
label="COM_USERS_OPTION_FILTER_LAST_VISIT_DATE"
description="COM_USERS_OPTION_FILTER_LAST_VISIT_DATE"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_FILTER_LAST_VISIT_DATE</option>
</field>
<field
name="range"
type="registrationdaterange"
label="COM_USERS_OPTION_FILTER_DATE"
description="COM_USERS_OPTION_FILTER_DATE"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_FILTER_DATE</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.name
ASC">COM_USERS_HEADING_NAME_ASC</option>
<option value="a.name
DESC">COM_USERS_HEADING_NAME_DESC</option>
<option value="a.username
ASC">COM_USERS_HEADING_USERNAME_ASC</option>
<option value="a.username
DESC">COM_USERS_HEADING_USERNAME_DESC</option>
<option value="a.block
ASC">COM_USERS_HEADING_ENABLED_ASC</option>
<option value="a.block
DESC">COM_USERS_HEADING_ENABLED_DESC</option>
<option value="a.activation
ASC">COM_USERS_HEADING_ACTIVATED_ASC</option>
<option value="a.activation
DESC">COM_USERS_HEADING_ACTIVATED_DESC</option>
<option value="a.email
ASC">COM_USERS_HEADING_EMAIL_ASC</option>
<option value="a.email
DESC">COM_USERS_HEADING_EMAIL_DESC</option>
<option value="a.lastvisitDate
ASC">COM_USERS_HEADING_LAST_VISIT_DATE_ASC</option>
<option value="a.lastvisitDate
DESC">COM_USERS_HEADING_LAST_VISIT_DATE_DESC</option>
<option value="a.registerDate
ASC">COM_USERS_HEADING_REGISTRATION_DATE_ASC</option>
<option value="a.registerDate
DESC">COM_USERS_HEADING_REGISTRATION_DATE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/group.xml000064400000005725151156223110007556 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
default="0"
class="readonly"
readonly="true"
/>
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<field
name="context"
type="hidden"
class="readonly"
readonly="true"
/>
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="JFIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="state"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
class="chzn-color-state"
default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="created"
type="calendar"
label="JGLOBAL_CREATED_DATE"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="created_by"
type="user"
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
description="JGLOBAL_FIELD_CREATED_BY_DESC"
/>
<field
name="modified"
type="calendar"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
translateformat="true"
showtime="true"
size="22"
class="readonly"
readonly="true"
filter="user_utc"
/>
<field
name="modified_by"
type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_FIELDS_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
<field
name="note"
type="text"
label="COM_FIELDS_FIELD_NOTE_LABEL"
description="COM_FIELDS_FIELD_NOTE_DESC"
class="span12"
size="40"
/>
<field
name="description"
type="textarea"
label="JGLOBAL_DESCRIPTION"
size="40"
filter="HTML"
/>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
/>
<field
name="rules"
type="rules"
label="JFIELD_RULES_LABEL"
id="rules"
translate_label="false"
filter="rules"
validate="rules"
section="fieldgroup"
/>
<field
name="ordering"
type="text"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
class="inputbox"
/>
</fieldset>
<fields name="params"
label="COM_FIELDS_FIELD_BASIC_LABEL">
<fieldset name="basic">
<field
name="display_readonly"
type="radio"
label="JFIELD_DISPLAY_READONLY_LABEL"
description="JFIELD_DISPLAY_READONLY_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</form>
forms/level.xml000064400000001062151156223110007517 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="hidden"
default="0"
readonly="true"
required="true"
/>
<field
name="title"
type="text"
label="COM_USERS_LEVEL_FIELD_TITLE_LABEL"
description="COM_USERS_LEVEL_FIELD_TITLE_DESC"
required="true"
size="50"
/>
<field
name="ordering"
type="text"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
default="0"
/>
<field
name="rules"
type="hidden"
filter="int_array"
/>
</fieldset>
</form>
forms/mail.xml000064400000002734151156223110007341 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="recurse"
type="checkbox"
label="COM_USERS_MAIL_FIELD_RECURSE_LABEL"
description="COM_USERS_MAIL_FIELD_RECURSE_DESC"
value="1"
/>
<field
name="mode"
type="checkbox"
label="COM_USERS_MAIL_FIELD_SEND_IN_HTML_MODE_LABEL"
description="COM_USERS_MAIL_FIELD_SEND_IN_HTML_MODE_DESC"
value="1"
/>
<field
name="disabled"
type="checkbox"
label="COM_USERS_MAIL_FIELD_EMAIL_DISABLED_USERS_LABEL"
description="COM_USERS_MAIL_FIELD_EMAIL_DISABLED_USERS_DESC"
value="1"
/>
<field
name="group"
type="usergrouplist"
label="COM_USERS_MAIL_FIELD_GROUP_LABEL"
description="COM_USERS_MAIL_FIELD_GROUP_DESC"
default="0"
size="10"
>
<option
value="0">COM_USERS_MAIL_FIELD_VALUE_ALL_USERS_GROUPS</option>
</field>
<field
name="bcc"
type="checkbox"
label="COM_USERS_MAIL_FIELD_SEND_AS_BLIND_CARBON_COPY_LABEL"
description="COM_USERS_MAIL_FIELD_SEND_AS_BLIND_CARBON_COPY_DESC"
default="1"
value="1"
checked="1"
/>
<field
name="subject"
type="text"
label="COM_USERS_MAIL_FIELD_SUBJECT_LABEL"
description="COM_USERS_MAIL_FIELD_SUBJECT_DESC"
class="span8"
maxlength="150"
size="30"
/>
<field
name="message"
type="textarea"
label="COM_USERS_MAIL_FIELD_MESSAGE_LABEL"
description="COM_USERS_MAIL_FIELD_MESSAGE_DESC"
class="span11 vert"
cols="70"
rows="20"
/>
</fieldset>
</form>
forms/note.xml000064400000005452151156223110007364 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_categories/models/fields"
>
<field
name="id"
type="hidden"
label="COM_USERS_FIELD_ID_LABEL"
class="readonly"
size="6"
default="0"
readonly="true"
/>
<field
name="user_id"
type="user"
label="COM_USERS_FIELD_USER_ID_LABEL"
description="JLIB_FORM_SELECT_USER"
size="50"
class="input-medium"
required="true"
/>
<field
name="catid"
type="modal_category"
label="COM_USERS_FIELD_CATEGORY_ID_LABEL"
description="JFIELD_CATEGORY_DESC"
extension="com_users"
required="true"
select="true"
new="true"
edit="true"
clear="true"
/>
<field
name="subject"
type="text"
label="COM_USERS_FIELD_SUBJECT_LABEL"
description="COM_USERS_FIELD_SUBJECT_DESC"
size="80"
/>
<field
name="body"
type="editor"
label="COM_USERS_FIELD_NOTEBODY_LABEL"
description="COM_USERS_FIELD_NOTEBODY_DESC"
rows="10"
cols="80"
filter="safehtml"
/>
<field
name="state"
type="list"
label="JSTATUS"
description="COM_USERS_FIELD_STATE_DESC"
size="1"
default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="review_time"
type="calendar"
label="COM_USERS_FIELD_REVIEW_TIME_LABEL"
description="COM_USERS_FIELD_REVIEW_TIME_DESC"
default="NOW"
translateformat="true"
filter="user_utc"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="created_user_id"
type="hidden"
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
filter="unset"
/>
<field
name="created_time"
type="hidden"
label="JGLOBAL_FIELD_CREATED_LABEL"
filter="unset"
/>
<field
name="modified_user_id"
type="hidden"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
filter="unset"
/>
<field
name="modified_time"
type="hidden"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
filter="unset"
/>
<field
name="publish_up"
type="calendar"
label="JGLOBAL_FIELD_PUBLISH_UP_LABEL"
description="JGLOBAL_FIELD_PUBLISH_UP_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="publish_down"
type="calendar"
label="JGLOBAL_FIELD_PUBLISH_DOWN_LABEL"
description="JGLOBAL_FIELD_PUBLISH_DOWN_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="version_note"
type="text"
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
description="JGLOBAL_FIELD_VERSION_NOTE_DESC"
maxlength="255"
size="45"
labelclass="control-label"
/>
</fieldset>
</form>
forms/user.xml000064400000011402151156223110007365 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset name="user_details">
<field
name="name"
type="text"
label="COM_USERS_USER_FIELD_NAME_LABEL"
description="COM_USERS_USER_FIELD_NAME_DESC"
required="true"
size="30"
/>
<field
name="username"
type="text"
label="COM_USERS_USER_FIELD_USERNAME_LABEL"
description="COM_USERS_USER_FIELD_USERNAME_DESC"
required="true"
size="30"
/>
<field
name="password"
type="password"
label="JGLOBAL_PASSWORD"
description="COM_USERS_USER_FIELD_PASSWORD_DESC"
autocomplete="off"
class="validate-password"
filter="raw"
validate="password"
size="30"
/>
<field
name="password2"
type="password"
label="COM_USERS_USER_FIELD_PASSWORD2_LABEL"
description="COM_USERS_USER_FIELD_PASSWORD2_DESC"
autocomplete="off"
class="validate-password"
filter="raw"
message="COM_USERS_USER_FIELD_PASSWORD1_MESSAGE"
size="30"
validate="equals"
field="password"
/>
<field
name="email"
type="email"
label="JGLOBAL_EMAIL"
description="COM_USERS_USER_FIELD_EMAIL_DESC"
required="true"
size="30"
validate="email"
validDomains="com_users.domains"
/>
<field
name="registerDate"
type="calendar"
label="COM_USERS_USER_FIELD_REGISTERDATE_LABEL"
description="COM_USERS_USER_FIELD_REGISTERDATE_DESC"
class="readonly"
readonly="true"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="lastvisitDate"
type="calendar"
label="COM_USERS_USER_FIELD_LASTVISIT_LABEL"
description="COM_USERS_USER_FIELD_LASTVISIT_DESC"
class="readonly"
readonly="true"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="lastResetTime"
type="calendar"
label="COM_USERS_USER_FIELD_LASTRESET_LABEL"
description="COM_USERS_USER_FIELD_LASTRESET_DESC"
class="readonly"
readonly="true"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="resetCount"
type="number"
label="COM_USERS_USER_FIELD_RESETCOUNT_LABEL"
description="COM_USERS_USER_FIELD_RESETCOUNT_DESC"
class="readonly"
default="0"
readonly="true"
/>
<field
name="sendEmail"
type="radio"
label="COM_USERS_USER_FIELD_SENDEMAIL_LABEL"
description="COM_USERS_USER_FIELD_SENDEMAIL_DESC"
default="0"
class="btn-group btn-group-yesno"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="block"
type="radio"
label="COM_USERS_USER_FIELD_BLOCK_LABEL"
description="COM_USERS_USER_FIELD_BLOCK_DESC"
class="btn-group btn-group-yesno btn-group-reversed"
default="0"
>
<option
value="1">COM_USERS_USER_FIELD_BLOCK</option>
<option
value="0">COM_USERS_USER_FIELD_ENABLE</option>
</field>
<field
name="requireReset"
type="radio"
label="COM_USERS_USER_FIELD_REQUIRERESET_LABEL"
description="COM_USERS_USER_FIELD_REQUIRERESET_DESC"
default="0"
class="btn-group btn-group-yesno"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
class="readonly"
default="0"
readonly="true"
/>
</fieldset>
<field name="groups" type="hidden" />
<field name="twofactor" type="hidden" />
<fields name="params">
<!-- Basic user account settings. -->
<fieldset name="settings"
label="COM_USERS_SETTINGS_FIELDSET_LABEL">
<field
name="admin_style"
type="templatestyle"
label="COM_USERS_USER_FIELD_BACKEND_TEMPLATE_LABEL"
description="COM_USERS_USER_FIELD_BACKEND_TEMPLATE_DESC"
client="administrator"
filter="uint"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="admin_language"
type="language"
label="COM_USERS_USER_FIELD_BACKEND_LANGUAGE_LABEL"
description="COM_USERS_USER_FIELD_BACKEND_LANGUAGE_DESC"
client="administrator"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="language"
type="language"
label="COM_USERS_USER_FIELD_FRONTEND_LANGUAGE_LABEL"
description="COM_USERS_USER_FIELD_FRONTEND_LANGUAGE_DESC"
client="site"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="editor"
type="plugins"
label="COM_USERS_USER_FIELD_EDITOR_LABEL"
description="COM_USERS_USER_FIELD_EDITOR_DESC"
folder="editors"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="timezone"
type="timezone"
label="COM_USERS_USER_FIELD_TIMEZONE_LABEL"
description="COM_USERS_USER_FIELD_TIMEZONE_DESC"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
</fieldset>
</fields>
</form>
group.php000064400000022063151156223110006411 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
/**
* Group Model
*
* @since 3.7.0
*/
class FieldsModelGroup extends JModelAdmin
{
/**
* @var null|string
*
* @since 3.7.0
*/
public $typeAlias = null;
/**
* Allowed batch commands
*
* @var array
*/
protected $batch_commands = array(
'assetgroup_id' => 'batchAccess',
'language_id' => 'batchLanguage'
);
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success, False on error.
*
* @since 3.7.0
*/
public function save($data)
{
// Alter the title for save as copy
$input = JFactory::getApplication()->input;
// Save new group as unpublished
if ($input->get('task') == 'save2copy')
{
$data['state'] = 0;
}
return parent::save($data);
}
/**
* Method to get a table object, load it if necessary.
*
* @param string $name The table name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $options Configuration array for model. Optional.
*
* @return JTable A JTable object
*
* @since 3.7.0
* @throws Exception
*/
public function getTable($name = 'Group', $prefix =
'FieldsTable', $options = array())
{
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_fields/tables');
return JTable::getInstance($name, $prefix, $options);
}
/**
* Abstract method for getting the form from the model.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 3.7.0
*/
public function getForm($data = array(), $loadData = true)
{
$context = $this->getState('filter.context');
$jinput = JFactory::getApplication()->input;
if (empty($context) && isset($data['context']))
{
$context = $data['context'];
$this->setState('filter.context', $context);
}
// Get the form.
$form = $this->loadForm(
'com_fields.group.' . $context, 'group',
array(
'control' => 'jform',
'load_data' => $loadData,
)
);
if (empty($form))
{
return false;
}
// Modify the form based on Edit State access controls.
if (empty($data['context']))
{
$data['context'] = $context;
}
if (!JFactory::getUser()->authorise('core.edit.state',
$context . '.fieldgroup.' . $jinput->get('id')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('state', 'disabled',
'true');
// Disable fields while saving. The controller has already verified this
is a record you can edit.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('state', 'filter',
'unset');
}
return $form;
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission for the component.
*
* @since 3.7.0
*/
protected function canDelete($record)
{
if (empty($record->id) || $record->state != -2)
{
return false;
}
return JFactory::getUser()->authorise('core.delete',
$record->context . '.fieldgroup.' . (int) $record->id);
}
/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission for the
* component.
*
* @since 3.7.0
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
// Check for existing fieldgroup.
if (!empty($record->id))
{
return $user->authorise('core.edit.state',
$record->context . '.fieldgroup.' . (int) $record->id);
}
// Default to component settings.
return $user->authorise('core.edit.state',
$record->context);
}
/**
* Auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 3.7.0
*/
protected function populateState()
{
parent::populateState();
$context =
JFactory::getApplication()->getUserStateFromRequest('com_fields.groups.context',
'context', 'com_fields', 'CMD');
$this->setState('filter.context', $context);
}
/**
* A protected method to get a set of ordering conditions.
*
* @param JTable $table A JTable object.
*
* @return array An array of conditions to add to ordering queries.
*
* @since 3.7.0
*/
protected function getReorderConditions($table)
{
return 'context = ' .
$this->_db->quote($table->context);
}
/**
* Method to preprocess the form.
*
* @param JForm $form A JForm object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @see JFormField
* @since 3.7.0
* @throws Exception if there is an error in the form event.
*/
protected function preprocessForm(JForm $form, $data, $group =
'content')
{
parent::preprocessForm($form, $data, $group);
$parts =
FieldsHelper::extract($this->state->get('filter.context'));
// Extract the component name
$component = $parts[0];
// Extract the optional section name
$section = (count($parts) > 1) ? $parts[1] : null;
if ($parts)
{
// Set the access control rules field component value.
$form->setFieldAttribute('rules', 'component',
$component);
}
if ($section !== null)
{
// Looking first in the component models/forms folder
$path = JPath::clean(JPATH_ADMINISTRATOR . '/components/' .
$component . '/models/forms/fieldgroup/' . $section .
'.xml');
if (file_exists($path))
{
$lang = JFactory::getLanguage();
$lang->load($component, JPATH_BASE, null, false, true);
$lang->load($component, JPATH_BASE . '/components/' .
$component, null, false, true);
if (!$form->loadFile($path, false))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
}
}
}
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return array|boolean Array of filtered data if valid, false
otherwise.
*
* @see JFormRule
* @see JFilterInput
* @since 3.9.23
*/
public function validate($form, $data, $group = null)
{
if (!JFactory::getUser()->authorise('core.admin',
'com_fields'))
{
if (isset($data['rules']))
{
unset($data['rules']);
}
}
return parent::validate($form, $data, $group);
}
/**
* Method to get the data that should be injected in the form.
*
* @return array The default data is an empty array.
*
* @since 3.7.0
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$app = JFactory::getApplication();
$data = $app->getUserState('com_fields.edit.group.data',
array());
if (empty($data))
{
$data = $this->getItem();
// Pre-select some filters (Status, Language, Access) in edit form if
those have been selected in Field Group Manager
if (!$data->id)
{
// Check for which context the Field Group Manager is used and get
selected fields
$context =
substr($app->getUserState('com_fields.groups.filter.context'),
4);
$filters = (array) $app->getUserState('com_fields.groups.'
. $context . '.filter');
$data->set(
'state',
$app->input->getInt('state',
(!empty($filters['state']) ? $filters['state'] : null))
);
$data->set(
'language',
$app->input->getString('language',
(!empty($filters['language']) ? $filters['language'] :
null))
);
$data->set(
'access',
$app->input->getInt('access',
(!empty($filters['access']) ? $filters['access'] :
JFactory::getConfig()->get('access')))
);
}
}
$this->preprocessData('com_fields.group', $data);
return $data;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 3.7.0
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
// Prime required properties.
if (empty($item->id))
{
$item->context = $this->getState('filter.context');
}
if (property_exists($item, 'params'))
{
$item->params = new Registry($item->params);
}
}
return $item;
}
/**
* Clean the cache
*
* @param string $group The cache group
* @param integer $clientId The ID of the client
*
* @return void
*
* @since 3.7.0
*/
protected function cleanCache($group = null, $clientId = 0)
{
$context =
JFactory::getApplication()->input->get('context');
parent::cleanCache($context);
}
}
groups.php000064400000014411151156223120006573 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
/**
* Groups Model
*
* @since 3.7.0
*/
class FieldsModelGroups extends JModelList
{
/**
* Context string for the model type. This is used to handle uniqueness
* when dealing with the getStoreId() method and caching data structures.
*
* @var string
* @since 3.7.0
*/
protected $context = 'com_fields.groups';
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JModelLegacy
* @since 3.7.0
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'type', 'a.type',
'state', 'a.state',
'access', 'a.access',
'access_level',
'language', 'a.language',
'ordering', 'a.ordering',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'created', 'a.created',
'created_by', 'a.created_by',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* This method should only be called once per instantiation and is
designed
* to be called on the first call to the getState() method unless the
model
* configuration flag to ignore the request is set.
*
* 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 3.7.0
*/
protected function populateState($ordering = null, $direction = null)
{
// List state information.
parent::populateState('a.ordering', 'asc');
$context = $this->getUserStateFromRequest($this->context .
'.context', 'context', 'com_content',
'CMD');
$this->setState('filter.context', $context);
}
/**
* Method to get a store id based on the model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id An identifier string to generate the store id.
*
* @return string A store id.
*
* @since 3.7.0
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.context');
$id .= ':' . $this->getState('filter.state');
$id .= ':' .
print_r($this->getState('filter.language'), true);
return parent::getStoreId($id);
}
/**
* Method to get a JDatabaseQuery object for retrieving the data set from
a database.
*
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data
set.
*
* @since 3.7.0
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select($this->getState('list.select',
'a.*'));
$query->from('#__fields_groups AS a');
// Join over the language
$query->select('l.title AS language_title, l.image AS
language_image')
->join('LEFT', $db->quoteName('#__languages')
. ' AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS
editor')->join('LEFT', '#__users AS uc ON
uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS
access_level')->join('LEFT', '#__viewlevels AS ag ON
ag.id = a.access');
// Join over the users for the author.
$query->select('ua.name AS
author_name')->join('LEFT', '#__users AS ua ON ua.id
= a.created_by');
// Filter by context
if ($context = $this->getState('filter.context',
'com_fields'))
{
$query->where('a.context = ' . $db->quote($context));
}
// Filter by access level.
if ($access = $this->getState('filter.access'))
{
if (is_array($access))
{
$access = ArrayHelper::toInteger($access);
$query->where('a.access in (' . implode(',',
$access) . ')');
}
else
{
$query->where('a.access = ' . (int) $access);
}
}
// Implement View Level Access
if (!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Filter by published state
$state = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where('a.state = ' . (int) $state);
}
elseif (!$state)
{
$query->where('a.state IN (0, 1)');
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('a.title LIKE ' . $search);
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$language = (array) $language;
foreach ($language as $key => $l)
{
$language[$key] = $db->quote($l);
}
$query->where('a.language in (' . implode(',',
$language) . ')');
}
// Add the list ordering clause
$listOrdering = $this->getState('list.ordering',
'a.ordering');
$listDirn = $db->escape($this->getState('list.direction',
'ASC'));
$query->order($db->escape($listOrdering) . ' ' .
$listDirn);
return $query;
}
/**
* Gets an array of objects from the results of database query.
*
* @param string $query The query.
* @param integer $limitstart Offset.
* @param integer $limit The number of records.
*
* @return array An array of results.
*
* @since 3.8.7
* @throws RuntimeException
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$result = parent::_getList($query, $limitstart, $limit);
if (is_array($result))
{
foreach ($result as $group)
{
$group->params = new Registry($group->params);
}
}
return $result;
}
}
level.php000064400000016443151156223130006373 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\UserGroupsHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\Utilities\ArrayHelper;
/**
* User view level model.
*
* @since 1.6
*/
class UsersModelLevel extends AdminModel
{
/**
* @var array A list of the access levels in use.
* @since 1.6
*/
protected $levelsInUse = null;
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
$groups = json_decode($record->rules);
if ($groups === null)
{
throw new RuntimeException('Invalid rules schema');
}
$isAdmin = JFactory::getUser()->authorise('core.admin');
// Check permissions
foreach ($groups as $group)
{
if (!$isAdmin && JAccess::checkGroup($group,
'core.admin'))
{
$this->setError(JText::_('JERROR_ALERTNOAUTHOR'));
return false;
}
}
// Check if the access level is being used by any content.
if ($this->levelsInUse === null)
{
// Populate the list once.
$this->levelsInUse = array();
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('DISTINCT access');
// Get all the tables and the prefix
$tables = $db->getTableList();
$prefix = $db->getPrefix();
foreach ($tables as $table)
{
// Get all of the columns in the table
$fields = $db->getTableColumns($table);
/**
* We are looking for the access field. If custom tables are using
something other
* than the 'access' field they are on their own
unfortunately.
* Also make sure the table prefix matches the live db prefix (eg, it
is not a "bak_" table)
*/
if (strpos($table, $prefix) === 0 &&
isset($fields['access']))
{
// Lookup the distinct values of the field.
$query->clear('from')
->from($db->quoteName($table));
$db->setQuery($query);
try
{
$values = $db->loadColumn();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
$this->levelsInUse = array_merge($this->levelsInUse, $values);
// TODO Could assemble an array of the tables used by each view level
list those,
// giving the user a clue in the error where to look.
}
}
// Get uniques.
$this->levelsInUse = array_unique($this->levelsInUse);
// Ok, after all that we are ready to check the record :)
}
if (in_array($record->id, $this->levelsInUse))
{
$this->setError(JText::sprintf('COM_USERS_ERROR_VIEW_LEVEL_IN_USE',
$record->id, $record->title));
return false;
}
return parent::canDelete($record);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Viewlevel', $prefix =
'JTable', $config = array())
{
$return = JTable::getInstance($type, $prefix, $config);
return $return;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
$result = parent::getItem($pk);
// Convert the params field to an array.
$result->rules = json_decode($result->rules);
return $result;
}
/**
* Method to get the record form.
*
* @param array $data An optional array of data for the form to
interrogate.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.level',
'level', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_users.edit.level.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_users.level', $data);
return $data;
}
/**
* Method to preprocess the form
*
* @param JForm $form A form object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @since 1.6
* @throws Exception if there is an error loading the form.
*/
protected function preprocessForm(JForm $form, $data, $group =
'')
{
parent::preprocessForm($form, $data, 'user');
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
if (!isset($data['rules']))
{
$data['rules'] = array();
}
$data['title'] =
JFilterInput::getInstance()->clean($data['title'],
'TRIM');
return parent::save($data);
}
/**
* Method to validate the form data.
*
* @param \JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return array|boolean Array of filtered data if valid, false
otherwise.
*
* @see \JFormRule
* @see \JFilterInput
* @since 3.8.8
*/
public function validate($form, $data, $group = null)
{
$isSuperAdmin = Factory::getUser()->authorise('core.admin');
// Non Super user should not be able to change the access levels of super
user groups
if (!$isSuperAdmin)
{
if (!isset($data['rules']) ||
!is_array($data['rules']))
{
$data['rules'] = array();
}
$groups = array_values(UserGroupsHelper::getInstance()->getAll());
$rules = array();
if (!empty($data['id']))
{
$table = $this->getTable();
$table->load($data['id']);
$rules = json_decode($table->rules);
}
$rules = ArrayHelper::toInteger($rules);
for ($i = 0, $n = count($groups); $i < $n; ++$i)
{
if (Access::checkGroup((int) $groups[$i]->id,
'core.admin'))
{
if (in_array((int) $groups[$i]->id, $rules) &&
!in_array((int) $groups[$i]->id, $data['rules']))
{
$data['rules'][] = (int) $groups[$i]->id;
}
elseif (!in_array((int) $groups[$i]->id, $rules) &&
in_array((int) $groups[$i]->id, $data['rules']))
{
$this->setError(Text::_('JLIB_USER_ERROR_NOT_SUPERADMIN'));
return false;
}
}
}
}
return parent::validate($form, $data, $group);
}
}
levels.php000064400000012357151156223130006556 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Methods supporting a list of user access level records.
*
* @since 1.6
*/
class UsersModelLevels extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'ordering', 'a.ordering',
);
}
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.6
*/
protected function populateState($ordering = 'a.ordering',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search'));
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from($db->quoteName('#__viewlevels') . ' AS
a');
// Add the level in the tree.
$query->group('a.id, a.title, a.ordering, a.rules');
// Filter the items over the search string if set.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('a.title LIKE ' . $search);
}
}
$query->group('a.id');
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.ordering')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Method to adjust the ordering of a row.
*
* @param integer $pk The ID of the primary key to move.
* @param integer $direction Increment, usually +1 or -1
*
* @return boolean False on failure or error, true otherwise.
*/
public function reorder($pk, $direction = 0)
{
// Sanitize the id and adjustment.
$pk = (!empty($pk)) ? $pk : (int)
$this->getState('level.id');
$user = JFactory::getUser();
// Get an instance of the record's table.
$table = JTable::getInstance('viewlevel');
// Load the row.
if (!$table->load($pk))
{
$this->setError($table->getError());
return false;
}
// Access checks.
$allow = $user->authorise('core.edit.state',
'com_users');
if (!$allow)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
return false;
}
// Move the row.
// TODO: Where clause to restrict category.
$table->move($pk);
return true;
}
/**
* Saves the manually set order of records.
*
* @param array $pks An array of primary key ids.
* @param integer $order Order position
*
* @return boolean|JException Boolean true on success, boolean false or
JException instance on error
*/
public function saveorder($pks, $order)
{
$table = JTable::getInstance('viewlevel');
$user = JFactory::getUser();
$conditions = array();
if (empty($pks))
{
return JError::raiseWarning(500,
JText::_('COM_USERS_ERROR_LEVELS_NOLEVELS_SELECTED'));
}
// Update ordering values
foreach ($pks as $i => $pk)
{
$table->load((int) $pk);
// Access checks.
$allow = $user->authorise('core.edit.state',
'com_users');
if (!$allow)
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
elseif ($table->ordering != $order[$i])
{
$table->ordering = $order[$i];
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
}
}
// Execute reorder for each category.
foreach ($conditions as $cond)
{
$table->load($cond[0]);
$table->reorder($cond[1]);
}
return true;
}
}
mail.php000064400000013253151156223130006202 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Users mail model.
*
* @since 1.6
*/
class UsersModelMail extends JModelAdmin
{
/**
* Method to get the row form.
*
* @param array $data An optional array of data for the form to
interrogate.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.mail', 'mail',
array('control' => 'jform', 'load_data'
=> $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_users.display.mail.data',
array());
$this->preprocessData('com_users.mail', $data);
return $data;
}
/**
* Method to preprocess the form
*
* @param JForm $form A form object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @since 1.6
* @throws Exception if there is an error loading the form.
*/
protected function preprocessForm(JForm $form, $data, $group =
'user')
{
parent::preprocessForm($form, $data, $group);
}
/**
* Send the email
*
* @return boolean
*/
public function send()
{
$app = JFactory::getApplication();
$data = $app->input->post->get('jform', array(),
'array');
$user = JFactory::getUser();
$access = new JAccess;
$db = $this->getDbo();
$mode = array_key_exists('mode', $data) ? (int)
$data['mode'] : 0;
$subject = array_key_exists('subject', $data) ?
$data['subject'] : '';
$grp = array_key_exists('group', $data) ? (int)
$data['group'] : 0;
$recurse = array_key_exists('recurse', $data) ? (int)
$data['recurse'] : 0;
$bcc = array_key_exists('bcc', $data) ? (int)
$data['bcc'] : 0;
$disabled = array_key_exists('disabled', $data) ? (int)
$data['disabled'] : 0;
$message_body = array_key_exists('message', $data) ?
$data['message'] : '';
// Automatically removes html formatting
if (!$mode)
{
$message_body = JFilterInput::getInstance()->clean($message_body,
'string');
}
// Check for a message body and subject
if (!$message_body || !$subject)
{
$app->setUserState('com_users.display.mail.data', $data);
$this->setError(JText::_('COM_USERS_MAIL_PLEASE_FILL_IN_THE_FORM_CORRECTLY'));
return false;
}
// Get users in the group out of the ACL, if group is provided.
$to = $grp !== 0 ? $access->getUsersByGroup($grp, $recurse) : array();
// When group is provided but no users are found in the group.
if ($grp !== 0 && !$to)
{
$rows = array();
}
else
{
// Get all users email and group except for senders
$query = $db->getQuery(true)
->select($db->quoteName('email'))
->from($db->quoteName('#__users'))
->where($db->quoteName('id') . ' != ' . (int)
$user->id);
if ($grp !== 0)
{
$query->where($db->quoteName('id') . ' IN ('
. implode(',', $to) . ')');
}
if ($disabled === 0)
{
$query->where($db->quoteName('block') . ' =
0');
}
$db->setQuery($query);
$rows = $db->loadColumn();
}
// Check to see if there are any users in this group before we continue
if (!$rows)
{
$app->setUserState('com_users.display.mail.data', $data);
if (in_array($user->id, $to))
{
$this->setError(JText::_('COM_USERS_MAIL_ONLY_YOU_COULD_BE_FOUND_IN_THIS_GROUP'));
}
else
{
$this->setError(JText::_('COM_USERS_MAIL_NO_USERS_COULD_BE_FOUND_IN_THIS_GROUP'));
}
return false;
}
// Get the Mailer
$mailer = JFactory::getMailer();
$params = JComponentHelper::getParams('com_users');
// Build email message format.
$mailer->setSender(array($app->get('mailfrom'),
$app->get('fromname')));
$mailer->setSubject($params->get('mailSubjectPrefix') .
stripslashes($subject));
$mailer->setBody($message_body .
$params->get('mailBodySuffix'));
$mailer->IsHtml($mode);
// Add recipients
if ($bcc)
{
$mailer->addBcc($rows);
$mailer->addRecipient($app->get('mailfrom'));
}
else
{
$mailer->addRecipient($rows);
}
// Send the Mail
$rs = $mailer->Send();
// Check for an error
if ($rs instanceof Exception)
{
$app->setUserState('com_users.display.mail.data', $data);
$this->setError($rs->getError());
return false;
}
elseif (empty($rs))
{
$app->setUserState('com_users.display.mail.data', $data);
$this->setError(JText::_('COM_USERS_MAIL_THE_MAIL_COULD_NOT_BE_SENT'));
return false;
}
else
{
/**
* Fill the data (specially for the 'mode', 'group'
and 'bcc': they could not exist in the array
* when the box is not checked and in this case, the default value would
be used instead of the '0'
* one)
*/
$data['mode'] = $mode;
$data['subject'] = $subject;
$data['group'] = $grp;
$data['recurse'] = $recurse;
$data['bcc'] = $bcc;
$data['message'] = $message_body;
$app->setUserState('com_users.display.mail.data', array());
$app->enqueueMessage(JText::plural('COM_USERS_MAIL_EMAIL_SENT_TO_N_USERS',
count($rows)), 'message');
return true;
}
}
}
note.php000064400000006433151156223130006227 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User note model.
*
* @since 2.5
*/
class UsersModelNote extends JModelAdmin
{
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_users.note';
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 2.5
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.note', 'note',
array('control' => 'jform', 'load_data'
=> $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 2.5
*/
public function getItem($pk = null)
{
$result = parent::getItem($pk);
// Get the dispatcher and load the content plugins.
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('content');
// Load the user plugins for backward compatibility (v3.3.3 and earlier).
JPluginHelper::importPlugin('user');
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData',
array('com_users.note', $result));
return $result;
}
/**
* Method to get a table object, load it if necessary.
*
* @param string $name The table name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $options Configuration array for model. Optional.
*
* @return JTable The table object
*
* @since 2.5
*/
public function getTable($name = 'Note', $prefix =
'UsersTable', $options = array())
{
return JTable::getInstance($name, $prefix, $options);
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Get the application
$app = JFactory::getApplication();
// Check the session for previously entered form data.
$data = $app->getUserState('com_users.edit.note.data',
array());
if (empty($data))
{
$data = $this->getItem();
// Prime some default values.
if ($this->getState('note.id') == 0)
{
$data->set('catid',
$app->input->get('catid',
$app->getUserState('com_users.notes.filter.category_id'),
'int'));
}
$userId = $app->input->get('u_id', 0, 'int');
if ($userId != 0)
{
$data->user_id = $userId;
}
}
$this->preprocessData('com_users.note', $data);
return $data;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 2.5
*/
protected function populateState()
{
parent::populateState();
$userId = JFactory::getApplication()->input->get('u_id',
0, 'int');
$this->setState('note.user_id', $userId);
}
}
notes.php000064400000013450151156223130006407 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User notes model class.
*
* @since 2.5
*/
class UsersModelNotes extends JModelList
{
/**
* Class constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 2.5
*/
public function __construct($config = array())
{
// Set the list ordering fields.
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'user_id', 'a.user_id',
'u.name',
'subject', 'a.subject',
'catid', 'a.catid', 'category_id',
'state', 'a.state', 'published',
'c.title',
'review_time', 'a.review_time',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'level', 'c.level',
);
}
parent::__construct($config);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data
set.
*
* @since 2.5
*/
protected function getListQuery()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState('list.select',
'a.id, a.subject, a.checked_out, a.checked_out_time,' .
'a.catid, a.created_time, a.review_time,' .
'a.state, a.publish_up, a.publish_down'
)
);
$query->from('#__user_notes AS a');
// Join over the category
$query->select('c.title AS category_title, c.params AS
category_params')
->join('LEFT', '#__categories AS c ON c.id =
a.catid');
// Join over the users for the note user.
$query->select('u.name AS user_name')
->join('LEFT', '#__users AS u ON u.id =
a.user_id');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON uc.id =
a.checked_out');
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
elseif (stripos($search, 'uid:') === 0)
{
$query->where('a.user_id = ' . (int) substr($search, 4));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('((a.subject LIKE ' . $search . ') OR
(u.name LIKE ' . $search . ') OR (u.username LIKE ' .
$search . '))');
}
}
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.state = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.state IN (0, 1))');
}
// Filter by a single category.
$categoryId = (int) $this->getState('filter.category_id');
if ($categoryId)
{
$query->where('a.catid = ' . $categoryId);
}
// Filter by a single user.
$userId = (int) $this->getState('filter.user_id');
if ($userId)
{
// Add the body and where filter.
$query->select('a.body')
->where('a.user_id = ' . $userId);
}
// Filter on the level.
if ($level = $this->getState('filter.level'))
{
$query->where($db->quoteName('c.level') . ' <=
' . (int) $level);
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.review_time')) . ' ' .
$db->escape($this->getState('list.direction',
'DESC')));
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 2.5
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' .
$this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.user_id');
$id .= ':' . $this->getState('filter.level');
return parent::getStoreId($id);
}
/**
* Gets a user object if the user filter is set.
*
* @return JUser The JUser object
*
* @since 2.5
*/
public function getUser()
{
$user = new JUser;
// Filter by search in title
$search = (int) $this->getState('filter.user_id');
if ($search != 0)
{
$user->load((int) $search);
}
return $user;
}
/**
* 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.6
*/
protected function populateState($ordering = 'a.review_time',
$direction = 'desc')
{
// Adjust the context to support modal layouts.
if ($layout =
JFactory::getApplication()->input->get('layout'))
{
$this->context .= '.' . $layout;
}
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search'));
$this->setState('filter.published',
$this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '',
'string'));
$this->setState('filter.category_id',
$this->getUserStateFromRequest($this->context .
'.filter.category_id', 'filter_category_id'));
$this->setState('filter.user_id',
$this->getUserStateFromRequest($this->context .
'.filter.user_id', 'filter_user_id'));
$this->setState('filter.level',
$this->getUserStateFromRequest($this->context .
'.filter.level', 'filter_level', '',
'cmd'));
parent::populateState($ordering, $direction);
}
}
user.php000064400000101446151156223130006240 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
/**
* User model.
*
* @since 1.6
*/
class UsersModelUser extends JModelAdmin
{
/**
* An item.
*
* @var array
*/
protected $_item = null;
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 3.2
*/
public function __construct($config = array())
{
$config = array_merge(
array(
'event_after_delete' => 'onUserAfterDelete',
'event_after_save' => 'onUserAfterSave',
'event_before_delete' => 'onUserBeforeDelete',
'event_before_save' => 'onUserBeforeSave',
'events_map' => array('save' =>
'user', 'delete' => 'user',
'validate' => 'user')
), $config
);
parent::__construct($config);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'User', $prefix =
'JTable', $config = array())
{
$table = JTable::getInstance($type, $prefix, $config);
return $table;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
$pk = (!empty($pk)) ? $pk : (int)
$this->getState('user.id');
if ($this->_item === null)
{
$this->_item = array();
}
if (!isset($this->_item[$pk]))
{
$this->_item[$pk] = parent::getItem($pk);
}
return $this->_item[$pk];
}
/**
* Method to get the record form.
*
* @param array $data An optional array of data for the form to
interrogate.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.user', 'user',
array('control' => 'jform', 'load_data'
=> $loadData));
if (empty($form))
{
return false;
}
// If the user needs to change their password, mark the password fields
as required
if (JFactory::getUser()->requireReset)
{
$form->setFieldAttribute('password', 'required',
'true');
$form->setFieldAttribute('password2', 'required',
'true');
}
// When multilanguage is set, a user's default site language should
also be a Content Language
if (JLanguageMultilang::isEnabled())
{
$form->setFieldAttribute('language', 'type',
'frontend_language', 'params');
}
$userId = $form->getValue('id');
// The user should not be able to set the requireReset value on their own
account
if ((int) $userId === (int) JFactory::getUser()->id)
{
$form->removeField('requireReset');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_users.edit.user.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_users.profile', $data,
'user');
return $data;
}
/**
* Override JModelAdmin::preprocessForm to ensure the correct plugin group
is loaded.
*
* @param JForm $form A JForm object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @since 1.6
* @throws Exception if there is an error in the form event.
*/
protected function preprocessForm(JForm $form, $data, $group =
'user')
{
parent::preprocessForm($form, $data, $group);
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$pk = (!empty($data['id'])) ? $data['id'] : (int)
$this->getState('user.id');
$user = JUser::getInstance($pk);
$my = JFactory::getUser();
$iAmSuperAdmin = $my->authorise('core.admin');
// User cannot modify own user groups
if ((int) $user->id == (int) $my->id && !$iAmSuperAdmin
&& isset($data['groups']))
{
// Form was probably tampered with
JFactory::getApplication()->enqueueMessage(JText::_('COM_USERS_USERS_ERROR_CANNOT_EDIT_OWN_GROUP'),
'warning');
$data['groups'] = null;
}
if ($data['block'] && $pk == $my->id &&
!$my->block)
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF'));
return false;
}
// Make sure user groups is selected when add/edit an account
if (empty($data['groups']) && ((int) $user->id !=
(int) $my->id || $iAmSuperAdmin))
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_SAVE_ACCOUNT_WITHOUT_GROUPS'));
return false;
}
// Make sure that we are not removing ourself from Super Admin group
if ($iAmSuperAdmin && $my->get('id') == $pk)
{
// Check that at least one of our new groups is Super Admin
$stillSuperAdmin = false;
$myNewGroups = $data['groups'];
foreach ($myNewGroups as $group)
{
$stillSuperAdmin = $stillSuperAdmin ?: JAccess::checkGroup($group,
'core.admin');
}
if (!$stillSuperAdmin)
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_DEMOTE_SELF'));
return false;
}
}
// Handle the two factor authentication setup
if (array_key_exists('twofactor', $data))
{
$twoFactorMethod = $data['twofactor']['method'];
// Get the current One Time Password (two factor auth) configuration
$otpConfig = $this->getOtpConfig($pk);
if ($twoFactorMethod != 'none')
{
// Run the plugins
FOFPlatform::getInstance()->importPlugin('twofactorauth');
$otpConfigReplies =
FOFPlatform::getInstance()->runPlugins('onUserTwofactorApplyConfiguration',
array($twoFactorMethod));
// Look for a valid reply
foreach ($otpConfigReplies as $reply)
{
if (!is_object($reply) || empty($reply->method) ||
($reply->method != $twoFactorMethod))
{
continue;
}
$otpConfig->method = $reply->method;
$otpConfig->config = $reply->config;
break;
}
// Save OTP configuration.
$this->setOtpConfig($pk, $otpConfig);
// Generate one time emergency passwords if required (depleted or not
set)
if (empty($otpConfig->otep))
{
$oteps = $this->generateOteps($pk);
}
}
else
{
$otpConfig->method = 'none';
$otpConfig->config = array();
$this->setOtpConfig($pk, $otpConfig);
}
// Unset the raw data
unset($data['twofactor']);
// Reload the user record with the updated OTP configuration
$user->load($pk);
}
// Bind the data.
if (!$user->bind($data))
{
$this->setError($user->getError());
return false;
}
// Store the data.
if (!$user->save())
{
$this->setError($user->getError());
return false;
}
$this->setState('user.id', $user->id);
return true;
}
/**
* Method to delete rows.
*
* @param array &$pks An array of item ids.
*
* @return boolean Returns true on success, false on failure.
*
* @since 1.6
*/
public function delete(&$pks)
{
$user = JFactory::getUser();
$table = $this->getTable();
$pks = (array) $pks;
// Check if I am a Super Admin
$iAmSuperAdmin = $user->authorise('core.admin');
JPluginHelper::importPlugin($this->events_map['delete']);
$dispatcher = JEventDispatcher::getInstance();
if (in_array($user->id, $pks))
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_DELETE_SELF'));
return false;
}
// Iterate the items to delete each one.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
// Access checks.
$allow = $user->authorise('core.delete',
'com_users');
// Don't allow non-super-admin to delete a super admin
$allow = (!$iAmSuperAdmin && JAccess::check($pk,
'core.admin')) ? false : $allow;
if ($allow)
{
// Get users data for the users to delete.
$user_to_delete = JFactory::getUser($pk);
// Fire the before delete event.
$dispatcher->trigger($this->event_before_delete,
array($table->getProperties()));
if (!$table->delete($pk))
{
$this->setError($table->getError());
return false;
}
else
{
// Trigger the after delete event.
$dispatcher->trigger($this->event_after_delete,
array($user_to_delete->getProperties(), true, $this->getError()));
}
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
}
}
else
{
$this->setError($table->getError());
return false;
}
}
return true;
}
/**
* Method to block user records.
*
* @param array &$pks The ids of the items to publish.
* @param integer $value The value of the published state
*
* @return boolean True on success.
*
* @since 1.6
*/
public function block(&$pks, $value = 1)
{
$app = JFactory::getApplication();
$dispatcher = JEventDispatcher::getInstance();
$user = JFactory::getUser();
// Check if I am a Super Admin
$iAmSuperAdmin = $user->authorise('core.admin');
$table = $this->getTable();
$pks = (array) $pks;
JPluginHelper::importPlugin($this->events_map['save']);
// Prepare the logout options.
$options = array(
'clientid' => $app->get('shared_session',
'0') ? null : 0,
);
// Access checks.
foreach ($pks as $i => $pk)
{
if ($value == 1 && $pk == $user->get('id'))
{
// Cannot block yourself.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF'));
}
elseif ($table->load($pk))
{
$old = $table->getProperties();
$allow = $user->authorise('core.edit.state',
'com_users');
// Don't allow non-super-admin to delete a super admin
$allow = (!$iAmSuperAdmin && JAccess::check($pk,
'core.admin')) ? false : $allow;
if ($allow)
{
// Skip changing of same state
if ($table->block == $value)
{
unset($pks[$i]);
continue;
}
$table->block = (int) $value;
// If unblocking, also change password reset count to zero to unblock
reset
if ($table->block === 0)
{
$table->resetCount = 0;
}
// Allow an exception to be thrown.
try
{
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Trigger the before save event.
$result = $dispatcher->trigger($this->event_before_save,
array($old, false, $table->getProperties()));
if (in_array(false, $result, true))
{
// Plugin will have to raise its own error or throw an exception.
return false;
}
// Store the table.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Trigger the after save event
$dispatcher->trigger($this->event_after_save,
array($table->getProperties(), false, true, null));
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
// Log the user out.
if ($value)
{
$app->logout($table->id, $options);
}
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
}
}
return true;
}
/**
* Method to activate user records.
*
* @param array &$pks The ids of the items to activate.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function activate(&$pks)
{
$dispatcher = JEventDispatcher::getInstance();
$user = JFactory::getUser();
// Check if I am a Super Admin
$iAmSuperAdmin = $user->authorise('core.admin');
$table = $this->getTable();
$pks = (array) $pks;
JPluginHelper::importPlugin($this->events_map['save']);
// Access checks.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
$old = $table->getProperties();
$allow = $user->authorise('core.edit.state',
'com_users');
// Don't allow non-super-admin to delete a super admin
$allow = (!$iAmSuperAdmin && JAccess::check($pk,
'core.admin')) ? false : $allow;
if (empty($table->activation))
{
// Ignore activated accounts.
unset($pks[$i]);
}
elseif ($allow)
{
$table->block = 0;
$table->activation = '';
// Allow an exception to be thrown.
try
{
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Trigger the before save event.
$result = $dispatcher->trigger($this->event_before_save,
array($old, false, $table->getProperties()));
if (in_array(false, $result, true))
{
// Plugin will have to raise it's own error or throw an
exception.
return false;
}
// Store the table.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Fire the after save event
$dispatcher->trigger($this->event_after_save,
array($table->getProperties(), false, true, null));
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
}
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 2.5
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize user ids.
$pks = array_unique($pks);
$pks = ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('COM_USERS_USERS_NO_ITEM_SELECTED'));
return false;
}
$done = false;
if (!empty($commands['group_id']))
{
$cmd = ArrayHelper::getValue($commands, 'group_action',
'add');
if (!$this->batchUser((int) $commands['group_id'], $pks,
$cmd))
{
return false;
}
$done = true;
}
if (!empty($commands['reset_id']))
{
if (!$this->batchReset($pks, $commands['reset_id']))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch flag users as being required to reset their passwords
*
* @param array $userIds An array of user IDs on which to operate
* @param string $action The action to perform
*
* @return boolean True on success, false on failure
*
* @since 3.2
*/
public function batchReset($userIds, $action)
{
$userIds = ArrayHelper::toInteger($userIds);
// Check if I am a Super Admin
$iAmSuperAdmin =
JFactory::getUser()->authorise('core.admin');
// Non-super super user cannot work with super-admin user.
if (!$iAmSuperAdmin &&
JUserHelper::checkSuperUserInUsers($userIds))
{
$this->setError(JText::_('COM_USERS_ERROR_CANNOT_BATCH_SUPERUSER'));
return false;
}
// Set the action to perform
if ($action === 'yes')
{
$value = 1;
}
else
{
$value = 0;
}
// Prune out the current user if they are in the supplied user ID array
$userIds = array_diff($userIds, array(JFactory::getUser()->id));
if (empty($userIds))
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_REQUIRERESET_SELF'));
return false;
}
// Get the DB object
$db = $this->getDbo();
$userIds = ArrayHelper::toInteger($userIds);
$query = $db->getQuery(true);
// Update the reset flag
$query->update($db->quoteName('#__users'))
->set($db->quoteName('requireReset') . ' = ' .
$value)
->where($db->quoteName('id') . ' IN (' .
implode(',', $userIds) . ')');
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
return true;
}
/**
* Perform batch operations
*
* @param integer $groupId The group ID which assignments are being
edited
* @param array $userIds An array of user IDs on which to operate
* @param string $action The action to perform
*
* @return boolean True on success, false on failure
*
* @since 1.6
*/
public function batchUser($groupId, $userIds, $action)
{
$userIds = ArrayHelper::toInteger($userIds);
// Check if I am a Super Admin
$iAmSuperAdmin =
JFactory::getUser()->authorise('core.admin');
// Non-super super user cannot work with super-admin user.
if (!$iAmSuperAdmin &&
JUserHelper::checkSuperUserInUsers($userIds))
{
$this->setError(JText::_('COM_USERS_ERROR_CANNOT_BATCH_SUPERUSER'));
return false;
}
// Non-super admin cannot work with super-admin group.
if ((!$iAmSuperAdmin && JAccess::checkGroup($groupId,
'core.admin')) || $groupId < 1)
{
$this->setError(JText::_('COM_USERS_ERROR_INVALID_GROUP'));
return false;
}
// Get the DB object
$db = $this->getDbo();
switch ($action)
{
// Sets users to a selected group
case 'set':
$doDelete = 'all';
$doAssign = true;
break;
// Remove users from a selected group
case 'del':
$doDelete = 'group';
break;
// Add users to a selected group
case 'add':
default:
$doAssign = true;
break;
}
// Remove the users from the group if requested.
if (isset($doDelete))
{
$query = $db->getQuery(true);
// Remove users from the group
$query->delete($db->quoteName('#__user_usergroup_map'))
->where($db->quoteName('user_id') . ' IN (' .
implode(',', $userIds) . ')');
// Only remove users from selected group
if ($doDelete == 'group')
{
$query->where($db->quoteName('group_id') . ' =
' . (int) $groupId);
}
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
// Assign the users to the group if requested.
if (isset($doAssign))
{
$query = $db->getQuery(true);
// First, we need to check if the user is already assigned to a group
$query->select($db->quoteName('user_id'))
->from($db->quoteName('#__user_usergroup_map'))
->where($db->quoteName('group_id') . ' = ' .
(int) $groupId);
$db->setQuery($query);
$users = $db->loadColumn();
// Build the values clause for the assignment query.
$query->clear();
$groups = false;
foreach ($userIds as $id)
{
if (!in_array($id, $users))
{
$query->values($id . ',' . $groupId);
$groups = true;
}
}
// If we have no users to process, throw an error to notify the user
if (!$groups)
{
$this->setError(JText::_('COM_USERS_ERROR_NO_ADDITIONS'));
return false;
}
$query->insert($db->quoteName('#__user_usergroup_map'))
->columns(array($db->quoteName('user_id'),
$db->quoteName('group_id')));
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
return true;
}
/**
* Gets the available groups.
*
* @return array An array of groups
*
* @since 1.6
*/
public function getGroups()
{
$user = JFactory::getUser();
if ($user->authorise('core.edit', 'com_users')
&& $user->authorise('core.manage',
'com_users'))
{
$model = JModelLegacy::getInstance('Groups',
'UsersModel', array('ignore_request' => true));
return $model->getItems();
}
else
{
return null;
}
}
/**
* Gets the groups this object is assigned to
*
* @param integer $userId The user ID to retrieve the groups for
*
* @return array An array of assigned groups
*
* @since 1.6
*/
public function getAssignedGroups($userId = null)
{
$userId = (!empty($userId)) ? $userId : (int)
$this->getState('user.id');
if (empty($userId))
{
$result = array();
$form = $this->getForm();
if ($form)
{
$groupsIDs = $form->getValue('groups');
}
if (!empty($groupsIDs))
{
$result = $groupsIDs;
}
else
{
$params = JComponentHelper::getParams('com_users');
if ($groupId = $params->get('new_usertype',
$params->get('guest_usergroup', 1)))
{
$result[] = $groupId;
}
}
}
else
{
$result = JUserHelper::getUserGroups($userId);
}
return $result;
}
/**
* Returns the one time password (OTP) – a.k.a. two factor
authentication –
* configuration for a particular user.
*
* @param integer $userId The numeric ID of the user
*
* @return stdClass An object holding the OTP configuration for this
user
*
* @since 3.2
*/
public function getOtpConfig($userId = null)
{
$userId = (!empty($userId)) ? $userId : (int)
$this->getState('user.id');
// Initialise
$otpConfig = (object) array(
'method' => 'none',
'config' => array(),
'otep' => array()
);
/**
* Get the raw data, without going through JUser (required in order to
* be able to modify the user record before logging in the user).
*/
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('*')
->from($db->qn('#__users'))
->where($db->qn('id') . ' = ' . (int)
$userId);
$db->setQuery($query);
$item = $db->loadObject();
// Make sure this user does have OTP enabled
if (empty($item->otpKey))
{
return $otpConfig;
}
// Get the encrypted data
list($method, $config) = explode(':', $item->otpKey, 2);
$encryptedOtep = $item->otep;
// Get the secret key, yes the thing that is saved in the configuration
file
$key = $this->getOtpConfigEncryptionKey();
if (strpos($config, '{') === false)
{
$openssl = new FOFEncryptAes($key, 256);
$mcrypt = new FOFEncryptAes($key, 256, 'cbc', null,
'mcrypt');
$decryptedConfig = $mcrypt->decryptString($config);
if (strpos($decryptedConfig, '{') !== false)
{
// Data encrypted with mcrypt
$decryptedOtep = $mcrypt->decryptString($encryptedOtep);
$encryptedOtep = $openssl->encryptString($decryptedOtep);
}
else
{
// Config data seems to be save encrypted, this can happen with 3.6.3
and openssl, lets get the data
$decryptedConfig = $openssl->decryptString($config);
}
$otpKey = $method . ':' . $decryptedConfig;
$query = $db->getQuery(true)
->update($db->qn('#__users'))
->set($db->qn('otep') . '=' .
$db->q($encryptedOtep))
->set($db->qn('otpKey') . '=' .
$db->q($otpKey))
->where($db->qn('id') . ' = ' .
$db->q($userId));
$db->setQuery($query);
$db->execute();
}
else
{
$decryptedConfig = $config;
}
// Create an encryptor class
$aes = new FOFEncryptAes($key, 256);
// Decrypt the data
$decryptedOtep = $aes->decryptString($encryptedOtep);
// Remove the null padding added during encryption
$decryptedConfig = rtrim($decryptedConfig, "\0");
$decryptedOtep = rtrim($decryptedOtep, "\0");
// Update the configuration object
$otpConfig->method = $method;
$otpConfig->config = @json_decode($decryptedConfig);
$otpConfig->otep = @json_decode($decryptedOtep);
/*
* If the decryption failed for any reason we essentially disable the
* two-factor authentication. This prevents impossible to log in sites
* if the site admin changes the site secret for any reason.
*/
if (is_null($otpConfig->config))
{
$otpConfig->config = array();
}
if (is_object($otpConfig->config))
{
$otpConfig->config = (array) $otpConfig->config;
}
if (is_null($otpConfig->otep))
{
$otpConfig->otep = array();
}
if (is_object($otpConfig->otep))
{
$otpConfig->otep = (array) $otpConfig->otep;
}
// Return the configuration object
return $otpConfig;
}
/**
* Sets the one time password (OTP) – a.k.a. two factor authentication
–
* configuration for a particular user. The $otpConfig object is the same
as
* the one returned by the getOtpConfig method.
*
* @param integer $userId The numeric ID of the user
* @param stdClass $otpConfig The OTP configuration object
*
* @return boolean True on success
*
* @since 3.2
*/
public function setOtpConfig($userId, $otpConfig)
{
$userId = (!empty($userId)) ? $userId : (int)
$this->getState('user.id');
$updates = (object) array(
'id' => $userId,
'otpKey' => '',
'otep' => ''
);
// Create an encryptor class
$key = $this->getOtpConfigEncryptionKey();
$aes = new FOFEncryptAes($key, 256);
// Create the encrypted option strings
if (!empty($otpConfig->method) && ($otpConfig->method !=
'none'))
{
$decryptedConfig = json_encode($otpConfig->config);
$decryptedOtep = json_encode($otpConfig->otep);
$updates->otpKey = $otpConfig->method . ':' .
$decryptedConfig;
$updates->otep = $aes->encryptString($decryptedOtep);
}
$db = $this->getDbo();
$result = $db->updateObject('#__users', $updates,
'id');
return $result;
}
/**
* Gets the symmetric encryption key for the OTP configuration data. It
* currently returns the site's secret.
*
* @return string The encryption key
*
* @since 3.2
*/
public function getOtpConfigEncryptionKey()
{
return JFactory::getConfig()->get('secret');
}
/**
* Gets the configuration forms for all two-factor authentication methods
* in an array.
*
* @param integer $userId The user ID to load the forms for (optional)
*
* @return array
*
* @since 3.2
*/
public function getTwofactorform($userId = null)
{
$userId = (!empty($userId)) ? $userId : (int)
$this->getState('user.id');
$otpConfig = $this->getOtpConfig($userId);
FOFPlatform::getInstance()->importPlugin('twofactorauth');
return
FOFPlatform::getInstance()->runPlugins('onUserTwofactorShowConfiguration',
array($otpConfig, $userId));
}
/**
* Generates a new set of One Time Emergency Passwords (OTEPs) for a given
user.
*
* @param integer $userId The user ID
* @param integer $count How many OTEPs to generate? Default: 10
*
* @return array The generated OTEPs
*
* @since 3.2
*/
public function generateOteps($userId, $count = 10)
{
$userId = (!empty($userId)) ? $userId : (int)
$this->getState('user.id');
// Initialise
$oteps = array();
// Get the OTP configuration for the user
$otpConfig = $this->getOtpConfig($userId);
// If two factor authentication is not enabled, abort
if (empty($otpConfig->method) || ($otpConfig->method ==
'none'))
{
return $oteps;
}
$salt = '0123456789';
$base = strlen($salt);
$length = 16;
for ($i = 0; $i < $count; $i++)
{
$makepass = '';
$random = JCrypt::genRandomBytes($length + 1);
$shift = ord($random[0]);
for ($j = 1; $j <= $length; ++$j)
{
$makepass .= $salt[($shift + ord($random[$j])) % $base];
$shift += ord($random[$j]);
}
$oteps[] = $makepass;
}
$otpConfig->otep = $oteps;
// Save the now modified OTP configuration
$this->setOtpConfig($userId, $otpConfig);
return $oteps;
}
/**
* Checks if the provided secret key is a valid two factor authentication
* secret key. If not, it will check it against the list of one time
* emergency passwords (OTEPs). If it's a valid OTEP it will also
remove it
* from the user's list of OTEPs.
*
* This method will return true in the following conditions:
* - The two factor authentication is not enabled
* - You have provided a valid secret key for
* - You have provided a valid OTEP
*
* You can define the following options in the $options array:
* otp_config The OTP (one time password, a.k.a. two factor auth)
* configuration object. If not set we'll load it
automatically.
* warn_if_not_req Issue a warning if you are checking a secret key
against
* a user account which doesn't have any two factor
* authentication method enabled.
* warn_irq_msg The string to use for the warn_if_not_req warning
*
* @param integer $userId The user's numeric ID
* @param string $secretKey The secret key you want to check
* @param array $options Options; see above
*
* @return boolean True if it's a valid secret key for this user.
*
* @since 3.2
*/
public function isValidSecretKey($userId, $secretKey, $options = array())
{
// Load the user's OTP (one time password, a.k.a. two factor auth)
configuration
if (!array_key_exists('otp_config', $options))
{
$otpConfig = $this->getOtpConfig($userId);
$options['otp_config'] = $otpConfig;
}
else
{
$otpConfig = $options['otp_config'];
}
// Check if the user has enabled two factor authentication
if (empty($otpConfig->method) || ($otpConfig->method ==
'none'))
{
// Load language
$lang = JFactory::getLanguage();
$extension = 'com_users';
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load($extension, JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load($extension, $source, null, false, true);
$warn = true;
$warnMessage =
JText::_('COM_USERS_ERROR_SECRET_CODE_WITHOUT_TFA');
if (array_key_exists('warn_if_not_req', $options))
{
$warn = $options['warn_if_not_req'];
}
if (array_key_exists('warn_irq_msg', $options))
{
$warnMessage = $options['warn_irq_msg'];
}
// Warn the user if they are using a secret code but they have not
// enabled two factor auth in their account.
if (!empty($secretKey) && $warn)
{
try
{
$app = JFactory::getApplication();
$app->enqueueMessage($warnMessage, 'warning');
}
catch (Exception $exc)
{
// This happens when we are in CLI mode. In this case
// no warning is issued
return true;
}
}
return true;
}
$credentials = array(
'secretkey' => $secretKey,
);
// Try to validate the OTP
FOFPlatform::getInstance()->importPlugin('twofactorauth');
$otpAuthReplies =
FOFPlatform::getInstance()->runPlugins('onUserTwofactorAuthenticate',
array($credentials, $options));
$check = false;
/*
* This looks like noob code but DO NOT TOUCH IT and do not convert
* to in_array(). During testing in_array() inexplicably returned
* null when the OTEP begins with a zero! o_O
*/
if (!empty($otpAuthReplies))
{
foreach ($otpAuthReplies as $authReply)
{
$check = $check || $authReply;
}
}
// Fall back to one time emergency passwords
if (!$check)
{
$check = $this->isValidOtep($userId, $secretKey, $otpConfig);
}
return $check;
}
/**
* Checks if the supplied string is a valid one time emergency password
* (OTEP) for this user. If it is it will be automatically removed from
the
* user's list of OTEPs.
*
* @param integer $userId The user ID against which you are
checking
* @param string $otep The string you want to test for validity
* @param object $otpConfig Optional; the two factor authentication
configuration (automatically fetched if not set)
*
* @return boolean True if it's a valid OTEP or if two factor auth
is not
* enabled in this user's account.
*
* @since 3.2
*/
public function isValidOtep($userId, $otep, $otpConfig = null)
{
if (is_null($otpConfig))
{
$otpConfig = $this->getOtpConfig($userId);
}
// Did the user use an OTEP instead?
if (empty($otpConfig->otep))
{
if (empty($otpConfig->method) || ($otpConfig->method ==
'none'))
{
// Two factor authentication is not enabled on this account.
// Any string is assumed to be a valid OTEP.
return true;
}
else
{
/**
* Two factor authentication enabled and no OTEPs defined. The
* user has used them all up. Therefore anything they enter is
* an invalid OTEP.
*/
return false;
}
}
// Clean up the OTEP (remove dashes, spaces and other funny stuff
// our beloved users may have unwittingly stuffed in it)
$otep = filter_var($otep, FILTER_SANITIZE_NUMBER_INT);
$otep = str_replace('-', '', $otep);
$check = false;
// Did we find a valid OTEP?
if (in_array($otep, $otpConfig->otep))
{
// Remove the OTEP from the array
$otpConfig->otep = array_diff($otpConfig->otep, array($otep));
$this->setOtpConfig($userId, $otpConfig);
// Return true; the OTEP was a valid one
$check = true;
}
return $check;
}
}
users.php000064400000032004151156223130006414 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Methods supporting a list of user records.
*
* @since 1.6
*/
class UsersModelUsers extends JModelList
{
/**
* A blacklist of filter variables to not merge into the model's
state
*
* @var array
*/
protected $filterBlacklist = array('groups',
'excluded');
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'name', 'a.name',
'username', 'a.username',
'email', 'a.email',
'block', 'a.block',
'sendEmail', 'a.sendEmail',
'registerDate', 'a.registerDate',
'lastvisitDate', 'a.lastvisitDate',
'activation', 'a.activation',
'active',
'group_id',
'range',
'lastvisitrange',
'state',
);
}
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.6
*/
protected function populateState($ordering = 'a.name',
$direction = 'asc')
{
$app = JFactory::getApplication('administrator');
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout',
'default', 'cmd'))
{
$this->context .= '.' . $layout;
}
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.active',
$this->getUserStateFromRequest($this->context .
'.filter.active', 'filter_active', '',
'cmd'));
$this->setState('filter.state',
$this->getUserStateFromRequest($this->context .
'.filter.state', 'filter_state', '',
'cmd'));
$this->setState('filter.group_id',
$this->getUserStateFromRequest($this->context .
'.filter.group_id', 'filter_group_id', null,
'int'));
$this->setState('filter.range',
$this->getUserStateFromRequest($this->context .
'.filter.range', 'filter_range', '',
'cmd'));
$this->setState(
'filter.lastvisitrange',
$this->getUserStateFromRequest($this->context .
'.filter.lastvisitrange', 'filter_lastvisitrange',
'', 'cmd')
);
$groups =
json_decode(base64_decode($app->input->get('groups',
'', 'BASE64')));
if (isset($groups))
{
$groups = ArrayHelper::toInteger($groups);
}
$this->setState('filter.groups', $groups);
$excluded =
json_decode(base64_decode($app->input->get('excluded',
'', 'BASE64')));
if (isset($excluded))
{
$excluded = ArrayHelper::toInteger($excluded);
}
$this->setState('filter.excluded', $excluded);
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.active');
$id .= ':' . $this->getState('filter.state');
$id .= ':' . $this->getState('filter.group_id');
$id .= ':' . $this->getState('filter.range');
return parent::getStoreId($id);
}
/**
* Gets the list of users and adds expensive joins to the result set.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 1.6
*/
public function getItems()
{
// Get a storage key.
$store = $this->getStoreId();
// Try to load the data from internal storage.
if (empty($this->cache[$store]))
{
$groups = $this->getState('filter.groups');
$groupId = $this->getState('filter.group_id');
if (isset($groups) && (empty($groups) || $groupId &&
!in_array($groupId, $groups)))
{
$items = array();
}
else
{
$items = parent::getItems();
}
// Bail out on an error or empty list.
if (empty($items))
{
$this->cache[$store] = $items;
return $items;
}
// Joining the groups with the main query is a performance hog.
// Find the information only on the result set.
// First pass: get list of the user id's and reset the counts.
$userIds = array();
foreach ($items as $item)
{
$userIds[] = (int) $item->id;
$item->group_count = 0;
$item->group_names = '';
$item->note_count = 0;
}
// Get the counts from the database only for the users in the list.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Join over the group mapping table.
$query->select('map.user_id, COUNT(map.group_id) AS
group_count')
->from('#__user_usergroup_map AS map')
->where('map.user_id IN (' . implode(',',
$userIds) . ')')
->group('map.user_id')
// Join over the user groups table.
->join('LEFT', '#__usergroups AS g2 ON g2.id =
map.group_id');
$db->setQuery($query);
// Load the counts into an array indexed on the user id field.
try
{
$userGroups = $db->loadObjectList('user_id');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
$query->clear()
->select('n.user_id, COUNT(n.id) As note_count')
->from('#__user_notes AS n')
->where('n.user_id IN (' . implode(',',
$userIds) . ')')
->where('n.state >= 0')
->group('n.user_id');
$db->setQuery($query);
// Load the counts into an array indexed on the aro.value field (the
user id).
try
{
$userNotes = $db->loadObjectList('user_id');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Second pass: collect the group counts into the master items array.
foreach ($items as &$item)
{
if (isset($userGroups[$item->id]))
{
$item->group_count = $userGroups[$item->id]->group_count;
// Group_concat in other databases is not supported
$item->group_names =
$this->_getUserDisplayedGroups($item->id);
}
if (isset($userNotes[$item->id]))
{
$item->note_count = $userNotes[$item->id]->note_count;
}
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
}
return $this->cache[$store];
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from($db->quoteName('#__users') . ' AS
a');
// If the model is set to check item state, add to the query.
$state = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where('a.block = ' . (int) $state);
}
// If the model is set to check the activated state, add to the query.
$active = $this->getState('filter.active');
if (is_numeric($active))
{
if ($active == '0')
{
$query->where('a.activation IN (' .
$db->quote('') . ', ' . $db->quote('0')
. ')');
}
elseif ($active == '1')
{
$query->where($query->length('a.activation') . '
> 1');
}
}
// Filter the items over the group id if set.
$groupId = $this->getState('filter.group_id');
$groups = $this->getState('filter.groups');
if ($groupId || isset($groups))
{
$query->join('LEFT', '#__user_usergroup_map AS map2 ON
map2.user_id = a.id')
->group(
$db->quoteName(
array(
'a.id',
'a.name',
'a.username',
'a.password',
'a.block',
'a.sendEmail',
'a.registerDate',
'a.lastvisitDate',
'a.activation',
'a.params',
'a.email'
)
)
);
if ($groupId)
{
$query->where('map2.group_id = ' . (int) $groupId);
}
if (isset($groups))
{
$query->where('map2.group_id IN (' .
implode(',', $groups) . ')');
}
}
// Filter the items over the search string if set.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
elseif (stripos($search, 'username:') === 0)
{
$search = $db->quote('%' . $db->escape(substr($search,
9), true) . '%');
$query->where('a.username LIKE ' . $search);
}
else
{
// Escape the search token.
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
// Compile the different search clauses.
$searches = array();
$searches[] = 'a.name LIKE ' . $search;
$searches[] = 'a.username LIKE ' . $search;
$searches[] = 'a.email LIKE ' . $search;
// Add the clauses to the query.
$query->where('(' . implode(' OR ', $searches) .
')');
}
}
// Add filter for registration ranges select list
$range = $this->getState('filter.range');
// Apply the range filter.
if ($range)
{
$dates = $this->buildDateRange($range);
if ($dates['dNow'] === false)
{
$query->where(
$db->qn('a.registerDate') . ' < ' .
$db->quote($dates['dStart']->format('Y-m-d
H:i:s'))
);
}
else
{
$query->where(
$db->qn('a.registerDate') . ' >= ' .
$db->quote($dates['dStart']->format('Y-m-d
H:i:s')) .
' AND ' . $db->qn('a.registerDate') . '
<= ' .
$db->quote($dates['dNow']->format('Y-m-d H:i:s'))
);
}
}
// Add filter for registration ranges select list
$lastvisitrange = $this->getState('filter.lastvisitrange');
// Apply the range filter.
if ($lastvisitrange)
{
$dates = $this->buildDateRange($lastvisitrange);
if (is_string($dates['dStart']))
{
$query->where(
$db->qn('a.lastvisitDate') . ' = ' .
$db->quote($dates['dStart'])
);
}
elseif ($dates['dNow'] === false)
{
$query->where(
$db->qn('a.lastvisitDate') . ' < ' .
$db->quote($dates['dStart']->format('Y-m-d
H:i:s'))
);
}
else
{
$query->where(
$db->qn('a.lastvisitDate') . ' >= ' .
$db->quote($dates['dStart']->format('Y-m-d
H:i:s')) .
' AND ' . $db->qn('a.lastvisitDate') . '
<= ' .
$db->quote($dates['dNow']->format('Y-m-d H:i:s'))
);
}
}
// Filter by excluded users
$excluded = $this->getState('filter.excluded');
if (!empty($excluded))
{
$query->where('id NOT IN (' . implode(',',
$excluded) . ')');
}
// Add the list ordering clause.
$query->order($db->qn($db->escape($this->getState('list.ordering',
'a.name'))) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Construct the date range to filter on.
*
* @param string $range The textual range to construct the filter for.
*
* @return string The date range to filter on.
*
* @since 3.6.0
*/
private function buildDateRange($range)
{
// Get UTC for now.
$dNow = new JDate;
$dStart = clone $dNow;
switch ($range)
{
case 'past_week':
$dStart->modify('-7 day');
break;
case 'past_1month':
$dStart->modify('-1 month');
break;
case 'past_3month':
$dStart->modify('-3 month');
break;
case 'past_6month':
$dStart->modify('-6 month');
break;
case 'post_year':
$dNow = false;
case 'past_year':
$dStart->modify('-1 year');
break;
case 'today':
// Ranges that need to align with local 'days' need special
treatment.
$app = JFactory::getApplication();
$offset = $app->get('offset');
// Reset the start time to be the beginning of today, local time.
$dStart = new JDate('now', $offset);
$dStart->setTime(0, 0, 0);
// Now change the timezone back to UTC.
$tz = new DateTimeZone('GMT');
$dStart->setTimezone($tz);
break;
case 'never':
$dNow = false;
$dStart = $this->_db->getNullDate();
break;
}
return array('dNow' => $dNow, 'dStart' =>
$dStart);
}
/**
* SQL server change
*
* @param integer $userId User identifier
*
* @return string Groups titles imploded :$
*/
protected function _getUserDisplayedGroups($userId)
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select($db->qn('title'))
->from($db->qn('#__usergroups', 'ug'))
->join('LEFT',
$db->qn('#__user_usergroup_map', 'map') . ' ON
(ug.id = map.group_id)')
->where($db->qn('map.user_id') . ' = ' . (int)
$userId);
try
{
$result = $db->setQuery($query)->loadColumn();
}
catch (RunTimeException $e)
{
$result = array();
}
return implode("\n", $result);
}
}
cache.php000064400000014561151156427250006337 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\Utilities\ArrayHelper;
/**
* Cache Model
*
* @since 1.6
*/
class CacheModelCache extends JModelList
{
/**
* An Array of CacheItems indexed by cache group ID
*
* @var Array
*/
protected $_data = array();
/**
* Group total
*
* @var integer
*/
protected $_total = null;
/**
* Pagination object
*
* @var object
*/
protected $_pagination = null;
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 3.5
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'group',
'count',
'size',
'client_id',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering Field for ordering.
* @param string $direction Direction of ordering.
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = 'group', $direction
= 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
// Special case for client id.
$clientId = (int) $this->getUserStateFromRequest($this->context .
'.client_id', 'client_id', 0, 'int');
$clientId = (!in_array($clientId, array (0, 1))) ? 0 : $clientId;
$this->setState('client_id', $clientId);
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 3.5
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('client_id');
$id .= ':' . $this->getState('filter.search');
return parent::getStoreId($id);
}
/**
* Method to get cache data
*
* @return array
*/
public function getData()
{
if (empty($this->_data))
{
try
{
$cache = $this->getCache();
$data = $cache->getAll();
if ($data && count($data) > 0)
{
// Process filter by search term.
if ($search = $this->getState('filter.search'))
{
foreach ($data as $key => $cacheItem)
{
if (stripos($cacheItem->group, $search) === false)
{
unset($data[$key]);
continue;
}
}
}
// Process ordering.
$listOrder = $this->getState('list.ordering',
'group');
$listDirn = $this->getState('list.direction',
'ASC');
$this->_data = ArrayHelper::sortObjects($data, $listOrder,
strtolower($listDirn) === 'desc' ? -1 : 1, true, true);
// Process pagination.
$limit = (int) $this->getState('list.limit', 25);
if ($limit !== 0)
{
$start = (int) $this->getState('list.start', 0);
return array_slice($this->_data, $start, $limit);
}
}
else
{
$this->_data = array();
}
}
catch (JCacheExceptionConnecting $exception)
{
$this->setError(JText::_('COM_CACHE_ERROR_CACHE_CONNECTION_FAILED'));
$this->_data = array();
}
catch (JCacheExceptionUnsupported $exception)
{
$this->setError(JText::_('COM_CACHE_ERROR_CACHE_DRIVER_UNSUPPORTED'));
$this->_data = array();
}
}
return $this->_data;
}
/**
* Method to get cache instance.
*
* @return JCacheController
*/
public function getCache($clientId = null)
{
$conf = JFactory::getConfig();
if (is_null($clientId))
{
$clientId = $this->getState('client_id');
}
$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler',
''),
'caching' => true,
'cachebase' => (int) $clientId === 1 ?
JPATH_ADMINISTRATOR . '/cache' :
$conf->get('cache_path', JPATH_SITE . '/cache')
);
return JCache::getInstance('', $options);
}
/**
* Method to get client data.
*
* @return array
*
* @deprecated 4.0 No replacement.
*/
public function getClient()
{
return
JApplicationHelper::getClientInfo($this->getState('client_id',
0));
}
/**
* Get the number of current Cache Groups.
*
* @return integer
*/
public function getTotal()
{
if (empty($this->_total))
{
$this->_total = count($this->getData());
}
return $this->_total;
}
/**
* Method to get a pagination object for the cache.
*
* @return JPagination
*/
public function getPagination()
{
if (empty($this->_pagination))
{
$this->_pagination = new JPagination($this->getTotal(),
$this->getState('list.start'),
$this->getState('list.limit'));
}
return $this->_pagination;
}
/**
* Clean out a cache group as named by param.
* If no param is passed clean all cache groups.
*
* @param string $group Cache group name.
*
* @return boolean True on success, false otherwise
*/
public function clean($group = '')
{
try
{
$this->getCache()->clean($group);
}
catch (JCacheExceptionConnecting $exception)
{
return false;
}
catch (JCacheExceptionUnsupported $exception)
{
return false;
}
Factory::getApplication()->triggerEvent('onAfterPurge',
array($group));
return true;
}
/**
* Purge an array of cache groups.
*
* @param array $array Array of cache group names.
*
* @return array Array with errors, if they exist.
*/
public function cleanlist($array)
{
$errors = array();
foreach ($array as $group)
{
if (!$this->clean($group))
{
$errors[] = $group;
}
}
return $errors;
}
/**
* Purge all cache items.
*
* @return boolean True if successful; false otherwise.
*/
public function purge()
{
try
{
JFactory::getCache('')->gc();
}
catch (JCacheExceptionConnecting $exception)
{
return false;
}
catch (JCacheExceptionUnsupported $exception)
{
return false;
}
Factory::getApplication()->triggerEvent('onAfterPurge',
array());
return true;
}
}
forms/filter_cache.xml000064400000002630151156427250011035 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<field
name="client_id"
type="list"
onchange="jQuery('#filter_search, select[id^=filter_],
#list_fullordering').val('');this.form.submit();"
filtermode="selector"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
</field>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_CACHE_FILTER_SEARCH_LABEL"
description="COM_CACHE_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
noresults="JGLOBAL_NO_MATCHING_RESULTS"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="group ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="group
ASC">COM_CACHE_HEADING_GROUP_ASC</option>
<option value="group
DESC">COM_CACHE_HEADING_GROUP_DESC</option>
<option value="count
ASC">COM_CACHE_HEADING_COUNT_ASC</option>
<option value="count
DESC">COM_CACHE_HEADING_COUNT_DESC</option>
<option value="size
ASC">COM_CACHE_HEADING_SIZE_ASC</option>
<option value="size
DESC">COM_CACHE_HEADING_SIZE_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
fields/redirect.php000064400000007452151156604450010343 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_redirect
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* A dropdown containing all valid HTTP 1.1 response codes.
*
* @package Joomla.Administrator
* @subpackage com_redirect
* @since 3.4
*/
class JFormFieldRedirect extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.4
*/
protected $type = 'Redirect';
/**
* A map of integer HTTP 1.1 response codes to the full HTTP Status for
the headers.
*
* @var object
* @since 3.4
* @link http://www.iana.org/assignments/http-status-codes/
*/
protected $responseMap = array(
100 => 'HTTP/1.1 100 Continue',
101 => 'HTTP/1.1 101 Switching Protocols',
102 => 'HTTP/1.1 102 Processing',
200 => 'HTTP/1.1 200 OK',
201 => 'HTTP/1.1 201 Created',
202 => 'HTTP/1.1 202 Accepted',
203 => 'HTTP/1.1 203 Non-Authoritative Information',
204 => 'HTTP/1.1 204 No Content',
205 => 'HTTP/1.1 205 Reset Content',
206 => 'HTTP/1.1 206 Partial Content',
207 => 'HTTP/1.1 207 Multi-Status',
208 => 'HTTP/1.1 208 Already Reported',
226 => 'HTTP/1.1 226 IM Used',
300 => 'HTTP/1.1 300 Multiple Choices',
301 => 'HTTP/1.1 301 Moved Permanently',
302 => 'HTTP/1.1 302 Found',
303 => 'HTTP/1.1 303 See other',
304 => 'HTTP/1.1 304 Not Modified',
305 => 'HTTP/1.1 305 Use Proxy',
306 => 'HTTP/1.1 306 (Unused)',
307 => 'HTTP/1.1 307 Temporary Redirect',
308 => 'HTTP/1.1 308 Permanent Redirect',
400 => 'HTTP/1.1 400 Bad Request',
401 => 'HTTP/1.1 401 Unauthorized',
402 => 'HTTP/1.1 402 Payment Required',
403 => 'HTTP/1.1 403 Forbidden',
404 => 'HTTP/1.1 404 Not Found',
405 => 'HTTP/1.1 405 Method Not Allowed',
406 => 'HTTP/1.1 406 Not Acceptable',
407 => 'HTTP/1.1 407 Proxy Authentication Required',
408 => 'HTTP/1.1 408 Request Timeout',
409 => 'HTTP/1.1 409 Conflict',
410 => 'HTTP/1.1 410 Gone',
411 => 'HTTP/1.1 411 Length Required',
412 => 'HTTP/1.1 412 Precondition Failed',
413 => 'HTTP/1.1 413 Payload Too Large',
414 => 'HTTP/1.1 414 URI Too Long',
415 => 'HTTP/1.1 415 Unsupported Media Type',
416 => 'HTTP/1.1 416 Requested Range Not Satisfiable',
417 => 'HTTP/1.1 417 Expectation Failed',
418 => 'HTTP/1.1 418 I\'m a teapot',
422 => 'HTTP/1.1 422 Unprocessable Entity',
423 => 'HTTP/1.1 423 Locked',
424 => 'HTTP/1.1 424 Failed Dependency',
425 => 'HTTP/1.1 425 Reserved for WebDAV advanced collections
expired proposal',
426 => 'HTTP/1.1 426 Upgrade Required',
428 => 'HTTP/1.1 428 Precondition Required',
429 => 'HTTP/1.1 429 Too Many Requests',
431 => 'HTTP/1.1 431 Request Header Fields Too Large',
451 => 'HTTP/1.1 451 Unavailable For Legal Reasons',
500 => 'HTTP/1.1 500 Internal Server Error',
501 => 'HTTP/1.1 501 Not Implemented',
502 => 'HTTP/1.1 502 Bad Gateway',
503 => 'HTTP/1.1 503 Service Unavailable',
504 => 'HTTP/1.1 504 Gateway Timeout',
505 => 'HTTP/1.1 505 HTTP Version Not Supported',
506 => 'HTTP/1.1 506 Variant Also Negotiates
(Experimental)',
507 => 'HTTP/1.1 507 Insufficient Storage',
508 => 'HTTP/1.1 508 Loop Detected',
510 => 'HTTP/1.1 510 Not Extended',
511 => 'HTTP/1.1 511 Network Authentication Required',
);
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.4
*/
protected function getOptions()
{
$options = array();
foreach ($this->responseMap as $key => $value)
{
$options[] = JHtml::_('select.option', $key, $value);
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
forms/filter_links.xml000064400000004565151156604450011122 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_REDIRECT_FILTER_SEARCH_LABEL"
description="COM_REDIRECT_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="redirect_status"
label="COM_REDIRECT_FILTER_PUBLISHED"
description="COM_REDIRECT_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="http_status"
type="Redirect"
label="COM_REDIRECT_FILTER_HTTP_HEADER_LABEL"
description="COM_REDIRECT_FILTER_HTTP_HEADER_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_REDIRECT_FILTER_SELECT_OPTION_HTTP_HEADER</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.old_url ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.old_url
ASC">COM_REDIRECT_HEADING_OLD_URL_ASC</option>
<option value="a.old_url
DESC">COM_REDIRECT_HEADING_OLD_URL_DESC</option>
<option value="a.new_url
ASC">COM_REDIRECT_HEADING_NEW_URL_ASC</option>
<option value="a.new_url
DESC">COM_REDIRECT_HEADING_NEW_URL_DESC</option>
<option value="a.referer
ASC">COM_REDIRECT_HEADING_REFERRER_ASC</option>
<option value="a.referer
DESC">COM_REDIRECT_HEADING_REFERRER_DESC</option>
<option value="a.created_date
ASC">COM_REDIRECT_HEADING_CREATED_DATE_ASC</option>
<option value="a.created_date
DESC">COM_REDIRECT_HEADING_CREATED_DATE_DESC</option>
<option value="a.hits
ASC">COM_REDIRECT_HEADING_HITS_ASC</option>
<option value="a.hits
DESC">COM_REDIRECT_HEADING_HITS_DESC</option>
<option value="a.header
ASC">COM_REDIRECT_HEADING_STATUS_CODE_ASC</option>
<option value="a.header
DESC">COM_REDIRECT_HEADING_STATUS_CODE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="5"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/link.xml000064400000004021151156604450007355 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
id="id"
default="0"
readonly="true"
class="readonly"
/>
<field
name="old_url"
type="text"
label="COM_REDIRECT_FIELD_OLD_URL_LABEL"
description="COM_REDIRECT_FIELD_OLD_URL_DESC"
class="input-xxlarge"
size="50"
required="true"
/>
<field
name="new_url"
type="text"
label="COM_REDIRECT_FIELD_NEW_URL_LABEL"
description="COM_REDIRECT_FIELD_NEW_URL_DESC"
class="input-xxlarge"
size="50"
required="true"
/>
<field
name="comment"
type="text"
label="COM_REDIRECT_FIELD_COMMENT_LABEL"
description="COM_REDIRECT_FIELD_COMMENT_DESC"
size="40"
/>
<field
name="published"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
class="chzn-color-state"
size="1"
default="1"
>
<option value="1">JENABLED</option>
<option value="0">JDISABLED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="referer"
type="text"
label="COM_REDIRECT_FIELD_REFERRER_LABEL"
id="referer"
size="50"
readonly="true"
/>
<field
name="created_date"
type="text"
label="COM_REDIRECT_FIELD_CREATED_DATE_LABEL"
id="created_date"
class="readonly"
size="20"
readonly="true"
/>
<field
name="modified_date"
type="text"
label="COM_REDIRECT_FIELD_UPDATED_DATE_LABEL"
id="modified_date"
class="readonly"
size="20"
readonly="true"
/>
<field
name="hits"
type="number"
label="JGLOBAL_HITS"
id="hits"
class="readonly"
size="20"
readonly="true"
filter="unset"
/>
</fieldset>
<fieldset name="advanced">
<field
name="header"
type="redirect"
label="COM_REDIRECT_FIELD_REDIRECT_STATUS_CODE_LABEL"
description="COM_REDIRECT_FIELD_REDIRECT_STATUS_CODE_DESC"
default="301"
validate="options"
class="input-xlarge"
/>
</fieldset>
</form>
link.php000064400000014057151156604450006230 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_redirect
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Redirect link model.
*
* @since 1.6
*/
class RedirectModelLink extends JModelAdmin
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_REDIRECT';
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if ($record->published != -2)
{
return false;
}
return parent::canDelete($record);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Link', $prefix =
'RedirectTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_redirect.link',
'link', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Modify the form based on access controls.
if ($this->canEditState((object) $data) != true)
{
// Disable fields for display.
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If in advanced mode then we make sure the new URL field is not
compulsory and the header
// field compulsory in case people select non-3xx redirects
if
(JComponentHelper::getParams('com_redirect')->get('mode',
0) == true)
{
$form->setFieldAttribute('new_url', 'required',
'false');
$form->setFieldAttribute('header', 'required',
'true');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_redirect.edit.link.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_redirect.link', $data);
return $data;
}
/**
* Method to activate links.
*
* @param array &$pks An array of link ids.
* @param string $url The new URL to set for the redirect.
* @param string $comment A comment for the redirect links.
*
* @return boolean Returns true on success, false on failure.
*
* @since 1.6
*/
public function activate(&$pks, $url, $comment = null)
{
$user = JFactory::getUser();
$db = $this->getDbo();
// Sanitize the ids.
$pks = (array) $pks;
$pks = ArrayHelper::toInteger($pks);
// Populate default comment if necessary.
$comment = (!empty($comment)) ? $comment :
JText::sprintf('COM_REDIRECT_REDIRECTED_ON',
JHtml::_('date', time()));
// Access checks.
if (!$user->authorise('core.edit',
'com_redirect'))
{
$pks = array();
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'));
return false;
}
if (!empty($pks))
{
// Update the link rows.
$query = $db->getQuery(true)
->update($db->quoteName('#__redirect_links'))
->set($db->quoteName('new_url') . ' = ' .
$db->quote($url))
->set($db->quoteName('published') . ' = ' .
(int) 1)
->set($db->quoteName('comment') . ' = ' .
$db->quote($comment))
->where($db->quoteName('id') . ' IN (' .
implode(',', $pks) . ')');
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
return true;
}
/**
* Method to batch update URLs to have new redirect urls and comments.
Note will publish any unpublished URLs.
*
* @param array &$pks An array of link ids.
* @param string $url The new URL to set for the redirect.
* @param string $comment A comment for the redirect links.
*
* @return boolean Returns true on success, false on failure.
*
* @since 3.6.0
*/
public function duplicateUrls(&$pks, $url, $comment = null)
{
$user = JFactory::getUser();
$db = $this->getDbo();
// Sanitize the ids.
$pks = (array) $pks;
$pks = ArrayHelper::toInteger($pks);
// Access checks.
if (!$user->authorise('core.edit',
'com_redirect'))
{
$pks = array();
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'));
return false;
}
if (!empty($pks))
{
$date = JFactory::getDate()->toSql();
// Update the link rows.
$query = $db->getQuery(true)
->update($db->quoteName('#__redirect_links'))
->set($db->quoteName('new_url') . ' = ' .
$db->quote($url))
->set($db->quoteName('modified_date') . ' = '
. $db->quote($date))
->set($db->quoteName('published') . ' = ' .
1)
->where($db->quoteName('id') . ' IN (' .
implode(',', $pks) . ')');
if (!empty($comment))
{
$query->set($db->quoteName('comment') . ' = '
. $db->quote($comment));
}
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
return true;
}
}
links.php000064400000013573151156604450006415 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_redirect
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Methods supporting a list of redirect links.
*
* @since 1.6
*/
class RedirectModelLinks extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'state', 'a.state',
'old_url', 'a.old_url',
'new_url', 'a.new_url',
'referer', 'a.referer',
'hits', 'a.hits',
'created_date', 'a.created_date',
'published', 'a.published',
'header', 'a.header', 'http_status',
);
}
parent::__construct($config);
}
/**
* Removes all of the unpublished redirects from the table.
*
* @return boolean result of operation
*
* @since 3.5
*/
public function purge()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->delete('#__redirect_links')->where($db->qn('published')
. '= 0');
$db->setQuery($query);
try
{
$db->execute();
}
catch (Exception $e)
{
return false;
}
return true;
}
/**
* 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.6
*/
protected function populateState($ordering = 'a.old_url',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.state',
$this->getUserStateFromRequest($this->context .
'.filter.state', 'filter_state', '',
'string'));
$this->setState('filter.http_status',
$this->getUserStateFromRequest($this->context .
'.filter.http_status', 'filter_http_status',
'', 'cmd'));
// Load the parameters.
$params = JComponentHelper::getParams('com_redirect');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.state');
$id .= ':' .
$this->getState('filter.http_status');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from($db->quoteName('#__redirect_links',
'a'));
// Filter by published state
$state = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where($db->quoteName('a.published') . ' =
' . (int) $state);
}
elseif ($state === '')
{
$query->where($db->quoteName('a.published') . ' IN
(0,1)');
}
// Filter the items over the HTTP status code header.
if ($httpStatusCode = $this->getState('filter.http_status'))
{
$query->where($db->quoteName('a.header') . ' =
' . (int) $httpStatusCode);
}
// Filter the items over the search string if set.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where($db->quoteName('a.id') . ' = '
. (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where(
'(' . $db->quoteName('old_url') . ' LIKE
' . $search .
' OR ' . $db->quoteName('new_url') . '
LIKE ' . $search .
' OR ' . $db->quoteName('comment') . '
LIKE ' . $search .
' OR ' . $db->quoteName('referer') . '
LIKE ' . $search . ')'
);
}
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.old_url')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Add the entered URLs into the database
*
* @param array $batchUrls Array of URLs to enter into the database
*
* @return boolean
*/
public function batchProcess($batchUrls)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$params = JComponentHelper::getParams('com_redirect');
$state = (int) $params->get('defaultImportState', 0);
$columns = array(
$db->quoteName('old_url'),
$db->quoteName('new_url'),
$db->quoteName('referer'),
$db->quoteName('comment'),
$db->quoteName('hits'),
$db->quoteName('published'),
$db->quoteName('created_date')
);
$query->columns($columns);
foreach ($batchUrls as $batch_url)
{
$old_url = $batch_url[0];
// Destination URL can also be an external URL
if (!empty($batch_url[1]))
{
$new_url = $batch_url[1];
}
else
{
$new_url = '';
}
$query->insert($db->quoteName('#__redirect_links'),
false)
->values(
$db->quote($old_url) . ', ' . $db->quote($new_url) .
' ,' . $db->quote('') . ', ' .
$db->quote('') . ', 0, ' . $state . ', ' .
$db->quote(JFactory::getDate()->toSql())
);
}
$db->setQuery($query);
$db->execute();
return true;
}
}
application.php000064400000001134151156772460007575 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_config
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
try
{
JLog::add(
sprintf('ConfigModelApplication has moved from %1$s to %2$s',
__FILE__, dirname(__DIR__) . '/model/application.php'),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
include_once JPATH_ADMINISTRATOR .
'/components/com_config/model/application.php';
component.php000064400000001126151156772460007275 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_config
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
try
{
JLog::add(
sprintf('ConfigModelComponent has moved from %1$s to %2$s',
__FILE__, dirname(__DIR__) . '/model/component.php'),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
include_once JPATH_ADMINISTRATOR .
'/components/com_config/model/component.php';
gateway.php000064400000005572151157455100006733 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Filesystem\File;
require_once JPATH_COMPONENT_ADMINISTRATOR .
'/gateways/dispatcher.php';
/**
* Gateway model class.
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JModelAdmin
*
* @since 3.4
*/
class JeaModelGateway extends JModelAdmin
{
/**
* Overrides parent method
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm|boolean A JForm object on success, false on failure
*
* @see JModelForm::getForm()
*/
public function getForm($data = array(), $loadData = true)
{
$app = JFactory::getApplication();
$type =
$app->getUserStateFromRequest('com_jea.gateway.type',
'type', '', 'cmd');
// @var $form JForm
$form = $this->loadForm('com_jea.' . $type, $type,
array('control' => 'jform', 'load_data'
=> false));
if (empty($form))
{
return false;
}
$item = $this->getItem($app->input->getInt('id', 0));
// Load gateway params
if ($item->id)
{
$formConfigFile = JPATH_COMPONENT_ADMINISTRATOR .
'/gateways/providers/' . $item->provider . '/' .
$item->type . '.xml';
if (File::exists($formConfigFile))
{
// Try to load provider language file
JFactory::getLanguage()->load($item->provider, JPATH_COMPONENT,
null, false, false);
$gatewayForm = $this->loadForm('com_jea.' . $item->type
. '.' . $item->provider, $formConfigFile,
array('load_data' => false));
$form->load($gatewayForm->getXml());
}
$dispatcher = GatewaysEventDispatcher::getInstance();
$dispatcher->loadGateway($item);
$dispatcher->trigger('onPrepareForm',
array('form' => $form));
$data = $this->loadFormData();
$form->bind($data);
}
return $form;
}
/**
* Overrides parent method
*
* @return array The default data is an empty array.
*
* @see JModelForm::loadFormData()
*/
protected function loadFormData()
{
// Check the session for previously entered form data. See
JControllerForm::save()
$data =
JFactory::getApplication()->getUserState('com_jea.edit.gateway.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
return $data;
}
/**
* Overrides parent method
*
* @param array $data The form data.
*
* @return boolean True on success, False on error.
*
* @see JModelAdmin::save()
*/
public function save($data)
{
if (isset($data['params']) &&
is_array($data['params']))
{
$data['params'] = json_encode($data['params']);
}
return parent::save($data);
}
}
gateways.php000064400000003134151157455100007106 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Gateways model class.
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JModelList
*
* @since 3.4
*/
class JeaModelGateways extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JModelList
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id',
'title',
'provider',
'published',
'ordering',
);
}
parent::__construct($config);
}
/**
* Overrides parent method
*
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data
set.
*
* @see JModelList::getListQuery()
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from('#__jea_gateways');
if ($type = $this->state->get('filter.type'))
{
$query->where('type=' . $db->Quote($type));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'id');
$orderDirn = $this->state->get('list.direction',
'desc');
$query->order($db->escape($orderCol . ' ' . $orderDirn));
return $query;
}
}
featurelist.php000064400000013050151157455100007607 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Filesystem\Folder;
/**
* Feature list model class.
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JModelList
*
* @since 2.0
*/
class JeaModelFeaturelist extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JModelList
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'f.id',
'f.value',
'f.ordering',
'l.title',
);
}
parent::__construct($config);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('feature.name');
$id .= ':' . $this->getState('filter.search');
$filters = $this->getState('feature.filters');
if (is_array($filters) && !empty($filters))
{
foreach ($filters as $filter)
{
$state = $this->getState('filter.' . $filter);
if (!empty($state))
{
$id .= ':' . $state;
}
}
}
return parent::getStoreId($id);
}
/**
* Overrides parent method
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @see JModelList::populateState()
*/
protected function populateState($ordering = 'f.id', $direction
= 'desc')
{
// The active feature
$feature = $this->getUserStateFromRequest($this->context .
'.feature.name', 'feature');
$this->setState('feature.name', $feature);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
// Retrieve the feature table params
$xmlPath = JPATH_COMPONENT . '/models/forms/features/';
$xmlFiles = Folder::files($xmlPath);
foreach ($xmlFiles as $filename)
{
$matches = array();
if (preg_match('/^[0-9]{2}-([a-z]*).xml/', $filename,
$matches))
{
if ($feature == $matches[1])
{
$form = simplexml_load_file($xmlPath . '/' . $filename);
$this->setState('feature.form', $form);
$this->setState('feature.table', (string)
$form['table']);
$filterFields =
$form->xpath("/form/fields[@name='filter']");
$filters = array();
if (isset($filterFields[0]) && $filterFields[0] instanceof
SimpleXMLElement)
{
foreach ($filterFields[0]->children() as $filterField)
{
$filter = (string) $filterField['name'];
$filterState = $this->getUserStateFromRequest($this->context .
'.filter.' . $filter, 'filter_' . $filter,
'');
$this->setState('filter.' . $filter, $filterState);
$filters[] = $filter;
$this->filter_fields[] = $filter;
}
}
$this->setState('feature.filters', $filters);
// Check if this feature uses language
$lang =
$form->xpath("//field[@name='language']");
if (!empty($lang))
{
$this->setState('language_enabled', true);
}
break;
}
}
}
parent::populateState($ordering, $direction);
}
/**
* Get the filter form
*
* @param array $data data
* @param boolean $loadData load current data
*
* @return \JForm|boolean The \JForm object or false on error
*
* @since 3.2
*/
public function getFilterForm($data = array(), $loadData = true)
{
$form = parent::getFilterForm($data, $loadData);
if ($form instanceof JForm)
{
$featureForm = $this->getState('feature.form');
if ($featureForm instanceof SimpleXMLElement)
{
$form->load($featureForm);
if ($loadData)
{
$data = $this->loadFormData();
$form->bind($data);
}
}
}
return $form;
}
/**
* Overrides parent method
*
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data
set.
*
* @see JModelList::getListQuery()
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select('f.*')->from($db->escape($this->getState('feature.table'))
. ' AS f');
// Join over the language
if ($this->getState('language_enabled'))
{
$query->select('l.title AS language_title');
$query->join('LEFT',
$db->quoteName('#__languages') . ' AS l ON l.lang_code =
f.language');
}
if ($filters = $this->getState('feature.filters'))
{
foreach ($filters as $filter)
{
if ($filterState = $this->getState('filter.' . $filter,
''))
{
$query->where('f.' . $filter . ' =' .
$db->Quote($filterState));
}
}
}
// Filter by search
if ($search = $this->getState('filter.search'))
{
$search = $db->Quote('%' . $db->escape($search, true) .
'%');
$query->where('f.value LIKE ' . $search);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'f.id');
$orderDirn = $this->state->get('list.direction',
'desc');
$query->order($db->escape($orderCol . ' ' . $orderDirn));
return $query;
}
}
forms/import.xml000064400000001527151157455100007737 0ustar00<?xml
version="1.0" encoding="UTF-8"?>
<form>
<fields
addfieldpath="/administrator/components/com_jea/models/fields">
<field name="id" type="hidden" />
<field name="title" type="text"
label="JGLOBAL_TITLE" description="JFIELD_TITLE_DESC"
class="input-xxlarge input-large-text" size="40"
required="true" />
<field name="published" type="radio"
label="JSTATUS" description="JFIELD_PUBLISHED_DESC"
class="btn-group" filter="intval" size="1"
default="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field name="provider"
type="gatewayproviderlist"
label="COM_JEA_GATEWAY_FIELD_PROVIDER_LABEL"
provider_type="import" required="true" />
<field name="type" type="hidden"
default="import" />
</fields>
<fields name="params" />
</form>forms/features/08-hotwatertype.xml000064400000001644151157455100013227
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form table="#__jea_hotwatertypes">
<fieldset name="feature">
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0"
readonly="true"
/>
<field
name="value"
type="text"
label="COM_JEA_FIELD_HOTWATERTYPE_LABEL"
size="50"
/>
<field
name="ordering"
type="hidden"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_JEA_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
</fieldset>
<fields name="filter">
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
</fields>
</form>
forms/features/05-amenity.xml000064400000001631151157455100012127
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form table="#__jea_amenities">
<fieldset name="feature">
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0"
readonly="true"
/>
<field
name="value"
type="text"
label="COM_JEA_FIELD_AMENITY_LABEL"
size="50"
/>
<field
name="ordering"
type="hidden"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_JEA_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
</fieldset>
<fields name="filter">
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
</fields>
</form>
forms/features/01-type.xml000064400000001635151157455100011442
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form table="#__jea_types">
<fieldset name="feature">
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0"
readonly="true"
/>
<field
name="value"
type="text"
label="COM_JEA_FIELD_PROPERTY_TYPE_LABEL"
size="50"
/>
<field
name="ordering"
type="hidden"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_JEA_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
</fieldset>
<fields name="filter">
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
</fields>
</form>
forms/features/09-slogan.xml000064400000001630151157455100011747
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form table="#__jea_slogans">
<fieldset name="feature">
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0"
readonly="true"
/>
<field
name="value"
type="text"
label="COM_JEA_FIELD_SLOGAN_LABEL"
size="50"
/>
<field
name="ordering"
type="hidden"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_JEA_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
</fieldset>
<fields name="filter">
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
</fields>
</form>
forms/features/07-heatingtype.xml000064400000001642151157455100013006
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form table="#__jea_heatingtypes">
<fieldset name="feature">
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0"
readonly="true"
/>
<field
name="value"
type="text"
label="COM_JEA_FIELD_HEATINGTYPE_LABEL"
size="50"
/>
<field
name="ordering"
type="hidden"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_JEA_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
</fieldset>
<fields name="filter">
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
</fields>
</form>
forms/features/04-area.xml000064400000001436151157455100011373
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form table="#__jea_areas">
<fieldset name="feature"
addfieldpath="/administrator/components/com_jea/models/fields">
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0"
readonly="true"
/>
<field
name="value"
type="text"
label="COM_JEA_FIELD_AREA_LABEL"
size="50"
/>
<field
name="town_id"
type="featureList"
subtype="towns"
label="COM_JEA_FIELD_TOWN_LABEL"
class="inputbox"
filter="intval"
/>
<field
name="ordering"
type="hidden"
/>
</fieldset>
<fields name="filter">
<field
name="town_id"
type="featurelist"
noajax="noajax"
subtype="towns"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/features/06-condition.xml000064400000001634151157455100012453
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form table="#__jea_conditions">
<fieldset name="feature">
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0"
readonly="true"
/>
<field
name="value"
type="text"
label="COM_JEA_FIELD_CONDITION_LABEL"
size="50"
/>
<field
name="ordering"
type="hidden"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_JEA_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
</fieldset>
<fields name="filter">
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
</fields>
</form>
forms/features/03-town.xml000064400000001445151157455100011451
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form table="#__jea_towns">
<fieldset name="feature"
addfieldpath="/administrator/components/com_jea/models/fields">
<field name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0"
readonly="true"
/>
<field
name="value"
type="text"
label="COM_JEA_FIELD_TOWN_LABEL"
size="50"
/>
<field
name="department_id"
type="featureList"
subtype="departments"
label="COM_JEA_FIELD_DEPARTMENT_LABEL"
filter="intval"
/>
<field
name="ordering"
type="hidden"
/>
</fieldset>
<fields name="filter">
<field
name="department_id"
type="featurelist"
noajax="noajax"
subtype="departments"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/features/02-department.xml000064400000000664151157455100012626
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form table="#__jea_departments">
<fieldset name="feature">
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0"
readonly="true"
/>
<field
name="value"
type="text"
label="COM_JEA_FIELD_DEPARTMENT_LABEL"
size="50"
/>
<field
name="ordering"
type="hidden"
/>
</fieldset>
</form>
forms/export.xml000064400000001430151157455100007737 0ustar00<?xml
version="1.0" encoding="UTF-8"?>
<form>
<fields
addfieldpath="/administrator/components/com_jea/models/fields">
<field name="id" type="hidden" />
<field name="title" type="text"
label="JGLOBAL_TITLE" description="JFIELD_TITLE_DESC"
class="input-xxlarge input-large-text" size="40"
required="true" />
<field name="published" type="radio"
label="JSTATUS" description="JFIELD_PUBLISHED_DESC"
class="btn-group" filter="intval" size="1"
default="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field name="provider" type="gatewayproviderlist"
label="COM_JEA_GATEWAY_FIELD_PROVIDER_LABEL"
provider_type="export" required="true" />
<field name="type" type="hidden"
default="export" />
</fields>
<fields name="params" />
</form>forms/filter_properties.xml000064400000002625151157455100012166
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
label="JSEARCH_FILTER_LABEL"
hint="COM_JEA_PROPERTIES_SEARCH_FILTER_DESC"
/>
<field
name="transaction_type"
type="list"
label="COM_JEA_FIELD_TRANSACTION_TYPE_LABEL"
onchange="this.form.submit();"
>
<option
value="">COM_JEA_FIELD_TRANSACTION_TYPE_LABEL</option>
<option
value="RENTING">COM_JEA_OPTION_RENTING</option>
<option
value="SELLING">COM_JEA_OPTION_SELLING</option>
</field>
<field
name="type_id"
type="featurelist"
subtype="types"
onchange="this.form.submit();"
/>
<field
name="department_id"
type="featurelist"
noajax="noajax"
subtype="departments"
onchange="this.form.submit();"
/>
<field
name="town_id"
type="featurelist"
noajax="noajax"
subtype="towns"
onchange="this.form.submit();"
/>
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
</fields>
<fields name="list">
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_featurelist.xml000064400000000620151157455100012312
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
label="JSEARCH_FILTER_LABEL"
/>
</fields>
<fields name="list">
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
onchange="this.form.submit();"
/>
</fields>
</form>forms/gateway.xml000064400000001401151157455100010055
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields
addfieldpath="/administrator/components/com_jea/models/fields">
<field name="id" type="hidden" />
<field name="title" type="text"
label="JGLOBAL_TITLE" description="JFIELD_TITLE_DESC"
class="input-xxlarge input-large-text" size="40"
required="true" />
<field name="published" type="radio"
label="JSTATUS" description="JFIELD_PUBLISHED_DESC"
class="btn-group" filter="intval" size="1"
default="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field name="provider" type="gatewayproviderlist"
label="COM_JEA_GATEWAY_FIELD_PROVIDER_LABEL"
provider_type="" required="true" />
<field name="type" type="hidden" />
</fields>
<fields name="params" />
</form>forms/import-jea.xml000064400000000746151157455100010476
0ustar00<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset name="params">
<field name="jea_version" type="list"
default="1.x" label="COM_JEA_FIELD_JEA_VERSION_LABEL"
description="COM_JEA_FIELD_JEA_VERSION_DESC" >
<option value="1.x">1.x</option>
<option value="2.x">2.x</option>
</field>
<field name="joomla_path" type="text"
default="" label="COM_JEA_FIELD_JOOMLA_PATH_LABEL"
description="COM_JEA_FIELD_JOOMLA_PATH_DESC"
class="inputbox" size="60" />
</fieldset>
</form>
forms/property.xml000064400000020405151157455100010305 0ustar00<?xml
version="1.0" encoding="UTF-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_jea/models/fields">
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<field
name="ref"
type="text"
label="COM_JEA_FIELD_REF_LABEL"
description="COM_JEA_FIELD_REF_DESC"
size="10"
/>
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="JFIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="40"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER"
size="40"
/>
<field
name="transaction_type"
type="list"
label="COM_JEA_FIELD_TRANSACTION_TYPE_LABEL"
required="true"
>
<option
value="SELLING">COM_JEA_OPTION_SELLING</option>
<option
value="RENTING">COM_JEA_OPTION_RENTING</option>
</field>
<field
name="type_id"
type="featureList"
subtype="types"
label="COM_JEA_FIELD_PROPERTY_TYPE_LABEL"
required="true"
filter="intval"
/>
<field
name="amenities"
type="amenities"
class="amenity"
/>
<field
name="images"
type="gallery"
/>
<field
name="description"
type="editor"
label="JGLOBAL_DESCRIPTION"
filter="JComponentHelper::filterText"
buttons="true"
/>
<field
name="published"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
filter="intval"
size="1"
default="1"
class="chzn-color-state"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
size="1"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_JEA_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
<field
name="featured"
type="radio"
label="JFEATURED"
description="COM_JEA_FIELD_FEATURED_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="slogan_id"
type="featureList"
subtype="slogans"
label="COM_JEA_FIELD_SLOGAN_LABEL"
filter="intval"
/>
<field
name="rules"
type="rules"
label="JFIELD_RULES_LABEL"
translate_label="false"
filter="rules"
component="com_jea"
section="property"
validate="rules"
/>
<field
name="notes"
type="textarea"
label="COM_JEA_FIELD_NOTES_LABEL"
description="COM_JEA_FIELD_NOTES_DESC"
rows="8"
cols="45"
/>
</fieldset>
<fieldset name="localization">
<field
name="address"
type="text"
label="COM_JEA_FIELD_ADDRESS_LABEL"
size="70"
/>
<field
name="zip_code"
type="text"
label="COM_JEA_FIELD_ZIP_CODE_LABEL"
size="5"
/>
<field
name="department_id"
type="featureList"
subtype="departments"
label="COM_JEA_FIELD_DEPARTMENT_LABEL"
filter="intval"
/>
<field
name="town_id"
type="featureList"
subtype="towns"
label="COM_JEA_FIELD_TOWN_LABEL"
filter="intval"
/>
<field
name="area_id"
type="featureList"
subtype="areas"
label="COM_JEA_FIELD_AREA_LABEL"
filter="intval"
/>
<field
name="latitude"
type="text"
label="COM_JEA_FIELD_LATITUDE_LABEL"
class="numberbox"
size="25"
/>
<field
name="longitude"
type="text"
label="COM_JEA_FIELD_LONGITUDE_LABEL"
class="numberbox"
size="25"
/>
<field
name="geolocalization"
type="geolocalization"
label="COM_JEA_FIELD_GEOLOCALIZATION_LABEL"
/>
</fieldset>
<fieldset name="publication">
<field
name="id"
type="text"
class="readonly"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0"
readonly="true"
/>
<field
name="hits"
type="text"
label="JGLOBAL_HITS"
description="COM_JEA_FIELD_HITS_DESC"
class="readonly"
size="6"
readonly="true"
filter="unset"
/>
<field
name="created"
type="calendar"
label="JGLOBAL_FIELD_CREATED_LABEL"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc"
/>
<field
name="modified"
type="calendar"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc"
/>
<field
name="publish_up"
type="calendar"
label="COM_JEA_FIELD_PUBLISH_UP_LABEL"
description="COM_JEA_FIELD_PUBLISH_UP_DESC"
format="%Y-%m-%d %H:%M:%S"
size="22"
filter="user_utc"
/>
<field
name="publish_down"
type="calendar"
label="COM_JEA_FIELD_PUBLISH_DOWN_LABEL"
description="COM_JEA_FIELD_PUBLISH_DOWN_DESC"
format="%Y-%m-%d %H:%M:%S"
size="22"
filter="user_utc"
/>
<field
name="created_by"
type="user"
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
description="COM_JEA_FIELD_CREATED_BY_DESC"
/>
</fieldset>
<fieldset name="financial_informations"
addfieldpath="/administrator/components/com_jea/models/fields">
<field
name="price"
type="price"
label="COM_JEA_FIELD_PRICE_LABEL"
class="numberbox"
size="10"
/>
<field
name="rate_frequency"
type="list"
label="COM_JEA_FIELD_RATE_FREQUENCY_LABEL"
>
<option
value="MONTHLY">COM_JEA_OPTION_MONTHLY</option>
<option
value="WEEKLY">COM_JEA_OPTION_WEEKLY</option>
<option
value="DAILY">COM_JEA_OPTION_DAILY</option>
</field>
<field
name="charges"
type="price"
label="COM_JEA_FIELD_CHARGES_LABEL"
class="numberbox"
size="10"
/>
<field
name="fees"
type="price"
label="COM_JEA_FIELD_FEES_LABEL"
class="numberbox"
size="10"
/>
<field
name="deposit"
type="price"
label="COM_JEA_FIELD_DEPOSIT_LABEL"
class="numberbox"
size="10"
/>
</fieldset>
<fieldset name="details"
addfieldpath="/administrator/components/com_jea/models/fields">
<field
name="living_space"
type="surface"
label="COM_JEA_FIELD_LIVING_SPACE_LABEL"
class="numberbox"
filter="floatval"
size="7"
/>
<field
name="land_space"
type="surface"
label="COM_JEA_FIELD_LAND_SPACE_LABEL"
class="numberbox"
filter="floatval"
size="7"
/>
<field
name="availability"
type="calendar"
label="COM_JEA_FIELD_PROPERTY_AVAILABILITY_LABEL"
size="11"
format="%Y-%m-%d"
filter="user_utc"
/>
<field
name="condition_id"
type="featureList"
subtype="conditions"
label="COM_JEA_FIELD_CONDITION_LABEL"
filter="intval"
/>
<field
name="orientation"
type="list"
label="COM_JEA_FIELD_ORIENTATION_LABEL"
>
<option value="0">JOPTION_DO_NOT_USE</option>
<option value="N">COM_JEA_OPTION_NORTH</option>
<option
value="NW">COM_JEA_OPTION_NORTH_WEST</option>
<option
value="NE">COM_JEA_OPTION_NORTH_EAST</option>
<option
value="NS">COM_JEA_OPTION_NORTH_SOUTH</option>
<option value="E">COM_JEA_OPTION_EAST</option>
<option
value="EW">COM_JEA_OPTION_EAST_WEST</option>
<option value="W">COM_JEA_OPTION_WEST</option>
<option value="S">COM_JEA_OPTION_SOUTH</option>
<option
value="SW">COM_JEA_OPTION_SOUTH_WEST</option>
<option
value="SE">COM_JEA_OPTION_SOUTH_EAST</option>
</field>
<field
name="floor"
type="number"
label="COM_JEA_FIELD_FLOOR_LABEL"
class="numberbox"
filter="floatval"
size="3"
/>
<field
name="floors_number"
type="number"
label="COM_JEA_FIELD_FLOORS_NUMBER_LABEL"
class="numberbox"
filter="floatval"
size="3"
/>
<field
name="rooms"
type="number"
label="COM_JEA_FIELD_NUMBER_OF_ROOMS_LABEL"
class="numberbox"
filter="floatval"
size="3"
/>
<field
name="bedrooms"
type="number"
label="COM_JEA_FIELD_NUMBER_OF_BEDROOMS_LABEL"
class="numberbox"
filter="intval"
size="3"
/>
<field
name="bathrooms"
type="number"
label="COM_JEA_FIELD_NUMBER_OF_BATHROOMS_LABEL"
class="numberbox"
filter="floatval"
size="3"
/>
<field
name="toilets"
type="number"
label="COM_JEA_FIELD_NUMBER_OF_TOILETS_LABEL"
class="numberbox"
filter="intval"
size="3"
/>
<field
name="hot_water_type"
type="featureList"
subtype="hotwatertypes"
label="COM_JEA_FIELD_HOTWATERTYPE_LABEL"
filter="intval"
/>
<field
name="heating_type"
type="featureList"
subtype="heatingtypes"
label="COM_JEA_FIELD_HEATINGTYPE_LABEL"
filter="intval"
/>
</fieldset>
</form>
properties.php000064400000014237151157455100007464 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Properties model class.
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JModelList
*
* @since 2.0
*/
class JeaModelProperties extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JModelList
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'p.id',
'p.ordering',
'p.price',
'p.featured',
'p.published',
'access_level',
'author',
'p.created',
'p.hits',
'language',
'search',
'transaction_type',
'type_id',
'department_id',
'town_id',
'language'
);
}
parent::__construct($config);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' .
$this->getState('filter.transaction_type');
$id .= ':' .
$this->getState('filter.department_id');
$id .= ':' . $this->getState('filter.town_id');
$id .= ':' . $this->getState('filter.language');
return parent::getStoreId($id);
}
/**
* Overrides parent method
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @see JModelList::populateState()
*/
protected function populateState($ordering = 'p.id', $direction
= 'desc')
{
$transaction_type = $this->getUserStateFromRequest($this->context .
'.filter.transaction_type', 'filter_transaction_type');
$this->setState('filter.transaction_type',
$transaction_type);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$type_id = $this->getUserStateFromRequest($this->context .
'.filter.type_id', 'filter_type_id');
$this->setState('filter.type_id', $type_id);
$department_id = $this->getUserStateFromRequest($this->context .
'.filter.department_id', 'filter_department_id');
$this->setState('filter.department_id', $department_id);
$town_id = $this->getUserStateFromRequest($this->context .
'.filter.town_id', 'filter_town_id');
$this->setState('filter.town_id', $town_id);
$language = $this->getUserStateFromRequest($this->context .
'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
parent::populateState($ordering, $direction);
}
/**
* Overrides parent method
*
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data
set.
*
* @see JModelList::getListQuery()
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$dispatcher = JDispatcher::getInstance();
// Include the jea plugins for the onBeforeSearchQuery event.
JPluginHelper::importPlugin('jea');
$query->select(
'p.id, p.ref, p.transaction_type, p.address, p.price,
p.rate_frequency, p.created,
p.featured, p.published, p.publish_up, p.publish_down,
p.access, p.ordering, p.checked_out, p.checked_out_time,
p.created_by, p.hits, p.language '
);
$query->from('#__jea_properties AS p');
// Join viewlevels
$query->select('al.title AS access_level');
$query->join('LEFT', '#__viewlevels AS al ON al.id =
p.access');
// Join departments
$query->select('d.value AS `department`');
$query->join('LEFT', '#__jea_departments AS d ON d.id =
p.department_id');
// Join properties types
$query->select('t.value AS `type`');
$query->join('LEFT', '#__jea_types AS t ON t.id =
p.type_id');
// Join towns
$query->select('town.value AS `town`');
$query->join('LEFT', '#__jea_towns AS town ON town.id =
p.town_id');
// Join users
$query->select('u.username AS `author`');
$query->join('LEFT', '#__users AS u ON u.id =
p.created_by');
// Join over the language
$query->select('l.title AS language_title');
$query->join('LEFT',
$db->quoteName('#__languages') . ' AS l ON l.lang_code =
p.language');
// Filter by transaction type
if ($transactionType =
$this->getState('filter.transaction_type'))
{
$query->where('p.transaction_type =' .
$db->Quote($db->escape($transactionType)));
}
// Filter by property type
if ($typeId = $this->getState('filter.type_id'))
{
$query->where('p.type_id =' . (int) $typeId);
}
// Filter by departments
if ($departmentId = $this->getState('filter.department_id'))
{
$query->where('p.department_id =' . (int) $departmentId);
}
// Filter by town
if ($townId = $this->getState('filter.town_id'))
{
$query->where('p.town_id =' . (int) $townId);
}
// Filter by search
if ($search = $this->getState('filter.search'))
{
$search = $db->Quote('%' . $db->escape($search, true) .
'%');
$search = '(p.ref LIKE ' . $search . ' OR p.title LIKE
' . $search . ' OR p.id LIKE ' . $search . ' OR
u.username LIKE ' . $search . ')';
$query->where($search);
}
// Filter by language.
if ($language = $this->getState('filter.language'))
{
$query->where('p.language = ' . $db->quote($language));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'p.id');
$orderDirn = $this->state->get('list.direction',
'desc');
// If language order selected order by languagetable title
if ($orderCol == 'language')
{
$orderCol = 'l.title';
}
$query->order($db->escape($orderCol . ' ' . $orderDirn));
$dispatcher->trigger('onBeforeSearch', array(&$query,
&$this->state));
return $query;
}
}
feature.php000064400000002315151157455100006715 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('ContentModelArticle', __DIR__ .
'/article.php');
/**
* Feature model.
*
* @since 1.6
*/
class ContentModelFeature extends ContentModelArticle
{
/**
* Returns a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Featured', $prefix =
'ContentTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* A protected method to get a set of ordering conditions.
*
* @param object $table A record object.
*
* @return array An array of conditions to add to add to ordering
queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
return array();
}
}
features.php000064400000006747151157455100007115 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Filesystem\Folder;
require JPATH_COMPONENT_ADMINISTRATOR . '/tables/features.php';
/**
* Features model class.
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JModelLegacy
*
* @since 2.0
*/
class JeaModelFeatures extends JModelLegacy
{
/**
* Get the list of features
*
* @return array of stdClass objects
*/
public function getItems()
{
$xmlPath = JPATH_COMPONENT_ADMINISTRATOR .
'/models/forms/features';
$xmlFiles = Folder::files($xmlPath);
$items = array();
foreach ($xmlFiles as $key => $filename)
{
$matches = array();
if (preg_match('/^[0-9]{2}-([a-z]*).xml/', $filename,
$matches))
{
$form = simplexml_load_file($xmlPath . '/' . $filename);
// Generate object
$feature = new stdClass;
$feature->id = $key;
$feature->name = $matches[1];
$feature->table = (string) $form['table'];
$feature->language = false;
// Check if this feature uses language
$lang =
$form->xpath("//field[@name='language']");
if (! empty($lang))
{
$feature->language = true;
}
$items[$feature->name] = $feature;
}
}
return $items;
}
/**
* Return table data as CSV string
*
* @param string $tableName The name of the feature table
*
* @return string CSV formatted
*/
public function getCSVData($tableName = '')
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*')->from($db->escape($tableName));
$db->setQuery($query);
$rows = $db->loadRowList();
$csv = '';
foreach ($rows as $row)
{
$csv .= JeaHelperUtility::arrayToCSV($row);
}
return $csv;
}
/**
* Import rows from CSV file and return the number of inserted rows
*
* @param string $file The file path
* @param string $tableName The feature table name to insert csv data
*
* @return integer The number of inserted rows
*/
public function importFromCSV($file = '', $tableName =
'')
{
$row = 0;
if (($handle = fopen($file, 'r')) !== false)
{
$db = JFactory::getDbo();
$tableName = $db->escape($tableName);
$table = new FeaturesFactory($tableName, 'id', $db);
$cols = array_keys($table->getProperties());
$query = $db->getQuery(true);
$query->select('*')->from($tableName);
$db->setQuery($query);
$ids = $db->loadObjectList('id');
$query->clear();
$query->select('ordering')
->from($tableName)
->order('ordering DESC');
$db->setQuery($query);
$maxOrdering = $db->loadResult();
if ($maxOrdering == null)
{
$maxOrdering = 1;
}
while (($data = fgetcsv($handle, 1000, ';',
'"')) !== false)
{
$num = count($data);
$bind = array();
for ($c = 0; $c < $num; $c ++)
{
if (isset($cols[$c]))
{
$bind[$cols[$c]] = $data[$c];
}
}
if (isset($bind['id']) &&
isset($ids[$bind['id']]))
{
// Load row to update
$table->load((int) $bind['id']);
}
elseif (isset($bind['ordering']))
{
$bind['ordering'] = $maxOrdering;
$maxOrdering ++;
}
$table->save($bind, '', 'id');
// To force new insertion
$table->id = null;
$row ++;
}
}
return $row;
}
}
fields/price.php000064400000002613151157455100007633 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for JEA.
* Provides a one line text field with currency symbol
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JFormFieldText
*
* @since 2.0
*/
class JFormFieldPrice extends JFormFieldText
{
/**
* The form field type.
*
* @var string
*/
protected $type = 'Price';
/**
* Method to change the label
*
* @param string $label The field label
*
* @return void
*/
public function setLabel($label = '')
{
$this->label = $label;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*/
protected function getInput()
{
$input = parent::getInput();
$params = JComponentHelper::getParams('com_jea');
$symbol_place = $params->get('symbol_place', 1);
$currency_symbol = $params->get('currency_symbol',
'€');
if ($symbol_place == 0)
{
return '<span class="input-prefix">' .
$currency_symbol . '</span> ' . $input;
}
return $input . ' <span class="input-suffix">'
. $currency_symbol . '</span>';
}
}
fields/featurelist.php000064400000007656151157455100011074 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for JEA.
* Provides a list of features
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JFormField
*
* @since 2.0
*/
class JFormFieldFeatureList extends JFormField
{
/**
* The form field type.
*
* @var string
*/
public $type = 'featureList';
/**
* Method to get the list of features.
*
* @return string The field input markup.
*
* @see JHtmlFeatures
*/
protected function getInput()
{
JHtml::addIncludePath(JPATH_ADMINISTRATOR .
'/components/com_jea/helpers/html');
$subtype = (string) $this->element['subtype'];
$params = array(
'id' => $this->id,
'class' => (string) $this->element['class']
);
if (isset($this->element['size']))
{
$params['size'] = (string)
$this->element['size'];
}
if (isset($this->element['multiple']))
{
$params['multiple'] = (string)
$this->element['multiple'];
}
if (isset($this->element['onchange']))
{
$params['onchange'] = (string)
$this->element['onchange'];
}
$group = null;
switch ($this->form->getName())
{
case 'com_menus.item':
$group = 'params';
break;
case 'com_jea.properties.filter':
case 'com_jea.featurelist.filter':
$group = 'filter';
break;
}
// Verify if some fields have relashionship
$hasRelationShip = $this->_hasRelationShip();
switch ($subtype)
{
case 'departments':
if ($hasRelationShip)
{
$this->_ajaxUpdateList('department_id',
'town_id', 'get_towns');
}
break;
case 'towns':
if ($hasRelationShip)
{
$this->_ajaxUpdateList('town_id', 'area_id',
'get_areas');
return JHtml::_('features.towns', $this->value,
$this->name, $params,
$this->form->getValue('department_id', $group, null));
}
case 'areas':
if ($hasRelationShip)
{
return JHtml::_('features.areas', $this->value,
$this->name, $params, $this->form->getValue('town_id',
$group, null));
}
}
return JHtml::_('features.' . $subtype, $this->value,
$this->name, $params);
}
/**
* Verify relationship component parameter
*
* @return boolean
*/
private function _hasRelationShip()
{
if (isset($this->element['norelation']))
{
return false;
}
$params = JComponentHelper::getParams('com_jea');
return (bool) $params->get('relationship_dpts_towns_area',
1);
}
/**
* Add AJAX behavior
*
* @param string $fromId The Element ID where the event come from
* @param string $toId The target Element ID
* @param string $task The AJAX controller task
*
* @return void
*/
private function _ajaxUpdateList($fromId, $toId, $task)
{
if (isset($this->element['noajax']))
{
return;
}
if ($this->form->getName() == 'com_menus.item')
{
$fieldTo = $this->form->getField('filter_' . $toId,
'params');
}
else
{
$fieldTo = $this->form->getField($toId);
}
if (! empty($fieldTo->id))
{
JFactory::getDocument()->addScriptDeclaration(
"
jQuery(document).ready(function($) {
$('#{$this->id}').change(function(e) {
$.ajax({
dataType: 'json',
url: 'index.php',
data:
'option=com_jea&format=json&task=features.{$task}&{$fromId}='
+ this.value,
success: function(response) {
var first = $('#{$fieldTo->id} option').first().clone();
$('#{$fieldTo->id}').empty().append(first);
if (response.length) {
$.each(response, function( idx, item ){
$('#{$fieldTo->id}').append($('<option></option>').text(item.value).attr('value',
item.id));
});
}
$('#{$fieldTo->id}').trigger('liszt:updated.chosen');
// Update jQuery choosen
}
});
});
});
"
);
}
}
}
fields/gallery.php000064400000005314151157455100010171 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Image\Image;
/**
* Form Field class for JEA.
* Provides a complete widget to manage a gallery
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JFormField
*
* @since 2.0
*/
class JFormFieldGallery extends JFormField
{
/**
* The form field type.
*
* @var string
*/
protected $type = 'Gallery';
/**
* Method to get the list of input[type="file"]
*
* @return string The field input markup.
*/
protected function getInput()
{
$params = JComponentHelper::getParams('com_jea');
if (is_string($this->value))
{
$images = (array) json_decode($this->value);
}
else
{
$images = (array) $this->value;
foreach ($images as $k => $image)
{
$images[$k] = (object) $image;
}
}
$propertyId = $this->form->getValue('id');
$baseURL = JUri::root(true);
$imgBaseURL = $baseURL . '/images/com_jea/images/' .
$propertyId;
$imgBasePath = JPATH_ROOT . '/images/com_jea/images/' .
$propertyId;
foreach ($images as $k => &$image)
{
$imgPath = $imgBasePath . '/' . $image->name;
try
{
$infos = Image::getImageFileProperties($imgPath);
}
catch (Exception $e)
{
$image->error = 'Recorded Image ' . $image->name .
' cannot be accessed';
continue;
}
$thumbName = 'thumb-admin-' . $image->name;
// Create the thumbnail
if (!file_exists($imgBasePath . '/' . $thumbName))
{
try
{
// This is where the JImage will be used, so only create it here
$JImage = new JImage($imgPath);
$thumb = $JImage->resize(150, 90);
$thumb->crop(150, 90, 0, 0);
$thumb->toFile($imgBasePath . '/' . $thumbName);
// To avoid memory overconsumption, destroy the JImage. We don't
need it anymore
$JImage->destroy();
$thumb->destroy();
}
catch (Exception $e)
{
$image->error = 'Thumbnail for ' . $image->name .
' cannot be generated';
continue;
}
}
$image->thumbUrl = $imgBaseURL . '/' . $thumbName;
$image->url = $imgBaseURL . '/' . $image->name;
// Kbytes
$image->weight = round($infos->bits / 1024, 1);
$image->height = $infos->height;
$image->width = $infos->width;
}
$layoutModel = array (
'uploadNumber' =>
$params->get('img_upload_number', 3),
'images' => $images,
'name' => $this->name,
);
return JLayoutHelper::render('jea.fields.gallery',
$layoutModel);
}
}
fields/amenities.php000064400000004771151157455100010516 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for JEA.
* Displays amenities as a list of check boxes.
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JFormField
*
* @since 2.0
*/
class JFormFieldAmenities extends JFormField
{
/**
* The form field type.
*
* @var string
*/
protected $type = 'Amenities';
/**
* Flag to tell the field to always be in multiple values mode.
*
* @var boolean
*/
protected $forceMultiple = true;
/**
* Method to get the field input markup for check boxes.
*
* @return string The field input markup.
*/
protected function getInput()
{
$options = $this->getOptions();
$output = '<ul id="amenities">';
if (! empty($this->value))
{
// Preformat data if comes from db
if (! is_array($this->value))
{
$this->value = explode('-', $this->value);
}
}
else
{
$this->value = array();
}
foreach ($options as $k => $row)
{
$checked = '';
$class = '';
if (in_array($row->id, $this->value))
{
$checked = 'checked="checked"';
$class = 'active';
}
$title = '';
$label = JHtml::_('string.truncate', $row->value, 23,
false, false);
if ($row->value != $label)
{
$title = ' title="' . $row->value .
'"';
}
$output .= '<li class="amenity ' . $class .
'">';
$output .= '<input class="am-input"
type="checkbox" name="' . $this->name .
'"'
. ' id="' . $this->id . $k . '"
value="' . $row->id . '" ' . $checked . '
/>'
. '<label class="am-title" for="' .
$this->id . $k . '" ' . $title . '>' .
$label . '</label>';
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
/**
* Method to get the field options.
*
* @return array The field option objects.
*/
protected function getOptions()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('f.id , f.value');
$query->from('#__jea_amenities AS f');
if (JFactory::getApplication()->isClient('site'))
{
$query->where('f.language in (' .
$db->quote(JFactory::getLanguage()->getTag()) . ',' .
$db->quote('*') . ')');
}
$query->order('f.value ASC');
$db->setQuery($query);
return $db->loadObjectList();
}
}
fields/surface.php000064400000002063151157455100010160 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for JEA.
* Provides a one line text field with the surface symbol
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JFormFieldText
*
* @since 2.0
*/
class JFormFieldSurface extends JFormFieldText
{
/**
* The form field type.
*
* @var string
*/
protected $type = 'Surface';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*/
protected function getInput()
{
$input = parent::getInput();
$params = JComponentHelper::getParams('com_jea');
$surface_measure = $params->get('surface_measure',
'm²');
return $input . ' <span class="input-suffix">'
. $surface_measure . '</span>';
}
}
fields/gatewayproviderlist.php000064400000005515151157455100012645
0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Filesystem\Folder;
JFormHelper::loadFieldClass('list');
/**
* Supports an HTML select list of gateway providers
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JFormFieldList
*
* @since 2.0
*/
class JFormFieldGatewayProviderList extends JFormFieldList
{
/**
* The form field type.
*
* @var string
*/
protected $type = 'GatewayProviderList';
/**
* The provider type (import or export).
*
* @var string
*/
protected $providerType = '';
/**
* Overrides parent method.
*
* @param string $name The property name for which to the the value.
*
* @return mixed The property value or null.
*
* @see JFormField::__get()
*/
public function __get($name)
{
if ($name == 'providerType')
{
return $this->$name;
}
return parent::__get($name);
}
/**
* Overrides parent method.
*
* @param string $name The property name for which to the the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @see JFormField::__set()
*/
public function __set($name, $value)
{
if ($name == 'providerType')
{
$this->$name = (string) $value;
}
parent::__set($name, $value);
}
/**
* Overrides parent method.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value.
*
* @return boolean True on success.
*
* @see JFormField::setup()
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->providerType = (string)
$this->element['provider_type'];
}
return $return;
}
/**
* Overrides parent method.
*
* @return array The field option objects.
*
* @see JFormFieldList::getOptions()
*/
protected function getOptions()
{
$options = array();
$path = JPATH_ADMINISTRATOR .
'/components/com_jea/gateways/providers';
$folders = Folder::folders($path);
$options[] = JHtml::_('select.option', '',
JText::alt('JOPTION_DO_NOT_USE',
preg_replace('/[^a-zA-Z0-9_\-]/', '_',
$this->fieldname)));
foreach ($folders as $folder)
{
if (file_exists($path . '/' . $folder . '/' .
$this->providerType . '.xml'))
{
$options[] = JHtml::_('select.option', $folder, $folder);
}
}
return $options;
}
}
fields/geolocalization.php000064400000015714151157455100011722
0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for JEA.
* Displays button to geolocalize coordinates with a map.
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JFormField
*
* @since 2.0
*/
class JFormFieldGeolocalization extends JFormField
{
/**
* The form field type.
*
* @var string
*
*/
protected $type = 'Geolocalization';
/**
* Method to get the button to geolocalize coordinates with a map.
*
* @return string The field input markup.
*/
protected function getInput()
{
$params = JComponentHelper::getParams('com_jea');
$ouptut = '';
// TODO : use JLayout
$ouptut = '<div class="button2-left">' .
"\n" .
'<div class="blank"><a class="modal btn
btn-info" href="#map-box-content"' .
' rel="{handler: \'clone\', size: {x: 800, y: 500},
onOpen:initBoxContent, onClose:closeBoxContent }">' .
JText::_('COM_JEA_MAP_OPEN') .
'</a></div>' . "\n" .
'</div>' . "\n" .
'<div id="map-box-content"
class="map-box-content" style="display:none">'
. "\n" . JText::_('COM_JEA_FIELD_LATITUDE_LABEL') .
' : <input type="text" readonly="readonly"
class="readonly input-latitude" value="" />' .
JText::_('COM_JEA_FIELD_LONGITUDE_LABEL') .
' : <input type="text" readonly="readonly"
class="readonly input-longitude" value="" />' .
'<div class="map-box-container" style="width:
100%; height: 480px"></div>' . "\n" .
'</div>' . "\n";
// Load the modal behavior script.
JHtml::_('behavior.modal');
$document = JFactory::getDocument();
$langs = explode('-', $document->getLanguage());
$lang = $langs[0];
$region = $langs[1];
$fieldDepartment =
$this->form->getField('department_id');
$fieldTown = $this->form->getField('town_id');
$fieldAddress = $this->form->getField('address');
$fieldLongitude = $this->form->getField('longitude');
$fieldLatitude = $this->form->getField('latitude');
$markerLabel =
addslashes(JText::_('COM_JEA_MAP_MARKER_LABEL'));
JFactory::getDocument()->addScriptDeclaration(
"
function initBoxContent(elementContent) {
var latitude =
document.id('{$fieldLatitude->id}').value;
var longitude =
document.id('{$fieldLongitude->id}').value;
var address =
document.id('{$fieldAddress->id}').value;
var town =
document.id('{$fieldTown->id}').getSelected().pick();
var department =
document.id('{$fieldDepartment->id}').getSelected().pick();
var zoom = 6;
var request = '{$lang}';
if (address && town &&
town.get('value') > 0){
zoom = 16;
request = address + ', ' +
town.get('text') + ', {$lang}';
} else if (town && town.get('value') >
0){
zoom = 13;
request = town.get('text') + ',
{$lang}';
} else if (department &&
department.get('value') > 0) {
zoom = 8;
request = department.get('text') + ',
{$lang}';
}
var inputLatitude =
elementContent.getElement('.input-latitude');
var inputLongitude =
elementContent.getElement('.input-longitude');
var mapContainer =
elementContent.getElement('.map-box-container');
var initMap = function(myLatlng) {
inputLongitude.set('value', myLatlng.lng());
inputLatitude.set('value', myLatlng.lat());
var options = {
zoom : zoom,
center : myLatlng,
mapTypeId : google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(mapContainer, options);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: '{$markerLabel}',
draggable: true,
cursor: 'move'
});
google.maps.event.addListener(marker,
'dragend', function(mouseEvent) {
inputLongitude.setProperty('value',
mouseEvent.latLng.lng());
inputLatitude.setProperty('value',
mouseEvent.latLng.lat());
});
};
elementContent.getElement('.map-box-content').setStyle('display',
'block');
if (longitude != 0 && latitude != 0) {
var myLatlng = new
google.maps.LatLng(latitude,longitude);
initMap(myLatlng);
} else {
var geocoder = new google.maps.Geocoder();
var opts = {'address':request,
'language':'{$lang}',
'region':'{$region}'};
var retry = 0;
var geocodeCallBack = function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var myLatlng = results[0].geometry.location;
initMap(myLatlng);
} else if (status ==
google.maps.GeocoderStatus.ZERO_RESULTS && retry < 3 ) {
if (town && town.get('value')
> 0 && retry == 0) {
// retry with town
zoom = 13;
request = town.get('text') +
', {$lang}';
} else if (department &&
department.get('value') > 0 && retry == 1) {
// retry with department
zoom = 8;
request = department.get('text')
+ ', {$lang}';
} else {
zoom = 6;
request = '{$lang}';
}
var opts = {'address':request,
'language':'{$lang}',
'region':'{$region}'};
geocoder.geocode(opts, geocodeCallBack);
retry++;
}
};
geocoder.geocode(opts, geocodeCallBack);
}
}
function closeBoxContent(elementContent)
{
document.id('{$fieldLatitude->id}').set('value',
elementContent.getElement('.input-latitude').value);
document.id('{$fieldLongitude->id}').set('value',
elementContent.getElement('.input-longitude').value);
}"
);
JFactory::getDocument()->addScript(
'https://maps.google.com/maps/api/js?key=' .
$params->get('googlemap_api_key') .
'&language=' . $lang . '&region=' .
$region
);
return $ouptut;
}
}
propertyInterface.php000064400000040644151157455100010776 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\User\User;
use Joomla\CMS\Mail\MailHelper;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
require_once JPATH_COMPONENT_ADMINISTRATOR .
'/tables/property.php';
/**
* JEAPropertyInterface model class.
*
* This class provides an interface between JEA data and third party
bridges
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @since 2.0
*/
class JEAPropertyInterface extends JObject
{
// These public members concern the interface
public $ref = '';
public $title = '';
public $type = '';
public $transaction_type = '';
/**
* Renting or selling price
*
* @var string
*/
public $price = '';
public $address = '';
public $town = '';
public $area = '';
public $zip_code = '';
public $department = '';
public $condition = '';
public $living_space = '';
public $land_space = '';
public $rooms = '';
public $bedrooms = '';
public $charges = '';
public $fees = '';
public $deposit = '';
public $hot_water_type = '';
public $heating_type = '';
public $bathrooms = '';
public $toilets = '';
public $availability = '';
public $floor = 0;
public $floors_number = 0;
public $orientation = '0';
public $amenities = array();
public $description = '';
public $author_name = '';
public $author_email = '';
public $latitude = 0;
public $longitude = 0;
/**
* Timestamp
*
* @var integer
*/
public $created = 0;
/**
* Timestamp
*
* @var integer
*/
public $modified = 0;
public $images = array();
public $language = '*';
/**
* A callback which replace the default implementation to save images.
* This should be a function or a method but not a closure because
* this object needs to be serialised and closures can't be
serialized
*
* @var string|array
*/
public $saveImagesCallback = null;
/**
* Fields which are not in the standard JEA interface
*
* @var array
*/
protected $additionnalsFields = array();
/**
* The users array from Joomla
*
* @var array
*/
protected static $users = null;
/**
* The tables data array from JEA
*
* @var array
*/
protected static $tables = null;
/**
* The features data array from JEA
*
* @var array
*/
protected static $features = array();
/**
* Convert Interface data to JEA data
*
* @return array representing a JEA propery row
*/
protected function toJEAData()
{
$data = array(
'ref' => $this->ref,
'title' => $this->title,
'type_id' => self::getFeatureId('types',
$this->type, $this->language),
'price' => floatval($this->price),
'address' => $this->address,
'department_id' =>
self::getFeatureId('departments', $this->department),
'zip_code' => $this->zip_code,
'condition_id' =>
self::getFeatureId('conditions', $this->condition,
$this->language),
'living_space' => floatval($this->living_space),
'land_space' => floatval($this->land_space),
'rooms' => intval($this->rooms),
'bedrooms' => intval($this->bedrooms),
'charges' => floatval($this->charges),
'fees' => floatval($this->fees),
'deposit' => floatval($this->deposit),
'hot_water_type' =>
self::getFeatureId('hotwatertypes', $this->hot_water_type,
$this->language),
'heating_type' =>
self::getFeatureId('heatingtypes', $this->heating_type,
$this->language),
'bathrooms' => intval($this->bathrooms),
'toilets' => intval($this->toilets),
'availability' =>
$this->_convertTimestampToMysqlDate($this->availability, false),
'floor' => intval($this->floor),
'floors_number' => (int) $this->floors_number,
'orientation' => $this->orientation,
'description' => $this->description,
'published' => 1,
'created' =>
$this->_convertTimestampToMysqlDate($this->created),
'modified' =>
$this->_convertTimestampToMysqlDate($this->modified),
'created_by' => self::getUserId($this->author_email,
$this->author_name),
'latitude' => floatval($this->latitude),
'longitude' => floatval($this->longitude),
'language' => $this->language
);
$this->transaction_type = strtoupper($this->transaction_type);
if ($this->transaction_type == 'RENTING' ||
$this->transaction_type == 'SELLING')
{
$data['transaction_type'] = $this->transaction_type;
}
else
{
$data['transaction_type'] = '0';
}
$data['town_id'] = self::getFeatureId('towns',
$this->town, null, $data['department_id']);
$data['area_id'] = self::getFeatureId('areas',
$this->area, null, $data['town_id']);
$orientations =
array('0','N','NE','NW','NS','E','EW','W','SW','SE');
$orientation = strtoupper($this->orientation);
if (in_array($orientation, $orientations))
{
$data['orientation'] = $orientation;
}
else
{
$data['orientation'] = 'O';
}
if (is_array($this->amenities))
{
$data['amenities'] = array();
foreach ($this->amenities as $value)
{
$data['amenities'][] =
self::getFeatureId('amenities', $value, $this->language);
}
}
$validExtensions = array('jpg', 'JPG',
'jpeg', 'JPEG', 'gif', 'GIF',
'png', 'PNG');
$data['images'] = array();
foreach ($this->images as $image)
{
if (substr($image, 0, 4) == 'http')
{
$uri = new \Joomla\Uri\Uri($image);
$image = $uri->getPath();
}
$image = basename($image);
if (! empty($image))
{
if (in_array(File::getExt($image), $validExtensions))
{
$img = new stdClass;
$img->name = $image;
$img->title = '';
$img->description = '';
$data['images'][] = $img;
}
}
}
return $data;
}
/**
* Add a custom field to the interface
*
* @param string $fieldName The custom field name
* @param string $value The custom field value
*
* @return void
*/
public function addAdditionalField($fieldName = '', $value =
'')
{
$this->additionnalsFields[$fieldName] = $value;
}
/**
* Save the property
*
* @param string $provider A provider name
* @param number $id The property id
* @param boolean $forceUTF8 To force string to be converted into
UTF-8
*
* @return boolean return true if property was saved
*/
public function save($provider = '', $id = 0, $forceUTF8 =
false)
{
$db = JFactory::getDbo();
$property = new TableProperty($db);
$isNew = true;
$dispatcher = JDispatcher::getInstance();
// Include the jea plugins for the on save events.
JPluginHelper::importPlugin('jea');
if (! empty($id))
{
$property->load($id);
$isNew = false;
}
// Prepare data
$data = $this->toJEAData();
foreach ($this->additionnalsFields as $fieldName => $value)
{
$data[$fieldName] = $value;
}
if (! empty($provider))
{
$data['provider'] = $provider;
}
if ($forceUTF8)
{
foreach ($data as $k => $v)
{
switch ($k)
{
case 'title':
case 'description':
case 'address':
$data[$k] = utf8_encode($v);
}
}
}
$property->bind($data);
$property->check();
// Check override created_by
if (! empty($data['created_by']))
{
$property->created_by = $data['created_by'];
}
// Trigger the onContentBeforeSave event.
$result = $dispatcher->trigger('onBeforeSaveProperty',
array('com_jea.propertyInterface', &$property, $isNew));
if (in_array(false, $result, true))
{
$this->_errors = $property->getError();
return false;
}
$property->store();
// Trigger the onContentAfterSave event.
$dispatcher->trigger('onAfterSaveProperty',
array('com_jea.propertyInterface', &$property, $isNew));
$errors = $property->getErrors();
if (! empty($errors))
{
$this->_errors = $errors;
return false;
}
// Save images
if (!empty($this->images) && $this->saveImagesCallback ===
null)
{
$imgDir = JPATH_ROOT . '/images/com_jea/images/' .
$property->id;
if (!Folder::exists($imgDir))
{
Folder::create($imgDir);
}
$validExtensions = array('jpg', 'JPG',
'jpeg', 'JPEG', 'gif', 'GIF',
'png', 'PNG');
foreach ($this->images as $image)
{
$basename = basename($image);
if (substr($image, 0, 4) == 'http')
{
$uri = new \Joomla\Uri\Uri($image);
$basename = basename($uri->getPath());
}
if (!in_array(File::getExt($basename), $validExtensions))
{
// Not a valid Extension
continue;
}
if (substr($image, 0, 4) != 'http' &&
file_exists($image))
{
File::copy($image, $imgDir . '/' . $basename);
}
if (substr($image, 0, 4) == 'http')
{
if (File::exists($imgDir . '/' . $basename))
{
$localtime = $this->getLastModified($imgDir . '/' .
$basename);
$remotetime = $this->getLastModified($image);
if ($remotetime <= $localtime)
{
JLog::add(
sprintf(
"File %s is up to date. [local time: %u - remote time:
%u]",
$imgDir . '/' . $basename,
$localtime,
$remotetime
),
JLog::DEBUG,
'jea'
);
continue;
}
}
$this->downloadImage($image, $imgDir . '/' . $basename);
}
}
}
elseif (!empty($this->images) &&
is_callable($this->saveImagesCallback))
{
call_user_func_array($this->saveImagesCallback,
array($this->images, $property));
}
return true;
}
/**
* Download an image
*
* @param string $url The image URL
* @param string $dest The destination directory
*
* @return boolean
*/
protected function downloadImage($url = '', $dest =
'')
{
JLog::add("Download Image : $url", JLog::DEBUG,
'jea');
if (empty($url) || empty($dest))
{
return false;
}
$buffer = '';
$allow_url_fopen = (bool) ini_get('allow_url_fopen');
if ($allow_url_fopen)
{
$buffer = file_get_contents($url);
}
elseif (function_exists('curl_init'))
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Don't check SSL certificate
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$buffer = curl_exec($ch);
curl_close($ch);
}
return File::write($dest, $buffer);
}
/**
* Get Last modified time as Unix timestamp
*
* @param string $file A local or remote file
*
* @throws RuntimeException
* @return integer Unix timestamp
*/
public function getLastModified($file)
{
if (substr($file, 0, 4) != 'http' &&
file_exists($file))
{
$stat = stat($file);
return $stat['mtime'];
}
$allow_url_fopen = (bool) ini_get('allow_url_fopen');
$headers = array();
if ($allow_url_fopen)
{
$headers = get_headers($file);
}
elseif (function_exists('curl_init'))
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $file);
// Don't check SSL certificate
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_FILETIME, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
$out = curl_exec($curl);
curl_close($curl);
$headers = explode("\n", $out);
}
if (empty($headers))
{
throw new RuntimeException("Cannot get HTTP headers for
$file");
}
foreach ($headers as $header)
{
if (strpos($header, 'Last-Modified') !== false)
{
$matches = array();
if (preg_match('/:\s?(.*)$/m', $header, $matches) !== false)
{
$matches[1];
JLog::add(sprintf("Last-Modified: %s - Time: %u",
$matches[1], strtotime($matches[1])), JLog::DEBUG, 'jea');
return strtotime($matches[1]);
}
}
}
return 0;
}
/**
* Get Feature id related to its value
*
* @param string $tableName The feature table name
* @param string $fieldValue The value to store
* @param string $language The language code
* @param integer $parentId An optional parent id
*
* @return integer
*/
public static function getFeatureId($tableName = '', $fieldValue
= '', $language = null, $parentId = 0)
{
$fieldValue = trim($fieldValue);
$id = 0;
$r = self::_getJeaRowIfExists($tableName, 'value',
$fieldValue);
static $tablesOrdering = array();
if ($r === false && ! empty($fieldValue) && !
isset(self::$features[$tableName][$fieldValue]))
{
$db = JFactory::getDbo();
if (! isset($tablesOrdering[$tableName]))
{
$db->setQuery('SELECT MAX(ordering) FROM #__jea_' .
$tableName);
$tablesOrdering[$tableName] = intval($db->loadResult());
}
$maxord = $tablesOrdering[$tableName] += 1;
$query = $db->getQuery(true);
$query->insert('#__jea_' . $tableName);
$columns = array('value', 'ordering');
$values = $db->quote($fieldValue) . ',' . $maxord;
if ($tableName == 'towns')
{
$columns[] = 'department_id';
$values .= ',' . (int) $parentId;
}
elseif ($tableName == 'areas')
{
$columns[] = 'town_id';
$values .= ',' . (int) $parentId;
}
if ($language != null)
{
$columns[] = 'language';
$values .= ',' . $query->q($language);
}
$query->columns($columns);
$query->values($values);
$db->setQuery($query);
$db->query();
$id = $db->insertid();
self::$features[$tableName][$fieldValue] = $id;
}
elseif (isset(self::$features[$tableName][$fieldValue]))
{
$id = self::$features[$tableName][$fieldValue];
}
elseif (is_object($r))
{
$id = $r->id;
}
return $id;
}
/**
* Return a feature row if already extis in the database
*
* @param string $tableName The feature table name
* @param string $fieldName The feature field name
* @param string $fieldValue The feature field value
*
* @return boolean|object The feature row object or false if feature not
found
*/
protected static function _getJeaRowIfExists($tableName = '',
$fieldName = '', $fieldValue = '')
{
if (self::$tables === null)
{
$db = JFactory::getDbo();
self::$tables = array();
$tables = array(
'amenities',
'areas',
'conditions',
'departments',
'heatingtypes',
'hotwatertypes',
'properties',
'slogans',
'towns',
'types'
);
foreach ($tables as $tableName)
{
// Get all JEA datas
$db->setQuery('SELECT * FROM #__jea_' . $tableName);
self::$tables[$tableName] = $db->loadObjectList('id');
}
}
if (empty(self::$tables[$tableName]) || empty($fieldName) ||
empty($fieldValue))
{
return false;
}
foreach (self::$tables[$tableName] as $row)
{
if (! isset($row->$fieldName))
{
return false;
}
if ($row->$fieldName == $fieldValue)
{
return $row;
}
}
return false;
}
/**
* Get an user. Try to create an user if not found.
*
* @param string $email The user email
* @param string $name The user name
*
* @return integer Return the user id. Return 0 if the user cannot be
created.
*/
public static function getUserId($email = '', $name =
'')
{
if (self::$users == null)
{
$db = JFactory::getDbo();
$db->setQuery('SELECT `id`, `email` FROM `#__users`');
$rows = $db->loadObjectList();
foreach ($rows as $row)
{
self::$users[$row->email] = $row->id;
}
}
if (isset(self::$users[$email]))
{
return self::$users[$email];
}
else
{
$id = self::_createUser($email, $name);
if ($id != false)
{
self::$users[$email] = $id;
return $id;
}
}
return 0;
}
/**
* Create an user
*
* @param string $email The user email
* @param string $name The user name
*
* @return boolean|number return the user id or false if the user cannot
be created
*/
protected static function _createUser($email = '', $name =
'')
{
if (!MailHelper::isEmailAddress($email))
{
return false;
}
$splitMail = explode('@', $email);
$user = new User;
$params = array(
'username' => $splitMail[0] . uniqid(),
'name' => $name,
'email' => $email,
'block' => 0,
'sendEmail' => 0
);
$user->bind($params);
if (true === $user->save())
{
return $user->id;
}
return false;
}
/**
* Convert Unix timestamp to MYSQL date
*
* @param integer $timestamp An UNIX timestamp
* @param boolean $datetime If true return MYSQL DATETIME else return
MYSQL DATE
*
* @return string
*/
protected function _convertTimestampToMysqlDate($timestamp, $datetime =
true)
{
if (is_int($timestamp) && $timestamp > 0)
{
if ($datetime)
{
return date('Y-m-d H:i:s', $timestamp);
}
return date('Y-m-d', $timestamp);
}
return '';
}
}
property.php000064400000020750151157455100007151 0ustar00<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Administrator
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
/**
* Property model class.
*
* @package Joomla.Administrator
* @subpackage com_jea
*
* @see JModelAdmin
*
* @since 2.0
*/
class JeaModelProperty extends JModelAdmin
{
/**
* The event to trigger after saving the data.
*
* @var string
*/
protected $event_after_save = 'onAfterSaveProperty';
/**
* The event to trigger before saving the data.
*
* @var string
*/
protected $event_before_save = 'onBeforeSaveProperty';
/**
* Overrides parent method
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm|boolean A JForm object on success, false on failure
*
* @see JModelForm::getForm()
*/
public function getForm($data = array(), $loadData = true)
{
$dispatcher = JDispatcher::getInstance();
// Include the jea plugins for the on after load property form events.
JPluginHelper::importPlugin('jea');
$form = $this->loadForm('com_jea.property',
'property', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
$id = $jinput->get('id', 0);
$user = JFactory::getUser();
$item = $this->getItem($id);
// Remove deposit field if transaction type is not SELLING
if (empty($item->transaction_type) || $item->transaction_type ==
'SELLING')
{
$form->removeField('deposit');
$form->removeField('rate_frequency');
}
elseif ($item->transaction_type == 'RENTING')
{
$form->setFieldAttribute('price', 'label',
'COM_JEA_FIELD_PRICE_RENT_LABEL');
}
// Check for existing article.
// Modify the form based on Edit State access controls.
if ($id != 0 && (!
$user->authorise('core.edit.state',
'com_jea.property.' . (int) $id))
|| ($id == 0 && !
$user->authorise('core.edit.state', 'com_jea')))
{
// Disable fields for display.
$form->setFieldAttribute('featured', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving. The controller has already verified this
is an article you can edit.
$form->setFieldAttribute('featured', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// Trigger the onAfterLoadPropertyForm event.
$dispatcher->trigger('onAfterLoadPropertyForm',
array(&$form));
return $form;
}
/**
* Overrides parent method
*
* @param array $data The form data.
*
* @return boolean True on success, False on error.
*
* @see JModelAdmin::save()
*/
public function save($data)
{
// Include the jea plugins for the on save events.
JPluginHelper::importPlugin('jea');
// Alter the title for save as copy
if (JFactory::getApplication()->input->getCmd('task') ==
'save2copy')
{
$data['ref'] = JString::increment($data['ref']);
$data['title'] = JString::increment($data['title']);
$data['alias'] = JString::increment($data['alias'],
'dash');
}
if (empty($data['images']))
{
// Set a default empty json array
$data['images'] = '[]';
}
if (parent::save($data))
{
return $this->processImages();
}
return false;
}
/**
* Method to manage new uploaded images and to remove non existing images
from the gallery
*
* @return boolean true on success otherwise false
*/
public function processImages()
{
$upload = JeaUpload::getUpload('newimages');
$item = $this->getItem();
$images = json_decode($item->images);
if (empty($images))
{
$images = array();
}
$imageNames = array();
foreach ($images as $row)
{
$imageNames[$row->name] = $row->name;
}
$baseUploadDir = JPATH_ROOT . '/images/com_jea/images';
$validExtensions = array('jpg', 'JPG',
'jpeg', 'JPEG', 'gif', 'GIF',
'png', 'PNG');
if (!Folder::exists($baseUploadDir))
{
Folder::create($baseUploadDir);
}
$uploadDir = $baseUploadDir . '/' . $item->id;
if (is_array($upload))
{
foreach ($upload as $file)
{
if ($file->isPosted())
{
$file->setValidExtensions($validExtensions)->nameToSafe();
if (! Folder::exists($uploadDir))
{
Folder::create($uploadDir);
}
if ($file->moveTo($uploadDir))
{
if (! isset($imageNames[$file->name]))
{
$image = new stdClass;
$image->name = $file->name;
$image->title = '';
$image->description = '';
$images[] = $image;
// Update the list of image names
$imageNames[$image->name] = $image->name;
}
}
else
{
$errors = $file->getErrors();
foreach ($errors as $error)
{
$this->setError(JText::_($error));
}
return false;
}
}
}
$table = $this->getTable();
$table->load($item->id);
$table->images = json_encode($images);
$table->store();
}
if (Folder::exists($uploadDir))
{
// Remove image files
$list = Folder::files($uploadDir);
foreach ($list as $filename)
{
if (strpos($filename, 'thumb') === 0)
{
continue;
}
if (! isset($imageNames[$filename]))
{
$removeList = Folder::files($uploadDir, $filename . '$',
false, true);
foreach ($removeList as $removeFile)
{
File::delete($removeFile);
}
}
}
}
return true;
}
/**
* Method to toggle the featured setting of properties.
*
* @param array $pks The ids of the items to toggle.
* @param integer $value The value to toggle to.
*
* @return void.
*/
public function featured($pks, $value = 0)
{
// Sanitize the ids.
$pks = ArrayHelper::toInteger((array) $pks);
$db = $this->getDbo();
$db->setQuery('UPDATE #__jea_properties SET featured = ' .
(int) $value . ' WHERE id IN (' . implode(',', $pks) .
')');
$db->execute();
}
/**
* Method to copy a set of properties.
*
* @param array $pks The ids of the items to copy.
*
* @return void.
*/
public function copy($pks)
{
// Sanitize the ids.
$pks = (array) $pks;
ArrayHelper::toInteger($pks);
$table = $this->getTable();
$nextOrdering = $table->getNextOrder();
$fields = $table->getProperties();
unset($fields['id']);
unset($fields['checked_out']);
unset($fields['checked_out_time']);
$fields = array_keys($fields);
$query = 'SELECT ' . implode(', ', $fields) . '
FROM #__jea_properties WHERE id IN (' . implode(',', $pks) .
')';
$rows = $this->_getList($query);
foreach ($rows as $row)
{
$row = (array) $row;
$row['ref'] = JString::increment($row['ref']);
$row['title'] = JString::increment($row['title']);
$row['alias'] = JString::increment($row['alias'],
'dash');
$row['ordering'] = $nextOrdering;
$row['created'] = date('Y-m-d H:i:s');
$table->bind($row);
$table->store();
$nextOrdering ++;
}
}
/**
* Overrides parent method
*
* @param array $pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @see JModelAdmin::delete()
*/
public function delete(&$pks)
{
if (parent::delete($pks))
{
// Remove images folder
foreach ($pks as $id)
{
if (Folder::exists(JPATH_ROOT . '/images/com_jea/images/' .
$id))
{
Folder::delete(JPATH_ROOT . '/images/com_jea/images/' .
$id);
}
}
return true;
}
return false;
}
/**
* Overrides parent method
*
* @return array The default data is an empty array.
*
* @see JModelForm::loadFormData()
*/
protected function loadFormData()
{
// Check the session for previously entered form data. See
// JControllerForm::save()
$data =
JFactory::getApplication()->getUserState('com_jea.edit.property.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
return $data;
}
/**
* Overrides parent method
*
* @param JTable $table A JTable object.
*
* @return array An array of conditions to add to ordering queries.
*
* @see JModelAdmin::getReorderConditions()
*/
protected function getReorderConditions($table)
{
$db = $table->getDbo();
$condition = array();
$condition[] = 'transaction_type = ' .
$db->quote($table->transaction_type);
return $condition;
}
}
fields/pluginelement.php000064400000001606151157644450011412
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_plugins
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('PluginsHelper', JPATH_ADMINISTRATOR .
'/components/com_plugins/helpers/plugins.php');
JFormHelper::loadFieldClass('list');
/**
* Plugin Element field.
*
* @since 3.9.0
*/
class JFormFieldPluginElement extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.9.0
*/
protected $type = 'PluginElement';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.9.0
*/
public function getOptions()
{
$options = PluginsHelper::elementOptions();
return array_merge(parent::getOptions(), $options);
}
}
fields/pluginordering.php000064400000002642151157644460011574
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_plugins
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('ordering');
/**
* Supports an HTML select list of plugins.
*
* @since 1.6
*/
class JFormFieldPluginordering extends JFormFieldOrdering
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Pluginordering';
/**
* Builds the query for the ordering list.
*
* @return JDatabaseQuery The query for the ordering form field.
*/
protected function getQuery()
{
$db = JFactory::getDbo();
$folder = $this->form->getValue('folder');
// Build the query for the ordering list.
$query = $db->getQuery(true)
->select(
array(
$db->quoteName('ordering', 'value'),
$db->quoteName('name', 'text'),
$db->quoteName('type'),
$db->quote('folder'),
$db->quote('extension_id')
)
)
->from($db->quoteName('#__extensions'))
->where('(type =' . $db->quote('plugin') .
'AND folder=' . $db->quote($folder) . ')')
->order('ordering');
return $query;
}
/**
* Retrieves the current Item's Id.
*
* @return integer The current item ID.
*/
protected function getItemId()
{
return (int) $this->form->getValue('extension_id');
}
}
fields/plugintype.php000064400000001566151157644460010750 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_plugins
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('PluginsHelper', JPATH_ADMINISTRATOR .
'/components/com_plugins/helpers/plugins.php');
JFormHelper::loadFieldClass('list');
/**
* Plugin Type field.
*
* @since 3.5
*/
class JFormFieldPluginType extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
protected $type = 'PluginType';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.5
*/
public function getOptions()
{
$options = PluginsHelper::folderOptions();
return array_merge(parent::getOptions(), $options);
}
}
forms/filter_plugins.xml000064400000004461151157644460011464
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_plugins/models/fields"
/>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_PLUGINS_FILTER_SEARCH_LABEL"
description="COM_PLUGINS_SEARCH_IN_TITLE"
hint="JSEARCH_FILTER"
/>
<field
name="enabled"
type="plugin_status"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="folder"
type="plugintype"
onchange="this.form.submit();"
>
<option
value="">COM_PLUGINS_OPTION_FOLDER</option>
</field>
<field
name="element"
type="pluginelement"
onchange="this.form.submit();"
>
<option
value="">COM_PLUGINS_OPTION_ELEMENT</option>
</field>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_ACCESS</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="folder ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="enabled ASC">JSTATUS_ASC</option>
<option value="enabled DESC">JSTATUS_DESC</option>
<option value="name
ASC">JGLOBAL_TITLE_ASC</option>
<option value="name
DESC">JGLOBAL_TITLE_DESC</option>
<option value="folder
ASC">COM_PLUGINS_HEADING_FOLDER_ASC</option>
<option value="folder
DESC">COM_PLUGINS_HEADING_FOLDER_DESC</option>
<option value="element
ASC">COM_PLUGINS_HEADING_ELEMENT_ASC</option>
<option value="element
DESC">COM_PLUGINS_HEADING_ELEMENT_DESC</option>
<option value="access
ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="access
DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="extension_id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="extension_id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/plugin.xml000064400000002531151157644460007730 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_plugins/models/fields"
>
<field
name="extension_id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
default="0"
readonly="true"
class="readonly"
/>
<field
name="name"
type="hidden"
label="COM_PLUGINS_FIELD_NAME_LABEL"
description="COM_PLUGINS_FIELD_NAME_DESC"
/>
<field
name="enabled"
type="list"
label="JSTATUS"
description="COM_PLUGINS_FIELD_ENABLED_DESC"
class="chzn-color-state"
size="1"
default="1"
>
<option value="1">JENABLED</option>
<option value="0">JDISABLED</option>
</field>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
size="1"
/>
<field
name="ordering"
type="pluginordering"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
/>
<field
name="folder"
type="text"
label="COM_PLUGINS_FIELD_FOLDER_LABEL"
description="COM_PLUGINS_FIELD_FOLDER_DESC"
class="readonly"
size="20"
readonly="true"
/>
<field
name="element"
type="text"
label="COM_PLUGINS_FIELD_ELEMENT_LABEL"
description="COM_PLUGINS_FIELD_ELEMENT_DESC"
class="readonly"
size="20"
readonly="true"
/>
</fieldset>
</form>
plugin.php000064400000022541151157644460006574 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_plugins
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
/**
* Plugin model.
*
* @since 1.6
*/
class PluginsModelPlugin extends JModelAdmin
{
/**
* @var string The help screen key for the module.
* @since 1.6
*/
protected $helpKey = 'JHELP_EXTENSIONS_PLUGIN_MANAGER_EDIT';
/**
* @var string The help screen base URL for the module.
* @since 1.6
*/
protected $helpURL;
/**
* @var array An array of cached plugin items.
* @since 1.6
*/
protected $_cache;
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*/
public function __construct($config = array())
{
$config = array_merge(
array(
'event_after_save' => 'onExtensionAfterSave',
'event_before_save' => 'onExtensionBeforeSave',
'events_map' => array(
'save' => 'extension'
)
), $config
);
parent::__construct($config);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure.
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// The folder and element vars are passed when saving the form.
if (empty($data))
{
$item = $this->getItem();
$folder = $item->folder;
$element = $item->element;
}
else
{
$folder = ArrayHelper::getValue($data, 'folder',
'', 'cmd');
$element = ArrayHelper::getValue($data, 'element',
'', 'cmd');
}
// Add the default fields directory
JForm::addFieldPath(JPATH_PLUGINS . '/' . $folder .
'/' . $element . '/field');
// These variables are used to add data from the plugin XML files.
$this->setState('item.folder', $folder);
$this->setState('item.element', $element);
// Get the form.
$form = $this->loadForm('com_plugins.plugin',
'plugin', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Modify the form based on access controls.
if (!$this->canEditState((object) $data))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('enabled', 'disabled',
'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('enabled', 'filter',
'unset');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_plugins.edit.plugin.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_plugins.plugin', $data);
return $data;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($pk = null)
{
$pk = (!empty($pk)) ? $pk : (int)
$this->getState('plugin.id');
if (!isset($this->_cache[$pk]))
{
// Get a row instance.
$table = $this->getTable();
// Attempt to load the row.
$return = $table->load($pk);
// Check for a table object error.
if ($return === false && $table->getError())
{
$this->setError($table->getError());
return false;
}
// Convert to the JObject before adding other data.
$properties = $table->getProperties(1);
$this->_cache[$pk] = ArrayHelper::toObject($properties,
'JObject');
// Convert the params field to an array.
$registry = new Registry($table->params);
$this->_cache[$pk]->params = $registry->toArray();
// Get the plugin XML.
$path = JPath::clean(JPATH_PLUGINS . '/' . $table->folder .
'/' . $table->element . '/' . $table->element .
'.xml');
if (file_exists($path))
{
$this->_cache[$pk]->xml = simplexml_load_file($path);
}
else
{
$this->_cache[$pk]->xml = null;
}
}
return $this->_cache[$pk];
}
/**
* Returns a reference to the Table object, always creating it.
*
* @param string $type The table type to instantiate.
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*/
public function getTable($type = 'Extension', $prefix =
'JTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
// Execute the parent method.
parent::populateState();
$app = JFactory::getApplication('administrator');
// Load the User state.
$pk = $app->input->getInt('extension_id');
$this->setState('plugin.id', $pk);
}
/**
* Preprocess the form.
*
* @param JForm $form A form object.
* @param mixed $data The data expected for the form.
* @param string $group Cache group name.
*
* @return mixed True if successful.
*
* @throws Exception if there is an error in the form event.
* @since 1.6
*/
protected function preprocessForm(JForm $form, $data, $group =
'content')
{
jimport('joomla.filesystem.path');
$folder = $this->getState('item.folder');
$element = $this->getState('item.element');
$lang = JFactory::getLanguage();
// Load the core and/or local language sys file(s) for the ordering
field.
$db = $this->getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('element'))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' .
$db->quote($folder));
$db->setQuery($query);
$elements = $db->loadColumn();
foreach ($elements as $elementa)
{
$lang->load('plg_' . $folder . '_' . $elementa .
'.sys', JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load('plg_' . $folder . '_' . $elementa
. '.sys', JPATH_PLUGINS . '/' . $folder . '/'
. $elementa, null, false, true);
}
if (empty($folder) || empty($element))
{
$app = JFactory::getApplication();
$app->redirect(JRoute::_('index.php?option=com_plugins&view=plugins',
false));
}
$formFile = JPath::clean(JPATH_PLUGINS . '/' . $folder .
'/' . $element . '/' . $element . '.xml');
if (!file_exists($formFile))
{
throw new
Exception(JText::sprintf('COM_PLUGINS_ERROR_FILE_NOT_FOUND',
$element . '.xml'));
}
// Load the core and/or local language file(s).
$lang->load('plg_' . $folder . '_' . $element,
JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load('plg_' . $folder . '_' . $element,
JPATH_PLUGINS . '/' . $folder . '/' . $element, null,
false, true);
if (file_exists($formFile))
{
// Get the plugin form.
if (!$form->loadFile($formFile, false, '//config'))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
}
// Attempt to load the xml file.
if (!$xml = simplexml_load_file($formFile))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
// Get the help data from the XML file if present.
$help = $xml->xpath('/extension/help');
if (!empty($help))
{
$helpKey = trim((string) $help[0]['key']);
$helpURL = trim((string) $help[0]['url']);
$this->helpKey = $helpKey ?: $this->helpKey;
$this->helpURL = $helpURL ?: $this->helpURL;
}
// Trigger the default form events.
parent::preprocessForm($form, $data, $group);
}
/**
* A protected method to get a set of ordering conditions.
*
* @param object $table A record object.
*
* @return array An array of conditions to add to add to ordering
queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
$condition = array();
$condition[] = 'type = ' .
$this->_db->quote($table->type);
$condition[] = 'folder = ' .
$this->_db->quote($table->folder);
return $condition;
}
/**
* Override method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
// Setup type.
$data['type'] = 'plugin';
return parent::save($data);
}
/**
* Get the necessary data to load an item help screen.
*
* @return object An object with key, url, and local properties for
loading the item help screen.
*
* @since 1.6
*/
public function getHelp()
{
return (object) array('key' => $this->helpKey,
'url' => $this->helpURL);
}
/**
* Custom clean cache method, plugins are cached in 2 places for different
clients.
*
* @param string $group Cache group name.
* @param integer $clientId Application client id.
*
* @return void
*
* @since 1.6
*/
protected function cleanCache($group = null, $clientId = 0)
{
parent::cleanCache('com_plugins', 0);
parent::cleanCache('com_plugins', 1);
}
}
plugins.php000064400000017465151157644460006770 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_plugins
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Methods supporting a list of plugin records.
*
* @since 1.6
*/
class PluginsModelPlugins extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'extension_id', 'a.extension_id',
'name', 'a.name',
'folder', 'a.folder',
'element', 'a.element',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'state', 'a.state',
'enabled', 'a.enabled',
'access', 'a.access', 'access_level',
'ordering', 'a.ordering',
'client_id', 'a.client_id',
);
}
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.6
*/
protected function populateState($ordering = 'folder',
$direction = 'asc')
{
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string');
$this->setState('filter.search', $search);
$accessId = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', '',
'cmd');
$this->setState('filter.access', $accessId);
$state = $this->getUserStateFromRequest($this->context .
'.filter.enabled', 'filter_enabled', '',
'cmd');
$this->setState('filter.enabled', $state);
$folder = $this->getUserStateFromRequest($this->context .
'.filter.folder', 'filter_folder', '',
'string');
$this->setState('filter.folder', $folder);
$element = $this->getUserStateFromRequest($this->context .
'.filter.element', 'filter_element', '',
'string');
$this->setState('filter.element', $element);
// Load the parameters.
$params = JComponentHelper::getParams('com_plugins');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.enabled');
$id .= ':' . $this->getState('filter.folder');
$id .= ':' . $this->getState('filter.element');
return parent::getStoreId($id);
}
/**
* Returns an object list.
*
* @param JDatabaseQuery $query A database query object.
* @param integer $limitstart Offset.
* @param integer $limit The number of records.
*
* @return array
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$search = $this->getState('filter.search');
$ordering = $this->getState('list.ordering',
'ordering');
// If "Sort Table By:" is not set, set ordering to name
if ($ordering == '')
{
$ordering = 'name';
}
if ($ordering == 'name' || (!empty($search) &&
stripos($search, 'id:') !== 0))
{
$this->_db->setQuery($query);
$result = $this->_db->loadObjectList();
$this->translate($result);
if (!empty($search))
{
$escapedSearchString = $this->refineSearchStringToRegex($search,
'/');
foreach ($result as $i => $item)
{
if (!preg_match("/$escapedSearchString/i", $item->name))
{
unset($result[$i]);
}
}
}
$orderingDirection =
strtolower($this->getState('list.direction'));
$direction = ($orderingDirection == 'desc') ? -1 : 1;
$result = ArrayHelper::sortObjects($result, $ordering, $direction, true,
true);
$total = count($result);
$this->cache[$this->getStoreId('getTotal')] = $total;
if ($total < $limitstart)
{
$limitstart = 0;
$this->setState('list.start', 0);
}
return array_slice($result, $limitstart, $limit ?: null);
}
else
{
if ($ordering == 'ordering')
{
$query->order('a.folder ASC');
$ordering = 'a.ordering';
}
$query->order($this->_db->quoteName($ordering) . ' '
. $this->getState('list.direction'));
if ($ordering == 'folder')
{
$query->order('a.ordering ASC');
}
$result = parent::_getList($query, $limitstart, $limit);
$this->translate($result);
return $result;
}
}
/**
* Translate a list of objects.
*
* @param array &$items The array of objects.
*
* @return array The array of translated objects.
*/
protected function translate(&$items)
{
$lang = JFactory::getLanguage();
foreach ($items as &$item)
{
$source = JPATH_PLUGINS . '/' . $item->folder .
'/' . $item->element;
$extension = 'plg_' . $item->folder . '_' .
$item->element;
$lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null,
false, true)
|| $lang->load($extension . '.sys', $source, null, false,
true);
$item->name = JText::_($item->name);
}
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.extension_id , a.name, a.element, a.folder, a.checked_out,
a.checked_out_time,' .
' a.enabled, a.access, a.ordering'
)
)
->from($db->quoteName('#__extensions') . ' AS
a')
->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'));
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON
uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Filter by access level.
if ($access = $this->getState('filter.access'))
{
$query->where('a.access = ' . (int) $access);
}
// Filter by published state.
$published = $this->getState('filter.enabled');
if (is_numeric($published))
{
$query->where('a.enabled = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.enabled IN (0, 1))');
}
// Filter by state.
$query->where('a.state >= 0');
// Filter by folder.
if ($folder = $this->getState('filter.folder'))
{
$query->where('a.folder = ' . $db->quote($folder));
}
// Filter by element.
if ($element = $this->getState('filter.element'))
{
$query->where('a.element = ' . $db->quote($element));
}
// Filter by search in name or id.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.extension_id = ' . (int) substr($search,
3));
}
}
return $query;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 3.5
*/
protected function loadFormData()
{
$data = parent::loadFormData();
// Set the selected filter values for pages that use the JLayouts for
filtering
$data->list['sortTable'] =
$this->state->get('list.ordering');
$data->list['directionTable'] =
$this->state->get('list.direction');
return $data;
}
}
fields/index.html000064400000000054151160015500010000
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>forms/filter_relations.xml000064400000003420151160015500011752
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_hilation/models/rules"
addfieldpath="/administrator/components/com_hilation/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_HILATION_FILTER_SEARCH"
description="COM_HILATION_FILTER_SEARCH_RELATIONS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_HILATION_FILTER_PUBLISHED"
description="COM_HILATION_FILTER_PUBLISHED_RELATIONS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="accesslevel"
name="access"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/index.html000064400000000054151160015500007660
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>forms/relation.xml000064400000012614151160015500010227
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_hilation/models/rules"
addfieldpath="/administrator/components/com_hilation/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_HILATION_RELATION_CREATED_DATE_LABEL"
description="COM_HILATION_RELATION_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_HILATION_RELATION_CREATED_BY_LABEL"
description="COM_HILATION_RELATION_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_HILATION_RELATION_MODIFIED_DATE_LABEL"
description="COM_HILATION_RELATION_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_HILATION_RELATION_MODIFIED_BY_LABEL"
description="COM_HILATION_RELATION_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Access Field. Type: Accesslevel (joomla)-->
<field name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
default="1"
required="false" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_HILATION_RELATION_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_HILATION_RELATION_VERSION_LABEL"
description="COM_HILATION_RELATION_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="hilation relation" />
<!-- Dynamic Fields.-->
<!-- Userid Field. Type: User. (joomla)-->
<field type="user"
name="userid"
label="COM_HILATION_RELATION_USERID_LABEL"
description="COM_HILATION_RELATION_USERID_DESCRIPTION"
class="form-control"
required="true" />
<!-- Parent Field. Type: User. (joomla)-->
<field type="user"
name="parent"
label="COM_HILATION_RELATION_PARENT_LABEL"
description="COM_HILATION_RELATION_PARENT_DESCRIPTION"
class="form-control"
required="false" />
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this relation"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_hilation"
section="relation"
/>
</fieldset>
</form>hilation.php000064400000016744151160015500007072
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 13th July, 2022
@created 13th July, 2022
@package Hilation
@subpackage hilation.php
@author farhad shahbazi <http://lmskaran.ir>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Hilation Model
*/
class HilationModelHilation extends JModelList
{
public function getIcons()
{
// load user for access menus
$user = JFactory::getUser();
// reset icon array
$icons = array();
// view groups array
$viewGroups = array(
'main' => array('png.relations')
);
// view access array
$viewAccess = array(
'relations.access' => 'relation.access',
'relation.access' => 'relation.access',
'relations.submenu' => 'relation.submenu',
'relations.dashboard_list' =>
'relation.dashboard_list');
// loop over the $views
foreach($viewGroups as $group => $views)
{
$i = 0;
if (HilationHelper::checkArray($views))
{
foreach($views as $view)
{
$add = false;
// external views (links)
if (strpos($view,'||') !== false)
{
$dwd = explode('||', $view);
if (count($dwd) == 3)
{
list($type, $name, $url) = $dwd;
$viewName = $name;
$alt = $name;
$url = $url;
$image = $name . '.' . $type;
$name = 'COM_HILATION_DASHBOARD_' .
HilationHelper::safeString($name,'U');
}
}
// internal views
elseif (strpos($view,'.') !== false)
{
$dwd = explode('.', $view);
if (count($dwd) == 3)
{
list($type, $name, $action) = $dwd;
}
elseif (count($dwd) == 2)
{
list($type, $name) = $dwd;
$action = false;
}
if ($action)
{
$viewName = $name;
switch($action)
{
case 'add':
$url = 'index.php?option=com_hilation&view=' . $name
. '&layout=edit';
$image = $name . '_' . $action. '.' . $type;
$alt = $name . ' ' . $action;
$name =
'COM_HILATION_DASHBOARD_'.HilationHelper::safeString($name,'U').'_ADD';
$add = true;
break;
default:
// check for new convention (more stable)
if (strpos($action, '_qpo0O0oqp_') !== false)
{
list($action, $extension) = (array)
explode('_qpo0O0oqp_', $action);
$extension = str_replace('_po0O0oq_', '.',
$extension);
}
else
{
$extension = 'com_hilation.' . $name;
}
$url =
'index.php?option=com_categories&view=categories&extension='
. $extension;
$image = $name . '_' . $action . '.' . $type;
$alt = $viewName . ' ' . $action;
$name = 'COM_HILATION_DASHBOARD_' .
HilationHelper::safeString($name,'U') . '_' .
HilationHelper::safeString($action,'U');
break;
}
}
else
{
$viewName = $name;
$alt = $name;
$url = 'index.php?option=com_hilation&view=' .
$name;
$image = $name . '.' . $type;
$name = 'COM_HILATION_DASHBOARD_' .
HilationHelper::safeString($name,'U');
$hover = false;
}
}
else
{
$viewName = $view;
$alt = $view;
$url = 'index.php?option=com_hilation&view=' . $view;
$image = $view . '.png';
$name = ucwords($view).'<br /><br />';
$hover = false;
}
// first make sure the view access is set
if (HilationHelper::checkArray($viewAccess))
{
// setup some defaults
$dashboard_add = false;
$dashboard_list = false;
$accessTo = '';
$accessAdd = '';
// access checking start
$accessCreate = (isset($viewAccess[$viewName.'.create'])) ?
HilationHelper::checkString($viewAccess[$viewName.'.create']):false;
$accessAccess = (isset($viewAccess[$viewName.'.access'])) ?
HilationHelper::checkString($viewAccess[$viewName.'.access']):false;
// set main controllers
$accessDashboard_add =
(isset($viewAccess[$viewName.'.dashboard_add'])) ?
HilationHelper::checkString($viewAccess[$viewName.'.dashboard_add']):false;
$accessDashboard_list =
(isset($viewAccess[$viewName.'.dashboard_list'])) ?
HilationHelper::checkString($viewAccess[$viewName.'.dashboard_list']):false;
// check for adding access
if ($add && $accessCreate)
{
$accessAdd = $viewAccess[$viewName.'.create'];
}
elseif ($add)
{
$accessAdd = 'core.create';
}
// check if access to view is set
if ($accessAccess)
{
$accessTo = $viewAccess[$viewName.'.access'];
}
// set main access controllers
if ($accessDashboard_add)
{
$dashboard_add =
$user->authorise($viewAccess[$viewName.'.dashboard_add'],
'com_hilation');
}
if ($accessDashboard_list)
{
$dashboard_list =
$user->authorise($viewAccess[$viewName.'.dashboard_list'],
'com_hilation');
}
if (HilationHelper::checkString($accessAdd) &&
HilationHelper::checkString($accessTo))
{
// check access
if($user->authorise($accessAdd, 'com_hilation')
&& $user->authorise($accessTo, 'com_hilation')
&& $dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (HilationHelper::checkString($accessTo))
{
// check access
if($user->authorise($accessTo, 'com_hilation')
&& $dashboard_list)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (HilationHelper::checkString($accessAdd))
{
// check access
if($user->authorise($accessAdd, 'com_hilation')
&& $dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
$i++;
}
}
else
{
$icons[$group][$i] = false;
}
}
return $icons;
}
}
import.php000064400000047157151160015500006577 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage import.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\Utilities\ArrayHelper;
use PhpOffice\PhpSpreadsheet\IOFactory;
/**
* Moojla Import Model
*/
class MoojlaModelImport extends JModelLegacy
{
// set uploading values
protected $use_streams = false;
protected $allow_unsafe = false;
protected $safeFileOptions = array();
/**
* @var object JTable object
*/
protected $_table = null;
/**
* @var object JTable object
*/
protected $_url = null;
/**
* Model context string.
*
* @var string
*/
protected $_context = 'com_moojla.import';
/**
* Import Settings
*/
protected $getType = NULL;
protected $dataType = NULL;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
*/
protected function populateState()
{
$app = JFactory::getApplication('administrator');
$this->setState('message',
$app->getUserState('com_moojla.message'));
$app->setUserState('com_moojla.message', '');
// Recall the 'Import from Directory' path.
$path = $app->getUserStateFromRequest($this->_context .
'.import_directory', 'import_directory',
$app->get('tmp_path'));
$this->setState('import.directory', $path);
parent::populateState();
}
/**
* Import an spreadsheet from either folder, url or upload.
*
* @return boolean result of import
*
*/
public function import()
{
$this->setState('action', 'import');
$app = JFactory::getApplication();
$session = JFactory::getSession();
$package = null;
$continue = false;
// get import type
$this->getType = $app->input->getString('gettype',
NULL);
// get import type
$this->dataType =
$session->get('dataType_VDM_IMPORTINTO', NULL);
if ($package === null)
{
switch ($this->getType)
{
case 'folder':
// Remember the 'Import from Directory' path.
$app->getUserStateFromRequest($this->_context .
'.import_directory', 'import_directory');
$package = $this->_getPackageFromFolder();
break;
case 'upload':
$package = $this->_getPackageFromUpload();
break;
case 'url':
$package = $this->_getPackageFromUrl();
break;
case 'continue':
$continue = true;
$package = $session->get('package', null);
$package = json_decode($package, true);
// clear session
$session->clear('package');
$session->clear('dataType');
$session->clear('hasPackage');
break;
default:
$app->setUserState('com_moojla.message',
JText::_('COM_MOOJLA_IMPORT_NO_IMPORT_TYPE_FOUND'));
return false;
break;
}
}
// Was the package valid?
if (!$package || !$package['type'])
{
if (in_array($this->getType, array('upload',
'url')))
{
$this->remove($package['packagename']);
}
$app->setUserState('com_moojla.message',
JText::_('COM_MOOJLA_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE'));
return false;
}
// first link data to table headers
if(!$continue){
$package = json_encode($package);
$session->set('package', $package);
$session->set('dataType', $this->dataType);
$session->set('hasPackage', true);
return true;
}
// set the data
$headerList =
json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS',
false), true);
if (!$this->setData($package,$this->dataType,$headerList))
{
// There was an error importing the package
$msg = JText::_('COM_MOOJLA_IMPORT_ERROR');
$back = $session->get('backto_VDM_IMPORT', NULL);
if ($back)
{
$app->setUserState('com_moojla.redirect_url',
'index.php?option=com_moojla&view='.$back);
$session->clear('backto_VDM_IMPORT');
}
$result = false;
}
else
{
// Package imported sucessfully
$msg = JText::sprintf('COM_MOOJLA_IMPORT_SUCCESS',
$package['packagename']);
$back = $session->get('backto_VDM_IMPORT', NULL);
if ($back)
{
$app->setUserState('com_moojla.redirect_url',
'index.php?option=com_moojla&view='.$back);
$session->clear('backto_VDM_IMPORT');
}
$result = true;
}
// Set some model state values
$app->enqueueMessage($msg);
// remove file after import
$this->remove($package['packagename']);
$session->clear($this->getType.'_VDM_IMPORTHEADERS');
return $result;
}
/**
* Works out an importation spreadsheet from a HTTP upload
*
* @return spreadsheet definition or false on failure
*/
protected function _getPackageFromUpload()
{
// Get the uploaded file information
$app = JFactory::getApplication();
$input = $app->input;
// Do not change the filter type 'raw'. We need this to let
files containing PHP code to upload. See JInputFiles::get.
$userfile = $input->files->get('import_package', null,
'raw');
// Make sure that file uploads are enabled in php
if (!(bool) ini_get('file_uploads'))
{
$app->enqueueMessage(JText::_('COM_MOOJLA_IMPORT_MSG_WARNIMPORTFILE'),
'warning');
return false;
}
// If there is no uploaded file, we have a problem...
if (!is_array($userfile))
{
$app->enqueueMessage(JText::_('COM_MOOJLA_IMPORT_MSG_NO_FILE_SELECTED'),
'warning');
return false;
}
// Check if there was a problem uploading the file.
if ($userfile['error'] || $userfile['size'] < 1)
{
$app->enqueueMessage(JText::_('COM_MOOJLA_IMPORT_MSG_WARNIMPORTUPLOADERROR'),
'warning');
return false;
}
// Build the appropriate paths
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path') . '/' .
$userfile['name'];
$tmp_src = $userfile['tmp_name'];
// Move uploaded file
jimport('joomla.filesystem.file');
$p_file = File::upload($tmp_src, $tmp_dest, $this->use_streams,
$this->allow_unsafe, $this->safeFileOptions);
// Was the package downloaded?
if (!$p_file)
{
$session = JFactory::getSession();
$session->clear('package');
$session->clear('dataType');
$session->clear('hasPackage');
// was not uploaded
return false;
}
// check that this is a valid spreadsheet
$package = $this->check($userfile['name']);
return $package;
}
/**
* Import an spreadsheet from a directory
*
* @return array Spreadsheet details or false on failure
*
*/
protected function _getPackageFromFolder()
{
$app = JFactory::getApplication();
$input = $app->input;
// Get the path to the package to import
$p_dir = $input->getString('import_directory');
$p_dir = JPath::clean($p_dir);
// Did you give us a valid path?
if (!file_exists($p_dir))
{
$app->enqueueMessage(JText::_('COM_MOOJLA_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'),
'warning');
return false;
}
// Detect the package type
$type = $this->getType;
// Did you give us a valid package?
if (!$type)
{
$app->enqueueMessage(JText::_('COM_MOOJLA_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'),
'warning');
}
// check the extention
if(!$this->checkExtension($p_dir))
{
// set error message
$app->enqueueMessage(JText::_('COM_MOOJLA_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'),
'warning');
return false;
}
$package['packagename'] = null;
$package['dir'] = $p_dir;
$package['type'] = $type;
return $package;
}
/**
* Import an spreadsheet from a URL
*
* @return Package details or false on failure
*
*/
protected function _getPackageFromUrl()
{
$app = JFactory::getApplication();
$input = $app->input;
// Get the URL of the package to import
$url = $input->getString('import_url');
// Did you give us a URL?
if (!$url)
{
$app->enqueueMessage(JText::_('COM_MOOJLA_IMPORT_MSG_ENTER_A_URL'),
'warning');
return false;
}
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file)
{
$app->enqueueMessage(JText::_('COM_MOOJLA_IMPORT_MSG_INVALID_URL'),
'warning');
return false;
}
// check that this is a valid spreadsheet
$package = $this->check($p_file);
return $package;
}
/**
* Check a file and verifies it as a spreadsheet file
* Supports .csv .xlsx .xls and .ods
*
* @param string $p_filename The uploaded package filename or import
directory
*
* @return array of elements
*
*/
protected function check($archivename)
{
$app = JFactory::getApplication();
// Clean the name
$archivename = JPath::clean($archivename);
// check the extention
if(!$this->checkExtension($archivename))
{
// Cleanup the import files
$this->remove($archivename);
$app->enqueueMessage(JText::_('COM_MOOJLA_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'),
'warning');
return false;
}
$config = JFactory::getConfig();
// set Package Name
$check['packagename'] = $archivename;
// set directory
$check['dir'] = $config->get('tmp_path').
'/' .$archivename;
// set type
$check['type'] = $this->getType;
return $check;
}
/**
* Check the extension
*
* @param string $file Name of the uploaded file
*
* @return boolean True on success
*
*/
protected function checkExtension($file)
{
// check the extention
switch(strtolower(pathinfo($file, PATHINFO_EXTENSION)))
{
case 'xls':
case 'ods':
case 'csv':
return true;
break;
}
return false;
}
/**
* Clean up temporary uploaded spreadsheet
*
* @param string $package Name of the uploaded spreadsheet file
*
* @return boolean True on success
*
*/
protected function remove($package)
{
jimport('joomla.filesystem.file');
$config = JFactory::getConfig();
$package = $config->get('tmp_path'). '/'
.$package;
// Is the package file a valid file?
if (is_file($package))
{
File::delete($package);
}
elseif (is_file(JPath::clean($package)))
{
// It might also be just a base filename
File::delete(JPath::clean($package));
}
}
/**
* Set the data from the spreadsheet to the database
*
* @param string $package Paths to the uploaded package file
*
* @return boolean false on failure
*
**/
protected function setData($package,$table,$target_headers)
{
if (MoojlaHelper::checkArray($target_headers))
{
// make sure the file is loaded
MoojlaHelper::composerAutoload('phpspreadsheet');
$jinput = JFactory::getApplication()->input;
foreach($target_headers as $header)
{
if (($column = $jinput->getString($header, false)) !== false ||
($column = $jinput->getString(strtolower($header), false)) !==
false)
{
$data['target_headers'][$header] = $column;
}
else
{
$data['target_headers'][$header] = null;
}
}
// set the data
if(isset($package['dir']))
{
$inputFileType = IOFactory::identify($package['dir']);
$excelReader = IOFactory::createReader($inputFileType);
$excelReader->setReadDataOnly(true);
$excelObj = $excelReader->load($package['dir']);
$data['array'] =
$excelObj->getActiveSheet()->toArray(null, true,true,true);
$excelObj->disconnectWorksheets();
unset($excelObj);
return $this->save($data, $table);
}
}
return false;
}
/**
* Save the data from the file to the database
*
* @param string $package Paths to the uploaded package file
*
* @return boolean false on failure
*
**/
protected function save($data,$table)
{
// import the data if there is any
if(MoojlaHelper::checkArray($data['array']))
{
// get user object
$user = JFactory::getUser();
// remove header if it has headers
$id_key = $data['target_headers']['id'];
$published_key =
$data['target_headers']['published'];
$ordering_key = $data['target_headers']['ordering'];
// get the first array set
$firstSet = reset($data['array']);
// check if first array is a header array and remove if true
if($firstSet[$id_key] == 'id' || $firstSet[$published_key] ==
'published' || $firstSet[$ordering_key] == 'ordering')
{
array_shift($data['array']);
}
// make sure there is still values in array and that it was not only
headers
if(MoojlaHelper::checkArray($data['array']) &&
$user->authorise($table.'.import', 'com_moojla')
&& $user->authorise('core.import',
'com_moojla'))
{
// set target.
$target = array_flip($data['target_headers']);
// Get a db connection.
$db = JFactory::getDbo();
// set some defaults
$todayDate = JFactory::getDate()->toSql();
// get global action permissions
$canDo = MoojlaHelper::getActions($table);
$canEdit = $canDo->get('core.edit');
$canState = $canDo->get('core.edit.state');
$canCreate = $canDo->get('core.create');
$hasAlias = $this->getAliasesUsed($table);
// prosses the data
foreach($data['array'] as $row)
{
$found = false;
if (isset($row[$id_key]) && is_numeric($row[$id_key])
&& $row[$id_key] > 0)
{
// raw items import & update!
$query = $db->getQuery(true);
$query
->select('version')
->from($db->quoteName('#__moojla_'.$table))
->where($db->quoteName('id') . ' = '.
$db->quote($row[$id_key]));
// Reset the query using our newly populated query object.
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
}
if($found && $canEdit)
{
// update item
$id = $row[$id_key];
$version = $db->loadResult();
// reset all buckets
$query = $db->getQuery(true);
$fields = array();
// Fields to update.
foreach($row as $key => $cell)
{
// ignore column
if ('IGNORE' == $target[$key])
{
continue;
}
// update modified
if ('modified_by' == $target[$key])
{
continue;
}
// update modified
if ('modified' == $target[$key])
{
continue;
}
// update version
if ('version' == $target[$key])
{
$cell = (int) $version + 1;
}
// verify publish authority
if ('published' == $target[$key] && !$canState)
{
continue;
}
// set to update array
if(in_array($key, $data['target_headers']) &&
is_numeric($cell))
{
$fields[] = $db->quoteName($target[$key]) . ' = ' .
$cell;
}
elseif(in_array($key, $data['target_headers']) &&
is_string($cell))
{
$fields[] = $db->quoteName($target[$key]) . ' = ' .
$db->quote($cell);
}
elseif(in_array($key, $data['target_headers']) &&
is_null($cell))
{
// if import data is null then set empty
$fields[] = $db->quoteName($target[$key]) . " =
''";
}
}
// load the defaults
$fields[] = $db->quoteName('modified_by') . ' =
' . $db->quote($user->id);
$fields[] = $db->quoteName('modified') . ' = '
. $db->quote($todayDate);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('id') . ' = ' . $id
);
$query->update($db->quoteName('#__moojla_'.$table))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
elseif ($canCreate)
{
// insert item
$query = $db->getQuery(true);
// reset all buckets
$columns = array();
$values = array();
$version = false;
// Insert columns. Insert values.
foreach($row as $key => $cell)
{
// ignore column
if ('IGNORE' == $target[$key])
{
continue;
}
// remove id
if ('id' == $target[$key])
{
continue;
}
// update created
if ('created_by' == $target[$key])
{
continue;
}
// update created
if ('created' == $target[$key])
{
continue;
}
// Make sure the alias is incremented
if ('alias' == $target[$key])
{
$cell = $this->getAlias($cell,$table);
}
// update version
if ('version' == $target[$key])
{
$cell = 1;
$version = true;
}
// set to insert array
if(in_array($key, $data['target_headers']) &&
is_numeric($cell))
{
$columns[] = $target[$key];
$values[] = $cell;
}
elseif(in_array($key, $data['target_headers']) &&
is_string($cell))
{
$columns[] = $target[$key];
$values[] = $db->quote($cell);
}
elseif(in_array($key, $data['target_headers']) &&
is_null($cell))
{
// if import data is null then set empty
$columns[] = $target[$key];
$values[] = "''";
}
}
// load the defaults
$columns[] = 'created_by';
$values[] = $db->quote($user->id);
$columns[] = 'created';
$values[] = $db->quote($todayDate);
if (!$version)
{
$columns[] = 'version';
$values[] = 1;
}
// Prepare the insert query.
$query
->insert($db->quoteName('#__moojla_'.$table))
->columns($db->quoteName($columns))
->values(implode(',', $values));
// Set the query using our newly populated query object and execute
it.
$db->setQuery($query);
$done = $db->execute();
if ($done)
{
$aId = $db->insertid();
// make sure the access of asset is set
MoojlaHelper::setAsset($aId,$table);
}
}
else
{
return false;
}
}
return true;
}
}
return false;
}
protected function getAlias($name,$type = false)
{
// sanitize the name to an alias
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
$alias = JFilterOutput::stringURLUnicodeSlug($name);
}
else
{
$alias = JFilterOutput::stringURLSafe($name);
}
// must be a uniqe alias
if ($type)
{
return $this->getUniqe($alias,'alias',$type);
}
return $alias;
}
/**
* Method to generate a uniqe value.
*
* @param string $field name.
* @param string $value data.
* @param string $type table.
*
* @return string New value.
*/
protected function getUniqe($value,$field,$type)
{
// insure the filed is always uniqe
while (isset($this->uniqeValueArray[$type][$field][$value]))
{
$value = JString::increment($value, 'dash');
}
$this->uniqeValueArray[$type][$field][$value] = $value;
return $value;
}
protected function getAliasesUsed($table)
{
// Get a db connection.
$db = JFactory::getDbo();
// first we check if there is a alias column
$columns = $db->getTableColumns('#__moojla_'.$table);
if(isset($columns['alias'])){
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('alias')));
$query->from($db->quoteName('#__moojla_'.$table));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$aliases = $db->loadColumn();
foreach($aliases as $alias)
{
$this->uniqeValueArray[$table]['alias'][$alias] = $alias;
}
}
return true;
}
return false;
}
}
index.html000064400000000054151160015500006532 0ustar00<html><body
bgcolor="#FFFFFF"></body></html>relation.php000064400000052270151160015500007072
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 13th July, 2022
@created 13th July, 2022
@package Hilation
@subpackage relation.php
@author farhad shahbazi <http://lmskaran.ir>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Hilation Relation Model
*/
class HilationModelRelation extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'userid'
),
'right' => array(
'parent'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_HILATION';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_hilation.relation';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'relation', $prefix =
'HilationTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_hilation/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_hilation.relation',
'relation', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_hilation.relation.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state',
'com_hilation')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_hilation'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_hilation'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_hilation/js/relation.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_hilation.relation.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_hilation.relation.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_hilation.relation.'. ((int) isset($data[$key]) ? $data[$key]
: 0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__hilation_relation'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_hilation.edit.relation.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_hilation.relation', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = HilationHelper::getActions('relation');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = HilationHelper::getActions('relation');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Only for strings
if (HilationHelper::checkString($this->table->userid) &&
!is_numeric($this->table->userid))
{
$this->table->userid =
$this->generateUnique('userid',$this->table->userid);
}
// insert all set values
if (HilationHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (HilationHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = HilationHelper::getActions('relation');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (HilationHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (HilationHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
relations.php000064400000024225151160015500007254 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 13th July, 2022
@created 13th July, 2022
@package Hilation
@subpackage relations.php
@author farhad shahbazi <http://lmskaran.ir>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Relations Model
*/
class HilationModelRelations extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.access','access',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the hilation_item table
$query->from($db->quoteName('#__hilation_relation',
'a'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Filter by access level.
$_access = $this->getState('filter.access');
if ($_access && is_numeric($_access))
{
$query->where('a.access = ' . (int) $_access);
}
elseif (HilationHelper::checkArray($_access))
{
// Secure the array for the query
$_access = ArrayHelper::toInteger($_access);
// Filter by the Access Array.
$query->where('a.access IN (' . implode(',',
$_access) . ')');
}
// Implement View Level Access
if (!$user->authorise('core.options',
'com_hilation'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get list export data.
*
* @param array $pks The ids of the items to get
* @param JUser $user The user making the request
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExportData($pks, $user = null)
{
// setup the query
if (($pks_size = HilationHelper::checkArray($pks)) !== false ||
'bulk' === $pks)
{
// Set a value to know this is export method. (USE IN CUSTOM CODE TO
ALTER OUTCOME)
$_export = true;
// Get the user object if not set.
if (!isset($user) || !HilationHelper::checkObject($user))
{
$user = JFactory::getUser();
}
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the hilation_relation table
$query->from($db->quoteName('#__hilation_relation',
'a'));
// The bulk export path
if ('bulk' === $pks)
{
$query->where('a.id > 0');
}
// A large array of ID's will not work out well
elseif ($pks_size > 500)
{
// Use lowest ID
$query->where('a.id >= ' . (int) min($pks));
// Use highest ID
$query->where('a.id <= ' . (int) max($pks));
}
// The normal default path
else
{
$query->where('a.id IN (' . implode(',',$pks) .
')');
}
// Implement View Level Access
if (!$user->authorise('core.options',
'com_hilation'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Order the results by ordering
$query->order('a.ordering ASC');
// Load the items
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$items = $db->loadObjectList();
// Set values to display correctly.
if (HilationHelper::checkArray($items))
{
foreach ($items as $nr => &$item)
{
// unset the values we don't want exported.
unset($item->asset_id);
unset($item->checked_out);
unset($item->checked_out_time);
}
}
// Add headers to items array.
$headers = $this->getExImPortHeaders();
if (HilationHelper::checkObject($headers))
{
array_unshift($items,$headers);
}
return $items;
}
}
return false;
}
/**
* Method to get header.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExImPortHeaders()
{
// Get a db connection.
$db = JFactory::getDbo();
// get the columns
$columns = $db->getTableColumns("#__hilation_relation");
if (HilationHelper::checkArray($columns))
{
// remove the headers you don't import/export.
unset($columns['asset_id']);
unset($columns['checked_out']);
unset($columns['checked_out_time']);
$headers = new stdClass();
foreach ($columns as $column => $type)
{
$headers->{$column} = $column;
}
return $headers;
}
return false;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
// Check if the value is an array
$_access = $this->getState('filter.access');
if (HilationHelper::checkArray($_access))
{
$id .= ':' . implode(':', $_access);
}
// Check if this is only an number or string
elseif (is_numeric($_access)
|| HilationHelper::checkString($_access))
{
$id .= ':' . $_access;
}
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_hilation')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__hilation_relation'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__hilation_relation'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
rules/index.html000064400000000054151160015500007664
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>dashboard.php000064400000001530151160433710007204
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_notifly
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Feature model.
*
* @since 1.6
*/
class NotiflyModelDashboard extends JModelItem
{
/**
* Returns a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Dashboard', $prefix =
'NotiflyTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
}
design.php000064400000005316151160433740006537 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_notifly
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Feature model.
*
* @since 1.6
*/
class NotiflyModelDesign extends JModelForm
{
/**
* Method to get a form object.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.0.0
*/
public function getForm($data = array(), $loadData = true)
{
$form = $this->loadForm('com_notifly.design',
'design', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Get the component information.
*
* @return object
*
* @since 1.0.0
*/
public function getComponent()
{
$state = $this->getState();
$option = 'com_notifly';
// Load common and local language files.
$lang = JFactory::getLanguage();
$lang->load($option, JPATH_BASE, null, false, true)
|| $lang->load($option, JPATH_BASE .
"/components/com_notifly", null, false, true);
$result = JComponentHelper::getComponent($option);
return $result;
}
/**
* Method to save the configuration data.
*
* @param array $data An array containing all global design data.
*
* @return boolean True on success, false on failure.
*
* @since 1.0.0
* @throws RuntimeException
*/
public function save($data)
{
$table = JTable::getInstance('extension');
// Load the previous Data
if (!$table->load($data['id']))
{
throw new RuntimeException($table->getError());
}
unset($data['id']);
// Bind the data.
if (!$table->bind($data))
{
throw new RuntimeException($table->getError());
}
// Check the data.
if (!$table->check())
{
throw new RuntimeException($table->getError());
}
// Store the data.
if (!$table->store())
{
throw new RuntimeException($table->getError());
}
$this->cleanCache();
return true;
}
/**
* Custom clean cache method, plugins are cached in 2 places for different
clients.
*
* @param string $group Cache group name.
* @param integer $client_id Application client id.
*
* @return void
*
* @since 1.6
*/
protected function cleanCache($group = null, $client_id = 0)
{
parent::cleanCache('_system', 0);
parent::cleanCache('_system', 1);
parent::cleanCache('com_notifly');
}
public static function getConfigs(){
$comInfo = JComponentHelper::getComponent('com_notifly');
return $comInfo->params;
}
}
event.php000064400000024436151160433740006413 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_notifly
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
use Joomla\String\StringHelper;
JLoader::register('NotiflyHelper', JPATH_ADMINISTRATOR .
'/components/com_notifly/helpers/notifly.php');
/**
* Feature model.
*
* @since 1.6
*/
class NotiflyModelEvent extends JModelAdmin
{
/**
* The prefix to use with controller messages.
*
* @var string
* @since 1.6
*/
protected $text_prefix = 'COM_NOTIFLY';
/**
* The type alias for this content type (for example,
'com_notifly.event').
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_notifly.event';
/**
* The context used for the associations table
*
* @var string
* @since 3.4.4
*/
protected $associationsContext = 'com_notifly.item';
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->state != -2)
{
return false;
}
return JFactory::getUser()->authorise('core.delete',
'com_notifly.event.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
// Check for existing event.
if (!empty($record->id))
{
return $user->authorise('core.edit.state',
'com_notifly.event.' . (int) $record->id);
}
// Default to component settings if neither event nor category known.
return parent::canEditState($record);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
// Set the publish date to now
if ($table->state == 1 && (int) $table->publish_up == 0)
{
$table->publish_up = JFactory::getDate()->toSql();
}
if ($table->state == 1 && intval($table->publish_down) ==
0)
{
$table->publish_down = $this->getDbo()->getNullDate();
}
// Increment the content version number.
$table->version++;
}
/**
* Returns a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*/
public function getTable($type = 'Event', $prefix =
'NotiflyTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
$template = $this->getTemplateInfo($item->template_id);
$item->template = $template->name;
// Convert the params field to an array.
$registry = new Registry($item->attribs);
$item->attribs = $registry->toArray();
}
return $item;
}
public function getTemplateInfo($extension_id){
$db = JFactory::getDBO();
$sql = "SELECT * from `#__notifly_templates` WHERE `id` =
'".$extension_id."'";
$db->setQuery($sql);
return $db->loadObject();
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm|boolean A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_notifly.event',
'event', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
/*
* The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
* The back end uses id so we use that the rest of the time and set it to
0 by default.
*/
$id = $jinput->get('a_id', $jinput->get('id',
0));
$user = JFactory::getUser();
// Check for existing event.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_notifly.event.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state',
'com_notifly')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('publish_up',
'disabled', 'true');
$form->setFieldAttribute('publish_down',
'disabled', 'true');
$form->setFieldAttribute('state', 'disabled',
'true');
// Disable fields while saving.
// The controller has already verified this is an event you can edit.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('publish_up', 'filter',
'unset');
$form->setFieldAttribute('publish_down',
'filter', 'unset');
$form->setFieldAttribute('state', 'filter',
'unset');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$app = JFactory::getApplication();
$data = $app->getUserState('com_notifly.edit.event.data',
array());
if (empty($data))
{
$data = $this->getItem();
// Pre-select some filters (Status, Category, Language, Access) in edit
form if those have been selected in Article Manager: Articles
if ($this->getState('event.id') == 0)
{
$filters = (array)
$app->getUserState('com_notifly.templates.filter');
$data->set(
'state',
$app->input->getInt(
'state',
((isset($filters['published']) &&
$filters['published'] !== '') ?
$filters['published'] : null)
)
);
$data->set('language',
$app->input->getString('language',
(!empty($filters['language']) ? $filters['language'] :
null)));
$data->set('access',
$app->input->getInt('access',
(!empty($filters['access']) ? $filters['access'] :
JFactory::getConfig()->get('access')))
);
}
}
// If there are params fieldsets in the form it will fail with a registry
object
if (isset($data->params) && $data->params instanceof
Registry)
{
$data->params = $data->params->toArray();
}
$this->preprocessData('com_notifly.event', $data);
return $data;
}
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return array|boolean Array of filtered data if valid, false
otherwise.
*
* @see JFormRule
* @see JFilterInput
* @since 3.7.0
*/
public function validate($form, $data, $group = null)
{
return parent::validate($form, $data, $group);
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// print_r($data);die;
// // Automatic handling of alias for empty fields
if (in_array($input->get('task'), array('apply',
'save', 'save2new')) &&
(!isset($data['id']) || (int) $data['id'] == 0))
{
if ($data['alias'] == null)
{
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
$data['alias'] =
JFilterOutput::stringURLUnicodeSlug($data['name']);
}
else
{
$data['alias'] =
JFilterOutput::stringURLSafe($data['name']);
}
$table = JTable::getInstance('Event',
'NotiflyTable');
if ($table->load(array('alias' =>
$data['alias'], 'extension_id' =>
$data['extension_id'])))
{
$msg = JText::_('COM_NOTIFLY_SAVE_WARNING');
}
list($name, $alias) =
$this->generateNewTitle($data['extension_id'],
$data['alias'], $data['name']);
$data['alias'] = $alias;
$data['name'] = $name;
if (isset($msg))
{
JFactory::getApplication()->enqueueMessage($msg,
'warning');
}
}
}
return parent::save($data);
}
/**
* Method to change the title & alias.
*
* @param integer $category_id The id of the category.
* @param string $alias The alias.
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
* @since 1.7
*/
protected function generateNewTitle($extension_id, $alias, $title)
{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias,
'extension_id' => $extension_id)))
{
$title = StringHelper::increment($title);
$alias = StringHelper::increment($alias, 'dash');
$alias = str_replace("-", "_", $alias);
}
return array($title, $alias);
}
/**
* Custom clean the cache of com_notifly and content modules
*
* @param string $group The cache group
* @param integer $client_id The ID of the client
*
* @return void
*
* @since 1.6
*/
protected function cleanCache($group = null, $client_id = 0)
{
parent::cleanCache('com_notifly');
}
/**
* Void hit function for pagebreak when editing content from frontend
*
* @return void
*
* @since 3.6.0
*/
public function hit()
{
return;
}
/**
* Delete #__content_frontpage items if the deleted articles was featured
*
* @param object &$pks The primary key related to the contents
that was deleted.
*
* @return boolean
*
* @since 3.7.0
*/
public function delete(&$pks)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__notifly_events'))
->where('id IN (' . implode(',', $pks) .
')');
$db->setQuery($query);
return $db->execute();
}
}
events.php000064400000014502151160433740006567 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_notifly
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Feature model.
*
* @since 1.6
*/
class NotiflyModelEvents extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 1.6
* @see JControllerLegacy
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'template_id', 'a.template_id',
'extension_id', 'a.extension_id',
'url', 'a.url',
'image_url', 'a.image_url',
'title', 'a.title',
'message', 't.message',
'name', 'a.name',
'email', 'a.email',
'ip', 'a.ip',
'city', 'a.city',
'state', 'a.state',
'country', 'a.country',
'created', 'a.created',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'state', 'a.state',
'access', 'a.access', 'access_level',
'ordering', 'a.ordering',
);
}
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.6
*/
protected function populateState($ordering = 'a.id', $direction
= 'desc')
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access');
// $extension_id = $app->input->post->get('');
$extension_id = $this->getUserStateFromRequest($this->context .
'.filter.extension_id', 'filter_extension_id');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' .
serialize($this->getState('filter.access'));
$id .= ':' .
serialize($this->getState('filter.access'));
$id .= ':' .
serialize($this->getState('filter.extension_id'));
$id .= ':' . $this->getState('filter.published');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*')
);
$query->from('#__notifly_events AS a');
// Join over the extensions.
$query->select('t.name AS template, t.message')
->join('LEFT', '#__notifly_templates AS t ON t.id =
a.template_id');
$query->select('ex.element AS integration')
->join('LEFT', '#__extensions AS ex ON ex.extension_id
= a.extension_id')
->where('ex.type="plugin" and
ex.folder="notifly"');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// show only the items enabled
$query->where('ex.enabled = 1');
// Filter by access level.
$extension_id = $this->getState('filter.extension_id');
if ($extension_id)
{
$query->where('ex.element = ' .
$db->quote($extension_id));
}
$access = $this->getState('filter.access');
if (is_numeric($access))
{
$query->where('a.access = ' . (int) $access);
}
elseif (is_array($access))
{
$access = ArrayHelper::toInteger($access);
$access = implode(',', $access);
$query->where('a.access IN (' . $access . ')');
}
// Filter by access level on categories.
if (!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
$query->where('c.access IN (' . $groups . ')');
}
// Filter by search in title.
$search = $this->getState('filter.search');
// if (!empty($search))
// {
// if (stripos($search, 'id:') === 0)
// {
// $query->where('a.id = ' . (int) substr($search, 3));
// }
// else
// {
// $search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
// $query->where('(a.name LIKE ' . $search . ' OR
a.alias LIKE ' . $search . ')');
// }
// }
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'DESC');
$query->order($db->escape($orderCol) . ' ' .
$db->escape($orderDirn));
// echo $query->__toString();die;
return $query;
}
/**
* Method to get a list of articles.
* Overridden to add a check for access levels.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 1.6.1
*/
public function getItems()
{
$items = parent::getItems();
if (JFactory::getApplication()->isClient('site'))
{
$groups = JFactory::getUser()->getAuthorisedViewLevels();
foreach (array_keys($items) as $x)
{
// Check the access level. Remove articles the user shouldn't see
if (!in_array($items[$x]->access, $groups))
{
unset($items[$x]);
}
}
}
return $items;
}
}
forms/design.xml000064400000013116151160433740007673 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields>
<fieldset name="design">
<field name="notifly_random" type="radio"
class="btn-group"
label="COM_NOTIFLY_DESIGN_NOTIFLY_RANDOM_LABEL"
description="COM_NOTIFLY_DESIGN_NOTIFLY_RANDOM_DESC"
default="1">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="notifly_loop" type="radio"
class="btn-group"
label="COM_NOTIFLY_DESIGN_NOTIFLY_LOOP_LABEL"
description="COM_NOTIFLY_DESIGN_NOTIFLY_LOOP_DESC"
default="1">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="allow_close" type="radio"
class="btn-group"
label="COM_NOTIFLY_DESIGN_ALLOW_CLOSE_LABEL"
description="COM_NOTIFLY_DESIGN_ALLOW_CLOSE_DESC"
default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="enable_hitcounter" type="radio"
class="btn-group"
label="COM_NOTIFLY_BEHAVIOR_ENABLE_HITCOUNTER_LABEL"
description="COM_NOTIFLY_BEHAVIOR_ENABLE_HITCOUNTER_DESC"
default="1">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="hide_mobile" type="radio"
class="btn-group"
label="COM_NOTIFLY_DESIGN_HIDE_MOBILE_LABEL"
description="COM_NOTIFLY_DESIGN_HIDE_MOBILE_DESC"
default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="hide_desktop" type="radio"
class="btn-group"
label="COM_NOTIFLY_DESIGN_HIDE_DESKTOP_LABEL"
description="COM_NOTIFLY_DESIGN_HIDE_DESKTOP_DESC"
default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="hide_user" type="radio"
class="btn-group"
label="COM_NOTIFLY_DESIGN_HIDE_USER_LABEL"
description="COM_NOTIFLY_DESIGN_HIDE_USER_DESC"
default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<!-- <field name="notify_delay_random"
type="radio" class="btn-group"
label="COM_NOTIFLY_DESIGN_NOTIFY_DELAY_RANDOM_LABEL"
description="COM_NOTIFLY_DESIGN_NOTIFY_DELAY_RANDOM_DESC"
default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field> -->
<!-- <field name="notify_newtab" type="radio"
class="btn-group"
label="COM_NOTIFLY_DESIGN_NOTIFY_NEWTAB_LABEL"
description="COM_NOTIFLY_DESIGN_NOTIFY_NEWTAB_DESC"
default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="notify_box_link" type="radio"
class="btn-group"
label="COM_NOTIFLY_DESIGN_NOTIFY_BOXLINK_LABEL"
description="COM_NOTIFLY_DESIGN_NOTIFY_BOXLINK_DESC"
default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field> -->
<!-- <field name="notify_max" type="radio"
class="btn-group"
label="COM_NOTIFLY_DESIGN_NOTIFY_MAX_LABEL"
description="COM_NOTIFLY_DESIGN_NOTIFY_MAX_DESC"
default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="notify_max_item" type="number"
label="COM_NOTIFLY_DESIGN_NOTIFY_MAX_ITEM_LABEL"
description="COM_NOTIFLY_DESIGN_NOTIFY_MAX_ITEM_DESC"
default="120" showon="notify_max:1" />
<field name="notify_max_time" type="number"
label="COM_NOTIFLY_DESIGN_NOTIFY_MAX_TIME_LABEL"
description="COM_NOTIFLY_DESIGN_NOTIFY_MAX_TIME_DESC"
default="60" showon="notify_max:1" /> -->
<field name="show_branding" type="radio"
class="btn-group"
label="COM_NOTIFLY_DESIGN_SHOW_BRANDING_LABEL"
description="COM_NOTIFLY_DESIGN_SHOW_BRANDING_DESC"
default="1">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
<fieldset name="behavior">
<field name="initial_delay" type="number"
label="COM_NOTIFLY_BEHAVIOR_INITIAL_DELAY_LABEL"
description="COM_NOTIFLY_BEHAVIOR_INITIAL_DELAY_DESC"
default="5" />
<field name="max_bypage" type="number"
label="COM_NOTIFLY_BEHAVIOR_MAX_BYPAGE_LABEL"
description="COM_NOTIFLY_BEHAVIOR_MAX_BYPAGE_DESC"
default="5" />
<field name="display_time" type="number"
label="COM_NOTIFLY_BEHAVIOR_DISPLAY_TIME_LABEL"
description="COM_NOTIFLY_BEHAVIOR_DISPLAY_TIME_DESC"
default="4" />
<field name="delay_time" type="number"
label="COM_NOTIFLY_BEHAVIOR_DELAY_TIME_LABEL"
description="COM_NOTIFLY_BEHAVIOR_DELAY_TIME_DESC"
default="12" />
<field name="expire_cookie" type="number"
label="COM_NOTIFLY_BEHAVIOR_EXPIRE_COOKIE_LABEL"
description="COM_NOTIFLY_BEHAVIOR_EXPIRE_COOKIE_DESC"
default="48" />
<field name="wrapper_width" type="text"
label="COM_NOTIFLY_BEHAVIOR_WRAPPER_WIDTH_LABEL"
description="COM_NOTIFLY_BEHAVIOR_WRAPPER_WIDTH_LABEL"
default="300px" />
<!-- <field name="box_position" type="list"
label="COM_NOTIFLY_BEHAVIOR_BOX_POSITION_LABEL"
description="COM_NOTIFLY_BEHAVIOR_BOX_POSITION_DESC"
default="bottom_left">
<option value="bottom_left">Bottom left</option>
<option value="bottom_right">Bottom
right</option>
<option value="top_left">Top left</option>
<option value="top_right">Top right</option>
<option value="top_center">Top center</option>
<option value="bottom_center">Bottom
center</option>
<option value="bottom_left_horizontal">Bottom left -
Slide In</option>
<option value="bottom_right_horizontal">Bottom right -
Slide In</option>
<option value="top_left_horizontal">Top left - Slide
In</option>
<option value="top_right_horizontal">Top right - Slide
In</option>
</field>
<field name="mobile_position" type="list"
label="COM_NOTIFLY_BEHAVIOR_MOBILE_POSITION_LABEL"
description="COM_NOTIFLY_BEHAVIOR_MOBILE_POSITION_LABEL"
default="bottom_left">
<option value="top">Top</option>
<option value="bottom">Bottom</option>
</field> -->
</fieldset>
</fields>
</form>
forms/event.xml000064400000007611151160433740007546 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
class="readonly"
size="10"
default="0"
readonly="true"
/>
<field
name="template_id"
type="hidden"
/>
<field
name="extension_id"
type="hidden"
/>
<field
name="template"
type="text"
label="COM_NOTIFLY_FIELD_TEMPLATE_LABEL"
description="COM_NOTIFLY_FIELD_TEMPLATE_DESC"
class="input-xxlarge input-large-text"
readonly="readonly"
size="40"
/>
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="JFIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="name"
type="text"
label="JGLOBAL_NAME"
description="JFIELD_NAME_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="email"
type="email"
label="JGLOBAL_EMAIL"
description="JFIELD_EMAIL_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="url"
type="text"
readonly="true"
label="COM_NOTIFLY_FIELD_URL_LABEL"
description="COM_NOTIFLY_FIELD_URL_DESC"
/>
<field
name="image_url"
type="text"
readonly="true"
label="COM_NOTIFLY_FIELD_IMAGE_URL_LABEL"
description="COM_NOTIFLY_FIELD_IMAGE_URL_DESC"
/>
<field
name="ip"
type="text"
readonly="true"
/>
<field
name="city"
type="city"
label="COM_NOTIFLY_FIELD_CITY_LABEL"
description="COM_NOTIFLY_FIELD_CITY_DESC"
/>
<field
name="state"
type="state"
label="COM_NOTIFLY_FIELD_STATE_LABEL"
description="COM_NOTIFLY_FIELD_STATE_DESC"
/>
<field
name="country"
type="country"
label="COM_NOTIFLY_FIELD_COUNTRY_LABEL"
description="COM_NOTIFLY_FIELD_COUNTRY_DESC"
/>
<field
name="published"
type="published"
label="COM_NOTIFLY_FIELD_PUBLISHED_LABEL"
description="COM_NOTIFLY_FIELD_PUBLISHED_DESC"
/>
<field
name="created"
type="text"
label="COM_NOTIFLY_FIELD_CREATED_LABEL"
description="COM_NOTIFLY_FIELD_CREATED_DESC"
readonly="true"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="publish_up"
type="calendar"
label="COM_NOTIFLY_FIELD_PUBLISH_UP_LABEL"
description="COM_NOTIFLY_FIELD_PUBLISH_UP_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="publish_down"
type="calendar"
label="COM_NOTIFLY_FIELD_PUBLISH_DOWN_LABEL"
description="COM_NOTIFLY_FIELD_PUBLISH_DOWN_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="version"
type="text"
label="COM_NOTIFLY_FIELD_VERSION_LABEL"
description="COM_NOTIFLY_FIELD_VERSION_DESC"
size="6"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
size="1"
/>
<field
name="hits"
type="text"
label="JGLOBAL_HITS"
description="COM_NOTIFLY_FIELD_HITS_DESC"
class="readonly"
size="6"
readonly="true"
filter="unset"
/>
<field
name="attribs"
type="text"
filter="unset"
/>
<field
name="params"
type="text"
filter="unset"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_NOTIFLY_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
<field
name="rules"
type="rules"
label="JFIELD_RULES_LABEL"
translate_label="false"
filter="rules"
component="com_notifly"
section="article"
validate="rules"
/>
</fieldset>
</form>
forms/filter_events.xml000064400000001011151160433740011262
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
label="COM_NOTIFLY_FILTER_SEARCH_LABEL"
description="COM_NOTIFLY_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field name="extension_id" type="plugins"
folder="notifly"
label="COM_NOTIFLY_FILTER_EXTENSION_LABEL"
description="COM_NOTIFLY_FILTER_EXTENSION_DESC"
onchange="this.form.submit();"
filter="cmd">
<option value="">COM_NOTIFLY_SHOW_ALL</option>
</field>
</fields>
</form>forms/filter_template.xml000064400000011233151160433740011600
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
label="COM_NOTIFLY_FILTER_SEARCH_LABEL"
description="COM_NOTIFLY_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
label="COM_NOTIFLY_FILTER_PUBLISHED"
description="COM_NOTIFLY_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
multiple="true"
class="multipleCategories"
extension="com_notifly"
onchange="this.form.submit();"
published="0,1,2"
/>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<field
name="author_id"
type="author"
label="COM_NOTIFLY_FILTER_AUTHOR"
description="COM_NOTIFLY_FILTER_AUTHOR_DESC"
multiple="true"
class="multipleAuthors"
onchange="this.form.submit();"
/>
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
<field
name="tag"
type="tag"
label="JOPTION_FILTER_TAG"
description="JOPTION_FILTER_TAG_DESC"
multiple="true"
class="multipleTags"
mode="nested"
onchange="this.form.submit();"
/>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_NOTIFLY_LIST_FULL_ORDERING"
description="COM_NOTIFLY_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.featured
ASC">JFEATURED_ASC</option>
<option value="a.featured
DESC">JFEATURED_DESC</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="category_title
ASC">JCATEGORY_ASC</option>
<option value="category_title
DESC">JCATEGORY_DESC</option>
<option value="a.access
ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="a.access
DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="association ASC"
requires="associations">JASSOCIATIONS_ASC</option>
<option value="association DESC"
requires="associations">JASSOCIATIONS_DESC</option>
<option value="a.created_by
ASC">JAUTHOR_ASC</option>
<option value="a.created_by
DESC">JAUTHOR_DESC</option>
<option value="language
ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="language
DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.created ASC">JDATE_ASC</option>
<option value="a.created DESC">JDATE_DESC</option>
<option value="a.modified
ASC">COM_NOTIFLY_MODIFIED_ASC</option>
<option value="a.modified
DESC">COM_NOTIFLY_MODIFIED_DESC</option>
<option value="a.publish_up
ASC">COM_NOTIFLY_PUBLISH_UP_ASC</option>
<option value="a.publish_up
DESC">COM_NOTIFLY_PUBLISH_UP_DESC</option>
<option value="a.publish_down
ASC">COM_NOTIFLY_PUBLISH_DOWN_ASC</option>
<option value="a.publish_down
DESC">COM_NOTIFLY_PUBLISH_DOWN_DESC</option>
<option value="a.hits
ASC">JGLOBAL_HITS_ASC</option>
<option value="a.hits
DESC">JGLOBAL_HITS_DESC</option>
<option value="rating_count ASC"
requires="vote">JGLOBAL_VOTES_ASC</option>
<option value="rating_count DESC"
requires="vote">JGLOBAL_VOTES_DESC</option>
<option value="rating ASC"
requires="vote">JGLOBAL_RATINGS_ASC</option>
<option value="rating DESC"
requires="vote">JGLOBAL_RATINGS_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_NOTIFLY_LIST_LIMIT"
description="COM_NOTIFLY_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/template.xml000064400000010520151160433740010231 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_categories/models/fields"
>
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
class="readonly"
size="10"
default="0"
readonly="true"
/>
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<field
name="extension_id"
type="sql"
label="COM_NOTIFLY_FIELD_EXTENSION_ID_LABEL"
readonly="true"
query="SELECT extension_id, name FROM `#__extensions` WHERE
`type` = 'plugin' AND `folder` = 'notifly'"
key_field="extension_id"
value_field="name"
required="true"
/>
<field
name="name"
type="text"
label="JGLOBAL_TITLE"
description="JFIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="alias"
type="text"
readonly="true"
label="COM_NOTIFLY_FIELD_ALIAS_LABEL"
description="COM_NOTIFLY_FIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER"
size="40"
/>
<field
name="message"
type="textarea"
label="COM_NOTIFLY_FIELD_MESSAGE_LABEL"
description="COM_NOTIFLY_FIELD_MESSAGE_DESC"
filter="JComponentHelper::filterText"
buttons="false"
height="100"
rows="3"
class="input-xxlarge input-large-text"
/>
<field
name="markdown"
type="radio"
label="COM_NOTIFLY_FIELD_MARKDOWN_LABEL"
description="COM_NOTIFLY_FIELD_MARKDOWN_DESC"
class="btn-group"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="image_disable"
type="radio"
label="COM_NOTIFLY_FIELD_IMAGE_DISABLE_LABEL"
description="COM_NOTIFLY_FIELD_IMAGE_DISABLE_DESC"
class="btn-group"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="avatar"
type="radio"
label="COM_NOTIFLY_FIELD_AVATAR_LABEL"
description="COM_NOTIFLY_FIELD_AVATAR_DESC"
class="btn-group"
default="1"
showon="image_disable:0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="image_url"
type="media"
class="input-xlarge"
label="COM_NOTIFLY_FIELD_IMAGE_URL_LABEL"
description="COM_NOTIFLY_FIELD_IMAGE_URL_DESC"
showon="image_disable:0[AND]avatar:0"
/>
<field
name="state"
type="hidden"
default="1"
/>
<field
name="created"
type="calendar"
label="COM_NOTIFLY_FIELD_CREATED_LABEL"
description="COM_NOTIFLY_FIELD_CREATED_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="publish_up"
type="calendar"
label="COM_NOTIFLY_FIELD_PUBLISH_UP_LABEL"
description="COM_NOTIFLY_FIELD_PUBLISH_UP_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="publish_down"
type="calendar"
label="COM_NOTIFLY_FIELD_PUBLISH_DOWN_LABEL"
description="COM_NOTIFLY_FIELD_PUBLISH_DOWN_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="version"
type="text"
label="COM_NOTIFLY_FIELD_VERSION_LABEL"
description="COM_NOTIFLY_FIELD_VERSION_DESC"
size="6"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="ordering"
type="text"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
size="6"
default="0"
/>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
size="1"
/>
<field
name="hits"
type="text"
label="JGLOBAL_HITS"
description="COM_NOTIFLY_FIELD_HITS_DESC"
class="readonly"
size="6"
readonly="true"
filter="unset"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_NOTIFLY_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
<field
name="rules"
type="rules"
label="JFIELD_RULES_LABEL"
translate_label="false"
filter="rules"
component="com_notifly"
section="article"
validate="rules"
/>
</fieldset>
</form>
integrations.php000064400000015710151160433740007773 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_notifly
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Feature model.
*
* @since 1.6
*/
class NotiflyModelIntegrations extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 1.6
* @see JControllerLegacy
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'extension_id', 'a.extension_id',
'name', 'a.name',
'element', 'a.element',
'enabled', 'a.enabled',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'state', 'a.state',
'access', 'a.access', 'access_level',
'ordering', 'a.ordering',
);
}
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.6
*/
protected function populateState($ordering = 'a.extension_id',
$direction = 'desc')
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' .
serialize($this->getState('filter.access'));
$id .= ':' . $this->getState('filter.published');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'DISTINCT a.extension_id, a.name, a.element, a.enabled,
a.checked_out_time' .
', a.state, a.access, a.ordering' .
', a.params, a.custom_data')
);
$query->from('#__extensions AS a');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Filter by access level.
$access = $this->getState('filter.access');
if (is_numeric($access))
{
$query->where('a.access = ' . (int) $access);
}
elseif (is_array($access))
{
$access = ArrayHelper::toInteger($access);
$access = implode(',', $access);
$query->where('a.access IN (' . $access . ')');
}
// Filter by access level on categories.
if (!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
$query->where('c.access IN (' . $groups . ')');
}
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.state = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.state = 0 OR a.state = 1)');
}
// Filter by search in title.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.extension_id = ' . (int) substr($search,
3));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('(a.name LIKE ' . $search . ' OR
a.element LIKE ' . $search . ')');
}
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.extension_id');
$orderDirn = $this->state->get('list.direction',
'DESC');
$query->where('a.type = "plugin"');
$query->where('a.folder = "notifly"');
$query->order($db->escape($orderCol) . ' ' .
$db->escape($orderDirn));
// echo $query->__toString();die;
return $query;
}
/**
* Method to get a list of articles.
* Overridden to add a check for access levels.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 1.6.1
*/
public function getItems()
{
$items = parent::getItems();
if (JFactory::getApplication()->isClient('site'))
{
$groups = JFactory::getUser()->getAuthorisedViewLevels();
foreach (array_keys($items) as $x)
{
// Check the access level. Remove articles the user shouldn't see
if (!in_array($items[$x]->access, $groups))
{
unset($items[$x]);
}
}
}
return $items;
}
/**
* Method to toggle the enable state of template
*
* @param array $pks The ids of the items to toggle.
* @param integer $value The value to toggle to.
*
* @return boolean True on success.
*/
public function enable($pks, $value = 0)
{
// Sanitize the ids.
$pks = (array) $pks;
$pks = ArrayHelper::toInteger($pks);
if (empty($pks))
{
$this->setError(JText::_('COM_NOTIFLY_NO_ITEM_SELECTED'));
return false;
}
try
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set('enabled = ' . (int) $value)
->where('extension_id IN (' . implode(',', $pks)
. ')');
// echo $query->__toString();die;
$db->setQuery($query);
$db->execute();
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
$this->cleanCache();
return true;
}
/**
* Custom clean the cache of com_content and content modules
*
* @param string $group The cache group
* @param integer $client_id The ID of the client
*
* @return void
*
* @since 1.6
*/
protected function cleanCache($group = null, $client_id = 0)
{
parent::cleanCache('com_notifly');
}
}
template.php000064400000111020151160433740007067 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Template model class.
*
* @since 1.6
*/
class TemplatesModelTemplate extends JModelForm
{
/**
* The information in a template
*
* @var stdClass
* @since 1.6
*/
protected $template = null;
/**
* The path to the template
*
* @var stdClass
* @since 3.2
*/
protected $element = null;
/**
* Internal method to get file properties.
*
* @param string $path The base path.
* @param string $name The file name.
*
* @return object
*
* @since 1.6
*/
protected function getFile($path, $name)
{
$temp = new stdClass;
if ($template = $this->getTemplate())
{
$temp->name = $name;
$temp->id = urlencode(base64_encode($path . $name));
return $temp;
}
}
/**
* Method to get a list of all the files to edit in a template.
*
* @return array A nested array of relevant files.
*
* @since 1.6
*/
public function getFiles()
{
$result = array();
if ($template = $this->getTemplate())
{
jimport('joomla.filesystem.folder');
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/');
$lang = JFactory::getLanguage();
// Load the core and/or local language file(s).
$lang->load('tpl_' . $template->element,
$client->path, null, false, true) ||
$lang->load('tpl_' . $template->element,
$client->path . '/templates/' . $template->element, null,
false, true);
$this->element = $path;
if (!is_writable($path))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_DIRECTORY_NOT_WRITABLE'),
'error');
}
if (is_dir($path))
{
$result = $this->getDirectoryTree($path);
}
else
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_TEMPLATE_FOLDER_NOT_FOUND'),
'error');
return false;
}
}
return $result;
}
/**
* Get the directory tree.
*
* @param string $dir The path of the directory to scan
*
* @return array
*
* @since 3.2
*/
public function getDirectoryTree($dir)
{
$result = array();
$dirFiles = scandir($dir);
foreach ($dirFiles as $key => $value)
{
if (!in_array($value, array('.', '..')))
{
if (is_dir($dir . $value))
{
$relativePath = str_replace($this->element, '', $dir .
$value);
$result['/' . $relativePath] =
$this->getDirectoryTree($dir . $value . '/');
}
else
{
$ext = pathinfo($dir . $value, PATHINFO_EXTENSION);
$allowedFormat = $this->checkFormat($ext);
if ($allowedFormat == true)
{
$relativePath = str_replace($this->element, '', $dir);
$info = $this->getFile('/' . $relativePath, $value);
$result[] = $info;
}
}
}
}
return $result;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
jimport('joomla.filesystem.file');
$app = JFactory::getApplication('administrator');
// Load the User state.
$pk = $app->input->getInt('id');
$this->setState('extension.id', $pk);
// Load the parameters.
$params = JComponentHelper::getParams('com_templates');
$this->setState('params', $params);
}
/**
* Method to get the template information.
*
* @return mixed Object if successful, false if not and internal error
is set.
*
* @since 1.6
*/
public function &getTemplate()
{
if (empty($this->template))
{
$pk = $this->getState('extension.id');
$db = $this->getDbo();
$app = JFactory::getApplication();
// Get the template information.
$query = $db->getQuery(true)
->select('extension_id, client_id, element, name,
manifest_cache')
->from('#__extensions')
->where($db->quoteName('extension_id') . ' =
' . (int) $pk)
->where($db->quoteName('type') . ' = ' .
$db->quote('template'));
$db->setQuery($query);
try
{
$result = $db->loadObject();
}
catch (RuntimeException $e)
{
$app->enqueueMessage($e->getMessage(), 'warning');
$this->template = false;
return false;
}
if (empty($result))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_EXTENSION_RECORD_NOT_FOUND'),
'error');
$this->template = false;
}
else
{
$this->template = $result;
}
}
return $this->template;
}
/**
* Method to check if new template name already exists
*
* @return boolean true if name is not used, false otherwise
*
* @since 2.5
*/
public function checkNewName()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('COUNT(*)')
->from('#__extensions')
->where('name = ' .
$db->quote($this->getState('new_name')));
$db->setQuery($query);
return ($db->loadResult() == 0);
}
/**
* Method to check if new template name already exists
*
* @return string name of current template
*
* @since 2.5
*/
public function getFromName()
{
return $this->getTemplate()->element;
}
/**
* Method to check if new template name already exists
*
* @return boolean true if name is not used, false otherwise
*
* @since 2.5
*/
public function copy()
{
$app = JFactory::getApplication();
if ($template = $this->getTemplate())
{
jimport('joomla.filesystem.folder');
$client = JApplicationHelper::getClientInfo($template->client_id);
$fromPath = JPath::clean($client->path . '/templates/' .
$template->element . '/');
// Delete new folder if it exists
$toPath = $this->getState('to_path');
if (JFolder::exists($toPath))
{
if (!JFolder::delete($toPath))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_COULD_NOT_WRITE'),
'error');
return false;
}
}
// Copy all files from $fromName template to $newName folder
if (!JFolder::copy($fromPath, $toPath) || !$this->fixTemplateName())
{
return false;
}
return true;
}
else
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_INVALID_FROM_NAME'),
'error');
return false;
}
}
/**
* Method to delete tmp folder
*
* @return boolean true if delete successful, false otherwise
*
* @since 2.5
*/
public function cleanup()
{
// Clear installation messages
$app = JFactory::getApplication();
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message',
'');
// Delete temporary directory
return JFolder::delete($this->getState('to_path'));
}
/**
* Method to rename the template in the XML files and rename the language
files
*
* @return boolean true if successful, false otherwise
*
* @since 2.5
*/
protected function fixTemplateName()
{
// Rename Language files
// Get list of language files
$result = true;
$files = JFolder::files($this->getState('to_path'),
'.ini', true, true);
$newName = strtolower($this->getState('new_name'));
$template = $this->getTemplate();
$oldName = $template->element;
$manifest = json_decode($template->manifest_cache);
jimport('joomla.filesystem.file');
foreach ($files as $file)
{
$newFile = '/' . str_replace($oldName, $newName,
basename($file));
$result = JFile::move($file, dirname($file) . $newFile) &&
$result;
}
// Edit XML file
$xmlFile = $this->getState('to_path') .
'/templateDetails.xml';
if (JFile::exists($xmlFile))
{
$contents = file_get_contents($xmlFile);
$pattern[] = '#<name>\s*' . $manifest->name .
'\s*</name>#i';
$replace[] = '<name>' . $newName .
'</name>';
$pattern[] = '#<language(.*)' . $oldName .
'(.*)</language>#';
$replace[] = '<language${1}' . $newName .
'${2}</language>';
$contents = preg_replace($pattern, $replace, $contents);
$result = JFile::write($xmlFile, $contents) && $result;
}
return $result;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
$app = JFactory::getApplication();
// Codemirror or Editor None should be enabled
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('COUNT(*)')
->from('#__extensions as a')
->where(
'(a.name =' .
$db->quote('plg_editors_codemirror') .
' AND a.enabled = 1) OR (a.name =' .
$db->quote('plg_editors_none') .
' AND a.enabled = 1)'
);
$db->setQuery($query);
$state = $db->loadResult();
if ((int) $state < 1)
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_EDITOR_DISABLED'),
'warning');
}
// Get the form.
$form = $this->loadForm('com_templates.source',
'source', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
$data = $this->getSource();
$this->preprocessData('com_templates.source', $data);
return $data;
}
/**
* Method to get a single record.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function &getSource()
{
$app = JFactory::getApplication();
$item = new stdClass;
if (!$this->template)
{
$this->getTemplate();
}
if ($this->template)
{
$input = JFactory::getApplication()->input;
$fileName = base64_decode($input->get('file'));
$client =
JApplicationHelper::getClientInfo($this->template->client_id);
try
{
$filePath = JPath::check($client->path . '/templates/' .
$this->template->element . '/' . $fileName);
}
catch (Exception $e)
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_FOUND'),
'error');
return;
}
if (file_exists($filePath))
{
$item->extension_id = $this->getState('extension.id');
$item->filename = $fileName;
$item->source = file_get_contents($filePath);
}
else
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_FOUND'),
'error');
}
}
return $item;
}
/**
* Method to store the source file contents.
*
* @param array $data The source data to save.
*
* @return boolean True on success, false otherwise and internal error
set.
*
* @since 1.6
*/
public function save($data)
{
jimport('joomla.filesystem.file');
// Get the template.
$template = $this->getTemplate();
if (empty($template))
{
return false;
}
$app = JFactory::getApplication();
$fileName = base64_decode($app->input->get('file'));
$client = JApplicationHelper::getClientInfo($template->client_id);
$filePath = JPath::clean($client->path . '/templates/' .
$template->element . '/' . $fileName);
// Include the extension plugins for the save events.
JPluginHelper::importPlugin('extension');
$user = get_current_user();
chown($filePath, $user);
JPath::setPermissions($filePath, '0644');
// Try to make the template file writable.
if (!is_writable($filePath))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_WRITABLE'),
'warning');
$app->enqueueMessage(JText::sprintf('COM_TEMPLATES_FILE_PERMISSIONS',
JPath::getPermissions($filePath)), 'warning');
if (!JPath::isOwner($filePath))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_CHECK_FILE_OWNERSHIP'),
'warning');
}
return false;
}
// Make sure EOL is Unix
$data['source'] = str_replace(array("\r\n",
"\r"), "\n", $data['source']);
$return = JFile::write($filePath, $data['source']);
if (!$return)
{
$app->enqueueMessage(JText::sprintf('COM_TEMPLATES_ERROR_FAILED_TO_SAVE_FILENAME',
$fileName), 'error');
return false;
}
// Get the extension of the changed file.
$explodeArray = explode('.', $fileName);
$ext = end($explodeArray);
if ($ext == 'less')
{
$app->enqueueMessage(JText::sprintf('COM_TEMPLATES_COMPILE_LESS',
$fileName));
}
return true;
}
/**
* Get overrides folder.
*
* @param string $name The name of override.
* @param string $path Location of override.
*
* @return object containing override name and path.
*
* @since 3.2
*/
public function getOverridesFolder($name,$path)
{
$folder = new stdClass;
$folder->name = $name;
$folder->path = base64_encode($path . $name);
return $folder;
}
/**
* Get a list of overrides.
*
* @return array containing overrides.
*
* @since 3.2
*/
public function getOverridesList()
{
if ($template = $this->getTemplate())
{
$client =
JApplicationHelper::getClientInfo($template->client_id);
$componentPath = JPath::clean($client->path .
'/components/');
$modulePath = JPath::clean($client->path . '/modules/');
$pluginPath = JPath::clean(JPATH_ROOT . '/plugins/');
$layoutPath = JPath::clean(JPATH_ROOT . '/layouts/');
$components = JFolder::folders($componentPath);
foreach ($components as $component)
{
if (file_exists($componentPath . '/' . $component .
'/views/'))
{
$viewPath = JPath::clean($componentPath . '/' . $component .
'/views/');
}
elseif (file_exists($componentPath . '/' . $component .
'/view/'))
{
$viewPath = JPath::clean($componentPath . '/' . $component .
'/view/');
}
else
{
$viewPath = '';
}
if ($viewPath)
{
$views = JFolder::folders($viewPath);
foreach ($views as $view)
{
// Only show the view has layout inside it
if (file_exists($viewPath . $view . '/tmpl'))
{
$result['components'][$component][] =
$this->getOverridesFolder($view, $viewPath);
}
}
}
}
foreach (JFolder::folders($pluginPath) as $pluginGroup)
{
foreach (JFolder::folders($pluginPath . '/' . $pluginGroup)
as $plugin)
{
if (file_exists($pluginPath . '/' . $pluginGroup .
'/' . $plugin . '/tmpl/'))
{
$pluginLayoutPath = JPath::clean($pluginPath . '/' .
$pluginGroup . '/');
$result['plugins'][$pluginGroup][] =
$this->getOverridesFolder($plugin, $pluginLayoutPath);
}
}
}
$modules = JFolder::folders($modulePath);
foreach ($modules as $module)
{
$result['modules'][] = $this->getOverridesFolder($module,
$modulePath);
}
$layoutFolders = JFolder::folders($layoutPath);
foreach ($layoutFolders as $layoutFolder)
{
$layoutFolderPath = JPath::clean($layoutPath . '/' .
$layoutFolder . '/');
$layouts = JFolder::folders($layoutFolderPath);
foreach ($layouts as $layout)
{
$result['layouts'][$layoutFolder][] =
$this->getOverridesFolder($layout, $layoutFolderPath);
}
}
// Check for layouts in component folders
foreach ($components as $component)
{
if (file_exists($componentPath . '/' . $component .
'/layouts/'))
{
$componentLayoutPath = JPath::clean($componentPath . '/' .
$component . '/layouts/');
if ($componentLayoutPath)
{
$layouts = JFolder::folders($componentLayoutPath);
foreach ($layouts as $layout)
{
$result['layouts'][$component][] =
$this->getOverridesFolder($layout, $componentLayoutPath);
}
}
}
}
}
if (!empty($result))
{
return $result;
}
}
/**
* Create overrides.
*
* @param string $override The override location.
*
* @return boolean true if override creation is successful, false
otherwise
*
* @since 3.2
*/
public function createOverride($override)
{
jimport('joomla.filesystem.folder');
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$explodeArray = explode(DIRECTORY_SEPARATOR, $override);
$name = end($explodeArray);
$client =
JApplicationHelper::getClientInfo($template->client_id);
if (stristr($name, 'mod_') != false)
{
$htmlPath = JPath::clean($client->path . '/templates/' .
$template->element . '/html/' . $name);
}
elseif (stristr($override, 'com_') != false)
{
$size = count($explodeArray);
$url = JPath::clean($explodeArray[$size - 3] . '/' .
$explodeArray[$size - 1]);
if ($explodeArray[$size - 2] == 'layouts')
{
$htmlPath = JPath::clean($client->path . '/templates/' .
$template->element . '/html/layouts/' . $url);
}
else
{
$htmlPath = JPath::clean($client->path . '/templates/' .
$template->element . '/html/' . $url);
}
}
elseif (stripos($override, JPath::clean(JPATH_ROOT .
'/plugins/')) === 0)
{
$size = count($explodeArray);
$layoutPath = JPath::clean('plg_' . $explodeArray[$size - 2]
. '_' . $explodeArray[$size - 1]);
$htmlPath = JPath::clean($client->path . '/templates/' .
$template->element . '/html/' . $layoutPath);
}
else
{
$layoutPath = implode('/', array_slice($explodeArray, -2));
$htmlPath = JPath::clean($client->path . '/templates/' .
$template->element . '/html/layouts/' . $layoutPath);
}
// Check Html folder, create if not exist
if (!JFolder::exists($htmlPath))
{
if (!JFolder::create($htmlPath))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FOLDER_ERROR'),
'error');
return false;
}
}
if (stristr($name, 'mod_') != false)
{
$return = $this->createTemplateOverride(JPath::clean($override .
'/tmpl'), $htmlPath);
}
elseif (stristr($override, 'com_') != false &&
stristr($override, 'layouts') == false)
{
$return = $this->createTemplateOverride(JPath::clean($override .
'/tmpl'), $htmlPath);
}
elseif (stripos($override, JPath::clean(JPATH_ROOT .
'/plugins/')) === 0)
{
$return = $this->createTemplateOverride(JPath::clean($override .
'/tmpl'), $htmlPath);
}
else
{
$return = $this->createTemplateOverride($override, $htmlPath);
}
if ($return)
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_OVERRIDE_CREATED')
. str_replace(JPATH_ROOT, '', $htmlPath));
return true;
}
else
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_OVERRIDE_FAILED'),
'error');
return false;
}
}
}
/**
* Create override folder & file
*
* @param string $overridePath The override location
* @param string $htmlPath The html location
*
* @return boolean True on success. False otherwise.
*/
public function createTemplateOverride($overridePath, $htmlPath)
{
$return = false;
if (empty($overridePath) || empty($htmlPath))
{
return $return;
}
// Get list of template folders
$folders = JFolder::folders($overridePath, null, true, true);
if (!empty($folders))
{
foreach ($folders as $folder)
{
$htmlFolder = $htmlPath . str_replace($overridePath, '',
$folder);
if (!JFolder::exists($htmlFolder))
{
JFolder::create($htmlFolder);
}
}
}
// Get list of template files (Only get *.php file for template file)
$files = JFolder::files($overridePath, '.php', true, true);
if (empty($files))
{
return true;
}
foreach ($files as $file)
{
$overrideFilePath = str_replace($overridePath, '', $file);
$htmlFilePath = $htmlPath . $overrideFilePath;
if (JFile::exists($htmlFilePath))
{
// Generate new unique file name base on current time
$today = JFactory::getDate();
$htmlFilePath = JFile::stripExt($htmlFilePath) . '-' .
$today->format('Ymd-His') . '.' .
JFile::getExt($htmlFilePath);
}
$return = JFile::copy($file, $htmlFilePath, '', true);
}
return $return;
}
/**
* Compile less using the less compiler under /build.
*
* @param string $input The relative location of the less file.
*
* @return boolean true if compilation is successful, false otherwise
*
* @since 3.2
*/
public function compileLess($input)
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client =
JApplicationHelper::getClientInfo($template->client_id);
$path = JPath::clean($client->path . '/templates/'
. $template->element . '/');
$inFile = urldecode(base64_decode($input));
$explodeArray = explode('/', $inFile);
$fileName = end($explodeArray);
$outFile = current(explode('.', $fileName));
$less = new JLess;
$less->setFormatter(new JLessFormatterJoomla);
try
{
$less->compileFile($path . $inFile, $path . 'css/' .
$outFile . '.css');
return true;
}
catch (Exception $e)
{
$app->enqueueMessage($e->getMessage(), 'error');
}
}
}
/**
* Delete a particular file.
*
* @param string $file The relative location of the file.
*
* @return boolean True if file deletion is successful, false otherwise
*
* @since 3.2
*/
public function deleteFile($file)
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/');
$filePath = $path . urldecode(base64_decode($file));
$return = JFile::delete($filePath);
if (!$return)
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_DELETE_FAIL'),
'error');
return false;
}
return true;
}
}
/**
* Create new file.
*
* @param string $name The name of file.
* @param string $type The extension of the file.
* @param string $location Location for the new file.
*
* @return boolean true if file created successfully, false otherwise
*
* @since 3.2
*/
public function createFile($name, $type, $location)
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/');
if (file_exists(JPath::clean($path . '/' . $location .
'/' . $name . '.' . $type)))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_EXISTS'),
'error');
return false;
}
if (!fopen(JPath::clean($path . '/' . $location .
'/' . $name . '.' . $type), 'x'))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_CREATE_ERROR'),
'error');
return false;
}
// Check if the format is allowed and will be showed in the backend
$check = $this->checkFormat($type);
// Add a message if we are not allowed to show this file in the backend.
if (!$check)
{
$app->enqueueMessage(JText::sprintf('COM_TEMPLATES_WARNING_FORMAT_WILL_NOT_BE_VISIBLE',
$type), 'warning');
}
return true;
}
}
/**
* Upload new file.
*
* @param string $file The name of the file.
* @param string $location Location for the new file.
*
* @return boolean True if file uploaded successfully, false otherwise
*
* @since 3.2
*/
public function uploadFile($file, $location)
{
jimport('joomla.filesystem.folder');
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/');
$fileName = JFile::makeSafe($file['name']);
$err = null;
JLoader::register('TemplateHelper', JPATH_ADMINISTRATOR .
'/components/com_templates/helpers/template.php');
if (!TemplateHelper::canUpload($file, $err))
{
// Can't upload the file
return false;
}
if (file_exists(JPath::clean($path . '/' . $location .
'/' . $file['name'])))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_EXISTS'),
'error');
return false;
}
if (!JFile::upload($file['tmp_name'], JPath::clean($path .
'/' . $location . '/' . $fileName)))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_UPLOAD_ERROR'),
'error');
return false;
}
$url = JPath::clean($location . '/' . $fileName);
return $url;
}
}
/**
* Create new folder.
*
* @param string $name The name of the new folder.
* @param string $location Location for the new folder.
*
* @return boolean True if override folder is created successfully,
false otherwise
*
* @since 3.2
*/
public function createFolder($name, $location)
{
jimport('joomla.filesystem.folder');
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/');
if (file_exists(JPath::clean($path . '/' . $location .
'/' . $name . '/')))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FOLDER_EXISTS'),
'error');
return false;
}
if (!JFolder::create(JPath::clean($path . '/' . $location .
'/' . $name)))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FOLDER_CREATE_ERROR'),
'error');
return false;
}
return true;
}
}
/**
* Delete a folder.
*
* @param string $location The name and location of the folder.
*
* @return boolean True if override folder is deleted successfully,
false otherwise
*
* @since 3.2
*/
public function deleteFolder($location)
{
jimport('joomla.filesystem.folder');
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/' . $location);
if (!file_exists($path))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FOLDER_NOT_EXISTS'),
'error');
return false;
}
$return = JFolder::delete($path);
if (!$return)
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_DELETE_ERROR'),
'error');
return false;
}
return true;
}
}
/**
* Rename a file.
*
* @param string $file The name and location of the old file
* @param string $name The new name of the file.
*
* @return string Encoded string containing the new file location.
*
* @since 3.2
*/
public function renameFile($file, $name)
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client =
JApplicationHelper::getClientInfo($template->client_id);
$path = JPath::clean($client->path . '/templates/'
. $template->element . '/');
$fileName = base64_decode($file);
$explodeArray = explode('.', $fileName);
$type = end($explodeArray);
$explodeArray = explode('/', $fileName);
$newName = str_replace(end($explodeArray), $name . '.' .
$type, $fileName);
if (file_exists($path . $newName))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_EXISTS'),
'error');
return false;
}
if (!rename($path . $fileName, $path . $newName))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_RENAME_ERROR'),
'error');
return false;
}
return base64_encode($newName);
}
}
/**
* Get an image address, height and width.
*
* @return array an associative array containing image address, height
and width.
*
* @since 3.2
*/
public function getImage()
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$fileName = base64_decode($app->input->get('file'));
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/');
if (stristr($client->path, 'administrator') == false)
{
$folder = '/templates/';
}
else
{
$folder = '/administrator/templates/';
}
$uri = JUri::root(true) . $folder . $template->element;
if (file_exists(JPath::clean($path . $fileName)))
{
$JImage = new JImage(JPath::clean($path . $fileName));
$image['address'] = $uri . $fileName;
$image['path'] = $fileName;
$image['height'] = $JImage->getHeight();
$image['width'] = $JImage->getWidth();
}
else
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_IMAGE_FILE_NOT_FOUND'),
'error');
return false;
}
return $image;
}
}
/**
* Crop an image.
*
* @param string $file The name and location of the file
* @param string $w width.
* @param string $h height.
* @param string $x x-coordinate.
* @param string $y y-coordinate.
*
* @return boolean true if image cropped successfully, false
otherwise.
*
* @since 3.2
*/
public function cropImage($file, $w, $h, $x, $y)
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$relPath = base64_decode($file);
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/' . $relPath);
try
{
$image = new \JImage($path);
$properties = $image->getImageFileProperties($path);
switch ($properties->mime)
{
case 'image/png':
$imageType = \IMAGETYPE_PNG;
break;
case 'image/gif':
$imageType = \IMAGETYPE_GIF;
break;
default:
$imageType = \IMAGETYPE_JPEG;
}
$image->crop($w, $h, $x, $y, false);
$image->toFile($path, $imageType);
return true;
}
catch (Exception $e)
{
$app->enqueueMessage($e->getMessage(), 'error');
}
}
}
/**
* Resize an image.
*
* @param string $file The name and location of the file
* @param string $width The new width of the image.
* @param string $height The new height of the image.
*
* @return boolean true if image resize successful, false otherwise.
*
* @since 3.2
*/
public function resizeImage($file, $width, $height)
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$relPath = base64_decode($file);
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/' . $relPath);
try
{
$image = new \JImage($path);
$properties = $image->getImageFileProperties($path);
switch ($properties->mime)
{
case 'image/png':
$imageType = \IMAGETYPE_PNG;
break;
case 'image/gif':
$imageType = \IMAGETYPE_GIF;
break;
default:
$imageType = \IMAGETYPE_JPEG;
}
$image->resize($width, $height, false, \JImage::SCALE_FILL);
$image->toFile($path, $imageType);
return true;
}
catch (Exception $e)
{
$app->enqueueMessage($e->getMessage(), 'error');
}
}
}
/**
* Template preview.
*
* @return object object containing the id of the template.
*
* @since 3.2
*/
public function getPreview()
{
$app = JFactory::getApplication();
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select('id, client_id');
$query->from('#__template_styles');
$query->where($db->quoteName('template') . ' =
' . $db->quote($this->template->element));
$db->setQuery($query);
try
{
$result = $db->loadObject();
}
catch (RuntimeException $e)
{
$app->enqueueMessage($e->getMessage(), 'warning');
}
if (empty($result))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_EXTENSION_RECORD_NOT_FOUND'),
'warning');
}
else
{
return $result;
}
}
/**
* Rename a file.
*
* @return mixed array on success, false on failure
*
* @since 3.2
*/
public function getFont()
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client =
JApplicationHelper::getClientInfo($template->client_id);
$relPath = base64_decode($app->input->get('file'));
$explodeArray = explode('/', $relPath);
$fileName = end($explodeArray);
$path = JPath::clean($client->path . '/templates/'
. $template->element . '/' . $relPath);
if (stristr($client->path, 'administrator') == false)
{
$folder = '/templates/';
}
else
{
$folder = '/administrator/templates/';
}
$uri = JUri::root(true) . $folder . $template->element;
if (file_exists(JPath::clean($path)))
{
$font['address'] = $uri . $relPath;
$font['rel_path'] = $relPath;
$font['name'] = $fileName;
}
else
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_FONT_FILE_NOT_FOUND'),
'error');
return false;
}
return $font;
}
}
/**
* Copy a file.
*
* @param string $newName The name of the copied file
* @param string $location The final location where the file is to be
copied
* @param string $file The name and location of the file
*
* @return boolean true if image resize successful, false otherwise.
*
* @since 3.2
*/
public function copyFile($newName, $location, $file)
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client =
JApplicationHelper::getClientInfo($template->client_id);
$relPath = base64_decode($file);
$explodeArray = explode('.', $relPath);
$ext = end($explodeArray);
$path = JPath::clean($client->path . '/templates/'
. $template->element . '/');
$newPath = JPath::clean($path . '/' . $location .
'/' . $newName . '.' . $ext);
if (file_exists($newPath))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_EXISTS'),
'error');
return false;
}
if (JFile::copy($path . $relPath, $newPath))
{
$app->enqueueMessage(JText::sprintf('COM_TEMPLATES_FILE_COPY_SUCCESS',
$newName . '.' . $ext));
return true;
}
else
{
return false;
}
}
}
/**
* Get the compressed files.
*
* @return array if file exists, false otherwise
*
* @since 3.2
*/
public function getArchive()
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$relPath = base64_decode($app->input->get('file'));
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/' . $relPath);
if (file_exists(JPath::clean($path)))
{
$files = array();
$zip = new ZipArchive;
if ($zip->open($path) === true)
{
for ($i = 0; $i < $zip->numFiles; $i++)
{
$entry = $zip->getNameIndex($i);
$files[] = $entry;
}
}
else
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_OPEN_FAIL'),
'error');
return false;
}
}
else
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_FONT_FILE_NOT_FOUND'),
'error');
return false;
}
return $files;
}
}
/**
* Extract contents of an archive file.
*
* @param string $file The name and location of the file
*
* @return boolean true if image extraction is successful, false
otherwise.
*
* @since 3.2
*/
public function extractArchive($file)
{
if ($template = $this->getTemplate())
{
$app = JFactory::getApplication();
$client =
JApplicationHelper::getClientInfo($template->client_id);
$relPath = base64_decode($file);
$explodeArray = explode('/', $relPath);
$fileName = end($explodeArray);
$folderPath = stristr($relPath, $fileName, true);
$path = JPath::clean($client->path . '/templates/'
. $template->element . '/' . $folderPath . '/');
if (file_exists(JPath::clean($path . '/' . $fileName)))
{
$zip = new ZipArchive;
if ($zip->open(JPath::clean($path . '/' . $fileName)) ===
true)
{
for ($i = 0; $i < $zip->numFiles; $i++)
{
$entry = $zip->getNameIndex($i);
if (file_exists(JPath::clean($path . '/' . $entry)))
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_EXISTS'),
'error');
return false;
}
}
$zip->extractTo($path);
return true;
}
else
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_OPEN_FAIL'),
'error');
return false;
}
}
else
{
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_NOT_FOUND'),
'error');
return false;
}
}
}
/**
* Check if the extension is allowed and will be shown in the template
manager
*
* @param string $ext The extension to check if it is allowed
*
* @return boolean true if the extension is allowed false otherwise
*
* @since 3.6.0
*/
protected function checkFormat($ext)
{
if (!isset($this->allowedFormats))
{
$params = JComponentHelper::getParams('com_templates');
$imageTypes = explode(',',
$params->get('image_formats'));
$sourceTypes = explode(',',
$params->get('source_formats'));
$fontTypes = explode(',',
$params->get('font_formats'));
$archiveTypes = explode(',',
$params->get('compressed_formats'));
$this->allowedFormats = array_merge($imageTypes, $sourceTypes,
$fontTypes, $archiveTypes);
}
return in_array($ext, $this->allowedFormats);
}
}
templates.php000064400000010306151160433740007257 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\String\StringHelper;
/**
* Methods supporting a list of template extension records.
*
* @since 1.6
*/
class TemplatesModelTemplates extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'name', 'a.name',
'folder', 'a.folder',
'element', 'a.element',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'state', 'a.state',
'enabled', 'a.enabled',
'ordering', 'a.ordering',
);
}
parent::__construct($config);
}
/**
* Override parent getItems to add extra XML metadata.
*
* @return array
*
* @since 1.6
*/
public function getItems()
{
$items = parent::getItems();
foreach ($items as &$item)
{
$client = JApplicationHelper::getClientInfo($item->client_id);
$item->xmldata =
TemplatesHelper::parseXMLTemplateFile($client->path, $item->element);
}
return $items;
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.extension_id, a.name, a.element, a.client_id'
)
);
$query->from($db->quoteName('#__extensions',
'a'))
->where($db->quoteName('a.client_id') . ' = '
. (int) $this->getState('client_id'))
->where($db->quoteName('a.enabled') . ' = 1')
->where($db->quoteName('a.type') . ' = ' .
$db->quote('template'));
// Filter by search in title.
if ($search = $this->getState('filter.search'))
{
if (stripos($search, 'id:') === 0)
{
$query->where($db->quoteName('a.id') . ' = '
. (int) substr($search, 3));
}
else
{
$search = $db->quote('%' .
StringHelper::strtolower($search) . '%');
$query->where('(' . ' LOWER(a.element) LIKE ' .
$search . ' OR LOWER(a.name) LIKE ' . $search . ')');
}
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.element')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('client_id');
$id .= ':' . $this->getState('filter.search');
return parent::getStoreId($id);
}
/**
* 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.6
*/
protected function populateState($ordering = 'a.element',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
// Special case for the client id.
$clientId = (int) $this->getUserStateFromRequest($this->context .
'.client_id', 'client_id', 0, 'int');
$clientId = (!in_array($clientId, array (0, 1))) ? 0 : $clientId;
$this->setState('client_id', $clientId);
// Load the parameters.
$params = JComponentHelper::getParams('com_templates');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
}
forms/filter_searches.xml000064400000001566151160560360011571
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_SEARCH_SEARCH_IN_PHRASE"
description="COM_SEARCH_SEARCH_IN_PHRASE"
hint="JSEARCH_FILTER"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
onchange="this.form.submit();"
default="a.hits ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.search_term
ASC">COM_SEARCH_HEADING_SEARCH_TERM_ASC</option>
<option value="a.search_term
DESC">COM_SEARCH_HEADING_SEARCH_TERM_DESC</option>
<option value="a.hits
ASC">JGLOBAL_HITS_ASC</option>
<option value="a.hits
DESC">JGLOBAL_HITS_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
searches.php000064400000010665151160560360007065 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_search
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Methods supporting a list of search terms.
*
* @since 1.6
*/
class SearchModelSearches extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'search_term', 'a.search_term',
'hits', 'a.hits',
);
}
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.6
*/
protected function populateState($ordering = 'a.hits',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
// Special state for toggle results button.
$this->setState('show_results',
$this->getUserStateFromRequest($this->context .
'.show_results', 'show_results', 1, 'int'));
// Load the parameters.
$params = JComponentHelper::getParams('com_search');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('show_results');
$id .= ':' . $this->getState('filter.search');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from($db->quoteName('#__core_log_searches',
'a'));
// Filter by search in title
if ($search = $this->getState('filter.search'))
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where($db->quoteName('a.search_term') . '
LIKE ' . $search);
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.hits')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Override the parent getItems to inject optional data.
*
* @return mixed An array of objects on success, false on failure.
*
* @since 1.6
*/
public function getItems()
{
$items = parent::getItems();
// Determine if number of results for search item should be calculated
// by default it is `off` as it is highly query intensive
if ($this->getState('show_results'))
{
JPluginHelper::importPlugin('search');
$app = JFactory::getApplication();
if (!class_exists('JSite'))
{
// This fools the routers in the search plugins into thinking it's
in the frontend
JLoader::register('JSite', JPATH_ADMINISTRATOR .
'/components/com_search/helpers/site.php');
}
foreach ($items as &$item)
{
$results = $app->triggerEvent('onContentSearch',
array($item->search_term));
$item->returns = 0;
foreach ($results as $result)
{
$item->returns += count($result);
}
}
}
return $items;
}
/**
* Method to reset the search log table.
*
* @return boolean
*
* @since 1.6
*/
public function reset()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__core_log_searches'));
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
return true;
}
}
database.php000064400000017210151160606600007023 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
JLoader::register('InstallerModel', __DIR__ .
'/extension.php');
JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR .
'/components/com_admin/script.php');
/**
* Installer Database Model
*
* @since 1.6
*/
class InstallerModelDatabase extends InstallerModel
{
protected $_context = 'com_installer.discover';
/**
* 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.6
*/
protected function populateState($ordering = 'name', $direction
= 'asc')
{
$app = JFactory::getApplication();
$this->setState('message',
$app->getUserState('com_installer.message'));
$this->setState('extension_message',
$app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message',
'');
// Prepare the utf8mb4 conversion check table
$this->prepareUtf8mb4StatusTable();
parent::populateState($ordering, $direction);
}
/**
* Fixes database problems.
*
* @return void
*/
public function fix()
{
if (!$changeSet = $this->getItems())
{
return false;
}
$changeSet->fix();
$this->fixSchemaVersion($changeSet);
$this->fixUpdateVersion();
$installer = new JoomlaInstallerScript;
$installer->deleteUnexistingFiles();
$this->fixDefaultTextFilters();
/*
* Finally, if the schema updates succeeded, make sure the database is
* converted to utf8mb4 or, if not supported by the server, compatible to
it.
*/
$statusArray = $changeSet->getStatus();
if (count($statusArray['error']) == 0)
{
$installer->convertTablesToUtf8mb4(false);
}
}
/**
* Gets the changeset object.
*
* @return JSchemaChangeset
*/
public function getItems()
{
$folder = JPATH_ADMINISTRATOR .
'/components/com_admin/sql/updates/';
try
{
$changeSet = JSchemaChangeset::getInstance($this->getDbo(), $folder);
}
catch (RuntimeException $e)
{
JFactory::getApplication()->enqueueMessage($e->getMessage(),
'warning');
return false;
}
return $changeSet;
}
/**
* Method to get a JPagination object for the data set.
*
* @return boolean
*
* @since 3.0.1
*/
public function getPagination()
{
return true;
}
/**
* Get version from #__schemas table.
*
* @return mixed the return value from the query, or null if the query
fails.
*
* @throws Exception
*/
public function getSchemaVersion()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('version_id')
->from($db->quoteName('#__schemas'))
->where('extension_id = 700');
$db->setQuery($query);
$result = $db->loadResult();
return $result;
}
/**
* Fix schema version if wrong.
*
* @param JSchemaChangeSet $changeSet Schema change set.
*
* @return mixed string schema version if success, false if fail.
*/
public function fixSchemaVersion($changeSet)
{
// Get correct schema version -- last file in array.
$schema = $changeSet->getSchema();
// Check value. If ok, don't do update.
if ($schema == $this->getSchemaVersion())
{
return $schema;
}
// Delete old row.
$db = $this->getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__schemas'))
->where($db->quoteName('extension_id') . ' =
700');
$db->setQuery($query);
$db->execute();
// Add new row.
$query->clear()
->insert($db->quoteName('#__schemas'))
->columns($db->quoteName('extension_id') . ','
. $db->quoteName('version_id'))
->values('700, ' . $db->quote($schema));
$db->setQuery($query);
try
{
$db->execute();
}
catch (JDatabaseExceptionExecuting $e)
{
return false;
}
return $schema;
}
/**
* Get current version from #__extensions table.
*
* @return mixed version if successful, false if fail.
*/
public function getUpdateVersion()
{
$table = JTable::getInstance('Extension');
$table->load('700');
$cache = new Registry($table->manifest_cache);
return $cache->get('version');
}
/**
* Fix Joomla version in #__extensions table if wrong (doesn't equal
JVersion short version).
*
* @return mixed string update version if success, false if fail.
*/
public function fixUpdateVersion()
{
$table = JTable::getInstance('Extension');
$table->load('700');
$cache = new Registry($table->manifest_cache);
$updateVersion = $cache->get('version');
$cmsVersion = new JVersion;
if ($updateVersion == $cmsVersion->getShortVersion())
{
return $updateVersion;
}
$cache->set('version', $cmsVersion->getShortVersion());
$table->manifest_cache = $cache->toString();
if ($table->store())
{
return $cmsVersion->getShortVersion();
}
return false;
}
/**
* For version 2.5.x only
* Check if com_config parameters are blank.
*
* @return string default text filters (if any).
*/
public function getDefaultTextFilters()
{
$table = JTable::getInstance('Extension');
$table->load($table->find(array('name' =>
'com_config')));
return $table->params;
}
/**
* For version 2.5.x only
* Check if com_config parameters are blank. If so, populate with
com_content text filters.
*
* @return mixed boolean true if params are updated, null otherwise.
*/
public function fixDefaultTextFilters()
{
$table = JTable::getInstance('Extension');
$table->load($table->find(array('name' =>
'com_config')));
// Check for empty $config and non-empty content filters.
if (!$table->params)
{
// Get filters from com_content and store if you find them.
$contentParams = JComponentHelper::getParams('com_content');
if ($contentParams->get('filters'))
{
$newParams = new Registry;
$newParams->set('filters',
$contentParams->get('filters'));
$table->params = (string) $newParams;
$table->store();
return true;
}
}
}
/**
* Prepare the table to save the status of utf8mb4 conversion
* Make sure it contains 1 initialized record if there is not
* already exactly 1 record.
*
* @return void
*
* @since 3.5
*/
private function prepareUtf8mb4StatusTable()
{
$db = JFactory::getDbo();
$serverType = $db->getServerType();
if ($serverType != 'mysql')
{
return;
}
$creaTabSql = 'CREATE TABLE IF NOT EXISTS ' .
$db->quoteName('#__utf8_conversion')
. ' (' . $db->quoteName('converted') . '
tinyint(4) NOT NULL DEFAULT 0'
. ') ENGINE=InnoDB';
if ($db->hasUTF8mb4Support())
{
$creaTabSql = $creaTabSql
. ' DEFAULT CHARSET=utf8mb4 DEFAULT
COLLATE=utf8mb4_unicode_ci;';
}
else
{
$creaTabSql = $creaTabSql
. ' DEFAULT CHARSET=utf8 DEFAULT COLLATE=utf8_unicode_ci;';
}
$db->setQuery($creaTabSql)->execute();
$db->setQuery('SELECT COUNT(*) FROM ' .
$db->quoteName('#__utf8_conversion') . ';');
$count = $db->loadResult();
if ($count > 1)
{
// Table messed up somehow, clear it
$db->setQuery('DELETE FROM ' .
$db->quoteName('#__utf8_conversion') . ';')
->execute();
$db->setQuery('INSERT INTO ' .
$db->quoteName('#__utf8_conversion')
. ' (' . $db->quoteName('converted') . ')
VALUES (0);'
)->execute();
}
elseif ($count == 0)
{
// Record missing somehow, fix this
$db->setQuery('INSERT INTO ' .
$db->quoteName('#__utf8_conversion')
. ' (' . $db->quoteName('converted') . ')
VALUES (0);'
)->execute();
}
}
}
discover.php000064400000014565151160606600007107 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JLoader::register('InstallerModel', __DIR__ .
'/extension.php');
/**
* Installer Discover Model
*
* @since 1.6
*/
class InstallerModelDiscover extends InstallerModel
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 3.5
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'name',
'client_id',
'client', 'client_translated',
'type', 'type_translated',
'folder', 'folder_translated',
'extension_id',
);
}
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 3.1
*/
protected function populateState($ordering = 'name', $direction
= 'asc')
{
$app = JFactory::getApplication();
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.client_id',
$this->getUserStateFromRequest($this->context .
'.filter.client_id', 'filter_client_id', null,
'int'));
$this->setState('filter.type',
$this->getUserStateFromRequest($this->context .
'.filter.type', 'filter_type', '',
'string'));
$this->setState('filter.folder',
$this->getUserStateFromRequest($this->context .
'.filter.folder', 'filter_folder', '',
'string'));
$this->setState('message',
$app->getUserState('com_installer.message'));
$this->setState('extension_message',
$app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message',
'');
parent::populateState($ordering, $direction);
}
/**
* Method to get the database query.
*
* @return JDatabaseQuery the database query
*
* @since 3.1
*/
protected function getListQuery()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__extensions'))
->where($db->quoteName('state') . ' = -1');
// Process select filters.
$type = $this->getState('filter.type');
$clientId = $this->getState('filter.client_id');
$folder = $this->getState('filter.folder');
if ($type)
{
$query->where($db->quoteName('type') . ' = ' .
$db->quote($type));
}
if ($clientId != '')
{
$query->where($db->quoteName('client_id') . ' =
' . (int) $clientId);
}
if ($folder != '' && in_array($type,
array('plugin', 'library', '')))
{
$query->where($db->quoteName('folder') . ' = '
. $db->quote($folder == '*' ? '' : $folder));
}
// Process search filter.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where($db->quoteName('extension_id') . ' =
' . (int) substr($search, 3));
}
}
// Note: The search for name, ordering and pagination are processed by
the parent InstallerModel class (in extension.php).
return $query;
}
/**
* Discover extensions.
*
* Finds uninstalled extensions
*
* @return void
*
* @since 1.6
*/
public function discover()
{
// Purge the list of discovered extensions and fetch them again.
$this->purge();
$results = JInstaller::getInstance()->discover();
// Get all templates, including discovered ones
$db = $this->getDbo();
$query = $db->getQuery(true)
->select($db->quoteName(array('extension_id',
'element', 'folder', 'client_id',
'type')))
->from($db->quoteName('#__extensions'));
$db->setQuery($query);
$installedtmp = $db->loadObjectList();
$extensions = array();
foreach ($installedtmp as $install)
{
$key = implode(':', array($install->type,
$install->element, $install->folder, $install->client_id));
$extensions[$key] = $install;
}
foreach ($results as $result)
{
// Check if we have a match on the element
$key = implode(':', array($result->type,
$result->element, $result->folder, $result->client_id));
if (!array_key_exists($key, $extensions))
{
// Put it into the table
$result->check();
$result->store();
}
}
}
/**
* Installs a discovered extension.
*
* @return void
*
* @since 1.6
*/
public function discover_install()
{
$app = JFactory::getApplication();
$input = $app->input;
$eid = $input->get('cid', 0, 'array');
if (is_array($eid) || $eid)
{
if (!is_array($eid))
{
$eid = array($eid);
}
$eid = ArrayHelper::toInteger($eid);
$failed = false;
foreach ($eid as $id)
{
$installer = new JInstaller;
$result = $installer->discover_install($id);
if (!$result)
{
$failed = true;
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_INSTALLFAILED')
. ': ' . $id);
}
}
// TODO - We are only receiving the message for the last JInstaller
instance
$this->setState('action', 'remove');
$this->setState('name',
$installer->get('name'));
$app->setUserState('com_installer.message',
$installer->message);
$app->setUserState('com_installer.extension_message',
$installer->get('extension_message'));
if (!$failed)
{
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_INSTALLSUCCESSFUL'));
}
}
else
{
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_NOEXTENSIONSELECTED'));
}
}
/**
* Cleans out the list of discovered extensions.
*
* @return boolean True on success
*
* @since 1.6
*/
public function purge()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__extensions'))
->where($db->quoteName('state') . ' = -1');
$db->setQuery($query);
try
{
$db->execute();
}
catch (JDatabaseExceptionExecuting $e)
{
$this->_message =
JText::_('COM_INSTALLER_MSG_DISCOVER_FAILEDTOPURGEEXTENSIONS');
return false;
}
$this->_message =
JText::_('COM_INSTALLER_MSG_DISCOVER_PURGEDDISCOVEREDEXTENSIONS');
return true;
}
}
extension.php000064400000015326151160606600007301 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Extension Manager Abstract Extension Model.
*
* @since 1.5
*/
class InstallerModel extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'name',
'client_id',
'client', 'client_translated',
'enabled',
'type', 'type_translated',
'folder', 'folder_translated',
'extension_id',
);
}
parent::__construct($config);
}
/**
* Returns an object list
*
* @param string $query The query
* @param int $limitstart Offset
* @param int $limit The number of records
*
* @return array
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$listOrder = $this->getState('list.ordering',
'name');
$listDirn = $this->getState('list.direction',
'asc');
// Replace slashes so preg_match will work
$search = $this->getState('filter.search');
$search = str_replace('/', ' ', $search);
$db = $this->getDbo();
// Define which fields have to be processed in a custom way because of
translation.
$customOrderFields = array('name',
'client_translated', 'type_translated',
'folder_translated');
// Process searching, ordering and pagination for fields that need to be
translated.
if (in_array($listOrder, $customOrderFields) || (!empty($search)
&& stripos($search, 'id:') !== 0))
{
// Get results from database and translate them.
$db->setQuery($query);
$result = $db->loadObjectList();
$this->translate($result);
// Process searching.
if (!empty($search) && stripos($search, 'id:') !== 0)
{
$escapedSearchString = $this->refineSearchStringToRegex($search,
'/');
// By default search only the extension name field.
$searchFields = array('name');
// If in update sites view search also in the update site name field.
if ($this instanceof InstallerModelUpdatesites)
{
$searchFields[] = 'update_site_name';
}
foreach ($result as $i => $item)
{
// Check if search string exists in any of the fields to be searched.
$found = 0;
foreach ($searchFields as $key => $field)
{
if (!$found && preg_match('/' .
$escapedSearchString . '/i', $item->{$field}))
{
$found = 1;
}
}
// If search string was not found in any of the fields searched remove
it from results array.
if (!$found)
{
unset($result[$i]);
}
}
}
// Process ordering.
// Sort array object by selected ordering and selected direction. Sort
is case insensitive and using locale sorting.
$result = ArrayHelper::sortObjects($result, $listOrder,
strtolower($listDirn) == 'desc' ? -1 : 1, false, true);
// Process pagination.
$total = count($result);
$this->cache[$this->getStoreId('getTotal')] = $total;
if ($total <= $limitstart)
{
$limitstart = 0;
$this->setState('list.limitstart', 0);
}
return array_slice($result, $limitstart, $limit ?: null);
}
// Process searching, ordering and pagination for regular database
fields.
$query->order($db->quoteName($listOrder) . ' ' .
$db->escape($listDirn));
$result = parent::_getList($query, $limitstart, $limit);
$this->translate($result);
return $result;
}
/**
* Translate a list of objects
*
* @param array $items The array of objects
*
* @return array The array of translated objects
*/
protected function translate(&$items)
{
$lang = JFactory::getLanguage();
foreach ($items as &$item)
{
if (strlen($item->manifest_cache) && $data =
json_decode($item->manifest_cache))
{
foreach ($data as $key => $value)
{
if ($key == 'type')
{
// Ignore the type field
continue;
}
$item->$key = $value;
}
}
$item->author_info = @$item->authorEmail . '<br
/>' . @$item->authorUrl;
$item->client = $item->client_id ?
JText::_('JADMINISTRATOR') : JText::_('JSITE');
$item->client_translated = $item->client;
$item->type_translated = JText::_('COM_INSTALLER_TYPE_' .
strtoupper($item->type));
$item->folder_translated = @$item->folder ? $item->folder :
JText::_('COM_INSTALLER_TYPE_NONAPPLICABLE');
$path = $item->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE;
switch ($item->type)
{
case 'component':
$extension = $item->element;
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null,
false, true)
|| $lang->load("$extension.sys", $source, null, false,
true);
break;
case 'file':
$extension = 'files_' . $item->element;
$lang->load("$extension.sys", JPATH_SITE, null, false,
true);
break;
case 'library':
$parts = explode('/', $item->element);
$vendor = (isset($parts[1]) ? $parts[0] : null);
$extension = 'lib_' . ($vendor ? implode('_',
$parts) : $item->element);
if (!$lang->load("$extension.sys", $path, null, false,
true))
{
$source = $path . '/libraries/' . ($vendor ? $vendor .
'/' . $parts[1] : $item->element);
$lang->load("$extension.sys", $source, null, false,
true);
}
break;
case 'module':
$extension = $item->element;
$source = $path . '/modules/' . $extension;
$lang->load("$extension.sys", $path, null, false, true)
|| $lang->load("$extension.sys", $source, null, false,
true);
break;
case 'plugin':
$extension = 'plg_' . $item->folder . '_' .
$item->element;
$source = JPATH_PLUGINS . '/' . $item->folder .
'/' . $item->element;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null,
false, true)
|| $lang->load("$extension.sys", $source, null, false,
true);
break;
case 'template':
$extension = 'tpl_' . $item->element;
$source = $path . '/templates/' . $item->element;
$lang->load("$extension.sys", $path, null, false, true)
|| $lang->load("$extension.sys", $source, null, false,
true);
break;
case 'package':
default:
$extension = $item->element;
$lang->load("$extension.sys", JPATH_SITE, null, false,
true);
break;
}
// Translate the extension name if possible
$item->name = JText::_($item->name);
settype($item->description, 'string');
if (!in_array($item->type, array('language')))
{
$item->description = JText::_($item->description);
}
}
}
}
fields/extensionstatus.php000064400000001621151160606600012004
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR .
'/components/com_installer/helpers/installer.php');
JFormHelper::loadFieldClass('list');
/**
* Extension Status field.
*
* @since 3.5
*/
class JFormFieldExtensionStatus extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
protected $type = 'ExtensionStatus';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.5
*/
public function getOptions()
{
$options = InstallerHelper::getStateOptions();
return array_merge(parent::getOptions(), $options);
}
}
fields/folder.php000064400000001571151160606600010003 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR .
'/components/com_installer/helpers/installer.php');
JFormHelper::loadFieldClass('list');
/**
* Folder field.
*
* @since 3.5
*/
class JFormFieldFolder extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
protected $type = 'Folder';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.5
*/
public function getOptions()
{
$options = InstallerHelper::getExtensionGroupes();
return array_merge(parent::getOptions(), $options);
}
}
fields/location.php000064400000001574151160606600010343 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR .
'/components/com_installer/helpers/installer.php');
JFormHelper::loadFieldClass('list');
/**
* Location field.
*
* @since 3.5
*/
class JFormFieldLocation extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
protected $type = 'Location';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.5
*/
public function getOptions()
{
$options = InstallerHelper::getClientOptions();
return array_merge(parent::getOptions(), $options);
}
}
fields/type.php000064400000004200151160606600007501 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* Fields Type
*
* @since 3.7.0
*/
class JFormFieldType extends JFormFieldList
{
public $type = 'Type';
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @since 3.7.0
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
$this->onchange = 'typeHasChanged(this);';
return $return;
}
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.7.0
*/
protected function getOptions()
{
$options = parent::getOptions();
$fieldTypes = FieldsHelper::getFieldTypes();
foreach ($fieldTypes as $fieldType)
{
$options[] = JHtml::_('select.option',
$fieldType['type'], $fieldType['label']);
}
// Sorting the fields based on the text which is displayed
usort(
$options,
function ($a, $b)
{
return strcmp($a->text, $b->text);
}
);
JFactory::getDocument()->addScriptDeclaration("
jQuery( document ).ready(function() {
Joomla.loadingLayer('load');
});
function typeHasChanged(element){
Joomla.loadingLayer('show');
var cat = jQuery(element);
jQuery('input[name=task]').val('field.reload');
element.form.submit();
}
"
);
return $options;
}
}
forms/filter_discover.xml000064400000004036151160606600011603
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_installer/models/fields"/>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_INSTALLER_DISCOVER_FILTER_SEARCH_LABEL"
description="COM_INSTALLER_DISCOVER_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="client_id"
type="location"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_CLIENT_SELECT</option>
</field>
<field
name="type"
type="type"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_TYPE_SELECT</option>
</field>
<field
name="folder"
type="folder"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_FOLDER_SELECT</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="name
ASC">COM_INSTALLER_HEADING_NAME_ASC</option>
<option value="name
DESC">COM_INSTALLER_HEADING_NAME_DESC</option>
<option value="client_translated
ASC">COM_INSTALLER_HEADING_LOCATION_ASC</option>
<option value="client_translated
DESC">COM_INSTALLER_HEADING_LOCATION_DESC</option>
<option value="type_translated
ASC">COM_INSTALLER_HEADING_TYPE_ASC</option>
<option value="type_translated
DESC">COM_INSTALLER_HEADING_TYPE_DESC</option>
<option value="folder_translated
ASC">COM_INSTALLER_HEADING_FOLDER_ASC</option>
<option value="folder_translated
DESC">COM_INSTALLER_HEADING_FOLDER_DESC</option>
<option value="extension_id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="extension_id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_languages.xml000064400000004637151160606600011742
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="JSEARCH_FILTER"
description="COM_LANGUAGES_SEARCH_IN_TITLE"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
filter="1,0,-2,*"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="access"
type="accesslevel"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_ACCESS</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.ordering ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.title_native
ASC">COM_LANGUAGES_HEADING_TITLE_NATIVE_ASC</option>
<option value="a.title_native
DESC">COM_LANGUAGES_HEADING_TITLE_NATIVE_DESC</option>
<option value="a.lang_code
ASC">COM_LANGUAGES_HEADING_LANG_TAG_ASC</option>
<option value="a.lang_code
DESC">COM_LANGUAGES_HEADING_LANG_TAG_DESC</option>
<option value="a.sef
ASC">COM_LANGUAGES_HEADING_LANG_CODE_ASC</option>
<option value="a.sef
DESC">COM_LANGUAGES_HEADING_LANG_CODE_DESC</option>
<option value="a.image
ASC">COM_LANGUAGES_HEADING_LANG_IMAGE_ASC</option>
<option value="a.image
DESC">COM_LANGUAGES_HEADING_LANG_IMAGE_DESC</option>
<option value="a.access
ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="a.access
DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="l.home
ASC">COM_LANGUAGES_HEADING_HOMEPAGE_ASC</option>
<option value="l.home
DESC">COM_LANGUAGES_HEADING_HOMEPAGE_DESC</option>
<option value="a.lang_id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.lang_id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_manage.xml000064400000005035151160606600011215
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_installer/models/fields"
/>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_INSTALLER_MANAGE_FILTER_SEARCH_LABEL"
description="COM_INSTALLER_MANAGE_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="status"
type="extensionstatus"
label="COM_PLUGINS_FILTER_PUBLISHED"
description="COM_PLUGINS_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="client_id"
type="location"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_CLIENT_SELECT</option>
</field>
<field
name="type"
type="type"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_TYPE_SELECT</option>
</field>
<field
name="folder"
type="folder"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_FOLDER_SELECT</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="status ASC">JSTATUS_ASC</option>
<option value="status DESC">JSTATUS_DESC</option>
<option value="name
ASC">COM_INSTALLER_HEADING_NAME_ASC</option>
<option value="name
DESC">COM_INSTALLER_HEADING_NAME_DESC</option>
<option value="client_translated
ASC">COM_INSTALLER_HEADING_LOCATION_ASC</option>
<option value="client_translated
DESC">COM_INSTALLER_HEADING_LOCATION_DESC</option>
<option value="type_translated
ASC">COM_INSTALLER_HEADING_TYPE_ASC</option>
<option value="type_translated
DESC">COM_INSTALLER_HEADING_TYPE_DESC</option>
<option value="folder_translated
ASC">COM_INSTALLER_HEADING_FOLDER_ASC</option>
<option value="folder_translated
DESC">COM_INSTALLER_HEADING_FOLDER_DESC</option>
<option value="package_id
ASC">COM_INSTALLER_HEADING_PACKAGE_ID_ASC</option>
<option value="package_id
DESC">COM_INSTALLER_HEADING_PACKAGE_ID_DESC</option>
<option value="extension_id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="extension_id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_update.xml000064400000003625151160606600011252
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_installer/models/fields"/>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_INSTALLER_UPDATE_FILTER_SEARCH_LABEL"
description="COM_INSTALLER_UPDATE_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="client_id"
type="location"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_CLIENT_SELECT</option>
</field>
<field
name="type"
type="type"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_TYPE_SELECT</option>
</field>
<field
name="folder"
type="folder"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_FOLDER_SELECT</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="u.name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="u.name
ASC">COM_INSTALLER_HEADING_NAME_ASC</option>
<option value="u.name
DESC">COM_INSTALLER_HEADING_NAME_DESC</option>
<option value="client_translated
ASC">COM_INSTALLER_HEADING_LOCATION_ASC</option>
<option value="client_translated
DESC">COM_INSTALLER_HEADING_LOCATION_DESC</option>
<option value="type_translated
ASC">COM_INSTALLER_HEADING_TYPE_ASC</option>
<option value="type_translated
DESC">COM_INSTALLER_HEADING_TYPE_DESC</option>
<option value="folder_translated
ASC">COM_INSTALLER_HEADING_FOLDER_ASC</option>
<option value="folder_translated
DESC">COM_INSTALLER_HEADING_FOLDER_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_updatesites.xml000064400000005201151160606600012312
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_installer/models/fields"/>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_INSTALLER_UPDATESITES_FILTER_SEARCH_LABEL"
description="COM_INSTALLER_UPDATESITES_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="enabled"
type="list"
label="COM_PLUGINS_FILTER_PUBLISHED"
description="COM_PLUGINS_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
<option value="0">JDISABLED</option>
<option value="1">JENABLED</option>
</field>
<field
name="client_id"
type="location"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_CLIENT_SELECT</option>
</field>
<field
name="type"
type="type"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_TYPE_SELECT</option>
</field>
<field
name="folder"
type="folder"
onchange="this.form.submit();"
>
<option
value="">COM_INSTALLER_VALUE_FOLDER_SELECT</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="enabled ASC">JSTATUS_ASC</option>
<option value="enabled DESC">JSTATUS_DESC</option>
<option value="update_site_name
ASC">COM_INSTALLER_HEADING_UPDATESITE_NAME_ASC</option>
<option value="update_site_name
DESC">COM_INSTALLER_HEADING_UPDATESITE_NAME_DESC</option>
<option value="name
ASC">COM_INSTALLER_HEADING_NAME_ASC</option>
<option value="name
DESC">COM_INSTALLER_HEADING_NAME_DESC</option>
<option value="client_translated
ASC">COM_INSTALLER_HEADING_LOCATION_ASC</option>
<option value="client_translated
DESC">COM_INSTALLER_HEADING_LOCATION_DESC</option>
<option value="type_translated
ASC">COM_INSTALLER_HEADING_TYPE_ASC</option>
<option value="type_translated
DESC">COM_INSTALLER_HEADING_TYPE_DESC</option>
<option value="folder_translated
ASC">COM_INSTALLER_HEADING_FOLDER_ASC</option>
<option value="folder_translated
DESC">COM_INSTALLER_HEADING_FOLDER_DESC</option>
<option value="update_site_id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="update_site_id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
install.php000064400000025706151160606600006736 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Extension Manager Install Model
*
* @since 1.5
*/
class InstallerModelInstall extends JModelLegacy
{
/**
* @var object JTable object
*/
protected $_table = null;
/**
* @var object JTable object
*/
protected $_url = null;
/**
* Model context string.
*
* @var string
*/
protected $_context = 'com_installer.install';
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication('administrator');
$this->setState('message',
$app->getUserState('com_installer.message'));
$this->setState('extension_message',
$app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message',
'');
parent::populateState();
}
/**
* Install an extension from either folder, URL or upload.
*
* @return boolean result of install.
*
* @since 1.5
*/
public function install()
{
$this->setState('action', 'install');
// Set FTP credentials, if given.
JClientHelper::setCredentialsFromRequest('ftp');
$app = JFactory::getApplication();
// Load installer plugins for assistance if required:
JPluginHelper::importPlugin('installer');
$dispatcher = JEventDispatcher::getInstance();
$package = null;
// This event allows an input pre-treatment, a custom pre-packing or
custom installation.
// (e.g. from a JSON description).
$results =
$dispatcher->trigger('onInstallerBeforeInstallation',
array($this, &$package));
if (in_array(true, $results, true))
{
return true;
}
if (in_array(false, $results, true))
{
return false;
}
$installType = $app->input->getWord('installtype');
if ($package === null)
{
switch ($installType)
{
case 'folder':
// Remember the 'Install from Directory' path.
$app->getUserStateFromRequest($this->_context .
'.install_directory', 'install_directory');
$package = $this->_getPackageFromFolder();
break;
case 'upload':
$package = $this->_getPackageFromUpload();
break;
case 'url':
$package = $this->_getPackageFromUrl();
break;
default:
$app->setUserState('com_installer.message',
JText::_('COM_INSTALLER_NO_INSTALL_TYPE_FOUND'));
return false;
break;
}
}
// This event allows a custom installation of the package or a
customization of the package:
$results =
$dispatcher->trigger('onInstallerBeforeInstaller',
array($this, &$package));
if (in_array(true, $results, true))
{
return true;
}
if (in_array(false, $results, true))
{
if (in_array($installType, array('upload', 'url')))
{
JInstallerHelper::cleanupInstall($package['packagefile'],
$package['extractdir']);
}
return false;
}
// Check if package was uploaded successfully.
if (!\is_array($package))
{
$app->enqueueMessage(JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'),
'error');
return false;
}
// Get an installer instance.
$installer = JInstaller::getInstance();
/*
* Check for a Joomla core package.
* To do this we need to set the source path to find the manifest (the
same first step as JInstaller::install())
*
* This must be done before the unpacked check because
JInstallerHelper::detectType() returns a boolean false since the manifest
* can't be found in the expected location.
*/
if (isset($package['dir']) &&
is_dir($package['dir']))
{
$installer->setPath('source', $package['dir']);
if (!$installer->findManifest())
{
// If a manifest isn't found at the source, this may be a Joomla
package; check the package directory for the Joomla manifest
if (file_exists($package['dir'] .
'/administrator/manifests/files/joomla.xml'))
{
// We have a Joomla package
if (in_array($installType, array('upload',
'url')))
{
JInstallerHelper::cleanupInstall($package['packagefile'],
$package['extractdir']);
}
$app->enqueueMessage(
JText::sprintf('COM_INSTALLER_UNABLE_TO_INSTALL_JOOMLA_PACKAGE',
JRoute::_('index.php?option=com_joomlaupdate')),
'warning'
);
return false;
}
}
}
// Was the package unpacked?
if (empty($package['type']))
{
if (in_array($installType, array('upload', 'url')))
{
JInstallerHelper::cleanupInstall($package['packagefile'],
$package['extractdir']);
}
$app->enqueueMessage(JText::_('JLIB_INSTALLER_ABORT_DETECTMANIFEST'),
'error');
return false;
}
// Install the package.
if (!$installer->install($package['dir']))
{
// There was an error installing the package.
$msg = JText::sprintf('COM_INSTALLER_INSTALL_ERROR',
JText::_('COM_INSTALLER_TYPE_TYPE_' .
strtoupper($package['type'])));
$result = false;
$msgType = 'error';
}
else
{
// Package installed successfully.
$msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS',
JText::_('COM_INSTALLER_TYPE_TYPE_' .
strtoupper($package['type'])));
$result = true;
$msgType = 'message';
}
// This event allows a custom a post-flight:
$dispatcher->trigger('onInstallerAfterInstaller',
array($this, &$package, $installer, &$result, &$msg));
// Set some model state values.
$app = JFactory::getApplication();
$app->enqueueMessage($msg, $msgType);
$this->setState('name',
$installer->get('name'));
$this->setState('result', $result);
$app->setUserState('com_installer.message',
$installer->message);
$app->setUserState('com_installer.extension_message',
$installer->get('extension_message'));
$app->setUserState('com_installer.redirect_url',
$installer->get('redirect_url'));
// Cleanup the install files.
if (!is_file($package['packagefile']))
{
$config = JFactory::getConfig();
$package['packagefile'] =
$config->get('tmp_path') . '/' .
$package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'],
$package['extractdir']);
// Clear the cached extension data and menu cache
$this->cleanCache('_system', 0);
$this->cleanCache('_system', 1);
$this->cleanCache('com_modules', 0);
$this->cleanCache('com_modules', 1);
$this->cleanCache('com_plugins', 0);
$this->cleanCache('com_plugins', 1);
$this->cleanCache('mod_menu', 0);
$this->cleanCache('mod_menu', 1);
return $result;
}
/**
* Works out an installation package from a HTTP upload.
*
* @return package definition or false on failure.
*/
protected function _getPackageFromUpload()
{
// Get the uploaded file information.
$input = JFactory::getApplication()->input;
// Do not change the filter type 'raw'. We need this to let
files containing PHP code to upload. See JInputFiles::get.
$userfile = $input->files->get('install_package', null,
'raw');
// Make sure that file uploads are enabled in php.
if (!(bool) ini_get('file_uploads'))
{
JError::raiseWarning('',
JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLFILE'));
return false;
}
// Make sure that zlib is loaded so that the package can be unpacked.
if (!extension_loaded('zlib'))
{
JError::raiseWarning('',
JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLZLIB'));
return false;
}
// If there is no uploaded file, we have a problem...
if (!is_array($userfile))
{
JError::raiseWarning('',
JText::_('COM_INSTALLER_MSG_INSTALL_NO_FILE_SELECTED'));
return false;
}
// Is the PHP tmp directory missing?
if ($userfile['error'] && ($userfile['error']
== UPLOAD_ERR_NO_TMP_DIR))
{
JError::raiseWarning(
'',
JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLUPLOADERROR')
. '<br />' .
JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSET')
);
return false;
}
// Is the max upload size too small in php.ini?
if ($userfile['error'] && ($userfile['error']
== UPLOAD_ERR_INI_SIZE))
{
JError::raiseWarning(
'',
JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLUPLOADERROR')
. '<br />' .
JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLUPLOADSIZE')
);
return false;
}
// Check if there was a different problem uploading the file.
if ($userfile['error'] || $userfile['size'] < 1)
{
JError::raiseWarning('',
JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLUPLOADERROR'));
return false;
}
// Build the appropriate paths.
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path') . '/' .
$userfile['name'];
$tmp_src = $userfile['tmp_name'];
// Move uploaded file.
jimport('joomla.filesystem.file');
JFile::upload($tmp_src, $tmp_dest, false, true);
// Unpack the downloaded package file.
$package = JInstallerHelper::unpack($tmp_dest, true);
return $package;
}
/**
* Install an extension from a directory
*
* @return array Package details or false on failure
*
* @since 1.5
*/
protected function _getPackageFromFolder()
{
$input = JFactory::getApplication()->input;
// Get the path to the package to install.
$p_dir = $input->getString('install_directory');
$p_dir = JPath::clean($p_dir);
// Did you give us a valid directory?
if (!is_dir($p_dir))
{
JError::raiseWarning('',
JText::_('COM_INSTALLER_MSG_INSTALL_PLEASE_ENTER_A_PACKAGE_DIRECTORY'));
return false;
}
// Detect the package type
$type = JInstallerHelper::detectType($p_dir);
// Did you give us a valid package?
if (!$type)
{
JError::raiseWarning('',
JText::_('COM_INSTALLER_MSG_INSTALL_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'));
}
$package['packagefile'] = null;
$package['extractdir'] = null;
$package['dir'] = $p_dir;
$package['type'] = $type;
return $package;
}
/**
* Install an extension from a URL.
*
* @return Package details or false on failure.
*
* @since 1.5
*/
protected function _getPackageFromUrl()
{
$input = JFactory::getApplication()->input;
// Get the URL of the package to install.
$url = $input->getString('install_url');
// Did you give us a URL?
if (!$url)
{
JError::raiseWarning('',
JText::_('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL'));
return false;
}
// Handle updater XML file case:
if (preg_match('/\.xml\s*$/', $url))
{
jimport('joomla.updater.update');
$update = new JUpdate;
$update->loadFromXml($url);
$package_url = trim($update->get('downloadurl',
false)->_data);
if ($package_url)
{
$url = $package_url;
}
unset($update);
}
// Download the package at the URL given.
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file)
{
JError::raiseWarning('',
JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file.
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file,
true);
return $package;
}
}
languages.php000064400000013000151160606600007216 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Languages Model Class
*
* @since 1.6
*/
class LanguagesModelLanguages extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'lang_id', 'a.lang_id',
'lang_code', 'a.lang_code',
'title', 'a.title',
'title_native', 'a.title_native',
'sef', 'a.sef',
'image', 'a.image',
'published', 'a.published',
'ordering', 'a.ordering',
'access', 'a.access', 'access_level',
'home', 'l.home',
);
}
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.6
*/
protected function populateState($ordering = 'a.ordering',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.access',
$this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', '',
'cmd'));
$this->setState('filter.published',
$this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '',
'string'));
// Load the parameters.
$params = JComponentHelper::getParams('com_languages');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.published');
return parent::getStoreId($id);
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select all fields from the languages table.
$query->select($this->getState('list.select',
'a.*', 'l.home'))
->from($db->quoteName('#__languages') . ' AS
a');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Select the language home pages.
$query->select('l.home AS home')
->join('LEFT', $db->quoteName('#__menu') .
' AS l ON l.language = a.lang_code AND l.home=1 AND l.language
<> ' . $db->quote('*'));
// Filter on the published state.
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published IN (0, 1))');
}
// Filter by search in title.
$search = $this->getState('filter.search');
if (!empty($search))
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('(a.title LIKE ' . $search . ')');
}
// Filter by access level.
if ($access = $this->getState('filter.access'))
{
$query->where('a.access = ' . (int) $access);
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.ordering')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Set the published language(s).
*
* @param array $cid An array of language IDs.
* @param integer $value The value of the published state.
*
* @return boolean True on success, false otherwise.
*
* @since 1.6
*/
public function setPublished($cid, $value = 0)
{
return JTable::getInstance('Language')->publish($cid,
$value);
}
/**
* Method to delete records.
*
* @param array $pks An array of item primary keys.
*
* @return boolean Returns true on success, false on failure.
*
* @since 1.6
*/
public function delete($pks)
{
// Sanitize the array.
$pks = (array) $pks;
// Get a row instance.
$table = JTable::getInstance('Language');
// Iterate the items to delete each one.
foreach ($pks as $itemId)
{
if (!$table->delete((int) $itemId))
{
$this->setError($table->getError());
return false;
}
}
// Clean the cache.
$this->cleanCache();
return true;
}
/**
* Custom clean cache method, 2 places for 2 clients.
*
* @param string $group Optional cache group name.
* @param integer $clientId Application client id.
*
* @return void
*
* @since 1.6
*/
protected function cleanCache($group = null, $clientId = 0)
{
parent::cleanCache('_system');
parent::cleanCache('com_languages');
}
}
manage.php000064400000021517151160606600006514 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('InstallerModel', __DIR__ .
'/extension.php');
/**
* Installer Manage Model
*
* @since 1.5
*/
class InstallerModelManage extends InstallerModel
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'status',
'name',
'client_id',
'client', 'client_translated',
'type', 'type_translated',
'folder', 'folder_translated',
'package_id',
'extension_id',
);
}
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.6
*/
protected function populateState($ordering = 'name', $direction
= 'asc')
{
$app = JFactory::getApplication();
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.client_id',
$this->getUserStateFromRequest($this->context .
'.filter.client_id', 'filter_client_id', null,
'int'));
$this->setState('filter.status',
$this->getUserStateFromRequest($this->context .
'.filter.status', 'filter_status', '',
'string'));
$this->setState('filter.type',
$this->getUserStateFromRequest($this->context .
'.filter.type', 'filter_type', '',
'string'));
$this->setState('filter.folder',
$this->getUserStateFromRequest($this->context .
'.filter.folder', 'filter_folder', '',
'string'));
$this->setState('message',
$app->getUserState('com_installer.message'));
$this->setState('extension_message',
$app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message',
'');
parent::populateState($ordering, $direction);
}
/**
* Enable/Disable an extension.
*
* @param array $eid Extension ids to un/publish
* @param int $value Publish value
*
* @return boolean True on success
*
* @since 1.5
*/
public function publish(&$eid = array(), $value = 1)
{
$user = JFactory::getUser();
if (!$user->authorise('core.edit.state',
'com_installer'))
{
JError::raiseWarning(403,
JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
return false;
}
$result = true;
/*
* Ensure eid is an array of extension ids
* TODO: If it isn't an array do we want to set an error and fail?
*/
if (!is_array($eid))
{
$eid = array($eid);
}
// Get a table object for the extension type
$table = JTable::getInstance('Extension');
JTable::addIncludePath(JPATH_ADMINISTRATOR .
'/components/com_templates/tables');
// Enable the extension in the table and store it in the database
foreach ($eid as $i => $id)
{
$table->load($id);
if ($table->type == 'template')
{
$style = JTable::getInstance('Style',
'TemplatesTable');
if ($style->load(array('template' =>
$table->element, 'client_id' => $table->client_id,
'home' => 1)))
{
JError::raiseNotice(403,
JText::_('COM_INSTALLER_ERROR_DISABLE_DEFAULT_TEMPLATE_NOT_PERMITTED'));
unset($eid[$i]);
continue;
}
}
if ($table->protected == 1)
{
$result = false;
JError::raiseWarning(403,
JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
else
{
$table->enabled = $value;
}
$context = $this->option . '.' . $this->name;
JPluginHelper::importPlugin('extension');
JEventDispatcher::getInstance()->trigger('onExtensionChangeState',
array($context, $eid, $value));
if (!$table->store())
{
$this->setError($table->getError());
$result = false;
}
}
// Clear the cached extension data and menu cache
$this->cleanCache('_system', 0);
$this->cleanCache('_system', 1);
$this->cleanCache('com_modules', 0);
$this->cleanCache('com_modules', 1);
$this->cleanCache('mod_menu', 0);
$this->cleanCache('mod_menu', 1);
return $result;
}
/**
* Refreshes the cached manifest information for an extension.
*
* @param int $eid extension identifier (key in #__extensions)
*
* @return boolean result of refresh
*
* @since 1.6
*/
public function refresh($eid)
{
if (!is_array($eid))
{
$eid = array($eid => 0);
}
// Get an installer object for the extension type
$installer = JInstaller::getInstance();
$result = 0;
// Uninstall the chosen extensions
foreach ($eid as $id)
{
$result |= $installer->refreshManifestCache($id);
}
return $result;
}
/**
* Remove (uninstall) an extension
*
* @param array $eid An array of identifiers
*
* @return boolean True on success
*
* @since 1.5
*/
public function remove($eid = array())
{
$user = JFactory::getUser();
if (!$user->authorise('core.delete',
'com_installer'))
{
JError::raiseWarning(403,
JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
return false;
}
/*
* Ensure eid is an array of extension ids in the form id => client_id
* TODO: If it isn't an array do we want to set an error and fail?
*/
if (!is_array($eid))
{
$eid = array($eid => 0);
}
// Get an installer object for the extension type
$installer = JInstaller::getInstance();
$row = JTable::getInstance('extension');
// Uninstall the chosen extensions
$msgs = array();
$result = false;
foreach ($eid as $id)
{
$id = trim($id);
$row->load($id);
$result = false;
$langstring = 'COM_INSTALLER_TYPE_TYPE_' .
strtoupper($row->type);
$rowtype = JText::_($langstring);
if (strpos($rowtype, $langstring) !== false)
{
$rowtype = $row->type;
}
if ($row->type)
{
$result = $installer->uninstall($row->type, $id);
// Build an array of extensions that failed to uninstall
if ($result === false)
{
// There was an error in uninstalling the package
$msgs[] = JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR',
$rowtype);
continue;
}
// Package uninstalled successfully
$msgs[] = JText::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS',
$rowtype);
$result = true;
continue;
}
// There was an error in uninstalling the package
$msgs[] = JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR',
$rowtype);
}
$msg = implode('<br />', $msgs);
$app = JFactory::getApplication();
$app->enqueueMessage($msg);
$this->setState('action', 'remove');
$this->setState('name',
$installer->get('name'));
$app->setUserState('com_installer.message',
$installer->message);
$app->setUserState('com_installer.extension_message',
$installer->get('extension_message'));
// Clear the cached extension data and menu cache
$this->cleanCache('_system', 0);
$this->cleanCache('_system', 1);
$this->cleanCache('com_modules', 0);
$this->cleanCache('com_modules', 1);
$this->cleanCache('com_plugins', 0);
$this->cleanCache('com_plugins', 1);
$this->cleanCache('mod_menu', 0);
$this->cleanCache('mod_menu', 1);
return $result;
}
/**
* Method to get the database query
*
* @return JDatabaseQuery The database query
*
* @since 1.6
*/
protected function getListQuery()
{
$query = $this->getDbo()->getQuery(true)
->select('*')
->select('2*protected+(1-protected)*enabled AS status')
->from('#__extensions')
->where('state = 0');
// Process select filters.
$status = $this->getState('filter.status');
$type = $this->getState('filter.type');
$clientId = $this->getState('filter.client_id');
$folder = $this->getState('filter.folder');
if ($status != '')
{
if ($status == '2')
{
$query->where('protected = 1');
}
elseif ($status == '3')
{
$query->where('protected = 0');
}
else
{
$query->where('protected = 0')
->where('enabled = ' . (int) $status);
}
}
if ($type)
{
$query->where('type = ' . $this->_db->quote($type));
}
if ($clientId != '')
{
$query->where('client_id = ' . (int) $clientId);
}
if ($folder != '')
{
$query->where('folder = ' . $this->_db->quote($folder
== '*' ? '' : $folder));
}
// Process search filter (extension id).
$search = $this->getState('filter.search');
if (!empty($search) && stripos($search, 'id:') === 0)
{
$query->where('extension_id = ' . (int) substr($search,
3));
}
// Note: The search for name, ordering and pagination are processed by
the parent InstallerModel class (in extension.php).
return $query;
}
}
update.php000064400000040360151160606600006543 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.updater.update');
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Installer\InstallerHelper;
/**
* Installer Update Model
*
* @since 1.6
*/
class InstallerModelUpdate extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'name', 'u.name',
'client_id', 'u.client_id',
'client_translated',
'type', 'u.type', 'type_translated',
'folder', 'u.folder',
'folder_translated',
'extension_id', 'u.extension_id',
);
}
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.6
*/
protected function populateState($ordering = 'u.name',
$direction = 'asc')
{
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.client_id',
$this->getUserStateFromRequest($this->context .
'.filter.client_id', 'filter_client_id', null,
'int'));
$this->setState('filter.type',
$this->getUserStateFromRequest($this->context .
'.filter.type', 'filter_type', '',
'string'));
$this->setState('filter.folder',
$this->getUserStateFromRequest($this->context .
'.filter.folder', 'filter_folder', '',
'string'));
$app = JFactory::getApplication();
$this->setState('message',
$app->getUserState('com_installer.message'));
$this->setState('extension_message',
$app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message',
'');
parent::populateState($ordering, $direction);
}
/**
* Method to get the database query
*
* @return JDatabaseQuery The database query
*
* @since 1.6
*/
protected function getListQuery()
{
$db = $this->getDbo();
// Grab updates ignoring new installs
$query = $db->getQuery(true)
->select('u.*')
->select($db->quoteName('e.manifest_cache'))
->from($db->quoteName('#__updates', 'u'))
->join('LEFT', $db->quoteName('#__extensions',
'e') . ' ON ' .
$db->quoteName('e.extension_id') . ' = ' .
$db->quoteName('u.extension_id'))
->where($db->quoteName('u.extension_id') . ' !=
' . $db->quote(0));
// Process select filters.
$clientId = $this->getState('filter.client_id');
$type = $this->getState('filter.type');
$folder = $this->getState('filter.folder');
$extensionId = $this->getState('filter.extension_id');
if ($type)
{
$query->where($db->quoteName('u.type') . ' = '
. $db->quote($type));
}
if ($clientId != '')
{
$query->where($db->quoteName('u.client_id') . ' =
' . (int) $clientId);
}
if ($folder != '' && in_array($type,
array('plugin', 'library', '')))
{
$query->where($db->quoteName('u.folder') . ' =
' . $db->quote($folder == '*' ? '' : $folder));
}
if ($extensionId)
{
$query->where($db->quoteName('u.extension_id') . '
= ' . $db->quote((int) $extensionId));
}
else
{
$query->where($db->quoteName('u.extension_id') . '
!= ' . $db->quote(0))
->where($db->quoteName('u.extension_id') . ' !=
' . $db->quote(700));
}
// Process search filter.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'eid:') !== false)
{
$query->where($db->quoteName('u.extension_id') . '
= ' . (int) substr($search, 4));
}
else
{
if (stripos($search, 'uid:') !== false)
{
$query->where($db->quoteName('u.update_site_id') .
' = ' . (int) substr($search, 4));
}
elseif (stripos($search, 'id:') !== false)
{
$query->where($db->quoteName('u.update_id') . ' =
' . (int) substr($search, 3));
}
else
{
$query->where($db->quoteName('u.name') . ' LIKE
' . $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true)) . '%'));
}
}
}
return $query;
}
/**
* Translate a list of objects
*
* @param array $items The array of objects
*
* @return array The array of translated objects
*
* @since 3.5
*/
protected function translate(&$items)
{
foreach ($items as &$item)
{
$item->client_translated = $item->client_id ?
JText::_('JADMINISTRATOR') : JText::_('JSITE');
$manifest = json_decode($item->manifest_cache);
$item->current_version = isset($manifest->version) ?
$manifest->version : JText::_('JLIB_UNKNOWN');
$item->type_translated = JText::_('COM_INSTALLER_TYPE_'
. strtoupper($item->type));
$item->folder_translated = $item->folder ?:
JText::_('COM_INSTALLER_TYPE_NONAPPLICABLE');
$item->install_type = $item->extension_id ?
JText::_('COM_INSTALLER_MSG_UPDATE_UPDATE') :
JText::_('COM_INSTALLER_NEW_INSTALL');
}
return $items;
}
/**
* Returns an object list
*
* @param string $query The query
* @param int $limitstart Offset
* @param int $limit The number of records
*
* @return array
*
* @since 3.5
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$db = $this->getDbo();
$listOrder = $this->getState('list.ordering',
'u.name');
$listDirn = $this->getState('list.direction',
'asc');
// Process ordering.
if (in_array($listOrder, array('client_translated',
'folder_translated', 'type_translated')))
{
$db->setQuery($query);
$result = $db->loadObjectList();
$this->translate($result);
$result = ArrayHelper::sortObjects($result, $listOrder,
strtolower($listDirn) === 'desc' ? -1 : 1, true, true);
$total = count($result);
if ($total < $limitstart)
{
$limitstart = 0;
$this->setState('list.start', 0);
}
return array_slice($result, $limitstart, $limit ?: null);
}
else
{
$query->order($db->quoteName($listOrder) . ' ' .
$db->escape($listDirn));
$result = parent::_getList($query, $limitstart, $limit);
$this->translate($result);
return $result;
}
}
/**
* Get the count of disabled update sites
*
* @return integer
*
* @since 3.4
*/
public function getDisabledUpdateSites()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName('#__update_sites'))
->where($db->quoteName('enabled') . ' = 0');
$db->setQuery($query);
return $db->loadResult();
}
/**
* Finds updates for an extension.
*
* @param int $eid Extension identifier to look for
* @param int $cacheTimeout Cache timout
* @param int $minimumStability Minimum stability for updates {@see
JUpdater} (0=dev, 1=alpha, 2=beta, 3=rc, 4=stable)
*
* @return boolean Result
*
* @since 1.6
*/
public function findUpdates($eid = 0, $cacheTimeout = 0, $minimumStability
= JUpdater::STABILITY_STABLE)
{
JUpdater::getInstance()->findUpdates($eid, $cacheTimeout,
$minimumStability);
return true;
}
/**
* Removes all of the updates from the table.
*
* @return boolean result of operation
*
* @since 1.6
*/
public function purge()
{
$db = $this->getDbo();
// Note: TRUNCATE is a DDL operation
// This may or may not mean depending on your database
$db->setQuery('TRUNCATE TABLE #__updates');
try
{
$db->execute();
}
catch (JDatabaseExceptionExecuting $e)
{
$this->_message =
JText::_('JLIB_INSTALLER_FAILED_TO_PURGE_UPDATES');
return false;
}
// Reset the last update check timestamp
$query = $db->getQuery(true)
->update($db->quoteName('#__update_sites'))
->set($db->quoteName('last_check_timestamp') . ' =
' . $db->quote(0));
$db->setQuery($query);
$db->execute();
// Clear the administrator cache
$this->cleanCache('_system', 1);
$this->_message = JText::_('JLIB_INSTALLER_PURGED_UPDATES');
return true;
}
/**
* Enables any disabled rows in #__update_sites table
*
* @return boolean result of operation
*
* @since 1.6
*/
public function enableSites()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->update($db->quoteName('#__update_sites'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('enabled') . ' = 0');
$db->setQuery($query);
try
{
$db->execute();
}
catch (JDatabaseExceptionExecuting $e)
{
$this->_message .=
JText::_('COM_INSTALLER_FAILED_TO_ENABLE_UPDATES');
return false;
}
if ($rows = $db->getAffectedRows())
{
$this->_message .=
JText::plural('COM_INSTALLER_ENABLED_UPDATES', $rows);
}
return true;
}
/**
* Update function.
*
* Sets the "result" state with the result of the operation.
*
* @param array $uids Array[int] List of updates to apply
* @param int $minimumStability The minimum allowed stability for
installed updates {@see JUpdater}
*
* @return void
*
* @since 1.6
*/
public function update($uids, $minimumStability =
JUpdater::STABILITY_STABLE)
{
$result = true;
foreach ($uids as $uid)
{
$update = new JUpdate;
$instance = JTable::getInstance('update');
$instance->load($uid);
$update->loadFromXml($instance->detailsurl, $minimumStability);
$update->set('extra_query', $instance->extra_query);
$this->preparePreUpdate($update, $instance);
// Install sets state and enqueues messages
$res = $this->install($update);
if ($res)
{
$instance->delete($uid);
}
$result = $res & $result;
}
// Clear the cached extension data and menu cache
$this->cleanCache('_system', 0);
$this->cleanCache('_system', 1);
$this->cleanCache('com_modules', 0);
$this->cleanCache('com_modules', 1);
$this->cleanCache('com_plugins', 0);
$this->cleanCache('com_plugins', 1);
$this->cleanCache('mod_menu', 0);
$this->cleanCache('mod_menu', 1);
// Set the final state
$this->setState('result', $result);
}
/**
* Handles the actual update installation.
*
* @param JUpdate $update An update definition
*
* @return boolean Result of install
*
* @since 1.6
*/
private function install($update)
{
$app = JFactory::getApplication();
if (!isset($update->get('downloadurl')->_data))
{
JError::raiseWarning('',
JText::_('COM_INSTALLER_INVALID_EXTENSION_UPDATE'));
return false;
}
$url = trim($update->downloadurl->_data);
$sources = $update->get('downloadSources', array());
if ($extra_query = $update->get('extra_query'))
{
$url .= (strpos($url, '?') === false) ? '?' :
'&';
$url .= $extra_query;
}
$mirror = 0;
while (!($p_file = InstallerHelper::downloadPackage($url)) &&
isset($sources[$mirror]))
{
$name = $sources[$mirror];
$url = trim($name->url);
if ($extra_query)
{
$url .= (strpos($url, '?') === false) ? '?' :
'&';
$url .= $extra_query;
}
$mirror++;
}
// Was the package downloaded?
if (!$p_file)
{
JError::raiseWarning('',
JText::sprintf('COM_INSTALLER_PACKAGE_DOWNLOAD_FAILED', $url));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file
$package = InstallerHelper::unpack($tmp_dest . '/' . $p_file);
if (empty($package))
{
$app->enqueueMessage(JText::sprintf('COM_INSTALLER_UNPACK_ERROR',
$p_file), 'error');
return false;
}
// Get an installer instance
$installer = JInstaller::getInstance();
$update->set('type', $package['type']);
// Check the package
$check =
InstallerHelper::isChecksumValid($package['packagefile'],
$update);
// The validation was not successful. Just a warning for now.
// TODO: In Joomla 4 this will abort the installation
if ($check === InstallerHelper::HASH_NOT_VALIDATED)
{
$app->enqueueMessage(JText::_('COM_INSTALLER_INSTALL_CHECKSUM_WRONG'),
'error');
}
// Install the package
if (!$installer->update($package['dir']))
{
// There was an error updating the package
$app->enqueueMessage(
JText::sprintf('COM_INSTALLER_MSG_UPDATE_ERROR',
JText::_('COM_INSTALLER_TYPE_TYPE_' .
strtoupper($package['type']))
), 'error'
);
$result = false;
}
else
{
// Package updated successfully
$app->enqueueMessage(
JText::sprintf('COM_INSTALLER_MSG_UPDATE_SUCCESS',
JText::_('COM_INSTALLER_TYPE_TYPE_' .
strtoupper($package['type']))
)
);
$result = true;
}
// Quick change
$this->type = $package['type'];
// TODO: Reconfigure this code when you have more battery life left
$this->setState('name',
$installer->get('name'));
$this->setState('result', $result);
$app->setUserState('com_installer.message',
$installer->message);
$app->setUserState('com_installer.extension_message',
$installer->get('extension_message'));
// Cleanup the install files
if (!is_file($package['packagefile']))
{
$config = JFactory::getConfig();
$package['packagefile'] =
$config->get('tmp_path') . '/' .
$package['packagefile'];
}
InstallerHelper::cleanupInstall($package['packagefile'],
$package['extractdir']);
return $result;
}
/**
* Method to get the row form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 2.5.2
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
$form = JForm::getInstance('com_installer.update',
'update', array('load_data' => $loadData));
// Check for an error.
if ($form == false)
{
$this->setError($form->getMessage());
return false;
}
// Check the session for previously entered form data.
$data = $this->loadFormData();
// Bind the form data if present.
if (!empty($data))
{
$form->bind($data);
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 2.5.2
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState($this->context,
array());
return $data;
}
/**
* Method to add parameters to the update
*
* @param JUpdate $update An update definition
* @param JTableUpdate $table The update instance from the database
*
* @return void
*
* @since 3.7.0
*/
protected function preparePreUpdate($update, $table)
{
jimport('joomla.filesystem.file');
switch ($table->type)
{
// Components could have a helper which adds additional data
case 'component':
$ename = str_replace('com_', '',
$table->element);
$fname = $ename . '.php';
$cname = ucfirst($ename) . 'Helper';
$path = JPATH_ADMINISTRATOR . '/components/' .
$table->element . '/helpers/' . $fname;
if (JFile::exists($path))
{
require_once $path;
if (class_exists($cname) && is_callable(array($cname,
'prepareUpdate')))
{
call_user_func_array(array($cname, 'prepareUpdate'),
array(&$update, &$table));
}
}
break;
// Modules could have a helper which adds additional data
case 'module':
$cname = str_replace('_', '', $table->element) .
'Helper';
$path = ($table->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) .
'/modules/' . $table->element . '/helper.php';
if (JFile::exists($path))
{
require_once $path;
if (class_exists($cname) && is_callable(array($cname,
'prepareUpdate')))
{
call_user_func_array(array($cname, 'prepareUpdate'),
array(&$update, &$table));
}
}
break;
// If we have a plugin, we can use the plugin trigger
"onInstallerBeforePackageDownload"
// But we should make sure, that our plugin is loaded, so we don't
need a second "installer" plugin
case 'plugin':
$cname = str_replace('plg_', '',
$table->element);
JPluginHelper::importPlugin($table->folder, $cname);
break;
}
}
}
updatesites.php000064400000033576151160606600007626 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('InstallerModel', __DIR__ .
'/extension.php');
/**
* Installer Update Sites Model
*
* @since 3.4
*/
class InstallerModelUpdatesites extends InstallerModel
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 3.4
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'update_site_name',
'name',
'client_id',
'client', 'client_translated',
'status',
'type', 'type_translated',
'folder', 'folder_translated',
'update_site_id',
'enabled',
);
}
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 3.4
*/
protected function populateState($ordering = 'name', $direction
= 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.client_id',
$this->getUserStateFromRequest($this->context .
'.filter.client_id', 'filter_client_id', null,
'int'));
$this->setState('filter.enabled',
$this->getUserStateFromRequest($this->context .
'.filter.enabled', 'filter_enabled', '',
'string'));
$this->setState('filter.type',
$this->getUserStateFromRequest($this->context .
'.filter.type', 'filter_type', '',
'string'));
$this->setState('filter.folder',
$this->getUserStateFromRequest($this->context .
'.filter.folder', 'filter_folder', '',
'string'));
parent::populateState($ordering, $direction);
}
/**
* Enable/Disable an extension.
*
* @param array $eid Extension ids to un/publish
* @param int $value Publish value
*
* @return boolean True on success
*
* @since 3.4
*
* @throws Exception on ACL error
*/
public function publish(&$eid = array(), $value = 1)
{
if (!JFactory::getUser()->authorise('core.edit.state',
'com_installer'))
{
throw new
Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'),
403);
}
$result = true;
// Ensure eid is an array of extension ids
if (!is_array($eid))
{
$eid = array($eid);
}
// Get a table object for the extension type
$table = JTable::getInstance('Updatesite');
// Enable the update site in the table and store it in the database
foreach ($eid as $i => $id)
{
$table->load($id);
$table->enabled = $value;
if (!$table->store())
{
$this->setError($table->getError());
$result = false;
}
}
return $result;
}
/**
* Deletes an update site.
*
* @param array $ids Extension ids to delete.
*
* @return void
*
* @since 3.6
*
* @throws Exception on ACL error
*/
public function delete($ids = array())
{
if (!JFactory::getUser()->authorise('core.delete',
'com_installer'))
{
throw new
Exception(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'),
403);
}
// Ensure eid is an array of extension ids
if (!is_array($ids))
{
$ids = array($ids);
}
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$count = 0;
// Gets the update site names.
$query = $db->getQuery(true)
->select($db->qn(array('update_site_id',
'name')))
->from($db->qn('#__update_sites'))
->where($db->qn('update_site_id') . ' IN (' .
implode(', ', $ids) . ')');
$db->setQuery($query);
$updateSitesNames = $db->loadObjectList('update_site_id');
// Gets Joomla core update sites Ids.
$joomlaUpdateSitesIds = $this->getJoomlaUpdateSitesIds(0);
// Enable the update site in the table and store it in the database
foreach ($ids as $i => $id)
{
// Don't allow to delete Joomla Core update sites.
if (in_array((int) $id, $joomlaUpdateSitesIds))
{
$app->enqueueMessage(JText::sprintf('COM_INSTALLER_MSG_UPDATESITES_DELETE_CANNOT_DELETE',
$updateSitesNames[$id]->name), 'error');
continue;
}
// Delete the update site from all tables.
try
{
$query = $db->getQuery(true)
->delete($db->qn('#__update_sites'))
->where($db->qn('update_site_id') . ' = ' .
(int) $id);
$db->setQuery($query);
$db->execute();
$query = $db->getQuery(true)
->delete($db->qn('#__update_sites_extensions'))
->where($db->qn('update_site_id') . ' = ' .
(int) $id);
$db->setQuery($query);
$db->execute();
$query = $db->getQuery(true)
->delete($db->qn('#__updates'))
->where($db->qn('update_site_id') . ' = ' .
(int) $id);
$db->setQuery($query);
$db->execute();
$count++;
}
catch (RuntimeException $e)
{
$app->enqueueMessage(JText::sprintf('COM_INSTALLER_MSG_UPDATESITES_DELETE_ERROR',
$updateSitesNames[$id]->name, $e->getMessage()), 'error');
}
}
if ($count > 0)
{
$app->enqueueMessage(JText::plural('COM_INSTALLER_MSG_UPDATESITES_N_DELETE_UPDATESITES_DELETED',
$count), 'message');
}
}
/**
* Rebuild update sites tables.
*
* @return void
*
* @since 3.6
*
* @throws Exception on ACL error
*/
public function rebuild()
{
if (!JFactory::getUser()->authorise('core.admin',
'com_installer'))
{
throw new
Exception(JText::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_NOT_PERMITTED'),
403);
}
$db = JFactory::getDbo();
$app = JFactory::getApplication();
// Check if Joomla Extension plugin is enabled.
if (!JPluginHelper::isEnabled('extension', 'joomla'))
{
$query = $db->getQuery(true)
->select($db->quoteName('extension_id'))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'))
->where($db->quoteName('element') . ' = ' .
$db->quote('joomla'))
->where($db->quoteName('folder') . ' = ' .
$db->quote('extension'));
$db->setQuery($query);
$pluginId = (int) $db->loadResult();
$link =
JRoute::_('index.php?option=com_plugins&task=plugin.edit&extension_id='
. $pluginId);
$app->enqueueMessage(JText::sprintf('COM_INSTALLER_MSG_UPDATESITES_REBUILD_EXTENSION_PLUGIN_NOT_ENABLED',
$link), 'error');
return;
}
$clients = array(JPATH_SITE, JPATH_ADMINISTRATOR);
$extensionGroupFolders = array('components',
'modules', 'plugins', 'templates',
'language', 'manifests');
$pathsToSearch = array();
// Identifies which folders to search for manifest files.
foreach ($clients as $clientPath)
{
foreach ($extensionGroupFolders as $extensionGroupFolderName)
{
// Components, modules, plugins, templates, languages and manifest
(files, libraries, etc)
if ($extensionGroupFolderName != 'plugins')
{
foreach (glob($clientPath . '/' . $extensionGroupFolderName
. '/*', GLOB_NOSORT | GLOB_ONLYDIR) as $extensionFolderPath)
{
$pathsToSearch[] = $extensionFolderPath;
}
}
// Plugins (another directory level is needed)
else
{
foreach (glob($clientPath . '/' . $extensionGroupFolderName
. '/*', GLOB_NOSORT | GLOB_ONLYDIR) as $pluginGroupFolderPath)
{
foreach (glob($pluginGroupFolderPath . '/*', GLOB_NOSORT |
GLOB_ONLYDIR) as $extensionFolderPath)
{
$pathsToSearch[] = $extensionFolderPath;
}
}
}
}
}
// Gets Joomla core update sites Ids.
$joomlaUpdateSitesIds = implode(', ',
$this->getJoomlaUpdateSitesIds(0));
// Delete from all tables (except joomla core update sites).
$query = $db->getQuery(true)
->delete($db->quoteName('#__update_sites'))
->where($db->quoteName('update_site_id') . ' NOT IN
(' . $joomlaUpdateSitesIds . ')');
$db->setQuery($query);
$db->execute();
$query = $db->getQuery(true)
->delete($db->quoteName('#__update_sites_extensions'))
->where($db->quoteName('update_site_id') . ' NOT IN
(' . $joomlaUpdateSitesIds . ')');
$db->setQuery($query);
$db->execute();
$query = $db->getQuery(true)
->delete($db->quoteName('#__updates'))
->where($db->quoteName('update_site_id') . ' NOT IN
(' . $joomlaUpdateSitesIds . ')');
$db->setQuery($query);
$db->execute();
$count = 0;
// Gets Joomla core extension Ids.
$joomlaCoreExtensionIds = implode(', ',
$this->getJoomlaUpdateSitesIds(1));
// Search for updateservers in manifest files inside the folders to
search.
foreach ($pathsToSearch as $extensionFolderPath)
{
$tmpInstaller = new JInstaller;
$tmpInstaller->setPath('source', $extensionFolderPath);
// Main folder manifests (higher priority)
$parentXmlfiles =
JFolder::files($tmpInstaller->getPath('source'),
'.xml$', false, true);
// Search for children manifests (lower priority)
$allXmlFiles =
JFolder::files($tmpInstaller->getPath('source'),
'.xml$', 1, true);
// Create an unique array of files ordered by priority
$xmlfiles = array_unique(array_merge($parentXmlfiles, $allXmlFiles));
if (!empty($xmlfiles))
{
foreach ($xmlfiles as $file)
{
// Is it a valid Joomla installation manifest file?
$manifest = $tmpInstaller->isManifest($file);
if (!is_null($manifest))
{
// Search if the extension exists in the extensions table. Excluding
joomla core extensions (id < 10000) and discovered extensions.
$query = $db->getQuery(true)
->select($db->quoteName('extension_id'))
->from($db->quoteName('#__extensions'))
->where('('
. $db->quoteName('name') . ' = ' .
$db->quote($manifest->name)
. ' OR ' . $db->quoteName('name') . ' =
' . $db->quote($manifest->packagename)
. ')' )
->where($db->quoteName('type') . ' = ' .
$db->quote($manifest['type']))
->where($db->quoteName('extension_id') . ' NOT
IN (' . $joomlaCoreExtensionIds . ')')
->where($db->quoteName('state') . ' !=
-1');
$db->setQuery($query);
$eid = (int) $db->loadResult();
if ($eid && $manifest->updateservers)
{
// Set the manifest object and path
$tmpInstaller->manifest = $manifest;
$tmpInstaller->setPath('manifest', $file);
// Load the extension plugin (if not loaded yet).
JPluginHelper::importPlugin('extension',
'joomla');
// Fire the onExtensionAfterUpdate
JEventDispatcher::getInstance()->trigger('onExtensionAfterUpdate',
array('installer' => $tmpInstaller, 'eid' =>
$eid));
$count++;
}
}
}
}
}
if ($count > 0)
{
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_SUCCESS'),
'message');
}
else
{
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_MESSAGE'),
'message');
}
}
/**
* Fetch the Joomla update sites ids.
*
* @param integer $column Column to return. 0 for update site ids, 1
for extension ids.
*
* @return array Array with joomla core update site ids.
*
* @since 3.6.0
*/
protected function getJoomlaUpdateSitesIds($column = 0)
{
$db = JFactory::getDbo();
// Fetch the Joomla core update sites ids and their extension ids. We
search for all except the core joomla extension with update sites.
$query = $db->getQuery(true)
->select($db->quoteName(array('use.update_site_id',
'e.extension_id')))
->from($db->quoteName('#__update_sites_extensions',
'use'))
->join('LEFT',
$db->quoteName('#__update_sites', 'us') . ' ON
' . $db->qn('us.update_site_id') . ' = ' .
$db->qn('use.update_site_id'))
->join('LEFT', $db->quoteName('#__extensions',
'e') . ' ON ' . $db->qn('e.extension_id')
. ' = ' . $db->qn('use.extension_id'))
->where('('
. '(' . $db->qn('e.type') . ' = ' .
$db->quote('file') . ' AND ' .
$db->qn('e.element') . ' = ' .
$db->quote('joomla') . ')'
. ' OR (' . $db->qn('e.type') . ' = '
. $db->quote('package') . ' AND ' .
$db->qn('e.element') . ' = ' .
$db->quote('pkg_en-GB') . ')'
. ' OR (' . $db->qn('e.type') . ' = '
. $db->quote('component') . ' AND ' .
$db->qn('e.element') . ' = ' .
$db->quote('com_joomlaupdate') . ')'
. ')'
);
$db->setQuery($query);
return $db->loadColumn($column);
}
/**
* Method to get the database query
*
* @return JDatabaseQuery The database query
*
* @since 3.4
*/
protected function getListQuery()
{
$query = JFactory::getDbo()->getQuery(true)
->select(
array(
's.update_site_id',
's.name AS update_site_name',
's.type AS update_site_type',
's.location',
's.enabled',
'e.extension_id',
'e.name',
'e.type',
'e.element',
'e.folder',
'e.client_id',
'e.state',
'e.manifest_cache',
)
)
->from('#__update_sites AS s')
->innerJoin('#__update_sites_extensions AS se ON
(se.update_site_id = s.update_site_id)')
->innerJoin('#__extensions AS e ON (e.extension_id =
se.extension_id)')
->where('state = 0');
// Process select filters.
$enabled = $this->getState('filter.enabled');
$type = $this->getState('filter.type');
$clientId = $this->getState('filter.client_id');
$folder = $this->getState('filter.folder');
if ($enabled != '')
{
$query->where('s.enabled = ' . (int) $enabled);
}
if ($type)
{
$query->where('e.type = ' .
$this->_db->quote($type));
}
if ($clientId != '')
{
$query->where('e.client_id = ' . (int) $clientId);
}
if ($folder != '' && in_array($type,
array('plugin', 'library', '')))
{
$query->where('e.folder = ' .
$this->_db->quote($folder == '*' ? '' :
$folder));
}
// Process search filter (update site id).
$search = $this->getState('filter.search');
if (!empty($search) && stripos($search, 'id:') === 0)
{
$query->where('s.update_site_id = ' . (int) substr($search,
3));
}
// Note: The search for name, ordering and pagination are processed by
the parent InstallerModel class (in extension.php).
return $query;
}
}
warnings.php000064400000010023151160606600007102 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Installer Warnings Model
*
* @since 1.6
*/
class InstallerModelWarnings extends JModelList
{
/**
* Extension Type
* @var string
*/
public $type = 'warnings';
/**
* Return the byte value of a particular string.
*
* @param string $val String optionally with G, M or K suffix
*
* @return integer size in bytes
*
* @since 1.6
*/
public function return_bytes($val)
{
if (empty($val))
{
return 0;
}
$val = trim($val);
preg_match('#([0-9]+)[\s]*([a-z]+)#i', $val, $matches);
$last = '';
if (isset($matches[2]))
{
$last = $matches[2];
}
if (isset($matches[1]))
{
$val = (int) $matches[1];
}
switch (strtolower($last))
{
case 'g':
case 'gb':
$val *= 1024;
case 'm':
case 'mb':
$val *= 1024;
case 'k':
case 'kb':
$val *= 1024;
}
return (int) $val;
}
/**
* Load the data.
*
* @return array Messages
*
* @since 1.6
*/
public function getItems()
{
static $messages;
if ($messages)
{
return $messages;
}
$messages = array();
$file_uploads = ini_get('file_uploads');
if (!$file_uploads)
{
$messages[] = array('message' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_FILEUPLOADSDISABLED'),
'description' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_FILEUPLOADISDISABLEDDESC'));
}
$upload_dir = ini_get('upload_tmp_dir');
if (!$upload_dir)
{
$messages[] = array('message' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSET'),
'description' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSETDESC'));
}
else
{
if (!is_writeable($upload_dir))
{
$messages[] = array('message' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTWRITEABLE'),
'description' =>
JText::sprintf('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTWRITEABLEDESC',
$upload_dir));
}
}
$config = JFactory::getConfig();
$tmp_path = $config->get('tmp_path');
if (!$tmp_path)
{
$messages[] = array('message' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTSET'),
'description' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTSETDESC'));
}
else
{
if (!is_writeable($tmp_path))
{
$messages[] = array('message' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTWRITEABLE'),
'description' =>
JText::sprintf('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTWRITEABLEDESC',
$tmp_path));
}
}
$memory_limit =
$this->return_bytes(ini_get('memory_limit'));
if ($memory_limit < (8 * 1024 * 1024) && $memory_limit != -1)
{
// 8MB
$messages[] = array('message' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_LOWMEMORYWARN'),
'description' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_LOWMEMORYDESC'));
}
elseif ($memory_limit < (16 * 1024 * 1024) && $memory_limit !=
-1)
{
// 16MB
$messages[] = array('message' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_MEDMEMORYWARN'),
'description' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_MEDMEMORYDESC'));
}
$post_max_size =
$this->return_bytes(ini_get('post_max_size'));
$upload_max_filesize =
$this->return_bytes(ini_get('upload_max_filesize'));
if ($post_max_size < $upload_max_filesize)
{
$messages[] = array('message' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_UPLOADBIGGERTHANPOST'),
'description' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_UPLOADBIGGERTHANPOSTDESC'));
}
if ($post_max_size < (8 * 1024 * 1024)) // 8MB
{
$messages[] = array('message' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLPOSTSIZE'),
'description' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLPOSTSIZEDESC'));
}
if ($upload_max_filesize < (8 * 1024 * 1024)) // 8MB
{
$messages[] = array('message' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLUPLOADSIZE'),
'description' =>
JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLUPLOADSIZEDESC'));
}
return $messages;
}
}
checkin.php000064400000011650151161046000006656 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_checkin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Checkin Model
*
* @since 1.6
*/
class CheckinModelCheckin extends JModelList
{
/**
* Count of the total items checked out
*
* @var integer
*/
protected $total;
/**
* Unused class variable
*
* @var object
* @deprecated 4.0
*/
protected $tables;
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 3.5
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'table',
'count',
);
}
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.6
*/
protected function populateState($ordering = 'table', $direction
= 'asc')
{
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search'));
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Checks in requested tables
*
* @param array $ids An array of table names. Optional.
*
* @return integer Checked in item count
*
* @since 1.6
*/
public function checkin($ids = array())
{
$db = $this->getDbo();
$nullDate = $db->getNullDate();
if (!is_array($ids))
{
return 0;
}
// This int will hold the checked item count.
$results = 0;
$dispatcher = \JEventDispatcher::getInstance();
foreach ($ids as $tn)
{
// Make sure we get the right tables based on prefix.
if (stripos($tn,
JFactory::getApplication()->get('dbprefix')) !== 0)
{
continue;
}
$fields = $db->getTableColumns($tn);
if (!(isset($fields['checked_out']) &&
isset($fields['checked_out_time'])))
{
continue;
}
$query = $db->getQuery(true)
->update($db->quoteName($tn))
->set($db->quoteName('checked_out') . ' =
DEFAULT')
->set($db->quoteName('checked_out_time') . ' =
' . $db->quote($nullDate))
->where($db->quoteName('checked_out') . ' >
0');
$db->setQuery($query);
if ($db->execute())
{
$results = $results + $db->getAffectedRows();
$dispatcher->trigger('onAfterCheckin', array($tn));
}
}
return $results;
}
/**
* Get total of tables
*
* @return integer Total to check-in tables
*
* @since 1.6
*/
public function getTotal()
{
if (!isset($this->total))
{
$this->getItems();
}
return $this->total;
}
/**
* Get tables
*
* @return array Checked in table names as keys and checked in item
count as values.
*
* @since 1.6
*/
public function getItems()
{
if (!isset($this->items))
{
$db = $this->getDbo();
$tables = $db->getTableList();
// This array will hold table name as key and checked in item count as
value.
$results = array();
foreach ($tables as $i => $tn)
{
// Make sure we get the right tables based on prefix.
if (stripos($tn,
JFactory::getApplication()->get('dbprefix')) !== 0)
{
unset($tables[$i]);
continue;
}
if ($this->getState('filter.search') &&
stripos($tn, $this->getState('filter.search')) === false)
{
unset($tables[$i]);
continue;
}
$fields = $db->getTableColumns($tn);
if (!(isset($fields['checked_out']) &&
isset($fields['checked_out_time'])))
{
unset($tables[$i]);
continue;
}
}
foreach ($tables as $tn)
{
$query = $db->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName($tn))
->where('checked_out > 0');
$db->setQuery($query);
if ($db->execute())
{
$results[$tn] = $db->loadResult();
// Show only tables with items to checkin.
if ((int) $results[$tn] === 0)
{
unset($results[$tn]);
}
}
else
{
continue;
}
}
$this->total = count($results);
// Order items by table
if ($this->getState('list.ordering') == 'table')
{
if (strtolower($this->getState('list.direction')) ==
'asc')
{
ksort($results);
}
else
{
krsort($results);
}
}
// Order items by number of items
else
{
if (strtolower($this->getState('list.direction')) ==
'asc')
{
asort($results);
}
else
{
arsort($results);
}
}
// Pagination
$limit = (int) $this->getState('list.limit');
if ($limit !== 0)
{
$this->items = array_slice($results,
$this->getState('list.start'), $limit);
}
else
{
$this->items = $results;
}
}
return $this->items;
}
}
forms/filter_checkin.xml000064400000002033151161046000011355
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_CHECKIN_FILTER_SEARCH_LABEL"
description="COM_CHECKIN_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
noresults="COM_CHECKIN_NO_ITEMS"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="table ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="table
ASC">COM_CHECKIN_DATABASE_TABLE_ASC</option>
<option value="table
DESC">COM_CHECKIN_DATABASE_TABLE_DESC</option>
<option value="count
ASC">COM_CHECKIN_ITEMS_TO_CHECK_IN_ASC</option>
<option value="count
DESC">COM_CHECKIN_ITEMS_TO_CHECK_IN_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="5"
onchange="this.form.submit();"
/>
</fields>
</form>
tree.php000064400000001477151161227220006224 0ustar00<?php
/**
* J!Dump
* @version $Id$
* @package jdump
* @copyright Copyright (C) 2006-2011 Mathias Verraes. All rights
reserved.
* @license GNU/GPL
* @link https://github.com/mathiasverraes/jdump
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
class DumpModelTree extends JModelLegacy
{
var $_nodes = array();
function __construct()
{
$mainframe = JFactory::getApplication(); $option =
JRequest::getCmd('option');
//get the userstate
$this->_nodes = $mainframe->getUserState('dump.nodes');
if (!is_array($this->_nodes))
{
$this->_nodes = array();
}
// and clear it
$mainframe->setUserState('dump.nodes', array());
parent::__construct();
}
function & getNodes()
{
return $this->_nodes;
}
function countDumps()
{
return count( $this->_nodes ) ;
}
}
fields/languageclient.php000064400000003376151161331100011506
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* Client Language List field.
*
* @since 3.9.0
*/
class JFormFieldLanguageclient extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.9.0
*/
protected $type = 'Languageclient';
/**
* Cached form field options.
*
* @var array
* @since 3.9.0
*/
protected $cache = array();
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.9.0
*/
protected function getOptions()
{
// Try to load the data from our mini-cache.
if (!empty($this->cache))
{
return $this->cache;
}
// Get all languages of frontend and backend.
$languages = array();
$site_languages = JLanguageHelper::getKnownLanguages(JPATH_SITE);
$admin_languages =
JLanguageHelper::getKnownLanguages(JPATH_ADMINISTRATOR);
// Create a single array of them.
foreach ($site_languages as $tag => $language)
{
$languages[$tag . '0'] =
JText::sprintf('COM_LANGUAGES_VIEW_OVERRIDES_LANGUAGES_BOX_ITEM',
$language['name'], JText::_('JSITE'));
}
foreach ($admin_languages as $tag => $language)
{
$languages[$tag . '1'] =
JText::sprintf('COM_LANGUAGES_VIEW_OVERRIDES_LANGUAGES_BOX_ITEM',
$language['name'], JText::_('JADMINISTRATOR'));
}
// Sort it by language tag and by client after that.
ksort($languages);
// Add the languages to the internal cache.
$this->cache = array_merge(parent::getOptions(), $languages);
return $this->cache;
}
}
forms/filter_installed.xml000064400000004601151161331100011731
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<field
name="client_id"
type="list"
onchange="jQuery('#filter_search, select[id^=filter_],
#list_fullordering').val('');this.form.submit();"
filtermode="selector"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
</field>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_LANGUAGES_INSTALLED_FILTER_SEARCH_LABEL"
description="COM_LANGUAGES_INSTALLED_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
noresults="JGLOBAL_NO_MATCHING_RESULTS"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="name
ASC">COM_LANGUAGES_HEADING_LANGUAGE_ASC</option>
<option value="name
DESC">COM_LANGUAGES_HEADING_LANGUAGE_DESC</option>
<option value="nativeName
ASC">COM_LANGUAGES_HEADING_TITLE_NATIVE_ASC</option>
<option value="nativeName
DESC">COM_LANGUAGES_HEADING_TITLE_NATIVE_DESC</option>
<option value="language
ASC">COM_LANGUAGES_HEADING_LANG_TAG_ASC</option>
<option value="language
DESC">COM_LANGUAGES_HEADING_LANG_TAG_DESC</option>
<option value="published
ASC">COM_LANGUAGES_HEADING_DEFAULT_ASC</option>
<option value="published
DESC">COM_LANGUAGES_HEADING_DEFAULT_DESC</option>
<option value="version
ASC">COM_LANGUAGES_HEADING_VERSION_ASC</option>
<option value="version
DESC">COM_LANGUAGES_HEADING_VERSION_DESC</option>
<option value="creationDate
ASC">COM_LANGUAGES_HEADING_DATE_ASC</option>
<option value="creationDate
DESC">COM_LANGUAGES_HEADING_DATE_DESC</option>
<option value="author
ASC">COM_LANGUAGES_HEADING_AUTHOR_ASC</option>
<option value="author
DESC">COM_LANGUAGES_HEADING_AUTHOR_DESC</option>
<option value="authorEmail
ASC">COM_LANGUAGES_HEADING_AUTHOR_EMAIL_ASC</option>
<option value="authorEmail
DESC">COM_LANGUAGES_HEADING_AUTHOR_EMAIL_DESC</option>
<option value="extension_id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="extension_id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_overrides.xml000064400000001220151161331100011746
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<field
name="language_client"
type="languageclient"
onchange="this.form.submit();"
>
<option
value="">COM_LANGUAGES_OVERRIDE_SELECT_LANGUAGE</option>
</field>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="JSEARCH_FILTER"
description="COM_LANGUAGES_VIEW_OVERRIDES_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
</fields>
<fields name="list">
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/language.xml000064400000005063151161331100010173 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="lang_id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
class="readonly"
default="0"
readonly="true"
/>
<field
name="lang_code"
type="text"
label="COM_LANGUAGES_FIELD_LANG_TAG_LABEL"
description="COM_LANGUAGES_FIELD_LANG_TAG_DESC"
maxlength="7"
required="true"
size="10"
/>
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="COM_LANGUAGES_FIELD_TITLE_DESC"
maxlength="50"
required="true"
size="40"
/>
<field
name="title_native"
type="text"
label="COM_LANGUAGES_FIELD_TITLE_NATIVE_LABEL"
description="COM_LANGUAGES_FIELD_TITLE_NATIVE_DESC"
maxlength="50"
required="true"
size="40"
/>
<field
name="sef"
type="text"
label="COM_LANGUAGES_FIELD_LANG_CODE_LABEL"
description="COM_LANGUAGES_FIELD_LANG_CODE_DESC"
maxlength="50"
required="true"
size="10"
/>
<field
name="image"
type="filelist"
label="COM_LANGUAGES_FIELD_IMAGE_LABEL"
description="COM_LANGUAGES_FIELD_IMAGE_DESC"
stripext="1"
directory="media/mod_languages/images/"
hide_none="1"
hide_default="1"
filter="\.gif$"
size="10"
>
<option value="">JNONE</option>
</field>
<field
name="description"
type="textarea"
label="JGLOBAL_DESCRIPTION"
description="COM_LANGUAGES_FIELD_DESCRIPTION_DESC"
cols="80"
rows="5"
/>
<field
name="published"
type="list"
label="JSTATUS"
description="COM_LANGUAGES_FIELD_PUBLISHED_DESC"
default="1"
size="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
size="1"
/>
</fieldset>
<fieldset name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<field
name="metakey"
type="textarea"
label="JFIELD_META_KEYWORDS_LABEL"
description="JFIELD_META_KEYWORDS_DESC"
rows="3"
cols="30"
/>
<field
name="metadesc"
type="textarea"
label="JFIELD_META_DESCRIPTION_LABEL"
description="JFIELD_META_DESCRIPTION_DESC"
rows="3"
cols="30"
/>
</fieldset>
<fieldset name="site_name"
label="COM_LANGUAGES_FIELDSET_SITE_NAME_LABEL">
<field
name="sitename"
type="text"
label="COM_LANGUAGES_FIELD_SITE_NAME_LABEL"
description="COM_LANGUAGES_FIELD_SITE_NAME_DESC"
filter="string"
size="50"
/>
</fieldset>
</form>
forms/override.xml000064400000003737151161331100010235 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="key"
type="text"
label="COM_LANGUAGES_OVERRIDE_FIELD_KEY_LABEL"
description="COM_LANGUAGES_OVERRIDE_FIELD_KEY_DESC"
size="60"
required="true"
filter="LanguagesHelper::filterKey"
/>
<field
name="override"
type="textarea"
label="COM_LANGUAGES_OVERRIDE_FIELD_OVERRIDE_LABEL"
description="COM_LANGUAGES_OVERRIDE_FIELD_OVERRIDE_DESC"
cols="50"
rows="5"
filter="LanguagesHelper::filterText"
/>
<field
name="both"
type="checkbox"
label="COM_LANGUAGES_OVERRIDE_FIELD_BOTH_LABEL"
description="COM_LANGUAGES_OVERRIDE_FIELD_BOTH_DESC"
value="true"
filter="boolean"
/>
<field
name="searchstring"
type="text"
label="COM_LANGUAGES_OVERRIDE_FIELD_SEARCHSTRING_LABEL"
description="COM_LANGUAGES_OVERRIDE_FIELD_SEARCHSTRING_DESC"
size="50"
/>
<field
name="searchtype"
type="list"
label="COM_LANGUAGES_OVERRIDE_FIELD_SEARCHTYPE_LABEL"
description="COM_LANGUAGES_OVERRIDE_FIELD_SEARCHTYPE_DESC"
default="value"
>
<option
value="constant">COM_LANGUAGES_OVERRIDE_FIELD_SEARCHTYPE_CONSTANT</option>
<option
value="value">COM_LANGUAGES_OVERRIDE_FIELD_SEARCHTYPE_TEXT</option>
</field>
<field
name="language"
type="text"
label="COM_LANGUAGES_OVERRIDE_FIELD_LANGUAGE_LABEL"
description="COM_LANGUAGES_OVERRIDE_FIELD_LANGUAGE_DESC"
filter="unset"
readonly="true"
class="readonly"
size="50"
/>
<field
name="client"
type="text"
label="COM_LANGUAGES_OVERRIDE_FIELD_CLIENT_LABEL"
description="COM_LANGUAGES_OVERRIDE_FIELD_CLIENT_DESC"
filter="unset"
readonly="true"
class="readonly"
size="50"
/>
<field
name="file"
type="text"
label="COM_LANGUAGES_OVERRIDE_FIELD_FILE_LABEL"
description="COM_LANGUAGES_OVERRIDE_FIELD_FILE_DESC"
filter="unset"
readonly="true"
class="readonly"
size="80"
/>
<field
name="id"
type="hidden"
/>
</fieldset>
</form>
installed.php000064400000024610151161331100007227 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Languages Component Languages Model
*
* @since 1.6
*/
class LanguagesModelInstalled extends JModelList
{
/**
* @var object client object
* @deprecated 4.0
*/
protected $client = null;
/**
* @var object user object
*/
protected $user = null;
/**
* @var boolean|JExeption True, if FTP settings should be shown, or an
exception
*/
protected $ftp = null;
/**
* @var string option name
*/
protected $option = null;
/**
* @var array languages description
*/
protected $data = null;
/**
* @var int total number of languages
*/
protected $total = null;
/**
* @var int total number of languages installed
* @deprecated 4.0
*/
protected $langlist = null;
/**
* @var string language path
*/
protected $path = null;
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 3.5
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'name',
'nativeName',
'language',
'author',
'published',
'version',
'creationDate',
'author',
'authorEmail',
'extension_id',
'client_id',
);
}
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.6
*/
protected function populateState($ordering = 'name', $direction
= 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
// Special case for client id.
$clientId = (int) $this->getUserStateFromRequest($this->context .
'.client_id', 'client_id', 0, 'int');
$clientId = (!in_array($clientId, array (0, 1))) ? 0 : $clientId;
$this->setState('client_id', $clientId);
// Load the parameters.
$params = JComponentHelper::getParams('com_languages');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('client_id');
$id .= ':' . $this->getState('filter.search');
return parent::getStoreId($id);
}
/**
* Method to get the client object.
*
* @return object
*
* @since 1.6
*/
public function getClient()
{
return
JApplicationHelper::getClientInfo($this->getState('client_id',
0));
}
/**
* Method to get the ftp credentials.
*
* @return object
*
* @since 1.6
*/
public function getFtp()
{
if (is_null($this->ftp))
{
$this->ftp =
JClientHelper::setCredentialsFromRequest('ftp');
}
return $this->ftp;
}
/**
* Method to get the option.
*
* @return object
*
* @since 1.6
*/
public function getOption()
{
$option = $this->getState('option');
return $option;
}
/**
* Method to get Languages item data.
*
* @return array
*
* @since 1.6
*/
public function getData()
{
// Fetch language data if not fetched yet.
if (is_null($this->data))
{
$this->data = array();
$isCurrentLanguageRtl = JFactory::getLanguage()->isRtl();
$params =
JComponentHelper::getParams('com_languages');
$installedLanguages = JLanguageHelper::getInstalledLanguages(null,
true, true, null, null, null);
// Compute all the languages.
foreach ($installedLanguages as $clientId => $languages)
{
$defaultLanguage =
$params->get(JApplicationHelper::getClientInfo($clientId)->name,
'en-GB');
foreach ($languages as $lang)
{
$row = new stdClass;
$row->language = $lang->element;
$row->name = $lang->metadata['name'];
$row->nativeName =
isset($lang->metadata['nativeName']) ?
$lang->metadata['nativeName'] : '-';
$row->client_id = (int) $lang->client_id;
$row->extension_id = (int) $lang->extension_id;
$row->author = $lang->manifest['author'];
$row->creationDate = $lang->manifest['creationDate'];
$row->authorEmail = $lang->manifest['authorEmail'];
$row->version = $lang->manifest['version'];
$row->published = $defaultLanguage === $row->language ? 1 :
0;
$row->checked_out = 0;
// Fix wrongly set parentheses in RTL languages
if ($isCurrentLanguageRtl)
{
$row->name = html_entity_decode($row->name .
'‎', ENT_QUOTES, 'UTF-8');
$row->nativeName = html_entity_decode($row->nativeName .
'‎', ENT_QUOTES, 'UTF-8');
}
$this->data[] = $row;
}
}
}
$installedLanguages = array_merge($this->data);
// Process filters.
$clientId = (int) $this->getState('client_id');
$search = $this->getState('filter.search');
foreach ($installedLanguages as $key => $installedLanguage)
{
// Filter by client id.
if (in_array($clientId, array(0, 1)))
{
if ($installedLanguage->client_id !== $clientId)
{
unset($installedLanguages[$key]);
continue;
}
}
// Filter by search term.
if (!empty($search))
{
if (stripos($installedLanguage->name, $search) === false
&& stripos($installedLanguage->nativeName, $search) ===
false
&& stripos($installedLanguage->language, $search) ===
false)
{
unset($installedLanguages[$key]);
continue;
}
}
}
// Process ordering.
$listOrder = $this->getState('list.ordering',
'name');
$listDirn = $this->getState('list.direction',
'ASC');
$installedLanguages = ArrayHelper::sortObjects($installedLanguages,
$listOrder, strtolower($listDirn) === 'desc' ? -1 : 1, true,
true);
// Process pagination.
$limit = (int) $this->getState('list.limit', 25);
// Sets the total for pagination.
$this->total = count($installedLanguages);
if ($limit !== 0)
{
$start = (int) $this->getState('list.start', 0);
return array_slice($installedLanguages, $start, $limit);
}
return $installedLanguages;
}
/**
* Method to get installed languages data.
*
* @return string An SQL query.
*
* @since 1.6
*
* @deprecated 4.0
*/
protected function getLanguageList()
{
// Create a new db object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$client = $this->getState('client_id');
$type = 'language';
// Select field element from the extensions table.
$query->select($this->getState('list.select',
'a.element'))
->from('#__extensions AS a');
$type = $db->quote($type);
$query->where('(a.type = ' . $type . ')')
->where('state = 0')
->where('enabled = 1')
->where('client_id=' . (int) $client);
// For client_id = 1 do we need to check language table also?
$db->setQuery($query);
$this->langlist = $db->loadColumn();
return $this->langlist;
}
/**
* Method to get the total number of Languages items.
*
* @return integer
*
* @since 1.6
*/
public function getTotal()
{
if (is_null($this->total))
{
$this->getData();
}
return $this->total;
}
/**
* Method to set the default language.
*
* @param integer $cid Id of the language to publish.
*
* @return boolean
*
* @since 1.6
*/
public function publish($cid)
{
if ($cid)
{
$client = $this->getClient();
$params = JComponentHelper::getParams('com_languages');
$params->set($client->name, $cid);
$table = JTable::getInstance('extension');
$id = $table->find(array('element' =>
'com_languages'));
// Load.
if (!$table->load($id))
{
$this->setError($table->getError());
return false;
}
$table->params = (string) $params;
// Pre-save checks.
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Save the changes.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
}
else
{
$this->setError(JText::_('COM_LANGUAGES_ERR_NO_LANGUAGE_SELECTED'));
return false;
}
// Clean the cache of com_languages and component cache.
$this->cleanCache();
$this->cleanCache('_system', 0);
$this->cleanCache('_system', 1);
return true;
}
/**
* Method to get the folders.
*
* @return array Languages folders.
*
* @since 1.6
*/
protected function getFolders()
{
if (is_null($this->folders))
{
$path = $this->getPath();
jimport('joomla.filesystem.folder');
$this->folders = JFolder::folders($path, '.', false, false,
array('.svn', 'CVS', '.DS_Store',
'__MACOSX', 'pdf_fonts', 'overrides'));
}
return $this->folders;
}
/**
* Method to get the path.
*
* @return string The path to the languages folders.
*
* @since 1.6
*/
protected function getPath()
{
if (is_null($this->path))
{
$client = $this->getClient();
$this->path = JLanguageHelper::getLanguagePath($client->path);
}
return $this->path;
}
/**
* Method to compare two languages in order to sort them.
*
* @param object $lang1 The first language.
* @param object $lang2 The second language.
*
* @return integer
*
* @since 1.6
*
* @deprecated 4.0
*/
protected function compareLanguages($lang1, $lang2)
{
return strcmp($lang1->name, $lang2->name);
}
/**
* Method to switch the administrator language.
*
* @param string $cid The language tag.
*
* @return boolean
*
* @since 3.5
*/
public function switchAdminLanguage($cid)
{
if ($cid)
{
$client = $this->getClient();
if ($client->name == 'administrator')
{
JFactory::getApplication()->setUserState('application.lang',
$cid);
}
}
else
{
JError::raiseWarning(500,
JText::_('COM_LANGUAGES_ERR_NO_LANGUAGE_SELECTED'));
return false;
}
return true;
}
}
language.php000064400000014033151161331110007032 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Languages Component Language Model
*
* @since 1.5
*/
class LanguagesModelLanguage extends JModelAdmin
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*/
public function __construct($config = array())
{
$config = array_merge(
array(
'event_after_save' => 'onExtensionAfterSave',
'event_before_save' => 'onExtensionBeforeSave',
'events_map' => array(
'save' => 'extension'
)
), $config
);
parent::__construct($config);
}
/**
* Override to get the table.
*
* @param string $name Name of the table.
* @param string $prefix Table name prefix.
* @param array $options Array of options.
*
* @return JTable
*
* @since 1.6
*/
public function getTable($name = '', $prefix = '',
$options = array())
{
return JTable::getInstance('Language');
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication('administrator');
$params = JComponentHelper::getParams('com_languages');
// Load the User state.
$langId = $app->input->getInt('lang_id');
$this->setState('language.id', $langId);
// Load the parameters.
$this->setState('params', $params);
}
/**
* Method to get a member item.
*
* @param integer $langId The id of the member to get.
*
* @return mixed User data object on success, false on failure.
*
* @since 1.0
*/
public function getItem($langId = null)
{
$langId = (!empty($langId)) ? $langId : (int)
$this->getState('language.id');
// Get a member row instance.
$table = $this->getTable();
// Attempt to load the row.
$return = $table->load($langId);
// Check for a table object error.
if ($return === false && $table->getError())
{
$this->setError($table->getError());
return false;
}
// Set a valid accesslevel in case '0' is stored due to a bug
in the installation SQL (was fixed with PR 2714).
if ($table->access == '0')
{
$table->access = (int)
JFactory::getConfig()->get('access');
}
$properties = $table->getProperties(1);
$value = ArrayHelper::toObject($properties, 'JObject');
return $value;
}
/**
* Method to get the group form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure.
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_languages.language',
'language', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_languages.edit.language.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_languages.language', $data);
return $data;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$langId = (!empty($data['lang_id'])) ?
$data['lang_id'] : (int)
$this->getState('language.id');
$isNew = true;
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin($this->events_map['save']);
$table = $this->getTable();
$context = $this->option . '.' . $this->name;
// Load the row if saving an existing item.
if ($langId > 0)
{
$table->load($langId);
$isNew = false;
}
// Prevent white spaces, including East Asian double bytes.
$spaces = array('/\xE3\x80\x80/', ' ');
$data['lang_code'] = str_replace($spaces, '',
$data['lang_code']);
// Prevent saving an incorrect language tag
if (!preg_match('#\b([a-z]{2,3})[-]([A-Z]{2})\b#',
$data['lang_code']))
{
$this->setError(JText::_('COM_LANGUAGES_ERROR_LANG_TAG'));
return false;
}
$data['sef'] = str_replace($spaces, '',
$data['sef']);
$data['sef'] =
JApplicationHelper::stringURLSafe($data['sef']);
// Prevent saving an empty url language code
if ($data['sef'] === '')
{
$this->setError(JText::_('COM_LANGUAGES_ERROR_SEF'));
return false;
}
// Bind the data.
if (!$table->bind($data))
{
$this->setError($table->getError());
return false;
}
// Check the data.
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Trigger the before save event.
$result = $dispatcher->trigger($this->event_before_save,
array($context, &$table, $isNew));
// Check the event responses.
if (in_array(false, $result, true))
{
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Trigger the after save event.
$dispatcher->trigger($this->event_after_save, array($context,
&$table, $isNew));
$this->setState('language.id', $table->lang_id);
// Clean the cache.
$this->cleanCache();
return true;
}
/**
* Custom clean cache method.
*
* @param string $group Optional cache group name.
* @param integer $clientId Application client id.
*
* @return void
*
* @since 1.6
*/
protected function cleanCache($group = null, $clientId = 0)
{
parent::cleanCache('_system');
parent::cleanCache('com_languages');
}
}
override.php000064400000014063151161331110007071 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Languages Override Model
*
* @since 2.5
*/
class LanguagesModelOverride extends JModelAdmin
{
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure.
*
* @since 2.5
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_languages.override',
'override', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
$client = $this->getState('filter.client',
'site');
$language = $this->getState('filter.language',
'en-GB');
$langName = JLanguage::getInstance($language)->getName();
if (!$langName)
{
// If a language only exists in frontend, its metadata cannot be
// loaded in backend at the moment, so fall back to the language tag.
$langName = $language;
}
$form->setValue('client', null,
JText::_('COM_LANGUAGES_VIEW_OVERRIDE_CLIENT_' .
strtoupper($client)));
$form->setValue('language', null,
JText::sprintf('COM_LANGUAGES_VIEW_OVERRIDE_LANGUAGE', $langName,
$language));
$form->setValue('file', null,
JPath::clean(constant('JPATH_' . strtoupper($client)) .
'/language/overrides/' . $language . '.override.ini'));
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 2.5
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_languages.edit.override.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_languages.override', $data);
return $data;
}
/**
* Method to get a single record.
*
* @param string $pk The key name.
*
* @return mixed Object on success, false otherwise.
*
* @since 2.5
*/
public function getItem($pk = null)
{
$input = JFactory::getApplication()->input;
$pk = !empty($pk) ? $pk : $input->get('id');
$fileName = constant('JPATH_' .
strtoupper($this->getState('filter.client')))
. '/language/overrides/' .
$this->getState('filter.language', 'en-GB') .
'.override.ini';
$strings = JLanguageHelper::parseIniFile($fileName);
$result = new stdClass;
$result->key = '';
$result->override = '';
if (isset($strings[$pk]))
{
$result->key = $pk;
$result->override = $strings[$pk];
}
$oppositeFileName = constant('JPATH_' .
strtoupper($this->getState('filter.client') ==
'site' ? 'administrator' : 'site'))
. '/language/overrides/' .
$this->getState('filter.language', 'en-GB') .
'.override.ini';
$oppositeStrings = JLanguageHelper::parseIniFile($oppositeFileName);
$result->both = isset($oppositeStrings[$pk]) &&
($oppositeStrings[$pk] == $strings[$pk]);
return $result;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
* @param boolean $oppositeClient Indicates whether the override
should not be created for the current client.
*
* @return boolean True on success, false otherwise.
*
* @since 2.5
*/
public function save($data, $oppositeClient = false)
{
jimport('joomla.filesystem.file');
$app = JFactory::getApplication();
$client =
$app->getUserState('com_languages.overrides.filter.client',
0);
$language =
$app->getUserState('com_languages.overrides.filter.language',
'en-GB');
// If the override should be created for both.
if ($oppositeClient)
{
$client = 1 - $client;
}
// Return false if the constant is a reserved word, i.e. YES, NO, NULL,
FALSE, ON, OFF, NONE, TRUE
$blacklist = array('YES', 'NO', 'NULL',
'FALSE', 'ON', 'OFF', 'NONE',
'TRUE');
if (in_array($data['key'], $blacklist))
{
$this->setError(JText::_('COM_LANGUAGES_OVERRIDE_ERROR_RESERVED_WORDS'));
return false;
}
$client = $client ? 'administrator' : 'site';
// Parse the override.ini file in oder to get the keys and strings.
$fileName = constant('JPATH_' . strtoupper($client)) .
'/language/overrides/' . $language . '.override.ini';
$strings = JLanguageHelper::parseIniFile($fileName);
if (isset($strings[$data['id']]))
{
// If an existent string was edited check whether
// the name of the constant is still the same.
if ($data['key'] == $data['id'])
{
// If yes, simply override it.
$strings[$data['key']] = $data['override'];
}
else
{
// If no, delete the old string and prepend the new one.
unset($strings[$data['id']]);
$strings = array($data['key'] =>
$data['override']) + $strings;
}
}
else
{
// If it is a new override simply prepend it.
$strings = array($data['key'] =>
$data['override']) + $strings;
}
// Write override.ini file with the strings.
if (JLanguageHelper::saveToIniFile($fileName, $strings) === false)
{
return false;
}
// If the override should be stored for both clients save
// it also for the other one and prevent endless recursion.
if (isset($data['both']) && $data['both']
&& !$oppositeClient)
{
return $this->save($data, true);
}
return true;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 2.5
*/
protected function populateState()
{
$app = JFactory::getApplication();
$client =
$app->getUserStateFromRequest('com_languages.overrides.filter.client',
'filter_client', 0, 'int') ? 'administrator'
: 'site';
$this->setState('filter.client', $client);
$language =
$app->getUserStateFromRequest('com_languages.overrides.filter.language',
'filter_language', 'en-GB', 'cmd');
$this->setState('filter.language', $language);
}
}
overrides.php000064400000014733151161331110007260 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Languages Overrides Model
*
* @since 2.5
*/
class LanguagesModelOverrides extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 2.5
*/
public function __construct($config = array())
{
parent::__construct($config);
$this->filter_fields = array('key', 'text');
}
/**
* Retrieves the overrides data
*
* @param boolean $all True if all overrides shall be returned without
considering pagination, defaults to false
*
* @return array Array of objects containing the overrides of the
override.ini file
*
* @since 2.5
*/
public function getOverrides($all = false)
{
// Get a storage key.
$store = $this->getStoreId();
// Try to load the data from internal storage.
if (!empty($this->cache[$store]))
{
return $this->cache[$store];
}
$client = strtoupper($this->getState('filter.client'));
// Parse the override.ini file in order to get the keys and strings.
$fileName = constant('JPATH_' . $client) .
'/language/overrides/' .
$this->getState('filter.language') .
'.override.ini';
$strings = JLanguageHelper::parseIniFile($fileName);
// Delete the override.ini file if empty.
if (file_exists($fileName) && $strings === array())
{
JFile::delete($fileName);
}
// Filter the loaded strings according to the search box.
$search = $this->getState('filter.search');
if ($search != '')
{
$search = preg_quote($search, '~');
$matchvals = preg_grep('~' . $search . '~i',
$strings);
$matchkeys = array_intersect_key($strings,
array_flip(preg_grep('~' . $search . '~i',
array_keys($strings))));
$strings = array_merge($matchvals, $matchkeys);
}
// Consider the ordering
if ($this->getState('list.ordering') == 'text')
{
if (strtoupper($this->getState('list.direction')) ==
'DESC')
{
arsort($strings);
}
else
{
asort($strings);
}
}
else
{
if (strtoupper($this->getState('list.direction')) ==
'DESC')
{
krsort($strings);
}
else
{
ksort($strings);
}
}
// Consider the pagination.
if (!$all && $this->getState('list.limit')
&& $this->getTotal() >
$this->getState('list.limit'))
{
$strings = array_slice($strings, $this->getStart(),
$this->getState('list.limit'), true);
}
// Add the items to the internal cache.
$this->cache[$store] = $strings;
return $this->cache[$store];
}
/**
* Method to get the total number of overrides.
*
* @return integer The total number of overrides.
*
* @since 2.5
*/
public function getTotal()
{
// Get a storage key.
$store = $this->getStoreId('getTotal');
// Try to load the data from internal storage
if (!empty($this->cache[$store]))
{
return $this->cache[$store];
}
// Add the total to the internal cache.
$this->cache[$store] = count($this->getOverrides(true));
return $this->cache[$store];
}
/**
* 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 2.5
*/
protected function populateState($ordering = 'key', $direction =
'asc')
{
// We call populate state first so that we can then set the filter.client
and filter.language properties in afterwards
parent::populateState($ordering, $direction);
$app = JFactory::getApplication();
$language_client =
$this->getUserStateFromRequest('com_languages.overrides.language_client',
'language_client', '', 'cmd');
$client = substr($language_client, -1);
$language = substr($language_client, 0, -1);
// Sets the search filter.
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$this->setState('language_client', $language . $client);
$this->setState('filter.client', $client ?
'administrator' : 'site');
$this->setState('filter.language', $language);
// Add the 'language_client' value to the session to display a
message if none selected
$app->setUserState('com_languages.overrides.language_client',
$language . $client);
// Add filters to the session because they won't be stored there by
'getUserStateFromRequest' if they aren't in the current
request.
$app->setUserState('com_languages.overrides.filter.client',
$client);
$app->setUserState('com_languages.overrides.filter.language',
$language);
}
/**
* Method to delete one or more overrides.
*
* @param array $cids Array of keys to delete.
*
* @return integer Number of successfully deleted overrides, boolean
false if an error occurred.
*
* @since 2.5
*/
public function delete($cids)
{
// Check permissions first.
if (!JFactory::getUser()->authorise('core.delete',
'com_languages'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
return false;
}
jimport('joomla.filesystem.file');
$filterclient =
JFactory::getApplication()->getUserState('com_languages.overrides.filter.client');
$client = $filterclient == 0 ? 'SITE' :
'ADMINISTRATOR';
// Parse the override.ini file in oder to get the keys and strings.
$fileName = constant('JPATH_' . $client) .
'/language/overrides/' .
$this->getState('filter.language') .
'.override.ini';
$strings = JLanguageHelper::parseIniFile($fileName);
// Unset strings that shall be deleted
foreach ($cids as $key)
{
if (isset($strings[$key]))
{
unset($strings[$key]);
}
}
// Write override.ini file with the strings.
if (JLanguageHelper::saveToIniFile($fileName, $strings) === false)
{
return false;
}
$this->cleanCache();
return count($cids);
}
/**
* Removes all of the cached strings from the table.
*
* @return boolean result of operation
*
* @since 3.4.2
*/
public function purge()
{
$db = JFactory::getDbo();
// Note: TRUNCATE is a DDL operation
// This may or may not mean depending on your database
try
{
$db->truncateTable('#__overrider');
}
catch (RuntimeException $e)
{
return $e;
}
JFactory::getApplication()->enqueueMessage(JText::_('COM_LANGUAGES_VIEW_OVERRIDES_PURGE_SUCCESS'));
}
}
strings.php000064400000010547151161331110006746 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Languages Strings Model
*
* @since 2.5
*/
class LanguagesModelStrings extends JModelLegacy
{
/**
* Method for refreshing the cache in the database with the known language
strings.
*
* @return boolean True on success, Exception object otherwise.
*
* @since 2.5
*/
public function refresh()
{
JLoader::register('LanguagesHelper', JPATH_ADMINISTRATOR .
'/components/com_languages/helpers/languages.php');
$app = JFactory::getApplication();
$app->setUserState('com_languages.overrides.cachedtime',
null);
// Empty the database cache first.
try
{
$this->_db->setQuery('TRUNCATE TABLE ' .
$this->_db->quoteName('#__overrider'));
$this->_db->execute();
}
catch (RuntimeException $e)
{
return $e;
}
// Create the insert query.
$query = $this->_db->getQuery(true)
->insert($this->_db->quoteName('#__overrider'))
->columns('constant, string, file');
// Initialize some variables.
$client =
$app->getUserState('com_languages.overrides.filter.client',
'site') ? 'administrator' : 'site';
$language =
$app->getUserState('com_languages.overrides.filter.language',
'en-GB');
$base = constant('JPATH_' . strtoupper($client));
$path = $base . '/language/' . $language;
$files = array();
// Parse common language directory.
jimport('joomla.filesystem.folder');
if (is_dir($path))
{
$files = JFolder::files($path, $language . '.*ini$', false,
true);
}
// Parse language directories of components.
$files = array_merge($files, JFolder::files($base .
'/components', $language . '.*ini$', 3, true));
// Parse language directories of modules.
$files = array_merge($files, JFolder::files($base . '/modules',
$language . '.*ini$', 3, true));
// Parse language directories of templates.
$files = array_merge($files, JFolder::files($base .
'/templates', $language . '.*ini$', 3, true));
// Parse language directories of plugins.
$files = array_merge($files, JFolder::files(JPATH_PLUGINS, $language .
'.*ini$', 4, true));
// Parse all found ini files and add the strings to the database cache.
foreach ($files as $file)
{
$strings = LanguagesHelper::parseFile($file);
if ($strings && count($strings))
{
$query->clear('values');
foreach ($strings as $key => $string)
{
$query->values($this->_db->quote($key) . ',' .
$this->_db->quote($string) . ',' .
$this->_db->quote(JPath::clean($file)));
}
try
{
$this->_db->setQuery($query);
$this->_db->execute();
}
catch (RuntimeException $e)
{
return $e;
}
}
}
// Update the cached time.
$app->setUserState('com_languages.overrides.cachedtime.' .
$client . '.' . $language, time());
return true;
}
/**
* Method for searching language strings.
*
* @return array Array of results on success, Exception object
otherwise.
*
* @since 2.5
*/
public function search()
{
$results = array();
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
$searchTerm = $input->getString('searchstring');
$limitstart = $input->getInt('more');
try
{
$searchstring = $this->_db->quote('%' .
$filter->clean($searchTerm, 'TRIM') . '%');
// Create the search query.
$query = $this->_db->getQuery(true)
->select('constant, string, file')
->from($this->_db->quoteName('#__overrider'));
if ($input->get('searchtype') == 'constant')
{
$query->where('constant LIKE ' . $searchstring);
}
else
{
$query->where('string LIKE ' . $searchstring);
}
// Consider the limitstart according to the 'more' parameter
and load the results.
$this->_db->setQuery($query, $limitstart, 10);
$results['results'] = $this->_db->loadObjectList();
// Check whether there are more results than already loaded.
$query->clear('select')->clear('limit')
->select('COUNT(id)');
$this->_db->setQuery($query);
if ($this->_db->loadResult() > $limitstart + 10)
{
// If this is set a 'More Results' link will be displayed in
the view.
$results['more'] = $limitstart + 10;
}
}
catch (RuntimeException $e)
{
return $e;
}
return $results;
}
}
banner.php000064400000026277151161332430006537 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Banner model.
*
* @since 1.6
*/
class BannersModelBanner extends JModelAdmin
{
/**
* The prefix to use with controller messages.
*
* @var string
* @since 1.6
*/
protected $text_prefix = 'COM_BANNERS_BANNER';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_banners.banner';
/**
* Batch copy/move command. If set to false, the batch copy/move command
is not supported
*
* @var string
*/
protected $batch_copymove = 'category_id';
/**
* Allowed batch commands
*
* @var array
*/
protected $batch_commands = array(
'client_id' => 'batchClient',
'language_id' => 'batchLanguage'
);
/**
* Batch client changes for a group of banners.
*
* @param string $value The new value matching a client.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 2.5
*/
protected function batchClient($value, $pks, $contexts)
{
// Set the variables
$user = JFactory::getUser();
/** @var BannersTableBanner $table */
$table = $this->getTable();
foreach ($pks as $pk)
{
if (!$user->authorise('core.edit', $contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
$table->reset();
$table->load($pk);
$table->cid = (int) $value;
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (empty($record->id) || $record->state != -2)
{
return false;
}
if (!empty($record->catid))
{
return JFactory::getUser()->authorise('core.delete',
'com_banners.category.' . (int) $record->catid);
}
return parent::canDelete($record);
}
/**
* A method to preprocess generating a new title in order to allow tables
with alternative names
* for alias and title to use the batch move and copy methods
*
* @param integer $categoryId The target category id
* @param JTable $table The JTable within which move or copy is
taking place
*
* @return void
*
* @since 3.8.12
*/
public function generateTitle($categoryId, $table)
{
// Alter the title & alias
$data = $this->generateNewTitle($categoryId, $table->alias,
$table->name);
$table->name = $data['0'];
$table->alias = $data['1'];
}
/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
// Check against the category.
if (!empty($record->catid))
{
return JFactory::getUser()->authorise('core.edit.state',
'com_banners.category.' . (int) $record->catid);
}
// Default to component settings if category not known.
return parent::canEditState($record);
}
/**
* Returns a JTable object, always creating it.
*
* @param string $type The table type to instantiate. [optional]
* @param string $prefix A prefix for the table class name. [optional]
* @param array $config Configuration array for model. [optional]
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Banner', $prefix =
'BannersTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form. [optional]
* @param boolean $loadData True if the form is to load its own data
(default case), false if not. [optional]
*
* @return JForm|boolean A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_banners.banner',
'banner', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Determine correct permissions to check.
if ($this->getState('banner.id'))
{
// Existing record. Can only edit in selected categories.
$form->setFieldAttribute('catid', 'action',
'core.edit');
}
else
{
// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action',
'core.create');
}
// Modify the form based on access controls.
if (!$this->canEditState((object) $data))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('publish_up',
'disabled', 'true');
$form->setFieldAttribute('publish_down',
'disabled', 'true');
$form->setFieldAttribute('state', 'disabled',
'true');
$form->setFieldAttribute('sticky', 'disabled',
'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('publish_up', 'filter',
'unset');
$form->setFieldAttribute('publish_down',
'filter', 'unset');
$form->setFieldAttribute('state', 'filter',
'unset');
$form->setFieldAttribute('sticky', 'filter',
'unset');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$app = JFactory::getApplication();
$data = $app->getUserState('com_banners.edit.banner.data',
array());
if (empty($data))
{
$data = $this->getItem();
// Prime some default values.
if ($this->getState('banner.id') == 0)
{
$filters = (array)
$app->getUserState('com_banners.banners.filter');
$filterCatId = isset($filters['category_id']) ?
$filters['category_id'] : null;
$data->set('catid',
$app->input->getInt('catid', $filterCatId));
}
}
$this->preprocessData('com_banners.banner', $data);
return $data;
}
/**
* Method to stick records.
*
* @param array $pks The ids of the items to publish.
* @param integer $value The value of the published state
*
* @return boolean True on success.
*
* @since 1.6
*/
public function stick(&$pks, $value = 1)
{
/** @var BannersTableBanner $table */
$table = $this->getTable();
$pks = (array) $pks;
// Access checks.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
if (!$this->canEditState($table))
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
}
}
// Attempt to change the state of the records.
if (!$table->stick($pks, $value, JFactory::getUser()->id))
{
$this->setError($table->getError());
return false;
}
return true;
}
/**
* A protected method to get a set of ordering conditions.
*
* @param JTable $table A record object.
*
* @return array An array of conditions to add to add to ordering
queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
return array(
'catid = ' . (int) $table->catid,
'state >= 0'
);
}
/**
* Prepare and sanitise the table prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (empty($table->id))
{
// Set the values
$table->created = $date->toSql();
$table->created_by = $user->id;
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from('#__banners');
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
// Set the values
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
// Increment the content version number.
$table->version++;
}
/**
* Allows preprocessing of the JForm object.
*
* @param JForm $form The form object
* @param array $data The data to be merged into the form object
* @param string $group The plugin group to be executed
*
* @return void
*
* @since 3.6.1
*/
protected function preprocessForm(JForm $form, $data, $group =
'content')
{
if ($this->canCreateCategory())
{
$form->setFieldAttribute('catid', 'allowAdd',
'true');
// Add a prefix for categories created on the fly.
$form->setFieldAttribute('catid', 'customPrefix',
'#new#');
}
parent::preprocessForm($form, $data, $group);
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR .
'/components/com_categories/helpers/categories.php');
// Create new category, if needed.
$createCategory = true;
// If category ID is provided, check if it's valid.
if (is_numeric($data['catid']) &&
$data['catid'])
{
$createCategory =
!CategoriesHelper::validateCategoryId($data['catid'],
'com_banners');
}
// Save New Category
if ($createCategory && $this->canCreateCategory())
{
$table = array();
// Remove #new# prefix, if exists.
$table['title'] = strpos($data['catid'],
'#new#') === 0 ? substr($data['catid'], 5) :
$data['catid'];
$table['parent_id'] = 1;
$table['extension'] = 'com_banners';
$table['language'] = $data['language'];
$table['published'] = 1;
// Create new category and get catid back
$data['catid'] = CategoriesHelper::createCategory($table);
}
// Alter the name for save as copy
if ($input->get('task') == 'save2copy')
{
/** @var BannersTableBanner $origTable */
$origTable = clone $this->getTable();
$origTable->load($input->getInt('id'));
if ($data['name'] == $origTable->name)
{
list($name, $alias) =
$this->generateNewTitle($data['catid'],
$data['alias'], $data['name']);
$data['name'] = $name;
$data['alias'] = $alias;
}
else
{
if ($data['alias'] == $origTable->alias)
{
$data['alias'] = '';
}
}
$data['state'] = 0;
}
return parent::save($data);
}
/**
* Is the user allowed to create an on the fly category?
*
* @return boolean
*
* @since 3.6.1
*/
private function canCreateCategory()
{
return JFactory::getUser()->authorise('core.create',
'com_banners');
}
}
banners.php000064400000017670151161332430006717 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Methods supporting a list of banner records.
*
* @since 1.6
*/
class BannersModelBanners extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'cid', 'a.cid', 'client_name',
'name', 'a.name',
'alias', 'a.alias',
'state', 'a.state',
'ordering', 'a.ordering',
'language', 'a.language',
'catid', 'a.catid', 'category_title',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'created', 'a.created',
'impmade', 'a.impmade',
'imptotal', 'a.imptotal',
'clicks', 'a.clicks',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'sticky', 'a.sticky',
'client_id',
'category_id',
'published',
'level', 'c.level',
);
}
parent::__construct($config);
}
/**
* Method to get the maximum ordering value for each category.
*
* @return array
*
* @since 1.6
*/
public function &getCategoryOrders()
{
if (!isset($this->cache['categoryorders']))
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering) as ' .
$db->quoteName('max') . ', catid')
->select('catid')
->from('#__banners')
->group('catid');
$db->setQuery($query);
$this->cache['categoryorders'] =
$db->loadAssocList('catid', 0);
}
return $this->cache['categoryorders'];
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id AS id,'
. 'a.name AS name,'
. 'a.alias AS alias,'
. 'a.checked_out AS checked_out,'
. 'a.checked_out_time AS checked_out_time,'
. 'a.catid AS catid,'
. 'a.clicks AS clicks,'
. 'a.metakey AS metakey,'
. 'a.sticky AS sticky,'
. 'a.impmade AS impmade,'
. 'a.imptotal AS imptotal,'
. 'a.state AS state,'
. 'a.ordering AS ordering,'
. 'a.purchase_type AS purchase_type,'
. 'a.language,'
. 'a.publish_up,'
. 'a.publish_down'
)
);
$query->from($db->quoteName('#__banners',
'a'));
// Join over the language
$query->select('l.title AS language_title, l.image AS
language_image')
->join('LEFT', $db->quoteName('#__languages',
'l') . ' ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select($db->quoteName('uc.name',
'editor'))
->join('LEFT', $db->quoteName('#__users',
'uc') . ' ON uc.id = a.checked_out');
// Join over the categories.
$query->select($db->quoteName('c.title',
'category_title'))
->join('LEFT', $db->quoteName('#__categories',
'c') . ' ON c.id = a.catid');
// Join over the clients.
$query->select($db->quoteName('cl.name',
'client_name'))
->select($db->quoteName('cl.purchase_type',
'client_purchase_type'))
->join('LEFT',
$db->quoteName('#__banner_clients', 'cl') . '
ON cl.id = a.cid');
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where($db->quoteName('a.state') . ' =
' . (int) $published);
}
elseif ($published === '')
{
$query->where($db->quoteName('a.state') . ' IN (0,
1)');
}
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
$query->where($db->quoteName('a.catid') . ' =
' . (int) $categoryId);
}
// Filter by client.
$clientId = $this->getState('filter.client_id');
if (is_numeric($clientId))
{
$query->where($db->quoteName('a.cid') . ' = '
. (int) $clientId);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where($db->quoteName('a.id') . ' = '
. (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('(a.name LIKE ' . $search . ' OR
a.alias LIKE ' . $search . ')');
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$query->where($db->quoteName('a.language') . ' =
' . $db->quote($language));
}
// Filter on the level.
if ($level = $this->getState('filter.level'))
{
$query->where($db->quoteName('c.level') . ' <=
' . (int) $level);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.name');
$orderDirn = $this->state->get('list.direction',
'ASC');
if ($orderCol == 'a.ordering' || $orderCol ==
'category_title')
{
$orderCol = 'c.title ' . $orderDirn . ',
a.ordering';
}
if ($orderCol == 'client_name')
{
$orderCol = 'cl.name';
}
$query->order($db->escape($orderCol . ' ' . $orderDirn));
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' .
$this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.client_id');
$id .= ':' . $this->getState('filter.language');
$id .= ':' . $this->getState('filter.level');
return parent::getStoreId($id);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A JTable object
*
* @since 1.6
*/
public function getTable($type = 'Banner', $prefix =
'BannersTable', $config = array())
{
return JTable::getInstance($type, $prefix, $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.6
*/
protected function populateState($ordering = 'a.name',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.published',
$this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '',
'string'));
$this->setState('filter.category_id',
$this->getUserStateFromRequest($this->context .
'.filter.category_id', 'filter_category_id',
'', 'cmd'));
$this->setState('filter.client_id',
$this->getUserStateFromRequest($this->context .
'.filter.client_id', 'filter_client_id', '',
'cmd'));
$this->setState('filter.language',
$this->getUserStateFromRequest($this->context .
'.filter.language', 'filter_language', '',
'string'));
$this->setState('filter.level',
$this->getUserStateFromRequest($this->context .
'.filter.level', 'filter_level', '',
'cmd'));
// Load the parameters.
$this->setState('params',
JComponentHelper::getParams('com_banners'));
// List state information.
parent::populateState($ordering, $direction);
}
}
client.php000064400000006537151161332430006545 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Client model.
*
* @since 1.6
*/
class BannersModelClient extends JModelAdmin
{
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_banners.client';
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (empty($record->id) || $record->state != -2)
{
return false;
}
if (!empty($record->catid))
{
return JFactory::getUser()->authorise('core.delete',
'com_banners.category.' . (int) $record->catid);
}
return parent::canDelete($record);
}
/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
* Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
if (!empty($record->catid))
{
return $user->authorise('core.edit.state',
'com_banners.category.' . (int) $record->catid);
}
return $user->authorise('core.edit.state',
'com_banners');
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A JTable object
*
* @since 1.6
*/
public function getTable($type = 'Client', $prefix =
'BannersTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm|boolean A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_banners.client',
'client', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_banners.edit.client.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_banners.client', $data);
return $data;
}
/**
* Prepare and sanitise the table prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
}
clients.php000064400000017231151161332430006721 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Methods supporting a list of banner records.
*
* @since 1.6
*/
class BannersModelClients extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'name', 'a.name',
'contact', 'a.contact',
'state', 'a.state',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'purchase_type', 'a.purchase_type'
);
}
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.6
*/
protected function populateState($ordering = 'a.name',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.state',
$this->getUserStateFromRequest($this->context .
'.filter.state', 'filter_state', '',
'string'));
$this->setState('filter.purchase_type',
$this->getUserStateFromRequest($this->context .
'.filter.purchase_type', 'filter_purchase_type'));
// Load the parameters.
$this->setState('params',
JComponentHelper::getParams('com_banners'));
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.state');
$id .= ':' .
$this->getState('filter.purchase_type');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$defaultPurchase =
JComponentHelper::getParams('com_banners')->get('purchase_type',
3);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id AS id,'
. 'a.name AS name,'
. 'a.contact AS contact,'
. 'a.checked_out AS checked_out,'
. 'a.checked_out_time AS checked_out_time, '
. 'a.state AS state,'
. 'a.metakey AS metakey,'
. 'a.purchase_type as purchase_type'
)
);
$query->from($db->quoteName('#__banner_clients') . '
AS a');
// Join over the banners for counting
$query->select('COUNT(b.id) as nbanners')
->join('LEFT', '#__banners AS b ON a.id =
b.cid');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON
uc.id=a.checked_out');
// Filter by published state
$published = $this->getState('filter.state');
if (is_numeric($published))
{
$query->where('a.state = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.state IN (0, 1))');
}
$query->group('a.id, a.name, a.contact, a.checked_out,
a.checked_out_time, a.state, a.metakey, a.purchase_type, uc.name');
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('a.name LIKE ' . $search);
}
}
// Filter by purchase type
$purchaseType = $this->getState('filter.purchase_type');
if (!empty($purchaseType))
{
if ($defaultPurchase == $purchaseType)
{
$query->where('(a.purchase_type = ' . (int) $purchaseType
. ' OR a.purchase_type = -1)');
}
else
{
$query->where('a.purchase_type = ' . (int) $purchaseType);
}
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.name')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Overrides the getItems method to attach additional metrics to the list.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 3.6
*/
public function getItems()
{
// Get a storage key.
$store = $this->getStoreId('getItems');
// Try to load the data from internal storage.
if (!empty($this->cache[$store]))
{
return $this->cache[$store];
}
// Load the list items.
$items = parent::getItems();
// If empty or an error, just return.
if (empty($items))
{
return array();
}
// Getting the following metric by joins is WAY TOO SLOW.
// Faster to do three queries for very large banner trees.
// Get the clients in the list.
$db = $this->getDbo();
$clientIds = ArrayHelper::getColumn($items, 'id');
// Quote the strings.
$clientIds = implode(
',',
array_map(array($db, 'quote'), $clientIds)
);
// Get the published banners count.
$query = $db->getQuery(true)
->select('cid, COUNT(cid) AS count_published')
->from('#__banners')
->where('state = 1')
->where('cid IN (' . $clientIds . ')')
->group('cid');
$db->setQuery($query);
try
{
$countPublished = $db->loadAssocList('cid',
'count_published');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Get the unpublished banners count.
$query->clear('where')
->where('state = 0')
->where('cid IN (' . $clientIds . ')');
$db->setQuery($query);
try
{
$countUnpublished = $db->loadAssocList('cid',
'count_published');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Get the trashed banners count.
$query->clear('where')
->where('state = -2')
->where('cid IN (' . $clientIds . ')');
$db->setQuery($query);
try
{
$countTrashed = $db->loadAssocList('cid',
'count_published');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Get the archived banners count.
$query->clear('where')
->where('state = 2')
->where('cid IN (' . $clientIds . ')');
$db->setQuery($query);
try
{
$countArchived = $db->loadAssocList('cid',
'count_published');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Inject the values back into the array.
foreach ($items as $item)
{
$item->count_published = isset($countPublished[$item->id]) ?
$countPublished[$item->id] : 0;
$item->count_unpublished = isset($countUnpublished[$item->id]) ?
$countUnpublished[$item->id] : 0;
$item->count_trashed = isset($countTrashed[$item->id]) ?
$countTrashed[$item->id] : 0;
$item->count_archived = isset($countArchived[$item->id]) ?
$countArchived[$item->id] : 0;
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
return $this->cache[$store];
}
}
download.php000064400000003611151161332430007064 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Download model.
*
* @since 1.5
*/
class BannersModelDownload extends JModelForm
{
/**
* The model context
*
* @var string
*/
protected $_context = 'com_banners.tracks';
/**
* Auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$input = JFactory::getApplication()->input;
$this->setState('basename',
$input->cookie->getString(JApplicationHelper::getHash($this->_context
. '.basename'), '__SITE__'));
$this->setState('compressed',
$input->cookie->getInt(JApplicationHelper::getHash($this->_context
. '.compressed'), 1));
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm|boolean A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_banners.download',
'download', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
$data = (object) array(
'basename' => $this->getState('basename'),
'compressed' => $this->getState('compressed'),
);
$this->preprocessData('com_banners.download', $data);
return $data;
}
}
fields/bannerclient.php000064400000001546151161332430011174
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('BannersHelper', JPATH_ADMINISTRATOR .
'/components/com_banners/helpers/banners.php');
JFormHelper::loadFieldClass('list');
/**
* Bannerclient field.
*
* @since 1.6
*/
class JFormFieldBannerClient extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'BannerClient';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.6
*/
public function getOptions()
{
return array_merge(parent::getOptions(),
BannersHelper::getClientOptions());
}
}
fields/clicks.php000064400000002037151161332430007774 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Clicks field.
*
* @since 1.6
*/
class JFormFieldClicks extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Clicks';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$onclick = ' onclick="document.getElementById(\'' .
$this->id . '\').value=\'0\';"';
return '<input class="input-small"
type="text" name="' . $this->name . '"
id="' . $this->id . '" value="'
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') .
'" readonly="readonly" /> <a
class="btn" ' . $onclick . '>'
. '<span class="icon-refresh"
aria-hidden="true"></span> ' .
JText::_('COM_BANNERS_RESET_CLICKS') . '</a>';
}
}
fields/impmade.php000064400000002047151161332440010142 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Impressions field.
*
* @since 1.6
*/
class JFormFieldImpMade extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'ImpMade';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$onclick = ' onclick="document.getElementById(\'' .
$this->id . '\').value=\'0\';"';
return '<input class="input-small"
type="text" name="' . $this->name . '"
id="' . $this->id . '" value="'
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') .
'" readonly="readonly" /> <a
class="btn" ' . $onclick . '>'
. '<span class="icon-refresh"
aria-hidden="true"></span> ' .
JText::_('COM_BANNERS_RESET_IMPMADE') . '</a>';
}
}
fields/imptotal.php000064400000003063151161332440010356 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Total Impressions field.
*
* @since 1.6
*/
class JFormFieldImpTotal extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'ImpTotal';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$class = ' class="validate-numeric text_area"';
$onchange = ' onchange="document.getElementById(\'' .
$this->id .
'_unlimited\').checked=document.getElementById(\'' .
$this->id
. '\').value==\'\';"';
$onclick = ' onclick="if
(document.getElementById(\'' . $this->id .
'_unlimited\').checked) document.getElementById(\'' .
$this->id
. '\').value=\'\';"';
$value = empty($this->value) ? '' : $this->value;
$checked = empty($this->value) ? '
checked="checked"' : '';
return '<input type="text" name="' .
$this->name . '" id="' . $this->id . '"
size="9" value="' . htmlspecialchars($value,
ENT_COMPAT, 'UTF-8')
. '" ' . $class . $onchange . ' />'
. '<fieldset class="checkbox
impunlimited"><input id="' . $this->id .
'_unlimited" type="checkbox"' . $checked .
$onclick . ' />'
. '<label for="' . $this->id .
'_unlimited" id="jform-imp"
type="text">' .
JText::_('COM_BANNERS_UNLIMITED') .
'</label></fieldset>';
}
}
forms/banner.xml000064400000020526151161332440007666 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset name="details"
addfieldpath="/administrator/components/com_banners/models/fields">
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
default="0"
readonly="true"
class="readonly"
/>
<field
name="name"
type="text"
label="COM_BANNERS_FIELD_NAME_LABEL"
description="COM_BANNERS_FIELD_NAME_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="COM_BANNERS_FIELD_ALIAS_DESC"
size="40"
hint="JFIELD_ALIAS_PLACEHOLDER"
/>
<field
name="catid"
type="categoryedit"
label="JCATEGORY"
description="COM_BANNERS_FIELD_CATEGORY_DESC"
extension="com_banners"
required="true"
addfieldpath="/administrator/components/com_categories/models/fields"
default=""
/>
<field
name="state"
type="list"
label="JSTATUS"
description="COM_BANNERS_FIELD_STATE_DESC"
class="chzn-color-state"
size="1"
default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="ordering"
type="ordering"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
table="#__banners"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_BANNERS_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
<field
name="version_note"
type="text"
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
description="JGLOBAL_FIELD_VERSION_NOTE_DESC"
maxlength="255"
class="span12"
size="45"
labelclass="control-label"
/>
<field
name="description"
type="editor"
label="JGLOBAL_DESCRIPTION"
description="COM_BANNERS_FIELD_DESCRIPTION_DESC"
filter="JComponentHelper::filterText"
buttons="true"
hide="readmore,pagebreak,module,article,contact,menu"
/>
<field
name="type"
type="list"
label="COM_BANNERS_FIELD_TYPE_LABEL"
description="COM_BANNERS_FIELD_TYPE_DESC"
default="0"
>
<option
value="0">COM_BANNERS_FIELD_VALUE_IMAGE</option>
<option
value="1">COM_BANNERS_FIELD_VALUE_CUSTOM</option>
</field>
<field
name="custombannercode"
type="textarea"
label="COM_BANNERS_FIELD_CUSTOMCODE_LABEL"
description="COM_BANNERS_FIELD_CUSTOMCODE_DESC"
rows="3"
cols="30"
filter="raw"
/>
<field
name="clickurl"
type="url"
label="COM_BANNERS_FIELD_CLICKURL_LABEL"
description="COM_BANNERS_FIELD_CLICKURL_DESC"
filter="url"
validate="url"
/>
</fieldset>
<fieldset name="publish"
label="COM_BANNERS_GROUP_LABEL_PUBLISHING_DETAILS">
<field
name="created"
type="calendar"
label="COM_BANNERS_FIELD_CREATED_LABEL"
description="COM_BANNERS_FIELD_CREATED_DESC"
size="22"
translateformat="true"
showtime="true"
filter="user_utc"
/>
<field
name="created_by"
type="user"
label="COM_BANNERS_FIELD_CREATED_BY_LABEL"
description="COM_BANNERS_FIELD_CREATED_BY_DESC"
/>
<field
name="created_by_alias"
type="text"
label="COM_BANNERS_FIELD_CREATED_BY_ALIAS_LABEL"
description="COM_BANNERS_FIELD_CREATED_BY_ALIAS_DESC"
size="20"
/>
<field
name="modified"
type="calendar"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
description="COM_BANNERS_FIELD_MODIFIED_DESC"
class="readonly"
size="22"
readonly="true"
translateformat="true"
showtime="true"
filter="user_utc"
/>
<field
name="modified_by"
type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
description="COM_BANNERS_FIELD_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="version"
type="text"
label="COM_BANNERS_FIELD_VERSION_LABEL"
description="COM_BANNERS_FIELD_VERSION_DESC"
class="readonly"
size="6"
readonly="true"
filter="unset"
/>
<field
name="publish_up"
type="calendar"
label="COM_BANNERS_FIELD_PUBLISH_UP_LABEL"
description="COM_BANNERS_FIELD_PUBLISH_UP_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="publish_down"
type="calendar"
label="COM_BANNERS_FIELD_PUBLISH_DOWN_LABEL"
description="COM_BANNERS_FIELD_PUBLISH_DOWN_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
</fieldset>
<fieldset name="bannerdetails"
label="COM_BANNERS_GROUP_LABEL_BANNER_DETAILS">
<field
name="sticky"
type="radio"
label="COM_BANNERS_FIELD_STICKY_LABEL"
description="COM_BANNERS_FIELD_STICKY_DESC"
default="0"
class="btn-group btn-group-yesno"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
<fieldset name="otherparams">
<field
name="imptotal"
type="imptotal"
label="COM_BANNERS_FIELD_IMPTOTAL_LABEL"
description="COM_BANNERS_FIELD_IMPTOTAL_DESC"
default="0"
/>
<field
name="impmade"
type="impmade"
label="COM_BANNERS_FIELD_IMPMADE_LABEL"
description="COM_BANNERS_FIELD_IMPMADE_DESC"
default="0"
/>
<field
name="clicks"
type="clicks"
label="COM_BANNERS_FIELD_CLICKS_LABEL"
description="COM_BANNERS_FIELD_CLICKS_DESC"
default="0"
/>
<field
name="cid"
type="bannerclient"
label="COM_BANNERS_FIELD_CLIENT_LABEL"
description="COM_BANNERS_FIELD_CLIENT_DESC"
/>
<field
name="purchase_type"
type="list"
label="COM_BANNERS_FIELD_PURCHASETYPE_LABEL"
description="COM_BANNERS_FIELD_PURCHASETYPE_DESC"
default="0"
>
<option
value="-1">COM_BANNERS_FIELD_VALUE_USECLIENTDEFAULT</option>
<option
value="1">COM_BANNERS_FIELD_VALUE_UNLIMITED</option>
<option
value="2">COM_BANNERS_FIELD_VALUE_YEARLY</option>
<option
value="3">COM_BANNERS_FIELD_VALUE_MONTHLY</option>
<option
value="4">COM_BANNERS_FIELD_VALUE_WEEKLY</option>
<option
value="5">COM_BANNERS_FIELD_VALUE_DAILY</option>
</field>
<field
name="track_impressions"
type="list"
label="COM_BANNERS_FIELD_TRACKIMPRESSION_LABEL"
description="COM_BANNERS_FIELD_TRACKIMPRESSION_DESC"
default="0"
>
<option
value="-1">COM_BANNERS_FIELD_VALUE_USECLIENTDEFAULT</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="track_clicks"
type="list"
label="COM_BANNERS_FIELD_TRACKCLICK_LABEL"
description="COM_BANNERS_FIELD_TRACKCLICK_DESC"
default="0"
>
<option
value="-1">COM_BANNERS_FIELD_VALUE_USECLIENTDEFAULT</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
<fieldset name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<field
name="metakey"
type="textarea"
label="JFIELD_META_KEYWORDS_LABEL"
description="COM_BANNERS_FIELD_METAKEYWORDS_DESC"
rows="3"
cols="30"
/>
<field
name="own_prefix"
type="radio"
label="COM_BANNERS_FIELD_BANNEROWNPREFIX_LABEL"
description="COM_BANNERS_FIELD_BANNEROWNPREFIX_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="metakey_prefix"
type="text"
label="COM_BANNERS_FIELD_METAKEYWORDPREFIX_LABEL"
description="COM_BANNERS_FIELD_METAKEYWORDPREFIX_DESC"
/>
</fieldset>
<fields name="params"
label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS">
<fieldset name="image">
<field
name="imageurl"
type="media"
label="COM_BANNERS_FIELD_IMAGE_LABEL"
description="COM_BANNERS_FIELD_IMAGE_DESC"
directory="banners"
hide_none="1"
size="40"
/>
<field
name="width"
type="number"
label="COM_BANNERS_FIELD_WIDTH_LABEL"
description="COM_BANNERS_FIELD_WIDTH_DESC"
class="input-mini validate-numeric"
/>
<field
name="height"
type="number"
label="COM_BANNERS_FIELD_HEIGHT_LABEL"
description="COM_BANNERS_FIELD_HEIGHT_DESC"
class="input-mini validate-numeric"
/>
<field
name="alt"
type="text"
label="COM_BANNERS_FIELD_ALT_LABEL"
description="COM_BANNERS_FIELD_ALT_DESC"
/>
</fieldset>
</fields>
<fieldset name="custom">
<field
name="bannercode"
type="textarea"
label="COM_BANNERS_FIELD_CUSTOMCODE_LABEL"
description="COM_BANNERS_FIELD_CUSTOMCODE_DESC"
rows="3"
cols="30"
filter="raw"
/>
</fieldset>
</form>
forms/client.xml000064400000007033151161332440007675 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset name="details"
addfieldpath="/administrator/components/com_banners/models/fields">
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
default="0"
readonly="true"
class="readonly"
/>
<field
name="name"
type="text"
label="COM_BANNERS_FIELD_NAME_LABEL"
description="COM_BANNERS_FIELD_CLIENT_NAME_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="contact"
type="text"
label="COM_BANNERS_FIELD_CONTACT_LABEL"
description="COM_BANNERS_FIELD_CONTACT_DESC"
size="40"
required="true"
/>
<field
name="email"
type="email"
label="COM_BANNERS_FIELD_EMAIL_LABEL"
description="COM_BANNERS_FIELD_EMAIL_DESC"
size="40"
validate="email"
/>
<field
name="state"
type="list"
label="JSTATUS"
description="COM_BANNERS_FIELD_CLIENT_STATE_DESC"
class="chzn-color-state"
size="1"
default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="version_note"
type="text"
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
description="JGLOBAL_FIELD_VERSION_NOTE_DESC"
maxlength="255"
size="45"
labelclass="control-label"
/>
<field
name="purchase_type"
type="list"
label="COM_BANNERS_FIELD_PURCHASETYPE_LABEL"
description="COM_BANNERS_FIELD_PURCHASETYPE_DESC"
default="0"
>
<option value="-1">JGLOBAL_USE_GLOBAL</option>
<option
value="1">COM_BANNERS_FIELD_VALUE_UNLIMITED</option>
<option
value="2">COM_BANNERS_FIELD_VALUE_YEARLY</option>
<option
value="3">COM_BANNERS_FIELD_VALUE_MONTHLY</option>
<option
value="4">COM_BANNERS_FIELD_VALUE_WEEKLY</option>
<option
value="5">COM_BANNERS_FIELD_VALUE_DAILY</option>
</field>
<field
name="track_impressions"
type="list"
label="COM_BANNERS_FIELD_TRACKIMPRESSION_LABEL"
description="COM_BANNERS_FIELD_TRACKIMPRESSION_DESC"
default="0"
class="chzn-color"
>
<option value="-1">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="track_clicks"
type="list"
label="COM_BANNERS_FIELD_TRACKCLICK_LABEL"
description="COM_BANNERS_FIELD_TRACKCLICK_DESC"
default="0"
class="chzn-color"
>
<option value="-1">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
<fieldset name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<field
name="metakey"
type="textarea"
label="JFIELD_META_KEYWORDS_LABEL"
description="COM_BANNERS_FIELD_CLIENT_METAKEYWORDS_DESC"
rows="3"
cols="30"
/>
<field
name="own_prefix"
type="radio"
label="COM_BANNERS_FIELD_CLIENTOWNPREFIX_LABEL"
description="COM_BANNERS_FIELD_CLIENTOWNPREFIX_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="metakey_prefix"
type="text"
label="COM_BANNERS_FIELD_CLIENT_METAKEYWORDPREFIX_LABEL"
description="COM_BANNERS_FIELD_CLIENT_METAKEYWORDPREFIX_DESC"
/>
</fieldset>
<fieldset name="extra"
label="COM_BANNERS_EXTRA">
<field
name="extrainfo"
type="textarea"
label="COM_BANNERS_FIELD_EXTRAINFO_LABEL"
description="COM_BANNERS_FIELD_EXTRAINFO_DESC"
class="span12"
rows="5"
cols="80"
/>
</fieldset>
</form>
forms/download.xml000064400000001145151161332440010224 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset name="details">
<field
name="compressed"
type="radio"
label="COM_BANNERS_FIELD_COMPRESSED_LABEL"
description="COM_BANNERS_FIELD_COMPRESSED_DESC"
default="0"
class="btn-group btn-group-yesno"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="basename"
type="text"
label="COM_BANNERS_FIELD_BASENAME_LABEL"
size="40"
/>
<field
name="basename_info"
type="note"
description="COM_BANNERS_FIELD_BASENAME_DESC"
class="alert alert-info"
/>
</fieldset>
</form>
forms/filter_banners.xml000064400000006732151161332440011421
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter"
addfieldpath="/administrator/components/com_banners/models/fields">
<field
name="search"
type="text"
inputmode="search"
label="COM_BANNERS_BANNERS_FILTER_SEARCH_LABEL"
description="COM_BANNERS_BANNERS_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
label="JOPTION_SELECT_PUBLISHED"
description="JOPTION_SELECT_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
extension="com_banners"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_CATEGORY</option>
</field>
<field
name="client_id"
type="bannerclient"
label="COM_BANNERS_FILTER_CLIENT"
description="COM_BANNERS_FILTER_CLIENT_DESC"
extension="com_content"
onchange="this.form.submit();"
>
<option
value="">COM_BANNERS_SELECT_CLIENT</option>
</field>
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
statuses="*,0,1,2,-2"
onchange="this.form.submit();"
default="a.name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.name
ASC">COM_BANNERS_HEADING_NAME_ASC</option>
<option value="a.name
DESC">COM_BANNERS_HEADING_NAME_DESC</option>
<option value="category_title
ASC">JCATEGORY_ASC</option>
<option value="category_title
DESC">JCATEGORY_DESC</option>
<option value="a.sticky
ASC">COM_BANNERS_HEADING_STICKY_ASC</option>
<option value="a.sticky
DESC">COM_BANNERS_HEADING_STICKY_DESC</option>
<option value="client_name
ASC">COM_BANNERS_HEADING_CLIENT_ASC</option>
<option value="client_name
DESC">COM_BANNERS_HEADING_CLIENT_DESC</option>
<option value="impmade
ASC">COM_BANNERS_HEADING_IMPRESSIONS_ASC</option>
<option value="impmade
DESC">COM_BANNERS_HEADING_IMPRESSIONS_DESC</option>
<option value="clicks
ASC">COM_BANNERS_HEADING_CLICKS_ASC</option>
<option value="clicks
DESC">COM_BANNERS_HEADING_CLICKS_DESC</option>
<option value="a.language
ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="a.language
DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_BANNERS_LIST_LIMIT"
description="COM_BANNERS_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_clients.xml000064400000004363151161332440011430
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_BANNERS_CLIENTS_FILTER_SEARCH_LABEL"
description="COM_BANNERS_CLIENTS_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="status"
label="JOPTION_SELECT_PUBLISHED"
description="JOPTION_SELECT_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="purchase_type"
type="list"
label="COM_BANNERS_FILTER_PURCHASETYPE_LABEL"
description="COM_BANNERS_FIELD_PURCHASETYPE_DESC"
default="0"
onchange="this.form.submit();"
>
<option value="">COM_BANNERS_SELECT_TYPE</option>
<option
value="1">COM_BANNERS_FIELD_VALUE_UNLIMITED</option>
<option
value="2">COM_BANNERS_FIELD_VALUE_YEARLY</option>
<option
value="3">COM_BANNERS_FIELD_VALUE_MONTHLY</option>
<option
value="4">COM_BANNERS_FIELD_VALUE_WEEKLY</option>
<option
value="5">COM_BANNERS_FIELD_VALUE_DAILY</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
statuses="*,0,1,2,-2"
onchange="this.form.submit();"
default="a.name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.name
ASC">COM_BANNERS_HEADING_CLIENT_ASC</option>
<option value="a.name
DESC">COM_BANNERS_HEADING_CLIENT_DESC</option>
<option value="a.contact
ASC">COM_BANNERS_HEADING_CONTACT_ASC</option>
<option value="a.contact
DESC">COM_BANNERS_HEADING_CONTACT_DESC</option>
<option value="a.purchase_type
ASC">COM_BANNERS_HEADING_PURCHASETYPE_ASC</option>
<option value="a.purchase_type
DESC">COM_BANNERS_HEADING_PURCHASETYPE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_BANNERS_LIST_LIMIT"
description="COM_BANNERS_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_tracks.xml000064400000005631151161332440011255
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter"
addfieldpath="/administrator/components/com_banners/models/fields">
<field
name="search"
type="text"
inputmode="search"
label="COM_BANNERS_TRACKS_FILTER_SEARCH_LABEL"
description="COM_BANNERS_TRACKS_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
extension="com_banners"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_CATEGORY</option>
</field>
<field
name="client_id"
type="bannerclient"
label="COM_BANNERS_FILTER_CLIENT"
description="COM_BANNERS_FILTER_CLIENT_DESC"
extension="com_content"
onchange="this.form.submit();"
>
<option
value="">COM_BANNERS_SELECT_CLIENT</option>
</field>
<field
name="type"
type="list"
onchange="this.form.submit();"
>
<option value="">COM_BANNERS_SELECT_TYPE</option>
<option value="1">COM_BANNERS_TYPE1</option>
<option value="2">COM_BANNERS_TYPE2</option>
</field>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
<field
name="begin"
type="calendar"
label="COM_BANNERS_BEGIN_LABEL"
description="COM_BANNERS_BEGIN_DESC"
hint="COM_BANNERS_BEGIN_HINT"
format="%Y-%m-%d"
size="10"
filter="user_utc"
/>
<field
name="end"
type="calendar"
label="COM_BANNERS_END_LABEL"
description="COM_BANNERS_END_DESC"
hint="COM_BANNERS_END_HINT"
format="%Y-%m-%d"
size="10"
filter="user_utc"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="b.name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="b.name
ASC">COM_BANNERS_HEADING_NAME_ASC</option>
<option value="b.name
DESC">COM_BANNERS_HEADING_NAME_DESC</option>
<option value="cl.name
ASC">COM_BANNERS_HEADING_CLIENT_ASC</option>
<option value="cl.name
DESC">COM_BANNERS_HEADING_CLIENT_DESC</option>
<option value="a.track_type
ASC">COM_BANNERS_HEADING_TYPE_ASC</option>
<option value="a.track_type
DESC">COM_BANNERS_HEADING_TYPE_DESC</option>
<option value="a.count
ASC">COM_BANNERS_HEADING_COUNT_ASC</option>
<option value="a.count
DESC">COM_BANNERS_HEADING_COUNT_DESC</option>
<option value="a.track_date
ASC">JDATE_ASC</option>
<option value="a.track_date
DESC">JDATE_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="5"
onchange="this.form.submit();"
/>
</fields>
</form>
tracks.php000064400000031776151161332440006562 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Archive\Archive;
use Joomla\String\StringHelper;
JLoader::register('BannersHelper', JPATH_ADMINISTRATOR .
'/components/com_banners/helpers/banners.php');
/**
* Methods supporting a list of tracks.
*
* @since 1.6
*/
class BannersModelTracks extends JModelList
{
/**
* The base name
*
* @var string
* @since 1.6
*/
protected $basename;
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'b.name', 'banner_name',
'cl.name', 'client_name', 'client_id',
'c.title', 'category_title',
'category_id',
'track_type', 'a.track_type', 'type',
'count', 'a.count',
'track_date', 'a.track_date', 'end',
'begin',
'level', 'c.level',
);
}
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.6
*/
protected function populateState($ordering = 'b.name',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.category_id',
$this->getUserStateFromRequest($this->context .
'.filter.category_id', 'filter_category_id',
'', 'cmd'));
$this->setState('filter.client_id',
$this->getUserStateFromRequest($this->context .
'.filter.client_id', 'filter_client_id', '',
'cmd'));
$this->setState('filter.type',
$this->getUserStateFromRequest($this->context .
'.filter.type', 'filter_type', '',
'cmd'));
$this->setState('filter.level',
$this->getUserStateFromRequest($this->context .
'.filter.level', 'filter_level', '',
'cmd'));
$this->setState('filter.begin',
$this->getUserStateFromRequest($this->context .
'.filter.begin', 'filter_begin', '',
'string'));
$this->setState('filter.end',
$this->getUserStateFromRequest($this->context .
'.filter.end', 'filter_end', '',
'string'));
// Load the parameters.
$this->setState('params',
JComponentHelper::getParams('com_banners'));
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select($db->quoteName(array('a.track_date',
'a.track_type', 'a.count')))
->select($db->quoteName('b.name',
'banner_name'))
->select($db->quoteName('cl.name',
'client_name'))
->select($db->quoteName('c.title',
'category_title'));
// From tracks table.
$query->from($db->quoteName('#__banner_tracks',
'a'));
// Join with the banners.
$query->join('LEFT',
$db->quoteName('#__banners', 'b') . ' ON '
. $db->quoteName('b.id') . ' = ' .
$db->quoteName('a.banner_id'));
// Join with the client.
$query->join('LEFT',
$db->quoteName('#__banner_clients', 'cl') . '
ON ' . $db->quoteName('cl.id') . ' = ' .
$db->quoteName('b.cid'));
// Join with the category.
$query->join('LEFT',
$db->quoteName('#__categories', 'c') . ' ON
' . $db->quoteName('c.id') . ' = ' .
$db->quoteName('b.catid'));
// Filter by type.
$type = $this->getState('filter.type');
if (!empty($type))
{
$query->where($db->quoteName('a.track_type') . ' =
' . (int) $type);
}
// Filter by client.
$clientId = $this->getState('filter.client_id');
if (is_numeric($clientId))
{
$query->where($db->quoteName('b.cid') . ' = '
. (int) $clientId);
}
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
$query->where($db->quoteName('b.catid') . ' =
' . (int) $categoryId);
}
// Filter by begin date.
$begin = $this->getState('filter.begin');
if (!empty($begin))
{
$query->where($db->quoteName('a.track_date') . '
>= ' . $db->quote($begin));
}
// Filter by end date.
$end = $this->getState('filter.end');
if (!empty($end))
{
$query->where($db->quoteName('a.track_date') . '
<= ' . $db->quote($end));
}
// Filter on the level.
if ($level = $this->getState('filter.level'))
{
$query->where($db->quoteName('c.level') . ' <=
' . (int) $level);
}
// Filter by search in banner name or client name.
$search = $this->getState('filter.search');
if (!empty($search))
{
$search = $db->quote('%' .
StringHelper::strtolower($search) . '%');
$query->where('(LOWER(b.name) LIKE ' . $search . ' OR
LOWER(cl.name) LIKE ' . $search . ')');
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'b.name')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Method to delete rows.
*
* @return boolean Returns true on success, false on failure.
*/
public function delete()
{
$user = JFactory::getUser();
$categoryId = $this->getState('category_id');
// Access checks.
if ($categoryId)
{
$allow = $user->authorise('core.delete',
'com_banners.category.' . (int) $categoryId);
}
else
{
$allow = $user->authorise('core.delete',
'com_banners');
}
if ($allow)
{
// Delete tracks from this banner
$db = $this->getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__banner_tracks'));
// Filter by type
$type = $this->getState('filter.type');
if (!empty($type))
{
$query->where('track_type = ' . (int) $type);
}
// Filter by begin date
$begin = $this->getState('filter.begin');
if (!empty($begin))
{
$query->where('track_date >= ' .
$db->quote($begin));
}
// Filter by end date
$end = $this->getState('filter.end');
if (!empty($end))
{
$query->where('track_date <= ' . $db->quote($end));
}
$where = '1 = 1';
// Filter by client
$clientId = $this->getState('filter.client_id');
if (!empty($clientId))
{
$where .= ' AND cid = ' . (int) $clientId;
}
// Filter by category
if (!empty($categoryId))
{
$where .= ' AND catid = ' . (int) $categoryId;
}
$query->where('banner_id IN (SELECT id FROM ' .
$db->quoteName('#__banners') . ' WHERE ' . $where .
')');
$db->setQuery($query);
$this->setError((string) $query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
else
{
JError::raiseWarning(403,
JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
}
return true;
}
/**
* Get file name
*
* @return string The file name
*
* @since 1.6
*/
public function getBaseName()
{
if (!isset($this->basename))
{
$basename = str_replace('__SITE__',
JFactory::getApplication()->get('sitename'),
$this->getState('basename'));
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
if ($categoryId > 0)
{
$basename = str_replace('__CATID__', $categoryId,
$basename);
}
else
{
$basename = str_replace('__CATID__', '',
$basename);
}
$categoryName = $this->getCategoryName();
$basename = str_replace('__CATNAME__', $categoryName,
$basename);
}
else
{
$basename = str_replace(array('__CATID__',
'__CATNAME__'), '', $basename);
}
$clientId = $this->getState('filter.client_id');
if (is_numeric($clientId))
{
if ($clientId > 0)
{
$basename = str_replace('__CLIENTID__', $clientId,
$basename);
}
else
{
$basename = str_replace('__CLIENTID__', '',
$basename);
}
$clientName = $this->getClientName();
$basename = str_replace('__CLIENTNAME__', $clientName,
$basename);
}
else
{
$basename = str_replace(array('__CLIENTID__',
'__CLIENTNAME__'), '', $basename);
}
$type = $this->getState('filter.type');
if ($type > 0)
{
$basename = str_replace('__TYPE__', $type, $basename);
$typeName = JText::_('COM_BANNERS_TYPE' . $type);
$basename = str_replace('__TYPENAME__', $typeName,
$basename);
}
else
{
$basename = str_replace(array('__TYPE__',
'__TYPENAME__'), '', $basename);
}
$begin = $this->getState('filter.begin');
if (!empty($begin))
{
$basename = str_replace('__BEGIN__', $begin, $basename);
}
else
{
$basename = str_replace('__BEGIN__', '',
$basename);
}
$end = $this->getState('filter.end');
if (!empty($end))
{
$basename = str_replace('__END__', $end, $basename);
}
else
{
$basename = str_replace('__END__', '', $basename);
}
$this->basename = $basename;
}
return $this->basename;
}
/**
* Get the category name.
*
* @return string The category name
*
* @since 1.6
*/
protected function getCategoryName()
{
$categoryId = $this->getState('filter.category_id');
if ($categoryId)
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('title')
->from($db->quoteName('#__categories'))
->where($db->quoteName('id') . '=' .
$db->quote($categoryId));
$db->setQuery($query);
try
{
$name = $db->loadResult();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
return $name;
}
return JText::_('COM_BANNERS_NOCATEGORYNAME');
}
/**
* Get the client name
*
* @return string The client name.
*
* @since 1.6
*/
protected function getClientName()
{
$clientId = $this->getState('filter.client_id');
if ($clientId)
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('name')
->from($db->quoteName('#__banner_clients'))
->where($db->quoteName('id') . '=' .
$db->quote($clientId));
$db->setQuery($query);
try
{
$name = $db->loadResult();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
return $name;
}
return JText::_('COM_BANNERS_NOCLIENTNAME');
}
/**
* Get the file type.
*
* @return string The file type
*
* @since 1.6
*/
public function getFileType()
{
return $this->getState('compressed') ? 'zip' :
'csv';
}
/**
* Get the mime type.
*
* @return string The mime type.
*
* @since 1.6
*/
public function getMimeType()
{
return $this->getState('compressed') ?
'application/zip' : 'text/csv';
}
/**
* Get the content
*
* @return string The content.
*
* @since 1.6
*/
public function getContent()
{
if (!isset($this->content))
{
$this->content = '"' . str_replace('"',
'""', JText::_('COM_BANNERS_HEADING_NAME')) .
'","'
. str_replace('"', '""',
JText::_('COM_BANNERS_HEADING_CLIENT')) .
'","'
. str_replace('"', '""',
JText::_('JCATEGORY')) . '","'
. str_replace('"', '""',
JText::_('COM_BANNERS_HEADING_TYPE')) . '","'
. str_replace('"', '""',
JText::_('COM_BANNERS_HEADING_COUNT')) .
'","'
. str_replace('"', '""',
JText::_('JDATE')) . '"' . "\n";
foreach ($this->getItems() as $item)
{
$this->content .= '"' .
str_replace('"', '""',
$item->banner_name) . '","'
. str_replace('"', '""',
$item->client_name) . '","'
. str_replace('"', '""',
$item->category_title) . '","'
. str_replace('"', '""',
($item->track_type == 1 ? JText::_('COM_BANNERS_IMPRESSION') :
JText::_('COM_BANNERS_CLICK'))) . '","'
. str_replace('"', '""',
$item->count) . '","'
. str_replace('"', '""',
$item->track_date) . '"' . "\n";
}
if ($this->getState('compressed'))
{
$app = JFactory::getApplication('administrator');
$files = array(
'track' => array(
'name' => $this->getBasename() . '.csv',
'data' => $this->content,
'time' => time()
)
);
$ziproot = $app->get('tmp_path') . '/' .
uniqid('banners_tracks_') . '.zip';
// Run the packager
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$delete = JFolder::files($app->get('tmp_path') .
'/', uniqid('banners_tracks_'), false, true);
if (!empty($delete))
{
if (!JFile::delete($delete))
{
// JFile::delete throws an error
$this->setError(JText::_('COM_BANNERS_ERR_ZIP_DELETE_FAILURE'));
return false;
}
}
$archive = new Archive;
if (!$packager = $archive->getAdapter('zip'))
{
$this->setError(JText::_('COM_BANNERS_ERR_ZIP_ADAPTER_FAILURE'));
return false;
}
elseif (!$packager->create($ziproot, $files))
{
$this->setError(JText::_('COM_BANNERS_ERR_ZIP_CREATE_FAILURE'));
return false;
}
$this->content = file_get_contents($ziproot);
}
}
return $this->content;
}
}
forms/filter_m_relations.xml000064400000003676151161523650012316
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_molation/models/rules"
addfieldpath="/administrator/components/com_molation/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOLATION_FILTER_SEARCH"
description="COM_MOLATION_FILTER_SEARCH_M_RELATIONS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOLATION_FILTER_PUBLISHED"
description="COM_MOLATION_FILTER_PUBLISHED_M_RELATIONS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="accesslevel"
name="access"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.module_id
ASC">COM_MOLATION_FILTER_MODULE_ID_ASCENDING</option>
<option value="a.module_id
DESC">COM_MOLATION_FILTER_MODULE_ID_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/m_relation.xml000064400000013141151161523650010552
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_molation/models/rules"
addfieldpath="/administrator/components/com_molation/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOLATION_M_RELATION_CREATED_DATE_LABEL"
description="COM_MOLATION_M_RELATION_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOLATION_M_RELATION_CREATED_BY_LABEL"
description="COM_MOLATION_M_RELATION_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOLATION_M_RELATION_MODIFIED_DATE_LABEL"
description="COM_MOLATION_M_RELATION_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOLATION_M_RELATION_MODIFIED_BY_LABEL"
description="COM_MOLATION_M_RELATION_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Access Field. Type: Accesslevel (joomla)-->
<field name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
default="1"
required="false" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOLATION_M_RELATION_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOLATION_M_RELATION_VERSION_LABEL"
description="COM_MOLATION_M_RELATION_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="molation m_relation" />
<!-- Dynamic Fields.-->
<!-- User Field. Type: User. (joomla)-->
<field type="user"
name="user"
label="COM_MOLATION_M_RELATION_USER_LABEL"
/>
<!-- Module_id Field. Type: Text. (joomla)-->
<field type="text"
name="module_id"
label="COM_MOLATION_M_RELATION_MODULE_ID_LABEL"
size="10"
maxlength="50"
default=""
description="COM_MOLATION_M_RELATION_MODULE_ID_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="INT"
message="COM_MOLATION_M_RELATION_MODULE_ID_MESSAGE"
autocomplete="on" />
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this m_relation"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_molation"
section="m_relation"
/>
</fieldset>
</form>molation.php000064400000016766151161523650007124
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 24th July, 2022
@created 13th July, 2022
@package Molation
@subpackage molation.php
@author farhad shahbazi <http://lmskaran.ir>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Molation Model
*/
class MolationModelMolation extends JModelList
{
public function getIcons()
{
// load user for access menus
$user = JFactory::getUser();
// reset icon array
$icons = array();
// view groups array
$viewGroups = array(
'main' => array('png.m_relations')
);
// view access array
$viewAccess = array(
'm_relations.access' => 'm_relation.access',
'm_relation.access' => 'm_relation.access',
'm_relations.submenu' => 'm_relation.submenu',
'm_relations.dashboard_list' =>
'm_relation.dashboard_list');
// loop over the $views
foreach($viewGroups as $group => $views)
{
$i = 0;
if (MolationHelper::checkArray($views))
{
foreach($views as $view)
{
$add = false;
// external views (links)
if (strpos($view,'||') !== false)
{
$dwd = explode('||', $view);
if (count($dwd) == 3)
{
list($type, $name, $url) = $dwd;
$viewName = $name;
$alt = $name;
$url = $url;
$image = $name . '.' . $type;
$name = 'COM_MOLATION_DASHBOARD_' .
MolationHelper::safeString($name,'U');
}
}
// internal views
elseif (strpos($view,'.') !== false)
{
$dwd = explode('.', $view);
if (count($dwd) == 3)
{
list($type, $name, $action) = $dwd;
}
elseif (count($dwd) == 2)
{
list($type, $name) = $dwd;
$action = false;
}
if ($action)
{
$viewName = $name;
switch($action)
{
case 'add':
$url = 'index.php?option=com_molation&view=' . $name
. '&layout=edit';
$image = $name . '_' . $action. '.' . $type;
$alt = $name . ' ' . $action;
$name =
'COM_MOLATION_DASHBOARD_'.MolationHelper::safeString($name,'U').'_ADD';
$add = true;
break;
default:
// check for new convention (more stable)
if (strpos($action, '_qpo0O0oqp_') !== false)
{
list($action, $extension) = (array)
explode('_qpo0O0oqp_', $action);
$extension = str_replace('_po0O0oq_', '.',
$extension);
}
else
{
$extension = 'com_molation.' . $name;
}
$url =
'index.php?option=com_categories&view=categories&extension='
. $extension;
$image = $name . '_' . $action . '.' . $type;
$alt = $viewName . ' ' . $action;
$name = 'COM_MOLATION_DASHBOARD_' .
MolationHelper::safeString($name,'U') . '_' .
MolationHelper::safeString($action,'U');
break;
}
}
else
{
$viewName = $name;
$alt = $name;
$url = 'index.php?option=com_molation&view=' .
$name;
$image = $name . '.' . $type;
$name = 'COM_MOLATION_DASHBOARD_' .
MolationHelper::safeString($name,'U');
$hover = false;
}
}
else
{
$viewName = $view;
$alt = $view;
$url = 'index.php?option=com_molation&view=' . $view;
$image = $view . '.png';
$name = ucwords($view).'<br /><br />';
$hover = false;
}
// first make sure the view access is set
if (MolationHelper::checkArray($viewAccess))
{
// setup some defaults
$dashboard_add = false;
$dashboard_list = false;
$accessTo = '';
$accessAdd = '';
// access checking start
$accessCreate = (isset($viewAccess[$viewName.'.create'])) ?
MolationHelper::checkString($viewAccess[$viewName.'.create']):false;
$accessAccess = (isset($viewAccess[$viewName.'.access'])) ?
MolationHelper::checkString($viewAccess[$viewName.'.access']):false;
// set main controllers
$accessDashboard_add =
(isset($viewAccess[$viewName.'.dashboard_add'])) ?
MolationHelper::checkString($viewAccess[$viewName.'.dashboard_add']):false;
$accessDashboard_list =
(isset($viewAccess[$viewName.'.dashboard_list'])) ?
MolationHelper::checkString($viewAccess[$viewName.'.dashboard_list']):false;
// check for adding access
if ($add && $accessCreate)
{
$accessAdd = $viewAccess[$viewName.'.create'];
}
elseif ($add)
{
$accessAdd = 'core.create';
}
// check if access to view is set
if ($accessAccess)
{
$accessTo = $viewAccess[$viewName.'.access'];
}
// set main access controllers
if ($accessDashboard_add)
{
$dashboard_add =
$user->authorise($viewAccess[$viewName.'.dashboard_add'],
'com_molation');
}
if ($accessDashboard_list)
{
$dashboard_list =
$user->authorise($viewAccess[$viewName.'.dashboard_list'],
'com_molation');
}
if (MolationHelper::checkString($accessAdd) &&
MolationHelper::checkString($accessTo))
{
// check access
if($user->authorise($accessAdd, 'com_molation')
&& $user->authorise($accessTo, 'com_molation')
&& $dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (MolationHelper::checkString($accessTo))
{
// check access
if($user->authorise($accessTo, 'com_molation')
&& $dashboard_list)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (MolationHelper::checkString($accessAdd))
{
// check access
if($user->authorise($accessAdd, 'com_molation')
&& $dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
$i++;
}
}
else
{
$icons[$group][$i] = false;
}
}
return $icons;
}
}
m_relation.php000064400000052013151161523650007414 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 24th July, 2022
@created 13th July, 2022
@package Molation
@subpackage m_relation.php
@author farhad shahbazi <http://lmskaran.ir>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Molation M_relation Model
*/
class MolationModelM_relation extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'user'
),
'right' => array(
'module_id'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOLATION';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_molation.m_relation';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'm_relation', $prefix =
'MolationTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_molation/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_molation.m_relation',
'm_relation', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_molation.m_relation.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state',
'com_molation')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_molation'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_molation'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_molation/js/m_relation.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_molation.m_relation.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_molation.m_relation.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_molation.m_relation.'. ((int) isset($data[$key]) ?
$data[$key] : 0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__molation_m_relation'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_molation.edit.m_relation.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_molation.m_relation', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MolationHelper::getActions('m_relation');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MolationHelper::getActions('m_relation');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values
if (MolationHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MolationHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MolationHelper::getActions('m_relation');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MolationHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MolationHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
m_relations.php000064400000025473151161523650007611 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 24th July, 2022
@created 13th July, 2022
@package Molation
@subpackage m_relations.php
@author farhad shahbazi <http://lmskaran.ir>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* M_relations Model
*/
class MolationModelM_relations extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.access','access',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.module_id','module_id'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$module_id = $this->getUserStateFromRequest($this->context .
'.filter.module_id', 'filter_module_id');
if ($formSubmited)
{
$module_id = $app->input->post->get('module_id');
$this->setState('filter.module_id', $module_id);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the molation_item table
$query->from($db->quoteName('#__molation_m_relation',
'a'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Filter by access level.
$_access = $this->getState('filter.access');
if ($_access && is_numeric($_access))
{
$query->where('a.access = ' . (int) $_access);
}
elseif (MolationHelper::checkArray($_access))
{
// Secure the array for the query
$_access = ArrayHelper::toInteger($_access);
// Filter by the Access Array.
$query->where('a.access IN (' . implode(',',
$_access) . ')');
}
// Implement View Level Access
if (!$user->authorise('core.options',
'com_molation'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.module_id LIKE '.$search.')');
}
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get list export data.
*
* @param array $pks The ids of the items to get
* @param JUser $user The user making the request
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExportData($pks, $user = null)
{
// setup the query
if (($pks_size = MolationHelper::checkArray($pks)) !== false ||
'bulk' === $pks)
{
// Set a value to know this is export method. (USE IN CUSTOM CODE TO
ALTER OUTCOME)
$_export = true;
// Get the user object if not set.
if (!isset($user) || !MolationHelper::checkObject($user))
{
$user = JFactory::getUser();
}
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the molation_m_relation table
$query->from($db->quoteName('#__molation_m_relation',
'a'));
// The bulk export path
if ('bulk' === $pks)
{
$query->where('a.id > 0');
}
// A large array of ID's will not work out well
elseif ($pks_size > 500)
{
// Use lowest ID
$query->where('a.id >= ' . (int) min($pks));
// Use highest ID
$query->where('a.id <= ' . (int) max($pks));
}
// The normal default path
else
{
$query->where('a.id IN (' . implode(',',$pks) .
')');
}
// Implement View Level Access
if (!$user->authorise('core.options',
'com_molation'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Order the results by ordering
$query->order('a.ordering ASC');
// Load the items
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$items = $db->loadObjectList();
// Set values to display correctly.
if (MolationHelper::checkArray($items))
{
foreach ($items as $nr => &$item)
{
// unset the values we don't want exported.
unset($item->asset_id);
unset($item->checked_out);
unset($item->checked_out_time);
}
}
// Add headers to items array.
$headers = $this->getExImPortHeaders();
if (MolationHelper::checkObject($headers))
{
array_unshift($items,$headers);
}
return $items;
}
}
return false;
}
/**
* Method to get header.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExImPortHeaders()
{
// Get a db connection.
$db = JFactory::getDbo();
// get the columns
$columns = $db->getTableColumns("#__molation_m_relation");
if (MolationHelper::checkArray($columns))
{
// remove the headers you don't import/export.
unset($columns['asset_id']);
unset($columns['checked_out']);
unset($columns['checked_out_time']);
$headers = new stdClass();
foreach ($columns as $column => $type)
{
$headers->{$column} = $column;
}
return $headers;
}
return false;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
// Check if the value is an array
$_access = $this->getState('filter.access');
if (MolationHelper::checkArray($_access))
{
$id .= ':' . implode(':', $_access);
}
// Check if this is only an number or string
elseif (is_numeric($_access)
|| MolationHelper::checkString($_access))
{
$id .= ':' . $_access;
}
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.module_id');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_molation')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__molation_m_relation'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__molation_m_relation'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
article.php000064400000060166151161622020006705 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
JLoader::register('ContentHelper', JPATH_ADMINISTRATOR .
'/components/com_content/helpers/content.php');
/**
* Item Model for an Article.
*
* @since 1.6
*/
class ContentModelArticle extends JModelAdmin
{
/**
* The prefix to use with controller messages.
*
* @var string
* @since 1.6
*/
protected $text_prefix = 'COM_CONTENT';
/**
* The type alias for this content type (for example,
'com_content.article').
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_content.article';
/**
* The context used for the associations table
*
* @var string
* @since 3.4.4
*/
protected $associationsContext = 'com_content.item';
/**
* Function that can be overridden to do any data cleanup after batch
copying data
*
* @param \JTableInterface $table The table object containing the
newly created item
* @param integer $newId The id of the new item
* @param integer $oldId The original item id
*
* @return void
*
* @since 3.8.12
*/
protected function cleanupPostBatchCopy(\JTableInterface $table, $newId,
$oldId)
{
// Check if the article was featured and update the #__content_frontpage
table
if ($table->featured == 1)
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->insert($db->quoteName('#__content_frontpage'))
->values($newId . ', 0');
$db->setQuery($query);
$db->execute();
}
// Register FieldsHelper
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR .
'/components/com_fields/helpers/fields.php');
$oldItem = $this->getTable();
$oldItem->load($oldId);
$fields = FieldsHelper::getFields('com_content.article',
$oldItem, true);
$fieldsData = array();
if (!empty($fields))
{
$fieldsData['com_fields'] = array();
foreach ($fields as $field)
{
$fieldsData['com_fields'][$field->name] =
$field->rawvalue;
}
}
JEventDispatcher::getInstance()->trigger('onContentAfterSave',
array('com_content.article', &$this->table, true,
$fieldsData));
}
/**
* Batch move categories to a new category.
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True on success.
*
* @since 3.8.6
*/
protected function batchMove($value, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
}
$categoryId = (int) $value;
if (!$this->checkCategoryId($categoryId))
{
return false;
}
JPluginHelper::importPlugin('system');
$dispatcher = JEventDispatcher::getInstance();
// Register FieldsHelper
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR .
'/components/com_fields/helpers/fields.php');
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
$fields = FieldsHelper::getFields('com_content.article',
$this->table, true);
$fieldsData = array();
if (!empty($fields))
{
$fieldsData['com_fields'] = array();
foreach ($fields as $field)
{
$fieldsData['com_fields'][$field->name] =
$field->rawvalue;
}
}
// Set the new category ID
$this->table->catid = $categoryId;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Run event for moved article
$dispatcher->trigger('onContentAfterSave',
array('com_content.article', &$this->table, false,
$fieldsData));
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (empty($record->id) || $record->state != -2)
{
return false;
}
return JFactory::getUser()->authorise('core.delete',
'com_content.article.' . (int) $record->id);
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
// Check for existing article.
if (!empty($record->id))
{
return $user->authorise('core.edit.state',
'com_content.article.' . (int) $record->id);
}
// New article, so check against the category.
if (!empty($record->catid))
{
return $user->authorise('core.edit.state',
'com_content.category.' . (int) $record->catid);
}
// Default to component settings if neither article nor category known.
return parent::canEditState($record);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
// Set the publish date to now
if ($table->state == 1 && (int) $table->publish_up == 0)
{
$table->publish_up = JFactory::getDate()->toSql();
}
if ($table->state == 1 && intval($table->publish_down) ==
0)
{
$table->publish_down = $this->getDbo()->getNullDate();
}
// Increment the content version number.
$table->version++;
// Reorder the articles within the category so the new article is first
if (empty($table->id))
{
$table->reorder('catid = ' . (int) $table->catid .
' AND state >= 0');
}
}
/**
* Returns a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*/
public function getTable($type = 'Content', $prefix =
'JTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
// Convert the params field to an array.
$registry = new Registry($item->attribs);
$item->attribs = $registry->toArray();
// Convert the metadata field to an array.
$registry = new Registry($item->metadata);
$item->metadata = $registry->toArray();
// Convert the images field to an array.
$registry = new Registry($item->images);
$item->images = $registry->toArray();
// Convert the urls field to an array.
$registry = new Registry($item->urls);
$item->urls = $registry->toArray();
$item->articletext = trim($item->fulltext) != '' ?
$item->introtext . "<hr id=\"system-readmore\"
/>" . $item->fulltext : $item->introtext;
if (!empty($item->id))
{
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id,
'com_content.article');
}
}
// Load associated content items
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$item->associations = array();
if ($item->id != null)
{
$associations =
JLanguageAssociations::getAssociations('com_content',
'#__content', 'com_content.item', $item->id);
foreach ($associations as $tag => $association)
{
$item->associations[$tag] = $association->id;
}
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm|boolean A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
// Get the form.
$form = $this->loadForm('com_content.article',
'article', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
/*
* The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
* The back end uses id so we use that the rest of the time and set it to
0 by default.
*/
$id = $jinput->get('a_id', $jinput->get('id',
0));
// Determine correct permissions to check.
if ($this->getState('article.id'))
{
$id = $this->getState('article.id');
// Existing record. Can only edit in selected categories.
$form->setFieldAttribute('catid', 'action',
'core.edit');
// Existing record. Can only edit own articles in selected categories.
if ($app->isClient('administrator'))
{
$form->setFieldAttribute('catid', 'action',
'core.edit.own');
}
else
// Existing record. We can't edit the category in frontend if not
edit.state.
{
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_content.article.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state',
'com_content')))
{
$form->setFieldAttribute('catid', 'readonly',
'true');
$form->setFieldAttribute('catid', 'filter',
'unset');
}
}
}
else
{
// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action',
'core.create');
}
// Check for existing article.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_content.article.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state',
'com_content')))
{
// Disable fields for display.
$form->setFieldAttribute('featured', 'disabled',
'true');
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('publish_up',
'disabled', 'true');
$form->setFieldAttribute('publish_down',
'disabled', 'true');
$form->setFieldAttribute('state', 'disabled',
'true');
// Disable fields while saving.
// The controller has already verified this is an article you can edit.
$form->setFieldAttribute('featured', 'filter',
'unset');
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('publish_up', 'filter',
'unset');
$form->setFieldAttribute('publish_down',
'filter', 'unset');
$form->setFieldAttribute('state', 'filter',
'unset');
}
// Prevent messing with article language and category when editing
existing article with associations
$assoc = JLanguageAssociations::isEnabled();
// Check if article is associated
if ($this->getState('article.id') &&
$app->isClient('site') && $assoc)
{
$associations =
JLanguageAssociations::getAssociations('com_content',
'#__content', 'com_content.item', $id);
// Make fields read only
if (!empty($associations))
{
$form->setFieldAttribute('language', 'readonly',
'true');
$form->setFieldAttribute('catid', 'readonly',
'true');
$form->setFieldAttribute('language', 'filter',
'unset');
$form->setFieldAttribute('catid', 'filter',
'unset');
}
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$app = JFactory::getApplication();
$data = $app->getUserState('com_content.edit.article.data',
array());
if (empty($data))
{
$data = $this->getItem();
// Pre-select some filters (Status, Category, Language, Access) in edit
form if those have been selected in Article Manager: Articles
if ($this->getState('article.id') == 0)
{
$filters = (array)
$app->getUserState('com_content.articles.filter');
$data->set(
'state',
$app->input->getInt(
'state',
((isset($filters['published']) &&
$filters['published'] !== '') ?
$filters['published'] : null)
)
);
$data->set('catid',
$app->input->getInt('catid',
(!empty($filters['category_id']) ?
$filters['category_id'] : null)));
$data->set('language',
$app->input->getString('language',
(!empty($filters['language']) ? $filters['language'] :
null)));
$data->set('access',
$app->input->getInt('access',
(!empty($filters['access']) ? $filters['access'] :
JFactory::getConfig()->get('access')))
);
}
}
// If there are params fieldsets in the form it will fail with a registry
object
if (isset($data->params) && $data->params instanceof
Registry)
{
$data->params = $data->params->toArray();
}
$this->preprocessData('com_content.article', $data);
return $data;
}
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return array|boolean Array of filtered data if valid, false
otherwise.
*
* @see JFormRule
* @see JFilterInput
* @since 3.7.0
*/
public function validate($form, $data, $group = null)
{
// Don't allow to change the users if not allowed to access
com_users.
if (JFactory::getApplication()->isClient('administrator')
&& !JFactory::getUser()->authorise('core.manage',
'com_users'))
{
if (isset($data['created_by']))
{
unset($data['created_by']);
}
if (isset($data['modified_by']))
{
unset($data['modified_by']);
}
}
if (!JFactory::getUser()->authorise('core.admin',
'com_content'))
{
if (isset($data['rules']))
{
unset($data['rules']);
}
}
return parent::validate($form, $data, $group);
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
}
if (isset($data['created_by_alias']))
{
$data['created_by_alias'] =
$filter->clean($data['created_by_alias'], 'TRIM');
}
if (isset($data['images']) &&
is_array($data['images']))
{
$registry = new Registry($data['images']);
$data['images'] = (string) $registry;
}
JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR .
'/components/com_categories/helpers/categories.php');
// Create new category, if needed.
$createCategory = true;
// If category ID is provided, check if it's valid.
if (is_numeric($data['catid']) &&
$data['catid'])
{
$createCategory =
!CategoriesHelper::validateCategoryId($data['catid'],
'com_content');
}
// Save New Category
if ($createCategory && $this->canCreateCategory())
{
$table = array();
// Remove #new# prefix, if exists.
$table['title'] = strpos($data['catid'],
'#new#') === 0 ? substr($data['catid'], 5) :
$data['catid'];
$table['parent_id'] = 1;
$table['extension'] = 'com_content';
$table['language'] = $data['language'];
$table['published'] = 1;
// Create new category and get catid back
$data['catid'] = CategoriesHelper::createCategory($table);
}
if (isset($data['urls']) &&
is_array($data['urls']))
{
$check = $input->post->get('jform', array(),
'array');
foreach ($data['urls'] as $i => $url)
{
if ($url != false && ($i == 'urla' || $i ==
'urlb' || $i == 'urlc'))
{
if (preg_match('~^#[a-zA-Z]{1}[a-zA-Z0-9-_:.]*$~',
$check['urls'][$i]) == 1)
{
$data['urls'][$i] = $check['urls'][$i];
}
else
{
$data['urls'][$i] = JStringPunycode::urlToPunycode($url);
}
}
}
unset($check);
$registry = new Registry($data['urls']);
$data['urls'] = (string) $registry;
}
// Alter the title for save as copy
if ($input->get('task') == 'save2copy')
{
$origTable = clone $this->getTable();
$origTable->load($input->getInt('id'));
if ($data['title'] == $origTable->title)
{
list($title, $alias) =
$this->generateNewTitle($data['catid'],
$data['alias'], $data['title']);
$data['title'] = $title;
$data['alias'] = $alias;
}
else
{
if ($data['alias'] == $origTable->alias)
{
$data['alias'] = '';
}
}
$data['state'] = 0;
}
// Automatic handling of alias for empty fields
if (in_array($input->get('task'), array('apply',
'save', 'save2new')) &&
(!isset($data['id']) || (int) $data['id'] == 0))
{
if ($data['alias'] == null)
{
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
$data['alias'] =
JFilterOutput::stringURLUnicodeSlug($data['title']);
}
else
{
$data['alias'] =
JFilterOutput::stringURLSafe($data['title']);
}
$table = JTable::getInstance('Content', 'JTable');
if ($table->load(array('alias' =>
$data['alias'], 'catid' =>
$data['catid'])))
{
$msg = JText::_('COM_CONTENT_SAVE_WARNING');
}
list($title, $alias) =
$this->generateNewTitle($data['catid'],
$data['alias'], $data['title']);
$data['alias'] = $alias;
if (isset($msg))
{
JFactory::getApplication()->enqueueMessage($msg,
'warning');
}
}
}
if (parent::save($data))
{
if (isset($data['featured']))
{
$this->featured($this->getState($this->getName() .
'.id'), $data['featured']);
}
return true;
}
return false;
}
/**
* Method to toggle the featured setting of articles.
*
* @param array $pks The ids of the items to toggle.
* @param integer $value The value to toggle to.
*
* @return boolean True on success.
*/
public function featured($pks, $value = 0)
{
// Sanitize the ids.
$pks = (array) $pks;
$pks = ArrayHelper::toInteger($pks);
if (empty($pks))
{
$this->setError(JText::_('COM_CONTENT_NO_ITEM_SELECTED'));
return false;
}
$table = $this->getTable('Featured',
'ContentTable');
try
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->update($db->quoteName('#__content'))
->set('featured = ' . (int) $value)
->where('id IN (' . implode(',', $pks) .
')');
$db->setQuery($query);
$db->execute();
if ((int) $value == 0)
{
// Adjust the mapping table.
// Clear the existing features settings.
$query = $db->getQuery(true)
->delete($db->quoteName('#__content_frontpage'))
->where('content_id IN (' . implode(',', $pks)
. ')');
$db->setQuery($query);
$db->execute();
}
else
{
// First, we find out which of our new featured articles are already
featured.
$query = $db->getQuery(true)
->select('f.content_id')
->from('#__content_frontpage AS f')
->where('content_id IN (' . implode(',', $pks)
. ')');
$db->setQuery($query);
$oldFeatured = $db->loadColumn();
// We diff the arrays to get a list of the articles that are newly
featured
$newFeatured = array_diff($pks, $oldFeatured);
// Featuring.
$tuples = array();
foreach ($newFeatured as $pk)
{
$tuples[] = $pk . ', 0';
}
if (count($tuples))
{
$columns = array('content_id', 'ordering');
$query = $db->getQuery(true)
->insert($db->quoteName('#__content_frontpage'))
->columns($db->quoteName($columns))
->values($tuples);
$db->setQuery($query);
$db->execute();
}
}
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
$table->reorder();
$this->cleanCache();
return true;
}
/**
* A protected method to get a set of ordering conditions.
*
* @param object $table A record object.
*
* @return array An array of conditions to add to add to ordering
queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
return array('catid = ' . (int) $table->catid);
}
/**
* Allows preprocessing of the JForm object.
*
* @param JForm $form The form object
* @param array $data The data to be merged into the form object
* @param string $group The plugin group to be executed
*
* @return void
*
* @since 3.0
*/
protected function preprocessForm(JForm $form, $data, $group =
'content')
{
if ($this->canCreateCategory())
{
$form->setFieldAttribute('catid', 'allowAdd',
'true');
// Add a prefix for categories created on the fly.
$form->setFieldAttribute('catid', 'customPrefix',
'#new#');
}
// Association content items
if (JLanguageAssociations::isEnabled())
{
$languages = JLanguageHelper::getContentLanguages(false, true, null,
'ordering', 'asc');
if (count($languages) > 1)
{
$addform = new SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name',
'item_associations');
foreach ($languages as $language)
{
$field = $fieldset->addChild('field');
$field->addAttribute('name', $language->lang_code);
$field->addAttribute('type', 'modal_article');
$field->addAttribute('language',
$language->lang_code);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label',
'false');
$field->addAttribute('select', 'true');
$field->addAttribute('new', 'true');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
$field->addAttribute('propagate', 'true');
}
$form->load($addform, false);
}
}
parent::preprocessForm($form, $data, $group);
}
/**
* Custom clean the cache of com_content and content modules
*
* @param string $group The cache group
* @param integer $clientId The ID of the client
*
* @return void
*
* @since 1.6
*/
protected function cleanCache($group = null, $clientId = 0)
{
parent::cleanCache('com_content');
parent::cleanCache('mod_articles_archive');
parent::cleanCache('mod_articles_categories');
parent::cleanCache('mod_articles_category');
parent::cleanCache('mod_articles_latest');
parent::cleanCache('mod_articles_news');
parent::cleanCache('mod_articles_popular');
}
/**
* Void hit function for pagebreak when editing content from frontend
*
* @return void
*
* @since 3.6.0
*/
public function hit()
{
return;
}
/**
* Is the user allowed to create an on the fly category?
*
* @return boolean
*
* @since 3.6.1
*/
private function canCreateCategory()
{
return JFactory::getUser()->authorise('core.create',
'com_content');
}
/**
* Delete #__content_frontpage items if the deleted articles was featured
*
* @param object $pks The primary key related to the contents that was
deleted.
*
* @return boolean
*
* @since 3.7.0
*/
public function delete(&$pks)
{
$return = parent::delete($pks);
if ($return)
{
// Now check to see if this articles was featured if so delete it from
the #__content_frontpage table
$db = $this->getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__content_frontpage'))
->where('content_id IN (' . implode(',', $pks) .
')');
$db->setQuery($query);
$db->execute();
}
return $return;
}
}
articles.php000064400000031645151161622020007070 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Methods supporting a list of article records.
*
* @since 1.6
*/
class ContentModelArticles extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 1.6
* @see JControllerLegacy
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'catid', 'a.catid', 'category_title',
'state', 'a.state',
'access', 'a.access', 'access_level',
'created', 'a.created',
'modified', 'a.modified',
'created_by', 'a.created_by',
'created_by_alias', 'a.created_by_alias',
'ordering', 'a.ordering',
'featured', 'a.featured',
'language', 'a.language',
'hits', 'a.hits',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'published', 'a.published',
'author_id',
'category_id',
'level',
'tag',
'rating_count', 'rating',
);
if (JLanguageAssociations::isEnabled())
{
$config['filter_fields'][] = 'association';
}
}
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.6
*/
protected function populateState($ordering = 'a.id', $direction
= 'desc')
{
$app = JFactory::getApplication();
$forcedLanguage = $app->input->get('forcedLanguage',
'', 'cmd');
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Adjust the context to support forced languages.
if ($forcedLanguage)
{
$this->context .= '.' . $forcedLanguage;
}
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$level = $this->getUserStateFromRequest($this->context .
'.filter.level', 'filter_level');
$this->setState('filter.level', $level);
$language = $this->getUserStateFromRequest($this->context .
'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access');
$authorId = $this->getUserStateFromRequest($this->context .
'.filter.author_id', 'filter_author_id');
$categoryId = $this->getUserStateFromRequest($this->context .
'.filter.category_id', 'filter_category_id');
$tag = $this->getUserStateFromRequest($this->context .
'.filter.tag', 'filter_tag', '');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
$authorId = $app->input->post->get('author_id');
$this->setState('filter.author_id', $authorId);
$categoryId = $app->input->post->get('category_id');
$this->setState('filter.category_id', $categoryId);
$tag = $app->input->post->get('tag');
$this->setState('filter.tag', $tag);
}
// List state information.
parent::populateState($ordering, $direction);
// Force a language
if (!empty($forcedLanguage))
{
$this->setState('filter.language', $forcedLanguage);
$this->setState('filter.forcedLanguage', $forcedLanguage);
}
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' .
serialize($this->getState('filter.access'));
$id .= ':' . $this->getState('filter.published');
$id .= ':' .
serialize($this->getState('filter.category_id'));
$id .= ':' .
serialize($this->getState('filter.author_id'));
$id .= ':' . $this->getState('filter.language');
$id .= ':' .
serialize($this->getState('filter.tag'));
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.checked_out, a.checked_out_time,
a.catid' .
', a.state, a.access, a.created, a.created_by, a.created_by_alias,
a.modified, a.ordering, a.featured, a.language, a.hits' .
', a.publish_up, a.publish_down, a.note'
)
);
$query->from('#__content AS a');
// Join over the language
$query->select('l.title AS language_title, l.image AS
language_image')
->join('LEFT', $db->quoteName('#__languages')
. ' AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON
uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Join over the categories.
$query->select('c.title AS category_title, c.created_user_id AS
category_uid, c.level AS category_level')
->join('LEFT', '#__categories AS c ON c.id =
a.catid');
// Join over the parent categories.
$query->select('parent.title AS parent_category_title, parent.id
AS parent_category_id,
parent.created_user_id AS parent_category_uid, parent.level AS
parent_category_level')
->join('LEFT', '#__categories AS parent ON parent.id =
c.parent_id');
// Join over the users for the author.
$query->select('ua.name AS author_name')
->join('LEFT', '#__users AS ua ON ua.id =
a.created_by');
// Join on voting table
if (JPluginHelper::isEnabled('content', 'vote'))
{
$query->select('COALESCE(NULLIF(ROUND(v.rating_sum /
v.rating_count, 0), 0), 0) AS rating,
COALESCE(NULLIF(v.rating_count, 0), 0) as rating_count')
->join('LEFT', '#__content_rating AS v ON a.id =
v.content_id');
}
// Join over the associations.
if (JLanguageAssociations::isEnabled())
{
$subQuery = $db->getQuery(true)
->select('COUNT(' .
$db->quoteName('asso1.id') . ') > 1')
->from($db->quoteName('#__associations',
'asso1'))
->join('INNER',
$db->quoteName('#__associations', 'asso2') . '
ON ' . $db->quoteName('asso1.key') . ' = ' .
$db->quoteName('asso2.key'))
->where(
array(
$db->quoteName('asso1.id') . ' = ' .
$db->quoteName('a.id'),
$db->quoteName('asso1.context') . ' = ' .
$db->quote('com_content.item'),
)
);
$query->select('(' . $subQuery . ') AS ' .
$db->quoteName('association'));
}
// Filter by access level.
$access = $this->getState('filter.access');
if (is_numeric($access))
{
$query->where('a.access = ' . (int) $access);
}
elseif (is_array($access))
{
$access = ArrayHelper::toInteger($access);
$access = implode(',', $access);
$query->where('a.access IN (' . $access . ')');
}
// Filter by access level on categories.
if (!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
$query->where('c.access IN (' . $groups . ')');
}
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.state = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.state = 0 OR a.state = 1)');
}
// Filter by categories and by level
$categoryId = $this->getState('filter.category_id',
array());
$level = $this->getState('filter.level');
if (!is_array($categoryId))
{
$categoryId = $categoryId ? array($categoryId) : array();
}
// Case: Using both categories filter and by level filter
if (count($categoryId))
{
$categoryId = ArrayHelper::toInteger($categoryId);
$categoryTable = JTable::getInstance('Category',
'JTable');
$subCatItemsWhere = array();
foreach ($categoryId as $filter_catid)
{
$categoryTable->load($filter_catid);
$subCatItemsWhere[] = '(' .
($level ? 'c.level <= ' . ((int) $level + (int)
$categoryTable->level - 1) . ' AND ' : '') .
'c.lft >= ' . (int) $categoryTable->lft . ' AND
' .
'c.rgt <= ' . (int) $categoryTable->rgt .
')';
}
$query->where('(' . implode(' OR ',
$subCatItemsWhere) . ')');
}
// Case: Using only the by level filter
elseif ($level)
{
$query->where('c.level <= ' . (int) $level);
}
// Filter by author
$authorId = $this->getState('filter.author_id');
if (is_numeric($authorId))
{
$type = $this->getState('filter.author_id.include', true) ?
'= ' : '<>';
$query->where('a.created_by ' . $type . (int) $authorId);
}
elseif (is_array($authorId))
{
$authorId = ArrayHelper::toInteger($authorId);
$authorId = implode(',', $authorId);
$query->where('a.created_by IN (' . $authorId .
')');
}
// Filter by search in title.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
elseif (stripos($search, 'author:') === 0)
{
$search = $db->quote('%' . $db->escape(substr($search,
7), true) . '%');
$query->where('(ua.name LIKE ' . $search . ' OR
ua.username LIKE ' . $search . ')');
}
elseif (stripos($search, 'content:') === 0)
{
$search = $db->quote('%' . $db->escape(substr($search,
8), true) . '%');
$query->where('(a.introtext LIKE ' . $search . ' OR
a.fulltext LIKE ' . $search . ')');
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('(a.title LIKE ' . $search . ' OR
a.alias LIKE ' . $search . ' OR a.note LIKE ' . $search .
')');
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$query->where('a.language = ' . $db->quote($language));
}
$tag = $this->getState('filter.tag');
// Run simplified query when filtering by one tag.
if (\is_array($tag) && \count($tag) === 1)
{
$tag = $tag[0];
}
if ($tag && \is_array($tag))
{
$tag = ArrayHelper::toInteger($tag);
$subQuery = $db->getQuery(true)
->select('DISTINCT ' .
$db->quoteName('content_item_id'))
->from($db->quoteName('#__contentitem_tag_map'))
->where(
array(
$db->quoteName('tag_id') . ' IN (' .
implode(',', $tag) . ')',
$db->quoteName('type_alias') . ' = ' .
$db->quote('com_content.article'),
)
);
$query->join(
'INNER',
'(' . $subQuery . ') AS ' .
$db->quoteName('tagmap')
. ' ON ' .
$db->quoteName('tagmap.content_item_id') . ' = ' .
$db->quoteName('a.id')
);
}
elseif ($tag = (int) $tag)
{
$query->join(
'INNER',
$db->quoteName('#__contentitem_tag_map',
'tagmap')
. ' ON ' .
$db->quoteName('tagmap.content_item_id') . ' = ' .
$db->quoteName('a.id')
)
->where(
array(
$db->quoteName('tagmap.tag_id') . ' = ' .
$tag,
$db->quoteName('tagmap.type_alias') . ' = ' .
$db->quote('com_content.article'),
)
);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'DESC');
if ($orderCol == 'a.ordering' || $orderCol ==
'category_title')
{
$orderCol = $db->quoteName('c.title') . ' ' .
$orderDirn . ', ' . $db->quoteName('a.ordering');
}
$query->order($db->escape($orderCol) . ' ' .
$db->escape($orderDirn));
return $query;
}
/**
* Build a list of authors
*
* @return stdClass
*
* @since 1.6
*
* @deprecated 4.0 To be removed with Hathor
*/
public function getAuthors()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Construct the query
$query->select('u.id AS value, u.name AS text')
->from('#__users AS u')
->join('INNER', '#__content AS c ON c.created_by =
u.id')
->group('u.id, u.name')
->order('u.name');
// Setup the query
$db->setQuery($query);
// Return the result
return $db->loadObjectList();
}
}
featured.php000064400000020421151161622020007047 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JLoader::register('ContentModelArticles', __DIR__ .
'/articles.php');
/**
* Methods supporting a list of featured article records.
*
* @since 1.6
*/
class ContentModelFeatured extends ContentModelArticles
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'catid', 'a.catid', 'category_title',
'state', 'a.state',
'access', 'a.access', 'access_level',
'created', 'a.created',
'created_by', 'a.created_by',
'created_by_alias', 'a.created_by_alias',
'ordering', 'a.ordering',
'featured', 'a.featured',
'language', 'a.language',
'hits', 'a.hits',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'fp.ordering',
'published', 'a.published',
'author_id',
'category_id',
'level',
'tag',
'rating_count', 'rating',
);
}
parent::__construct($config);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.checked_out, a.checked_out_time,
a.catid, a.state, a.access, a.created, a.hits,' .
'a.created_by, a.featured, a.language, a.created_by_alias,
a.publish_up, a.publish_down, a.note'
)
);
$query->from('#__content AS a');
// Join over the language
$query->select('l.title AS language_title, l.image AS
language_image')
->join('LEFT', $db->quoteName('#__languages')
. ' AS l ON l.lang_code = a.language');
// Join over the content table.
$query->select('fp.ordering')
->join('INNER', '#__content_frontpage AS fp ON
fp.content_id = a.id');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON
uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Join over the categories.
$query->select('c.title AS category_title, c.created_user_id AS
category_uid, c.level AS category_level')
->join('LEFT', '#__categories AS c ON c.id =
a.catid');
// Join over the parent categories.
$query->select('parent.title AS parent_category_title, parent.id
AS parent_category_id,
parent.created_user_id AS parent_category_uid, parent.level AS
parent_category_level')
->join('LEFT', '#__categories AS parent ON parent.id =
c.parent_id');
// Join over the users for the author.
$query->select('ua.name AS author_name')
->join('LEFT', '#__users AS ua ON ua.id =
a.created_by');
// Join on voting table
if (JPluginHelper::isEnabled('content', 'vote'))
{
$query->select('COALESCE(NULLIF(ROUND(v.rating_sum /
v.rating_count, 0), 0), 0) AS rating,
COALESCE(NULLIF(v.rating_count, 0), 0) as rating_count')
->join('LEFT', '#__content_rating AS v ON a.id =
v.content_id');
}
// Filter by access level.
$access = $this->getState('filter.access');
if (is_numeric($access))
{
$query->where('a.access = ' . (int) $access);
}
elseif (is_array($access))
{
$access = ArrayHelper::toInteger($access);
$access = implode(',', $access);
$query->where('a.access IN (' . $access . ')');
}
// Filter by access level on categories.
if (!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
$query->where('c.access IN (' . $groups . ')');
}
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.state = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.state = 0 OR a.state = 1)');
}
// Filter by a single or group of categories.
$baselevel = 1;
$categoryId = $this->getState('filter.category_id');
if (is_array($categoryId) && count($categoryId) === 1)
{
$cat_tbl = JTable::getInstance('Category',
'JTable');
$cat_tbl->load($categoryId[0]);
$rgt = $cat_tbl->rgt;
$lft = $cat_tbl->lft;
$baselevel = (int) $cat_tbl->level;
$query->where('c.lft >= ' . (int) $lft)
->where('c.rgt <= ' . (int) $rgt);
}
elseif (is_array($categoryId))
{
$categoryId = implode(',',
ArrayHelper::toInteger($categoryId));
$query->where('a.catid IN (' . $categoryId .
')');
}
// Filter on the level.
if ($level = $this->getState('filter.level'))
{
$query->where('c.level <= ' . ((int) $level + (int)
$baselevel - 1));
}
// Filter by author
$authorId = $this->getState('filter.author_id');
if (is_numeric($authorId))
{
$type = $this->getState('filter.author_id.include', true) ?
'= ' : '<>';
$query->where('a.created_by ' . $type . (int) $authorId);
}
elseif (is_array($authorId))
{
$authorId = ArrayHelper::toInteger($authorId);
$authorId = implode(',', $authorId);
$query->where('a.created_by IN (' . $authorId .
')');
}
// Filter by search in title.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
elseif (stripos($search, 'author:') === 0)
{
$search = $db->quote('%' . $db->escape(substr($search,
7), true) . '%');
$query->where('(ua.name LIKE ' . $search . ' OR
ua.username LIKE ' . $search . ')');
}
elseif (stripos($search, 'content:') === 0)
{
$search = $db->quote('%' . $db->escape(substr($search,
8), true) . '%');
$query->where('(a.introtext LIKE ' . $search . ' OR
a.fulltext LIKE ' . $search . ')');
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('(a.title LIKE ' . $search . ' OR
a.alias LIKE ' . $search . ' OR a.note LIKE ' . $search .
')');
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$query->where('a.language = ' . $db->quote($language));
}
// Filter by a single or group of tags.
$tagId = $this->getState('filter.tag');
if (is_array($tagId) && count($tagId) === 1)
{
$tagId = current($tagId);
}
if (is_array($tagId))
{
$tagId = implode(',', ArrayHelper::toInteger($tagId));
if ($tagId)
{
$subQuery = $db->getQuery(true)
->select('DISTINCT content_item_id')
->from($db->quoteName('#__contentitem_tag_map'))
->where('tag_id IN (' . $tagId . ')')
->where('type_alias = ' .
$db->quote('com_content.article'));
$query->join('INNER', '(' . (string) $subQuery .
') AS tagmap ON tagmap.content_item_id = a.id');
}
}
elseif ($tagId)
{
$query->join(
'INNER',
$db->quoteName('#__contentitem_tag_map',
'tagmap')
. ' ON tagmap.tag_id = ' . (int) $tagId
. ' AND tagmap.content_item_id = a.id'
. ' AND tagmap.type_alias = ' .
$db->quote('com_content.article')
);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.title');
$orderDirn = $this->state->get('list.direction',
'ASC');
$query->order($db->escape($orderCol) . ' ' .
$db->escape($orderDirn));
return $query;
}
/**
* 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 3.5
*/
protected function populateState($ordering = 'a.title',
$direction = 'asc')
{
parent::populateState($ordering, $direction);
}
}
fields/modal/article.php000064400000023145151161622020011243
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\LanguageHelper;
/**
* Supports a modal article picker.
*
* @since 1.6
*/
class JFormFieldModal_Article extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Modal_Article';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$allowNew = ((string) $this->element['new'] ==
'true');
$allowEdit = ((string) $this->element['edit'] ==
'true');
$allowClear = ((string) $this->element['clear'] !=
'false');
$allowSelect = ((string) $this->element['select'] !=
'false');
$allowPropagate = ((string) $this->element['propagate'] ==
'true');
$languages = LanguageHelper::getContentLanguages(array(0, 1));
// Load language
JFactory::getLanguage()->load('com_content',
JPATH_ADMINISTRATOR);
// The active article id field.
$value = (int) $this->value > 0 ? (int) $this->value :
'';
// Create the modal id.
$modalId = 'Article_' . $this->id;
// Add the modal field script to the document head.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/modal-fields.js',
array('version' => 'auto', 'relative'
=> true));
// Script to proxy the select modal function to the modal-fields.js file.
if ($allowSelect)
{
static $scriptSelect = null;
if (is_null($scriptSelect))
{
$scriptSelect = array();
}
if (!isset($scriptSelect[$this->id]))
{
JFactory::getDocument()->addScriptDeclaration("
function jSelectArticle_" . $this->id . "(id, title,
catid, object, url, language) {
window.processModalSelect('Article', '" .
$this->id . "', id, title, catid, object, url, language);
}
");
JText::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
$scriptSelect[$this->id] = true;
}
}
// Setup variables for display.
$linkArticles =
'index.php?option=com_content&view=articles&layout=modal&tmpl=component&'
. JSession::getFormToken() . '=1';
$linkArticle =
'index.php?option=com_content&view=article&layout=modal&tmpl=component&'
. JSession::getFormToken() . '=1';
if (isset($this->element['language']))
{
$linkArticles .= '&forcedLanguage=' .
$this->element['language'];
$linkArticle .= '&forcedLanguage=' .
$this->element['language'];
$modalTitle = JText::_('COM_CONTENT_CHANGE_ARTICLE') .
' — ' . $this->element['label'];
}
else
{
$modalTitle = JText::_('COM_CONTENT_CHANGE_ARTICLE');
}
$urlSelect = $linkArticles .
'&function=jSelectArticle_' . $this->id;
$urlEdit = $linkArticle .
'&task=article.edit&id=\' +
document.getElementById("' . $this->id .
'_id").value + \'';
$urlNew = $linkArticle . '&task=article.add';
if ($value)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__content'))
->where($db->quoteName('id') . ' = ' . (int)
$value);
$db->setQuery($query);
try
{
$title = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
}
$title = empty($title) ?
JText::_('COM_CONTENT_SELECT_AN_ARTICLE') :
htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// The current article display field.
$html = '<span class="input-append">';
$html .= '<input class="input-medium" id="' .
$this->id . '_name" type="text" value="' .
$title . '" disabled="disabled" size="35"
/>';
// Select article button
if ($allowSelect)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? '
hidden' : '') . '"'
. ' id="' . $this->id . '_select"'
. ' data-toggle="modal"'
. ' data-target="#ModalSelect' . $modalId .
'"'
. ' title="' .
JHtml::tooltipText('COM_CONTENT_CHANGE_ARTICLE') .
'">'
. '<span class="icon-file"
aria-hidden="true"></span> ' .
JText::_('JSELECT')
. '</button>';
}
// New article button
if ($allowNew)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? '
hidden' : '') . '"'
. ' id="' . $this->id . '_new"'
. ' data-toggle="modal"'
. ' data-target="#ModalNew' . $modalId .
'"'
. ' title="' .
JHtml::tooltipText('COM_CONTENT_NEW_ARTICLE') .
'">'
. '<span class="icon-new"
aria-hidden="true"></span> ' .
JText::_('JACTION_CREATE')
. '</button>';
}
// Edit article button
if ($allowEdit)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? '' :
' hidden') . '"'
. ' id="' . $this->id . '_edit"'
. ' data-toggle="modal"'
. ' data-target="#ModalEdit' . $modalId .
'"'
. ' title="' .
JHtml::tooltipText('COM_CONTENT_EDIT_ARTICLE') .
'">'
. '<span class="icon-edit"
aria-hidden="true"></span> ' .
JText::_('JACTION_EDIT')
. '</button>';
}
// Clear article button
if ($allowClear)
{
$html .= '<button'
. ' type="button"'
. ' class="btn' . ($value ? '' : '
hidden') . '"'
. ' id="' . $this->id . '_clear"'
. ' onclick="window.processModalParent(\'' .
$this->id . '\'); return false;">'
. '<span class="icon-remove"
aria-hidden="true"></span>' .
JText::_('JCLEAR')
. '</button>';
}
// Propagate article button
if ($allowPropagate && count($languages) > 2)
{
// Strip off language tag at the end
$tagLength = (int) strlen($this->element['language']);
$callbackFunctionStem = substr("jSelectArticle_" .
$this->id, 0, -$tagLength);
$html .= '<a'
. ' class="btn hasTooltip' . ($value ? '' :
' hidden') . '"'
. ' id="' . $this->id . '_propagate"'
. ' href="#"'
. ' title="' .
JHtml::tooltipText('JGLOBAL_ASSOCIATIONS_PROPAGATE_TIP') .
'"'
. ' onclick="Joomla.propagateAssociation(\'' .
$this->id . '\', \'' . $callbackFunctionStem .
'\');">'
. '<span class="icon-refresh"
aria-hidden="true"></span>' .
JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_BUTTON')
. '</a>';
}
$html .= '</span>';
// Select article modal
if ($allowSelect)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalSelect' . $modalId,
array(
'title' => $modalTitle,
'url' => $urlSelect,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button"
class="btn" data-dismiss="modal">' .
JText::_('JLIB_HTML_BEHAVIOR_CLOSE') .
'</button>',
)
);
}
// New article modal
if ($allowNew)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalNew' . $modalId,
array(
'title' =>
JText::_('COM_CONTENT_NEW_ARTICLE'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlNew,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button"
class="btn"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'add\', \'article\',
\'cancel\', \'item-form\'); return
false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') .
'</button>'
. '<button type="button" class="btn
btn-primary"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'add\', \'article\',
\'save\', \'item-form\'); return false;">'
. JText::_('JSAVE') . '</button>'
. '<button type="button" class="btn
btn-success"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'add\', \'article\',
\'apply\', \'item-form\'); return
false;">'
. JText::_('JAPPLY') . '</button>',
)
);
}
// Edit article modal
if ($allowEdit)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalEdit' . $modalId,
array(
'title' =>
JText::_('COM_CONTENT_EDIT_ARTICLE'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlEdit,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button"
class="btn"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'edit\', \'article\',
\'cancel\', \'item-form\'); return
false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') .
'</button>'
. '<button type="button" class="btn
btn-primary"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'edit\', \'article\',
\'save\', \'item-form\'); return false;">'
. JText::_('JSAVE') . '</button>'
. '<button type="button" class="btn
btn-success"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'edit\', \'article\',
\'apply\', \'item-form\'); return
false;">'
. JText::_('JAPPLY') . '</button>',
)
);
}
// Note: class='required' for client side validation.
$class = $this->required ? ' class="required
modal-value"' : '';
$html .= '<input type="hidden" id="' .
$this->id . '_id" ' . $class . '
data-required="' . (int) $this->required . '"
name="' . $this->name
. '" data-text="' .
htmlspecialchars(JText::_('COM_CONTENT_SELECT_AN_ARTICLE'),
ENT_COMPAT, 'UTF-8') . '" value="' . $value .
'" />';
return $html;
}
/**
* Method to get the field label markup.
*
* @return string The field label markup.
*
* @since 3.4
*/
protected function getLabel()
{
return str_replace($this->id, $this->id . '_id',
parent::getLabel());
}
}
fields/voteradio.php000064400000002147151161622020010517 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('radio');
/**
* Voteradio Field class.
*
* @since 3.8.0
*/
class JFormFieldVoteradio extends JFormFieldRadio
{
/**
* The form field type.
*
* @var string
* @since 3.7.1
*/
protected $type = 'Voteradio';
/**
* Method to get the field Label.
*
* @return array The field label objects.
*
* @throws \Exception
*
* @since 3.8.2
*/
public function getLabel()
{
// Requires vote plugin enabled
return JPluginHelper::isEnabled('content', 'vote') ?
parent::getLabel() : null;
}
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @throws \Exception
*
* @since 3.7.1
*/
public function getOptions()
{
// Requires vote plugin enabled
return JPluginHelper::isEnabled('content', 'vote') ?
parent::getOptions() : array();
}
}
forms/article.xml000064400000055206151161622020010043 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_categories/models/fields"
>
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
class="readonly"
size="10"
default="0"
readonly="true"
/>
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="JFIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER"
size="40"
/>
<field
name="note"
type="text"
label="COM_CONTENT_FIELD_NOTE_LABEL"
description="COM_CONTENT_FIELD_NOTE_DESC"
class="span12"
size="40"
maxlength="255"
/>
<field
name="version_note"
type="text"
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
description="JGLOBAL_FIELD_VERSION_NOTE_DESC"
class="span12"
maxlength="255"
size="45"
/>
<field
name="articletext"
type="editor"
label="COM_CONTENT_FIELD_ARTICLETEXT_LABEL"
description="COM_CONTENT_FIELD_ARTICLETEXT_DESC"
filter="JComponentHelper::filterText"
buttons="true"
/>
<field
name="state"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
class="chzn-color-state"
filter="intval"
size="1"
default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="catid"
type="categoryedit"
label="JCATEGORY"
description="JFIELD_CATEGORY_DESC"
required="true"
default=""
/>
<field
name="tags"
type="tag"
label="JTAG"
description="JTAG_DESC"
class="span12"
multiple="true"
/>
<field
name="buttonspacer"
type="spacer"
description="JGLOBAL_ACTION_PERMISSIONS_DESCRIPTION"
/>
<field
name="created"
type="calendar"
label="COM_CONTENT_FIELD_CREATED_LABEL"
description="COM_CONTENT_FIELD_CREATED_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="created_by"
type="user"
label="COM_CONTENT_FIELD_CREATED_BY_LABEL"
description="COM_CONTENT_FIELD_CREATED_BY_DESC"
/>
<field
name="created_by_alias"
type="text"
label="COM_CONTENT_FIELD_CREATED_BY_ALIAS_LABEL"
description="COM_CONTENT_FIELD_CREATED_BY_ALIAS_DESC"
size="20"
/>
<field
name="modified"
type="calendar"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
description="COM_CONTENT_FIELD_MODIFIED_DESC"
class="readonly"
translateformat="true"
showtime="true"
size="22"
readonly="true"
filter="user_utc"
/>
<field
name="modified_by"
type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="publish_up"
type="calendar"
label="COM_CONTENT_FIELD_PUBLISH_UP_LABEL"
description="COM_CONTENT_FIELD_PUBLISH_UP_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="publish_down"
type="calendar"
label="COM_CONTENT_FIELD_PUBLISH_DOWN_LABEL"
description="COM_CONTENT_FIELD_PUBLISH_DOWN_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="version"
type="text"
label="COM_CONTENT_FIELD_VERSION_LABEL"
description="COM_CONTENT_FIELD_VERSION_DESC"
size="6"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="ordering"
type="text"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
size="6"
default="0"
/>
<field
name="metakey"
type="textarea"
label="JFIELD_META_KEYWORDS_LABEL"
description="JFIELD_META_KEYWORDS_DESC"
rows="3"
cols="30"
/>
<field
name="metadesc"
type="textarea"
label="JFIELD_META_DESCRIPTION_LABEL"
description="JFIELD_META_DESCRIPTION_DESC"
rows="3"
cols="30"
/>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
size="1"
/>
<field
name="hits"
type="number"
label="JGLOBAL_HITS"
description="COM_CONTENT_FIELD_HITS_DESC"
class="readonly"
size="6"
readonly="true"
filter="unset"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_CONTENT_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
<field
name="featured"
type="radio"
label="JFEATURED"
description="COM_CONTENT_FIELD_FEATURED_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="rules"
type="rules"
label="JFIELD_RULES_LABEL"
translate_label="false"
filter="rules"
component="com_content"
section="article"
validate="rules"
/>
</fieldset>
<fields name="attribs"
label="COM_CONTENT_ATTRIBS_FIELDSET_LABEL">
<fieldset name="basic"
label="COM_CONTENT_ATTRIBS_FIELDSET_LABEL">
<field
name="article_layout"
type="componentlayout"
label="JFIELD_ALT_LAYOUT_LABEL"
description="JFIELD_ALT_COMPONENT_LAYOUT_DESC"
useglobal="true"
extension="com_content"
view="article"
/>
<field
name="show_title"
type="list"
label="JGLOBAL_SHOW_TITLE_LABEL"
description="JGLOBAL_SHOW_TITLE_DESC"
class="chzn-color"
useglobal="true"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="link_titles"
type="list"
label="JGLOBAL_LINKED_TITLES_LABEL"
description="JGLOBAL_LINKED_TITLES_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="show_tags"
type="list"
label="COM_CONTENT_FIELD_SHOW_TAGS_LABEL"
description="COM_CONTENT_FIELD_SHOW_TAGS_DESC"
class="chzn-color"
useglobal="true"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="show_intro"
type="list"
label="JGLOBAL_SHOW_INTRO_LABEL"
description="JGLOBAL_SHOW_INTRO_DESC"
class="chzn-color"
useglobal="true"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="info_block_position"
type="list"
label="COM_CONTENT_FIELD_INFOBLOCK_POSITION_LABEL"
description="COM_CONTENT_FIELD_INFOBLOCK_POSITION_DESC"
useglobal="true"
>
<option
value="0">COM_CONTENT_FIELD_OPTION_ABOVE</option>
<option
value="1">COM_CONTENT_FIELD_OPTION_BELOW</option>
<option
value="2">COM_CONTENT_FIELD_OPTION_SPLIT</option>
</field>
<field
name="info_block_show_title"
type="list"
label="COM_CONTENT_FIELD_INFOBLOCK_TITLE_LABEL"
description="COM_CONTENT_FIELD_INFOBLOCK_TITLE_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_category"
type="list"
label="JGLOBAL_SHOW_CATEGORY_LABEL"
description="JGLOBAL_SHOW_CATEGORY_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="link_category"
type="list"
label="JGLOBAL_LINK_CATEGORY_LABEL"
description="JGLOBAL_LINK_CATEGORY_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="show_parent_category"
type="list"
label="JGLOBAL_SHOW_PARENT_CATEGORY_LABEL"
description="JGLOBAL_SHOW_PARENT_CATEGORY_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="link_parent_category"
type="list"
label="JGLOBAL_LINK_PARENT_CATEGORY_LABEL"
description="JGLOBAL_LINK_PARENT_CATEGORY_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="show_associations"
type="list"
label="JGLOBAL_SHOW_ASSOCIATIONS_LABEL"
description="JGLOBAL_SHOW_ASSOCIATIONS_DESC"
class="chzn-color"
useglobal="true"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="show_author"
type="list"
label="JGLOBAL_SHOW_AUTHOR_LABEL"
description="JGLOBAL_SHOW_AUTHOR_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="link_author"
type="list"
label="JGLOBAL_LINK_AUTHOR_LABEL"
description="JGLOBAL_LINK_AUTHOR_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="show_create_date"
type="list"
label="JGLOBAL_SHOW_CREATE_DATE_LABEL"
description="JGLOBAL_SHOW_CREATE_DATE_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_modify_date"
type="list"
label="JGLOBAL_SHOW_MODIFY_DATE_LABEL"
description="JGLOBAL_SHOW_MODIFY_DATE_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_publish_date"
type="list"
label="JGLOBAL_SHOW_PUBLISH_DATE_LABEL"
description="JGLOBAL_SHOW_PUBLISH_DATE_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_item_navigation"
type="list"
label="JGLOBAL_SHOW_NAVIGATION_LABEL"
description="JGLOBAL_SHOW_NAVIGATION_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_icons"
type="list"
label="JGLOBAL_SHOW_ICONS_LABEL"
description="JGLOBAL_SHOW_ICONS_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_print_icon"
type="list"
label="JGLOBAL_SHOW_PRINT_ICON_LABEL"
description="JGLOBAL_SHOW_PRINT_ICON_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_email_icon"
type="list"
label="JGLOBAL_SHOW_EMAIL_ICON_LABEL"
description="JGLOBAL_SHOW_EMAIL_ICON_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_vote"
type="list"
label="JGLOBAL_SHOW_VOTE_LABEL"
description="JGLOBAL_SHOW_VOTE_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_hits"
type="list"
label="JGLOBAL_SHOW_HITS_LABEL"
description="JGLOBAL_SHOW_HITS_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_noauth"
type="list"
label="JGLOBAL_SHOW_UNAUTH_LINKS_LABEL"
description="JGLOBAL_SHOW_UNAUTH_LINKS_DESC"
useglobal="true"
class="chzn-color"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="urls_position"
type="list"
label="COM_CONTENT_FIELD_URLSPOSITION_LABEL"
description="COM_CONTENT_FIELD_URLSPOSITION_DESC"
useglobal="true"
class="chzn-color"
>
<option
value="0">COM_CONTENT_FIELD_OPTION_ABOVE</option>
<option
value="1">COM_CONTENT_FIELD_OPTION_BELOW</option>
</field>
<field
name="spacer2"
type="spacer"
hr="true"
/>
<field
name="alternative_readmore"
type="text"
label="JFIELD_READMORE_LABEL"
description="JFIELD_READMORE_DESC"
size="25"
/>
<field
name="article_page_title"
type="text"
label="COM_CONTENT_FIELD_BROWSER_PAGE_TITLE_LABEL"
description="COM_CONTENT_FIELD_BROWSER_PAGE_TITLE_DESC"
size="25"
/>
</fieldset>
<fieldset name="editorConfig"
label="COM_CONTENT_EDITORCONFIG_FIELDSET_LABEL">
<field
name="show_publishing_options"
type="list"
label="COM_CONTENT_SHOW_PUBLISHING_OPTIONS_LABEL"
description="COM_CONTENT_SHOW_PUBLISHING_OPTIONS_DESC"
default=""
useglobal="true"
class="chzn-color"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="show_article_options"
type="list"
label="COM_CONTENT_SHOW_ARTICLE_OPTIONS_LABEL"
description="COM_CONTENT_SHOW_ARTICLE_OPTIONS_DESC"
default=""
useglobal="true"
class="chzn-color"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="show_urls_images_backend"
type="list"
label="COM_CONTENT_SHOW_IMAGES_URLS_BACK_LABEL"
description="COM_CONTENT_SHOW_IMAGES_URLS_BACK_DESC"
useglobal="true"
class="chzn-color"
default=""
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="show_urls_images_frontend"
type="list"
label="COM_CONTENT_SHOW_IMAGES_URLS_FRONT_LABEL"
description="COM_CONTENT_SHOW_IMAGES_URLS_FRONT_DESC"
useglobal="true"
class="chzn-color"
default=""
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
<fieldset name="basic-limited"
label="COM_CONTENT_ATTRIBS_FIELDSET_LABEL">
<field
name="show_title"
type="hidden"
label="JGLOBAL_SHOW_TITLE_LABEL"
description="JGLOBAL_SHOW_TITLE_DESC"
/>
<field
name="link_titles"
type="hidden"
label="JGLOBAL_LINKED_TITLES_LABEL"
description="JGLOBAL_LINKED_TITLES_DESC"
/>
<field
name="show_intro"
type="hidden"
label="JGLOBAL_SHOW_INTRO_LABEL"
description="JGLOBAL_SHOW_INTRO_DESC"
/>
<field
name="show_category"
type="hidden"
label="JGLOBAL_SHOW_CATEGORY_LABEL"
description="JGLOBAL_SHOW_CATEGORY_DESC"
/>
<field
name="link_category"
type="hidden"
label="JGLOBAL_LINK_CATEGORY_LABEL"
description="JGLOBAL_LINK_CATEGORY_DESC"
/>
<field
name="show_parent_category"
type="hidden"
label="JGLOBAL_SHOW_PARENT_CATEGORY_LABEL"
description="JGLOBAL_SHOW_PARENT_CATEGORY_DESC"
/>
<field
name="link_parent_category"
type="hidden"
label="JGLOBAL_LINK_PARENT_CATEGORY_LABEL"
description="JGLOBAL_LINK_PARENT_CATEGORY_DESC"
/>
<field
name="show_author"
type="hidden"
label="JGLOBAL_SHOW_AUTHOR_LABEL"
description="JGLOBAL_SHOW_AUTHOR_DESC"
/>
<field
name="link_author"
type="hidden"
label="JGLOBAL_LINK_AUTHOR_LABEL"
description="JGLOBAL_LINK_AUTHOR_DESC"
/>
<field
name="show_create_date"
type="hidden"
label="JGLOBAL_SHOW_CREATE_DATE_LABEL"
description="JGLOBAL_SHOW_CREATE_DATE_DESC"
/>
<field
name="show_modify_date"
type="hidden"
label="JGLOBAL_SHOW_MODIFY_DATE_LABEL"
description="JGLOBAL_SHOW_MODIFY_DATE_DESC"
/>
<field
name="show_publish_date"
type="hidden"
label="JGLOBAL_SHOW_PUBLISH_DATE_LABEL"
description="JGLOBAL_SHOW_PUBLISH_DATE_DESC"
/>
<field
name="show_item_navigation"
type="hidden"
label="JGLOBAL_SHOW_NAVIGATION_LABEL"
description="JGLOBAL_SHOW_NAVIGATION_DESC"
/>
<field
name="show_icons"
type="hidden"
label="JGLOBAL_SHOW_ICONS_LABEL"
description="JGLOBAL_SHOW_ICONS_DESC"
/>
<field
name="show_print_icon"
type="hidden"
label="JGLOBAL_SHOW_PRINT_ICON_LABEL"
description="JGLOBAL_SHOW_PRINT_ICON_DESC"
/>
<field
name="show_email_icon"
type="hidden"
label="JGLOBAL_SHOW_EMAIL_ICON_LABEL"
description="JGLOBAL_SHOW_EMAIL_ICON_DESC"
/>
<field
name="show_vote"
type="hidden"
label="JGLOBAL_SHOW_VOTE_LABEL"
description="JGLOBAL_SHOW_VOTE_DESC"
/>
<field
name="show_hits"
type="hidden"
label="JGLOBAL_SHOW_HITS_LABEL"
description="JGLOBAL_SHOW_HITS_DESC"
/>
<field
name="show_noauth"
type="hidden"
label="JGLOBAL_SHOW_UNAUTH_LINKS_LABEL"
description="JGLOBAL_SHOW_UNAUTH_LINKS_DESC"
/>
<field
name="alternative_readmore"
type="hidden"
label="JFIELD_READMORE_LABEL"
description="JFIELD_READMORE_DESC"
size="25"
/>
<field
name="article_layout"
type="hidden"
label="JFIELD_ALT_LAYOUT_LABEL"
description="JFIELD_ALT_COMPONENT_LAYOUT_DESC"
useglobal="true"
extension="com_content" view="article"
/>
</fieldset>
</fields>
<field
name="xreference"
type="text"
label="JFIELD_KEY_REFERENCE_LABEL"
description="JFIELD_KEY_REFERENCE_DESC"
size="20"
/>
<fields name="images"
label="COM_CONTENT_FIELD_IMAGE_OPTIONS">
<field
name="image_intro"
type="media"
label="COM_CONTENT_FIELD_INTRO_LABEL"
description="COM_CONTENT_FIELD_INTRO_DESC"
/>
<field
name="float_intro"
type="list"
label="COM_CONTENT_FLOAT_LABEL"
description="COM_CONTENT_FLOAT_DESC"
useglobal="true"
>
<option value="right">COM_CONTENT_RIGHT</option>
<option value="left">COM_CONTENT_LEFT</option>
<option value="none">COM_CONTENT_NONE</option>
</field>
<field
name="image_intro_alt"
type="text"
label="COM_CONTENT_FIELD_IMAGE_ALT_LABEL"
description="COM_CONTENT_FIELD_IMAGE_ALT_DESC"
size="20"
/>
<field
name="image_intro_caption"
type="text"
label="COM_CONTENT_FIELD_IMAGE_CAPTION_LABEL"
description="COM_CONTENT_FIELD_IMAGE_CAPTION_DESC"
size="20"
/>
<field
name="spacer1"
type="spacer"
hr="true"
/>
<field
name="image_fulltext"
type="media"
label="COM_CONTENT_FIELD_FULL_LABEL"
description="COM_CONTENT_FIELD_FULL_DESC"
/>
<field
name="float_fulltext"
type="list"
label="COM_CONTENT_FLOAT_LABEL"
description="COM_CONTENT_FLOAT_DESC"
useglobal="true"
>
<option value="right">COM_CONTENT_RIGHT</option>
<option value="left">COM_CONTENT_LEFT</option>
<option value="none">COM_CONTENT_NONE</option>
</field>
<field
name="image_fulltext_alt"
type="text"
label="COM_CONTENT_FIELD_IMAGE_ALT_LABEL"
description="COM_CONTENT_FIELD_IMAGE_ALT_DESC"
size="20"
/>
<field
name="image_fulltext_caption"
type="text"
label="COM_CONTENT_FIELD_IMAGE_CAPTION_LABEL"
description="COM_CONTENT_FIELD_IMAGE_CAPTION_DESC"
size="20"
/>
</fields>
<fields name="urls"
label="COM_CONTENT_FIELD_URLS_OPTIONS">
<field
name="urla"
type="url"
label="COM_CONTENT_FIELD_URLA_LABEL"
description="COM_CONTENT_FIELD_URL_DESC"
validate="url"
filter="url"
relative="true"
/>
<field
name="urlatext"
type="text"
label="COM_CONTENT_FIELD_URLA_LINK_TEXT_LABEL"
description="COM_CONTENT_FIELD_URL_LINK_TEXT_DESC"
size="20"
/>
<field
name="targeta"
type="list"
label="COM_CONTENT_URL_FIELD_BROWSERNAV_LABEL"
description="COM_CONTENT_URL_FIELD_BROWSERNAV_DESC"
default=""
filter="options"
useglobal="true"
>
<option value="0">JBROWSERTARGET_PARENT</option>
<option value="1">JBROWSERTARGET_NEW</option>
<option value="2">JBROWSERTARGET_POPUP</option>
<option value="3">JBROWSERTARGET_MODAL</option>
</field>
<field
name="spacer3"
type="spacer"
hr="true"
/>
<field
name="urlb"
type="url"
label="COM_CONTENT_FIELD_URLB_LABEL"
description="COM_CONTENT_FIELD_URL_DESC"
validate="url"
filter="url"
relative="true"
/>
<field
name="urlbtext"
type="text"
label="COM_CONTENT_FIELD_URLB_LINK_TEXT_LABEL"
description="COM_CONTENT_FIELD_URL_LINK_TEXT_DESC"
size="20"
/>
<field
name="targetb"
type="list"
label="COM_CONTENT_URL_FIELD_BROWSERNAV_LABEL"
description="COM_CONTENT_URL_FIELD_BROWSERNAV_DESC"
default=""
filter="options"
useglobal="true"
>
<option value="0">JBROWSERTARGET_PARENT</option>
<option value="1">JBROWSERTARGET_NEW</option>
<option value="2">JBROWSERTARGET_POPUP</option>
<option value="3">JBROWSERTARGET_MODAL</option>
</field>
<field
name="spacer4"
type="spacer"
hr="true"
/>
<field
name="urlc"
type="url"
label="COM_CONTENT_FIELD_URLC_LABEL"
description="COM_CONTENT_FIELD_URL_DESC"
validate="url"
filter="url"
relative="true"
/>
<field
name="urlctext"
type="text"
label="COM_CONTENT_FIELD_URLC_LINK_TEXT_LABEL"
description="COM_CONTENT_FIELD_URL_LINK_TEXT_DESC"
size="20"
/>
<field
name="targetc"
type="list"
label="COM_CONTENT_URL_FIELD_BROWSERNAV_LABEL"
description="COM_CONTENT_URL_FIELD_BROWSERNAV_DESC"
default=""
filter="options"
useglobal="true"
>
<option value="0">JBROWSERTARGET_PARENT</option>
<option value="1">JBROWSERTARGET_NEW</option>
<option value="2">JBROWSERTARGET_POPUP</option>
<option value="3">JBROWSERTARGET_MODAL</option>
</field>
</fields>
<fields name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<fieldset name="jmetadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<field
name="robots"
type="list"
label="JFIELD_METADATA_ROBOTS_LABEL"
description="JFIELD_METADATA_ROBOTS_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="index, follow"></option>
<option value="noindex, follow"></option>
<option value="index, nofollow"></option>
<option value="noindex, nofollow"></option>
</field>
<field
name="author"
type="text"
label="JAUTHOR"
description="JFIELD_METADATA_AUTHOR_DESC"
size="20"
/>
<field
name="rights"
type="textarea"
label="JFIELD_META_RIGHTS_LABEL"
description="JFIELD_META_RIGHTS_DESC"
filter="string"
cols="30"
rows="2"
/>
<field
name="xreference"
type="text"
label="COM_CONTENT_FIELD_XREFERENCE_LABEL"
description="COM_CONTENT_FIELD_XREFERENCE_DESC"
size="20"
/>
</fieldset>
</fields>
<!-- These fields are used to get labels for the Content History
Preview and Compare Views -->
<fields>
<field
name="introtext"
label="COM_CONTENT_FIELD_INTROTEXT"
/>
<field
name="fulltext"
label="COM_CONTENT_FIELD_FULLTEXT"
/>
</fields>
</form>
forms/filter_articles.xml000064400000011366151161622020011572
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_CONTENT_FILTER_SEARCH_LABEL"
description="COM_CONTENT_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
label="COM_CONTENT_FILTER_PUBLISHED"
description="COM_CONTENT_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
multiple="true"
class="multipleCategories"
extension="com_content"
onchange="this.form.submit();"
published="0,1,2"
/>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<field
name="author_id"
type="author"
label="COM_CONTENT_FILTER_AUTHOR"
description="COM_CONTENT_FILTER_AUTHOR_DESC"
multiple="true"
class="multipleAuthors"
onchange="this.form.submit();"
>
<option value="0">JNONE</option>
</field>
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
<field
name="tag"
type="tag"
label="JOPTION_FILTER_TAG"
description="JOPTION_FILTER_TAG_DESC"
multiple="true"
class="multipleTags"
mode="nested"
onchange="this.form.submit();"
/>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.featured
ASC">JFEATURED_ASC</option>
<option value="a.featured
DESC">JFEATURED_DESC</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="category_title
ASC">JCATEGORY_ASC</option>
<option value="category_title
DESC">JCATEGORY_DESC</option>
<option value="a.access
ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="a.access
DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="association ASC"
requires="associations">JASSOCIATIONS_ASC</option>
<option value="association DESC"
requires="associations">JASSOCIATIONS_DESC</option>
<option value="a.created_by
ASC">JAUTHOR_ASC</option>
<option value="a.created_by
DESC">JAUTHOR_DESC</option>
<option value="language
ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="language
DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.created ASC">JDATE_ASC</option>
<option value="a.created DESC">JDATE_DESC</option>
<option value="a.modified
ASC">COM_CONTENT_MODIFIED_ASC</option>
<option value="a.modified
DESC">COM_CONTENT_MODIFIED_DESC</option>
<option value="a.publish_up
ASC">COM_CONTENT_PUBLISH_UP_ASC</option>
<option value="a.publish_up
DESC">COM_CONTENT_PUBLISH_UP_DESC</option>
<option value="a.publish_down
ASC">COM_CONTENT_PUBLISH_DOWN_ASC</option>
<option value="a.publish_down
DESC">COM_CONTENT_PUBLISH_DOWN_DESC</option>
<option value="a.hits
ASC">JGLOBAL_HITS_ASC</option>
<option value="a.hits
DESC">JGLOBAL_HITS_DESC</option>
<option value="rating_count ASC"
requires="vote">JGLOBAL_VOTES_ASC</option>
<option value="rating_count DESC"
requires="vote">JGLOBAL_VOTES_DESC</option>
<option value="rating ASC"
requires="vote">JGLOBAL_RATINGS_ASC</option>
<option value="rating DESC"
requires="vote">JGLOBAL_RATINGS_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_featured.xml000064400000010400151161622020011547
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_CONTENT_FILTER_SEARCH_LABEL"
description="COM_CONTENT_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
label="COM_CONTENT_FILTER_PUBLISHED"
description="COM_CONTENT_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
multiple="true"
class="multipleCategories"
extension="com_content"
onchange="this.form.submit();"
/>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<field
name="author_id"
type="author"
label="COM_CONTENT_FILTER_AUTHOR"
description="COM_CONTENT_FILTER_AUTHOR_DESC"
multiple="true"
class="multipleAuthors"
onchange="this.form.submit();"
>
<option value="0">JNONE</option>
</field>
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
<field
name="tag"
type="tag"
label="JOPTION_FILTER_TAG"
description="JOPTION_FILTER_TAG_DESC"
multiple="true"
class="multipleTags"
mode="nested"
onchange="this.form.submit();"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.title ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="fp.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="fp.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="category_title
ASC">JCATEGORY_ASC</option>
<option value="category_title
DESC">JCATEGORY_DESC</option>
<option value="a.access
ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="a.access
DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="a.created_by
ASC">JAUTHOR_ASC</option>
<option value="a.created_by
DESC">JAUTHOR_DESC</option>
<option value="a.publish_up
ASC">COM_CONTENT_PUBLISH_UP_ASC</option>
<option value="a.publish_up
DESC">COM_CONTENT_PUBLISH_UP_DESC</option>
<option value="a.publish_down
ASC">COM_CONTENT_PUBLISH_DOWN_ASC</option>
<option value="a.publish_down
DESC">COM_CONTENT_PUBLISH_DOWN_DESC</option>
<option value="language
ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="language
DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.created ASC">JDATE_ASC</option>
<option value="a.created DESC">JDATE_DESC</option>
<option value="a.hits
ASC">JGLOBAL_HITS_ASC</option>
<option value="a.hits
DESC">JGLOBAL_HITS_DESC</option>
<option value="rating_count ASC"
requires="vote">JGLOBAL_VOTES_ASC</option>
<option value="rating_count DESC"
requires="vote">JGLOBAL_VOTES_DESC</option>
<option value="rating ASC"
requires="vote">JGLOBAL_RATINGS_ASC</option>
<option value="rating DESC"
requires="vote">JGLOBAL_RATINGS_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
fields/templatelocation.php000064400000001625151162110670012073
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR .
'/components/com_templates/helpers/templates.php');
JFormHelper::loadFieldClass('list');
/**
* Template Location field.
*
* @since 3.5
*/
class JFormFieldTemplateLocation extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
protected $type = 'TemplateLocation';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.5
*/
public function getOptions()
{
$options = TemplatesHelper::getClientOptions();
return array_merge(parent::getOptions(), $options);
}
}
fields/templatename.php000064400000002240151162110670011175
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR .
'/components/com_templates/helpers/templates.php');
JFormHelper::loadFieldClass('list');
/**
* Template Name field.
*
* @since 3.5
*/
class JFormFieldTemplateName extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
protected $type = 'TemplateName';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.6
*/
public function getOptions()
{
// Get the client_id filter from the user state.
$clientId =
JFactory::getApplication()->getUserStateFromRequest('com_templates.styles.client_id',
'client_id', '0', 'string');
// Get the templates for the selected client_id.
$options = TemplatesHelper::getTemplateOptions($clientId);
// Merge into the parent options.
return array_merge(parent::getOptions(), $options);
}
}
forms/filter_styles.xml000064400000004213151162110670011304
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_templates/models/fields"
/>
<field
name="client_id"
type="list"
filtermode="selector"
onchange="jQuery('#filter_search, select[id^=filter_],
#list_fullordering').val('');this.form.submit();"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
</field>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="JSEARCH_FILTER"
description="COM_TEMPLATES_STYLES_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
noresults="COM_TEMPLATES_MSG_MANAGE_NO_STYLES"
/>
<field
name="menuitem"
type="menuitem"
label="COM_TEMPLATES_OPTION_SELECT_MENU_ITEM"
disable="separator,alias,heading,url"
showon="client_id:0"
onchange="this.form.submit();"
>
<option value="">COM_TEMPLATES_OPTION_SELECT_MENU_ITEM</option>
<option value="-1">COM_TEMPLATES_OPTION_NONE</option>
</field>
<field
name="template"
type="templatename"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_TEMPLATE</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.template ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.title
ASC">COM_TEMPLATES_HEADING_STYLE_ASC</option>
<option value="a.title
DESC">COM_TEMPLATES_HEADING_STYLE_DESC</option>
<option value="a.home
ASC">COM_TEMPLATES_HEADING_DEFAULT_ASC</option>
<option value="a.home
DESC">COM_TEMPLATES_HEADING_DEFAULT_DESC</option>
<option value="a.template
ASC">COM_TEMPLATES_HEADING_TEMPLATE_ASC</option>
<option value="a.template
DESC">COM_TEMPLATES_HEADING_TEMPLATE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_templates.xml000064400000002406151162110670011761
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_templates/models/fields"
/>
<field
name="client_id"
type="list"
filtermode="selector"
onchange="jQuery('#filter_search, select[id^=filter_],
#list_fullordering').val('');this.form.submit();"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
</field>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="JSEARCH_FILTER"
description="COM_TEMPLATES_TEMPLATES_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
noresults="COM_TEMPLATES_MSG_MANAGE_NO_TEMPLATES"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.element ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.element
ASC">COM_TEMPLATES_HEADING_TEMPLATE_ASC</option>
<option value="a.element
DESC">COM_TEMPLATES_HEADING_TEMPLATE_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/source.xml000064400000000701151162110670007712 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="extension_id"
type="hidden"
/>
<field
name="filename"
type="hidden"
/>
<field
name="source"
type="editor"
label="COM_TEMPLATES_FIELD_SOURCE_LABEL"
description="COM_TEMPLATES_FIELD_SOURCE_DESC"
editor="codemirror|none"
buttons="no"
height="500px"
rows="20"
cols="80"
syntax="php"
filter="raw"
/>
</fieldset>
</form>
forms/style.xml000064400000001637151162110670007563 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
id="id"
default="0"
readonly="true"
class="readonly"
/>
<field
name="template"
type="text"
label="COM_TEMPLATES_FIELD_TEMPLATE_LABEL"
description="COM_TEMPLATES_FIELD_TEMPLATE_DESC"
class="readonly"
size="30"
readonly="true"
/>
<field
name="client_id"
type="hidden"
label="COM_TEMPLATES_FIELD_CLIENT_LABEL"
description="COM_TEMPLATES_FIELD_CLIENT_DESC"
class="readonly"
default="0"
readonly="true"
/>
<field
name="title"
type="text"
label="COM_TEMPLATES_FIELD_TITLE_LABEL"
description="COM_TEMPLATES_FIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="50"
required="true"
/>
<field
name="assigned"
type="hidden"
/>
</fieldset>
</form>
forms/style_administrator.xml000064400000000547151162110670012522
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="home"
type="radio"
label="COM_TEMPLATES_FIELD_HOME_LABEL"
description="COM_TEMPLATES_FIELD_HOME_ADMINISTRATOR_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</form>
forms/style_site.xml000064400000000503151162110670010576 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="home"
type="contentlanguage"
label="COM_TEMPLATES_FIELD_HOME_LABEL"
description="COM_TEMPLATES_FIELD_HOME_SITE_DESC"
default="0"
>
<option value="0">JNO</option>
<option value="1">JALL</option>
</field>
</fieldset>
</form>
style.php000064400000043375151162110670006431 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Template style model.
*
* @since 1.6
*/
class TemplatesModelStyle extends JModelAdmin
{
/**
* The help screen key for the module.
*
* @var string
* @since 1.6
*/
protected $helpKey =
'JHELP_EXTENSIONS_TEMPLATE_MANAGER_STYLES_EDIT';
/**
* The help screen base URL for the module.
*
* @var string
* @since 1.6
*/
protected $helpURL;
/**
* Item cache.
*
* @var array
* @since 1.6
*/
private $_cache = array();
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*/
public function __construct($config = array())
{
$config = array_merge(
array(
'event_before_delete' =>
'onExtensionBeforeDelete',
'event_after_delete' =>
'onExtensionAfterDelete',
'event_before_save' =>
'onExtensionBeforeSave',
'event_after_save' => 'onExtensionAfterSave',
'events_map' => array('delete' =>
'extension', 'save' => 'extension')
), $config
);
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* @note Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication('administrator');
// Load the User state.
$pk = $app->input->getInt('id');
$this->setState('style.id', $pk);
// Load the parameters.
$params = JComponentHelper::getParams('com_templates');
$this->setState('params', $params);
}
/**
* Method to delete rows.
*
* @param array &$pks An array of item ids.
*
* @return boolean Returns true on success, false on failure.
*
* @since 1.6
* @throws Exception
*/
public function delete(&$pks)
{
$pks = (array) $pks;
$user = JFactory::getUser();
$table = $this->getTable();
$dispatcher = JEventDispatcher::getInstance();
$context = $this->option . '.' . $this->name;
JPluginHelper::importPlugin($this->events_map['delete']);
// Iterate the items to delete each one.
foreach ($pks as $pk)
{
if ($table->load($pk))
{
// Access checks.
if (!$user->authorise('core.delete',
'com_templates'))
{
throw new
Exception(JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
}
// You should not delete a default style
if ($table->home != '0')
{
JError::raiseWarning(500,
JText::_('COM_TEMPLATES_STYLE_CANNOT_DELETE_DEFAULT_STYLE'));
return false;
}
// Trigger the before delete event.
$result = $dispatcher->trigger($this->event_before_delete,
array($context, $table));
if (in_array(false, $result, true) || !$table->delete($pk))
{
$this->setError($table->getError());
return false;
}
// Trigger the after delete event.
$dispatcher->trigger($this->event_after_delete, array($context,
$table));
}
else
{
$this->setError($table->getError());
return false;
}
}
// Clean cache
$this->cleanCache();
return true;
}
/**
* Method to duplicate styles.
*
* @param array &$pks An array of primary key IDs.
*
* @return boolean True if successful.
*
* @throws Exception
*/
public function duplicate(&$pks)
{
$user = JFactory::getUser();
// Access checks.
if (!$user->authorise('core.create',
'com_templates'))
{
throw new
Exception(JText::_('JERROR_CORE_CREATE_NOT_PERMITTED'));
}
$dispatcher = JEventDispatcher::getInstance();
$context = $this->option . '.' . $this->name;
// Include the plugins for the save events.
JPluginHelper::importPlugin($this->events_map['save']);
$table = $this->getTable();
foreach ($pks as $pk)
{
if ($table->load($pk, true))
{
// Reset the id to create a new record.
$table->id = 0;
// Reset the home (don't want dupes of that field).
$table->home = 0;
// Alter the title.
$m = null;
$table->title = $this->generateNewTitle(null, null,
$table->title);
if (!$table->check())
{
throw new Exception($table->getError());
}
// Trigger the before save event.
$result = $dispatcher->trigger($this->event_before_save,
array($context, &$table, true));
if (in_array(false, $result, true) || !$table->store())
{
throw new Exception($table->getError());
}
// Trigger the after save event.
$dispatcher->trigger($this->event_after_save, array($context,
&$table, true));
}
else
{
throw new Exception($table->getError());
}
}
// Clean cache
$this->cleanCache();
return true;
}
/**
* Method to change the title.
*
* @param integer $categoryId The id of the category.
* @param string $alias The alias.
* @param string $title The title.
*
* @return string New title.
*
* @since 1.7.1
*/
protected function generateNewTitle($categoryId, $alias, $title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
/**
* Method to get the record form.
*
* @param array $data An optional array of data for the form to
interrogate.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// The folder and element vars are passed when saving the form.
if (empty($data))
{
$item = $this->getItem();
$clientId = $item->client_id;
$template = $item->template;
}
else
{
$clientId = ArrayHelper::getValue($data, 'client_id');
$template = ArrayHelper::getValue($data, 'template');
}
// Add the default fields directory
$baseFolder = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE;
JForm::addFieldPath($baseFolder . '/templates/' . $template .
'/field');
// These variables are used to add data from the plugin XML files.
$this->setState('item.client_id', $clientId);
$this->setState('item.template', $template);
// Get the form.
$form = $this->loadForm('com_templates.style',
'style', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Modify the form based on access controls.
if (!$this->canEditState((object) $data))
{
// Disable fields for display.
$form->setFieldAttribute('home', 'disabled',
'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('home', 'filter',
'unset');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_templates.edit.style.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_templates.style', $data);
return $data;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($pk = null)
{
$pk = (!empty($pk)) ? $pk : (int)
$this->getState('style.id');
if (!isset($this->_cache[$pk]))
{
// Get a row instance.
$table = $this->getTable();
// Attempt to load the row.
$return = $table->load($pk);
// Check for a table object error.
if ($return === false && $table->getError())
{
$this->setError($table->getError());
return false;
}
// Convert to the JObject before adding other data.
$properties = $table->getProperties(1);
$this->_cache[$pk] = ArrayHelper::toObject($properties,
'JObject');
// Convert the params field to an array.
$registry = new Registry($table->params);
$this->_cache[$pk]->params = $registry->toArray();
// Get the template XML.
$client = JApplicationHelper::getClientInfo($table->client_id);
$path = JPath::clean($client->path . '/templates/' .
$table->template . '/templateDetails.xml');
if (file_exists($path))
{
$this->_cache[$pk]->xml = simplexml_load_file($path);
}
else
{
$this->_cache[$pk]->xml = null;
}
}
return $this->_cache[$pk];
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*/
public function getTable($type = 'Style', $prefix =
'TemplatesTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to allow derived classes to preprocess the form.
*
* @param JForm $form A JForm object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @since 1.6
* @throws Exception if there is an error in the form event.
*/
protected function preprocessForm(JForm $form, $data, $group =
'content')
{
$clientId = $this->getState('item.client_id');
$template = $this->getState('item.template');
$lang = JFactory::getLanguage();
$client = JApplicationHelper::getClientInfo($clientId);
if (!$form->loadFile('style_' . $client->name, true))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
jimport('joomla.filesystem.path');
$formFile = JPath::clean($client->path . '/templates/' .
$template . '/templateDetails.xml');
// Load the core and/or local language file(s).
$lang->load('tpl_' . $template, $client->path, null,
false, true)
|| $lang->load('tpl_' . $template, $client->path .
'/templates/' . $template, null, false, true);
if (file_exists($formFile))
{
// Get the template form.
if (!$form->loadFile($formFile, false, '//config'))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
}
// Disable home field if it is default style
if ((is_array($data) && array_key_exists('home', $data)
&& $data['home'] == '1')
|| (is_object($data) && isset($data->home) &&
$data->home == '1'))
{
$form->setFieldAttribute('home', 'readonly',
'true');
}
// Attempt to load the xml file.
if (!$xml = simplexml_load_file($formFile))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
// Get the help data from the XML file if present.
$help = $xml->xpath('/extension/help');
if (!empty($help))
{
$helpKey = trim((string) $help[0]['key']);
$helpURL = trim((string) $help[0]['url']);
$this->helpKey = $helpKey ?: $this->helpKey;
$this->helpURL = $helpURL ?: $this->helpURL;
}
// Trigger the default form events.
parent::preprocessForm($form, $data, $group);
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*/
public function save($data)
{
// Detect disabled extension
$extension = JTable::getInstance('Extension');
if ($extension->load(array('enabled' => 0,
'type' => 'template', 'element' =>
$data['template'], 'client_id' =>
$data['client_id'])))
{
$this->setError(JText::_('COM_TEMPLATES_ERROR_SAVE_DISABLED_TEMPLATE'));
return false;
}
$app = JFactory::getApplication();
$dispatcher = JEventDispatcher::getInstance();
$table = $this->getTable();
$pk = (!empty($data['id'])) ? $data['id'] :
(int) $this->getState('style.id');
$isNew = true;
// Include the extension plugins for the save events.
JPluginHelper::importPlugin($this->events_map['save']);
// Load the row if saving an existing record.
if ($pk > 0)
{
$table->load($pk);
$isNew = false;
}
if ($app->input->get('task') == 'save2copy')
{
$data['title'] = $this->generateNewTitle(null, null,
$data['title']);
$data['home'] = 0;
$data['assigned'] = '';
}
// Bind the data.
if (!$table->bind($data))
{
$this->setError($table->getError());
return false;
}
// Prepare the row for saving
$this->prepareTable($table);
// Check the data.
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Trigger the before save event.
$result = $dispatcher->trigger($this->event_before_save,
array('com_templates.style', &$table, $isNew));
// Store the data.
if (in_array(false, $result, true) || !$table->store())
{
$this->setError($table->getError());
return false;
}
$user = JFactory::getUser();
if ($user->authorise('core.edit', 'com_menus')
&& $table->client_id == 0)
{
$n = 0;
$db = $this->getDbo();
$user = JFactory::getUser();
if (!empty($data['assigned']) &&
is_array($data['assigned']))
{
$data['assigned'] =
ArrayHelper::toInteger($data['assigned']);
// Update the mapping for menu items that this style IS assigned to.
$query = $db->getQuery(true)
->update('#__menu')
->set('template_style_id = ' . (int) $table->id)
->where('id IN (' . implode(',',
$data['assigned']) . ')')
->where('template_style_id != ' . (int) $table->id)
->where('checked_out IN (0,' . (int) $user->id .
')');
$db->setQuery($query);
$db->execute();
$n += $db->getAffectedRows();
}
// Remove style mappings for menu items this style is NOT assigned to.
// If unassigned then all existing maps will be removed.
$query = $db->getQuery(true)
->update('#__menu')
->set('template_style_id = 0');
if (!empty($data['assigned']))
{
$query->where('id NOT IN (' . implode(',',
$data['assigned']) . ')');
}
$query->where('template_style_id = ' . (int) $table->id)
->where('checked_out IN (0,' . (int) $user->id .
')');
$db->setQuery($query);
$db->execute();
$n += $db->getAffectedRows();
if ($n > 0)
{
$app->enqueueMessage(JText::plural('COM_TEMPLATES_MENU_CHANGED',
$n));
}
}
// Clean the cache.
$this->cleanCache();
// Trigger the after save event.
$dispatcher->trigger($this->event_after_save,
array('com_templates.style', &$table, $isNew));
$this->setState('style.id', $table->id);
return true;
}
/**
* Method to set a template style as home.
*
* @param integer $id The primary key ID for the style.
*
* @return boolean True if successful.
*
* @throws Exception
*/
public function setHome($id = 0)
{
$user = JFactory::getUser();
$db = $this->getDbo();
// Access checks.
if (!$user->authorise('core.edit.state',
'com_templates'))
{
throw new
Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
$style = JTable::getInstance('Style',
'TemplatesTable');
if (!$style->load((int) $id))
{
throw new
Exception(JText::_('COM_TEMPLATES_ERROR_STYLE_NOT_FOUND'));
}
// Detect disabled extension
$extension = JTable::getInstance('Extension');
if ($extension->load(array('enabled' => 0,
'type' => 'template', 'element' =>
$style->template, 'client_id' => $style->client_id)))
{
throw new
Exception(JText::_('COM_TEMPLATES_ERROR_SAVE_DISABLED_TEMPLATE'));
}
// Reset the home fields for the client_id.
$query = $db->getQuery(true)
->update('#__template_styles')
->set('home = ' . $db->q('0'))
->where('client_id = ' . (int) $style->client_id)
->where('home = ' . $db->q('1'));
$db->setQuery($query);
$db->execute();
// Set the new home style.
$query = $db->getQuery(true)
->update('#__template_styles')
->set('home = ' . $db->q('1'))
->where('id = ' . (int) $id);
$db->setQuery($query);
$db->execute();
// Clean the cache.
$this->cleanCache();
return true;
}
/**
* Method to unset a template style as default for a language.
*
* @param integer $id The primary key ID for the style.
*
* @return boolean True if successful.
*
* @throws Exception
*/
public function unsetHome($id = 0)
{
$user = JFactory::getUser();
$db = $this->getDbo();
// Access checks.
if (!$user->authorise('core.edit.state',
'com_templates'))
{
throw new
Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
// Lookup the client_id.
$query = $db->getQuery(true)
->select('client_id, home')
->from('#__template_styles')
->where('id = ' . (int) $id);
$db->setQuery($query);
$style = $db->loadObject();
if (!is_numeric($style->client_id))
{
throw new
Exception(JText::_('COM_TEMPLATES_ERROR_STYLE_NOT_FOUND'));
}
elseif ($style->home == '1')
{
throw new
Exception(JText::_('COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE'));
}
// Set the new home style.
$query = $db->getQuery(true)
->update('#__template_styles')
->set('home = ' . $db->q('0'))
->where('id = ' . (int) $id);
$db->setQuery($query);
$db->execute();
// Clean the cache.
$this->cleanCache();
return true;
}
/**
* Get the necessary data to load an item help screen.
*
* @return object An object with key, url, and local properties for
loading the item help screen.
*
* @since 1.6
*/
public function getHelp()
{
return (object) array('key' => $this->helpKey,
'url' => $this->helpURL);
}
/**
* Custom clean cache method
*
* @param string $group The cache group
* @param integer $clientId The ID of the client
*
* @return void
*
* @since 1.6
*/
protected function cleanCache($group = null, $clientId = 0)
{
parent::cleanCache('com_templates');
parent::cleanCache('_system');
}
}
styles.php000064400000015247151162110670006611 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\String\StringHelper;
/**
* Methods supporting a list of template style records.
*
* @since 1.6
*/
class TemplatesModelStyles extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'template', 'a.template',
'home', 'a.home',
'menuitem',
);
}
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.6
*/
protected function populateState($ordering = 'a.template',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.template',
$this->getUserStateFromRequest($this->context .
'.filter.template', 'filter_template', '',
'string'));
$this->setState('filter.menuitem',
$this->getUserStateFromRequest($this->context .
'.filter.menuitem', 'filter_menuitem', '',
'cmd'));
// Special case for the client id.
$clientId = (int) $this->getUserStateFromRequest($this->context .
'.client_id', 'client_id', 0, 'int');
$clientId = (!in_array($clientId, array (0, 1))) ? 0 : $clientId;
$this->setState('client_id', $clientId);
// Load the parameters.
$params = JComponentHelper::getParams('com_templates');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('client_id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.template');
$id .= ':' . $this->getState('filter.menuitem');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
$clientId = (int) $this->getState('client_id');
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.template, a.title, a.home, a.client_id, l.title AS
language_title, l.image as image, l.sef AS language_sef'
)
);
$query->from($db->quoteName('#__template_styles',
'a'))
->where($db->quoteName('a.client_id') . ' = '
. $clientId);
// Join on menus.
$query->select('COUNT(m.template_style_id) AS assigned')
->join('LEFT', $db->quoteName('#__menu',
'm') . ' ON ' .
$db->quoteName('m.template_style_id') . ' = ' .
$db->quoteName('a.id'))
->group('a.id, a.template, a.title, a.home, a.client_id,
l.title, l.image, e.extension_id, l.sef');
// Join over the language.
$query->join('LEFT',
$db->quoteName('#__languages', 'l') . ' ON
' . $db->quoteName('l.lang_code') . ' = ' .
$db->quoteName('a.home'));
// Filter by extension enabled.
$query->select($db->quoteName('extension_id',
'e_id'))
->join('LEFT', $db->quoteName('#__extensions',
'e') . ' ON e.element = a.template AND e.client_id =
a.client_id')
->where($db->quoteName('e.enabled') . ' = 1')
->where($db->quoteName('e.type') . ' = ' .
$db->quote('template'));
// Filter by template.
if ($template = $this->getState('filter.template'))
{
$query->where($db->quoteName('a.template') . ' =
' . $db->quote($template));
}
// Filter by menuitem.
$menuItemId = $this->getState('filter.menuitem');
if ($clientId === 0 && is_numeric($menuItemId))
{
// If user selected the templates styles that are not assigned to any
page.
if ((int) $menuItemId === -1)
{
// Only custom template styles overrides not assigned to any menu item.
$query->where($db->quoteName('a.home') . ' =
' . $db->quote(0))
->where($db->quoteName('m.id') . ' IS
NULL');
}
// If user selected the templates styles assigned to particular pages.
else
{
// Subquery to get the language of the selected menu item.
$menuItemLanguageSubQuery = $db->getQuery(true);
$menuItemLanguageSubQuery->select($db->quoteName('language'))
->from($db->quoteName('#__menu'))
->where($db->quoteName('id') . ' = ' .
$menuItemId);
// Subquery to get the language of the selected menu item.
$templateStylesMenuItemsSubQuery = $db->getQuery(true);
$templateStylesMenuItemsSubQuery->select($db->quoteName('id'))
->from($db->quoteName('#__menu'))
->where($db->quoteName('template_style_id') . ' =
' . $db->quoteName('a.id'));
// Main query where clause.
$query->where('(' .
// Default template style (fallback template style to all menu items).
$db->quoteName('a.home') . ' = ' .
$db->quote(1) . ' OR ' .
// Default template style for specific language (fallback template
style to the selected menu item language).
$db->quoteName('a.home') . ' IN (' .
$menuItemLanguageSubQuery . ') OR ' .
// Custom template styles override (only if assigned to the selected
menu item).
'(' . $db->quoteName('a.home') . ' =
' . $db->quote(0) . ' AND ' . $menuItemId . ' IN
(' . $templateStylesMenuItemsSubQuery . '))' .
')'
);
}
}
// Filter by search in title.
if ($search = $this->getState('filter.search'))
{
if (stripos($search, 'id:') === 0)
{
$query->where($db->quoteName('a.id') . ' = '
. (int) substr($search, 3));
}
else
{
$search = $db->quote('%' .
StringHelper::strtolower($search) . '%');
$query->where('(' . ' LOWER(a.template) LIKE ' .
$search . ' OR LOWER(a.title) LIKE ' . $search . ')');
}
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.template')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
}
ajax.php000064400000013055151162147310006205 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage ajax.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Ajax Model
*/
class MoojlaModelAjax extends JModelList
{
protected $app_params;
public function __construct()
{
parent::__construct();
// get params
$this->app_params =
JComponentHelper::getParams('com_moojla');
}
// Used in course
/***[JCBGUI.admin_view.php_ajaxmethod.129.$$$$]***/
public function shop_requirement($shop_name)
{
$shop_integration = $shop_name;
$res= [];
if ($shop_integration == 'hk') {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('extension_id, enabled, name');
$query->from($db->quoteName('#__extensions'));
$query->where('(' .
$db->quoteName('folder') . '=' .
$db->quote('editors-xtd') . ' and ' .
$db->quoteName('element') . '=' .
$db->quote('hikashopproduct') . ') or (' .
$db->quoteName('folder') . '=' .
$db->quote('system') . ' and ' .
$db->quoteName('element') . '=' .
$db->quote('hikashopproductinsert') . ')');
$db->setQuery($query);
$results = $db->loadObjectList('name');
$required_plugins = ['Hikashop product tag insertion
plugin', 'HikaShop product tag translation plugin'];
foreach ($required_plugins as $required_plugin) {
if ($results[$required_plugin]) {
if ($results[$required_plugin]->enabled == 1)
$res['messages'][]=['message'=>
$results[$required_plugin]->name . ' is installed and
enabled', 'class'=>'success'];
else
$res['messages'][]=['message'=>
$results[$required_plugin]->name . ' is installed but not
enabled', 'class'=>'error'];
} else
$res['messages'][]=['message'=>
$results[$required_plugin]->name . ' is not installed',
'class'=>'error'];
}
$res['component']= 'hikashop';
return $res;
}
}/***[/JCBGUI$$$$]***/
// Used in user_map
/***[JCBGUI.admin_view.php_ajaxmethod.130.$$$$]***/
public function userbatch($users, $group, $op)
{
foreach($users as $user)
{
$user = JFactory::getUser(intval($user));
$set_group = array();
foreach($group as $gp)
{
switch($op[0])
{
case 'add':
if(!in_array($gp, $user->groups))
{
$user->groups[] = intval($gp);
}
break;
case 'del':
if (($key = array_search($gp, $user->groups)) !== false) {
unset($user->groups[$key]);
}
break;
case 'set':
if(!in_array($gp, $set_group))
{
$set_group[] = $gp;
}
$user->groups = $set_group;
break;
}
}
$user->save();
}
return array(
'staus' => true
);
// return array(
// 'users' => $users,
// 'group' => $group,
// 'op' => $op,
// );
}/***[/JCBGUI$$$$]***/
// Used in user_field_map
/***[JCBGUI.admin_view.php_ajaxmethod.134.$$$$]***/
public function addMapperRows($ads)
{
JLoader::register('MoojlaModelUser_field_map',
JPATH_ADMINISTRATOR.'/components/com_moojla/models/user_field_map.php');
JLoader::register('MoojlaModelUser_fields_map',
JPATH_ADMINISTRATOR.'/components/com_moojla/models/user_fields_map.php');
JLoader::register('MoojlaTableUser_field_map',
JPATH_ADMINISTRATOR.'/components/com_moojla/tables/user_fields_map.php');
$ufsmModel = new MoojlaModelUser_fields_map;
$mappings = $ufsmModel->getItems();
foreach($mappings as $map)
{
$ufmModel = new MoojlaModelUser_field_map;
$pk = array($map->id);
$ufmModel->publish($pk, -2);
$ufmModel->delete($pk);
}
if($ads == 'cb')
{
$firstnameMapArray = array(
'juserfields' => 'cb_firstname',
'muserfields' => 'sm_firstname'
);
$lastnameMapArray = array(
'juserfields' => 'cb_lastname',
'muserfields' => 'sm_lastname'
);
$ufmModel = new MoojlaModelUser_field_map;
$ufmModel->save($firstnameMapArray);
$ufmModel = new MoojlaModelUser_field_map;
$ufmModel->save($lastnameMapArray);
}
$emailMapArray = array(
'juserfields' => 'sj_email',
'muserfields' => 'sm_email'
);
$ufmModel = new MoojlaModelUser_field_map;
$ufmModel->save($emailMapArray);
return array();
}
/***[/JCBGUI$$$$]***/
}
categories_map.php000064400000016201151162147310010240 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage categories_map.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Categories_map Model
*/
class MoojlaModelCategories_map extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.jcatid','jcatid',
'a.mcatid','mcatid'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$jcatid = $this->getUserStateFromRequest($this->context .
'.filter.jcatid', 'filter_jcatid');
if ($formSubmited)
{
$jcatid = $app->input->post->get('jcatid');
$this->setState('filter.jcatid', $jcatid);
}
$mcatid = $this->getUserStateFromRequest($this->context .
'.filter.mcatid', 'filter_mcatid');
if ($formSubmited)
{
$mcatid = $app->input->post->get('mcatid');
$this->setState('filter.mcatid', $mcatid);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_category_map',
'a'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.jcatid LIKE '.$search.' OR a.mcatid
LIKE '.$search.')');
}
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.jcatid');
$id .= ':' . $this->getState('filter.mcatid');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_category_map'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_category_map'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
category_map.php000064400000051172151162147310007736 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage category_map.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Category_map Model
*/
class MoojlaModelCategory_map extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'jcatid'
),
'right' => array(
'mcatid'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.category_map';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'category_map', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.category_map',
'category_map', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.category_map.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/category_map.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.category_map.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.category_map.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.category_map.'. ((int) isset($data[$key]) ?
$data[$key] : 0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_category_map'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.category_map.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.category_map', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('category_map');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('category_map');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('category_map');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
}
cohort.php000064400000051025151162147310006557 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage cohort.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Cohort Model
*/
class MoojlaModelCohort extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'mcohort'
),
'right' => array(
'course_group'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.cohort';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'cohort', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.cohort',
'cohort', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.cohort.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/cohort.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.cohort.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.cohort.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.cohort.'. ((int) isset($data[$key]) ? $data[$key] :
0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_cohort'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.cohort.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.cohort', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('cohort');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('cohort');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('cohort');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
}
cohorts.php000064400000021472151162147310006745 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage cohorts.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Cohorts Model
*/
class MoojlaModelCohorts extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'g.name','mcohort',
'h.title','course_group'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$mcohort = $this->getUserStateFromRequest($this->context .
'.filter.mcohort', 'filter_mcohort');
if ($formSubmited)
{
$mcohort = $app->input->post->get('mcohort');
$this->setState('filter.mcohort', $mcohort);
}
$course_group = $this->getUserStateFromRequest($this->context .
'.filter.course_group', 'filter_course_group');
if ($formSubmited)
{
$course_group =
$app->input->post->get('course_group');
$this->setState('filter.course_group', $course_group);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
/***[JCBGUI.admin_view.php_getitems_after_all.141.$$$$]***/
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$dataObj = array(
"wsfunction" =>
"moojla_get_cohorts",
"moodlewsrestformat" => "json",
);
$cohorts =
json_decode(MoojlaHelper::sendRequestToMoodle($dataObj)->response,
true);
$ids = array_flip(array_column($cohorts, 'id'));
foreach($items as $ind => $item)
{
$items[$ind]->mcohort =
$cohorts[$ids[$items[$ind]->mcohort]]['name'];
}
/***[/JCBGUI$$$$]***/
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_cohort',
'a'));
// From the usergroups table.
$query->select($db->quoteName('h.title','course_group_title'));
$query->join('LEFT',
$db->quoteName('#__usergroups', 'h') . ' ON
(' . $db->quoteName('a.course_group') . ' = ' .
$db->quoteName('h.id') . ')');
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.mcohort LIKE '.$search.' OR g.name
LIKE '.$search.')');
}
}
// Filter by Mcohort.
$_mcohort = $this->getState('filter.mcohort');
if (is_numeric($_mcohort))
{
if (is_float($_mcohort))
{
$query->where('a.mcohort = ' . (float) $_mcohort);
}
else
{
$query->where('a.mcohort = ' . (int) $_mcohort);
}
}
elseif (MoojlaHelper::checkString($_mcohort))
{
$query->where('a.mcohort = ' .
$db->quote($db->escape($_mcohort)));
}
// Filter by Course_group.
$_course_group = $this->getState('filter.course_group');
if (is_numeric($_course_group))
{
if (is_float($_course_group))
{
$query->where('a.course_group = ' . (float)
$_course_group);
}
else
{
$query->where('a.course_group = ' . (int) $_course_group);
}
}
elseif (MoojlaHelper::checkString($_course_group))
{
$query->where('a.course_group = ' .
$db->quote($db->escape($_course_group)));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.mcohort');
$id .= ':' .
$this->getState('filter.course_group');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_cohort'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_cohort'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
content.php000064400000055757151162147310006753 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage content.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Content Model
*/
class MoojlaModelContent extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'contents_module_id',
'fileurl',
'filesize',
'mimetype',
'type',
'filename',
'file'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.content';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'content', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/***[JCBGUI.admin_view.php_model.133.$$$$]***/
public function myDelete($pk){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('rules',
'id')));
$query->from($db->quoteName('#__assets'));
$query->where($db->quoteName('name') . ' = '
. $db->quote('com_moojla'));
$db->setQuery($query);
$results = $db->loadObjectList();
$acls = json_decode($results[0]->rules);
$deleteAcl = null;
$permission = 'core.delete';
if(!property_exists($acls, $permission))
{
$acls->$permission = new stdClass();
}
$pub = '1';
$acls->$permission->$pub = 1;
$obj = new stdClass();
$obj->id = $results[0]->id;
$obj->rules = json_encode($acls);
JFactory::getDbo()->updateObject('#__assets', $obj,
'id');
$obj = new stdClass();
$obj->id = $pk;
$obj->published = -2;
JFactory::getDbo()->updateObject('#__moojla_content',
$obj, 'id'); // trash item
$pks = array($pk);
$res = $this->delete($pks);
$obj = new stdClass();
$obj->id = $results[0]->id;
$obj->rules = $results[0]->rules;
JFactory::getDbo()->updateObject('#__assets', $obj,
'id');
return $res;
}/***[/JCBGUI$$$$]***/
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.content',
'content', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.content.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/content.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.content.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.content.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.content.'. ((int) isset($data[$key]) ? $data[$key] :
0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_content'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.content.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.content', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('content');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('content');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Only for strings
if (MoojlaHelper::checkString($this->table->type) &&
!is_numeric($this->table->type))
{
$this->table->type =
$this->generateUnique('type',$this->table->type);
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('content');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
/***[JCBGUI.admin_view.php_save.133.$$$$]***/
$params = JComponentHelper::getParams('com_moojla');
$moodle_token = trim($params->get('moodle_token'));
$url = $data["fileurl"];
$url = str_replace("?forcedownload=1", "", $url);
$url .= "?token=" . $moodle_token;
$file_name = $data["filename"];
if(file_put_contents(JPATH_COMPONENT_ADMINISTRATOR .
"/donwnloaded/" . $file_name,file_get_contents($url))) {
$data["file"] = JPATH_COMPONENT_ADMINISTRATOR .
"/donwnloaded/" . $file_name;
}
else {
$data["file"] = "File downloading failed.";
} /***[/JCBGUI$$$$]***/
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
contents.php000064400000020177151162147310007122 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage contents.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Contents Model
*/
class MoojlaModelContents extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.contents_module_id','contents_module_id',
'a.mimetype','mimetype'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$contents_module_id = $this->getUserStateFromRequest($this->context
. '.filter.contents_module_id',
'filter_contents_module_id');
if ($formSubmited)
{
$contents_module_id =
$app->input->post->get('contents_module_id');
$this->setState('filter.contents_module_id',
$contents_module_id);
}
$mimetype = $this->getUserStateFromRequest($this->context .
'.filter.mimetype', 'filter_mimetype');
if ($formSubmited)
{
$mimetype = $app->input->post->get('mimetype');
$this->setState('filter.mimetype', $mimetype);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_content',
'a'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.file LIKE '.$search.')');
}
}
// Filter by Contents_module_id.
$_contents_module_id =
$this->getState('filter.contents_module_id');
if (is_numeric($_contents_module_id))
{
if (is_float($_contents_module_id))
{
$query->where('a.contents_module_id = ' . (float)
$_contents_module_id);
}
else
{
$query->where('a.contents_module_id = ' . (int)
$_contents_module_id);
}
}
elseif (MoojlaHelper::checkString($_contents_module_id))
{
$query->where('a.contents_module_id = ' .
$db->quote($db->escape($_contents_module_id)));
}
// Filter by Mimetype.
$_mimetype = $this->getState('filter.mimetype');
if (is_numeric($_mimetype))
{
if (is_float($_mimetype))
{
$query->where('a.mimetype = ' . (float) $_mimetype);
}
else
{
$query->where('a.mimetype = ' . (int) $_mimetype);
}
}
elseif (MoojlaHelper::checkString($_mimetype))
{
$query->where('a.mimetype = ' .
$db->quote($db->escape($_mimetype)));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' .
$this->getState('filter.contents_module_id');
$id .= ':' . $this->getState('filter.mimetype');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_content'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_content'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
course.php000064400000102056151162147310006562 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage course.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Course Model
*/
class MoojlaModelCourse extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'cat_id',
'cat_name',
'currency',
'self_enrolment',
'startdate',
'summary_files',
'teachers'
),
'right' => array(
'cost',
'remoteid',
'guest',
'in_enrol_date',
'enddate',
'summary'
),
'above' => array(
'alias',
'shortname',
'fullname',
'permanent_fields',
'catid'
)
),
'video' => array(
'left' => array(
'useglobalvideo',
'videotype',
'preventdownload',
'addcontrols',
'preloadvideo',
'autoplay',
'muted'
)
),
'moodle_access' => array(
'left' => array(
'availabilityinfolink',
'redirect_after_enrol',
'showlogintab',
'loginurl',
'alterurl',
'enterlbl',
'buylbl'
),
'right' => array(
'cangotomoodle',
'popupbutton',
'showregtab',
'registrationurl',
'loginlbl',
'freeenterlbl',
'enrollbl'
)
),
'audio' => array(
'left' => array(
'useglobalaudio',
'preventdownloadaudio',
'preloadaudio',
'autoplayaudio'
)
),
'templates' => array(
'left' => array(
'course_templatestyle_forcourseconfig'
),
'right' => array(
'course_detail_layout'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.course';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'course', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/***[JCBGUI.admin_view.php_model.129.$$$$]***/
public function myDelete($pk){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('rules',
'id')));
$query->from($db->quoteName('#__assets'));
$query->where($db->quoteName('name') . ' = '
. $db->quote('com_moojla'));
$db->setQuery($query);
$results = $db->loadObjectList();
$acls = json_decode($results[0]->rules);
$deleteAcl = null;
$permission = 'core.delete';
if(!property_exists($acls, $permission))
{
$acls->$permission = new stdClass();
}
$pub = '1';
$acls->$permission->$pub = 1;
$obj = new stdClass();
$obj->id = $results[0]->id;
$obj->rules = json_encode($acls);
JFactory::getDbo()->updateObject('#__assets', $obj,
'id');
$obj = new stdClass();
$obj->id = $pk;
$obj->published = -2;
JFactory::getDbo()->updateObject('#__moojla_course', $obj,
'id'); // trash item
$pks = array($pk);
$res = $this->delete($pks);
$obj = new stdClass();
$obj->id = $results[0]->id;
$obj->rules = $results[0]->rules;
JFactory::getDbo()->updateObject('#__assets', $obj,
'id');
return $res;
}
public function setFieldValue($fieldId, $itemId, $value)
{
JLoader::register('FieldsHelper',
JPATH_ADMINISTRATOR.'/components/com_fields/helpers/fields.php');
JLoader::register('FieldsModelField',
JPATH_ADMINISTRATOR.'/components/com_fields/models/field.php');
$fieldModle = new FieldsModelField;
$field = $fieldModle->getItem($fieldId);
$params = $field->params;
if (is_array($params))
{
$params = new Registry($params);
}
$needsDelete = false;
$needsInsert = false;
$needsUpdate = false;
$oldValue = $fieldModle->getFieldValue($fieldId, $itemId);
$value = (array) $value;
if ($oldValue === null)
{
// No records available, doing normal insert
$needsInsert = true;
}
elseif (count($value) == 1 && count((array) $oldValue) == 1)
{
// Only a single row value update can be done when not empty
$needsUpdate = is_array($value[0]) ? count($value[0]) :
strlen($value[0]);
$needsDelete = !$needsUpdate;
}
else
{
// Multiple values, we need to purge the data and do a new
// insert
$needsDelete = true;
$needsInsert = true;
}
if ($needsDelete)
{
// Deleting the existing record as it is a reset
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->delete($query->qn('#__fields_values'))
->where($query->qn('field_id') . ' = ' .
(int) $fieldId)
->where($query->qn('item_id') . ' = ' .
$query->q($itemId));
$db->setQuery($query)->execute();
}
if ($needsInsert)
{
$newObj = new stdClass;
$newObj->field_id = (int) $fieldId;
$newObj->item_id = $itemId;
foreach ($value as $v)
{
$newObj->value = $v;
$db = JFactory::getDbo();
$db->insertObject('#__fields_values', $newObj);
}
}
if ($needsUpdate)
{
$updateObj = new stdClass;
$updateObj->field_id = (int) $fieldId;
$updateObj->item_id = $itemId;
$updateObj->value = reset($value);
$db = JFactory::getDbo();
$db->updateObject('#__fields_values', $updateObj,
array('field_id', 'item_id'));
}
FieldsHelper::clearFieldsCache();
return true;
}
/***[/JCBGUI$$$$]***/
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
if (!empty($item->permanent_fields))
{
// Convert the permanent_fields field to an array.
$permanent_fields = new Registry;
$permanent_fields->loadString($item->permanent_fields);
$item->permanent_fields = $permanent_fields->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.course',
'course', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.course.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/course.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('course.delete',
'com_moojla.course.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.course.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
$user = JFactory::getUser();
return $user->authorise('course.edit',
'com_moojla.course.'. ((int) isset($data[$key]) ? $data[$key] :
0)) or $user->authorise('course.edit',
'com_moojla');
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_course'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.course.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.course', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return array('remoteid');
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
/***[JCBGUI.admin_view.php_before_delete.129.$$$$]***/
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/course.php";
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/section.php";
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/module.php";
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/content.php";
foreach($pks as $id)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('remoteid')))
->from($db->quoteName('#__moojla_course'))
->where($db->quoteName('id') . ' = ' .
$id);
$db->setQuery($query);
$courseid = $db->loadResult();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id',
'section_id')))
->from($db->quoteName('#__moojla_section'))
->where($db->quoteName('courseid') . ' = '
. $courseid);
$db->setQuery($query);
$moojlasectionids = $db->loadObjectList();
foreach($moojlasectionids as $section)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id',
'module_id')))
->from($db->quoteName('#__moojla_module'))
->where($db->quoteName('module_section_id') .
' = ' . $section->section_id);
$db->setQuery($query);
$moojlamoduleids = $db->loadObjectList();
foreach($moojlamoduleids as $module)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')))
->from($db->quoteName('#__moojla_content'))
->where($db->quoteName('contents_module_id') .
' = ' . $module->module_id);
$db->setQuery($query);
$moojlacontentids = $db->loadObjectList();
foreach($moojlacontentids as $content)
{
$contentIns = new MoojlaModelContent();
$contentIns->myDelete($content->id);
}
$moduleIns = new MoojlaModelModule();
$moduleIns->myDelete($module->id);
}
$sectionIns = new MoojlaModelSection();
$sectionIns->myDelete($section->id);
}
}
/***[/JCBGUI$$$$]***/
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('course');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('course');
}
if (!$this->canDo->get('course.create') &&
!$this->canDo->get('course.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
if (isset($values['category']) && (int)
$values['category'] > 0 &&
!static::checkCategoryId($values['category']))
{
return false;
}
elseif (isset($values['category']) && (int)
$values['category'] > 0)
{
// move the category value to correct field name
$values['catid'] = $values['category'];
unset($values['category']);
}
elseif (isset($values['category']))
{
unset($values['category']);
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('course.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
if (isset($values['catid']))
{
list($this->table->shortname, $this->table->alias) =
$this->generateNewTitle($values['catid'],
$this->table->alias, $this->table->shortname);
}
else
{
list($this->table->shortname, $this->table->alias) =
$this->generateNewTitle($this->table->catid,
$this->table->alias, $this->table->shortname);
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('course');
}
if (!$this->canDo->get('course.edit') &&
!$this->canDo->get('course.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
if (isset($values['category']) && (int)
$values['category'] > 0 &&
!static::checkCategoryId($values['category']))
{
return false;
}
elseif (isset($values['category']) && (int)
$values['category'] > 0)
{
// move the category value to correct field name
$values['catid'] = $values['category'];
unset($values['category']);
}
elseif (isset($values['category']))
{
unset($values['category']);
}
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('course.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the permanent_fields items to data.
if (isset($data['permanent_fields']) &&
is_array($data['permanent_fields']))
{
$permanent_fields = new JRegistry;
$permanent_fields->loadArray($data['permanent_fields']);
$data['permanent_fields'] = (string) $permanent_fields;
}
elseif (!isset($data['permanent_fields']))
{
// Set the empty permanent_fields to data
$data['permanent_fields'] = '';
}
/***[JCBGUI.admin_view.php_save.129.$$$$]***/
$moodleimgurl = $data["summary_files"];
if($moodleimgurl)
{
$olddlpath =
JPATH_ROOT.'/media/com_moojla/images/'.urldecode(basename($moodleimgurl));
$dlpath =
JPATH_ROOT.'/media/com_moojla/images/'.$data["remoteid"].'_'.urldecode(basename($moodleimgurl));
if(!file_exists($dlpath) && !file_exists($olddlpath))
{
$ch = curl_init($moodleimgurl);
$fp = fopen($dlpath, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$data["summary_files"] = basename($moodleimgurl) ?
'/media/com_moojla/images/'.$data["remoteid"].'_'.basename($moodleimgurl)
: '';
}
else
{
$data["summary_files"] = file_exists($dlpath) ?
'/media/com_moojla/images/'.$data["remoteid"].'_'.basename($moodleimgurl)
: '/media/com_moojla/images/'.basename($moodleimgurl);
}
}
JPluginHelper::importPlugin("notifly");
$dispatcher = JEventDispatcher::getInstance();
$args = array('com_moojla.coursecreated', $data, true);
$dispatcher->trigger("onContentAfterSave", $args);
/***[/JCBGUI$$$$]***/
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the shortname for save as copy
if ($input->get('task') === 'save2copy')
{
$origTable = clone $this->getTable();
$origTable->load($input->getInt('id'));
if ($data['shortname'] == $origTable->shortname)
{
list($shortname, $alias) =
$this->generateNewTitle($data['catid'],
$data['alias'], $data['shortname']);
$data['shortname'] = $shortname;
$data['alias'] = $alias;
}
else
{
if ($data['alias'] == $origTable->alias)
{
$data['alias'] = '';
}
}
$data['published'] = 0;
}
// Automatic handling of alias for empty fields
if (in_array($input->get('task'), array('apply',
'save', 'save2new')) && (int)
$input->get('id') == 0)
{
if ($data['alias'] == null || empty($data['alias']))
{
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
$data['alias'] =
JFilterOutput::stringURLUnicodeSlug($data['shortname']);
}
else
{
$data['alias'] =
JFilterOutput::stringURLSafe($data['shortname']);
}
$table = JTable::getInstance('course',
'moojlaTable');
if ($table->load(array('alias' =>
$data['alias'], 'catid' =>
$data['catid'])) && ($table->id !=
$data['id'] || $data['id'] == 0))
{
$msg = JText::_('COM_MOOJLA_COURSE_SAVE_WARNING');
}
list($shortname, $alias) =
$this->generateNewTitle($data['catid'],
$data['alias'], $data['shortname']);
$data['alias'] = $alias;
if (isset($msg))
{
JFactory::getApplication()->enqueueMessage($msg,
'warning');
}
}
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title/s & alias.
*
* @param string $alias The alias.
* @param string/array $title The title.
*
* @return array/string Contains the modified title/s and/or alias.
*
*/
protected function _generateNewTitle($alias, $title = null)
{
// Alter the title/s & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias)))
{
// Check if this is an array of titles
if (MoojlaHelper::checkArray($title))
{
foreach($title as $nr => &$_title)
{
$_title = StringHelper::increment($_title);
}
}
// Make sure we have a title
elseif ($title)
{
$title = StringHelper::increment($title);
}
$alias = StringHelper::increment($alias, 'dash');
}
// Check if this is an array of titles
if (MoojlaHelper::checkArray($title))
{
$title[] = $alias;
return $title;
}
// Make sure we have a title
elseif ($title)
{
return array($title, $alias);
}
// We only had an alias
return $alias;
}
}
courses.php000064400000032112151162147310006740 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage courses.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Courses Model
*/
class MoojlaModelCourses extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'c.title','category_title',
'c.id', 'category_id',
'a.catid','catid',
'a.shortname','shortname',
'a.fullname','fullname'
);
}
parent::__construct($config);
}
/***[JCBGUI.admin_view.php_model_list.129.$$$$]***/
///***[/JCBGUI$$$$]***/
/**
* 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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$category = $app->getUserStateFromRequest($this->context .
'.filter.category', 'filter_category');
$this->setState('filter.category', $category);
$categoryId = $this->getUserStateFromRequest($this->context .
'.filter.category_id', 'filter_category_id');
$this->setState('filter.category_id', $categoryId);
$catid = $this->getUserStateFromRequest($this->context .
'.filter.catid', 'filter_catid');
if ($formSubmited)
{
$catid = $app->input->post->get('catid');
$this->setState('filter.catid', $catid);
}
$shortname = $this->getUserStateFromRequest($this->context .
'.filter.shortname', 'filter_shortname');
if ($formSubmited)
{
$shortname = $app->input->post->get('shortname');
$this->setState('filter.shortname', $shortname);
}
$fullname = $this->getUserStateFromRequest($this->context .
'.filter.fullname', 'filter_fullname');
if ($formSubmited)
{
$fullname = $app->input->post->get('fullname');
$this->setState('filter.fullname', $fullname);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// Set values to display correctly.
if (MoojlaHelper::checkArray($items))
{
// Get the user object if not set.
if (!isset($user) || !MoojlaHelper::checkObject($user))
{
$user = JFactory::getUser();
}
foreach ($items as $nr => &$item)
{
// Remove items the user can't access.
$access = ($user->authorise('course.access',
'com_moojla.course.' . (int) $item->id) &&
$user->authorise('course.access', 'com_moojla'));
if (!$access)
{
unset($items[$nr]);
continue;
}
}
}
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
$query->select($db->quoteName('c.title','category_title'));
// From the moojla_item table
$query->from($db->quoteName('#__moojla_course',
'a'));
$query->join('LEFT',
$db->quoteName('#__categories', 'c') . ' ON
(' . $db->quoteName('a.catid') . ' = ' .
$db->quoteName('c.id') . ')');
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.shortname LIKE '.$search.' OR
a.fullname LIKE '.$search.' OR a.catid LIKE '.$search.'
OR a.remoteid LIKE '.$search.')');
}
}
// Filter by a single or group of categories.
$baselevel = 1;
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
$cat_tbl = JTable::getInstance('Category',
'JTable');
$cat_tbl->load($categoryId);
$rgt = $cat_tbl->rgt;
$lft = $cat_tbl->lft;
$baselevel = (int) $cat_tbl->level;
$query->where('c.lft >= ' . (int) $lft)
->where('c.rgt <= ' . (int) $rgt);
}
elseif (is_array($categoryId))
{
$categoryId = ArrayHelper::toInteger($categoryId);
$categoryId = implode(',', $categoryId);
$query->where('a.catid IN (' . $categoryId .
')');
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get list export data.
*
* @param array $pks The ids of the items to get
* @param JUser $user The user making the request
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExportData($pks, $user = null)
{
// setup the query
if (($pks_size = MoojlaHelper::checkArray($pks)) !== false ||
'bulk' === $pks)
{
// Set a value to know this is export method. (USE IN CUSTOM CODE TO
ALTER OUTCOME)
$_export = true;
// Get the user object if not set.
if (!isset($user) || !MoojlaHelper::checkObject($user))
{
$user = JFactory::getUser();
}
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_course table
$query->from($db->quoteName('#__moojla_course',
'a'));
// The bulk export path
if ('bulk' === $pks)
{
$query->where('a.id > 0');
}
// A large array of ID's will not work out well
elseif ($pks_size > 500)
{
// Use lowest ID
$query->where('a.id >= ' . (int) min($pks));
// Use highest ID
$query->where('a.id <= ' . (int) max($pks));
}
// The normal default path
else
{
$query->where('a.id IN (' . implode(',',$pks) .
')');
}
// Order the results by ordering
$query->order('a.ordering ASC');
// Load the items
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$items = $db->loadObjectList();
// Set values to display correctly.
if (MoojlaHelper::checkArray($items))
{
foreach ($items as $nr => &$item)
{
// Remove items the user can't access.
$access = ($user->authorise('course.access',
'com_moojla.course.' . (int) $item->id) &&
$user->authorise('course.access', 'com_moojla'));
if (!$access)
{
unset($items[$nr]);
continue;
}
// unset the values we don't want exported.
unset($item->asset_id);
unset($item->checked_out);
unset($item->checked_out_time);
}
}
// Add headers to items array.
$headers = $this->getExImPortHeaders();
if (MoojlaHelper::checkObject($headers))
{
array_unshift($items,$headers);
}
return $items;
}
}
return false;
}
/**
* Method to get header.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExImPortHeaders()
{
// Get a db connection.
$db = JFactory::getDbo();
// get the columns
$columns = $db->getTableColumns("#__moojla_course");
if (MoojlaHelper::checkArray($columns))
{
// remove the headers you don't import/export.
unset($columns['asset_id']);
unset($columns['checked_out']);
unset($columns['checked_out_time']);
$headers = new stdClass();
foreach ($columns as $column => $type)
{
$headers->{$column} = $column;
}
return $headers;
}
return false;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
// Check if the value is an array
$_category = $this->getState('filter.category');
if (MoojlaHelper::checkArray($_category))
{
$id .= ':' . implode(':', $_category);
}
// Check if this is only an number or string
elseif (is_numeric($_category)
|| MoojlaHelper::checkString($_category))
{
$id .= ':' . $_category;
}
// Check if the value is an array
$_category_id = $this->getState('filter.category_id');
if (MoojlaHelper::checkArray($_category_id))
{
$id .= ':' . implode(':', $_category_id);
}
// Check if this is only an number or string
elseif (is_numeric($_category_id)
|| MoojlaHelper::checkString($_category_id))
{
$id .= ':' . $_category_id;
}
// Check if the value is an array
$_catid = $this->getState('filter.catid');
if (MoojlaHelper::checkArray($_catid))
{
$id .= ':' . implode(':', $_catid);
}
// Check if this is only an number or string
elseif (is_numeric($_catid)
|| MoojlaHelper::checkString($_catid))
{
$id .= ':' . $_catid;
}
$id .= ':' . $this->getState('filter.shortname');
$id .= ':' . $this->getState('filter.fullname');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_course'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_course'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
course_fields_mapper.php000064400000027307151162147310011461
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage course_fields_mapper.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Course_fields_mapper Model
*/
class MoojlaModelCourse_fields_mapper extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.access','access',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
/***[JCBGUI.admin_view.php_getitems_after_all.138.$$$$]***/
/*foreach($items as $ind => $it)
{
$items[$ind]->field_icon = JUri::root().$it->field_icon;
}*/
foreach($items as $index => $it)
{
$items[$index]->mcoursefields_id = $it->mcoursefields;
}/***[/JCBGUI$$$$]***/
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_course_field_mapper',
'a'));
// From the fields table.
$query->select($db->quoteName('g.name','coursefield_name'));
$query->join('LEFT',
$db->quoteName('#__fields', 'g') . ' ON ('
. $db->quoteName('a.coursefield') . ' = ' .
$db->quoteName('g.id') . ')');
// From the moojla_course_field_mapper table.
$query->select($db->quoteName('h.id','mcoursefields_id'));
$query->join('LEFT',
$db->quoteName('#__moojla_course_field_mapper', 'h')
. ' ON (' . $db->quoteName('a.mcoursefields') .
' = ' . $db->quoteName('h.id') . ')');
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Filter by access level.
$_access = $this->getState('filter.access');
if ($_access && is_numeric($_access))
{
$query->where('a.access = ' . (int) $_access);
}
elseif (MoojlaHelper::checkArray($_access))
{
// Secure the array for the query
$_access = ArrayHelper::toInteger($_access);
// Filter by the Access Array.
$query->where('a.access IN (' . implode(',',
$_access) . ')');
}
// Implement View Level Access
if (!$user->authorise('core.options',
'com_moojla'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.coursefield LIKE '.$search.' OR
g.name LIKE '.$search.' OR a.mcoursefields LIKE
'.$search.' OR h.id LIKE '.$search.')');
}
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get list export data.
*
* @param array $pks The ids of the items to get
* @param JUser $user The user making the request
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExportData($pks, $user = null)
{
// setup the query
if (($pks_size = MoojlaHelper::checkArray($pks)) !== false ||
'bulk' === $pks)
{
// Set a value to know this is export method. (USE IN CUSTOM CODE TO
ALTER OUTCOME)
$_export = true;
// Get the user object if not set.
if (!isset($user) || !MoojlaHelper::checkObject($user))
{
$user = JFactory::getUser();
}
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_course_field_mapper table
$query->from($db->quoteName('#__moojla_course_field_mapper',
'a'));
// The bulk export path
if ('bulk' === $pks)
{
$query->where('a.id > 0');
}
// A large array of ID's will not work out well
elseif ($pks_size > 500)
{
// Use lowest ID
$query->where('a.id >= ' . (int) min($pks));
// Use highest ID
$query->where('a.id <= ' . (int) max($pks));
}
// The normal default path
else
{
$query->where('a.id IN (' . implode(',',$pks) .
')');
}
// Implement View Level Access
if (!$user->authorise('core.options',
'com_moojla'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Order the results by ordering
$query->order('a.ordering ASC');
// Load the items
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$items = $db->loadObjectList();
// Set values to display correctly.
if (MoojlaHelper::checkArray($items))
{
foreach ($items as $nr => &$item)
{
// unset the values we don't want exported.
unset($item->asset_id);
unset($item->checked_out);
unset($item->checked_out_time);
}
}
// Add headers to items array.
$headers = $this->getExImPortHeaders();
if (MoojlaHelper::checkObject($headers))
{
array_unshift($items,$headers);
}
/***[JCBGUI.admin_view.php_getitems_after_all.138.$$$$]***/
/*foreach($items as $ind => $it)
{
$items[$ind]->field_icon = JUri::root().$it->field_icon;
}*/
foreach($items as $index => $it)
{
$items[$index]->mcoursefields_id = $it->mcoursefields;
}/***[/JCBGUI$$$$]***/
return $items;
}
}
return false;
}
/**
* Method to get header.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExImPortHeaders()
{
// Get a db connection.
$db = JFactory::getDbo();
// get the columns
$columns =
$db->getTableColumns("#__moojla_course_field_mapper");
if (MoojlaHelper::checkArray($columns))
{
// remove the headers you don't import/export.
unset($columns['asset_id']);
unset($columns['checked_out']);
unset($columns['checked_out_time']);
$headers = new stdClass();
foreach ($columns as $column => $type)
{
$headers->{$column} = $column;
}
return $headers;
}
return false;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
// Check if the value is an array
$_access = $this->getState('filter.access');
if (MoojlaHelper::checkArray($_access))
{
$id .= ':' . implode(':', $_access);
}
// Check if this is only an number or string
elseif (is_numeric($_access)
|| MoojlaHelper::checkString($_access))
{
$id .= ':' . $_access;
}
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_course_field_mapper'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_course_field_mapper'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
course_field_mapper.php000064400000052540151162147310011273
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage course_field_mapper.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Course_field_mapper Model
*/
class MoojlaModelCourse_field_mapper extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'coursefield',
'mcoursefields',
'field_icon'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.course_field_mapper';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'course_field_mapper', $prefix
= 'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.course_field_mapper',
'course_field_mapper', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.course_field_mapper.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/course_field_mapper.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.course_field_mapper.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.course_field_mapper.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.course_field_mapper.'. ((int) isset($data[$key]) ?
$data[$key] : 0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_course_field_mapper'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.course_field_mapper.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.course_field_mapper',
$data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo =
MoojlaHelper::getActions('course_field_mapper');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo =
MoojlaHelper::getActions('course_field_mapper');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Only for strings
if (MoojlaHelper::checkString($this->table->coursefield)
&& !is_numeric($this->table->coursefield))
{
$this->table->coursefield =
$this->generateUnique('coursefield',$this->table->coursefield);
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo =
MoojlaHelper::getActions('course_field_mapper');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
course_group_map.php000064400000054755151162147310010647 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage course_group_map.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Course_group_map Model
*/
class MoojlaModelCourse_group_map extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'moojlacourse',
'role'
),
'right' => array(
'course_group'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.course_group_map';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'course_group_map', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.course_group_map',
'course_group_map', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.course_group_map.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/course_group_map.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.course_group_map.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.course_group_map.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.course_group_map.'. ((int) isset($data[$key]) ?
$data[$key] : 0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_course_group_map'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.course_group_map.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.course_group_map',
$data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
/***[JCBGUI.admin_view.php_before_delete.135.$$$$]***/
//beforedelete/***[/JCBGUI$$$$]***/
if (!parent::delete($pks))
{
return false;
}
/***[JCBGUI.admin_view.php_after_delete.135.$$$$]***/
//afterdelete/***[/JCBGUI$$$$]***/
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo =
MoojlaHelper::getActions('course_group_map');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo =
MoojlaHelper::getActions('course_group_map');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Only for strings
if (MoojlaHelper::checkString($this->table->moojlacourse)
&& !is_numeric($this->table->moojlacourse))
{
$this->table->moojlacourse =
$this->generateUnique('moojlacourse',$this->table->moojlacourse);
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo =
MoojlaHelper::getActions('course_group_map');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
/***[JCBGUI.admin_view.php_save.135.$$$$]***/
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('user_id'));
$query->from($db->quoteName('#__user_usergroup_map'));
$query->where($db->quoteName('group_id') . ' =
' . $db->quote($data['course_group']));
$db->setQuery($query);
$results = (array)$db->loadObjectList();
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$dataObj = array(
"wsfunction" =>
"moojla_multiple_enrol_users",
"moodlewsrestformat" => "json",
"roleid" => $data['role'],
"courseid" => $data['moojlacourse'],
"enrolments" => array()
);
foreach($results as $result)
{
$mid = MoojlaHelper::joomlaToMoodleID($result->user_id);
if($mid)
{
$dataObj['enrolments'][] = array(
"userid" => $mid,
);
}
}
$res = MoojlaHelper::sendRequestToMoodle($dataObj);
/***[/JCBGUI$$$$]***/
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
course_group_maps.php000064400000026765151162147310011032 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage course_group_maps.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Course_group_maps Model
*/
class MoojlaModelCourse_group_maps extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.role','role',
'g.fullname','moojlacourse',
'h.title','course_group'
);
}
parent::__construct($config);
}
/***[JCBGUI.admin_view.php_model_list.135.$$$$]***/
public function group_users($group_id)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('count(*) as num_of_group_users');
$query->from($db->quoteName('#__user_usergroup_map',
'ugm'));
$query->where($db->quoteName('ugm.group_id').'='.$db->quote($group_id));
$db->setQuery($query);
$result = $db->loadObject();
return "<span style='background: #43a4c1;color:
#fff;border-radius: 9px;padding: 2px
9px'>{$result->num_of_group_users}
".JText::_('COM_MOOJLA_GROUP_USERS')."</span>";
}
public function group_courses($group_id, $course_id)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id');
$query->from($db->quoteName('#__moojla_course_group_map',
'mgm'));
$query->where($db->quoteName('mgm.course_group').'='.$db->quote($group_id));
$db->setQuery($query);
$results = $db->loadObjectList();
if (count($results) > 1)
{
$html= jtext::_('COM_MOOJLA_GROUP_TOTAL_COURSES')."
<span style='background: #f20d38;color: #fff;border-radius:
9px;padding: 2px 9px'>".count($results)."</span>
".jtext::_('COM_MOOJLA_ROW_ID');
foreach ($results as $result) {
$html .= "<span style='background: #48a835;color:
#fff;border-radius: 9px;padding: 2px
9px'>{$result->id}</span> ";
}
return $html;
}
}/***[/JCBGUI$$$$]***/
/**
* 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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$role = $this->getUserStateFromRequest($this->context .
'.filter.role', 'filter_role');
if ($formSubmited)
{
$role = $app->input->post->get('role');
$this->setState('filter.role', $role);
}
$moojlacourse = $this->getUserStateFromRequest($this->context .
'.filter.moojlacourse', 'filter_moojlacourse');
if ($formSubmited)
{
$moojlacourse =
$app->input->post->get('moojlacourse');
$this->setState('filter.moojlacourse', $moojlacourse);
}
$course_group = $this->getUserStateFromRequest($this->context .
'.filter.course_group', 'filter_course_group');
if ($formSubmited)
{
$course_group =
$app->input->post->get('course_group');
$this->setState('filter.course_group', $course_group);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// set selection value to a translatable value
if (MoojlaHelper::checkArray($items))
{
foreach ($items as $nr => &$item)
{
// convert role
$item->role = $this->selectionTranslation($item->role,
'role');
}
}
// return items
return $items;
}
/**
* Method to convert selection values to translatable string.
*
* @return translatable string
*/
public function selectionTranslation($value,$name)
{
// Array of role language strings
if ($name === 'role')
{
$roleArray = array(
0 => 'COM_MOOJLA_COURSE_GROUP_MAP_SELECT_ROLE',
5 => 'COM_MOOJLA_COURSE_GROUP_MAP_STUDENT',
3 => 'COM_MOOJLA_COURSE_GROUP_MAP_TEACHER',
1 => 'COM_MOOJLA_COURSE_GROUP_MAP_MANAGER'
);
// Now check if value is found in this array
if (isset($roleArray[$value]) &&
MoojlaHelper::checkString($roleArray[$value]))
{
return $roleArray[$value];
}
}
return $value;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_course_group_map',
'a'));
// From the moojla_course table.
$query->select($db->quoteName('g.fullname','moojlacourse_fullname'));
$query->join('LEFT',
$db->quoteName('#__moojla_course', 'g') . ' ON
(' . $db->quoteName('a.moojlacourse') . ' = ' .
$db->quoteName('g.remoteid') . ')');
// From the usergroups table.
$query->select($db->quoteName('h.title','course_group_title'));
$query->join('LEFT',
$db->quoteName('#__usergroups', 'h') . ' ON
(' . $db->quoteName('a.course_group') . ' = ' .
$db->quoteName('h.id') . ')');
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.moojlacourse LIKE '.$search.' OR
g.fullname LIKE '.$search.' OR a.course_group LIKE
'.$search.' OR h.title LIKE '.$search.')');
}
}
// Filter by Role.
$_role = $this->getState('filter.role');
if (is_numeric($_role))
{
if (is_float($_role))
{
$query->where('a.role = ' . (float) $_role);
}
else
{
$query->where('a.role = ' . (int) $_role);
}
}
elseif (MoojlaHelper::checkString($_role))
{
$query->where('a.role = ' .
$db->quote($db->escape($_role)));
}
elseif (MoojlaHelper::checkArray($_role))
{
// Secure the array for the query
$_role = array_map( function ($val) use(&$db) {
if (is_numeric($val))
{
if (is_float($val))
{
return (float) $val;
}
else
{
return (int) $val;
}
}
elseif (MoojlaHelper::checkString($val))
{
return $db->quote($db->escape($val));
}
}, $_role);
// Filter by the Role Array.
$query->where('a.role IN (' . implode(',',
$_role) . ')');
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
// Check if the value is an array
$_role = $this->getState('filter.role');
if (MoojlaHelper::checkArray($_role))
{
$id .= ':' . implode(':', $_role);
}
// Check if this is only an number or string
elseif (is_numeric($_role)
|| MoojlaHelper::checkString($_role))
{
$id .= ':' . $_role;
}
$id .= ':' .
$this->getState('filter.moojlacourse');
$id .= ':' .
$this->getState('filter.course_group');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_course_group_map'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_course_group_map'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
enrolment.php000064400000051145151162147310007267 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage enrolment.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Enrolment Model
*/
class MoojlaModelEnrolment extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'moojlacourse',
'role'
),
'right' => array(
'jid',
'enrolldate'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.enrolment';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'enrolment', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.enrolment',
'enrolment', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.enrolment.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/enrolment.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.enrolment.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.enrolment.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.enrolment.'. ((int) isset($data[$key]) ? $data[$key]
: 0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_enrolment'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.enrolment.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.enrolment', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('enrolment');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('enrolment');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('enrolment');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
}
enrolments.php000064400000023055151162147310007451 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage enrolments.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Enrolments Model
*/
class MoojlaModelEnrolments extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.role','role',
'g.fullname','moojlacourse',
'h.name','jid',
'a.enrolldate','enrolldate'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$role = $this->getUserStateFromRequest($this->context .
'.filter.role', 'filter_role');
if ($formSubmited)
{
$role = $app->input->post->get('role');
$this->setState('filter.role', $role);
}
$moojlacourse = $this->getUserStateFromRequest($this->context .
'.filter.moojlacourse', 'filter_moojlacourse');
if ($formSubmited)
{
$moojlacourse =
$app->input->post->get('moojlacourse');
$this->setState('filter.moojlacourse', $moojlacourse);
}
$jid = $this->getUserStateFromRequest($this->context .
'.filter.jid', 'filter_jid');
if ($formSubmited)
{
$jid = $app->input->post->get('jid');
$this->setState('filter.jid', $jid);
}
$enrolldate = $this->getUserStateFromRequest($this->context .
'.filter.enrolldate', 'filter_enrolldate');
if ($formSubmited)
{
$enrolldate = $app->input->post->get('enrolldate');
$this->setState('filter.enrolldate', $enrolldate);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// set selection value to a translatable value
if (MoojlaHelper::checkArray($items))
{
foreach ($items as $nr => &$item)
{
// convert role
$item->role = $this->selectionTranslation($item->role,
'role');
}
}
// return items
return $items;
}
/**
* Method to convert selection values to translatable string.
*
* @return translatable string
*/
public function selectionTranslation($value,$name)
{
// Array of role language strings
if ($name === 'role')
{
$roleArray = array(
0 => 'COM_MOOJLA_ENROLMENT_SELECT_AN_OPTION',
1 => 'COM_MOOJLA_ENROLMENT_MANAGER',
2 => 'COM_MOOJLA_ENROLMENT_COURSE_CREATOR',
3 => 'COM_MOOJLA_ENROLMENT_TEACHER',
4 => 'COM_MOOJLA_ENROLMENT_NONEDITING_TEACHER',
5 => 'COM_MOOJLA_ENROLMENT_STUDENT'
);
// Now check if value is found in this array
if (isset($roleArray[$value]) &&
MoojlaHelper::checkString($roleArray[$value]))
{
return $roleArray[$value];
}
}
return $value;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_enrolment',
'a'));
// From the moojla_course table.
$query->select($db->quoteName('g.fullname','moojlacourse_fullname'));
$query->join('LEFT',
$db->quoteName('#__moojla_course', 'g') . ' ON
(' . $db->quoteName('a.moojlacourse') . ' = ' .
$db->quoteName('g.remoteid') . ')');
// From the users table.
$query->select($db->quoteName('h.name','jid_name'));
$query->join('LEFT', $db->quoteName('#__users',
'h') . ' ON (' . $db->quoteName('a.jid') .
' = ' . $db->quoteName('h.id') . ')');
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.moojlacourse LIKE '.$search.' OR
g.fullname LIKE '.$search.' OR a.jid LIKE '.$search.'
OR h.name LIKE '.$search.')');
}
}
// Filter by Role.
$_role = $this->getState('filter.role');
if (is_numeric($_role))
{
if (is_float($_role))
{
$query->where('a.role = ' . (float) $_role);
}
else
{
$query->where('a.role = ' . (int) $_role);
}
}
elseif (MoojlaHelper::checkString($_role))
{
$query->where('a.role = ' .
$db->quote($db->escape($_role)));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.role');
$id .= ':' .
$this->getState('filter.moojlacourse');
$id .= ':' . $this->getState('filter.jid');
$id .= ':' . $this->getState('filter.enrolldate');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_enrolment'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_enrolment'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
fields/ads.php000064400000004215151162147310007275 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage ads.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Ads Form Field class for the Moojla component
*/
class JFormFieldAds extends JFormFieldList
{
/**
* The ads field type.
*
* @var string
*/
public $type = 'ads';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$document = JFactory::getDocument();
$document->addScript('components/com_moojla/assets/js/admin.js');
JPluginHelper::importPlugin("moojlaaditionalfields");
$dispatcher = JEventDispatcher::getInstance();
$items = $dispatcher->trigger("getName", array());
$options = array();
$options[] = JHtml::_('select.option', '',
'Select an option');
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id,
$item->additional_data_source_name);
}
}
return $options;
}
}
fields/contentsfiltercontentsmoduleid.php000064400000005007151162147310015072
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage contentsfiltercontentsmoduleid.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Contentsfiltercontentsmoduleid Form Field class for the Moojla component
*/
class JFormFieldContentsfiltercontentsmoduleid extends JFormFieldList
{
/**
* The contentsfiltercontentsmoduleid field type.
*
* @var string
*/
public $type = 'contentsfiltercontentsmoduleid';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select the text.
$query->select($db->quoteName('contents_module_id'));
$query->from($db->quoteName('#__moojla_content'));
$query->order($db->quoteName('contents_module_id') .
' ASC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
$results = $db->loadColumn();
$_filter = array();
$_filter[] = JHtml::_('select.option', '', '-
' . JText::_('COM_MOOJLA_FILTER_SELECT_CONTENTS_MODULE_ID')
. ' -');
if ($results)
{
$results = array_unique($results);
foreach ($results as $contents_module_id)
{
// Now add the contents_module_id and its text to the options array
$_filter[] = JHtml::_('select.option', $contents_module_id,
$contents_module_id);
}
}
return $_filter;
}
}
fields/contentsfiltermimetype.php000064400000004642151162147310013347
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage contentsfiltermimetype.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Contentsfiltermimetype Form Field class for the Moojla component
*/
class JFormFieldContentsfiltermimetype extends JFormFieldList
{
/**
* The contentsfiltermimetype field type.
*
* @var string
*/
public $type = 'contentsfiltermimetype';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select the text.
$query->select($db->quoteName('mimetype'));
$query->from($db->quoteName('#__moojla_content'));
$query->order($db->quoteName('mimetype') . '
ASC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
$results = $db->loadColumn();
$_filter = array();
$_filter[] = JHtml::_('select.option', '', '-
' . JText::_('COM_MOOJLA_FILTER_SELECT_CONTENTS_MIMETYPE') .
' -');
if ($results)
{
$results = array_unique($results);
foreach ($results as $mimetype)
{
// Now add the mimetype and its text to the options array
$_filter[] = JHtml::_('select.option', $mimetype, $mimetype);
}
}
return $_filter;
}
}
fields/course.php000064400000015153151162147310010031 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage course.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Course Form Field class for the Moojla component
*/
class JFormFieldCourse extends JFormFieldList
{
/**
* The course field type.
*
* @var string
*/
public $type = 'course';
/**
* Override to add new button
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
// see if we should add buttons
$set_button = $this->getAttribute('button');
// get html
$html = parent::getInput();
// if true set button
if ($set_button === 'true')
{
$button = array();
$script = array();
$button_code_name = $this->getAttribute('name');
// get the input from url
$app = JFactory::getApplication();
$jinput = $app->input;
// get the view name & id
$values = $jinput->getArray(array(
'id' => 'int',
'view' => 'word'
));
// check if new item
$ref = '';
$refJ = '';
if (!is_null($values['id']) &&
strlen($values['view']))
{
// only load referral if not new item.
$ref = '&ref=' . $values['view'] .
'&refid=' . $values['id'];
$refJ = '&ref=' . $values['view'] .
'&refid=' . $values['id'];
// get the return value.
$_uri = (string) JUri::getInstance();
$_return = urlencode(base64_encode($_uri));
// load return value.
$ref .= '&return=' . $_return;
$refJ .= '&return=' . $_return;
}
// get button label
$button_label = trim($button_code_name);
$button_label = preg_replace('/_+/', ' ',
$button_label);
$button_label = preg_replace('/\s+/', ' ',
$button_label);
$button_label = preg_replace("/[^A-Za-z ]/", '',
$button_label);
$button_label = ucfirst(strtolower($button_label));
// get user object
$user = JFactory::getUser();
// only add if user allowed to create course
if ($user->authorise('course.create',
'com_moojla') && $app->isAdmin()) // TODO for now only
in admin area.
{
// build Create button
$button[] = '<a
id="'.$button_code_name.'Create" class="btn
btn-small btn-success hasTooltip"
title="'.JText::sprintf('COM_MOOJLA_CREATE_NEW_S',
$button_label).'" style="border-radius: 0px 4px 4px 0px;
padding: 4px 4px 4px 7px;"
href="index.php?option=com_moojla&view=course&layout=edit'.$ref.'"
>
<span class="icon-new
icon-white"></span></a>';
}
// only add if user allowed to edit course
if ($user->authorise('course.edit', 'com_moojla')
&& $app->isAdmin()) // TODO for now only in admin area.
{
// build edit button
$button[] = '<a
id="'.$button_code_name.'Edit" class="btn
btn-small hasTooltip"
title="'.JText::sprintf('COM_MOOJLA_EDIT_S',
$button_label).'" style="display: none; padding: 4px 4px 4px
7px;" href="#" >
<span class="icon-edit"></span></a>';
// build script
$script[] = "
jQuery(document).ready(function() {
jQuery('#adminForm').on('change',
'#jform_".$button_code_name."',function (e) {
e.preventDefault();
var ".$button_code_name."Value =
jQuery('#jform_".$button_code_name."').val();
".$button_code_name."Button(".$button_code_name."Value);
});
var ".$button_code_name."Value =
jQuery('#jform_".$button_code_name."').val();
".$button_code_name."Button(".$button_code_name."Value);
});
function ".$button_code_name."Button(value) {
if (value > 0) {
// hide the create button
jQuery('#".$button_code_name."Create').hide();
// show edit button
jQuery('#".$button_code_name."Edit').show();
var url =
'index.php?option=com_moojla&view=courses&task=course.edit&id='+value+'".$refJ."';
jQuery('#".$button_code_name."Edit').attr('href',
url);
} else {
// show the create button
jQuery('#".$button_code_name."Create').show();
// hide edit button
jQuery('#".$button_code_name."Edit').hide();
}
}";
}
// check if button was created for course field.
if (is_array($button) && count($button) > 0)
{
// Load the needed script.
$document = JFactory::getDocument();
$document->addScriptDeclaration(implode(' ',$script));
// return the button attached to input field.
return '<div class="input-append">' .$html .
implode('',$button).'</div>';
}
}
return $html;
}
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.remoteid','a.shortname'),array('remoteid','course_detail_request_id_shortname')));
$query->from($db->quoteName('#__moojla_course',
'a'));
$query->where($db->quoteName('a.published') . ' =
1');
$query->order('a.shortname ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_moojla'))
{
$columns = $db->getTableColumns('#__moojla_course');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$query->where('a.published = 1');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '',
'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->remoteid,
$item->course_detail_request_id_shortname);
}
}
return $options;
}
}
fields/coursegroupmapsfilterrole.php000064400000004756151162147340014071
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage coursegroupmapsfilterrole.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Coursegroupmapsfilterrole Form Field class for the Moojla component
*/
class JFormFieldCoursegroupmapsfilterrole extends JFormFieldList
{
/**
* The coursegroupmapsfilterrole field type.
*
* @var string
*/
public $type = 'coursegroupmapsfilterrole';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select the text.
$query->select($db->quoteName('role'));
$query->from($db->quoteName('#__moojla_course_group_map'));
$query->order($db->quoteName('role') . ' ASC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
$results = $db->loadColumn();
$_filter = array();
if ($results)
{
// get course_group_mapsmodel
$model = MoojlaHelper::getModel('course_group_maps');
$results = array_unique($results);
foreach ($results as $role)
{
// Translate the role selection
$text = $model->selectionTranslation($role,'role');
// Now add the role and its text to the options array
$_filter[] = JHtml::_('select.option', $role,
JText::_($text));
}
}
return $_filter;
}
}
fields/coursescategory.php000064400000005112151162147340011747
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage coursescategory.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Coursescategory Form Field class for the Moojla component
*/
class JFormFieldCoursescategory extends JFormFieldList
{
/**
* The coursescategory field type.
*
* @var string
*/
public $type = 'coursescategory';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$params = JComponentHelper::getParams('com_moojla');
$shop_integration = trim($params->get('shop_integration'));
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
if($shop_integration == 'hk' ){
$query->select($db->quoteName(array('category_id','category_name'),array('id','title')));
$query->from($db->quoteName('#__hikashop_category',
'a'));
$query->where($db->quoteName('a.category_type') . '
= "product"');
$query->where($db->quoteName('a.category_published') .
' = 1');
}
$db->setQuery((string)$query);
if($shop_integration != "0"){
$items = $db->loadObjectList();
}
else
{
$items = array();
}
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '',
'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id,
$item->title);
}
}
return $options;
}
}
fields/customtemplatestyle.php000064400000006407151162147340012665
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage customtemplatestyle.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Customtemplatestyle Form Field class for the Moojla component
*/
class JFormFieldCustomtemplatestyle extends JFormFieldList
{
/**
* The customtemplatestyle field type.
*
* @var string
*/
public $type = 'customtemplatestyle';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.title'),array('id','course_templatestyle_forcourseconfig_title')));
$query->from($db->quoteName('#__template_styles',
'a'));
$query->where($db->quoteName('a.client_id') . ' =
0');
$query->order('a.title ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_templates'))
{
$columns = $db->getTableColumns('#__template_styles');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
$tmp_op = array();
if ($items)
{
$first = current($items);
$lbl = explode(' - ',
$first->course_templatestyle_forcourseconfig_title)[0];
$options[] = JHtml::_('select.option', '',
JText::_('JOPTION_USE_DEFAULT'));
$groups = array();
foreach($items as $item)
{
$thislbl = explode(' - ',
$item->course_templatestyle_forcourseconfig_title)[0];
$groups[$thislbl][] = ['id' => $item->id,
'course_templatestyle_title' =>
$item->course_templatestyle_forcourseconfig_title];
}
foreach($groups as $gkey => $group)
{
$options[] = JHtmlSelect::optgroup($gkey);
foreach($group as $item)
{
$options[] = JHtml::_('select.option',
$item['id'], $item['course_templatestyle_title']);
}
$options[] = JHtmlSelect::optgroup($gkey);
}
}
return $options;
}
}
fields/customusergroup.php000064400000014767151162147340012034
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage customusergroup.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Customusergroup Form Field class for the Moojla component
*/
class JFormFieldCustomusergroup extends JFormFieldList
{
/**
* The customusergroup field type.
*
* @var string
*/
public $type = 'customusergroup';
/**
* Override to add new button
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
// see if we should add buttons
$set_button = $this->getAttribute('button');
// get html
$html = parent::getInput();
// if true set button
if ($set_button === 'true')
{
$button = array();
$script = array();
$button_code_name = $this->getAttribute('name');
// get the input from url
$app = JFactory::getApplication();
$jinput = $app->input;
// get the view name & id
$values = $jinput->getArray(array(
'id' => 'int',
'view' => 'word'
));
// check if new item
$ref = '';
$refJ = '';
if (!is_null($values['id']) &&
strlen($values['view']))
{
// only load field details if not new item.
$ref = '&field=' . $values['view'] .
'&field_id=' . $values['id'];
$refJ = '&field=' . $values['view'] .
'&field_id=' . $values['id'];
// get the return value.
$_uri = (string) JUri::getInstance();
$_return = urlencode(base64_encode($_uri));
// load return value.
$ref = '&return=' . $_return;
$refJ = '&return=' . $_return;
}
// get button label
$button_label = trim($button_code_name);
$button_label = preg_replace('/_+/', ' ',
$button_label);
$button_label = preg_replace('/\s+/', ' ',
$button_label);
$button_label = preg_replace("/[^A-Za-z ]/", '',
$button_label);
$button_label = ucfirst(strtolower($button_label));
// get user object
$user = JFactory::getUser();
// only add if user allowed to create group
if ($user->authorise('core.create', 'com_users')
&& $app->isAdmin()) // TODO for now only in admin area.
{
// build Create button
$button[] = '<a
id="'.$button_code_name.'Create" class="btn
btn-small btn-success hasTooltip"
title="'.JText::sprintf('COM_MOOJLA_CREATE_NEW_S',
$button_label).'" style="border-radius: 0px 4px 4px 0px;
padding: 4px 4px 4px 7px;"
href="index.php?option=com_users&view=group&layout=edit'.$ref.'"
>
<span class="icon-new
icon-white"></span></a>';
}
// only add if user allowed to edit group
if ($user->authorise('core.edit', 'com_users')
&& $app->isAdmin()) // TODO for now only in admin area.
{
// build edit button
$button[] = '<a
id="'.$button_code_name.'Edit" class="btn
btn-small hasTooltip"
title="'.JText::sprintf('COM_MOOJLA_EDIT_S',
$button_label).'" style="display: none; padding: 4px 4px 4px
7px;" href="#" >
<span class="icon-edit"></span></a>';
// build script
$script[] = "
jQuery(document).ready(function() {
jQuery('#adminForm').on('change',
'#jform_".$button_code_name."',function (e) {
e.preventDefault();
var ".$button_code_name."Value =
jQuery('#jform_".$button_code_name."').val();
".$button_code_name."Button(".$button_code_name."Value);
});
var ".$button_code_name."Value =
jQuery('#jform_".$button_code_name."').val();
".$button_code_name."Button(".$button_code_name."Value);
});
function ".$button_code_name."Button(value) {
if (value > 0) {
// hide the create button
jQuery('#".$button_code_name."Create').hide();
// show edit button
jQuery('#".$button_code_name."Edit').show();
var url =
'index.php?option=com_users&view=groups&task=group.edit&id='+value+'".$refJ."';
jQuery('#".$button_code_name."Edit').attr('href',
url);
} else {
// show the create button
jQuery('#".$button_code_name."Create').show();
// hide edit button
jQuery('#".$button_code_name."Edit').hide();
}
}";
}
// check if button was created for group field.
if (is_array($button) && count($button) > 0)
{
// Load the needed script.
$document = JFactory::getDocument();
$document->addScriptDeclaration(implode(' ',$script));
// return the button attached to input field.
return '<div class="input-append">' .$html .
implode('',$button).'</div>';
}
}
return $html;
}
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.title'),array('id','course_group_title')));
$query->from($db->quoteName('#__usergroups',
'a'));
$query->order('a.title ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_users'))
{
$columns = $db->getTableColumns('#__usergroups');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '',
'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id,
$item->course_group_title);
}
}
return $options;
}
}
fields/enrolmentsfilterrole.php000064400000005047151162147340013013
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage enrolmentsfilterrole.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Enrolmentsfilterrole Form Field class for the Moojla component
*/
class JFormFieldEnrolmentsfilterrole extends JFormFieldList
{
/**
* The enrolmentsfilterrole field type.
*
* @var string
*/
public $type = 'enrolmentsfilterrole';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select the text.
$query->select($db->quoteName('role'));
$query->from($db->quoteName('#__moojla_enrolment'));
$query->order($db->quoteName('role') . ' ASC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
$results = $db->loadColumn();
$_filter = array();
$_filter[] = JHtml::_('select.option', '', '-
' . JText::_('COM_MOOJLA_FILTER_SELECT_ROLE') . '
-');
if ($results)
{
// get enrolmentsmodel
$model = MoojlaHelper::getModel('enrolments');
$results = array_unique($results);
foreach ($results as $role)
{
// Translate the role selection
$text = $model->selectionTranslation($role,'role');
// Now add the role and its text to the options array
$_filter[] = JHtml::_('select.option', $role,
JText::_($text));
}
}
return $_filter;
}
}
fields/fulllanguage.php000064400000010350151162147340011174
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.63
@build 10th May, 2021
@created 22nd July, 2020
@package Moojla
@subpackage fulllanguage.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Fulllanguage Form Field class for the Moojla component
*/
class JFormFieldFulllanguage extends JFormFieldList
{
/**
* The fulllanguage field type.
*
* @var string
*/
public $type = 'fulllanguage';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
$script = '
jQuery(document).ready(function($){
langselector = $("#myform_language");
langselector.change(function(e){
lang = $(this).val();
originalTextArea = $("#myform_original_translation");
overrideTextArea = $("#myform_override");
if(lang){
isAdmin = lang.substr(-1) == 1 ? true : false;
code = lang.substr(0, lang.length - 1);
url = `/${isAdmin ? "administrator/" :
""}language/overrides/${code}.override.ini`;
// console.log(url);
jQuery.ajax({
url: url,
cache: false,
beforeSend: function(){
// console.log("beforeSend");
overrideTextArea.val("Wait please ...");
},
success: function(data, textStatus, xhr){
ct = xhr.getResponseHeader("content-type") || "";
// console.log("success");
// console.log(ct);
if(ct != "text/html; charset=utf-8")
overrideTextArea.val(data);
else
overrideTextArea.val("");
},
error: function(data, textStatus, xhr){
overrideTextArea.val("");
// ct = xhr.getResponseHeader("content-type") ||
"";
// console.log("error");
// console.log(ct);
},
});
url = `/${isAdmin ? "administrator/" :
""}language/${code}/${code}.com_moojla.ini`;
// console.log(url);
jQuery.ajax({
url: url,
cache: false,
beforeSend: function(){
// console.log("beforeSend");
originalTextArea.val("Wait please ...");
},
success: function(data, textStatus, xhr){
ct = xhr.getResponseHeader("content-type") || "";
// console.log("success");
// console.log(ct);
if(ct != "text/html; charset=utf-8")
originalTextArea.val(data);
else
originalTextArea.val("");
},
error: function(data, textStatus, xhr){
ct = xhr.getResponseHeader("content-type") || "";
// console.log("error");
// console.log(ct);
},
});
}
else{
overrideTextArea.val("");
originalTextArea.val("");
}
});
})';
$document = JFactory::getDocument();
$document->addScriptDeclaration($script);
$languages = array();
$languages[] = JHtml::_('select.option', '',
'Select an option');
$site_languages = JLanguageHelper::getKnownLanguages(JPATH_SITE);
$admin_languages =
JLanguageHelper::getKnownLanguages(JPATH_ADMINISTRATOR);
// Create a single array of them.
foreach ($site_languages as $tag => $language)
{
$languages[$tag . '0'] = $language['name'] . '
- ' . JText::_('JSITE');
}
foreach ($admin_languages as $tag => $language)
{
$languages[$tag . '1'] = $language['name'] . '
- ' . JText::_('JADMINISTRATOR');
}
// Sort it by language tag and by client after that.
ksort($languages);
return array_merge(parent::getOptions(), $languages);
}
}
fields/juserfields.php000064400000007057151162147340011057 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage juserfields.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Juserfields Form Field class for the Moojla component
*/
class JFormFieldJuserfields extends JFormFieldList
{
/**
* The juserfields field type.
*
* @var string
*/
public $type = 'juserfields';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$params = JComponentHelper::getParams('com_moojla');
$ads = trim($params->get('additional_data_source'));
switch($ads)
{
case "jf":
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.name'),array('id','juserfields_name')));
$query->from($db->quoteName('#__fields',
'a'));
$query->where($db->quoteName('a.state') . ' =
1');
$query->where($db->quoteName('a.context') . ' =
"com_users.user"');
$query->order('a.name ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_moojla'))
{
$columns = $db->getTableColumns('#__fields');
if(isset($columns['access']))
{
$groups = implode(',',
$user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups .
')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
foreach($items as $index => $item)
{
$items[$index]->id = 'jf_'.$item->juserfields_name;
}
break;
case "cb":
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$sql = "DESC #__comprofiler";
$db->setQuery($sql);
$items = $db->loadObjectList();
foreach($items as $index => $item)
{
$obj = new stdClass();
$obj->id = 'cb_'.$item->Field;
$obj->juserfields_name = $item->Field;
$items[$index] = $obj;
}
break;
}
$standardFields = ['name', 'email',
'groups'];
foreach($standardFields as $index => $sf)
{
$obj = new stdClass();
$obj->id = 'sj_'.$sf;
$obj->juserfields_name = $sf;
$items[] = $obj;
}
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '',
'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id,
$item->juserfields_name);
}
}
return $options;
}
}
fields/mcategory.php000064400000005321151162147340010522 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage mcategory.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Mcategory Form Field class for the Moojla component
*/
class JFormFieldMcategory extends JFormFieldList
{
/**
* The mcategory field type.
*
* @var string
*/
public $type = 'mcategory';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.catid','c.title'),array('catid','category_title')));
$query->from($db->quoteName('#__moojla_course',
'a'));
$query->join('inner',
$db->quoteName('#__categories', 'c') .
'on' . $db->quoteName('a.catid') . '=' .
$db->quoteName('c.id'));
$query->where($db->quoteName('a.published') . ' =
1');
$query->order('c.title ASC');
$query->group('catid');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_moojla'))
{
$columns = $db->getTableColumns('#__moojla_course');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->catid,
$item->category_title);
}
}
return $options;
}
}
fields/mcohort.php000064400000004357151162147340010213 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage mcohort.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Mcohort Form Field class for the Moojla component
*/
class JFormFieldMcohort extends JFormFieldList
{
/**
* The mcohort field type.
*
* @var string
*/
public $type = 'mcohort';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
//user
$user = JFactory::getUser();
$document = JFactory::getDocument();
$document->addScript('components/com_moojla/assets/js/admin.js');
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$dataObj = array(
"wsfunction" => "moojla_get_cohorts",
"moodlewsrestformat" => "json",
);
$items =
json_decode(moojlaHelper::sendRequestToMoodle($dataObj)->response);
$options = array();
$options[] = JHtml::_('select.option', '',
'Select an option');
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id ,
$item->name);
}
}
return $options;
}
}
fields/mcoursefields.php000064400000004221151162147340011372
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage mcoursefields.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Mcoursefields Form Field class for the Moojla component
*/
class JFormFieldMcoursefields extends JFormFieldList
{
/**
* The mcoursefields field type.
*
* @var string
*/
public $type = 'mcoursefields';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$options = array();
$options[] = JHtml::_('select.option', '',
'Select an option');
$items = array();
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$data = array(
"wsfunction" =>
"moojla_get_course_custom_fields",
"moodlewsrestformat" => "json",
);
$items =
json_decode(MoojlaHelper::sendRequestToMoodle($data)->response);
foreach($items as $item)
{
$options[] = JHtml::_('select.option',
'cm_'.$item->id, $item->name);
}
return $options;
}
}
fields/modulesfiltermodname.php000064400000004613151162147340012752
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage modulesfiltermodname.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Modulesfiltermodname Form Field class for the Moojla component
*/
class JFormFieldModulesfiltermodname extends JFormFieldList
{
/**
* The modulesfiltermodname field type.
*
* @var string
*/
public $type = 'modulesfiltermodname';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select the text.
$query->select($db->quoteName('modname'));
$query->from($db->quoteName('#__moojla_module'));
$query->order($db->quoteName('modname') . '
ASC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
$results = $db->loadColumn();
$_filter = array();
$_filter[] = JHtml::_('select.option', '', '-
' . JText::_('COM_MOOJLA_FILTER_SELECT_MODULE_TYPE') .
' -');
if ($results)
{
$results = array_unique($results);
foreach ($results as $modname)
{
// Now add the modname and its text to the options array
$_filter[] = JHtml::_('select.option', $modname, $modname);
}
}
return $_filter;
}
}
fields/modulesfiltermodulesectionid.php000064400000004765151162147340014531
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage modulesfiltermodulesectionid.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Modulesfiltermodulesectionid Form Field class for the Moojla component
*/
class JFormFieldModulesfiltermodulesectionid extends JFormFieldList
{
/**
* The modulesfiltermodulesectionid field type.
*
* @var string
*/
public $type = 'modulesfiltermodulesectionid';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select the text.
$query->select($db->quoteName('module_section_id'));
$query->from($db->quoteName('#__moojla_module'));
$query->order($db->quoteName('module_section_id') .
' ASC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
$results = $db->loadColumn();
$_filter = array();
$_filter[] = JHtml::_('select.option', '', '-
' . JText::_('COM_MOOJLA_FILTER_SELECT_MODULE_SECTION_ID') .
' -');
if ($results)
{
$results = array_unique($results);
foreach ($results as $module_section_id)
{
// Now add the module_section_id and its text to the options array
$_filter[] = JHtml::_('select.option', $module_section_id,
$module_section_id);
}
}
return $_filter;
}
}
fields/moodlecoursecategories.php000064400000004320151162147340013274
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage moodlecoursecategories.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Moodlecoursecategories Form Field class for the Moojla component
*/
class JFormFieldMoodlecoursecategories extends JFormFieldList
{
/**
* The moodlecoursecategories field type.
*
* @var string
*/
public $type = 'moodlecoursecategories';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
$user = JFactory::getUser();
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$dataObj = array(
"wsfunction" =>
"moojla_get_course_categories",
"moodlewsrestformat" => "json",
);
$items =
json_decode(moojlaHelper::sendRequestToMoodle($dataObj)->response);
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '',
'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id ,
$item->name);
}
}
return $options;
}
}
fields/moodletag.php000064400000005140151162147340010502 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage moodletag.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Moodletag Form Field class for the Moojla component
*/
class JFormFieldMoodletag extends JFormFieldList
{
/**
* The moodletag field type.
*
* @var string
*/
public $type = 'moodletag';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.tagid','a.tagname'),array('tagid','moodletag_tagname')));
$query->from($db->quoteName('#__moojla_tag',
'a'));
$query->where($db->quoteName('a.published') . ' =
1');
$query->order('a.tagname ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_moojla'))
{
$columns = $db->getTableColumns('#__moojla_tag');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '',
'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->tagid,
$item->moodletag_tagname);
}
}
return $options;
}
}
fields/moojlacourse.php000064400000005233151162147340011234
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage moojlacourse.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Moojlacourse Form Field class for the Moojla component
*/
class JFormFieldMoojlacourse extends JFormFieldList
{
/**
* The moojlacourse field type.
*
* @var string
*/
public $type = 'moojlacourse';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.remoteid','a.fullname'),array('remoteid','moojlacourse_fullname')));
$query->from($db->quoteName('#__moojla_course',
'a'));
$query->where($db->quoteName('a.published') . ' =
1');
// $query->order('a.fullname ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_moojla'))
{
$columns = $db->getTableColumns('#__moojla_course');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '',
'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->remoteid,
$item->moojlacourse_fullname);
}
}
return $options;
}
}
fields/moojlacoursefield.php000064400000005265151162147340012245
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage moojlacoursefield.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Moojlacoursefield Form Field class for the Moojla component
*/
class JFormFieldMoojlacoursefield extends JFormFieldList
{
/**
* The moojlacoursefield field type.
*
* @var string
*/
public $type = 'moojlacoursefield';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.name'),array('id','coursefield_name')));
$query->from($db->quoteName('#__fields',
'a'));
$query->where($db->quoteName('a.state') . ' =
1');
$query->where($db->quoteName('a.context') . ' =
"com_moojla.course"');
$query->order('a.name ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_moojla'))
{
$columns = $db->getTableColumns('#__fields');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '',
'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id,
$item->coursefield_name);
}
}
return $options;
}
}
fields/mtag.php000064400000005077151162147340007470 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage mtag.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Mtag Form Field class for the Moojla component
*/
class JFormFieldMtag extends JFormFieldList
{
/**
* The mtag field type.
*
* @var string
*/
public $type = 'mtag';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.tagid','a.tagname'),array('tagid','tag_tagname')));
$query->from($db->quoteName('#__moojla_tag',
'a'));
$query->where($db->quoteName('a.published') . ' =
1');
$query->where($db->quoteName('a.isstandard')
. ' = 1');
$query->order('a.tagname ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_moojla'))
{
$columns = $db->getTableColumns('#__moojla_tag');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->tagid,
$item->tag_tagname);
}
}
return $options;
}
}
fields/mteacher.php000064400000005661151162147340010327 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage mteacher.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Mteacher Form Field class for the Moojla component
*/
class JFormFieldMteacher extends JFormFieldList
{
/**
* The mteacher field type.
*
* @var string
*/
public $type = 'mteacher';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$role=
JComponentHelper::getParams('com_moojla')->get('role');
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.mid','a.jid','u.name'),array('mid','teacher_jid','name')));
$query->from($db->quoteName('#__moojla_user_map',
'a'));
$query->join('inner',$db->quoteName('#__moojla_enrolment',
'e').' on
'.$db->quoteName('a.jid').'='.$db->quoteName('e.jid'));
$query->join('inner',$db->quoteName('#__users',
'u').' on
'.$db->quoteName('a.jid').'='.$db->quoteName('u.id'));
$query->where($db->quoteName('e.role') . ' =
'.$db->quote($role));
$query->where($db->quoteName('a.published') . ' =
1');
$query->order('a.jid ASC');
$query->group('a.mid');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_moojla'))
{
$columns = $db->getTableColumns('#__moojla_user_map');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->mid,
$item->name);
}
}
return $options;
}
}
fields/muserfields.php000064400000006106151162147340011054 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage muserfields.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Muserfields Form Field class for the Moojla component
*/
class JFormFieldMuserfields extends JFormFieldList
{
/**
* The muserfields field type.
*
* @var string
*/
public $type = 'muserfields';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$fields = array ('firstname', 'lastname',
'email', 'icq', 'skype', 'yahoo',
'aim', 'msn', 'phone1', 'phone2',
'institution', 'department',
'address', 'city', 'country',
'lang', 'timezone', 'idnumber',
'description', 'lastnamephonetic',
'firstnamephonetic', 'middlename',
'alternatename');
$input = JFactory::getApplication()->input;
$id = $input->get('id', 0);
$options = array();
$options[] = JHtml::_('select.option', '',
'Select an option');
$items = array();
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$data = array(
"wsfunction" =>
"moojla_get_custom_fields",
"moodlewsrestformat" => "json",
);
$items =
json_decode(MoojlaHelper::sendRequestToMoodle($data)->response);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('muserfields')));
$query->from($db->quoteName('#__moojla_user_field_map'));
$query->where($db->quoteName('id') . ' <>
' . $db->quote($id));
$query->where($db->quoteName('published') . ' =
1');
$db->setQuery($query);
$selectedbefore = $db->loadColumn();
foreach($fields as $field)
{
if(!in_array('sm_'.$field, $selectedbefore))
$options[] = JHtml::_('select.option',
'sm_'.$field, $field);
}
foreach($items as $item)
{
if(!in_array('cm_'.$item->id, $selectedbefore))
$options[] = JHtml::_('select.option',
'cm_'.$item->id, $item->name);
}
return $options;
}
}
fields/mycustomtemplatestyle.php000064400000006327151162147340013234
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage mycustomtemplatestyle.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Mycustomtemplatestyle Form Field class for the Moojla component
*/
class JFormFieldMycustomtemplatestyle extends JFormFieldList
{
/**
* The mycustomtemplatestyle field type.
*
* @var string
*/
public $type = 'mycustomtemplatestyle';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.title'),array('id','course_templatestyle_title')));
$query->from($db->quoteName('#__template_styles',
'a'));
$query->where($db->quoteName('a.client_id') . ' =
0');
$query->order('a.title ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options',
'com_templates'))
{
$columns = $db->getTableColumns('#__template_styles');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
$tmp_op = array();
if ($items)
{
$first = current($items);
$lbl = explode(' - ',
$first->course_templatestyle_title)[0];
$options[] = JHtml::_('select.option', '',
JText::_('JOPTION_USE_DEFAULT'));
$groups = array();
foreach($items as $item)
{
$thislbl = explode(' - ',
$item->course_templatestyle_title)[0];
$groups[$thislbl][] = ['id' => $item->id,
'course_templatestyle_title' =>
$item->course_templatestyle_title];
}
foreach($groups as $gkey => $group)
{
$options[] = JHtmlSelect::optgroup($gkey);
foreach($group as $item)
{
$options[] = JHtml::_('select.option',
$item['id'], $item['course_templatestyle_title']);
}
$options[] = JHtmlSelect::optgroup($gkey);
}
////
}
return $options;
}
}
fields/sectionsfiltercourseid.php000064400000004631151162147360013330
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage sectionsfiltercourseid.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Sectionsfiltercourseid Form Field class for the Moojla component
*/
class JFormFieldSectionsfiltercourseid extends JFormFieldList
{
/**
* The sectionsfiltercourseid field type.
*
* @var string
*/
public $type = 'sectionsfiltercourseid';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select the text.
$query->select($db->quoteName('courseid'));
$query->from($db->quoteName('#__moojla_section'));
$query->order($db->quoteName('courseid') . '
ASC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
$results = $db->loadColumn();
$_filter = array();
$_filter[] = JHtml::_('select.option', '', '-
' . JText::_('COM_MOOJLA_FILTER_SELECT_COURSEID') . '
-');
if ($results)
{
$results = array_unique($results);
foreach ($results as $courseid)
{
// Now add the courseid and its text to the options array
$_filter[] = JHtml::_('select.option', $courseid, $courseid);
}
}
return $_filter;
}
}
fields/shopintegration.php000064400000006653151162147360011760
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage shopintegration.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Shopintegration Form Field class for the Moojla component
*/
class JFormFieldShopintegration extends JFormFieldList
{
/**
* The shopintegration field type.
*
* @var string
*/
public $type = 'shopintegration';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
?>
<script>
jQuery(document).ready(function($){
var shop_integration_val=
$('#jform_shop_integration').val();
$('#jform_shop_integration').on('change', function() {
var val= $(this).val()
$('#shop_integration_message').remove();
$.ajax({
url: 'index.php?option=com_moojla',
method: 'post',
data: {'shop_name':
val,'task':'ajax.shop_requirement','format':'json','raw':'true',
'token': '<?= JSession::getFormToken()?>'},
success: function(msg){
if (msg)
{
$('#jform_shop_integration').parents('.control-group').append('<div
style="padding: 10px 0;"
id="shop_integration_message"></div>')
msg.messages.each(function(value, index){
$('#shop_integration_message').append('<div
style="margin: 0;" class="alert
alert-'+value.class+'">'+value.message+'</div>');
})
}
}
})
});
})
</script>
<?php
$user = JFactory::getUser();
// Get the databse object.
JPluginHelper::importPlugin("moojlashopintegration");
$dispatcher = JEventDispatcher::getInstance();
$items = $dispatcher->trigger("getShopIntegrationName",
array());
$options = array();
$options[] = JHtml::_('select.option', '',
'Select an option');
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id,
$item->shop_integration_name);
}
}
return $options;
}
}
fields/skyroommod.php000064400000004142151162147360010735 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage skyroommod.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Skyroommod Form Field class for the Moojla component
*/
class JFormFieldSkyroommod extends JFormFieldList
{
/**
* The skyroommod field type.
*
* @var string
*/
public $type = 'skyroommod';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
$user = JFactory::getUser();
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$dataObj = array(
"wsfunction" =>
"moojla_get_plugins_of_type",
"moodlewsrestformat" => "json",
"type"=>"mod"
);
$items =
json_decode(moojlaHelper::sendRequestToMoodle($dataObj)->response);
$options = array();
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->name ,
$item->name);
}
}
return $options;
}
}
fields/staffusers.php000064400000003676151162147360010732 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage staffusers.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('user');
/**
* Staffusers Form Field class for the Moojla component
*/
class JFormFieldStaffusers extends JFormFieldUser
{
/**
* The staffusers field type.
*
* @var string
*/
public $type = 'staffusers';
/**
* Method to get the filtering groups (null means no filtering)
*
* @return mixed array of filtering groups or null.
*
* @since 1.6
*/
protected function getGroups()
{
// set the groups array
$groups =
JComponentHelper::getParams('com_moojla')->get('staffusers');
return $groups;
}
/**
* Method to get the users to exclude from the list of users
*
* @return mixed Array of users to exclude or null to to not exclude
them
*
* @since 1.6
*/
protected function getExcluded()
{
return null;
}
}
fields/userfieldsmapfilteriscv.php000064400000005103151162147360013466
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage userfieldsmapfilteriscv.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Userfieldsmapfilteriscv Form Field class for the Moojla component
*/
class JFormFieldUserfieldsmapfilteriscv extends JFormFieldList
{
/**
* The userfieldsmapfilteriscv field type.
*
* @var string
*/
public $type = 'userfieldsmapfilteriscv';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select the text.
$query->select($db->quoteName('iscv'));
$query->from($db->quoteName('#__moojla_user_field_map'));
$query->order($db->quoteName('iscv') . ' ASC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
$results = $db->loadColumn();
$_filter = array();
$_filter[] = JHtml::_('select.option', '', '-
' . JText::_('COM_MOOJLA_FILTER_SELECT_CV') . '
-');
if ($results)
{
// get user_fields_mapmodel
$model = MoojlaHelper::getModel('user_fields_map');
$results = array_unique($results);
foreach ($results as $iscv)
{
// Translate the iscv selection
$text = $model->selectionTranslation($iscv,'iscv');
// Now add the iscv and its text to the options array
$_filter[] = JHtml::_('select.option', $iscv,
JText::_($text));
}
}
return $_filter;
}
}
forms/category_map.xml000064400000012346151162147360011102 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_CATEGORY_MAP_CREATED_DATE_LABEL"
description="COM_MOOJLA_CATEGORY_MAP_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_CATEGORY_MAP_CREATED_BY_LABEL"
description="COM_MOOJLA_CATEGORY_MAP_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_CATEGORY_MAP_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_CATEGORY_MAP_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_CATEGORY_MAP_MODIFIED_BY_LABEL"
description="COM_MOOJLA_CATEGORY_MAP_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_CATEGORY_MAP_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_CATEGORY_MAP_VERSION_LABEL"
description="COM_MOOJLA_CATEGORY_MAP_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla category_map" />
<!-- Dynamic Fields.-->
<!-- Jcatid Field. Type: Text. (joomla)-->
<field type="text"
name="jcatid"
label="COM_MOOJLA_CATEGORY_MAP_JCATID_LABEL"
size="10"
maxlength="50"
description="COM_MOOJLA_CATEGORY_MAP_JCATID_DESCRIPTION"
class="text_area"
filter="INT" />
<!-- Mcatid Field. Type: Text. (joomla)-->
<field type="text"
name="mcatid"
label="COM_MOOJLA_CATEGORY_MAP_MCATID_LABEL"
size="10"
maxlength="50"
description="COM_MOOJLA_CATEGORY_MAP_MCATID_DESCRIPTION"
class="text_area"
filter="INT" />
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this category_map"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="category_map"
/>
</fieldset>
</form>forms/cohort.xml000064400000012170151162147360007721
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_COHORT_CREATED_DATE_LABEL"
description="COM_MOOJLA_COHORT_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_COHORT_CREATED_BY_LABEL"
description="COM_MOOJLA_COHORT_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_COHORT_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_COHORT_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_COHORT_MODIFIED_BY_LABEL"
description="COM_MOOJLA_COHORT_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_COHORT_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_COHORT_VERSION_LABEL"
description="COM_MOOJLA_COHORT_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla cohort" />
<!-- Dynamic Fields.-->
<!-- Mcohort Field. Type: Mcohort. (custom)-->
<field type="mcohort"
name="mcohort"
label="COM_MOOJLA_COHORT_MCOHORT_LABEL"
description="COM_MOOJLA_COHORT_MCOHORT_DESCRIPTION"
class="list_class"
multiple="false"
required="true"
button="false" />
<!-- Course_group Field. Type: Customusergroup.
(custom)-->
<field type="customusergroup"
name="course_group"
label="COM_MOOJLA_COHORT_COURSE_GROUP_LABEL"
description="COM_MOOJLA_COHORT_COURSE_GROUP_DESCRIPTION"
class="list_class"
button="true" />
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this cohort"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="cohort"
/>
</fieldset>
</form>forms/content.xml000064400000022747151162147360010110
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_CONTENT_CREATED_DATE_LABEL"
description="COM_MOOJLA_CONTENT_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_CONTENT_CREATED_BY_LABEL"
description="COM_MOOJLA_CONTENT_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_CONTENT_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_CONTENT_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_CONTENT_MODIFIED_BY_LABEL"
description="COM_MOOJLA_CONTENT_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_CONTENT_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_CONTENT_VERSION_LABEL"
description="COM_MOOJLA_CONTENT_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla content" />
<!-- Dynamic Fields.-->
<!-- Contents_module_id Field. Type: Text.
(joomla)-->
<field type="text"
name="contents_module_id"
label="COM_MOOJLA_CONTENT_CONTENTS_MODULE_ID_LABEL"
size="10"
maxlength="50"
default="Some text"
description="COM_MOOJLA_CONTENT_CONTENTS_MODULE_ID_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="true"
filter="INT"
message="COM_MOOJLA_CONTENT_CONTENTS_MODULE_ID_MESSAGE"
hint="COM_MOOJLA_CONTENT_CONTENTS_MODULE_ID_HINT"
autocomplete="on" />
<!-- Type Field. Type: Text. (joomla)-->
<field type="text"
name="type"
label="COM_MOOJLA_CONTENT_TYPE_LABEL"
size="64"
maxlength="64"
default=""
description="COM_MOOJLA_CONTENT_TYPE_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="true"
filter="STRING"
message="COM_MOOJLA_CONTENT_TYPE_MESSAGE"
hint="COM_MOOJLA_CONTENT_TYPE_HINT"
autocomplete="on" />
<!-- Filename Field. Type: Text. (joomla)-->
<field type="text"
name="filename"
label="COM_MOOJLA_CONTENT_FILENAME_LABEL"
size="255"
maxlength="255"
default=""
description="COM_MOOJLA_CONTENT_FILENAME_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_CONTENT_FILENAME_MESSAGE"
hint="COM_MOOJLA_CONTENT_FILENAME_HINT"
autocomplete="on" />
<!-- Mimetype Field. Type: Text. (joomla)-->
<field type="text"
name="mimetype"
label="COM_MOOJLA_CONTENT_MIMETYPE_LABEL"
size="50"
maxlength="50"
default=""
description="COM_MOOJLA_CONTENT_MIMETYPE_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_CONTENT_MIMETYPE_MESSAGE"
hint="COM_MOOJLA_CONTENT_MIMETYPE_HINT"
autocomplete="on" />
<!-- File Field. Type: Text. (joomla)-->
<field type="text"
name="file"
label="COM_MOOJLA_CONTENT_FILE_LABEL"
size="255"
maxlength="255"
default=""
description="COM_MOOJLA_CONTENT_FILE_DESCRIPTION"
class="text_area"
readonly="true"
disabled="true"
required="false"
filter="STRING"
message="COM_MOOJLA_CONTENT_FILE_MESSAGE"
hint="COM_MOOJLA_CONTENT_FILE_HINT"
autocomplete="on" />
<!-- Filesize Field. Type: Text. (joomla)-->
<field type="text"
name="filesize"
label="COM_MOOJLA_CONTENT_FILESIZE_LABEL"
size="255"
maxlength="255"
default="0"
description="COM_MOOJLA_CONTENT_FILESIZE_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="INT"
message="COM_MOOJLA_CONTENT_FILESIZE_MESSAGE"
hint="COM_MOOJLA_CONTENT_FILESIZE_HINT"
autocomplete="on" />
<!-- Fileurl Field. Type: Url. (joomla)-->
<field type="url"
name="fileurl"
label="COM_MOOJLA_CONTENT_FILEURL_LABEL"
size="255"
maxlength="255"
default=""
description="COM_MOOJLA_CONTENT_FILEURL_DESCRIPTION"
class="text_area"
relative="false"
filter="url"
validated="url"
scheme="http,https,mailto"
message="COM_MOOJLA_CONTENT_FILEURL_MESSAGE"
hint="COM_MOOJLA_CONTENT_FILEURL_HINT"
/>
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this content"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="content"
/>
</fieldset>
</form>forms/course.xml000064400000104614151162147360007730
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_COURSE_CREATED_DATE_LABEL"
description="COM_MOOJLA_COURSE_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_COURSE_CREATED_BY_LABEL"
description="COM_MOOJLA_COURSE_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_COURSE_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_COURSE_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_COURSE_MODIFIED_BY_LABEL"
description="COM_MOOJLA_COURSE_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_COURSE_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_COURSE_VERSION_LABEL"
description="COM_MOOJLA_COURSE_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Metakey Field. Type: Textarea (joomla)-->
<field name="metakey"
type="textarea"
label="JFIELD_META_KEYWORDS_LABEL"
description="JFIELD_META_KEYWORDS_DESC"
rows="3"
cols="30" />
<!-- Metadesc Field. Type: Textarea (joomla)-->
<field name="metadesc"
type="textarea"
label="JFIELD_META_DESCRIPTION_LABEL"
description="JFIELD_META_DESCRIPTION_DESC"
rows="3"
cols="30" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla course" />
<!-- Dynamic Fields.-->
<!-- Shortname Field. Type: Text. (joomla)-->
<field type="text"
name="shortname"
label="COM_MOOJLA_COURSE_SHORTNAME_LABEL"
size="10"
maxlength="50"
default=""
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_COURSE_SHORTNAME_MESSAGE"
autocomplete="on" />
<!-- Fullname Field. Type: Text. (joomla)-->
<field type="text"
name="fullname"
label="COM_MOOJLA_COURSE_FULLNAME_LABEL"
size="10"
maxlength="50"
default=""
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_COURSE_FULLNAME_MESSAGE"
hint="COM_MOOJLA_COURSE_FULLNAME_HINT"
autocomplete="on" />
<!-- Catid Field. Type: Category. (joomla)-->
<field type="category"
name="catid"
label="COM_MOOJLA_COURSE_CATID_LABEL"
extension="com_moojla.course"
required="false"
show_root="true"
default="0"
description="COM_MOOJLA_COURSE_CATID_DESCRIPTION"
class="inputbox" />
<!-- Addcontrols Field. Type: Radio. (joomla)-->
<field type="radio"
name="addcontrols"
label="COM_MOOJLA_COURSE_ADDCONTROLS_LABEL"
description="COM_MOOJLA_COURSE_ADDCONTROLS_DESCRIPTION"
class="btn-group btn-group-yesno"
default="1"
showon="useglobalvideo:0">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
</field>
<!-- Showregtab Field. Type: Radio. (joomla)-->
<field type="radio"
name="showregtab"
label="COM_MOOJLA_COURSE_SHOWREGTAB_LABEL"
description="COM_MOOJLA_COURSE_SHOWREGTAB_DESCRIPTION"
class="btn-group btn-group-yesno"
default="2"
showon="popupbutton:1">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
<option
value="2">COM_MOOJLA_COURSE_INHERIT</option>
</field>
<!-- Startdate Field. Type: Calendar. (joomla)-->
<field type="calendar"
name="startdate"
label="COM_MOOJLA_COURSE_STARTDATE_LABEL"
default="NOW"
format="%Y-%m-%d" />
<!-- Enterlbl Field. Type: Text. (joomla)-->
<field type="text"
name="enterlbl"
label="COM_MOOJLA_COURSE_ENTERLBL_LABEL"
size="20"
maxlength="50"
default=""
description="COM_MOOJLA_COURSE_ENTERLBL_DESCRIPTION"
class="text_area"
filter="STRING"
message="COM_MOOJLA_COURSE_ENTERLBL_MESSAGE"
hint="COM_MOOJLA_COURSE_ENTERLBL_HINT"
autocomplete="off" />
<!-- Cangotomoodle Field. Type: Radio. (joomla)-->
<field type="radio"
name="cangotomoodle"
label="COM_MOOJLA_COURSE_CANGOTOMOODLE_LABEL"
description="COM_MOOJLA_COURSE_CANGOTOMOODLE_DESCRIPTION"
class="btn-group btn-group-yesno"
default="2">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
<option
value="2">COM_MOOJLA_COURSE_DEFAULT</option>
</field>
<!-- Preloadaudio Field. Type: Radio. (joomla)-->
<field type="radio"
name="preloadaudio"
label="COM_MOOJLA_COURSE_PRELOADAUDIO_LABEL"
description="COM_MOOJLA_COURSE_PRELOADAUDIO_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0"
showon="useglobalaudio:0">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
</field>
<!-- Loginurl Field. Type: Text. (joomla)-->
<field type="text"
name="loginurl"
label="COM_MOOJLA_COURSE_LOGINURL_LABEL"
size="256"
maxlength="256"
default=""
description="COM_MOOJLA_COURSE_LOGINURL_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_COURSE_LOGINURL_MESSAGE"
hint="COM_MOOJLA_COURSE_LOGINURL_HINT"
autocomplete="on"
showon="showlogintab:1" />
<!-- In_enrol_date Field. Type: Text. (joomla)-->
<field type="text"
name="in_enrol_date"
label="COM_MOOJLA_COURSE_IN_ENROL_DATE_LABEL"
size="10"
maxlength="50"
default=""
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_COURSE_IN_ENROL_DATE_MESSAGE"
autocomplete="on" />
<!-- Enddate Field. Type: Calendar. (joomla)-->
<field type="calendar"
name="enddate"
label="COM_MOOJLA_COURSE_ENDDATE_LABEL"
default="NOW"
format="%Y-%m-%d %H:%M"
filter="user_utc"
showtime="true" />
<!-- Remoteid Field. Type: Text. (joomla)-->
<field type="text"
name="remoteid"
label="COM_MOOJLA_COURSE_REMOTEID_LABEL"
size="10"
maxlength="50"
default=""
description="COM_MOOJLA_COURSE_REMOTEID_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_COURSE_REMOTEID_MESSAGE"
autocomplete="on" />
<!-- Guest Field. Type: Text. (joomla)-->
<field type="text"
name="guest"
label="COM_MOOJLA_COURSE_GUEST_LABEL"
size="10"
maxlength="50"
default="0"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="INT"
message="COM_MOOJLA_COURSE_GUEST_MESSAGE"
autocomplete="on" />
<!-- Cost Field. Type: Text. (joomla)-->
<field type="text"
name="cost"
label="COM_MOOJLA_COURSE_COST_LABEL"
size="10"
maxlength="50"
default="0"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="INT"
message="COM_MOOJLA_COURSE_COST_MESSAGE"
hint="COM_MOOJLA_COURSE_COST_HINT"
autocomplete="on" />
<!-- Teachers Field. Type: Editor. (joomla)-->
<field type="editor"
name="teachers"
label="COM_MOOJLA_COURSE_TEACHERS_LABEL"
default=""
buttons="no"
editor="codemirror|none"
filter="safehtml" />
<!-- Summary_files Field. Type: Editor. (joomla)-->
<field type="editor"
name="summary_files"
label="COM_MOOJLA_COURSE_SUMMARY_FILES_LABEL"
default=""
buttons="no"
editor="codemirror|none"
filter="safehtml" />
<!-- Autoplay Field. Type: Radio. (joomla)-->
<field type="radio"
name="autoplay"
label="COM_MOOJLA_COURSE_AUTOPLAY_LABEL"
description="COM_MOOJLA_COURSE_AUTOPLAY_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0"
showon="useglobalvideo:0">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
</field>
<!-- Summary Field. Type: Editor. (joomla)-->
<field type="editor"
name="summary"
label="COM_MOOJLA_COURSE_SUMMARY_LABEL"
default=""
buttons="no"
editor="tinymce|none"
filter="safehtml" />
<!-- Useglobalaudio Field. Type: Radio. (joomla)-->
<field type="radio"
name="useglobalaudio"
label="COM_MOOJLA_COURSE_USEGLOBALAUDIO_LABEL"
description="COM_MOOJLA_COURSE_USEGLOBALAUDIO_DESCRIPTION"
class="btn-group btn-group-yesno"
default="1">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
</field>
<!-- Alias Field. Type: Text. (joomla)-->
<field type="text"
name="alias"
label="COM_MOOJLA_COURSE_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
filter="STRING"
hint="COM_MOOJLA_COURSE_ALIAS_HINT" />
<!-- Cat_name Field. Type: Text. (joomla)-->
<field type="text"
name="cat_name"
label="COM_MOOJLA_COURSE_CAT_NAME_LABEL"
size="10"
maxlength="50"
default=""
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_COURSE_CAT_NAME_MESSAGE"
hint="COM_MOOJLA_COURSE_CAT_NAME_HINT"
autocomplete="on"
showon="cat_:" />
<!-- Currency Field. Type: Text. (joomla)-->
<field type="text"
name="currency"
label="COM_MOOJLA_COURSE_CURRENCY_LABEL"
size="10"
maxlength="50"
default="IRT"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_COURSE_CURRENCY_MESSAGE"
autocomplete="on" />
<!-- Alterurl Field. Type: Text. (joomla)-->
<field type="text"
name="alterurl"
label="COM_MOOJLA_COURSE_ALTERURL_LABEL"
size="256"
maxlength="256"
default=""
description="COM_MOOJLA_COURSE_ALTERURL_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_COURSE_ALTERURL_MESSAGE"
hint="COM_MOOJLA_COURSE_ALTERURL_HINT"
autocomplete="on"
showon="popupbutton:0" />
<!-- Loginlbl Field. Type: Text. (joomla)-->
<field type="text"
name="loginlbl"
label="COM_MOOJLA_COURSE_LOGINLBL_LABEL"
size="20"
maxlength="50"
default=""
description="COM_MOOJLA_COURSE_LOGINLBL_DESCRIPTION"
class="text_area"
filter="STRING"
message="COM_MOOJLA_COURSE_LOGINLBL_MESSAGE"
hint="COM_MOOJLA_COURSE_LOGINLBL_HINT"
autocomplete="off" />
<!-- Buylbl Field. Type: Text. (joomla)-->
<field type="text"
name="buylbl"
label="COM_MOOJLA_COURSE_BUYLBL_LABEL"
size="20"
maxlength="50"
default=""
description="COM_MOOJLA_COURSE_BUYLBL_DESCRIPTION"
class="text_area"
filter="STRING"
message="COM_MOOJLA_COURSE_BUYLBL_MESSAGE"
hint="COM_MOOJLA_COURSE_BUYLBL_HINT"
autocomplete="off" />
<!-- Enrollbl Field. Type: Text. (joomla)-->
<field type="text"
name="enrollbl"
label="COM_MOOJLA_COURSE_ENROLLBL_LABEL"
size="20"
maxlength="50"
default=""
description="COM_MOOJLA_COURSE_ENROLLBL_DESCRIPTION"
class="text_area"
filter="STRING"
message="COM_MOOJLA_COURSE_ENROLLBL_MESSAGE"
hint="COM_MOOJLA_COURSE_ENROLLBL_HINT"
autocomplete="off" />
<!-- Popupbutton Field. Type: Radio. (joomla)-->
<field type="radio"
name="popupbutton"
label="COM_MOOJLA_COURSE_POPUPBUTTON_LABEL"
description="COM_MOOJLA_COURSE_POPUPBUTTON_DESCRIPTION"
class="btn-group btn-group-yesno"
default="2"
readonly="false"
disabled="false">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
<option
value="2">COM_MOOJLA_COURSE_DEFAULT</option>
</field>
<!-- Videotype Field. Type: Radio. (joomla)-->
<field type="radio"
name="videotype"
label="COM_MOOJLA_COURSE_VIDEOTYPE_LABEL"
description="COM_MOOJLA_COURSE_VIDEOTYPE_DESCRIPTION"
class="btn-group btn-group-yesno"
default="1"
showon="useglobalvideo:0">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_MODAL</option>
<option
value="2">COM_MOOJLA_COURSE_EMBED</option>
<option
value="3">COM_MOOJLA_COURSE_SCROLL_TO_TOP</option>
</field>
<!-- Registrationurl Field. Type: Text. (joomla)-->
<field type="text"
name="registrationurl"
label="COM_MOOJLA_COURSE_REGISTRATIONURL_LABEL"
size="256"
maxlength="256"
default=""
description="COM_MOOJLA_COURSE_REGISTRATIONURL_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_COURSE_REGISTRATIONURL_MESSAGE"
hint="COM_MOOJLA_COURSE_REGISTRATIONURL_HINT"
autocomplete="on"
showon="showregtab:1" />
<!-- Self_enrolment Field. Type: Text. (joomla)-->
<field type="text"
name="self_enrolment"
label="COM_MOOJLA_COURSE_SELF_ENROLMENT_LABEL"
size="10"
maxlength="50"
default=""
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_COURSE_SELF_ENROLMENT_MESSAGE"
autocomplete="on" />
<!-- Freeenterlbl Field. Type: Text. (joomla)-->
<field type="text"
name="freeenterlbl"
label="COM_MOOJLA_COURSE_FREEENTERLBL_LABEL"
size="20"
maxlength="50"
default=""
description="COM_MOOJLA_COURSE_FREEENTERLBL_DESCRIPTION"
class="text_area"
filter="STRING"
message="COM_MOOJLA_COURSE_FREEENTERLBL_MESSAGE"
hint="COM_MOOJLA_COURSE_FREEENTERLBL_HINT"
autocomplete="off" />
<!-- Permanent_fields Field. Type: Sql. (joomla)-->
<field type="sql"
name="permanent_fields"
label="COM_MOOJLA_COURSE_PERMANENT_FIELDS_LABEL"
query="DESC `#__moojla_course`"
default=""
description="COM_MOOJLA_COURSE_PERMANENT_FIELDS_DESCRIPTION"
key_field="Field"
value_field="Field"
multiple="true" />
<!-- Useglobalvideo Field. Type: Radio. (joomla)-->
<field type="radio"
name="useglobalvideo"
label="COM_MOOJLA_COURSE_USEGLOBALVIDEO_LABEL"
description="COM_MOOJLA_COURSE_USEGLOBALVIDEO_DESCRIPTION"
class="btn-group btn-group-yesno"
default="1">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
</field>
<!-- Course_templatestyle_forcourseconfig Field. Type:
Customtemplatestyle. (custom)-->
<field type="customtemplatestyle"
name="course_templatestyle_forcourseconfig"
label="COM_MOOJLA_COURSE_COURSE_TEMPLATESTYLE_FORCOURSECONFIG_LABEL"
description="COM_MOOJLA_COURSE_COURSE_TEMPLATESTYLE_FORCOURSECONFIG_DESCRIPTION"
message="COM_MOOJLA_COURSE_COURSE_TEMPLATESTYLE_FORCOURSECONFIG_MESSAGE"
class="list_class"
multiple="false"
default="0"
button="false" />
<!-- Preventdownload Field. Type: Radio. (joomla)-->
<field type="radio"
name="preventdownload"
label="COM_MOOJLA_COURSE_PREVENTDOWNLOAD_LABEL"
description="COM_MOOJLA_COURSE_PREVENTDOWNLOAD_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0"
showon="useglobalvideo:0">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
</field>
<!-- Course_detail_layout Field. Type: Filelist.
(joomla)-->
<field type="filelist"
name="course_detail_layout"
label="COM_MOOJLA_COURSE_COURSE_DETAIL_LAYOUT_LABEL"
directory="components/com_moojla/views/coursedetail/tmpl/"
default=""
description="COM_MOOJLA_COURSE_COURSE_DETAIL_LAYOUT_DESCRIPTION"
filter="^[^_]*\.php$"
hide_none="ture"
hide_default="true" />
<!-- Preloadvideo Field. Type: Radio. (joomla)-->
<field type="radio"
name="preloadvideo"
label="COM_MOOJLA_COURSE_PRELOADVIDEO_LABEL"
description="COM_MOOJLA_COURSE_PRELOADVIDEO_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0"
showon="useglobalvideo:0">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
</field>
<!-- Availabilityinfolink Field. Type: Radio.
(joomla)-->
<field type="radio"
name="availabilityinfolink"
label="COM_MOOJLA_COURSE_AVAILABILITYINFOLINK_LABEL"
description="COM_MOOJLA_COURSE_AVAILABILITYINFOLINK_DESCRIPTION"
class="btn-group btn-group-yesno"
default="2"
readonly="false"
disabled="false">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_ENABLE</option>
<option
value="0">COM_MOOJLA_COURSE_DISABLE</option>
<option
value="2">COM_MOOJLA_COURSE_DEFAULT</option>
</field>
<!-- Muted Field. Type: Radio. (joomla)-->
<field type="radio"
name="muted"
label="COM_MOOJLA_COURSE_MUTED_LABEL"
description="COM_MOOJLA_COURSE_MUTED_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0"
showon="useglobalvideo:0">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
</field>
<!-- Redirect_after_enrol Field. Type: Radio.
(joomla)-->
<field type="radio"
name="redirect_after_enrol"
label="COM_MOOJLA_COURSE_REDIRECT_AFTER_ENROL_LABEL"
description="COM_MOOJLA_COURSE_REDIRECT_AFTER_ENROL_DESCRIPTION"
class="btn-group btn-group-yesno"
default="2">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
<option
value="2">COM_MOOJLA_COURSE_DEFAULT</option>
</field>
<!-- Preventdownloadaudio Field. Type: Radio.
(joomla)-->
<field type="radio"
name="preventdownloadaudio"
label="COM_MOOJLA_COURSE_PREVENTDOWNLOADAUDIO_LABEL"
description="COM_MOOJLA_COURSE_PREVENTDOWNLOADAUDIO_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0"
showon="useglobalaudio:0">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
</field>
<!-- Showlogintab Field. Type: Radio. (joomla)-->
<field type="radio"
name="showlogintab"
label="COM_MOOJLA_COURSE_SHOWLOGINTAB_LABEL"
description="COM_MOOJLA_COURSE_SHOWLOGINTAB_DESCRIPTION"
class="btn-group btn-group-yesno"
default="2"
showon="popupbutton:1">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
<option
value="2">COM_MOOJLA_COURSE_INHERIT</option>
</field>
<!-- Autoplayaudio Field. Type: Radio. (joomla)-->
<field type="radio"
name="autoplayaudio"
label="COM_MOOJLA_COURSE_AUTOPLAYAUDIO_LABEL"
description="COM_MOOJLA_COURSE_AUTOPLAYAUDIO_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0"
showon="useglobalaudio:0">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_COURSE_YES</option>
<option
value="0">COM_MOOJLA_COURSE_NO</option>
</field>
<!-- Cat_id Field. Type: Text. (joomla)-->
<field type="text"
name="cat_id"
label="COM_MOOJLA_COURSE_CAT_ID_LABEL"
size="10"
maxlength="50"
default=""
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="INT"
message="COM_MOOJLA_COURSE_CAT_ID_MESSAGE"
autocomplete="on"
showon="cat_:" />
<!-- Metadata Fields-->
<fields name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<fieldset name="vdmmetadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<!-- Robots Field. Type: List
(joomla)-->
<field name="robots"
type="list"
label="JFIELD_METADATA_ROBOTS_LABEL"
description="JFIELD_METADATA_ROBOTS_DESC">
<option
value="">JGLOBAL_USE_GLOBAL</option>
<option value="index,
follow">JGLOBAL_INDEX_FOLLOW</option>
<option value="noindex,
follow">JGLOBAL_NOINDEX_FOLLOW</option>
<option value="index,
nofollow">JGLOBAL_INDEX_NOFOLLOW</option>
<option value="noindex,
nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>
</field>
<!-- Author Field. Type: Text
(joomla)-->
<field name="author"
type="text"
label="JAUTHOR"
description="JFIELD_METADATA_AUTHOR_DESC"
size="20" />
<!-- Rights Field. Type: Textarea
(joomla)-->
<field name="rights"
type="textarea"
label="JFIELD_META_RIGHTS_LABEL"
description="JFIELD_META_RIGHTS_DESC"
required="false"
filter="string"
cols="30"
rows="2" />
</fieldset>
</fields>
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this course"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="course"
/>
</fieldset>
</form>forms/course_field_mapper.xml000064400000014347151162147360012442
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_COURSE_FIELD_MAPPER_CREATED_DATE_LABEL"
description="COM_MOOJLA_COURSE_FIELD_MAPPER_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_COURSE_FIELD_MAPPER_CREATED_BY_LABEL"
description="COM_MOOJLA_COURSE_FIELD_MAPPER_CREATED_BY_DESC"
/>
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_COURSE_FIELD_MAPPER_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_COURSE_FIELD_MAPPER_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_COURSE_FIELD_MAPPER_MODIFIED_BY_LABEL"
description="COM_MOOJLA_COURSE_FIELD_MAPPER_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Access Field. Type: Accesslevel (joomla)-->
<field name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
default="1"
required="false" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_COURSE_FIELD_MAPPER_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_COURSE_FIELD_MAPPER_VERSION_LABEL"
description="COM_MOOJLA_COURSE_FIELD_MAPPER_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla course_field_mapper" />
<!-- Dynamic Fields.-->
<!-- Coursefield Field. Type: Moojlacoursefield.
(custom)-->
<field type="moojlacoursefield"
name="coursefield"
label="COM_MOOJLA_COURSE_FIELD_MAPPER_COURSEFIELD_LABEL"
description="COM_MOOJLA_COURSE_FIELD_MAPPER_COURSEFIELD_DESCRIPTION"
class="list_class"
multiple="false"
default=""
required="true"
button="false" />
<!-- Mcoursefields Field. Type: Mcoursefields.
(custom)-->
<field type="mcoursefields"
name="mcoursefields"
label="COM_MOOJLA_COURSE_FIELD_MAPPER_MCOURSEFIELDS_LABEL"
description="COM_MOOJLA_COURSE_FIELD_MAPPER_MCOURSEFIELDS_DESCRIPTION"
class="list_class"
multiple="false"
default=""
required="true"
button="false" />
<!-- Field_icon Field. Type: Media. (joomla)-->
<field type="media"
name="field_icon"
label="COM_MOOJLA_COURSE_FIELD_MAPPER_FIELD_ICON_LABEL"
description="COM_MOOJLA_COURSE_FIELD_MAPPER_FIELD_ICON_DESCRIPTION"
directory=""
preview="ture" />
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this course_field_mapper"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="course_field_mapper"
/>
</fieldset>
</form>forms/course_group_map.xml000064400000014307151162147360012000
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_COURSE_GROUP_MAP_CREATED_DATE_LABEL"
description="COM_MOOJLA_COURSE_GROUP_MAP_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_COURSE_GROUP_MAP_CREATED_BY_LABEL"
description="COM_MOOJLA_COURSE_GROUP_MAP_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_COURSE_GROUP_MAP_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_COURSE_GROUP_MAP_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_COURSE_GROUP_MAP_MODIFIED_BY_LABEL"
description="COM_MOOJLA_COURSE_GROUP_MAP_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_COURSE_GROUP_MAP_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_COURSE_GROUP_MAP_VERSION_LABEL"
description="COM_MOOJLA_COURSE_GROUP_MAP_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla course_group_map" />
<!-- Dynamic Fields.-->
<!-- Moojlacourse Field. Type: Moojlacourse.
(custom)-->
<field type="moojlacourse"
name="moojlacourse"
label="COM_MOOJLA_COURSE_GROUP_MAP_MOOJLACOURSE_LABEL"
description="COM_MOOJLA_COURSE_GROUP_MAP_MOOJLACOURSE_DESCRIPTION"
message="COM_MOOJLA_COURSE_GROUP_MAP_MOOJLACOURSE_MESSAGE"
class="list_class"
multiple="false"
default=""
button="false" />
<!-- Course_group Field. Type: Customusergroup.
(custom)-->
<field type="customusergroup"
name="course_group"
label="COM_MOOJLA_COURSE_GROUP_MAP_COURSE_GROUP_LABEL"
description="COM_MOOJLA_COURSE_GROUP_MAP_COURSE_GROUP_DESCRIPTION"
class="list_class"
button="true" />
<!-- Role Field. Type: List. (joomla)-->
<field type="list"
name="role"
label="COM_MOOJLA_COURSE_GROUP_MAP_ROLE_LABEL"
description="COM_MOOJLA_COURSE_GROUP_MAP_ROLE_DESCRIPTION"
class="list_class"
multiple="false"
default="">
<!-- Option Set.-->
<option
value="">COM_MOOJLA_COURSE_GROUP_MAP_SELECT_ROLE</option>
<option
value="5">COM_MOOJLA_COURSE_GROUP_MAP_STUDENT</option>
<option
value="3">COM_MOOJLA_COURSE_GROUP_MAP_TEACHER</option>
<option
value="1">COM_MOOJLA_COURSE_GROUP_MAP_MANAGER</option>
</field>
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this course_group_map"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="course_group_map"
/>
</fieldset>
</form>forms/enrolment.xml000064400000015252151162147360010432
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_ENROLMENT_CREATED_DATE_LABEL"
description="COM_MOOJLA_ENROLMENT_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_ENROLMENT_CREATED_BY_LABEL"
description="COM_MOOJLA_ENROLMENT_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_ENROLMENT_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_ENROLMENT_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_ENROLMENT_MODIFIED_BY_LABEL"
description="COM_MOOJLA_ENROLMENT_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_ENROLMENT_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_ENROLMENT_VERSION_LABEL"
description="COM_MOOJLA_ENROLMENT_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla enrolment" />
<!-- Dynamic Fields.-->
<!-- Role Field. Type: List. (joomla)-->
<field type="list"
name="role"
label="COM_MOOJLA_ENROLMENT_ROLE_LABEL"
description="COM_MOOJLA_ENROLMENT_ROLE_DESCRIPTION"
class="list_class"
default="0">
<!-- Option Set.-->
<option
value="0">COM_MOOJLA_ENROLMENT_SELECT_AN_OPTION</option>
<option
value="1">COM_MOOJLA_ENROLMENT_MANAGER</option>
<option
value="2">COM_MOOJLA_ENROLMENT_COURSE_CREATOR</option>
<option
value="3">COM_MOOJLA_ENROLMENT_TEACHER</option>
<option
value="4">COM_MOOJLA_ENROLMENT_NONEDITING_TEACHER</option>
<option
value="5">COM_MOOJLA_ENROLMENT_STUDENT</option>
</field>
<!-- Moojlacourse Field. Type: Moojlacourse.
(custom)-->
<field type="moojlacourse"
name="moojlacourse"
label="COM_MOOJLA_ENROLMENT_MOOJLACOURSE_LABEL"
description="COM_MOOJLA_ENROLMENT_MOOJLACOURSE_DESCRIPTION"
message="COM_MOOJLA_ENROLMENT_MOOJLACOURSE_MESSAGE"
class="list_class"
multiple="false"
default=""
button="false" />
<!-- Jid Field. Type: Staffusers. (custom)-->
<field type="staffusers"
name="jid"
label="COM_MOOJLA_ENROLMENT_JID_LABEL"
description="COM_MOOJLA_ENROLMENT_JID_DESCRIPTION"
multiple="false"
required="true"
default=""
hint="COM_MOOJLA_ENROLMENT_JID_HINT" />
<!-- Enrolldate Field. Type: Calendar. (joomla)-->
<field type="calendar"
name="enrolldate"
label="COM_MOOJLA_ENROLMENT_ENROLLDATE_LABEL"
default="NOW"
description="COM_MOOJLA_ENROLMENT_ENROLLDATE_DESCRIPTION"
format="%Y-%m-%d %H:%M"
showtime="true"
todaybutton="true" />
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this enrolment"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="enrolment"
/>
</fieldset>
</form>forms/filter_categories_map.xml000064400000003645151162147360012761
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_CATEGORIES_MAP"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_CATEGORIES_MAP"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.jcatid
ASC">COM_MOOJLA_FILTER_JOOMLA_CATEGORY_ID_ASCENDING</option>
<option value="a.jcatid
DESC">COM_MOOJLA_FILTER_JOOMLA_CATEGORY_ID_DESCENDING</option>
<option value="a.mcatid
ASC">COM_MOOJLA_FILTER_MOODLE_CATEGORY_ID_ASCENDING</option>
<option value="a.mcatid
DESC">COM_MOOJLA_FILTER_MOODLE_CATEGORY_ID_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_cohorts.xml000064400000004001151162147360011443
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_COHORTS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_COHORTS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="mcohort"
name="mcohort"
label="COM_MOOJLA_COHORT_MCOHORT_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<field
type="customusergroup"
name="course_group"
label="COM_MOOJLA_COHORT_COURSE_GROUP_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="g.name
ASC">COM_MOOJLA_FILTER_COHORT_ASCENDING</option>
<option value="g.name
DESC">COM_MOOJLA_FILTER_COHORT_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_contents.xml000064400000004145151162147360011630
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_CONTENTS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_CONTENTS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="contentsfiltercontentsmoduleid"
name="contents_module_id"
label="COM_MOOJLA_CONTENT_CONTENTS_MODULE_ID_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<field
type="contentsfiltermimetype"
name="mimetype"
label="COM_MOOJLA_CONTENT_MIMETYPE_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.contents_module_id
ASC">COM_MOOJLA_FILTER_CONTENTS_MODULE_ID_ASCENDING</option>
<option value="a.contents_module_id
DESC">COM_MOOJLA_FILTER_CONTENTS_MODULE_ID_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_courses.xml000064400000004527151162147360011462
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_COURSES"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_COURSES"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="category"
name="category_id"
label="COM_MOOJLA_COURSE_COURSES_CATEGORIES"
description="JOPTION_FILTER_CATEGORY_DESC"
multiple="true"
class="multipleCategories"
extension="com_moojla.course"
onchange="this.form.submit();"
published="0,1,2"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.shortname
ASC">COM_MOOJLA_FILTER_SHORTNAME_ASCENDING</option>
<option value="a.shortname
DESC">COM_MOOJLA_FILTER_SHORTNAME_DESCENDING</option>
<option value="a.fullname
ASC">COM_MOOJLA_FILTER_FULLNAME_ASCENDING</option>
<option value="a.fullname
DESC">COM_MOOJLA_FILTER_FULLNAME_DESCENDING</option>
<option value="category_title
ASC">COM_MOOJLA_FILTER_COURSES_CATEGORIES_ASCENDING</option>
<option value="category_title
DESC">COM_MOOJLA_FILTER_COURSES_CATEGORIES_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_course_fields_mapper.xml000064400000003432151162147360014163
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_COURSE_FIELDS_MAPPER"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_COURSE_FIELDS_MAPPER"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="accesslevel"
name="access"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_course_group_maps.xml000064400000004360151162147410013522
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_COURSE_GROUP_MAPS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_COURSE_GROUP_MAPS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="coursegroupmapsfilterrole"
name="role"
label="COM_MOOJLA_COURSE_GROUP_MAP_ROLE_LABEL"
class="multipleCoursegroupmapsfilterrole"
multiple="true"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="g.fullname
ASC">COM_MOOJLA_FILTER_COURSE_ASCENDING</option>
<option value="g.fullname
DESC">COM_MOOJLA_FILTER_COURSE_DESCENDING</option>
<option value="h.title
ASC">COM_MOOJLA_FILTER_COURSE_GROUP_ASCENDING</option>
<option value="h.title
DESC">COM_MOOJLA_FILTER_COURSE_GROUP_DESCENDING</option>
<option value="a.role
ASC">COM_MOOJLA_FILTER_ROLE_ASCENDING</option>
<option value="a.role
DESC">COM_MOOJLA_FILTER_ROLE_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_enrolments.xml000064400000004522151162147410012154
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_ENROLMENTS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_ENROLMENTS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="enrolmentsfilterrole"
name="role"
label="COM_MOOJLA_ENROLMENT_ROLE_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.role
ASC">COM_MOOJLA_FILTER_ROLE_ASCENDING</option>
<option value="a.role
DESC">COM_MOOJLA_FILTER_ROLE_DESCENDING</option>
<option value="g.fullname
ASC">COM_MOOJLA_FILTER_COURSE_ASCENDING</option>
<option value="g.fullname
DESC">COM_MOOJLA_FILTER_COURSE_DESCENDING</option>
<option value="h.name
ASC">COM_MOOJLA_FILTER_JOOMLA_USER_ASCENDING</option>
<option value="h.name
DESC">COM_MOOJLA_FILTER_JOOMLA_USER_DESCENDING</option>
<option value="a.enrolldate
ASC">COM_MOOJLA_FILTER_ENROLL_DATE_ASCENDING</option>
<option value="a.enrolldate
DESC">COM_MOOJLA_FILTER_ENROLL_DATE_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_modules.xml000064400000004365151162147410011443
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_MODULES"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_MODULES"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="modulesfiltermodulesectionid"
name="module_section_id"
label="COM_MOOJLA_MODULE_MODULE_SECTION_ID_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<field
type="modulesfiltermodname"
name="modname"
label="COM_MOOJLA_MODULE_MODNAME_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.module_section_id
ASC">COM_MOOJLA_FILTER_MODULE_SECTION_ID_ASCENDING</option>
<option value="a.module_section_id
DESC">COM_MOOJLA_FILTER_MODULE_SECTION_ID_DESCENDING</option>
<option value="a.name
ASC">COM_MOOJLA_FILTER_MODULE_NAME_ASCENDING</option>
<option value="a.name
DESC">COM_MOOJLA_FILTER_MODULE_NAME_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_sections.xml000064400000004270151162147410011615
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_SECTIONS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_SECTIONS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="sectionsfiltercourseid"
name="courseid"
label="COM_MOOJLA_SECTION_COURSEID_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.courseid
ASC">COM_MOOJLA_FILTER_COURSEID_ASCENDING</option>
<option value="a.courseid
DESC">COM_MOOJLA_FILTER_COURSEID_DESCENDING</option>
<option value="a.section_id
ASC">COM_MOOJLA_FILTER_SECTION_ID_ASCENDING</option>
<option value="a.section_id
DESC">COM_MOOJLA_FILTER_SECTION_ID_DESCENDING</option>
<option value="a.name
ASC">COM_MOOJLA_FILTER_NAME_ASCENDING</option>
<option value="a.name
DESC">COM_MOOJLA_FILTER_NAME_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_tags.xml000064400000004062151162147410010723
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_TAGS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_TAGS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="accesslevel"
name="access"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.tagid
ASC">COM_MOOJLA_FILTER_TAG_ID_ASCENDING</option>
<option value="a.tagid
DESC">COM_MOOJLA_FILTER_TAG_ID_DESCENDING</option>
<option value="a.tagname
ASC">COM_MOOJLA_FILTER_TAG_NAME_ASCENDING</option>
<option value="a.tagname
DESC">COM_MOOJLA_FILTER_TAG_NAME_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_tag_instances.xml000064400000004623151162147410012612
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_TAG_INSTANCES"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_TAG_INSTANCES"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="accesslevel"
name="access"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<field
type="moojlacourse"
name="moojlacourse"
label="COM_MOOJLA_TAG_INSTANCE_MOOJLACOURSE_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<field
type="moodletag"
name="moodletag"
label="COM_MOOJLA_TAG_INSTANCE_MOODLETAG_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="g.fullname
ASC">COM_MOOJLA_FILTER_COURSE_ASCENDING</option>
<option value="g.fullname
DESC">COM_MOOJLA_FILTER_COURSE_DESCENDING</option>
<option value="h.tagname
ASC">COM_MOOJLA_FILTER_MOODLETAG_ASCENDING</option>
<option value="h.tagname
DESC">COM_MOOJLA_FILTER_MOODLETAG_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_user_fields_map.xml000064400000004316151162147410013130
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_USER_FIELDS_MAP"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_USER_FIELDS_MAP"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="userfieldsmapfilteriscv"
name="iscv"
label="COM_MOOJLA_USER_FIELD_MAP_ISCV_LABEL"
multiple="false"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="g.name
ASC">COM_MOOJLA_FILTER_JOOMLA_USERS_FIELD_ASCENDING</option>
<option value="g.name
DESC">COM_MOOJLA_FILTER_JOOMLA_USERS_FIELD_DESCENDING</option>
<option value="h.id
ASC">COM_MOOJLA_FILTER_MOODLE_USERS_FIELD_ASCENDING</option>
<option value="h.id
DESC">COM_MOOJLA_FILTER_MOODLE_USERS_FIELD_DESCENDING</option>
<option value="a.iscv
ASC">COM_MOOJLA_FILTER_CV_ASCENDING</option>
<option value="a.iscv
DESC">COM_MOOJLA_FILTER_CV_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/filter_user_maps.xml000064400000003571151162147410011767
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_MOOJLA_FILTER_SEARCH"
description="COM_MOOJLA_FILTER_SEARCH_USER_MAPS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_MOOJLA_FILTER_PUBLISHED"
description="COM_MOOJLA_FILTER_PUBLISHED_USER_MAPS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.jid
ASC">COM_MOOJLA_FILTER_JOOMLA_USER_ASCENDING</option>
<option value="a.jid
DESC">COM_MOOJLA_FILTER_JOOMLA_USER_DESCENDING</option>
<option value="a.mid
ASC">COM_MOOJLA_FILTER_MOODLE_USER_ID_ASCENDING</option>
<option value="a.mid
DESC">COM_MOOJLA_FILTER_MOODLE_USER_ID_DESCENDING</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>forms/languagetranslation.xml000064400000001444151162147410012463
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_moojla/models/fields">
<field name="language" type="fulllanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_CATEGORIES_FIELD_LANGUAGE_DESC" >
</field>
</fieldset>
<field type="editor"
name="original_translation"
description="{language}.com_moojla.ini file"
label="Original Translation"
width="100%"
height="450px"
cols="15"
rows="30"
buttons="no"
editor="none"
filter="raw"
validate="code" />
<field type="editor"
name="override"
description="{language}.override.ini file"
label="Override"
width="100%"
height="450px"
cols="15"
rows="30"
buttons="no"
editor="none"
filter="raw"
validate="code" />
</form>forms/module.xml000064400000022430151162147410007704
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_MODULE_CREATED_DATE_LABEL"
description="COM_MOOJLA_MODULE_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_MODULE_CREATED_BY_LABEL"
description="COM_MOOJLA_MODULE_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_MODULE_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_MODULE_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_MODULE_MODIFIED_BY_LABEL"
description="COM_MOOJLA_MODULE_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_MODULE_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_MODULE_VERSION_LABEL"
description="COM_MOOJLA_MODULE_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla module" />
<!-- Dynamic Fields.-->
<!-- Module_section_id Field. Type: Text. (joomla)-->
<field type="text"
name="module_section_id"
label="COM_MOOJLA_MODULE_MODULE_SECTION_ID_LABEL"
size="10"
maxlength="50"
default=""
description="COM_MOOJLA_MODULE_MODULE_SECTION_ID_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="INT"
message="COM_MOOJLA_MODULE_MODULE_SECTION_ID_MESSAGE"
hint="COM_MOOJLA_MODULE_MODULE_SECTION_ID_HINT" />
<!-- Module_id Field. Type: Text. (joomla)-->
<field type="text"
name="module_id"
label="COM_MOOJLA_MODULE_MODULE_ID_LABEL"
size="10"
maxlength="50"
default=""
description="COM_MOOJLA_MODULE_MODULE_ID_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="true"
filter="INT"
message="COM_MOOJLA_MODULE_MODULE_ID_MESSAGE"
hint="COM_MOOJLA_MODULE_MODULE_ID_HINT"
/>
<!-- Name Field. Type: Text. (joomla)-->
<field type="text"
name="name"
label="COM_MOOJLA_MODULE_NAME_LABEL"
size="10"
maxlength="50"
default=""
description="COM_MOOJLA_MODULE_NAME_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_MODULE_NAME_MESSAGE"
hint="COM_MOOJLA_MODULE_NAME_HINT" />
<!-- Modname Field. Type: Text. (joomla)-->
<field type="text"
name="modname"
label="COM_MOOJLA_MODULE_MODNAME_LABEL"
size="10"
maxlength="50"
default=""
description="COM_MOOJLA_MODULE_MODNAME_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="true"
filter="STRING"
message="COM_MOOJLA_MODULE_MODNAME_MESSAGE"
hint="COM_MOOJLA_MODULE_MODNAME_HINT"
/>
<!-- Visible Field. Type: Checkbox. (joomla)-->
<field type="checkbox"
name="visible"
label="COM_MOOJLA_MODULE_VISIBLE_LABEL"
value="1"
default=""
description="COM_MOOJLA_MODULE_VISIBLE_DESCRIPTION"
class="inputbox" />
<!-- Uservisible Field. Type: Checkbox. (joomla)-->
<field type="checkbox"
name="uservisible"
label="COM_MOOJLA_MODULE_USERVISIBLE_LABEL"
value="1"
default=""
description="COM_MOOJLA_MODULE_USERVISIBLE_DESCRIPTION"
class="inputbox" />
<!-- Modicon Field. Type: Editor. (joomla)-->
<field type="editor"
name="modicon"
label="COM_MOOJLA_MODULE_MODICON_LABEL"
default=""
buttons="no"
editor="codemirror|none"
filter="safehtml" />
<!-- Description Field. Type: Editor. (joomla)-->
<field type="editor"
name="description"
label="COM_MOOJLA_MODULE_DESCRIPTION_LABEL"
default=""
buttons="no"
editor="tinymce|none"
filter="safehtml" />
<!-- Url Field. Type: Url. (joomla)-->
<field type="url"
name="url"
label="COM_MOOJLA_MODULE_URL_LABEL"
size="255"
maxlength="255"
default=""
description="COM_MOOJLA_MODULE_URL_DESCRIPTION"
class="text_area"
relative="false"
filter="url"
validated="url"
scheme="http,https,mailto"
message="COM_MOOJLA_MODULE_URL_MESSAGE"
hint="COM_MOOJLA_MODULE_URL_HINT" />
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this module"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="module"
/>
</fieldset>
</form>forms/section.xml000064400000017107151162147410010070
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_SECTION_CREATED_DATE_LABEL"
description="COM_MOOJLA_SECTION_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_SECTION_CREATED_BY_LABEL"
description="COM_MOOJLA_SECTION_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_SECTION_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_SECTION_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_SECTION_MODIFIED_BY_LABEL"
description="COM_MOOJLA_SECTION_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_SECTION_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_SECTION_VERSION_LABEL"
description="COM_MOOJLA_SECTION_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla section" />
<!-- Dynamic Fields.-->
<!-- Courseid Field. Type: Text. (joomla)-->
<field type="text"
name="courseid"
label="COM_MOOJLA_SECTION_COURSEID_LABEL"
size="10"
maxlength="50"
default=""
description="COM_MOOJLA_SECTION_COURSEID_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="true"
filter="INT"
message="COM_MOOJLA_SECTION_COURSEID_MESSAGE"
hint="COM_MOOJLA_SECTION_COURSEID_HINT"
/>
<!-- Section_id Field. Type: Text. (joomla)-->
<field type="text"
name="section_id"
label="COM_MOOJLA_SECTION_SECTION_ID_LABEL"
size="10"
maxlength="50"
default=""
description="COM_MOOJLA_SECTION_SECTION_ID_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="INT"
message="COM_MOOJLA_SECTION_SECTION_ID_MESSAGE"
hint="COM_MOOJLA_SECTION_SECTION_ID_HINT"
/>
<!-- Name Field. Type: Text. (joomla)-->
<field type="text"
name="name"
label="COM_MOOJLA_SECTION_NAME_LABEL"
size="50"
maxlength="50"
default=""
description="COM_MOOJLA_SECTION_NAME_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
message="COM_MOOJLA_SECTION_NAME_MESSAGE"
hint="COM_MOOJLA_SECTION_NAME_HINT"
autocomplete="on" />
<!-- Visible Field. Type: Checkbox. (joomla)-->
<field type="checkbox"
name="visible"
label="COM_MOOJLA_SECTION_VISIBLE_LABEL"
value="1"
default=""
description="COM_MOOJLA_SECTION_VISIBLE_DESCRIPTION"
class="inputbox" />
<!-- Uservisible Field. Type: Checkbox. (joomla)-->
<field type="checkbox"
name="uservisible"
label="COM_MOOJLA_SECTION_USERVISIBLE_LABEL"
value="1"
default=""
description="COM_MOOJLA_SECTION_USERVISIBLE_DESCRIPTION"
class="inputbox" />
<!-- Summary Field. Type: Editor. (joomla)-->
<field type="editor"
name="summary"
label="COM_MOOJLA_SECTION_SUMMARY_LABEL"
default=""
buttons="no"
editor="tinymce|none"
filter="safehtml" />
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this section"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="section"
/>
</fieldset>
</form>forms/tag.xml000064400000015177151162147410007204
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_TAG_CREATED_DATE_LABEL"
description="COM_MOOJLA_TAG_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_TAG_CREATED_BY_LABEL"
description="COM_MOOJLA_TAG_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_TAG_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_TAG_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_TAG_MODIFIED_BY_LABEL"
description="COM_MOOJLA_TAG_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Access Field. Type: Accesslevel (joomla)-->
<field name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
default="1"
required="false" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_TAG_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_TAG_VERSION_LABEL"
description="COM_MOOJLA_TAG_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla tag" />
<!-- Dynamic Fields.-->
<!-- Tagid Field. Type: Text. (joomla)-->
<field type="text"
name="tagid"
label="COM_MOOJLA_TAG_TAGID_LABEL"
size="10"
maxlength="10"
default=""
description="COM_MOOJLA_TAG_TAGID_DESCRIPTION"
class="text_area"
filter="INT"
message="COM_MOOJLA_TAG_TAGID_MESSAGE"
hint="COM_MOOJLA_TAG_TAGID_HINT" />
<!-- Tagname Field. Type: Text. (joomla)-->
<field type="text"
name="tagname"
label="COM_MOOJLA_TAG_TAGNAME_LABEL"
size="64"
maxlength="64"
default=""
description="COM_MOOJLA_TAG_TAGNAME_DESCRIPTION"
class="text_area"
required="false"
message="COM_MOOJLA_TAG_TAGNAME_MESSAGE"
hint="COM_MOOJLA_TAG_TAGNAME_HINT" />
<!-- Isstandard Field. Type: Radio. (joomla)-->
<field type="radio"
name="isstandard"
label="COM_MOOJLA_TAG_ISSTANDARD_LABEL"
description="COM_MOOJLA_TAG_ISSTANDARD_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_TAG_YES</option>
<option
value="0">COM_MOOJLA_TAG_NO</option>
</field>
<!-- Tags Field. Type: Tag. (joomla)-->
<field type="tag"
name="tags"
mode="ajax"
label="COM_MOOJLA_TAG_TAGS_LABEL"
description="COM_MOOJLA_TAG_TAGS_DESCRIPTION"
class="inputbox small"
multiple="true" />
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this tag"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="tag"
/>
</fieldset>
</form>forms/tag_instance.xml000064400000013165151162147410011063
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_TAG_INSTANCE_CREATED_DATE_LABEL"
description="COM_MOOJLA_TAG_INSTANCE_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_TAG_INSTANCE_CREATED_BY_LABEL"
description="COM_MOOJLA_TAG_INSTANCE_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_TAG_INSTANCE_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_TAG_INSTANCE_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_TAG_INSTANCE_MODIFIED_BY_LABEL"
description="COM_MOOJLA_TAG_INSTANCE_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Access Field. Type: Accesslevel (joomla)-->
<field name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
default="1"
required="false" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_TAG_INSTANCE_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_TAG_INSTANCE_VERSION_LABEL"
description="COM_MOOJLA_TAG_INSTANCE_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla tag_instance" />
<!-- Dynamic Fields.-->
<!-- Moojlacourse Field. Type: Moojlacourse.
(custom)-->
<field type="moojlacourse"
name="moojlacourse"
label="COM_MOOJLA_TAG_INSTANCE_MOOJLACOURSE_LABEL"
description="COM_MOOJLA_TAG_INSTANCE_MOOJLACOURSE_DESCRIPTION"
message="COM_MOOJLA_TAG_INSTANCE_MOOJLACOURSE_MESSAGE"
class="list_class"
multiple="false"
default=""
button="false" />
<!-- Moodletag Field. Type: Moodletag. (custom)-->
<field type="moodletag"
name="moodletag"
label="COM_MOOJLA_TAG_INSTANCE_MOODLETAG_LABEL"
class="list_class"
multiple="false"
default="0"
button="false" />
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this tag_instance"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="tag_instance"
/>
</fieldset>
</form>forms/user_field_map.xml000064400000013643151162147410011403
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_USER_FIELD_MAP_CREATED_DATE_LABEL"
description="COM_MOOJLA_USER_FIELD_MAP_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_USER_FIELD_MAP_CREATED_BY_LABEL"
description="COM_MOOJLA_USER_FIELD_MAP_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_USER_FIELD_MAP_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_USER_FIELD_MAP_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_USER_FIELD_MAP_MODIFIED_BY_LABEL"
description="COM_MOOJLA_USER_FIELD_MAP_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_USER_FIELD_MAP_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_USER_FIELD_MAP_VERSION_LABEL"
description="COM_MOOJLA_USER_FIELD_MAP_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla user_field_map" />
<!-- Dynamic Fields.-->
<!-- Juserfields Field. Type: Juserfields.
(custom)-->
<field type="juserfields"
name="juserfields"
label="COM_MOOJLA_USER_FIELD_MAP_JUSERFIELDS_LABEL"
class="list_class"
multiple="false"
default=""
required="true"
button="false" />
<!-- Muserfields Field. Type: Muserfields.
(custom)-->
<field type="muserfields"
name="muserfields"
label="COM_MOOJLA_USER_FIELD_MAP_MUSERFIELDS_LABEL"
class="list_class"
multiple="false"
default="0"
required="true"
button="false" />
<!-- Iscv Field. Type: Radio. (joomla)-->
<field type="radio"
name="iscv"
label="COM_MOOJLA_USER_FIELD_MAP_ISCV_LABEL"
description="COM_MOOJLA_USER_FIELD_MAP_ISCV_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0"
readonly="false"
disabled="false">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_USER_FIELD_MAP_YES</option>
<option
value="0">COM_MOOJLA_USER_FIELD_MAP_NO</option>
</field>
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this user_field_map"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="user_field_map"
/>
</fieldset>
</form>forms/user_map.xml000064400000015175151162147410010242
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_moojla/models/rules"
addfieldpath="/administrator/components/com_moojla/models/fields"
>
<fieldset name="details">
<!-- Default Fields.-->
<!-- Id Field. Type: Text (joomla)-->
<field name="id"
type="text"
class="readonly"
readonly="true"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
size="10"
default="0" />
<!-- Date Created Field. Type: Calendar (joomla)-->
<field name="created"
type="calendar"
label="COM_MOOJLA_USER_MAP_CREATED_DATE_LABEL"
description="COM_MOOJLA_USER_MAP_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Created Field. Type: User (joomla)-->
<field name="created_by"
type="user"
label="COM_MOOJLA_USER_MAP_CREATED_BY_LABEL"
description="COM_MOOJLA_USER_MAP_CREATED_BY_DESC" />
<!-- Published Field. Type: List (joomla)-->
<field name="published"
type="list"
label="JSTATUS">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-2">JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla)-->
<field name="modified"
type="calendar"
class="readonly"
label="COM_MOOJLA_USER_MAP_MODIFIED_DATE_LABEL"
description="COM_MOOJLA_USER_MAP_MODIFIED_DATE_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<!-- User Modified Field. Type: User (joomla)-->
<field name="modified_by"
type="user"
label="COM_MOOJLA_USER_MAP_MODIFIED_BY_LABEL"
description="COM_MOOJLA_USER_MAP_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset" />
<!-- Ordering Field. Type: Numbers (joomla)-->
<field name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_MOOJLA_USER_MAP_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false" />
<!-- Version Field. Type: Text (joomla)-->
<field name="version"
type="text"
class="readonly"
label="COM_MOOJLA_USER_MAP_VERSION_LABEL"
description="COM_MOOJLA_USER_MAP_VERSION_DESC"
size="6"
readonly="true"
filter="unset" />
<!-- Was added due to Permissions JS needing a Title
field-->
<!-- Let us know at gh-629 should this change-->
<!--
https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235-->
<field name="title"
type="hidden"
default="moojla user_map" />
<!-- Dynamic Fields.-->
<!-- Jid Field. Type: User. (joomla)-->
<field type="user"
name="jid"
label="COM_MOOJLA_USER_MAP_JID_LABEL"
description="COM_MOOJLA_USER_MAP_JID_DESCRIPTION"
required="true" />
<!-- Mid Field. Type: Text. (joomla)-->
<field type="text"
name="mid"
label="COM_MOOJLA_USER_MAP_MID_LABEL"
size="10"
maxlength="50"
default=""
description="COM_MOOJLA_USER_MAP_MID_DESCRIPTION"
class="text_area"
readonly="false"
disabled="false"
required="true"
filter="INT"
message="COM_MOOJLA_USER_MAP_MID_MESSAGE"
hint="COM_MOOJLA_USER_MAP_MID_HINT"
autocomplete="off" />
<!-- Userimage Field. Type: Text. (joomla)-->
<field type="text"
name="userimage"
label="COM_MOOJLA_USER_MAP_USERIMAGE_LABEL"
size="1024"
maxlength="1024"
description="COM_MOOJLA_USER_MAP_USERIMAGE_DESCRIPTION"
class="text_area" />
<!-- Debug Field. Type: Hidden. (joomla)-->
<field type="hidden"
name="debug"
default="1"
filter="STRING" />
<!-- Updatetype Field. Type: Radio. (joomla)-->
<field type="radio"
name="updatetype"
label="COM_MOOJLA_USER_MAP_UPDATETYPE_LABEL"
class="btn-group btn-group-yesno"
default="1">
<!-- Option Set.-->
<option
value="1">COM_MOOJLA_USER_MAP_TWOWAY_EFFECT</option>
<option
value="-1">COM_MOOJLA_USER_MAP_MOODLE_EFFECT</option>
<option
value="-2">COM_MOOJLA_USER_MAP_JOOMLA_EFFECT</option>
<option
value="0">COM_MOOJLA_USER_MAP_NEVER</option>
</field>
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this user_map"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_moojla"
section="user_map"
/>
</fieldset>
</form>healthcheck.php000064400000033046151162147410007530
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage healthcheck.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Healthcheck Model
*/
class MoojlaModelHealthcheck extends JModelItem
{
/**
* Model context string.
*
* @var string
*/
protected $_context = 'com_moojla.healthcheck';
/**
* Model user data.
*
* @var strings
*/
protected $user;
protected $userId;
protected $guest;
protected $groups;
protected $levels;
protected $app;
protected $input;
protected $uikitComp;
/**
* @var object item
*/
protected $item;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*
* @return void
*/
protected function populateState()
{
$this->app = JFactory::getApplication();
$this->input = $this->app->input;
// Get the item main id
$id = $this->input->getInt('id', null);
$this->setState('healthcheck.id', $id);
// Load the parameters.
parent::populateState();
}
/**
* Method to get article data.
*
* @param integer $pk The id of the article.
*
* @return mixed Menu item data object on success, false on failure.
*/
public function getItem($pk = null)
{
$this->user = JFactory::getUser();
// check if this user has permission to access item
if (!$this->user->authorise('healthcheck.access',
'com_moojla'))
{
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('Not authorised!'),
'error');
// redirect away if not a correct to cPanel/default view
$app->redirect('index.php?option=com_moojla');
return false;
}
$this->userId = $this->user->get('id');
$this->guest = $this->user->get('guest');
$this->groups = $this->user->get('groups');
$this->authorisedGroups = $this->user->getAuthorisedGroups();
$this->levels = $this->user->getAuthorisedViewLevels();
$this->initSet = true;
$pk = (!empty($pk)) ? $pk : (int)
$this->getState('healthcheck.id');
if ($this->_item === null)
{
$this->_item = array();
}
if (!isset($this->_item[$pk]))
{
try
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Get data
/***[JCBGUI.dynamic_get.php_custom_get.57.$$$$]***/
$plugins = new stdClass();
$plugins->joomla = array();
$plugins->thirdparties = array();
$moojla_joomla_plugins_name = array( // translate need
"moojlaaditionalfields_moojlaaditionnalfieldcb" =>
"Its important for syncing users with joomla fields",
"moojlaaditionalfields_moojlaaditionnalfieldnative"
=> "Its important for syncing users with cb fields",
"user_moojlasso_j2m" => "Its important for
syncing users login status from joomla to moodle",
"moojlaevents_moojlasso_m2j" => "Its important
for syncing users login status from moodle to joomla",
"user_moojlausersyncer_j2m" => "Its important
for syncing users from joomla to moodle",
"moojlaevents_moojlausersyncer_m2j" => "Its
important for syncing users from moodle to joomla",
"moojlaevents_moojlacoursesyncer_m2j" => "Its
important for syncing course from moodle to joomla",
"system_moojlahikashoporder" => "Its important
enrolling users in hikashop products(courses)",
"moojlaevents_moojlaenrolmentmethod" => "Its
important for syncing course enrolment instances",
"moojlashopintegration_moojlahikashopproduct_m2j" =>
"Its important for syncing course product in hikashop",
"search_moojlasearchbycourse" => "Its important
for search course by name",
"search_moojlasearchbycategory" => "Its
important for search course by category",
"user_moojlaautologingwithredirect" => "for
login user after creation",
"moojlaevents_moojlacourse_events" => "for
showing particles like kommento in moojla coursedetil view",
"moojlaevents_moojlagroup_manager" => "Its
important for creating groups after course creation",
"user_moojlaenrolwithgroups_j2m" => "Its
important for enrrol(unenrol) users with joinig(leaving) groups",
"moojlaevents_moojlatagsyncer_m2j" => "for
creating and syncing coursetags from moodle to joomla",
"moojlaevents_moojlaenrolment_m2j" => "Its
important for syncing moojla enroments",
);
foreach($moojla_joomla_plugins_name as $mjp => $importancy)
{
$plugins->joomla[$mjp] = new stdClass();
$plugins->joomla[$mjp]->installed = false;
$plugins->joomla[$mjp]->enabled = false;
$plugins->joomla[$mjp]->importancy = $importancy;
}
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__extensions'));
$query->where($db->quoteName('name') . ' IN
("plg_' . implode('","plg_',
array_keys($moojla_joomla_plugins_name)) . '")');
$db->setQuery($query);
$extensions_res = $db->loadObjectList('name');
foreach(array_keys($moojla_joomla_plugins_name) as $mjp)
{
if(isset($extensions_res['PLG_' . strtoupper($mjp)]))
{
$plugins->joomla[$mjp]->installed = true;
$plugins->joomla[$mjp]->enabled =
(($extensions_res['PLG_' . strtoupper($mjp)]->enabled) == 1);
}
}
$moojla_cb_plugins_name = array( // translate need
"moojlacbeventforwarder" => "Its important for
syncing users with cb fields"
);
foreach($moojla_cb_plugins_name as $mcp => $importancy)
{
$plugins->thirdparties['cb'][$mcp] = new
stdClass();
$plugins->thirdparties['cb'][$mcp]->installed =
false;
$plugins->thirdparties['cb'][$mcp]->enabled =
false;
$plugins->thirdparties['cb'][$mcp]->importancy =
$importancy;
}
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__comprofiler_plugin'));
$query->where($db->quoteName('element') . ' IN
("' . implode('","',
array_keys($moojla_cb_plugins_name)) . '")');
$db->setQuery($query);
try {
$comprofiler_plugin =
$db->loadObjectList('element');
foreach(array_keys($moojla_cb_plugins_name) as $mcp)
{
if(isset($comprofiler_plugin[$mcp]))
{
$plugins->thirdparties['cb'][$mcp]->installed
= true;
$plugins->thirdparties['cb'][$mcp]->enabled =
(($comprofiler_plugin[$mcp]->published) == 1);
}
}
} catch (Exception $e) {
$plugins->thirdparties['cb'] = array();
}
$this->_item[$pk] = array("plugins" => $plugins);
$uri = JUri::getInstance();
$params = JComponentHelper::getParams('com_moojla');
$moodle_url = trim($params->get('moodle_url'));
$joomla_token = trim($params->get('joomla_token'));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL =>
$moodle_url.'auth/moojla/requestHandler.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('joomla_url' =>
$uri->root(),'joomla_token' => $joomla_token),
));
$response = curl_exec($curl);
$this->_item[$pk]['component'] =
json_decode($response);
curl_close($curl);
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$dataObj = array(
"wsfunction" =>
"moojla_health_check",
"moodlewsrestformat" => "json",
);
$tokenReq = MoojlaHelper::sendRequestToMoodle($dataObj);
$token_status = json_decode($tokenReq->response);
$this->_item[$pk]['component']->moodleToken =
$token_status->message === 1 ? true : false;
if($token_status->message !== 1)
{
$this->_item[$pk]['component']->error->moodleToken =
'Moodle token should be exactly what set to moojla service in
yourmoodle.com/admin/settings.php?section=webservicetokens'; //
translate need
}
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$dataObj = array(
"wsfunction" =>
"moojla_get_users_minimal",
"moodlewsrestformat" => "json",
"notadmin" => 1
);
$moodleusers =
json_decode(MoojlaHelper::sendRequestToMoodle($dataObj)->response,
true);
$mids = array_column($moodleusers, 'id');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('mid');
$query->from($db->quoteName('#__moojla_user_map'));
$query->where($db->quoteName('mid') . '
<> 0');
$query->where($db->quoteName('jid') . '
<> 0');
$query->where($db->quoteName('published') . '
= 1');
$db->setQuery($query);
$map = $db->loadColumn();
$diff = array_diff($mids ,$map);
$this->_item[$pk]['moodleusersdiff'] = $diff;
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$dataObj = array(
"wsfunction" =>
"moojla_get_mapped_users",
"moodlewsrestformat" => "json",
);
$moodlemoojlamap =
json_decode(MoojlaHelper::sendRequestToMoodle($dataObj)->response,
true);
$jids = array_column($moodlemoojlamap, 'jid');
$db = JFactory::getDbo();
$query = "SELECT u.id FROM #__users AS u WHERE u.id NOT IN (
SELECT uum.user_id FROM #__user_usergroup_map AS uum INNER JOIN
#__usergroups AS uu ON uu.id = uum.group_id WHERE uu.title IN ('Super
Users', 'Administrator'))";
$db->setQuery($query);
$jmap = $db->loadColumn();
$jdiff = array_diff($jmap, $jids);
$this->_item[$pk]['joomlausersdiff'] = $jdiff;
JLoader::register('MoojlaHelper',
JPATH_ADMINISTRATOR.'/components/com_moojla/helpers/moojla.php');
$dataObj = array(
"wsfunction" =>
"moojla_get_courses",
"moodlewsrestformat" => "json",
);
$moodlecourses =
json_decode(MoojlaHelper::sendRequestToMoodle($dataObj)->response,
true);
$remoteids = array_column($moodlecourses, 'id');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('remoteid');
$query->from($db->quoteName('#__moojla_course'));
$query->where($db->quoteName('published') . '
= 1');
$db->setQuery($query);
$cmap = $db->loadColumn();
$coursedif = array_diff($remoteids, $cmap);
$this->_item[$pk]['coursedif'] = $coursedif;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('mcatid');
$query->from($db->quoteName('#__moojla_category_map'));
$query->where($db->quoteName('published') . '
= 1');
$db->setQuery($query);
$catmap = $db->loadColumn();
$dataObj = array(
"wsfunction" =>
"moojla_get_course_categories",
"moodlewsrestformat" => "json",
);
$course_cats =
json_decode(MoojlaHelper::sendRequestToMoodle($dataObj)->response);
$categories = array_column($course_cats, 'id');
$catdif = array_diff($categories, $catmap);
$this->_item[$pk]['catdif'] = $catdif;
return $this->_item[$pk];
/***[/JCBGUI$$$$]***/
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a stdClass object.
$data = $db->loadObject();
if (empty($data))
{
$app = JFactory::getApplication();
// If no data is found redirect to default page and show warning.
$app->enqueueMessage(JText::_('COM_MOOJLA_NOT_FOUND_OR_ACCESS_DENIED'),
'warning');
$app->redirect('index.php?option=com_moojla');
return false;
}
// set data object to item.
$this->_item[$pk] = $data;
}
catch (Exception $e)
{
if ($e->getCode() == 404)
{
// Need to go thru the error handler to allow Redirect to work.
JError::raiseWarning(404, $e->getMessage());
}
else
{
$this->setError($e);
$this->_item[$pk] = false;
}
}
}
return $this->_item[$pk];
}
}
languagetranslation.php000064400000010336151162147410011324
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage languagetranslation.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Languagetranslation Model
*/
class MoojlaModelLanguagetranslation extends JModelItem
{
/**
* Model context string.
*
* @var string
*/
protected $_context = 'com_moojla.languagetranslation';
/**
* Model user data.
*
* @var strings
*/
protected $user;
protected $userId;
protected $guest;
protected $groups;
protected $levels;
protected $app;
protected $input;
protected $uikitComp;
/**
* @var object item
*/
protected $item;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*
* @return void
*/
protected function populateState()
{
$this->app = JFactory::getApplication();
$this->input = $this->app->input;
// Get the item main id
$id = $this->input->getInt('id', null);
$this->setState('languagetranslation.id', $id);
// Load the parameters.
parent::populateState();
}
/**
* Method to get article data.
*
* @param integer $pk The id of the article.
*
* @return mixed Menu item data object on success, false on failure.
*/
public function getItem($pk = null)
{
$this->user = JFactory::getUser();
// check if this user has permission to access item
if (!$this->user->authorise('languagetranslation.access',
'com_moojla'))
{
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('Not authorised!'),
'error');
// redirect away if not a correct to cPanel/default view
$app->redirect('index.php?option=com_moojla');
return false;
}
$this->userId = $this->user->get('id');
$this->guest = $this->user->get('guest');
$this->groups = $this->user->get('groups');
$this->authorisedGroups = $this->user->getAuthorisedGroups();
$this->levels = $this->user->getAuthorisedViewLevels();
$this->initSet = true;
$pk = (!empty($pk)) ? $pk : (int)
$this->getState('languagetranslation.id');
if ($this->_item === null)
{
$this->_item = array();
}
if (!isset($this->_item[$pk]))
{
try
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Get data
/***[JCBGUI.dynamic_get.php_custom_get.62.$$$$]***/
return array();
/***[/JCBGUI$$$$]***/
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a stdClass object.
$data = $db->loadObject();
if (empty($data))
{
$app = JFactory::getApplication();
// If no data is found redirect to default page and show warning.
$app->enqueueMessage(JText::_('COM_MOOJLA_NOT_FOUND_OR_ACCESS_DENIED'),
'warning');
$app->redirect('index.php?option=com_moojla');
return false;
}
// set data object to item.
$this->_item[$pk] = $data;
}
catch (Exception $e)
{
if ($e->getCode() == 404)
{
// Need to go thru the error handler to allow Redirect to work.
JError::raiseWarning(404, $e->getMessage());
}
else
{
$this->setError($e);
$this->_item[$pk] = false;
}
}
}
return $this->_item[$pk];
}
}
module.php000064400000055251151162147410006554 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage module.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Module Model
*/
class MoojlaModelModule extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'module_section_id',
'module_id',
'visible',
'uservisible',
'name',
'modname',
'url',
'description',
'modicon'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.module';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'module', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/***[JCBGUI.admin_view.php_model.132.$$$$]***/
public function myDelete($pk){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('rules',
'id')));
$query->from($db->quoteName('#__assets'));
$query->where($db->quoteName('name') . ' = '
. $db->quote('com_moojla'));
$db->setQuery($query);
$results = $db->loadObjectList();
$acls = json_decode($results[0]->rules);
$deleteAcl = null;
$permission = 'core.delete';
if(!property_exists($acls, $permission))
{
$acls->$permission = new stdClass();
}
$pub = '1';
$acls->$permission->$pub = 1;
$obj = new stdClass();
$obj->id = $results[0]->id;
$obj->rules = json_encode($acls);
JFactory::getDbo()->updateObject('#__assets', $obj,
'id');
$obj = new stdClass();
$obj->id = $pk;
$obj->published = -2;
JFactory::getDbo()->updateObject('#__moojla_module', $obj,
'id'); // trash item
$pks = array($pk);
$res = $this->delete($pks);
$obj = new stdClass();
$obj->id = $results[0]->id;
$obj->rules = $results[0]->rules;
JFactory::getDbo()->updateObject('#__assets', $obj,
'id');
return $res;
}/***[/JCBGUI$$$$]***/
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.module',
'module', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.module.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/module.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.module.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.module.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.module.'. ((int) isset($data[$key]) ? $data[$key] :
0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_module'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.module.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.module', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return array('module_id');
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('module');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('module');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Only for strings
if (MoojlaHelper::checkString($this->table->module_id) &&
!is_numeric($this->table->module_id))
{
$this->table->module_id =
$this->generateUnique('module_id',$this->table->module_id);
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('module');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the empty visible item to data
if (!isset($data['visible']))
{
$data['visible'] = '';
}
// Set the empty uservisible item to data
if (!isset($data['uservisible']))
{
$data['uservisible'] = '';
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
modules.php000064400000020536151162147410006735 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage modules.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Modules Model
*/
class MoojlaModelModules extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.module_section_id','module_section_id',
'a.modname','modname',
'a.name','name'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$module_section_id = $this->getUserStateFromRequest($this->context
. '.filter.module_section_id',
'filter_module_section_id');
if ($formSubmited)
{
$module_section_id =
$app->input->post->get('module_section_id');
$this->setState('filter.module_section_id',
$module_section_id);
}
$modname = $this->getUserStateFromRequest($this->context .
'.filter.modname', 'filter_modname');
if ($formSubmited)
{
$modname = $app->input->post->get('modname');
$this->setState('filter.modname', $modname);
}
$name = $this->getUserStateFromRequest($this->context .
'.filter.name', 'filter_name');
if ($formSubmited)
{
$name = $app->input->post->get('name');
$this->setState('filter.name', $name);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_module',
'a'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.name LIKE '.$search.')');
}
}
// Filter by Module_section_id.
$_module_section_id =
$this->getState('filter.module_section_id');
if (is_numeric($_module_section_id))
{
if (is_float($_module_section_id))
{
$query->where('a.module_section_id = ' . (float)
$_module_section_id);
}
else
{
$query->where('a.module_section_id = ' . (int)
$_module_section_id);
}
}
elseif (MoojlaHelper::checkString($_module_section_id))
{
$query->where('a.module_section_id = ' .
$db->quote($db->escape($_module_section_id)));
}
// Filter by Modname.
$_modname = $this->getState('filter.modname');
if (is_numeric($_modname))
{
if (is_float($_modname))
{
$query->where('a.modname = ' . (float) $_modname);
}
else
{
$query->where('a.modname = ' . (int) $_modname);
}
}
elseif (MoojlaHelper::checkString($_modname))
{
$query->where('a.modname = ' .
$db->quote($db->escape($_modname)));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' .
$this->getState('filter.module_section_id');
$id .= ':' . $this->getState('filter.modname');
$id .= ':' . $this->getState('filter.name');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_module'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_module'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
moojla.php000064400000022227151162147410006545 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage moojla.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Moojla Model
*/
class MoojlaModelMoojla extends JModelList
{
public function getIcons()
{
// load user for access menus
$user = JFactory::getUser();
// reset icon array
$icons = array();
// view groups array
$viewGroups = array(
'main' => array('png.courses',
'png.courses.catid_qpo0O0oqp_com_moojla_po0O0oq_course',
'png.course_fields_mapper', 'png.user_maps',
'png.user_fields_map', 'png.course_group_maps',
'png.enrolments', 'png.tags',
'png.tag_instances', 'png.healthcheck',
'png.cohorts', 'png.languagetranslation')
);
// view access array
$viewAccess = array(
'healthcheck.submenu' => 'healthcheck.submenu',
'healthcheck.dashboard_list' =>
'healthcheck.dashboard_list',
'languagetranslation.submenu' =>
'languagetranslation.submenu',
'languagetranslation.dashboard_list' =>
'languagetranslation.dashboard_list',
'courses.access' => 'course.access',
'course.access' => 'course.access',
'course.create' => 'course.create',
'courses.submenu' => 'course.submenu',
'courses.dashboard_list' =>
'course.dashboard_list',
'course_fields_mapper.access' =>
'course_field_mapper.access',
'course_field_mapper.access' =>
'course_field_mapper.access',
'course_fields_mapper.submenu' =>
'course_field_mapper.submenu',
'course_fields_mapper.dashboard_list' =>
'course_field_mapper.dashboard_list',
'user_maps.submenu' => 'user_map.submenu',
'user_maps.dashboard_list' =>
'user_map.dashboard_list',
'user_fields_map.submenu' =>
'user_field_map.submenu',
'user_fields_map.dashboard_list' =>
'user_field_map.dashboard_list',
'course_group_maps.submenu' =>
'course_group_map.submenu',
'course_group_maps.dashboard_list' =>
'course_group_map.dashboard_list',
'enrolments.submenu' => 'enrolment.submenu',
'enrolments.dashboard_list' =>
'enrolment.dashboard_list',
'tags.access' => 'tag.access',
'tag.access' => 'tag.access',
'tags.submenu' => 'tag.submenu',
'tags.dashboard_list' => 'tag.dashboard_list',
'tag_instances.access' => 'tag_instance.access',
'tag_instance.access' => 'tag_instance.access',
'tag_instances.submenu' =>
'tag_instance.submenu',
'tag_instances.dashboard_list' =>
'tag_instance.dashboard_list',
'cohorts.submenu' => 'cohort.submenu',
'cohorts.dashboard_list' =>
'cohort.dashboard_list');
// loop over the $views
foreach($viewGroups as $group => $views)
{
$i = 0;
if (MoojlaHelper::checkArray($views))
{
foreach($views as $view)
{
$add = false;
// external views (links)
if (strpos($view,'||') !== false)
{
$dwd = explode('||', $view);
if (count($dwd) == 3)
{
list($type, $name, $url) = $dwd;
$viewName = $name;
$alt = $name;
$url = $url;
$image = $name . '.' . $type;
$name = 'COM_MOOJLA_DASHBOARD_' .
MoojlaHelper::safeString($name,'U');
}
}
// internal views
elseif (strpos($view,'.') !== false)
{
$dwd = explode('.', $view);
if (count($dwd) == 3)
{
list($type, $name, $action) = $dwd;
}
elseif (count($dwd) == 2)
{
list($type, $name) = $dwd;
$action = false;
}
if ($action)
{
$viewName = $name;
switch($action)
{
case 'add':
$url = 'index.php?option=com_moojla&view=' . $name .
'&layout=edit';
$image = $name . '_' . $action. '.' . $type;
$alt = $name . ' ' . $action;
$name =
'COM_MOOJLA_DASHBOARD_'.MoojlaHelper::safeString($name,'U').'_ADD';
$add = true;
break;
default:
// check for new convention (more stable)
if (strpos($action, '_qpo0O0oqp_') !== false)
{
list($action, $extension) = (array)
explode('_qpo0O0oqp_', $action);
$extension = str_replace('_po0O0oq_', '.',
$extension);
}
else
{
$extension = 'com_moojla.' . $name;
}
$url =
'index.php?option=com_categories&view=categories&extension='
. $extension;
$image = $name . '_' . $action . '.' . $type;
$alt = $viewName . ' ' . $action;
$name = 'COM_MOOJLA_DASHBOARD_' .
MoojlaHelper::safeString($name,'U') . '_' .
MoojlaHelper::safeString($action,'U');
break;
}
}
else
{
$viewName = $name;
$alt = $name;
$url = 'index.php?option=com_moojla&view=' . $name;
$image = $name . '.' . $type;
$name = 'COM_MOOJLA_DASHBOARD_' .
MoojlaHelper::safeString($name,'U');
$hover = false;
}
}
else
{
$viewName = $view;
$alt = $view;
$url = 'index.php?option=com_moojla&view=' . $view;
$image = $view . '.png';
$name = ucwords($view).'<br /><br />';
$hover = false;
}
// first make sure the view access is set
if (MoojlaHelper::checkArray($viewAccess))
{
// setup some defaults
$dashboard_add = false;
$dashboard_list = false;
$accessTo = '';
$accessAdd = '';
// access checking start
$accessCreate = (isset($viewAccess[$viewName.'.create'])) ?
MoojlaHelper::checkString($viewAccess[$viewName.'.create']):false;
$accessAccess = (isset($viewAccess[$viewName.'.access'])) ?
MoojlaHelper::checkString($viewAccess[$viewName.'.access']):false;
// set main controllers
$accessDashboard_add =
(isset($viewAccess[$viewName.'.dashboard_add'])) ?
MoojlaHelper::checkString($viewAccess[$viewName.'.dashboard_add']):false;
$accessDashboard_list =
(isset($viewAccess[$viewName.'.dashboard_list'])) ?
MoojlaHelper::checkString($viewAccess[$viewName.'.dashboard_list']):false;
// check for adding access
if ($add && $accessCreate)
{
$accessAdd = $viewAccess[$viewName.'.create'];
}
elseif ($add)
{
$accessAdd = 'core.create';
}
// check if access to view is set
if ($accessAccess)
{
$accessTo = $viewAccess[$viewName.'.access'];
}
// set main access controllers
if ($accessDashboard_add)
{
$dashboard_add =
$user->authorise($viewAccess[$viewName.'.dashboard_add'],
'com_moojla');
}
if ($accessDashboard_list)
{
$dashboard_list =
$user->authorise($viewAccess[$viewName.'.dashboard_list'],
'com_moojla');
}
if (MoojlaHelper::checkString($accessAdd) &&
MoojlaHelper::checkString($accessTo))
{
// check access
if($user->authorise($accessAdd, 'com_moojla')
&& $user->authorise($accessTo, 'com_moojla')
&& $dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (MoojlaHelper::checkString($accessTo))
{
// check access
if($user->authorise($accessTo, 'com_moojla') &&
$dashboard_list)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (MoojlaHelper::checkString($accessAdd))
{
// check access
if($user->authorise($accessAdd, 'com_moojla')
&& $dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
$i++;
}
}
else
{
$icons[$group][$i] = false;
}
}
return $icons;
}
}
section.php000064400000055215151162147410006733 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage section.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Section Model
*/
class MoojlaModelSection extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'courseid',
'section_id',
'name',
'visible',
'uservisible',
'summary'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.section';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'section', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/***[JCBGUI.admin_view.php_model.131.$$$$]***/
public function myDelete($pk){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('rules',
'id')));
$query->from($db->quoteName('#__assets'));
$query->where($db->quoteName('name') . ' = '
. $db->quote('com_moojla'));
$db->setQuery($query);
$results = $db->loadObjectList();
$acls = json_decode($results[0]->rules);
$deleteAcl = null;
$permission = 'core.delete';
if(!property_exists($acls, $permission))
{
$acls->$permission = new stdClass();
}
$pub = '1';
$acls->$permission->$pub = 1;
$obj = new stdClass();
$obj->id = $results[0]->id;
$obj->rules = json_encode($acls);
JFactory::getDbo()->updateObject('#__assets', $obj,
'id');
$obj = new stdClass();
$obj->id = $pk;
$obj->published = -2;
JFactory::getDbo()->updateObject('#__moojla_section',
$obj, 'id'); // trash item
$pks = array($pk);
$res = $this->delete($pks);
$obj = new stdClass();
$obj->id = $results[0]->id;
$obj->rules = $results[0]->rules;
JFactory::getDbo()->updateObject('#__assets', $obj,
'id');
return $res;
}/***[/JCBGUI$$$$]***/
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.section',
'section', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.section.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/section.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.section.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.section.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.section.'. ((int) isset($data[$key]) ? $data[$key] :
0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_section'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.section.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.section', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return array('section_id');
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('section');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('section');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Only for strings
if (MoojlaHelper::checkString($this->table->section_id) &&
!is_numeric($this->table->section_id))
{
$this->table->section_id =
$this->generateUnique('section_id',$this->table->section_id);
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('section');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the empty visible item to data
if (!isset($data['visible']))
{
$data['visible'] = '';
}
// Set the empty uservisible item to data
if (!isset($data['uservisible']))
{
$data['uservisible'] = '';
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
sections.php000064400000017453151162147430007122 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage sections.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Sections Model
*/
class MoojlaModelSections extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.courseid','courseid',
'a.section_id','section_id',
'a.name','name'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$courseid = $this->getUserStateFromRequest($this->context .
'.filter.courseid', 'filter_courseid');
if ($formSubmited)
{
$courseid = $app->input->post->get('courseid');
$this->setState('filter.courseid', $courseid);
}
$section_id = $this->getUserStateFromRequest($this->context .
'.filter.section_id', 'filter_section_id');
if ($formSubmited)
{
$section_id = $app->input->post->get('section_id');
$this->setState('filter.section_id', $section_id);
}
$name = $this->getUserStateFromRequest($this->context .
'.filter.name', 'filter_name');
if ($formSubmited)
{
$name = $app->input->post->get('name');
$this->setState('filter.name', $name);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_section',
'a'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.name LIKE '.$search.')');
}
}
// Filter by Courseid.
$_courseid = $this->getState('filter.courseid');
if (is_numeric($_courseid))
{
if (is_float($_courseid))
{
$query->where('a.courseid = ' . (float) $_courseid);
}
else
{
$query->where('a.courseid = ' . (int) $_courseid);
}
}
elseif (MoojlaHelper::checkString($_courseid))
{
$query->where('a.courseid = ' .
$db->quote($db->escape($_courseid)));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.courseid');
$id .= ':' . $this->getState('filter.section_id');
$id .= ':' . $this->getState('filter.name');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_section'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_section'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
tag.php000064400000057652151162147430006053 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage tag.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Tag Model
*/
class MoojlaModelTag extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'tagid',
'isstandard'
),
'right' => array(
'tagname',
'tags'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.tag';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'tag', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
if (!empty($item->id))
{
// Get Tag IDs.
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id, 'com_moojla.tag');
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.tag', 'tag',
$options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.tag.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/tag.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.tag.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.tag.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.tag.'. ((int) isset($data[$key]) ? $data[$key] : 0))
or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_tag'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.tag.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.tag', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return array('tagid');
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
/***[JCBGUI.admin_view.php_before_delete.136.$$$$]***/
require_once(JPATH_ADMINISTRATOR.'/components/com_moojla/models/tag_instance.php');
require_once(JPATH_ADMINISTRATOR.'/components/com_tags/models/tag.php');
require_once(JPATH_ADMINISTRATOR.'/components/com_tags/tables/tag.php');
$db= JFactory::getDbo();
$query= $db->getQuery(true)
->select(' ti.id as tiid , ctm.tag_id as tag_id')
->from($db->quoteName('#__moojla_tag','mt'))
->join('inner',$db->quoteName('#__moojla_tag_instance','ti').'on'.$db->quoteName('mt.tagid').'='.$db->quoteName('ti.moodletag'))
->join('inner',$db->quoteName('#__contentitem_tag_map','ctm').'on'.$db->quoteName('mt.id').'='.$db->quoteName('ctm.content_item_id'))
->where($db->quoteName('mt.id').'IN('.implode(',',$pks).')');
$db->setQuery($query);
$tiids= $db->loadColumn(0);
$tag_ids= $db->loadColumn(1);
$tiModel= new MoojlaModelTag_instance;
$tiModel->publish($tiids,-2);
$tiModel->delete($tiids);
$tagModel= new TagsModelTag;
$tagModel->publish($tag_ids,-2);
$tagModel->delete($tag_ids);
/***[/JCBGUI$$$$]***/
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('tag');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('tag');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Only for strings
if (MoojlaHelper::checkString($this->table->tagname) &&
!is_numeric($this->table->tagname))
{
$this->table->tagname =
$this->generateUnique('tagname',$this->table->tagname);
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('tag');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
/***[JCBGUI.admin_view.php_before_save.136.$$$$]***/
require_once(JPATH_ADMINISTRATOR.'/components/com_tags/models/tag.php');
require_once(JPATH_ADMINISTRATOR.'/components/com_tags/tables/tag.php');
$joomlatag = array();
if($data['id']) // update
{
$db= JFactory::getDbo();
$query= $db->getQuery(true)
->select('ctm.tag_id as tag_id')
->from($db->quoteName('#__moojla_tag','mt'))
->join('inner',$db->quoteName('#__contentitem_tag_map','ctm').'on'.$db->quoteName('mt.id').'='.$db->quoteName('ctm.content_item_id'))
->where($db->quoteName('mt.id') . ' = ' .
$db->quote($data['id']));
$db->setQuery($query);
$tagrows = $db->loadAssoc();
if(isset($tagrows['tag_id']))
{
$joomlatag['id'] = $tagrows['tag_id'];
}
}
$db= JFactory::getDbo();
$query= $db->getQuery(true)
->select('id')
->from($db->quoteName('#__tags'))
->where($db->quoteName('title') . ' = ' .
$db->quote($data['tagname']));
$db->setQuery($query);
$tagid = $db->loadResult();
if(!$tagid)
{
$joomlatag['access'] = 1;
$joomlatag['language'] = '*';
$joomlatag['published'] = 1;
$joomlatag['title'] = $data['tagname'];
$tagModel= new TagsModelTag;
$tagModel->save($joomlatag);
$itemid = ($tagrows['tag_id'] ?
array($tagrows['tag_id']) :
array($tagModel->getItem()->id));
$data['tags'] = $itemid;
}
else
{
$data['tags'] = array($tagid);
}
/***[/JCBGUI$$$$]***/
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
tags.php000064400000023051151162147430006220 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage tags.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Tags Model
*/
class MoojlaModelTags extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.access','access',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.tagid','tagid',
'a.tagname','tagname'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$tagid = $this->getUserStateFromRequest($this->context .
'.filter.tagid', 'filter_tagid');
if ($formSubmited)
{
$tagid = $app->input->post->get('tagid');
$this->setState('filter.tagid', $tagid);
}
$tagname = $this->getUserStateFromRequest($this->context .
'.filter.tagname', 'filter_tagname');
if ($formSubmited)
{
$tagname = $app->input->post->get('tagname');
$this->setState('filter.tagname', $tagname);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// Set values to display correctly.
if (MoojlaHelper::checkArray($items))
{
// Get the user object if not set.
if (!isset($user) || !MoojlaHelper::checkObject($user))
{
$user = JFactory::getUser();
}
foreach ($items as $nr => &$item)
{
// Add the tags
$item->tags = new JHelperTags;
$item->tags->getTagIds(
$item->id, 'com_moojla.tag'
);
if ($item->tags->tags)
{
$item->tags = implode(', ',
$item->tags->getTagNames(
explode(',', $item->tags->tags)
)
);
}
else
{
$item->tags = '';
}
}
}
// set selection value to a translatable value
if (MoojlaHelper::checkArray($items))
{
foreach ($items as $nr => &$item)
{
// convert isstandard
$item->isstandard =
$this->selectionTranslation($item->isstandard,
'isstandard');
}
}
// return items
return $items;
}
/**
* Method to convert selection values to translatable string.
*
* @return translatable string
*/
public function selectionTranslation($value,$name)
{
// Array of isstandard language strings
if ($name === 'isstandard')
{
$isstandardArray = array(
1 => 'COM_MOOJLA_TAG_YES',
0 => 'COM_MOOJLA_TAG_NO'
);
// Now check if value is found in this array
if (isset($isstandardArray[$value]) &&
MoojlaHelper::checkString($isstandardArray[$value]))
{
return $isstandardArray[$value];
}
}
return $value;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_tag',
'a'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Filter by access level.
$_access = $this->getState('filter.access');
if ($_access && is_numeric($_access))
{
$query->where('a.access = ' . (int) $_access);
}
elseif (MoojlaHelper::checkArray($_access))
{
// Secure the array for the query
$_access = ArrayHelper::toInteger($_access);
// Filter by the Access Array.
$query->where('a.access IN (' . implode(',',
$_access) . ')');
}
// Implement View Level Access
if (!$user->authorise('core.options',
'com_moojla'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.tagid LIKE '.$search.' OR a.tagname
LIKE '.$search.')');
}
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
// Check if the value is an array
$_access = $this->getState('filter.access');
if (MoojlaHelper::checkArray($_access))
{
$id .= ':' . implode(':', $_access);
}
// Check if this is only an number or string
elseif (is_numeric($_access)
|| MoojlaHelper::checkString($_access))
{
$id .= ':' . $_access;
}
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.tagid');
$id .= ':' . $this->getState('filter.tagname');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_tag'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_tag'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
tag_instance.php000064400000052354151162147430007731 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage tag_instance.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla Tag_instance Model
*/
class MoojlaModelTag_instance extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'moodletag'
),
'right' => array(
'moojlacourse'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.tag_instance';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'tag_instance', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.tag_instance',
'tag_instance', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.tag_instance.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/tag_instance.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.tag_instance.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.tag_instance.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.tag_instance.'. ((int) isset($data[$key]) ?
$data[$key] : 0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_tag_instance'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.tag_instance.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.tag_instance', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('tag_instance');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('tag_instance');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Only for strings
if (MoojlaHelper::checkString($this->table->moojlacourse)
&& !is_numeric($this->table->moojlacourse))
{
$this->table->moojlacourse =
$this->generateUnique('moojlacourse',$this->table->moojlacourse);
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('tag_instance');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
tag_instances.php000064400000023354151162147430010112 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage tag_instances.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Tag_instances Model
*/
class MoojlaModelTag_instances extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.access','access',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'g.fullname','moojlacourse',
'h.tagname','moodletag'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$moojlacourse = $this->getUserStateFromRequest($this->context .
'.filter.moojlacourse', 'filter_moojlacourse');
if ($formSubmited)
{
$moojlacourse =
$app->input->post->get('moojlacourse');
$this->setState('filter.moojlacourse', $moojlacourse);
}
$moodletag = $this->getUserStateFromRequest($this->context .
'.filter.moodletag', 'filter_moodletag');
if ($formSubmited)
{
$moodletag = $app->input->post->get('moodletag');
$this->setState('filter.moodletag', $moodletag);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_tag_instance',
'a'));
// From the moojla_course table.
$query->select($db->quoteName('g.fullname','moojlacourse_fullname'));
$query->join('LEFT',
$db->quoteName('#__moojla_course', 'g') . ' ON
(' . $db->quoteName('a.moojlacourse') . ' = ' .
$db->quoteName('g.remoteid') . ')');
// From the moojla_tag table.
$query->select($db->quoteName('h.tagname','moodletag_tagname'));
$query->join('LEFT',
$db->quoteName('#__moojla_tag', 'h') . ' ON
(' . $db->quoteName('a.moodletag') . ' = ' .
$db->quoteName('h.tagid') . ')');
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Filter by access level.
$_access = $this->getState('filter.access');
if ($_access && is_numeric($_access))
{
$query->where('a.access = ' . (int) $_access);
}
elseif (MoojlaHelper::checkArray($_access))
{
// Secure the array for the query
$_access = ArrayHelper::toInteger($_access);
// Filter by the Access Array.
$query->where('a.access IN (' . implode(',',
$_access) . ')');
}
// Implement View Level Access
if (!$user->authorise('core.options',
'com_moojla'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.moojlacourse LIKE '.$search.' OR
g.fullname LIKE '.$search.' OR a.moodletag LIKE
'.$search.' OR h.tagname LIKE '.$search.')');
}
}
// Filter by Moojlacourse.
$_moojlacourse = $this->getState('filter.moojlacourse');
if (is_numeric($_moojlacourse))
{
if (is_float($_moojlacourse))
{
$query->where('a.moojlacourse = ' . (float)
$_moojlacourse);
}
else
{
$query->where('a.moojlacourse = ' . (int) $_moojlacourse);
}
}
elseif (MoojlaHelper::checkString($_moojlacourse))
{
$query->where('a.moojlacourse = ' .
$db->quote($db->escape($_moojlacourse)));
}
// Filter by Moodletag.
$_moodletag = $this->getState('filter.moodletag');
if (is_numeric($_moodletag))
{
if (is_float($_moodletag))
{
$query->where('a.moodletag = ' . (float) $_moodletag);
}
else
{
$query->where('a.moodletag = ' . (int) $_moodletag);
}
}
elseif (MoojlaHelper::checkString($_moodletag))
{
$query->where('a.moodletag = ' .
$db->quote($db->escape($_moodletag)));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
// Check if the value is an array
$_access = $this->getState('filter.access');
if (MoojlaHelper::checkArray($_access))
{
$id .= ':' . implode(':', $_access);
}
// Check if this is only an number or string
elseif (is_numeric($_access)
|| MoojlaHelper::checkString($_access))
{
$id .= ':' . $_access;
}
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' .
$this->getState('filter.moojlacourse');
$id .= ':' . $this->getState('filter.moodletag');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_tag_instance'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_tag_instance'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
user_fields_map.php000064400000022634151162147430010431 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage user_fields_map.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* User_fields_map Model
*/
class MoojlaModelUser_fields_map extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.iscv','iscv',
'g.name','juserfields',
'h.id','muserfields'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$iscv = $this->getUserStateFromRequest($this->context .
'.filter.iscv', 'filter_iscv');
if ($formSubmited)
{
$iscv = $app->input->post->get('iscv');
$this->setState('filter.iscv', $iscv);
}
$juserfields = $this->getUserStateFromRequest($this->context .
'.filter.juserfields', 'filter_juserfields');
if ($formSubmited)
{
$juserfields = $app->input->post->get('juserfields');
$this->setState('filter.juserfields', $juserfields);
}
$muserfields = $this->getUserStateFromRequest($this->context .
'.filter.muserfields', 'filter_muserfields');
if ($formSubmited)
{
$muserfields = $app->input->post->get('muserfields');
$this->setState('filter.muserfields', $muserfields);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// set selection value to a translatable value
if (MoojlaHelper::checkArray($items))
{
foreach ($items as $nr => &$item)
{
// convert iscv
$item->iscv = $this->selectionTranslation($item->iscv,
'iscv');
}
}
/***[JCBGUI.admin_view.php_getitems_after_all.134.$$$$]***/
foreach($items as $index => $it)
{
$items[$index]->juserfields_name = substr($it->juserfields,
3);
$items[$index]->muserfields_id = substr($it->muserfields, 3);
}
/***[/JCBGUI$$$$]***/
// return items
return $items;
}
/**
* Method to convert selection values to translatable string.
*
* @return translatable string
*/
public function selectionTranslation($value,$name)
{
// Array of iscv language strings
if ($name === 'iscv')
{
$iscvArray = array(
1 => 'COM_MOOJLA_USER_FIELD_MAP_YES',
0 => 'COM_MOOJLA_USER_FIELD_MAP_NO'
);
// Now check if value is found in this array
if (isset($iscvArray[$value]) &&
MoojlaHelper::checkString($iscvArray[$value]))
{
return $iscvArray[$value];
}
}
return $value;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_user_field_map',
'a'));
// From the fields table.
$query->select($db->quoteName('g.name','juserfields_name'));
$query->join('LEFT',
$db->quoteName('#__fields', 'g') . ' ON ('
. $db->quoteName('a.juserfields') . ' = ' .
$db->quoteName('g.id') . ')');
// From the moojla_user_field_map table.
$query->select($db->quoteName('h.id','muserfields_id'));
$query->join('LEFT',
$db->quoteName('#__moojla_user_field_map', 'h') .
' ON (' . $db->quoteName('a.muserfields') . ' =
' . $db->quoteName('h.id') . ')');
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.juserfields LIKE '.$search.' OR
g.name LIKE '.$search.' OR a.muserfields LIKE
'.$search.' OR h.id LIKE '.$search.')');
}
}
// Filter by Iscv.
$_iscv = $this->getState('filter.iscv');
if (is_numeric($_iscv))
{
if (is_float($_iscv))
{
$query->where('a.iscv = ' . (float) $_iscv);
}
else
{
$query->where('a.iscv = ' . (int) $_iscv);
}
}
elseif (MoojlaHelper::checkString($_iscv))
{
$query->where('a.iscv = ' .
$db->quote($db->escape($_iscv)));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.iscv');
$id .= ':' .
$this->getState('filter.juserfields');
$id .= ':' .
$this->getState('filter.muserfields');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_user_field_map'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_user_field_map'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
user_field_map.php000064400000052376151162147430010254 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage user_field_map.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla User_field_map Model
*/
class MoojlaModelUser_field_map extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'juserfields',
'muserfields',
'iscv'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.user_field_map';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'user_field_map', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.user_field_map',
'user_field_map', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.user_field_map.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/user_field_map.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.user_field_map.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.user_field_map.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.user_field_map.'. ((int) isset($data[$key]) ?
$data[$key] : 0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_user_field_map'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.user_field_map.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.user_field_map', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('user_field_map');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('user_field_map');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Only for strings
if (MoojlaHelper::checkString($this->table->juserfields)
&& !is_numeric($this->table->juserfields))
{
$this->table->juserfields =
$this->generateUnique('juserfields',$this->table->juserfields);
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('user_field_map');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
user_map.php000064400000056154151162147430007107 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage user_map.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Moojla User_map Model
*/
class MoojlaModelUser_map extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'details' => array(
'left' => array(
'debug',
'jid',
'userimage'
),
'right' => array(
'updatetype',
'mid'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MOOJLA';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_moojla.user_map';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'user_map', $prefix =
'MoojlaTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_moojla/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/***[JCBGUI.admin_view.php_model.130.$$$$]***/
public function myDelete($pk){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('rules',
'id')));
$query->from($db->quoteName('#__assets'));
$query->where($db->quoteName('name') . ' = '
. $db->quote('com_moojla'));
$db->setQuery($query);
$results = $db->loadObjectList();
$acls = json_decode($results[0]->rules);
$deleteAcl = null;
$permission = 'core.delete';
if(!property_exists($acls, $permission))
{
$acls->$permission = new stdClass();
}
$pub = '1';
$acls->$permission->$pub = 1;
$obj = new stdClass();
$obj->id = $results[0]->id;
$obj->rules = json_encode($acls);
JFactory::getDbo()->updateObject('#__assets', $obj,
'id');
$obj = new stdClass();
$obj->id = $pk;
$obj->published = -2;
JFactory::getDbo()->updateObject('#__moojla_user_map',
$obj, 'id'); // trash item
$pks = array($pk);
$res = $this->delete($pks);
$obj = new stdClass();
$obj->id = $results[0]->id;
$obj->rules = $results[0]->rules;
JFactory::getDbo()->updateObject('#__assets', $obj,
'id');
return $res;
}
/***[/JCBGUI$$$$]***/
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_moojla.user_map',
'user_map', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_moojla.user_map.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_moojla')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_moojla'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_moojla/js/user_map.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_moojla.user_map.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_moojla.user_map.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_moojla.user_map.'. ((int) isset($data[$key]) ? $data[$key] :
0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__moojla_user_map'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_moojla.edit.user_map.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_moojla.user_map', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = MoojlaHelper::getActions('user_map');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('user_map');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Only for strings
if (MoojlaHelper::checkString($this->table->jid) &&
!is_numeric($this->table->jid))
{
$this->table->jid =
$this->generateUnique('jid',$this->table->jid);
}
// insert all set values
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = MoojlaHelper::getActions('user_map');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (MoojlaHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
/***[JCBGUI.admin_view.php_before_save.130.$$$$]***/
if($data['mid'])
{
$dataObj = array(
"wsfunction" =>
"moojla_user_get_users",
"moodlewsrestformat" => "json",
"criteria" => array(
array(
'key' => 'id',
'value' => $data['mid']
)
)
);
$moodleuser =
current(json_decode(MoojlaHelper::sendRequestToMoodle($dataObj)->response));
if(is_array($moodleuser) && !empty($moodleuser))
{
$data['userimage'] =
str_replace('/pluginfile.php/',
'/auth/moojla/pluginfile_moojla.php/',
$moodleuser[0]->profileimageurl);
}
}
/***[/JCBGUI$$$$]***/
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (MoojlaHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
{
$title = StringHelper::increment($title);
}
return $title;
}
}
user_maps.php000064400000024271151162147430007265 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage user_maps.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* User_maps Model
*/
class MoojlaModelUser_maps extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.jid','jid',
'a.mid','mid'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$jid = $this->getUserStateFromRequest($this->context .
'.filter.jid', 'filter_jid');
if ($formSubmited)
{
$jid = $app->input->post->get('jid');
$this->setState('filter.jid', $jid);
}
$mid = $this->getUserStateFromRequest($this->context .
'.filter.mid', 'filter_mid');
if ($formSubmited)
{
$mid = $app->input->post->get('mid');
$this->setState('filter.mid', $mid);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
/***[JCBGUI.admin_view.php_getitems_after_all.130.$$$$]***/
foreach($items as $index => $it)
{
if($it->userimage)
{
$items[$index]->userimage = "<img
src='{$it->userimage}' width='100px'
height='100px'>";
}
}
/***[/JCBGUI$$$$]***/
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_item table
$query->from($db->quoteName('#__moojla_user_map',
'a'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) .
'%');
$query->where('(a.jid LIKE '.$search.')');
}
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get list export data.
*
* @param array $pks The ids of the items to get
* @param JUser $user The user making the request
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExportData($pks, $user = null)
{
// setup the query
if (($pks_size = MoojlaHelper::checkArray($pks)) !== false ||
'bulk' === $pks)
{
// Set a value to know this is export method. (USE IN CUSTOM CODE TO
ALTER OUTCOME)
$_export = true;
// Get the user object if not set.
if (!isset($user) || !MoojlaHelper::checkObject($user))
{
$user = JFactory::getUser();
}
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the moojla_user_map table
$query->from($db->quoteName('#__moojla_user_map',
'a'));
// The bulk export path
if ('bulk' === $pks)
{
$query->where('a.id > 0');
}
// A large array of ID's will not work out well
elseif ($pks_size > 500)
{
// Use lowest ID
$query->where('a.id >= ' . (int) min($pks));
// Use highest ID
$query->where('a.id <= ' . (int) max($pks));
}
// The normal default path
else
{
$query->where('a.id IN (' . implode(',',$pks) .
')');
}
// Order the results by ordering
$query->order('a.ordering ASC');
// Load the items
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$items = $db->loadObjectList();
// Set values to display correctly.
if (MoojlaHelper::checkArray($items))
{
foreach ($items as $nr => &$item)
{
// unset the values we don't want exported.
unset($item->asset_id);
unset($item->checked_out);
unset($item->checked_out_time);
}
}
// Add headers to items array.
$headers = $this->getExImPortHeaders();
if (MoojlaHelper::checkObject($headers))
{
array_unshift($items,$headers);
}
/***[JCBGUI.admin_view.php_getitems_after_all.130.$$$$]***/
foreach($items as $index => $it)
{
if($it->userimage)
{
$items[$index]->userimage = "<img
src='{$it->userimage}' width='100px'
height='100px'>";
}
}
/***[/JCBGUI$$$$]***/
return $items;
}
}
return false;
}
/**
* Method to get header.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExImPortHeaders()
{
// Get a db connection.
$db = JFactory::getDbo();
// get the columns
$columns = $db->getTableColumns("#__moojla_user_map");
if (MoojlaHelper::checkArray($columns))
{
// remove the headers you don't import/export.
unset($columns['asset_id']);
unset($columns['checked_out']);
unset($columns['checked_out_time']);
$headers = new stdClass();
foreach ($columns as $column => $type)
{
$headers->{$column} = $column;
}
return $headers;
}
return false;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.jid');
$id .= ':' . $this->getState('filter.mid');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_moojla')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__moojla_user_map'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__moojla_user_map'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
forms/profile.xml000064400000006756151162260460010075 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset name="user_details">
<field
name="name"
type="text"
label="COM_ADMIN_USER_HEADING_NAME"
description="COM_ADMIN_USER_FIELD_NAME_DESC"
required="true"
size="30"
/>
<field
name="username"
type="text"
label="COM_ADMIN_USER_FIELD_USERNAME_LABEL"
description="COM_ADMIN_USER_FIELD_USERNAME_DESC"
required="true"
size="30"
/>
<field
name="password2"
type="password"
label="JGLOBAL_PASSWORD"
description="COM_ADMIN_USER_FIELD_PASSWORD_DESC"
autocomplete="off"
class="validate-password"
field="password"
filter="raw"
message="COM_ADMIN_USER_FIELD_PASSWORD1_MESSAGE"
size="30"
validate="equals"
/>
<field
name="password"
type="password"
label="COM_ADMIN_USER_FIELD_PASSWORD2_LABEL"
description="COM_ADMIN_USER_FIELD_PASSWORD2_DESC"
autocomplete="off"
class="validate-password"
filter="raw"
size="30"
validate="password"
/>
<field
name="email"
type="email"
label="JGLOBAL_EMAIL"
description="COM_ADMIN_USER_FIELD_EMAIL_DESC"
class="validate-email"
required="true"
size="30"
validate="email"
validDomains="com_users.domains"
/>
<field
name="registerDate"
type="calendar"
label="COM_ADMIN_USER_FIELD_REGISTERDATE_LABEL"
description="COM_ADMIN_USER_FIELD_REGISTERDATE_DESC"
class="readonly"
readonly="true"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="lastvisitDate"
type="calendar"
label="COM_ADMIN_USER_FIELD_LASTVISIT_LABEL"
description="COM_ADMIN_USER_FIELD_LASTVISIT_DESC"
class="readonly"
readonly="true"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
class="readonly"
default="0"
readonly="true"
filter="unset"
/>
<!-- Used to get the two factor authentication configuration -->
<field
name="twofactor"
type="hidden"
/>
</fieldset>
<fields name="params">
<!-- Basic user account settings. -->
<fieldset name="settings"
label="COM_ADMIN_USER_SETTINGS_FIELDSET_LABEL">
<field
name="admin_style"
type="templatestyle"
label="COM_ADMIN_USER_FIELD_BACKEND_TEMPLATE_LABEL"
description="COM_ADMIN_USER_FIELD_BACKEND_TEMPLATE_DESC"
client="administrator"
filter="uint"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="admin_language"
type="language"
label="COM_ADMIN_USER_FIELD_BACKEND_LANGUAGE_LABEL"
description="COM_ADMIN_USER_FIELD_BACKEND_LANGUAGE_DESC"
client="administrator"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="language"
type="language"
label="COM_ADMIN_USER_FIELD_FRONTEND_LANGUAGE_LABEL"
description="COM_ADMIN_USER_FIELD_FRONTEND_LANGUAGE_DESC"
client="site"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="editor"
type="plugins"
label="COM_ADMIN_USER_FIELD_EDITOR_LABEL"
description="COM_ADMIN_USER_FIELD_EDITOR_DESC"
folder="editors"
useaccess="true"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="timezone"
type="timezone"
label="COM_ADMIN_USER_FIELD_TIMEZONE_LABEL"
description="COM_ADMIN_USER_FIELD_TIMEZONE_DESC"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
</fieldset>
</fields>
</form>
help.php000064400000007673151162260460006225 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_admin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\String\StringHelper;
/**
* Admin Component Help Model
*
* @since 1.6
*/
class AdminModelHelp extends JModelLegacy
{
/**
* The search string
*
* @var string
* @since 1.6
*/
protected $help_search = null;
/**
* The page to be viewed
*
* @var string
* @since 1.6
*/
protected $page = null;
/**
* The ISO language tag
*
* @var string
* @since 1.6
*/
protected $lang_tag = null;
/**
* Table of contents
*
* @var array
* @since 1.6
*/
protected $toc = null;
/**
* URL for the latest version check
*
* @var string
* @since 1.6
*/
protected $latest_version_check = null;
/**
* Method to get the help search string
*
* @return string Help search string
*
* @since 1.6
*/
public function &getHelpSearch()
{
if (is_null($this->help_search))
{
$this->help_search =
JFactory::getApplication()->input->getString('helpsearch');
}
return $this->help_search;
}
/**
* Method to get the page
*
* @return string The page
*
* @since 1.6
*/
public function &getPage()
{
if (is_null($this->page))
{
$this->page =
JHelp::createUrl(JFactory::getApplication()->input->get('page',
'JHELP_START_HERE'));
}
return $this->page;
}
/**
* Method to get the lang tag
*
* @return string lang iso tag
*
* @since 1.6
*/
public function getLangTag()
{
if (is_null($this->lang_tag))
{
$this->lang_tag = JFactory::getLanguage()->getTag();
if (!is_dir(JPATH_BASE . '/help/' . $this->lang_tag))
{
// Use English as fallback
$this->lang_tag = 'en-GB';
}
}
return $this->lang_tag;
}
/**
* Method to get the table of contents
*
* @return array Table of contents
*/
public function &getToc()
{
if (!is_null($this->toc))
{
return $this->toc;
}
// Get vars
$lang_tag = $this->getLangTag();
$help_search = $this->getHelpSearch();
// New style - Check for a TOC JSON file
if (file_exists(JPATH_BASE . '/help/' . $lang_tag .
'/toc.json'))
{
$data = json_decode(file_get_contents(JPATH_BASE . '/help/' .
$lang_tag . '/toc.json'));
// Loop through the data array
foreach ($data as $key => $value)
{
$this->toc[$key] = JText::_('COM_ADMIN_HELP_' . $value);
}
// Sort the Table of Contents
asort($this->toc);
return $this->toc;
}
// Get Help files
jimport('joomla.filesystem.folder');
$files = JFolder::files(JPATH_BASE . '/help/' . $lang_tag,
'\.xml$|\.html$');
$this->toc = array();
foreach ($files as $file)
{
$buffer = file_get_contents(JPATH_BASE . '/help/' . $lang_tag
. '/' . $file);
if (!preg_match('#<title>(.*?)</title>#', $buffer,
$m))
{
continue;
}
$title = trim($m[1]);
if (!$title)
{
continue;
}
// Translate the page title
$title = JText::_($title);
// Strip the extension
$file = preg_replace('#\.xml$|\.html$#', '', $file);
if ($help_search &&
StringHelper::strpos(StringHelper::strtolower(strip_tags($buffer)),
StringHelper::strtolower($help_search)) === false)
{
continue;
}
// Add an item in the Table of Contents
$this->toc[$file] = $title;
}
// Sort the Table of Contents
asort($this->toc);
return $this->toc;
}
/**
* Method to get the latest version check
*
* @return string Latest Version Check URL
*/
public function &getLatestVersionCheck()
{
if (!$this->latest_version_check)
{
$override =
'https://help.joomla.org/proxy/index.php?keyref=Help{major}{minor}:'
.
'Joomla_Version_{major}_{minor}_{maintenance}/{langcode}&lang={langcode}';
$this->latest_version_check = JHelp::createUrl('JVERSION',
false, $override);
}
return $this->latest_version_check;
}
}
profile.php000064400000016613151162260460006727 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_admin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Load the helper and model used for two factor authentication
JLoader::register('UsersModelUser', JPATH_ADMINISTRATOR .
'/components/com_users/models/user.php');
JLoader::register('UsersHelper', JPATH_ADMINISTRATOR .
'/components/com_users/helpers/users.php');
/**
* User model.
*
* @since 1.6
*/
class AdminModelProfile extends UsersModelUser
{
/**
* Method to get the record form.
*
* @param array $data An optional array of data for the form to
interrogate.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_admin.profile',
'profile', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Check for username compliance and parameter set
$isUsernameCompliant = true;
if ($this->loadFormData()->username)
{
$username = $this->loadFormData()->username;
$isUsernameCompliant =
!(preg_match('#[<>"\'%;()&\\\\]|\\.\\./#',
$username) || strlen(utf8_decode($username)) < 2
|| trim($username) != $username);
}
$this->setState('user.username.compliant',
$isUsernameCompliant);
if
(!JComponentHelper::getParams('com_users')->get('change_login_name')
&& $isUsernameCompliant)
{
$form->setFieldAttribute('username', 'required',
'false');
$form->setFieldAttribute('username', 'readonly',
'true');
$form->setFieldAttribute('username',
'description',
'COM_ADMIN_USER_FIELD_NOCHANGE_USERNAME_DESC');
}
// When multilanguage is set, a user's default site language should
also be a Content Language
if (JLanguageMultilang::isEnabled())
{
$form->setFieldAttribute('language', 'type',
'frontend_language', 'params');
}
// If the user needs to change their password, mark the password fields
as required
if (JFactory::getUser()->requireReset)
{
$form->setFieldAttribute('password', 'required',
'true');
$form->setFieldAttribute('password2', 'required',
'true');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_users.edit.user.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
// Load the users plugins.
JPluginHelper::importPlugin('user');
$this->preprocessData('com_admin.profile', $data);
return $data;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
return parent::getItem(JFactory::getUser()->id);
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$user = JFactory::getUser();
unset($data['id']);
unset($data['groups']);
unset($data['sendEmail']);
unset($data['block']);
$isUsernameCompliant =
$this->getState('user.username.compliant');
if
(!JComponentHelper::getParams('com_users')->get('change_login_name')
&& $isUsernameCompliant)
{
unset($data['username']);
}
// Handle the two factor authentication setup
if (isset($data['twofactor']['method']))
{
$twoFactorMethod = $data['twofactor']['method'];
// Get the current One Time Password (two factor auth) configuration
$otpConfig = $this->getOtpConfig($user->id);
if ($twoFactorMethod !== 'none')
{
// Run the plugins
FOFPlatform::getInstance()->importPlugin('twofactorauth');
$otpConfigReplies =
FOFPlatform::getInstance()->runPlugins('onUserTwofactorApplyConfiguration',
array($twoFactorMethod));
// Look for a valid reply
foreach ($otpConfigReplies as $reply)
{
if (!is_object($reply) || empty($reply->method) ||
($reply->method != $twoFactorMethod))
{
continue;
}
$otpConfig->method = $reply->method;
$otpConfig->config = $reply->config;
break;
}
// Save OTP configuration.
$this->setOtpConfig($user->id, $otpConfig);
// Generate one time emergency passwords if required (depleted or not
set)
if (empty($otpConfig->otep))
{
$this->generateOteps($user->id);
}
}
else
{
$otpConfig->method = 'none';
$otpConfig->config = array();
$this->setOtpConfig($user->id, $otpConfig);
}
// Unset the raw data
unset($data['twofactor']);
// Reload the user record with the updated OTP configuration
$user->load($user->id);
}
// Bind the data.
if (!$user->bind($data))
{
$this->setError($user->getError());
return false;
}
$user->groups = null;
// Store the data.
if (!$user->save())
{
$this->setError($user->getError());
return false;
}
$this->setState('user.id', $user->id);
return true;
}
/**
* Gets the configuration forms for all two-factor authentication methods
* in an array.
*
* @param integer $userId The user ID to load the forms for (optional)
*
* @return array
*
* @since __DEPOLOY_VERSION__
*/
public function getTwofactorform($userId = null)
{
$userId = (!empty($userId)) ? $userId : (int) JFactory::getUser()->id;
$model = new UsersModelUser;
return $model->getTwofactorform($userId);
}
/**
* Returns the one time password (OTP) – a.k.a. two factor
authentication –
* configuration for a particular user.
*
* @param integer $userId The numeric ID of the user
*
* @return stdClass An object holding the OTP configuration for this
user
*
* @since __DEPOLOY_VERSION__
*/
public function getOtpConfig($userId = null)
{
$userId = (!empty($userId)) ? $userId : (int) JFactory::getUser()->id;
$model = new UsersModelUser;
return $model->getOtpConfig($userId);
}
/**
* Sets the one time password (OTP) – a.k.a. two factor authentication
–
* configuration for a particular user. The $otpConfig object is the same
as
* the one returned by the getOtpConfig method.
*
* @param integer $userId The numeric ID of the user
* @param stdClass $otpConfig The OTP configuration object
*
* @return boolean True on success
*
* @since __DEPOLOY_VERSION__
*/
public function setOtpConfig($userId, $otpConfig)
{
$userId = (!empty($userId)) ? $userId : (int) JFactory::getUser()->id;
$model = new UsersModelUser;
return $model->setOtpConfig($userId, $otpConfig);
}
/**
* Generates a new set of One Time Emergency Passwords (OTEPs) for a given
user.
*
* @param integer $userId The user ID
* @param integer $count How many OTEPs to generate? Default: 10
*
* @return array The generated OTEPs
*
* @since __DEPOLOY_VERSION__
*/
public function generateOteps($userId, $count = 10)
{
$userId = (!empty($userId)) ? $userId : (int) JFactory::getUser()->id;
$model = new UsersModelUser;
return $model->generateOteps($userId, $count);
}
}
sysinfo.php000064400000041672151162260460006764 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_admin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
/**
* Model for the display of system information.
*
* @since 1.6
*/
class AdminModelSysInfo extends JModelLegacy
{
/**
* Some PHP settings
*
* @var array
* @since 1.6
*/
protected $php_settings = array();
/**
* Config values
*
* @var array
* @since 1.6
*/
protected $config = array();
/**
* Some system values
*
* @var array
* @since 1.6
*/
protected $info = array();
/**
* PHP info
*
* @var string
* @since 1.6
*/
protected $php_info = null;
/**
* Array containing the phpinfo() data.
*
* @var array
*
* @since 3.5
*/
protected $phpInfoArray;
/**
* Private/critical data that we don't want to share
*
* @var array
*
* @since 3.5
*/
protected $privateSettings = array(
'phpInfoArray' => array(
'CONTEXT_DOCUMENT_ROOT',
'Cookie',
'DOCUMENT_ROOT',
'extension_dir',
'error_log',
'Host',
'HTTP_COOKIE',
'HTTP_HOST',
'HTTP_ORIGIN',
'HTTP_REFERER',
'HTTP Request',
'include_path',
'mysql.default_socket',
'MYSQL_SOCKET',
'MYSQL_INCLUDE',
'MYSQL_LIBS',
'mysqli.default_socket',
'MYSQLI_SOCKET',
'PATH',
'Path to sendmail',
'pdo_mysql.default_socket',
'Referer',
'REMOTE_ADDR',
'SCRIPT_FILENAME',
'sendmail_path',
'SERVER_ADDR',
'SERVER_ADMIN',
'Server Administrator',
'SERVER_NAME',
'Server Root',
'session.name',
'session.save_path',
'upload_tmp_dir',
'User/Group',
'open_basedir',
),
'other' => array(
'db',
'dbprefix',
'fromname',
'live_site',
'log_path',
'mailfrom',
'memcache_server_host',
'memcached_server_host',
'open_basedir',
'Origin',
'proxy_host',
'proxy_user',
'proxy_pass',
'redis_server_host',
'redis_server_auth',
'secret',
'sendmail',
'session.save_path',
'session_memcache_server_host',
'session_memcached_server_host',
'session_redis_server_host',
'session_redis_server_auth',
'sitename',
'smtphost',
'tmp_path',
'open_basedir',
)
);
/**
* System values that can be "safely" shared
*
* @var array
*
* @since 3.5
*/
protected $safeData;
/**
* Information about writable state of directories
*
* @var array
* @since 1.6
*/
protected $directories = array();
/**
* The current editor.
*
* @var string
* @since 1.6
*/
protected $editor = null;
/**
* Remove sections of data marked as private in the privateSettings
*
* @param array $dataArray Array with data that may contain private
information
* @param string $dataType Type of data to search for a specific
section in the privateSettings array
*
* @return array
*
* @since 3.5
*/
protected function cleanPrivateData($dataArray, $dataType =
'other')
{
$dataType = isset($this->privateSettings[$dataType]) ? $dataType :
'other';
$privateSettings = $this->privateSettings[$dataType];
if (!$privateSettings)
{
return $dataArray;
}
foreach ($dataArray as $section => $values)
{
if (is_array($values))
{
$dataArray[$section] = $this->cleanPrivateData($values, $dataType);
}
if (in_array($section, $privateSettings, true))
{
$dataArray[$section] = $this->cleanSectionPrivateData($values);
}
}
return $dataArray;
}
/**
* Obfuscate section values
*
* @param mixed $sectionValues Section data
*
* @return mixed
*
* @since 3.5
*/
protected function cleanSectionPrivateData($sectionValues)
{
if (!is_array($sectionValues))
{
if (strstr($sectionValues, JPATH_ROOT))
{
$sectionValues = 'xxxxxx';
}
return strlen($sectionValues) ? 'xxxxxx' : '';
}
foreach ($sectionValues as $setting => $value)
{
$sectionValues[$setting] = strlen($value) ? 'xxxxxx' :
'';
}
return $sectionValues;
}
/**
* Method to get the PHP settings
*
* @return array Some PHP settings
*
* @since 1.6
*/
public function &getPhpSettings()
{
if (!empty($this->php_settings))
{
return $this->php_settings;
}
$this->php_settings = array(
'safe_mode' => ini_get('safe_mode') ==
'1',
'display_errors' => ini_get('display_errors')
== '1',
'short_open_tag' => ini_get('short_open_tag')
== '1',
'file_uploads' => ini_get('file_uploads')
== '1',
'magic_quotes_gpc' =>
ini_get('magic_quotes_gpc') == '1',
'register_globals' =>
ini_get('register_globals') == '1',
'output_buffering' => (int)
ini_get('output_buffering') !== 0,
'open_basedir' => ini_get('open_basedir'),
'session.save_path' =>
ini_get('session.save_path'),
'session.auto_start' =>
ini_get('session.auto_start'),
'disable_functions' =>
ini_get('disable_functions'),
'xml' => extension_loaded('xml'),
'zlib' => extension_loaded('zlib'),
'zip' =>
function_exists('zip_open') &&
function_exists('zip_read'),
'mbstring' =>
extension_loaded('mbstring'),
'iconv' => function_exists('iconv'),
'max_input_vars' =>
ini_get('max_input_vars'),
);
return $this->php_settings;
}
/**
* Method to get the config
*
* @return array config values
*
* @since 1.6
*/
public function &getConfig()
{
if (!empty($this->config))
{
return $this->config;
}
$registry = new Registry(new JConfig);
$this->config = $registry->toArray();
$hidden = array(
'host', 'user', 'password',
'ftp_user', 'ftp_pass',
'smtpuser', 'smtppass',
'redis_server_auth', 'session_redis_server_auth',
'proxy_user', 'proxy_pass', 'secret'
);
foreach ($hidden as $key)
{
$this->config[$key] = 'xxxxxx';
}
return $this->config;
}
/**
* Method to get the system information
*
* @return array System information values
*
* @since 1.6
*/
public function &getInfo()
{
if (!empty($this->info))
{
return $this->info;
}
$version = new JVersion;
$platform = new JPlatform;
$db = $this->getDbo();
$this->info = array(
'php' => php_uname(),
'dbserver' => $db->getServerType(),
'dbversion' => $db->getVersion(),
'dbcollation' => $db->getCollation(),
'dbconnectioncollation' =>
$db->getConnectionCollation(),
'phpversion' => phpversion(),
'server' =>
isset($_SERVER['SERVER_SOFTWARE']) ?
$_SERVER['SERVER_SOFTWARE'] :
getenv('SERVER_SOFTWARE'),
'sapi_name' => php_sapi_name(),
'version' => $version->getLongVersion(),
'platform' => $platform->getLongVersion(),
'useragent' =>
isset($_SERVER['HTTP_USER_AGENT']) ?
$_SERVER['HTTP_USER_AGENT'] : '',
);
return $this->info;
}
/**
* Check if the phpinfo function is enabled
*
* @return boolean True if enabled
*
* @since 3.4.1
*/
public function phpinfoEnabled()
{
return !in_array('phpinfo', explode(',',
ini_get('disable_functions')));
}
/**
* Method to get filter data from the model
*
* @param string $dataType Type of data to get safely
* @param bool $public If true no sensitive information will be
removed
*
* @return array
*
* @since 3.5
*/
public function getSafeData($dataType, $public = true)
{
if (isset($this->safeData[$dataType]))
{
return $this->safeData[$dataType];
}
$methodName = 'get' . ucfirst($dataType);
if (!method_exists($this, $methodName))
{
return array();
}
$data = $this->$methodName($public);
$this->safeData[$dataType] = $this->cleanPrivateData($data,
$dataType);
return $this->safeData[$dataType];
}
/**
* Method to get the PHP info
*
* @return string PHP info
*
* @since 1.6
*/
public function &getPHPInfo()
{
if (!$this->phpinfoEnabled())
{
$this->php_info = JText::_('COM_ADMIN_PHPINFO_DISABLED');
return $this->php_info;
}
if (!is_null($this->php_info))
{
return $this->php_info;
}
ob_start();
date_default_timezone_set('UTC');
phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES);
$phpInfo = ob_get_contents();
ob_end_clean();
preg_match_all('#<body[^>]*>(.*)</body>#siU',
$phpInfo, $output);
$output = preg_replace('#<table[^>]*>#',
'<table class="table table-striped adminlist">',
$output[1][0]);
$output = preg_replace('#(\w),(\w)#', '\1, \2',
$output);
$output = preg_replace('#<hr />#', '',
$output);
$output = str_replace('<div class="center">',
'', $output);
$output = preg_replace('#<tr
class="h">(.*)<\/tr>#', '<thead><tr
class="h">$1</tr></thead><tbody>',
$output);
$output = str_replace('</table>',
'</tbody></table>', $output);
$output = str_replace('</div>', '', $output);
$this->php_info = $output;
return $this->php_info;
}
/**
* Get phpinfo() output as array
*
* @return array
*
* @since 3.5
*/
public function getPhpInfoArray()
{
// Already cached
if (null !== $this->phpInfoArray)
{
return $this->phpInfoArray;
}
$phpInfo = $this->getPhpInfo();
$this->phpInfoArray = $this->parsePhpInfo($phpInfo);
return $this->phpInfoArray;
}
/**
* Method to get a list of installed extensions
*
* @return array installed extensions
*
* @since 3.5
*/
public function getExtensions()
{
$installed = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('*')
->from($db->qn('#__extensions'));
$db->setQuery($query);
try
{
$extensions = $db->loadObjectList();
}
catch (Exception $e)
{
try
{
JLog::add(JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED',
$e->getCode(), $e->getMessage()), JLog::WARNING, 'jerror');
}
catch (RuntimeException $exception)
{
JFactory::getApplication()->enqueueMessage(
JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED',
$e->getCode(), $e->getMessage()),
'warning'
);
}
return $installed;
}
if (empty($extensions))
{
return $installed;
}
foreach ($extensions as $extension)
{
if (strlen($extension->name) == 0)
{
continue;
}
$installed[$extension->name] = array(
'name' => $extension->name,
'type' => $extension->type,
'state' => $extension->enabled ?
JText::_('JENABLED') : JText::_('JDISABLED'),
'author' => 'unknown',
'version' => 'unknown',
'creationDate' => 'unknown',
'authorUrl' => 'unknown',
);
$manifest = new Registry($extension->manifest_cache);
$extraData = array(
'author' => $manifest->get('author',
''),
'version' => $manifest->get('version',
''),
'creationDate' =>
$manifest->get('creationDate', ''),
'authorUrl' => $manifest->get('authorUrl',
'')
);
$installed[$extension->name] =
array_merge($installed[$extension->name], $extraData);
}
return $installed;
}
/**
* Method to get the directory states
*
* @param bool $public If true no information is going to be removed
*
* @return array States of directories
*
* @since 1.6
*/
public function getDirectory($public = false)
{
if (!empty($this->directories))
{
return $this->directories;
}
$this->directories = array();
$registry = JFactory::getConfig();
$cparams = JComponentHelper::getParams('com_media');
$this->addDirectory('administrator/components',
JPATH_ADMINISTRATOR . '/components');
$this->addDirectory('administrator/language',
JPATH_ADMINISTRATOR . '/language');
// List all admin languages
$admin_langs = new DirectoryIterator(JPATH_ADMINISTRATOR .
'/language');
foreach ($admin_langs as $folder)
{
if ($folder->isDot() || !$folder->isDir())
{
continue;
}
$this->addDirectory(
'administrator/language/' . $folder->getFilename(),
JPATH_ADMINISTRATOR . '/language/' .
$folder->getFilename()
);
}
// List all manifests folders
$manifests = new DirectoryIterator(JPATH_ADMINISTRATOR .
'/manifests');
foreach ($manifests as $folder)
{
if ($folder->isDot() || !$folder->isDir())
{
continue;
}
$this->addDirectory(
'administrator/manifests/' . $folder->getFilename(),
JPATH_ADMINISTRATOR . '/manifests/' .
$folder->getFilename()
);
}
$this->addDirectory('administrator/modules',
JPATH_ADMINISTRATOR . '/modules');
$this->addDirectory('administrator/templates',
JPATH_THEMES);
$this->addDirectory('components', JPATH_SITE .
'/components');
$this->addDirectory($cparams->get('image_path'),
JPATH_SITE . '/' . $cparams->get('image_path'));
// List all images folders
$image_folders = new DirectoryIterator(JPATH_SITE . '/' .
$cparams->get('image_path'));
foreach ($image_folders as $folder)
{
if ($folder->isDot() || !$folder->isDir())
{
continue;
}
$this->addDirectory(
'images/' . $folder->getFilename(),
JPATH_SITE . '/' . $cparams->get('image_path') .
'/' . $folder->getFilename()
);
}
$this->addDirectory('language', JPATH_SITE .
'/language');
// List all site languages
$site_langs = new DirectoryIterator(JPATH_SITE . '/language');
foreach ($site_langs as $folder)
{
if ($folder->isDot() || !$folder->isDir())
{
continue;
}
$this->addDirectory('language/' .
$folder->getFilename(), JPATH_SITE . '/language/' .
$folder->getFilename());
}
$this->addDirectory('libraries', JPATH_LIBRARIES);
$this->addDirectory('media', JPATH_SITE .
'/media');
$this->addDirectory('modules', JPATH_SITE .
'/modules');
$this->addDirectory('plugins', JPATH_PLUGINS);
$plugin_groups = new DirectoryIterator(JPATH_SITE .
'/plugins');
foreach ($plugin_groups as $folder)
{
if ($folder->isDot() || !$folder->isDir())
{
continue;
}
$this->addDirectory('plugins/' . $folder->getFilename(),
JPATH_PLUGINS . '/' . $folder->getFilename());
}
$this->addDirectory('templates', JPATH_SITE .
'/templates');
$this->addDirectory('configuration.php', JPATH_CONFIGURATION
. '/configuration.php');
// Is there a cache path in configuration.php?
if ($cache_path = trim($registry->get('cache_path',
'')))
{
// Frontend and backend use same directory for caching.
$this->addDirectory($cache_path, $cache_path,
'COM_ADMIN_CACHE_DIRECTORY');
}
else
{
$this->addDirectory('cache', JPATH_SITE .
'/cache', 'COM_ADMIN_CACHE_DIRECTORY');
$this->addDirectory('administrator/cache', JPATH_CACHE,
'COM_ADMIN_CACHE_DIRECTORY');
}
if ($public)
{
$this->addDirectory(
'log',
$registry->get('log_path', JPATH_ADMINISTRATOR .
'/logs'),
'COM_ADMIN_LOG_DIRECTORY'
);
$this->addDirectory(
'tmp',
$registry->get('tmp_path', JPATH_ROOT . '/tmp'),
'COM_ADMIN_TEMP_DIRECTORY'
);
}
else
{
$this->addDirectory(
$registry->get('log_path', JPATH_ADMINISTRATOR .
'/logs'),
$registry->get('log_path', JPATH_ADMINISTRATOR .
'/logs'),
'COM_ADMIN_LOG_DIRECTORY'
);
$this->addDirectory(
$registry->get('tmp_path', JPATH_ROOT . '/tmp'),
$registry->get('tmp_path', JPATH_ROOT . '/tmp'),
'COM_ADMIN_TEMP_DIRECTORY'
);
}
return $this->directories;
}
/**
* Method to add a directory
*
* @param string $name Directory Name
* @param string $path Directory path
* @param string $message Message
*
* @return void
*
* @since 1.6
*/
private function addDirectory($name, $path, $message = '')
{
$this->directories[$name] = array('writable' =>
is_writable($path), 'message' => $message,);
}
/**
* Method to get the editor
*
* @return string The default editor
*
* @note Has to be removed (it is present in the config...)
* @since 1.6
*/
public function &getEditor()
{
if (!is_null($this->editor))
{
return $this->editor;
}
$this->editor = JFactory::getConfig()->get('editor');
return $this->editor;
}
/**
* Parse phpinfo output into an array
* Source https://gist.github.com/sbmzhcn/6255314
*
* @param string $html Output of phpinfo()
*
* @return array
*
* @since 3.5
*/
protected function parsePhpInfo($html)
{
$html = strip_tags($html, '<h2><th><td>');
$html =
preg_replace('/<th[^>]*>([^<]+)<\/th>/',
'<info>\1</info>', $html);
$html =
preg_replace('/<td[^>]*>([^<]+)<\/td>/',
'<info>\1</info>', $html);
$t = preg_split('/(<h2[^>]*>[^<]+<\/h2>)/',
$html, -1, PREG_SPLIT_DELIM_CAPTURE);
$r = array();
$count = count($t);
$p1 = '<info>([^<]+)<\/info>';
$p2 = '/' . $p1 . '\s*' . $p1 . '\s*' . $p1
. '/';
$p3 = '/' . $p1 . '\s*' . $p1 . '/';
for ($i = 1; $i < $count; $i++)
{
if (preg_match('/<h2[^>]*>([^<]+)<\/h2>/',
$t[$i], $matchs))
{
$name = trim($matchs[1]);
$vals = explode("\n", $t[$i + 1]);
foreach ($vals AS $val)
{
// 3cols
if (preg_match($p2, $val, $matchs))
{
$r[$name][trim($matchs[1])] = array(trim($matchs[2]),
trim($matchs[3]),);
}
// 2cols
elseif (preg_match($p3, $val, $matchs))
{
$r[$name][trim($matchs[1])] = trim($matchs[2]);
}
}
}
}
return $r;
}
}
fields/modulesmodule.php000064400000001716151162265220011410
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('ModulesHelper', JPATH_ADMINISTRATOR .
'/components/com_modules/helpers/modules.php');
JFormHelper::loadFieldClass('list');
/**
* Modules Module field.
*
* @since 3.4.2
*/
class JFormFieldModulesModule extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.4.2
*/
protected $type = 'ModulesModule';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.4.2
*/
public function getOptions()
{
$options =
ModulesHelper::getModules(JFactory::getApplication()->getUserState('com_modules.modules.client_id',
0));
return array_merge(parent::getOptions(), $options);
}
}
fields/modulesposition.php000064400000001726151162265220011770
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('ModulesHelper', JPATH_ADMINISTRATOR .
'/components/com_modules/helpers/modules.php');
JFormHelper::loadFieldClass('list');
/**
* Modules Position field.
*
* @since 3.4.2
*/
class JFormFieldModulesPosition extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.4.2
*/
protected $type = 'ModulesPosition';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.4.2
*/
public function getOptions()
{
$options =
ModulesHelper::getPositions(JFactory::getApplication()->getUserState('com_modules.modules.client_id',
0));
return array_merge(parent::getOptions(), $options);
}
}
forms/advanced.xml000064400000002050151162265220010160 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields name="params">
<fieldset
name="advanced">
<field
name="module_tag"
type="moduletag"
label="COM_MODULES_FIELD_MODULE_TAG_LABEL"
description="COM_MODULES_FIELD_MODULE_TAG_DESC"
default="div"
validate="options"
/>
<field
name="bootstrap_size"
type="integer"
label="COM_MODULES_FIELD_BOOTSTRAP_SIZE_LABEL"
description="COM_MODULES_FIELD_BOOTSTRAP_SIZE_DESC"
first="0"
last="12"
step="1"
/>
<field
name="header_tag"
type="headertag"
label="COM_MODULES_FIELD_HEADER_TAG_LABEL"
description="COM_MODULES_FIELD_HEADER_TAG_DESC"
default="h3"
validate="options"
/>
<field
name="header_class"
type="text"
label="COM_MODULES_FIELD_HEADER_CLASS_LABEL"
description="COM_MODULES_FIELD_HEADER_CLASS_DESC"
/>
<field
name="style"
type="chromestyle"
label="COM_MODULES_FIELD_MODULE_STYLE_LABEL"
description="COM_MODULES_FIELD_MODULE_STYLE_DESC"
/>
</fieldset>
</fields>
</form>
forms/filter_modulesadmin.xml000064400000006601151162265220012447
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_modules/models/fields"
/>
<field
name="client_id"
type="list"
label=""
filtermode="selector"
layout="default"
onchange="jQuery('#filter_position, #filter_module,
#filter_language').val('');this.form.submit();"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
</field>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_MODULES_MODULES_FILTER_SEARCH_LABEL"
description="COM_MODULES_MODULES_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
noresults="COM_MODULES_MSG_MANAGE_NO_MODULES"
/>
<field
name="state"
type="status"
label="JSTATUS"
filter="*,-2,0,1"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="position"
type="modulesposition"
label="COM_MODULES_FIELD_POSITION_LABEL"
onchange="this.form.submit();"
>
<option
value="">COM_MODULES_OPTION_SELECT_POSITION</option>
</field>
<field
name="module"
type="ModulesModule"
label="COM_MODULES_OPTION_SELECT_MODULE"
onchange="this.form.submit();"
>
<option
value="">COM_MODULES_OPTION_SELECT_MODULE</option>
</field>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_ACCESS</option>
</field>
<field
name="language"
type="language"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
client="administrator"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
statuses="*,0,1,-2"
onchange="this.form.submit();"
default="a.position ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.position
ASC">COM_MODULES_HEADING_POSITION_ASC</option>
<option value="a.position
DESC">COM_MODULES_HEADING_POSITION_DESC</option>
<option value="name
ASC">COM_MODULES_HEADING_MODULE_ASC</option>
<option value="name
DESC">COM_MODULES_HEADING_MODULE_DESC</option>
<option value="ag.title
ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="ag.title
DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="a.language ASC"
requires="adminlanguage">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="a.language DESC"
requires="adminlanguage">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_MODULES_LIST_LIMIT"
description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/moduleadmin.xml000064400000006375151162265220010727 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
default="0"
readonly="true"
/>
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="COM_MODULES_FIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="40"
maxlength="100"
required="true"
/>
<field
name="note"
type="text"
label="COM_MODULES_FIELD_NOTE_LABEL"
description="COM_MODULES_FIELD_NOTE_DESC"
maxlength="255"
size="40"
class="span12"
/>
<field
name="module"
type="hidden"
label="COM_MODULES_FIELD_MODULE_LABEL"
description="COM_MODULES_FIELD_MODULE_DESC"
readonly="readonly"
size="20"
/>
<field
name="showtitle"
type="radio"
label="COM_MODULES_FIELD_SHOWTITLE_LABEL"
description="COM_MODULES_FIELD_SHOWTITLE_DESC"
class="btn-group btn-group-yesno"
default="1"
size="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="published"
type="list"
label="JSTATUS"
description="COM_MODULES_FIELD_PUBLISHED_DESC"
class="chzn-color-state"
default="1"
size="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="publish_up"
type="calendar"
label="COM_MODULES_FIELD_PUBLISH_UP_LABEL"
description="COM_MODULES_FIELD_PUBLISH_UP_DESC"
filter="user_utc"
translateformat="true"
showtime="true"
size="22"
/>
<field
name="publish_down"
type="calendar"
label="COM_MODULES_FIELD_PUBLISH_DOWN_LABEL"
description="COM_MODULES_FIELD_PUBLISH_DOWN_DESC"
filter="user_utc"
translateformat="true"
showtime="true"
size="22"
/>
<field
name="client_id"
type="hidden"
label="COM_MODULES_FIELD_CLIENT_ID_LABEL"
description="COM_MODULES_FIELD_CLIENT_ID_DESC"
readonly="true"
size="1"
/>
<field
name="position"
type="moduleposition"
label="COM_MODULES_FIELD_POSITION_LABEL"
description="COM_MODULES_FIELD_POSITION_DESC"
default=""
maxlength="50"
/>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
size="1"
/>
<field
name="ordering"
type="moduleorder"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
linked="position"
/>
<field
name="language"
type="language"
label="JFIELD_LANGUAGE_LABEL"
description="JFIELD_MODULE_LANGUAGE_DESC"
default="*"
client="administrator"
>
<option value="*">JALL</option>
</field>
<field
name="content"
type="editor"
label="COM_MODULES_FIELD_CONTENT_LABEL"
description="COM_MODULES_FIELD_CONTENT_DESC"
buttons="true"
filter="JComponentHelper::filterText"
hide="readmore,pagebreak,module"
/>
<field name="assignment" type="hidden" />
<field name="assigned" type="hidden" />
<field name="asset_id" type="hidden"
filter="unset"
/>
<field
name="rules"
type="rules"
label="JFIELD_RULES_LABEL"
translate_label="false"
filter="rules"
component="com_modules"
section="module"
validate="rules"
/>
</fieldset>
</form>
positions.php000064400000014273151162265220007315 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Modules Component Positions Model
*
* @since 1.6
*/
class ModulesModelPositions extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'value',
'templates',
);
}
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.6
*/
protected function populateState($ordering = 'value', $direction
= 'asc')
{
$app = JFactory::getApplication('administrator');
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$state = $this->getUserStateFromRequest($this->context .
'.filter.state', 'filter_state', '',
'string');
$this->setState('filter.state', $state);
$template = $this->getUserStateFromRequest($this->context .
'.filter.template', 'filter_template', '',
'string');
$this->setState('filter.template', $template);
$type = $this->getUserStateFromRequest($this->context .
'.filter.type', 'filter_type', '',
'string');
$this->setState('filter.type', $type);
// Special case for the client id.
$clientId = (int) $this->getUserStateFromRequest($this->context .
'.client_id', 'client_id', 0, 'int');
$clientId = (!in_array((int) $clientId, array (0, 1))) ? 0 : (int)
$clientId;
$this->setState('client_id', $clientId);
// Load the parameters.
$params = JComponentHelper::getParams('com_modules');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 1.6
*/
public function getItems()
{
if (!isset($this->items))
{
$lang = JFactory::getLanguage();
$search = $this->getState('filter.search');
$state = $this->getState('filter.state');
$clientId = $this->getState('client_id');
$filter_template = $this->getState('filter.template');
$type = $this->getState('filter.type');
$ordering = $this->getState('list.ordering');
$direction = $this->getState('list.direction');
$limitstart = $this->getState('list.start');
$limit = $this->getState('list.limit');
$client = JApplicationHelper::getClientInfo($clientId);
if ($type != 'template')
{
// Get the database object and a new query object.
$query = $this->_db->getQuery(true)
->select('DISTINCT(position) as value')
->from('#__modules')
->where($this->_db->quoteName('client_id') . '
= ' . (int) $clientId);
if ($search)
{
$search = $this->_db->quote('%' . str_replace('
', '%', $this->_db->escape(trim($search), true) .
'%'));
$query->where('position LIKE ' . $search);
}
$this->_db->setQuery($query);
try
{
$positions = $this->_db->loadObjectList('value');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
foreach ($positions as $value => $position)
{
$positions[$value] = array();
}
}
else
{
$positions = array();
}
// Load the positions from the installed templates.
foreach (ModulesHelper::getTemplates($clientId) as $template)
{
$path = JPath::clean($client->path . '/templates/' .
$template->element . '/templateDetails.xml');
if (file_exists($path))
{
$xml = simplexml_load_file($path);
if (isset($xml->positions[0]))
{
$lang->load('tpl_' . $template->element .
'.sys', $client->path, null, false, true)
|| $lang->load('tpl_' . $template->element .
'.sys', $client->path . '/templates/' .
$template->element, null, false, true);
foreach ($xml->positions[0] as $position)
{
$value = (string) $position['value'];
$label = (string) $position;
if (!$value)
{
$value = $label;
$label = preg_replace('/[^a-zA-Z0-9_\-]/', '_',
'TPL_' . $template->element . '_POSITION_' .
$value);
$altlabel = preg_replace('/[^a-zA-Z0-9_\-]/',
'_', 'COM_MODULES_POSITION_' . $value);
if (!$lang->hasKey($label) &&
$lang->hasKey($altlabel))
{
$label = $altlabel;
}
}
if ($type == 'user' || ($state != '' &&
$state != $template->enabled))
{
unset($positions[$value]);
}
elseif (preg_match(chr(1) . $search . chr(1) . 'i',
$value) && ($filter_template == '' || $filter_template ==
$template->element))
{
if (!isset($positions[$value]))
{
$positions[$value] = array();
}
$positions[$value][$template->name] = $label;
}
}
}
}
}
$this->total = count($positions);
if ($limitstart >= $this->total)
{
$limitstart = $limitstart < $limit ? 0 : $limitstart - $limit;
$this->setState('list.start', $limitstart);
}
if ($ordering == 'value')
{
if ($direction == 'asc')
{
ksort($positions);
}
else
{
krsort($positions);
}
}
else
{
if ($direction == 'asc')
{
asort($positions);
}
else
{
arsort($positions);
}
}
$this->items = array_slice($positions, $limitstart, $limit ?: null);
}
return $this->items;
}
/**
* Method to get the total number of items.
*
* @return integer The total number of items.
*
* @since 1.6
*/
public function getTotal()
{
if (!isset($this->total))
{
$this->getItems();
}
return $this->total;
}
}
select.php000064400000007711151162265220006544 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Module model.
*
* @since 1.6
*/
class ModulesModelSelect extends JModelList
{
/**
* 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.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication('administrator');
// Load the filter state.
$clientId =
$app->getUserState('com_modules.modules.client_id', 0);
$this->setState('client_id', (int) $clientId);
// Load the parameters.
$params = JComponentHelper::getParams('com_modules');
$this->setState('params', $params);
// Manually set limits to get all modules.
$this->setState('list.limit', 0);
$this->setState('list.start', 0);
$this->setState('list.ordering', 'a.name');
$this->setState('list.direction', 'ASC');
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('client_id');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.extension_id, a.name, a.element AS module'
)
);
$query->from($db->quoteName('#__extensions') . ' AS
a');
// Filter by module
$query->where('a.type = ' .
$db->quote('module'));
// Filter by client.
$clientId = $this->getState('client_id');
$query->where('a.client_id = ' . (int) $clientId);
// Filter by enabled
$query->where('a.enabled = 1');
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.ordering')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Method to get a list of items.
*
* @return mixed An array of objects on success, false on failure.
*/
public function getItems()
{
// Get the list of items from the database.
$items = parent::getItems();
$client =
JApplicationHelper::getClientInfo($this->getState('client_id',
0));
$lang = JFactory::getLanguage();
// Loop through the results to add the XML metadata,
// and load language support.
foreach ($items as &$item)
{
$path = JPath::clean($client->path . '/modules/' .
$item->module . '/' . $item->module . '.xml');
if (file_exists($path))
{
$item->xml = simplexml_load_file($path);
}
else
{
$item->xml = null;
}
// 1.5 Format; Core files or language packs then
// 1.6 3PD Extension Support
$lang->load($item->module . '.sys', $client->path,
null, false, true)
|| $lang->load($item->module . '.sys', $client->path
. '/modules/' . $item->module, null, false, true);
$item->name = JText::_($item->name);
if (isset($item->xml) && $text =
trim($item->xml->description))
{
$item->desc = JText::_($text);
}
else
{
$item->desc = JText::_('COM_MODULES_NODESCRIPTION');
}
}
$items = ArrayHelper::sortObjects($items, 'name', 1, true,
true);
// TODO: Use the cached XML from the extensions table?
return $items;
}
}
contact.php000064400000031407151162335450006722 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
JLoader::register('ContactHelper', JPATH_ADMINISTRATOR .
'/components/com_contact/helpers/contact.php');
/**
* Item Model for a Contact.
*
* @since 1.6
*/
class ContactModelContact extends JModelAdmin
{
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_contact.contact';
/**
* The context used for the associations table
*
* @var string
* @since 3.4.4
*/
protected $associationsContext = 'com_contact.item';
/**
* Batch copy/move command. If set to false, the batch copy/move command
is not supported
*
* @var string
*/
protected $batch_copymove = 'category_id';
/**
* Allowed batch commands
*
* @var array
*/
protected $batch_commands = array(
'assetgroup_id' => 'batchAccess',
'language_id' => 'batchLanguage',
'tag' => 'batchTag',
'user_id' => 'batchUser',
);
/**
* Batch change a linked user.
*
* @param integer $value The new value matching a User ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 2.5
*/
protected function batchUser($value, $pks, $contexts)
{
foreach ($pks as $pk)
{
if ($this->user->authorise('core.edit', $contexts[$pk]))
{
$this->table->reset();
$this->table->load($pk);
$this->table->user_id = (int) $value;
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (empty($record->id) || $record->published != -2)
{
return false;
}
return JFactory::getUser()->authorise('core.delete',
'com_contact.category.' . (int) $record->catid);
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
// Check against the category.
if (!empty($record->catid))
{
return JFactory::getUser()->authorise('core.edit.state',
'com_contact.category.' . (int) $record->catid);
}
// Default to component settings if category not known.
return parent::canEditState($record);
}
/**
* Returns a Table object, always creating it
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Contact', $prefix =
'ContactTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get the row form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm|boolean A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
JForm::addFieldPath(JPATH_ADMINISTRATOR .
'/components/com_users/models/fields');
// Get the form.
$form = $this->loadForm('com_contact.contact',
'contact', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Modify the form based on access controls.
if (!$this->canEditState((object) $data))
{
// Disable fields for display.
$form->setFieldAttribute('featured', 'disabled',
'true');
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('featured', 'filter',
'unset');
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
return $form;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
// Convert the metadata field to an array.
$registry = new Registry($item->metadata);
$item->metadata = $registry->toArray();
}
// Load associated contact items
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$item->associations = array();
if ($item->id != null)
{
$associations =
JLanguageAssociations::getAssociations('com_contact',
'#__contact_details', 'com_contact.item',
$item->id);
foreach ($associations as $tag => $association)
{
$item->associations[$tag] = $association->id;
}
}
}
// Load item tags
if (!empty($item->id))
{
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id,
'com_contact.contact');
}
return $item;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
$app = JFactory::getApplication();
// Check the session for previously entered form data.
$data = $app->getUserState('com_contact.edit.contact.data',
array());
if (empty($data))
{
$data = $this->getItem();
// Prime some default values.
if ($this->getState('contact.id') == 0)
{
$data->set('catid',
$app->input->get('catid',
$app->getUserState('com_contact.contacts.filter.category_id'),
'int'));
}
}
$this->preprocessData('com_contact.contact', $data);
return $data;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 3.0
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR .
'/components/com_categories/helpers/categories.php');
// Create new category, if needed.
$createCategory = true;
// If category ID is provided, check if it's valid.
if (is_numeric($data['catid']) &&
$data['catid'])
{
$createCategory =
!CategoriesHelper::validateCategoryId($data['catid'],
'com_contact');
}
// Save New Category
if ($createCategory && $this->canCreateCategory())
{
$table = array();
// Remove #new# prefix, if exists.
$table['title'] = strpos($data['catid'],
'#new#') === 0 ? substr($data['catid'], 5) :
$data['catid'];
$table['parent_id'] = 1;
$table['extension'] = 'com_contact';
$table['language'] = $data['language'];
$table['published'] = 1;
// Create new category and get catid back
$data['catid'] = CategoriesHelper::createCategory($table);
}
// Alter the name for save as copy
if ($input->get('task') == 'save2copy')
{
$origTable = clone $this->getTable();
$origTable->load($input->getInt('id'));
if ($data['name'] == $origTable->name)
{
list($name, $alias) =
$this->generateNewTitle($data['catid'],
$data['alias'], $data['name']);
$data['name'] = $name;
$data['alias'] = $alias;
}
else
{
if ($data['alias'] == $origTable->alias)
{
$data['alias'] = '';
}
}
$data['published'] = 0;
}
$links = array('linka', 'linkb', 'linkc',
'linkd', 'linke');
foreach ($links as $link)
{
if ($data['params'][$link])
{
$data['params'][$link] =
JStringPunycode::urlToPunycode($data['params'][$link]);
}
}
return parent::save($data);
}
/**
* Prepare and sanitise the table prior to saving.
*
* @param JTable $table The JTable object
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate()->toSql();
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
$table->generateAlias();
if (empty($table->id))
{
// Set the values
$table->created = $date;
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__contact_details'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
// Set the values
$table->modified = $date;
$table->modified_by = JFactory::getUser()->id;
}
// Increment the content version number.
$table->version++;
}
/**
* A protected method to get a set of ordering conditions.
*
* @param JTable $table A record object.
*
* @return array An array of conditions to add to add to ordering
queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
return array('catid = ' . (int) $table->catid);
}
/**
* Preprocess the form.
*
* @param JForm $form Form object.
* @param object $data Data object.
* @param string $group Group name.
*
* @return void
*
* @since 3.0.3
*/
protected function preprocessForm(JForm $form, $data, $group =
'content')
{
// Determine correct permissions to check.
if ($this->getState('contact.id'))
{
// Existing record. Can only edit in selected categories.
$form->setFieldAttribute('catid', 'action',
'core.edit');
}
else
{
// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action',
'core.create');
}
if ($this->canCreateCategory())
{
$form->setFieldAttribute('catid', 'allowAdd',
'true');
// Add a prefix for categories created on the fly.
$form->setFieldAttribute('catid', 'customPrefix',
'#new#');
}
// Association contact items
if (JLanguageAssociations::isEnabled())
{
$languages = JLanguageHelper::getContentLanguages(false, true, null,
'ordering', 'asc');
if (count($languages) > 1)
{
$addform = new SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name',
'item_associations');
foreach ($languages as $language)
{
$field = $fieldset->addChild('field');
$field->addAttribute('name', $language->lang_code);
$field->addAttribute('type', 'modal_contact');
$field->addAttribute('language',
$language->lang_code);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label',
'false');
$field->addAttribute('select', 'true');
$field->addAttribute('new', 'true');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
$field->addAttribute('propagate', 'true');
}
$form->load($addform, false);
}
}
parent::preprocessForm($form, $data, $group);
}
/**
* Method to toggle the featured setting of contacts.
*
* @param array $pks The ids of the items to toggle.
* @param integer $value The value to toggle to.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function featured($pks, $value = 0)
{
// Sanitize the ids.
$pks = ArrayHelper::toInteger((array) $pks);
if (empty($pks))
{
$this->setError(JText::_('COM_CONTACT_NO_ITEM_SELECTED'));
return false;
}
$table = $this->getTable();
try
{
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->update('#__contact_details');
$query->set('featured = ' . (int) $value);
$query->where('id IN (' . implode(',', $pks) .
')');
$db->setQuery($query);
$db->execute();
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
$table->reorder();
// Clean component's cache
$this->cleanCache();
return true;
}
/**
* Is the user allowed to create an on the fly category?
*
* @return boolean
*
* @since 3.6.1
*/
private function canCreateCategory()
{
return JFactory::getUser()->authorise('core.create',
'com_contact');
}
}
contacts.php000064400000023740151162335450007106 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Methods supporting a list of contact records.
*
* @since 1.6
*/
class ContactModelContacts extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'name', 'a.name',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'catid', 'a.catid', 'category_id',
'category_title',
'user_id', 'a.user_id',
'published', 'a.published',
'access', 'a.access', 'access_level',
'created', 'a.created',
'created_by', 'a.created_by',
'ordering', 'a.ordering',
'featured', 'a.featured',
'language', 'a.language',
'language_title',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'ul.name', 'linked_user',
'tag',
'level', 'c.level',
);
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$config['filter_fields'][] = 'association';
}
}
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.6
*/
protected function populateState($ordering = 'a.name',
$direction = 'asc')
{
$app = JFactory::getApplication();
$forcedLanguage = $app->input->get('forcedLanguage',
'', 'cmd');
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Adjust the context to support forced languages.
if ($forcedLanguage)
{
$this->context .= '.' . $forcedLanguage;
}
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.published',
$this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '',
'string'));
$this->setState('filter.category_id',
$this->getUserStateFromRequest($this->context .
'.filter.category_id', 'filter_category_id',
'', 'string')
);
$this->setState('filter.access',
$this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', '',
'cmd'));
$this->setState('filter.language',
$this->getUserStateFromRequest($this->context .
'.filter.language', 'filter_language', '',
'string'));
$this->setState('filter.tag',
$this->getUserStateFromRequest($this->context .
'.filter.tag', 'filter_tag', '',
'string'));
$this->setState('filter.level',
$this->getUserStateFromRequest($this->context .
'.filter.level', 'filter_level', null,
'int'));
// List state information.
parent::populateState($ordering, $direction);
// Force a language.
if (!empty($forcedLanguage))
{
$this->setState('filter.language', $forcedLanguage);
}
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' .
serialize($this->getState('filter.category_id'));
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.language');
$id .= ':' . $this->getState('filter.tag');
$id .= ':' . $this->getState('filter.level');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select(
$db->quoteName(
explode(', ', $this->getState(
'list.select',
'a.id, a.name, a.alias, a.checked_out, a.checked_out_time,
a.catid, a.user_id' .
', a.published, a.access, a.created, a.created_by, a.ordering,
a.featured, a.language' .
', a.publish_up, a.publish_down'
)
)
)
);
$query->from($db->quoteName('#__contact_details',
'a'));
// Join over the users for the linked user.
$query->select(
array(
$db->quoteName('ul.name', 'linked_user'),
$db->quoteName('ul.email')
)
)
->join(
'LEFT',
$db->quoteName('#__users', 'ul') . ' ON
' . $db->quoteName('ul.id') . ' = ' .
$db->quoteName('a.user_id')
);
// Join over the language
$query->select($db->quoteName('l.title',
'language_title'))
->select($db->quoteName('l.image',
'language_image'))
->join(
'LEFT',
$db->quoteName('#__languages', 'l') . ' ON
' . $db->quoteName('l.lang_code') . ' = ' .
$db->quoteName('a.language')
);
// Join over the users for the checked out user.
$query->select($db->quoteName('uc.name',
'editor'))
->join(
'LEFT',
$db->quoteName('#__users', 'uc') . ' ON
' . $db->quoteName('uc.id') . ' = ' .
$db->quoteName('a.checked_out')
);
// Join over the asset groups.
$query->select($db->quoteName('ag.title',
'access_level'))
->join(
'LEFT',
$db->quoteName('#__viewlevels', 'ag') . '
ON ' . $db->quoteName('ag.id') . ' = ' .
$db->quoteName('a.access')
);
// Join over the categories.
$query->select($db->quoteName('c.title',
'category_title'))
->join(
'LEFT',
$db->quoteName('#__categories', 'c') . ' ON
' . $db->quoteName('c.id') . ' = ' .
$db->quoteName('a.catid')
);
// Join over the associations.
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$subQuery = $db->getQuery(true)
->select('COUNT(' .
$db->quoteName('asso1.id') . ') > 1')
->from($db->quoteName('#__associations',
'asso1'))
->join('INNER',
$db->quoteName('#__associations', 'asso2') . '
ON ' . $db->quoteName('asso1.key') . ' = ' .
$db->quoteName('asso2.key'))
->where(
array(
$db->quoteName('asso1.id') . ' = ' .
$db->quoteName('a.id'),
$db->quoteName('asso1.context') . ' = ' .
$db->quote('com_contact.item'),
)
);
$query->select('(' . $subQuery . ') AS ' .
$db->quoteName('association'));
}
// Filter by access level.
if ($access = $this->getState('filter.access'))
{
$query->where($db->quoteName('a.access') . ' =
' . (int) $access);
}
// Implement View Level Access
if (!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where($db->quoteName('a.access') . ' IN
(' . $groups . ')');
}
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where($db->quoteName('a.published') . ' =
' . (int) $published);
}
elseif ($published === '')
{
$query->where('(' .
$db->quoteName('a.published') . ' = 0 OR ' .
$db->quoteName('a.published') . ' = 1)');
}
// Filter by search in name.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where(
'(' . $db->quoteName('a.name') . ' LIKE
' . $search . ' OR ' .
$db->quoteName('a.alias') . ' LIKE ' . $search .
')'
);
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$query->where($db->quoteName('a.language') . ' =
' . $db->quote($language));
}
// Filter by a single tag.
$tagId = $this->getState('filter.tag');
if (is_numeric($tagId))
{
$query->where($db->quoteName('tagmap.tag_id') . ' =
' . (int) $tagId)
->join(
'LEFT',
$db->quoteName('#__contentitem_tag_map',
'tagmap')
. ' ON ' .
$db->quoteName('tagmap.content_item_id') . ' = ' .
$db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias')
. ' = ' . $db->quote('com_contact.contact')
);
}
// Filter by categories and by level
$categoryId = $this->getState('filter.category_id',
array());
$level = $this->getState('filter.level');
if (!is_array($categoryId))
{
$categoryId = $categoryId ? array($categoryId) : array();
}
// Case: Using both categories filter and by level filter
if (count($categoryId))
{
$categoryId = ArrayHelper::toInteger($categoryId);
$categoryTable = JTable::getInstance('Category',
'JTable');
$subCatItemsWhere = array();
foreach ($categoryId as $filter_catid)
{
$categoryTable->load($filter_catid);
$subCatItemsWhere[] = '(' .
($level ? 'c.level <= ' . ((int) $level + (int)
$categoryTable->level - 1) . ' AND ' : '') .
'c.lft >= ' . (int) $categoryTable->lft . ' AND
' .
'c.rgt <= ' . (int) $categoryTable->rgt .
')';
}
$query->where('(' . implode(' OR ',
$subCatItemsWhere) . ')');
}
// Case: Using only the by level filter
elseif ($level)
{
$query->where('c.level <= ' . (int) $level);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.name');
$orderDirn = $this->state->get('list.direction',
'asc');
if ($orderCol == 'a.ordering' || $orderCol ==
'category_title')
{
$orderCol = $db->quoteName('c.title') . ' ' .
$orderDirn . ', ' . $db->quoteName('a.ordering');
}
$query->order($db->escape($orderCol . ' ' . $orderDirn));
return $query;
}
}
fields/modal/contact.php000064400000023403151162335450011261
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\LanguageHelper;
/**
* Supports a modal contact picker.
*
* @since 1.6
*/
class JFormFieldModal_Contact extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Modal_Contact';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$allowNew = ((string) $this->element['new'] ==
'true');
$allowEdit = ((string) $this->element['edit'] ==
'true');
$allowClear = ((string) $this->element['clear'] !=
'false');
$allowSelect = ((string) $this->element['select'] !=
'false');
$allowPropagate = ((string) $this->element['propagate'] ==
'true');
$languages = LanguageHelper::getContentLanguages(array(0, 1));
// Load language
JFactory::getLanguage()->load('com_contact',
JPATH_ADMINISTRATOR);
// The active contact id field.
$value = (int) $this->value > 0 ? (int) $this->value :
'';
// Create the modal id.
$modalId = 'Contact_' . $this->id;
// Add the modal field script to the document head.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/modal-fields.js',
array('version' => 'auto', 'relative'
=> true));
// Script to proxy the select modal function to the modal-fields.js file.
if ($allowSelect)
{
static $scriptSelect = null;
if (is_null($scriptSelect))
{
$scriptSelect = array();
}
if (!isset($scriptSelect[$this->id]))
{
JFactory::getDocument()->addScriptDeclaration("
function jSelectContact_" . $this->id . "(id, title,
object) {
window.processModalSelect('Contact', '" .
$this->id . "', id, title, '', object);
}
");
JText::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
$scriptSelect[$this->id] = true;
}
}
// Setup variables for display.
$linkContacts =
'index.php?option=com_contact&view=contacts&layout=modal&tmpl=component&'
. JSession::getFormToken() . '=1';
$linkContact =
'index.php?option=com_contact&view=contact&layout=modal&tmpl=component&'
. JSession::getFormToken() . '=1';
$modalTitle = JText::_('COM_CONTACT_CHANGE_CONTACT');
if (isset($this->element['language']))
{
$linkContacts .= '&forcedLanguage=' .
$this->element['language'];
$linkContact .= '&forcedLanguage=' .
$this->element['language'];
$modalTitle .= ' — ' .
$this->element['label'];
}
$urlSelect = $linkContacts .
'&function=jSelectContact_' . $this->id;
$urlEdit = $linkContact .
'&task=contact.edit&id=\' +
document.getElementById("' . $this->id .
'_id").value + \'';
$urlNew = $linkContact . '&task=contact.add';
if ($value)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('name'))
->from($db->quoteName('#__contact_details'))
->where($db->quoteName('id') . ' = ' . (int)
$value);
$db->setQuery($query);
try
{
$title = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
}
$title = empty($title) ?
JText::_('COM_CONTACT_SELECT_A_CONTACT') :
htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// The current contact display field.
$html = '<span class="input-append">';
$html .= '<input class="input-medium" id="' .
$this->id . '_name" type="text" value="' .
$title . '" disabled="disabled" size="35"
/>';
// Select contact button
if ($allowSelect)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? '
hidden' : '') . '"'
. ' id="' . $this->id . '_select"'
. ' data-toggle="modal"'
. ' data-target="#ModalSelect' . $modalId .
'"'
. ' title="' .
JHtml::tooltipText('COM_CONTACT_CHANGE_CONTACT') .
'">'
. '<span class="icon-file"
aria-hidden="true"></span> ' .
JText::_('JSELECT')
. '</button>';
}
// New contact button
if ($allowNew)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? '
hidden' : '') . '"'
. ' id="' . $this->id . '_new"'
. ' data-toggle="modal"'
. ' data-target="#ModalNew' . $modalId .
'"'
. ' title="' .
JHtml::tooltipText('COM_CONTACT_NEW_CONTACT') .
'">'
. '<span class="icon-new"
aria-hidden="true"></span> ' .
JText::_('JACTION_CREATE')
. '</button>';
}
// Edit contact button
if ($allowEdit)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? '' :
' hidden') . '"'
. ' id="' . $this->id . '_edit"'
. ' data-toggle="modal"'
. ' data-target="#ModalEdit' . $modalId .
'"'
. ' title="' .
JHtml::tooltipText('COM_CONTACT_EDIT_CONTACT') .
'">'
. '<span class="icon-edit"
aria-hidden="true"></span> ' .
JText::_('JACTION_EDIT')
. '</button>';
}
// Clear contact button
if ($allowClear)
{
$html .= '<button'
. ' type="button"'
. ' class="btn' . ($value ? '' : '
hidden') . '"'
. ' id="' . $this->id . '_clear"'
. ' onclick="window.processModalParent(\'' .
$this->id . '\'); return false;">'
. '<span class="icon-remove"
aria-hidden="true"></span>' .
JText::_('JCLEAR')
. '</button>';
}
// Propagate contact button
if ($allowPropagate && count($languages) > 2)
{
// Strip off language tag at the end
$tagLength = (int) strlen($this->element['language']);
$callbackFunctionStem = substr("jSelectContact_" .
$this->id, 0, -$tagLength);
$html .= '<a'
. ' class="btn hasTooltip' . ($value ? '' :
' hidden') . '"'
. ' id="' . $this->id . '_propagate"'
. ' href="#"'
. ' title="' .
JHtml::tooltipText('JGLOBAL_ASSOCIATIONS_PROPAGATE_TIP') .
'"'
. ' onclick="Joomla.propagateAssociation(\'' .
$this->id . '\', \'' . $callbackFunctionStem .
'\');">'
. '<span class="icon-refresh"
aria-hidden="true"></span>' .
JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_BUTTON')
. '</a>';
}
$html .= '</span>';
// Select contact modal
if ($allowSelect)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalSelect' . $modalId,
array(
'title' => $modalTitle,
'url' => $urlSelect,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button"
class="btn" data-dismiss="modal">' .
JText::_('JLIB_HTML_BEHAVIOR_CLOSE') .
'</button>',
)
);
}
// New contact modal
if ($allowNew)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalNew' . $modalId,
array(
'title' =>
JText::_('COM_CONTACT_NEW_CONTACT'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlNew,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button"
class="btn"'
. ' onclick="window.processModalEdit(this, \''
. $this->id . '\', \'add\',
\'contact\', \'cancel\', \'contact-form\',
\'jform_id\', \'jform_name\'); return
false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') .
'</button>'
. '<button type="button" class="btn
btn-primary"'
. ' onclick="window.processModalEdit(this, \''
. $this->id . '\', \'add\',
\'contact\', \'save\', \'contact-form\',
\'jform_id\', \'jform_name\'); return
false;">'
. JText::_('JSAVE') . '</button>'
. '<button type="button" class="btn
btn-success"'
. ' onclick="window.processModalEdit(this, \''
. $this->id . '\', \'add\',
\'contact\', \'apply\', \'contact-form\',
\'jform_id\', \'jform_name\'); return
false;">'
. JText::_('JAPPLY') . '</button>',
)
);
}
// Edit contact modal.
if ($allowEdit)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalEdit' . $modalId,
array(
'title' =>
JText::_('COM_CONTACT_EDIT_CONTACT'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlEdit,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button"
class="btn"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id
. '\', \'edit\', \'contact\',
\'cancel\', \'contact-form\', \'jform_id\',
\'jform_name\'); return false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') .
'</button>'
. '<button type="button" class="btn
btn-primary"'
. ' onclick="window.processModalEdit(this, \''
. $this->id . '\', \'edit\',
\'contact\', \'save\', \'contact-form\',
\'jform_id\', \'jform_name\'); return
false;">'
. JText::_('JSAVE') . '</button>'
. '<button type="button" class="btn
btn-success"'
. ' onclick="window.processModalEdit(this, \''
. $this->id . '\', \'edit\',
\'contact\', \'apply\', \'contact-form\',
\'jform_id\', \'jform_name\'); return
false;">'
. JText::_('JAPPLY') . '</button>',
)
);
}
// Note: class='required' for client side validation.
$class = $this->required ? ' class="required
modal-value"' : '';
$html .= '<input type="hidden" id="' .
$this->id . '_id"' . $class . '
data-required="' . (int) $this->required . '"
name="' . $this->name
. '" data-text="' .
htmlspecialchars(JText::_('COM_CONTACT_SELECT_A_CONTACT', true),
ENT_COMPAT, 'UTF-8') . '" value="' . $value .
'" />';
return $html;
}
/**
* Method to get the field label markup.
*
* @return string The field label markup.
*
* @since 3.4
*/
protected function getLabel()
{
return str_replace($this->id, $this->id . '_id',
parent::getLabel());
}
}
forms/contact.xml000064400000053200151162335450010054 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_categories/models/fields">
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
default="0"
class="readonly"
size="10"
readonly="true"
/>
<field
name="name"
type="text"
label="COM_CONTACT_FIELD_NAME_LABEL"
description="COM_CONTACT_FIELD_NAME_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
size="45"
hint="JFIELD_ALIAS_PLACEHOLDER"
/>
<field
name="version_note"
type="text"
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
description="JGLOBAL_FIELD_VERSION_NOTE_DESC"
labelclass="control-label"
class="span12"
size="45"
maxlength="255"
/>
<field
name="user_id"
type="user"
label="COM_CONTACT_FIELD_LINKED_USER_LABEL"
description="COM_CONTACT_FIELD_LINKED_USER_DESC"
/>
<field
name="published"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
default="1"
id="published"
class="chzn-color-state"
size="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="catid"
type="categoryedit"
label="JCATEGORY"
description="JFIELD_CATEGORY_DESC"
extension="com_contact"
required="true"
default=""
/>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
size="1"
/>
<field
name="misc"
type="editor"
label="COM_CONTACT_FIELD_INFORMATION_MISC_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_MISC_DESC"
filter="JComponentHelper::filterText"
buttons="true"
hide="readmore,pagebreak"
/>
<field
name="created_by"
type="user"
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
description="COM_CONTACT_FIELD_CREATED_BY_DESC"
/>
<field
name="created_by_alias"
type="text"
label="COM_CONTACT_FIELD_CREATED_BY_ALIAS_LABEL"
description="COM_CONTACT_FIELD_CREATED_BY_ALIAS_DESC"
size="20"
/>
<field
name="created"
type="calendar"
label="COM_CONTACT_FIELD_CREATED_LABEL"
description="COM_CONTACT_FIELD_CREATED_DESC"
size="22"
translateformat="true"
showtime="true"
filter="user_utc"
/>
<field
name="modified"
type="calendar"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
description="COM_CONTACT_FIELD_MODIFIED_DESC"
class="readonly"
size="22"
readonly="true"
translateformat="true"
showtime="true"
filter="user_utc"
/>
<field
name="modified_by"
type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
description="COM_CONTACT_FIELD_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="ordering"
type="ordering"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
content_type="com_contact.contact"
/>
<field
name="publish_up"
type="calendar"
label="COM_CONTACT_FIELD_PUBLISH_UP_LABEL"
description="COM_CONTACT_FIELD_PUBLISH_UP_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="publish_down"
type="calendar"
label="COM_CONTACT_FIELD_PUBLISH_DOWN_LABEL"
description="COM_CONTACT_FIELD_PUBLISH_DOWN_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="metakey"
type="textarea"
label="JFIELD_META_KEYWORDS_LABEL"
description="JFIELD_META_KEYWORDS_DESC"
rows="3"
cols="30"
/>
<field
name="metadesc"
type="textarea"
label="JFIELD_META_DESCRIPTION_LABEL"
description="JFIELD_META_DESCRIPTION_DESC"
rows="3"
cols="30"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_CONTACT_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
<field
name="featured"
type="radio"
label="JFEATURED"
description="COM_CONTACT_FIELD_FEATURED_DESC"
default="0"
class="btn-group btn-group-yesno"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="tags"
type="tag"
label="JTAG"
description="JTAG_DESC"
class="span12"
multiple="true"
/>
<field
name="contact_icons"
type="list"
label="COM_CONTACT_FIELD_ICONS_SETTINGS"
description="COM_CONTACT_FIELD_ICONS_SETTINGS_DESC"
default="0"
>
<option
value="0">COM_CONTACT_FIELD_VALUE_NONE</option>
<option
value="1">COM_CONTACT_FIELD_VALUE_TEXT</option>
<option
value="2">COM_CONTACT_FIELD_VALUE_ICONS</option>
</field>
<field
name="icon_address"
type="media"
label="COM_CONTACT_FIELD_ICONS_ADDRESS_LABEL"
description="COM_CONTACT_FIELD_ICONS_ADDRESS_DESC"
hide_none="1"
/>
<field
name="icon_email"
type="media"
label="COM_CONTACT_FIELD_ICONS_EMAIL_LABEL"
description="COM_CONTACT_FIELD_ICONS_EMAIL_DESC"
hide_none="1"
/>
<field
name="icon_telephone"
type="media"
label="COM_CONTACT_FIELD_ICONS_TELEPHONE_LABEL"
description="COM_CONTACT_FIELD_ICONS_TELEPHONE_DESC"
hide_none="1"
/>
<field
name="icon_mobile"
type="media"
label="COM_CONTACT_FIELD_ICONS_MOBILE_LABEL"
description="COM_CONTACT_FIELD_ICONS_MOBILE_DESC"
hide_none="1"
/>
<field
name="icon_fax"
type="media"
label="COM_CONTACT_FIELD_ICONS_FAX_LABEL"
description="COM_CONTACT_FIELD_ICONS_FAX_DESC"
hide_none="1"
/>
<field
name="icon_misc"
type="media"
label="COM_CONTACT_FIELD_ICONS_MISC_LABEL"
description="COM_CONTACT_FIELD_ICONS_MISC_DESC"
hide_none="1"
/>
</fieldset>
<fieldset name="details"
label="COM_CONTACT_CONTACT_DETAILS">
<field
name="image"
type="media"
label="COM_CONTACT_FIELD_PARAMS_IMAGE_LABEL"
description="COM_CONTACT_FIELD_PARAMS_IMAGE_DESC"
hide_none="1"
/>
<field
name="con_position"
type="text"
label="COM_CONTACT_FIELD_INFORMATION_POSITION_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_POSITION_DESC"
size="30"
/>
<field
name="email_to"
type="email"
label="JGLOBAL_EMAIL"
description="COM_CONTACT_FIELD_INFORMATION_EMAIL_DESC"
size="30"
/>
<field
name="address"
type="textarea"
label="COM_CONTACT_FIELD_INFORMATION_ADDRESS_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_ADDRESS_DESC"
rows="3"
cols="30"
/>
<field
name="suburb"
type="text"
label="COM_CONTACT_FIELD_INFORMATION_SUBURB_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_SUBURB_DESC"
size="30"
/>
<field
name="state"
type="text"
label="COM_CONTACT_FIELD_INFORMATION_STATE_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_STATE_DESC"
size="30"
/>
<field
name="postcode"
type="text"
label="COM_CONTACT_FIELD_INFORMATION_POSTCODE_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_POSTCODE_DESC"
size="30"
/>
<field
name="country"
type="text"
label="COM_CONTACT_FIELD_INFORMATION_COUNTRY_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_COUNTRY_DESC"
size="30"
/>
<field
name="telephone"
type="text"
label="COM_CONTACT_FIELD_INFORMATION_TELEPHONE_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_TELEPHONE_DESC"
size="30"
/>
<field
name="mobile"
type="text"
label="COM_CONTACT_FIELD_INFORMATION_MOBILE_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_MOBILE_DESC"
size="30"
/>
<field
name="fax"
type="text"
label="COM_CONTACT_FIELD_INFORMATION_FAX_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_FAX_DESC"
size="30"
/>
<field
name="webpage"
type="url"
label="COM_CONTACT_FIELD_INFORMATION_WEBPAGE_LABEL"
description="COM_CONTACT_FIELD_INFORMATION_WEBPAGE_DESC"
size="30"
filter="url"
validate="url"
/>
<field
name="sortname1"
type="text"
label="COM_CONTACT_FIELD_SORTNAME1_LABEL"
description="COM_CONTACT_FIELD_SORTNAME1_DESC"
size="30"
/>
<field
name="sortname2"
type="text"
label="COM_CONTACT_FIELD_SORTNAME2_LABEL"
description="COM_CONTACT_FIELD_SORTNAME2_DESC"
size="30"
/>
<field
name="sortname3"
type="text"
label="COM_CONTACT_FIELD_SORTNAME3_LABEL"
description="COM_CONTACT_FIELD_SORTNAME3_DESC"
size="30"
/>
</fieldset>
<fields name="params"
label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS">
<fieldset name="display"
label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS"
addfieldpath="/administrator/components/com_fields/models/fields">
<field
name="show_contact_category"
type="list"
label="JGLOBAL_SHOW_CATEGORY_LABEL"
description="COM_CONTACT_FIELD_SHOW_CATEGORY_DESC"
class="chzn-color"
useglobal="true"
>
<option value="hide">JHIDE</option>
<option
value="show_no_link">COM_CONTACT_FIELD_VALUE_NO_LINK</option>
<option
value="show_with_link">COM_CONTACT_FIELD_VALUE_WITH_LINK</option>
</field>
<field
name="show_contact_list"
type="list"
label="COM_CONTACT_FIELD_CONTACT_SHOW_LIST_LABEL"
description="COM_CONTACT_FIELD_CONTACT_SHOW_LIST_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="presentation_style"
type="list"
label="COM_CONTACT_FIELD_PRESENTATION_LABEL"
description="COM_CONTACT_FIELD_PRESENTATION_DESC"
useglobal="true"
>
<option
value="sliders">COM_CONTACT_FIELD_VALUE_SLIDERS</option>
<option
value="tabs">COM_CONTACT_FIELD_VALUE_TABS</option>
<option
value="plain">COM_CONTACT_FIELD_VALUE_PLAIN</option>
</field>
<field
name="show_tags"
type="list"
label="COM_CONTACT_FIELD_SHOW_TAGS_LABEL"
description="COM_CONTACT_FIELD_SHOW_TAGS_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_info"
type="list"
label="COM_CONTACT_FIELD_SHOW_INFO_LABEL"
description="COM_CONTACT_FIELD_SHOW_INFO_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_name"
type="list"
label="COM_CONTACT_FIELD_PARAMS_NAME_LABEL"
description="COM_CONTACT_FIELD_PARAMS_NAME_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_position"
type="list"
label="COM_CONTACT_FIELD_PARAMS_CONTACT_POSITION_LABEL"
description="COM_CONTACT_FIELD_PARAMS_CONTACT_POSITION_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_email"
type="list"
label="JGLOBAL_EMAIL"
description="COM_CONTACT_FIELD_PARAMS_CONTACT_E_MAIL_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="add_mailto_link"
type="list"
label="COM_CONTACT_FIELD_PARAMS_ADD_MAILTO_LINK_LABEL"
description="COM_CONTACT_FIELD_PARAMS_ADD_MAILTO_LINK_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="show_street_address"
type="list"
label="COM_CONTACT_FIELD_PARAMS_STREET_ADDRESS_LABEL"
description="COM_CONTACT_FIELD_PARAMS_STREET_ADDRESS_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_suburb"
type="list"
label="COM_CONTACT_FIELD_PARAMS_TOWN-SUBURB_LABEL"
description="COM_CONTACT_FIELD_PARAMS_TOWN-SUBURB_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_state"
type="list"
label="COM_CONTACT_FIELD_PARAMS_STATE-COUNTY_LABEL"
description="COM_CONTACT_FIELD_PARAMS_STATE-COUNTY_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_postcode"
type="list"
label="COM_CONTACT_FIELD_PARAMS_POST-ZIP_CODE_LABEL"
description="COM_CONTACT_FIELD_PARAMS_POST-ZIP_CODE_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_country"
type="list"
label="COM_CONTACT_FIELD_PARAMS_COUNTRY_LABEL"
description="COM_CONTACT_FIELD_PARAMS_COUNTRY_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_telephone"
type="list"
label="COM_CONTACT_FIELD_PARAMS_TELEPHONE_LABEL"
description="COM_CONTACT_FIELD_PARAMS_TELEPHONE_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_mobile"
type="list"
label="COM_CONTACT_FIELD_PARAMS_MOBILE_LABEL"
description="COM_CONTACT_FIELD_PARAMS_MOBILE_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_fax"
type="list"
label="COM_CONTACT_FIELD_PARAMS_FAX_LABEL"
description="COM_CONTACT_FIELD_PARAMS_FAX_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_webpage"
type="list"
label="COM_CONTACT_FIELD_PARAMS_WEBPAGE_LABEL"
description="COM_CONTACT_FIELD_PARAMS_WEBPAGE_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_image"
type="list"
label="COM_CONTACT_FIELD_PARAMS_SHOW_IMAGE_LABEL"
description="COM_CONTACT_FIELD_PARAMS_SHOW_IMAGE_DESC"
class="chzn-color"
useglobal="true"
showon="show_info:1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_misc"
type="list"
label="COM_CONTACT_FIELD_PARAMS_MISC_INFO_LABEL"
description="COM_CONTACT_FIELD_PARAMS_MISC_INFO_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="allow_vcard"
type="list"
label="COM_CONTACT_FIELD_PARAMS_VCARD_LABEL"
description="COM_CONTACT_FIELD_PARAMS_VCARD_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_articles"
type="list"
label="COM_CONTACT_FIELD_ARTICLES_SHOW_LABEL"
description="COM_CONTACT_FIELD_ARTICLES_SHOW_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="articles_display_num"
type="list"
label="COM_CONTACT_FIELD_ARTICLES_DISPLAY_NUM_LABEL"
description="COM_CONTACT_FIELD_ARTICLES_DISPLAY_NUM_DESC"
default=""
useglobal="true"
>
<option value="5">J5</option>
<option value="10">J10</option>
<option value="15">J15</option>
<option value="20">J20</option>
<option value="25">J25</option>
<option value="30">J30</option>
<option value="50">J50</option>
<option value="75">J75</option>
<option value="100">J100</option>
<option value="150">J150</option>
<option value="200">J200</option>
<option value="250">J250</option>
<option value="300">J300</option>
<option value="0">JALL</option>
</field>
<field
name="show_profile"
type="list"
label="COM_CONTACT_FIELD_PROFILE_SHOW_LABEL"
description="COM_CONTACT_FIELD_PROFILE_SHOW_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_user_custom_fields"
type="fieldgroups"
label="COM_CONTACT_FIELD_USER_CUSTOM_FIELDS_SHOW_LABEL"
description="COM_CONTACT_FIELD_USER_CUSTOM_FIELDS_SHOW_DESC"
multiple="true"
context="com_users.user"
>
<option value="-1">JALL</option>
</field>
<field
name="show_links"
type="list"
label="COM_CONTACT_FIELD_SHOW_LINKS_LABEL"
description="COM_CONTACT_FIELD_SHOW_LINKS_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="linka_name"
type="text"
label="COM_CONTACT_FIELD_LINKA_NAME_LABEL"
description="COM_CONTACT_FIELD_LINK_NAME_DESC"
size="30"
/>
<field
name="linka"
type="url"
label="COM_CONTACT_FIELD_LINKA_LABEL"
description="COM_CONTACT_FIELD_LINKA_DESC"
size="30"
filter="url"
validate="url"
/>
<field
name="linkb_name"
type="text"
label="COM_CONTACT_FIELD_LINKB_NAME_LABEL"
description="COM_CONTACT_FIELD_LINK_NAME_DESC"
size="30"
/>
<field
name="linkb"
type="url"
label="COM_CONTACT_FIELD_LINKB_LABEL"
description="COM_CONTACT_FIELD_LINKB_DESC"
size="30"
filter="url"
validate="url"
/>
<field
name="linkc_name"
type="text"
label="COM_CONTACT_FIELD_LINKC_NAME_LABEL"
description="COM_CONTACT_FIELD_LINK_NAME_DESC"
size="30"
/>
<field
name="linkc"
type="url"
label="COM_CONTACT_FIELD_LINKC_LABEL"
description="COM_CONTACT_FIELD_LINKC_DESC"
size="30"
filter="url"
validate="url"
/>
<field
name="linkd_name"
type="text"
label="COM_CONTACT_FIELD_LINKD_NAME_LABEL"
description="COM_CONTACT_FIELD_LINK_NAME_DESC"
size="30"
/>
<field
name="linkd"
type="url"
label="COM_CONTACT_FIELD_LINKD_LABEL"
description="COM_CONTACT_FIELD_LINKD_DESC"
size="30"
filter="url"
validate="url"
/>
<field
name="linke_name"
type="text"
label="COM_CONTACT_FIELD_LINKE_NAME_LABEL"
description="COM_CONTACT_FIELD_LINK_NAME_DESC"
size="30"
/>
<field
name="linke"
type="url"
label="COM_CONTACT_FIELD_LINKE_LABEL"
description="COM_CONTACT_FIELD_LINKE_DESC"
size="30"
filter="url"
validate="url"
/>
<field
name="contact_layout"
type="componentlayout"
label="JFIELD_ALT_LAYOUT_LABEL"
description="JFIELD_ALT_COMPONENT_LAYOUT_DESC"
extension="com_contact"
view="contact"
useglobal="true"
/>
</fieldset>
<fieldset name="email"
label="COM_CONTACT_FIELDSET_CONTACT_LABEL">
<field
name="show_email_form"
type="list"
label="COM_CONTACT_FIELD_EMAIL_SHOW_FORM_LABEL"
description="COM_CONTACT_FIELD_EMAIL_SHOW_FORM_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_email_copy"
type="list"
label="COM_CONTACT_FIELD_EMAIL_EMAIL_COPY_LABEL"
description="COM_CONTACT_FIELD_EMAIL_EMAIL_COPY_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="validate_session"
type="list"
label="COM_CONTACT_FIELD_CONFIG_SESSION_CHECK_LABEL"
description="COM_CONTACT_FIELD_CONFIG_SESSION_CHECK_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="custom_reply"
type="list"
label="COM_CONTACT_FIELD_CONFIG_CUSTOM_REPLY_LABEL"
description="COM_CONTACT_FIELD_CONFIG_CUSTOM_REPLY_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="redirect"
type="text"
label="COM_CONTACT_FIELD_CONFIG_REDIRECT_LABEL"
description="COM_CONTACT_FIELD_CONFIG_REDIRECT_DESC"
size="30"
/>
</fieldset>
</fields>
<fields name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<fieldset name="jmetadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<field
name="robots"
type="list"
label="JFIELD_METADATA_ROBOTS_LABEL"
description="JFIELD_METADATA_ROBOTS_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="index, follow"></option>
<option value="noindex, follow"></option>
<option value="index, nofollow"></option>
<option value="noindex, nofollow"></option>
</field>
<field
name="rights"
type="text"
label="JFIELD_METADATA_RIGHTS_LABEL"
description="JFIELD_METADATA_RIGHTS_DESC"
size="20"
/>
</fieldset>
</fields>
<field
name="hits"
type="number"
label="JGLOBAL_HITS"
description="COM_CONTACT_HITS_DESC"
class="readonly"
size="6"
readonly="true"
filter="unset"
/>
<field
name="version"
type="text"
label="COM_CONTACT_FIELD_VERSION_LABEL"
description="COM_CONTACT_FIELD_VERSION_DESC"
class="readonly"
size="6"
readonly="true"
filter="unset"
/>
</form>
forms/fields/mail.xml000064400000000353151162335450010612 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields name="params"
label="COM_FIELDS_FIELD_BASIC_LABEL">
<fieldset name="basic">
<field
name="display"
type="hidden"
default="2"
/>
</fieldset>
</fields>
</form>
forms/filter_contacts.xml000064400000007205151162335450011610
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_CONTACT_FILTER_SEARCH_LABEL"
description="COM_CONTACT_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
label="JOPTION_SELECT_PUBLISHED"
description="JOPTION_SELECT_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
extension="com_contact"
published="0,1,2"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_CATEGORY</option>
</field>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_ACCESS</option>
</field>
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
<field
name="tag"
type="tag"
label="JOPTION_FILTER_TAG"
description="JOPTION_FILTER_TAG_DESC"
mode="nested"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_TAG</option>
</field>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTACT_LIST_FULL_ORDERING"
description="COM_CONTACT_LIST_FULL_ORDERING_DESC"
default="a.name ASC"
onchange="this.form.submit();"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.featured
ASC">JFEATURED_ASC</option>
<option value="a.featured
DESC">JFEATURED_DESC</option>
<option value="a.name
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.name
DESC">JGLOBAL_TITLE_DESC</option>
<option value="category_title
ASC">JCATEGORY_ASC</option>
<option value="category_title
DESC">JCATEGORY_DESC</option>
<option value="ul.name
ASC">COM_CONTACT_FIELD_LINKED_USER_LABEL_ASC</option>
<option value="ul.name
DESC">COM_CONTACT_FIELD_LINKED_USER_LABEL_DESC</option>
<option value="access_level
ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="access_level
DESC">JGRID_HEADING_ACCESS_DESC</option>
<option
value="association ASC"
requires="associations"
>
JASSOCIATIONS_ASC
</option>
<option
value="association DESC"
requires="associations"
>
JASSOCIATIONS_DESC
</option>
<option value="language_title
ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="language_title
DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTACT_LIST_LIMIT"
description="COM_CONTACT_LIST_LIMIT_DESC"
default="25"
class="input-mini"
onchange="this.form.submit();"
/>
</fields>
</form>
fields/branches.php000064400000001352151163626560010324 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_BASE') or die();
JFormHelper::loadFieldClass('list');
/**
* Search Branches field for the Finder package.
*
* @since 3.5
*/
class JFormFieldBranches extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
protected $type = 'Branches';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.5
*/
public function getOptions()
{
return JHtml::_('finder.mapslist');
}
}
fields/contentmap.php000064400000006172151163626570010715 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('groupedlist');
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR .
'/components/com_finder/helpers/language.php');
/**
* Supports a select grouped list of finder content map.
*
* @since 3.6.0
*/
class JFormFieldContentMap extends JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 3.6.0
*/
public $type = 'ContentMap';
/**
* Method to get the list of content map options grouped by first level.
*
* @return array The field option objects as a nested array in groups.
*
* @since 3.6.0
*/
protected function getGroups()
{
$groups = array();
// Get the database object and a new query object.
$db = JFactory::getDbo();
// Levels subquery.
$levelQuery = $db->getQuery(true);
$levelQuery->select('title AS branch_title, 1 as level')
->select($db->quoteName('id'))
->from($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('parent_id') . ' = 1');
$levelQuery2 = $db->getQuery(true);
$levelQuery2->select('b.title AS branch_title, 2 as level')
->select($db->quoteName('a.id'))
->from($db->quoteName('#__finder_taxonomy',
'a'))
->join('LEFT',
$db->quoteName('#__finder_taxonomy', 'b') . '
ON ' . $db->qn('a.parent_id') . ' = ' .
$db->qn('b.id'))
->where($db->quoteName('a.parent_id') . ' NOT IN
(0, 1)');
$levelQuery->union($levelQuery2);
// Main query.
$query = $db->getQuery(true)
->select($db->quoteName('a.title', 'text'))
->select($db->quoteName('a.id', 'value'))
->select($db->quoteName('d.level'))
->from($db->quoteName('#__finder_taxonomy',
'a'))
->join('LEFT', '(' . $levelQuery . ') AS d
ON ' . $db->qn('d.id') . ' = ' .
$db->qn('a.id'))
->where($db->quoteName('a.parent_id') . ' <>
0')
->order('d.branch_title ASC, d.level ASC, a.title ASC');
$db->setQuery($query);
try
{
$contentMap = $db->loadObjectList();
}
catch (RuntimeException $e)
{
return;
}
// Build the grouped list array.
if ($contentMap)
{
$lang = JFactory::getLanguage();
foreach ($contentMap as $branch)
{
if ((int) $branch->level === 1)
{
$name = $branch->text;
}
else
{
$levelPrefix = str_repeat('- ', max(0, $branch->level -
1));
if (trim($name, '**') === 'Language')
{
$text = FinderHelperLanguage::branchLanguageTitle($branch->text);
}
else
{
$key = FinderHelperLanguage::branchSingular($branch->text);
$text = $lang->hasKey($key) ? JText::_($key) : $branch->text;
}
// Initialize the group if necessary.
if (!isset($groups[$name]))
{
$groups[$name] = array();
}
$groups[$name][] = JHtml::_('select.option',
$branch->value, $levelPrefix . $text);
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
}
fields/contenttypes.php000064400000003677151163626570011313
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_BASE') or die();
use Joomla\Utilities\ArrayHelper;
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR .
'/components/com_finder/helpers/language.php');
JFormHelper::loadFieldClass('list');
/**
* Content Types Filter field for the Finder package.
*
* @since 3.6.0
*/
class JFormFieldContentTypes extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.6.0
*/
protected $type = 'ContentTypes';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.6.0
*/
public function getOptions()
{
$lang = JFactory::getLanguage();
$options = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id', 'value'))
->select($db->quoteName('title', 'text'))
->from($db->quoteName('#__finder_types'));
// Get the options.
$db->setQuery($query);
try
{
$contentTypes = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $db->getMessage());
}
// Translate.
foreach ($contentTypes as $contentType)
{
$key = FinderHelperLanguage::branchSingular($contentType->text);
$contentType->translatedText = $lang->hasKey($key) ?
JText::_($key) : $contentType->text;
}
// Order by title.
$contentTypes = ArrayHelper::sortObjects($contentTypes,
'translatedText', 1, true, true);
// Convert the values to options.
foreach ($contentTypes as $contentType)
{
$options[] = JHtml::_('select.option', $contentType->value,
$contentType->translatedText);
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
fields/directories.php000064400000004232151163626570011054 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Load the base adapter.
JLoader::register('FinderIndexerAdapter', JPATH_ADMINISTRATOR .
'/components/com_finder/helpers/indexer/adapter.php');
JFormHelper::loadFieldClass('list');
/**
* Renders a list of directories.
*
* @since 2.5
* @deprecated 4.0 Use JFormFieldFolderlist
*/
class JFormFieldDirectories extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 2.5
*/
protected $type = 'Directories';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 2.5
*/
public function getOptions()
{
$values = array();
$options = array();
$exclude = array(
JPATH_ADMINISTRATOR,
JPATH_INSTALLATION,
JPATH_LIBRARIES,
JPATH_PLUGINS,
JPATH_SITE . '/cache',
JPATH_SITE . '/components',
JPATH_SITE . '/includes',
JPATH_SITE . '/language',
JPATH_SITE . '/modules',
JPATH_THEMES,
JFactory::getApplication()->get('log_path'),
JFactory::getApplication()->get('tmp_path')
);
// Get the base directories.
jimport('joomla.filesystem.folder');
$dirs = JFolder::folders(JPATH_SITE, '.', false, true);
// Iterate through the base directories and find the subdirectories.
foreach ($dirs as $dir)
{
// Check if the directory should be excluded.
if (in_array($dir, $exclude))
{
continue;
}
// Get the child directories.
$return = JFolder::folders($dir, '.', true, true);
// Merge the directories.
if (is_array($return))
{
$values[] = $dir;
$values = array_merge($values, $return);
}
}
// Convert the values to options.
foreach ($values as $value)
{
$options[] = JHtml::_('select.option', str_replace(JPATH_SITE
. '/', '', $value), str_replace(JPATH_SITE .
'/', '', $values));
}
// Add a null option.
array_unshift($options, JHtml::_('select.option', '',
'- ' . JText::_('JNONE') . ' -'));
return $options;
}
}
fields/searchfilter.php000064400000002210151163626570011205
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_BASE') or die();
JFormHelper::loadFieldClass('list');
/**
* Search Filter field for the Finder package.
*
* @since 2.5
*/
class JFormFieldSearchFilter extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 2.5
*/
protected $type = 'SearchFilter';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 2.5
*/
public function getOptions()
{
// Build the query.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('f.title AS text, f.filter_id AS value')
->from($db->quoteName('#__finder_filters') . ' AS
f')
->where('f.state = 1')
->order('f.title ASC');
$db->setQuery($query);
$options = $db->loadObjectList();
array_unshift($options, JHtml::_('select.option', '',
JText::_('COM_FINDER_SELECT_SEARCH_FILTER'), 'value',
'text'));
return $options;
}
}
filter.php000064400000007175151163626570006570 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Filter model class for Finder.
*
* @since 2.5
*/
class FinderModelFilter extends JModelAdmin
{
/**
* The prefix to use with controller messages.
*
* @var string
* @since 2.5
*/
protected $text_prefix = 'COM_FINDER';
/**
* Model context string.
*
* @var string
* @since 2.5
*/
protected $context = 'com_finder.filter';
/**
* Custom clean cache method.
*
* @param string $group The component name. [optional]
* @param integer $clientId The client ID. [optional]
*
* @return void
*
* @since 2.5
*/
protected function cleanCache($group = 'com_finder', $clientId =
1)
{
parent::cleanCache($group, $clientId);
}
/**
* Method to get the filter data.
*
* @return FinderTableFilter|boolean The filter data or false on a
failure.
*
* @since 2.5
*/
public function getFilter()
{
$filter_id = (int) $this->getState('filter.id');
// Get a FinderTableFilter instance.
$filter = $this->getTable();
// Attempt to load the row.
$return = $filter->load($filter_id);
// Check for a database error.
if ($return === false && $filter->getError())
{
$this->setError($filter->getError());
return false;
}
// Process the filter data.
if (!empty($filter->data))
{
$filter->data = explode(',', $filter->data);
}
elseif (empty($filter->data))
{
$filter->data = array();
}
// Check for a database error.
if ($this->_db->getErrorNum())
{
$this->setError($this->_db->getErrorMsg());
return false;
}
return $filter;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form. [optional]
* @param boolean $loadData True if the form is to load its own data
(default case), false if not. [optional]
*
* @return JForm|boolean A JForm object on success, false on failure
*
* @since 2.5
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_finder.filter',
'filter', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Returns a JTable object, always creating it.
*
* @param string $type The table type to instantiate. [optional]
* @param string $prefix A prefix for the table class name. [optional]
* @param array $config Configuration array for model. [optional]
*
* @return JTable A database object
*
* @since 2.5
*/
public function getTable($type = 'Filter', $prefix =
'FinderTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 2.5
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_finder.edit.filter.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_finder.filter', $data);
return $data;
}
/**
* Method to get the total indexed items
*
* @return number the number of indexed items
*
* @since 3.5
*/
public function getTotal()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(link_id)')
->from('#__finder_links');
return $db->setQuery($query)->loadResult();
}
}
filters.php000064400000007401151163626570006743 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Filters model class for Finder.
*
* @since 2.5
*/
class FinderModelFilters extends JModelList
{
/**
* Constructor.
*
* @param array $config An associative array of configuration
settings. [optional]
*
* @since 2.5
* @see JControllerLegacy
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'filter_id', 'a.filter_id',
'title', 'a.title',
'state', 'a.state',
'created_by_alias', 'a.created_by_alias',
'created', 'a.created',
'map_count', 'a.map_count'
);
}
parent::__construct($config);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery A JDatabaseQuery object
*
* @since 2.5
*/
protected function getListQuery()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select all fields from the table.
$query->select('a.*')
->from($db->quoteName('#__finder_filters',
'a'));
// Join over the users for the checked out user.
$query->select($db->quoteName('uc.name',
'editor'))
->join('LEFT', $db->quoteName('#__users',
'uc') . ' ON ' . $db->quoteName('uc.id') .
' = ' . $db->quoteName('a.checked_out'));
// Join over the users for the author.
$query->select($db->quoteName('ua.name',
'user_name'))
->join('LEFT', $db->quoteName('#__users',
'ua') . ' ON ' . $db->quoteName('ua.id') .
' = ' . $db->quoteName('a.created_by'));
// Check for a search filter.
if ($search = $this->getState('filter.search'))
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where($db->quoteName('a.title') . ' LIKE
' . $search);
}
// If the model is set to check item state, add to the query.
$state = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where($db->quoteName('a.state') . ' =
' . (int) $state);
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.title') . ' ' .
$db->escape($this->getState('list.direction',
'ASC'))));
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id. [optional]
*
* @return string A store id.
*
* @since 2.5
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.state');
return parent::getStoreId($id);
}
/**
* Method to auto-populate the model state. Calling getState in this
method will result in recursion.
*
* @param string $ordering An optional ordering field. [optional]
* @param string $direction An optional direction. [optional]
*
* @return void
*
* @since 2.5
*/
protected function populateState($ordering = 'a.title',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.state',
$this->getUserStateFromRequest($this->context .
'.filter.state', 'filter_state', '',
'cmd'));
// Load the parameters.
$params = JComponentHelper::getParams('com_finder');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
}
forms/filter.xml000064400000007152151163626570007722 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="filter_id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
class="readonly"
size="10"
default="0"
readonly="true"
/>
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="COM_FINDER_FILTER_TITLE_DESCRIPTION"
class="input-xxlarge input-large-text"
size="40"
id="title"
required="true"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER"
size="45"
/>
<field
name="created"
type="calendar"
label="JGLOBAL_FIELD_CREATED_LABEL"
description="JGLOBAL_FIELD_CREATED_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="modified"
type="calendar"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
description="COM_FINDER_FIELD_MODIFIED_DESCRIPTION"
class="readonly"
translateformat="true"
showtime="true"
size="22"
readonly="true"
filter="user_utc"
/>
<field
name="created_by"
type="user"
label="COM_FINDER_FIELD_CREATED_BY_LABEL"
description="COM_FINDER_FIELD_CREATED_BY_DESC"
/>
<field
name="created_by_alias"
type="text"
label="COM_FINDER_FIELD_CREATED_BY_ALIAS_LABEL"
description="COM_FINDER_FIELD_CREATED_BY_ALIAS_DESC"
size="20"
/>
<field
name="modified_by"
type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="state"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
class="chzn-color-state"
filter="intval"
size="1"
default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field
name="map_count"
type="text"
label="COM_FINDER_FILTER_MAP_COUNT"
description="COM_FINDER_FILTER_MAP_COUNT_DESCRIPTION"
class="readonly"
size="10"
default="0"
readonly="true"
/>
</fieldset>
<fields name="params">
<fieldset name="jbasic"
label="COM_FINDER_FILTER_FIELDSET_PARAMS">
<field
name="w1"
type="list"
label="COM_FINDER_FILTER_WHEN_START_DATE_LABEL"
description="COM_FINDER_FILTER_WHEN_START_DATE_DESCRIPTION"
default=""
filter="string"
>
<option value="">JNONE</option>
<option
value="-1">COM_FINDER_FILTER_WHEN_BEFORE</option>
<option
value="0">COM_FINDER_FILTER_WHEN_EXACTLY</option>
<option
value="1">COM_FINDER_FILTER_WHEN_AFTER</option>
</field>
<field
name="d1"
type="calendar"
label="COM_FINDER_FILTER_START_DATE_LABEL"
description="COM_FINDER_FILTER_START_DATE_DESCRIPTION"
translateformat="true"
size="22"
filter="user_utc"
/>
<field
name="w2"
type="list"
label="COM_FINDER_FILTER_WHEN_END_DATE_LABEL"
description="COM_FINDER_FILTER_WHEN_END_DATE_DESCRIPTION"
default=""
filter="string"
>
<option value="">JNONE</option>
<option
value="-1">COM_FINDER_FILTER_WHEN_BEFORE</option>
<option
value="0">COM_FINDER_FILTER_WHEN_EXACTLY</option>
<option
value="1">COM_FINDER_FILTER_WHEN_AFTER</option>
</field>
<field
name="d2"
type="calendar"
label="COM_FINDER_FILTER_END_DATE_LABEL"
description="COM_FINDER_FILTER_END_DATE_DESCRIPTION"
translateformat="true"
size="22"
filter="user_utc"
/>
</fieldset>
</fields>
</form>
forms/filter_filters.xml000064400000003270151163626570011447
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_FINDER_SEARCH_FILTER_SEARCH_LABEL"
description="COM_FINDER_SEARCH_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="status"
label="COM_FINDER_FILTER_PUBLISHED"
description="COM_FINDER_FILTER_PUBLISHED_DESC"
filter="0,1"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
onchange="this.form.submit();"
default="a.title ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.created_by_alias
ASC">COM_FINDER_HEADING_CREATED_BY_ASC</option>
<option value="a.created_by_alias
DESC">COM_FINDER_HEADING_CREATED_BY_DESC</option>
<option value="a.created
ASC">COM_FINDER_HEADING_CREATED_ON_ASC</option>
<option value="a.created
DESC">COM_FINDER_HEADING_CREATED_ON_DESC</option>
<option value="a.map_count
ASC">COM_FINDER_HEADING_MAP_COUNT_ASC</option>
<option value="a.map_count
DESC">COM_FINDER_HEADING_MAP_COUNT_DESC</option>
<option value="a.filter_id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.filter_id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_index.xml000064400000004050151163626570011103 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_FINDER_INDEX_SEARCH_LABEL"
description="COM_FINDER_INDEX_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="status"
label="COM_FINDER_FILTER_PUBLISHED"
description="COM_FINDER_FILTER_PUBLISHED_DESC"
filter="0,1"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="type"
type="ContentTypes"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_FINDER_MAPS_SELECT_TYPE</option>
</field>
<field
name="content_map"
type="ContentMap"
label="COM_FINDER_FILTER_CONTENT_MAP_LABEL"
description="COM_FINDER_FILTER_CONTENT_MAP_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_FINDER_FILTER_SELECT_CONTENT_MAP</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
onchange="this.form.submit();"
default="l.title ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="l.published
ASC">JSTATUS_ASC</option>
<option value="l.published
DESC">JSTATUS_DESC</option>
<option value="l.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="l.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="t.title
ASC">COM_FINDER_INDEX_HEADING_INDEX_TYPE_ASC</option>
<option value="t.title
DESC">COM_FINDER_INDEX_HEADING_INDEX_TYPE_DESC</option>
<option value="l.indexdate
ASC">COM_FINDER_INDEX_HEADING_INDEX_DATE_ASC</option>
<option value="l.indexdate
DESC">COM_FINDER_INDEX_HEADING_INDEX_DATE_DESC</option>
<option value="l.url
ASC">COM_FINDER_INDEX_HEADING_LINK_URL_ASC</option>
<option value="l.url
DESC">COM_FINDER_INDEX_HEADING_LINK_URL_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_maps.xml000064400000002737151163626570010746 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_FINDER_SEARCH_SEARCH_QUERY_LABEL"
description="COM_FINDER_SEARCH_SEARCH_QUERY_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="status"
label="COM_FINDER_FILTER_PUBLISHED"
description="COM_FINDER_FILTER_PUBLISHED_DESC"
filter="0,1"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="branch"
type="branches"
default="0"
onchange="this.form.submit();"
/>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="2"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
onchange="this.form.submit();"
default="d.branch_title ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="d.branch_title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="d.branch_title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
index.php000064400000026673151163626570006416 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Index model class for Finder.
*
* @since 2.5
*/
class FinderModelIndex extends JModelList
{
/**
* The event to trigger after deleting the data.
*
* @var string
* @since 2.5
*/
protected $event_after_delete = 'onContentAfterDelete';
/**
* The event to trigger before deleting the data.
*
* @var string
* @since 2.5
*/
protected $event_before_delete = 'onContentBeforeDelete';
/**
* Constructor.
*
* @param array $config An associative array of configuration
settings. [optional]
*
* @since 2.5
* @see JControllerLegacy
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'state', 'published', 'l.published',
'title', 'l.title',
'type', 'type_id', 'l.type_id',
't.title', 't_title',
'url', 'l.url',
'indexdate', 'l.indexdate',
'content_map',
);
}
parent::__construct($config);
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission for the component.
*
* @since 2.5
*/
protected function canDelete($record)
{
return JFactory::getUser()->authorise('core.delete',
$this->option);
}
/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission for the component.
*
* @since 2.5
*/
protected function canEditState($record)
{
return JFactory::getUser()->authorise('core.edit.state',
$this->option);
}
/**
* Method to delete one or more records.
*
* @param array $pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 2.5
*/
public function delete(&$pks)
{
$dispatcher = JEventDispatcher::getInstance();
$pks = (array) $pks;
$table = $this->getTable();
// Include the content plugins for the on delete events.
JPluginHelper::importPlugin('content');
// Iterate the items to delete each one.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
if ($this->canDelete($table))
{
$context = $this->option . '.' . $this->name;
// Trigger the onContentBeforeDelete event.
$result = $dispatcher->trigger($this->event_before_delete,
array($context, $table));
if (in_array(false, $result, true))
{
$this->setError($table->getError());
return false;
}
if (!$table->delete($pk))
{
$this->setError($table->getError());
return false;
}
// Trigger the onContentAfterDelete event.
$dispatcher->trigger($this->event_after_delete, array($context,
$table));
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
$error = $this->getError();
if ($error)
{
$this->setError($error);
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
}
}
}
else
{
$this->setError($table->getError());
return false;
}
}
// Clear the component's cache
$this->cleanCache();
return true;
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery A JDatabaseQuery object
*
* @since 2.5
*/
protected function getListQuery()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('l.*')
->select($db->quoteName('t.title', 't_title'))
->from($db->quoteName('#__finder_links', 'l'))
->join('INNER',
$db->quoteName('#__finder_types', 't') . ' ON
' . $db->quoteName('t.id') . ' = ' .
$db->quoteName('l.type_id'));
// Check the type filter.
$type = $this->getState('filter.type');
if (is_numeric($type))
{
$query->where($db->quoteName('l.type_id') . ' =
' . (int) $type);
}
// Check the map filter.
$contentMapId = $this->getState('filter.content_map');
if (is_numeric($contentMapId))
{
$query->join('INNER',
$db->quoteName('#__finder_taxonomy_map', 'm') .
' ON ' . $db->quoteName('m.link_id') . ' =
' . $db->quoteName('l.link_id'))
->where($db->quoteName('m.node_id') . ' = ' .
(int) $contentMapId);
}
// Check for state filter.
$state = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where($db->quoteName('l.published') . ' =
' . (int) $state);
}
// Check the search phrase.
$search = $this->getState('filter.search');
if (!empty($search))
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$orSearchSql = $db->quoteName('l.title') . ' LIKE
' . $search . ' OR ' . $db->quoteName('l.url')
. ' LIKE ' . $search;
// Filter by indexdate only if $search doesn't contains non-ascii
characters
if (!preg_match('/[^\x00-\x7F]/', $search))
{
$orSearchSql .= ' OR ' .
$query->castAsChar($db->quoteName('l.indexdate')) . '
LIKE ' . $search;
}
$query->where('(' . $orSearchSql . ')');
}
// Handle the list ordering.
$listOrder = $this->getState('list.ordering',
'l.title');
$listDir = $this->getState('list.direction',
'ASC');
if ($listOrder === 't.title')
{
$ordering = $db->quoteName('t.title') . ' ' .
$db->escape($listDir) . ', ' .
$db->quoteName('l.title') . ' ' .
$db->escape($listDir);
}
else
{
$ordering = $db->escape($listOrder) . ' ' .
$db->escape($listDir);
}
$query->order($ordering);
return $query;
}
/**
* Method to get the state of the Smart Search Plugins.
*
* @return array Array of relevant plugins and whether they are enabled
or not.
*
* @since 2.5
*/
public function getPluginState()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('name, enabled')
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'))
->where($db->quoteName('folder') . ' IN (' .
$db->quote('system') . ',' .
$db->quote('content') . ')')
->where($db->quoteName('element') . ' = ' .
$db->quote('finder'));
$db->setQuery($query);
return $db->loadObjectList('name');
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id. [optional]
*
* @return string A store id.
*
* @since 2.5
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.state');
$id .= ':' . $this->getState('filter.type');
$id .= ':' .
$this->getState('filter.content_map');
return parent::getStoreId($id);
}
/**
* Gets the total of indexed items.
*
* @return integer The total of indexed items.
*
* @since 3.6.0
*/
public function getTotalIndexed()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('COUNT(link_id)')
->from($db->quoteName('#__finder_links'));
$db->setQuery($query);
$db->execute();
return (int) $db->loadResult();
}
/**
* Returns a JTable object, always creating it.
*
* @param string $type The table type to instantiate. [optional]
* @param string $prefix A prefix for the table class name. [optional]
* @param array $config Configuration array for model. [optional]
*
* @return JTable A database object
*
* @since 2.5
*/
public function getTable($type = 'Link', $prefix =
'FinderTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to purge the index, deleting all links.
*
* @return boolean True on success, false on failure.
*
* @since 2.5
* @throws Exception on database error
*/
public function purge()
{
$db = $this->getDbo();
// Truncate the links table.
$db->truncateTable('#__finder_links');
// Truncate the links terms tables.
for ($i = 0; $i <= 15; $i++)
{
// Get the mapping table suffix.
$suffix = dechex($i);
$db->truncateTable('#__finder_links_terms' . $suffix);
}
// Truncate the terms table.
$db->truncateTable('#__finder_terms');
// Truncate the taxonomy map table.
$db->truncateTable('#__finder_taxonomy_map');
// Delete all the taxonomy nodes except the root.
$query = $db->getQuery(true)
->delete($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('id') . ' > 1');
$db->setQuery($query);
$db->execute();
// Truncate the tokens tables.
$db->truncateTable('#__finder_tokens');
// Truncate the tokens aggregate table.
$db->truncateTable('#__finder_tokens_aggregate');
return true;
}
/**
* Method to auto-populate the model state. Calling getState in this
method will result in recursion.
*
* @param string $ordering An optional ordering field. [optional]
* @param string $direction An optional direction. [optional]
*
* @return void
*
* @since 2.5
*/
protected function populateState($ordering = 'l.title',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.state',
$this->getUserStateFromRequest($this->context .
'.filter.state', 'filter_state', '',
'cmd'));
$this->setState('filter.type',
$this->getUserStateFromRequest($this->context .
'.filter.type', 'filter_type', '',
'cmd'));
$this->setState('filter.content_map',
$this->getUserStateFromRequest($this->context .
'.filter.content_map', 'filter_content_map',
'', 'cmd'));
// Load the parameters.
$params = JComponentHelper::getParams('com_finder');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to change the published state of one or more records.
*
* @param array $pks A list of the primary keys to change.
* @param integer $value The value of the published state. [optional]
*
* @return boolean True on success.
*
* @since 2.5
*/
public function publish(&$pks, $value = 1)
{
$dispatcher = JEventDispatcher::getInstance();
$user = JFactory::getUser();
$table = $this->getTable();
$pks = (array) $pks;
// Include the content plugins for the change of state event.
JPluginHelper::importPlugin('content');
// Access checks.
foreach ($pks as $i => $pk)
{
$table->reset();
if ($table->load($pk) && !$this->canEditState($table))
{
// Prune items that you can't change.
unset($pks[$i]);
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
return false;
}
}
// Attempt to change the state of the records.
if (!$table->publish($pks, $value, $user->get('id')))
{
$this->setError($table->getError());
return false;
}
$context = $this->option . '.' . $this->name;
// Trigger the onContentChangeState event.
$result = $dispatcher->trigger('onContentChangeState',
array($context, $pks, $value));
if (in_array(false, $result, true))
{
$this->setError($table->getError());
return false;
}
// Clear the component's cache
$this->cleanCache();
return true;
}
}
indexer.php000064400000000604151163626570006727 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Indexer model class for Finder.
*
* @since 2.5
*/
class FinderModelIndexer extends JModelLegacy
{
}
maps.php000064400000025014151163626570006233 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die();
/**
* Maps model for the Finder package.
*
* @since 2.5
*/
class FinderModelMaps extends JModelList
{
/**
* Constructor.
*
* @param array $config An associative array of configuration
settings. [optional]
*
* @since 2.5
* @see JControllerLegacy
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'state', 'a.state',
'title', 'a.title',
'branch',
'branch_title', 'd.branch_title',
'level', 'd.level',
);
}
parent::__construct($config);
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission for the component.
*
* @since 2.5
*/
protected function canDelete($record)
{
return JFactory::getUser()->authorise('core.delete',
$this->option);
}
/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission for the component.
*
* @since 2.5
*/
protected function canEditState($record)
{
return JFactory::getUser()->authorise('core.edit.state',
$this->option);
}
/**
* Method to delete one or more records.
*
* @param array $pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 2.5
*/
public function delete(&$pks)
{
$dispatcher = JEventDispatcher::getInstance();
$pks = (array) $pks;
$table = $this->getTable();
// Include the content plugins for the on delete events.
JPluginHelper::importPlugin('content');
// Iterate the items to delete each one.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
if ($this->canDelete($table))
{
$context = $this->option . '.' . $this->name;
// Trigger the onContentBeforeDelete event.
$result = $dispatcher->trigger('onContentBeforeDelete',
array($context, $table));
if (in_array(false, $result, true))
{
$this->setError($table->getError());
return false;
}
if (!$table->delete($pk))
{
$this->setError($table->getError());
return false;
}
// Trigger the onContentAfterDelete event.
$dispatcher->trigger('onContentAfterDelete',
array($context, $table));
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
$error = $this->getError();
if ($error)
{
$this->setError($error);
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
}
}
}
else
{
$this->setError($table->getError());
return false;
}
}
// Clear the component's cache
$this->cleanCache();
return true;
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery A JDatabaseQuery object
*
* @since 2.5
*/
protected function getListQuery()
{
$db = $this->getDbo();
// Select all fields from the table.
$query = $db->getQuery(true)
->select('a.id, a.parent_id, a.title, a.state, a.access,
a.ordering')
->select('CASE WHEN a.parent_id = 1 THEN 1 ELSE 2 END AS
level')
->select('p.title AS parent_title')
->from($db->quoteName('#__finder_taxonomy',
'a'))
->leftJoin($db->quoteName('#__finder_taxonomy',
'p') . ' ON p.id = a.parent_id')
->where('a.parent_id != 0');
$childQuery = $db->getQuery(true)
->select('parent_id')
->select('COUNT(*) AS num_children')
->from($db->quoteName('#__finder_taxonomy'))
->where('parent_id != 0')
->group('parent_id');
// Join to get children.
$query->select('b.num_children');
$query->select('CASE WHEN a.parent_id = 1 THEN a.title ELSE
p.title END AS branch_title');
$query->leftJoin('(' . $childQuery . ') AS b ON
b.parent_id = a.id');
// Join to get the map links.
$stateQuery = $db->getQuery(true)
->select('m.node_id')
->select('COUNT(NULLIF(l.published, 0)) AS
count_published')
->select('COUNT(NULLIF(l.published, 1)) AS
count_unpublished')
->from($db->quoteName('#__finder_taxonomy_map',
'm'))
->leftJoin($db->quoteName('#__finder_links',
'l') . ' ON l.link_id = m.link_id')
->group('m.node_id');
$query->select('COALESCE(s.count_published, 0) AS
count_published');
$query->select('COALESCE(s.count_unpublished, 0) AS
count_unpublished');
$query->leftJoin('(' . $stateQuery . ') AS s ON
s.node_id = a.id');
// If the model is set to check item state, add to the query.
$state = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where('a.state = ' . (int) $state);
}
// Filter over level.
$level = $this->getState('filter.level');
if (is_numeric($level) && (int) $level === 1)
{
$query->where('a.parent_id = 1');
}
// Filter the maps over the branch if set.
$branchId = $this->getState('filter.branch');
if (is_numeric($branchId))
{
$query->where('a.parent_id = ' . (int) $branchId);
}
// Filter the maps over the search string if set.
if ($search = $this->getState('filter.search'))
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('a.title LIKE ' . $search);
}
// Handle the list ordering.
$listOrdering = $this->getState('list.ordering',
'd.branch_title');
$listDirn = $this->getState('list.direction',
'ASC');
if ($listOrdering === 'd.branch_title')
{
$query->order("branch_title $listDirn, level ASC, a.title
$listDirn");
}
elseif ($listOrdering === 'a.state')
{
$query->order("a.state $listDirn, branch_title $listDirn, level
ASC");
}
return $query;
}
/**
* Returns a record count for the query.
*
* @param JDatabaseQuery|string $query The query.
*
* @return integer Number of rows for query.
*
* @since 3.0
*/
protected function _getListCount($query)
{
$query = clone $query;
$query->clear('select')->clear('join')->clear('order')->clear('limit')->clear('offset')->select('COUNT(*)');
return (int) $this->getDbo()->setQuery($query)->loadResult();
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id. [optional]
*
* @return string A store id.
*
* @since 2.5
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.state');
$id .= ':' . $this->getState('filter.branch');
$id .= ':' . $this->getState('filter.level');
return parent::getStoreId($id);
}
/**
* Returns a JTable object, always creating it.
*
* @param string $type The table type to instantiate. [optional]
* @param string $prefix A prefix for the table class name. [optional]
* @param array $config Configuration array for model. [optional]
*
* @return JTable A database object
*
* @since 2.5
*/
public function getTable($type = 'Map', $prefix =
'FinderTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to auto-populate the model state. Calling getState in this
method will result in recursion.
*
* @param string $ordering An optional ordering field. [optional]
* @param string $direction An optional direction. [optional]
*
* @return void
*
* @since 2.5
*/
protected function populateState($ordering = 'd.branch_title',
$direction = 'ASC')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.state',
$this->getUserStateFromRequest($this->context .
'.filter.state', 'filter_state', '',
'cmd'));
$this->setState('filter.branch',
$this->getUserStateFromRequest($this->context .
'.filter.branch', 'filter_branch', '',
'cmd'));
$this->setState('filter.level',
$this->getUserStateFromRequest($this->context .
'.filter.level', 'filter_level', '',
'cmd'));
// Load the parameters.
$params = JComponentHelper::getParams('com_finder');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to change the published state of one or more records.
*
* @param array $pks A list of the primary keys to change.
* @param integer $value The value of the published state. [optional]
*
* @return boolean True on success.
*
* @since 2.5
*/
public function publish(&$pks, $value = 1)
{
$dispatcher = JEventDispatcher::getInstance();
$user = JFactory::getUser();
$table = $this->getTable();
$pks = (array) $pks;
// Include the content plugins for the change of state event.
JPluginHelper::importPlugin('content');
// Access checks.
foreach ($pks as $i => $pk)
{
$table->reset();
if ($table->load($pk) && !$this->canEditState($table))
{
// Prune items that you can't change.
unset($pks[$i]);
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
return false;
}
}
// Attempt to change the state of the records.
if (!$table->publish($pks, $value, $user->get('id')))
{
$this->setError($table->getError());
return false;
}
$context = $this->option . '.' . $this->name;
// Trigger the onContentChangeState event.
$result = $dispatcher->trigger('onContentChangeState',
array($context, $pks, $value));
if (in_array(false, $result, true))
{
$this->setError($table->getError());
return false;
}
// Clear the component's cache
$this->cleanCache();
return true;
}
/**
* Method to purge all maps from the taxonomy.
*
* @return boolean Returns true on success, false on failure.
*
* @since 2.5
*/
public function purge()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('parent_id') . ' >
1');
$db->setQuery($query);
$db->execute();
$query->clear()
->delete($db->quoteName('#__finder_taxonomy_map'));
$db->setQuery($query);
$db->execute();
return true;
}
}
statistics.php000064400000004126151163626570007466 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Statistics model class for Finder.
*
* @since 2.5
*/
class FinderModelStatistics extends JModelLegacy
{
/**
* Method to get the component statistics
*
* @return JObject The component statistics
*
* @since 2.5
*/
public function getData()
{
// Initialise
$db = $this->getDbo();
$query = $db->getQuery(true);
$data = new JObject;
$query->select('COUNT(term_id)')
->from($db->quoteName('#__finder_terms'));
$db->setQuery($query);
$data->term_count = $db->loadResult();
$query->clear()
->select('COUNT(link_id)')
->from($db->quoteName('#__finder_links'));
$db->setQuery($query);
$data->link_count = $db->loadResult();
$query->clear()
->select('COUNT(id)')
->from($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('parent_id') . ' = 1');
$db->setQuery($query);
$data->taxonomy_branch_count = $db->loadResult();
$query->clear()
->select('COUNT(id)')
->from($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('parent_id') . ' >
1');
$db->setQuery($query);
$data->taxonomy_node_count = $db->loadResult();
$query->clear()
->select('t.title AS type_title, COUNT(a.link_id) AS
link_count')
->from($db->quoteName('#__finder_links') . ' AS
a')
->join('INNER',
$db->quoteName('#__finder_types') . ' AS t ON t.id =
a.type_id')
->group('a.type_id, t.title')
->order($db->quoteName('type_title') . '
ASC');
$db->setQuery($query);
$data->type_list = $db->loadObjectList();
$lang = JFactory::getLanguage();
$plugins = JPluginHelper::getPlugin('finder');
foreach ($plugins as $plugin)
{
$lang->load('plg_finder_' . $plugin->name .
'.sys', JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load('plg_finder_' . $plugin->name .
'.sys', JPATH_PLUGINS . '/finder/' . $plugin->name,
null, false, true);
}
return $data;
}
}
field.php000064400000066715151164035040006356 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Field Model
*
* @since 3.7.0
*/
class FieldsModelField extends JModelAdmin
{
/**
* @var null|string
*
* @since 3.7.0
*/
public $typeAlias = null;
/**
* @var string
*
* @since 3.7.0
*/
protected $text_prefix = 'COM_FIELDS';
/**
* Batch copy/move command. If set to false,
* the batch copy/move command is not supported
*
* @var string
* @since 3.4
*/
protected $batch_copymove = 'group_id';
/**
* Allowed batch commands
*
* @var array
*/
protected $batch_commands = array(
'assetgroup_id' => 'batchAccess',
'language_id' => 'batchLanguage'
);
/**
* @var array
*
* @since 3.7.0
*/
private $valueCache = array();
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JModelLegacy
* @since 3.7.0
*/
public function __construct($config = array())
{
parent::__construct($config);
$this->typeAlias =
JFactory::getApplication()->input->getCmd('context',
'com_content.article') . '.field';
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success, False on error.
*
* @since 3.7.0
*/
public function save($data)
{
$field = null;
if (isset($data['id']) && $data['id'])
{
$field = $this->getItem($data['id']);
}
if (!isset($data['label']) &&
isset($data['params']['label']))
{
$data['label'] = $data['params']['label'];
unset($data['params']['label']);
}
// Alter the title for save as copy
$input = JFactory::getApplication()->input;
if ($input->get('task') == 'save2copy')
{
$origTable = clone $this->getTable();
$origTable->load($input->getInt('id'));
if ($data['title'] == $origTable->title)
{
list($title, $name) =
$this->generateNewTitle($data['group_id'],
$data['name'], $data['title']);
$data['title'] = $title;
$data['label'] = $title;
$data['name'] = $name;
}
else
{
if ($data['name'] == $origTable->name)
{
$data['name'] = '';
}
}
$data['state'] = 0;
}
// Load the fields plugins, perhaps they want to do something
JPluginHelper::importPlugin('fields');
$message = $this->checkDefaultValue($data);
if ($message !== true)
{
$this->setError($message);
return false;
}
if (!parent::save($data))
{
return false;
}
// Save the assigned categories into #__fields_categories
$db = $this->getDbo();
$id = (int) $this->getState('field.id');
$cats = isset($data['assigned_cat_ids']) ? (array)
$data['assigned_cat_ids'] : array();
$cats = ArrayHelper::toInteger($cats);
$assignedCatIds = array();
foreach ($cats as $cat)
{
if ($cat)
{
$assignedCatIds[] = $cat;
}
}
// First delete all assigned categories
$query = $db->getQuery(true);
$query->delete('#__fields_categories')
->where('field_id = ' . $id);
$db->setQuery($query);
$db->execute();
// Inset new assigned categories
$tupel = new stdClass;
$tupel->field_id = $id;
foreach ($assignedCatIds as $catId)
{
$tupel->category_id = $catId;
$db->insertObject('#__fields_categories', $tupel);
}
// If the options have changed delete the values
if ($field &&
isset($data['fieldparams']['options']) &&
isset($field->fieldparams['options']))
{
$oldParams =
$this->getParams($field->fieldparams['options']);
$newParams =
$this->getParams($data['fieldparams']['options']);
if (is_object($oldParams) && is_object($newParams) &&
$oldParams != $newParams)
{
$names = array();
foreach ($newParams as $param)
{
$names[] = $db->q($param['value']);
}
$query = $db->getQuery(true);
$query->delete('#__fields_values')->where('field_id
= ' . (int) $field->id);
// If new values are set, delete only old values. Otherwise delete all
values.
if ($names)
{
$query->where('value NOT IN (' . implode(',',
$names) . ')');
}
$db->setQuery($query);
$db->execute();
}
}
FieldsHelper::clearFieldsCache();
return true;
}
/**
* Checks if the default value is valid for the given data. If a string is
returned then
* it can be assumed that the default value is invalid.
*
* @param array $data The data.
*
* @return true|string true if valid, a string containing the exception
message when not.
*
* @since 3.7.0
*/
private function checkDefaultValue($data)
{
// Empty default values are correct
if (empty($data['default_value']) &&
$data['default_value'] !== '0')
{
return true;
}
$types = FieldsHelper::getFieldTypes();
// Check if type exists
if (!key_exists($data['type'], $types))
{
return true;
}
$path = $types[$data['type']]['rules'];
// Add the path for the rules of the plugin when available
if ($path)
{
// Add the lookup path for the rule
JFormHelper::addRulePath($path);
}
// Create the fields object
$obj = (object) $data;
$obj->params = new Registry($obj->params);
$obj->fieldparams = new Registry(!empty($obj->fieldparams) ?
$obj->fieldparams : array());
// Prepare the dom
$dom = new DOMDocument;
$node = $dom->appendChild(new DOMElement('form'));
// Trigger the event to create the field dom node
JEventDispatcher::getInstance()->trigger('onCustomFieldsPrepareDom',
array($obj, $node, new JForm($data['context'])));
// Check if a node is created
if (!$node->firstChild)
{
return true;
}
// Define the type either from the field or from the data
$type = $node->firstChild->getAttribute('validate') ? :
$data['type'];
// Load the rule
$rule = JFormHelper::loadRuleType($type);
// When no rule exists, we allow the default value
if (!$rule)
{
return true;
}
try
{
// Perform the check
$result = $rule->test(simplexml_import_dom($node->firstChild),
$data['default_value']);
// Check if the test succeeded
return $result === true ? :
JText::_('COM_FIELDS_FIELD_INVALID_DEFAULT_VALUE');
}
catch (UnexpectedValueException $e)
{
return $e->getMessage();
}
}
/**
* Converts the unknown params into an object.
*
* @param mixed $params The params.
*
* @return stdClass Object on success, false on failure.
*
* @since 3.7.0
*/
private function getParams($params)
{
if (is_string($params))
{
$params = json_decode($params);
}
if (is_array($params))
{
$params = (object) $params;
}
return $params;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 3.7.0
*/
public function getItem($pk = null)
{
$result = parent::getItem($pk);
if ($result)
{
// Prime required properties.
if (empty($result->id))
{
$result->context =
JFactory::getApplication()->input->getCmd('context',
$this->getState('field.context'));
}
if (property_exists($result, 'fieldparams') &&
$result->fieldparams !== null)
{
$registry = new Registry;
$registry->loadString($result->fieldparams);
$result->fieldparams = $registry->toArray();
}
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select('category_id')
->from('#__fields_categories')
->where('field_id = ' . (int) $result->id);
$db->setQuery($query);
$result->assigned_cat_ids = $db->loadColumn() ?: array(0);
}
return $result;
}
/**
* Method to get a table object, load it if necessary.
*
* @param string $name The table name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $options Configuration array for model. Optional.
*
* @return JTable A JTable object
*
* @since 3.7.0
* @throws Exception
*/
public function getTable($name = 'Field', $prefix =
'FieldsTable', $options = array())
{
if (strpos(JPATH_COMPONENT, 'com_fields') === false)
{
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_fields/tables');
}
// Default to text type
$table = JTable::getInstance($name, $prefix, $options);
$table->type = 'text';
return $table;
}
/**
* Method to change the title & name.
*
* @param integer $categoryId The id of the category.
* @param string $name The name.
* @param string $title The title.
*
* @return array Contains the modified title and name.
*
* @since 3.7.0
*/
protected function generateNewTitle($categoryId, $name, $title)
{
// Alter the title & name
$table = $this->getTable();
while ($table->load(array('name' => $name)))
{
$title = StringHelper::increment($title);
$name = StringHelper::increment($name, 'dash');
}
return array(
$title,
$name,
);
}
/**
* Method to delete one or more records.
*
* @param array $pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 3.7.0
*/
public function delete(&$pks)
{
$success = parent::delete($pks);
if ($success)
{
$pks = (array) $pks;
$pks = ArrayHelper::toInteger($pks);
$pks = array_filter($pks);
if (!empty($pks))
{
// Delete Values
$query = $this->getDbo()->getQuery(true);
$query->delete($query->qn('#__fields_values'))
->where($query->qn('field_id') . ' IN(' .
implode(',', $pks) . ')');
$this->getDbo()->setQuery($query)->execute();
// Delete Assigned Categories
$query = $this->getDbo()->getQuery(true);
$query->delete($query->qn('#__fields_categories'))
->where($query->qn('field_id') . ' IN(' .
implode(',', $pks) . ')');
$this->getDbo()->setQuery($query)->execute();
}
}
return $success;
}
/**
* Abstract method for getting the form from the model.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 3.7.0
*/
public function getForm($data = array(), $loadData = true)
{
$context = $this->getState('field.context');
$jinput = JFactory::getApplication()->input;
// A workaround to get the context into the model for save requests.
if (empty($context) && isset($data['context']))
{
$context = $data['context'];
$parts = FieldsHelper::extract($context);
$this->setState('field.context', $context);
if ($parts)
{
$this->setState('field.component', $parts[0]);
$this->setState('field.section', $parts[1]);
}
}
if (isset($data['type']))
{
// This is needed that the plugins can determine the type
$this->setState('field.type', $data['type']);
}
// Load the fields plugin that they can add additional parameters to the
form
JPluginHelper::importPlugin('fields');
// Get the form.
$form = $this->loadForm(
'com_fields.field.' . $context, 'field',
array(
'control' => 'jform',
'load_data' => true,
)
);
if (empty($form))
{
return false;
}
// Modify the form based on Edit State access controls.
if (empty($data['context']))
{
$data['context'] = $context;
}
$fieldId = $jinput->get('id');
$assetKey = $this->state->get('field.component') .
'.field.' . $fieldId;
if (!JFactory::getUser()->authorise('core.edit.state',
$assetKey))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('state', 'disabled',
'true');
// Disable fields while saving. The controller has already verified this
is a record you can edit.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('state', 'filter',
'unset');
}
return $form;
}
/**
* Setting the value for the given field id, context and item id.
*
* @param string $fieldId The field ID.
* @param string $itemId The ID of the item.
* @param string $value The value.
*
* @return boolean
*
* @since 3.7.0
*/
public function setFieldValue($fieldId, $itemId, $value)
{
$field = $this->getItem($fieldId);
$params = $field->params;
if (is_array($params))
{
$params = new Registry($params);
}
// Don't save the value when the user is not authorized to change it
if (!$field || !FieldsHelper::canEditFieldValue($field))
{
return false;
}
$needsDelete = false;
$needsInsert = false;
$needsUpdate = false;
$oldValue = $this->getFieldValue($fieldId, $itemId);
$value = (array) $value;
if ($oldValue === null)
{
// No records available, doing normal insert
$needsInsert = true;
}
elseif (count($value) == 1 && count((array) $oldValue) == 1)
{
// Only a single row value update can be done when not empty
$needsUpdate = is_array($value[0]) ? count($value[0]) :
strlen($value[0]);
$needsDelete = !$needsUpdate;
}
else
{
// Multiple values, we need to purge the data and do a new
// insert
$needsDelete = true;
$needsInsert = true;
}
if ($needsDelete)
{
// Deleting the existing record as it is a reset
$query = $this->getDbo()->getQuery(true);
$query->delete($query->qn('#__fields_values'))
->where($query->qn('field_id') . ' = ' .
(int) $fieldId)
->where($query->qn('item_id') . ' = ' .
$query->q($itemId));
$this->getDbo()->setQuery($query)->execute();
}
if ($needsInsert)
{
$newObj = new stdClass;
$newObj->field_id = (int) $fieldId;
$newObj->item_id = $itemId;
foreach ($value as $v)
{
$newObj->value = $v;
$this->getDbo()->insertObject('#__fields_values',
$newObj);
}
}
if ($needsUpdate)
{
$updateObj = new stdClass;
$updateObj->field_id = (int) $fieldId;
$updateObj->item_id = $itemId;
$updateObj->value = reset($value);
$this->getDbo()->updateObject('#__fields_values',
$updateObj, array('field_id', 'item_id'));
}
$this->valueCache = array();
FieldsHelper::clearFieldsCache();
return true;
}
/**
* Returning the value for the given field id, context and item id.
*
* @param string $fieldId The field ID.
* @param string $itemId The ID of the item.
*
* @return NULL|string
*
* @since 3.7.0
*/
public function getFieldValue($fieldId, $itemId)
{
$values = $this->getFieldValues(array($fieldId), $itemId);
if (key_exists($fieldId, $values))
{
return $values[$fieldId];
}
return null;
}
/**
* Returning the values for the given field ids, context and item id.
*
* @param array $fieldIds The field Ids.
* @param string $itemId The ID of the item.
*
* @return NULL|array
*
* @since 3.7.0
*/
public function getFieldValues(array $fieldIds, $itemId)
{
if (!$fieldIds)
{
return array();
}
// Create a unique key for the cache
$key = md5(serialize($fieldIds) . $itemId);
// Fill the cache when it doesn't exist
if (!key_exists($key, $this->valueCache))
{
// Create the query
$query = $this->getDbo()->getQuery(true);
$query->select(array($query->qn('field_id'),
$query->qn('value')))
->from($query->qn('#__fields_values'))
->where($query->qn('field_id') . ' IN (' .
implode(',', ArrayHelper::toInteger($fieldIds)) . ')')
->where($query->qn('item_id') . ' = ' .
$query->q($itemId));
// Fetch the row from the database
$rows = $this->getDbo()->setQuery($query)->loadObjectList();
$data = array();
// Fill the data container from the database rows
foreach ($rows as $row)
{
// If there are multiple values for a field, create an array
if (key_exists($row->field_id, $data))
{
// Transform it to an array
if (!is_array($data[$row->field_id]))
{
$data[$row->field_id] = array($data[$row->field_id]);
}
// Set the value in the array
$data[$row->field_id][] = $row->value;
// Go to the next row, otherwise the value gets overwritten in the
data container
continue;
}
// Set the value
$data[$row->field_id] = $row->value;
}
// Assign it to the internal cache
$this->valueCache[$key] = $data;
}
// Return the value from the cache
return $this->valueCache[$key];
}
/**
* Cleaning up the values for the given item on the context.
*
* @param string $context The context.
* @param string $itemId The Item ID.
*
* @return void
*
* @since 3.7.0
*/
public function cleanupValues($context, $itemId)
{
// Delete with inner join is not possible so we need to do a subquery
$fieldsQuery = $this->getDbo()->getQuery(true);
$fieldsQuery->select($fieldsQuery->qn('id'))
->from($fieldsQuery->qn('#__fields'))
->where($fieldsQuery->qn('context') . ' = ' .
$fieldsQuery->q($context));
$query = $this->getDbo()->getQuery(true);
$query->delete($query->qn('#__fields_values'))
->where($query->qn('field_id') . ' IN (' .
$fieldsQuery . ')')
->where($query->qn('item_id') . ' = ' .
$query->q($itemId));
$this->getDbo()->setQuery($query)->execute();
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission for the component.
*
* @since 3.7.0
*/
protected function canDelete($record)
{
if (empty($record->id) || $record->state != -2)
{
return false;
}
$parts = FieldsHelper::extract($record->context);
return JFactory::getUser()->authorise('core.delete',
$parts[0] . '.field.' . (int) $record->id);
}
/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission for the
* component.
*
* @since 3.7.0
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$parts = FieldsHelper::extract($record->context);
// Check for existing field.
if (!empty($record->id))
{
return $user->authorise('core.edit.state', $parts[0] .
'.field.' . (int) $record->id);
}
return $user->authorise('core.edit.state', $parts[0]);
}
/**
* Stock method to auto-populate the model state.
*
* @return void
*
* @since 3.7.0
*/
protected function populateState()
{
$app = JFactory::getApplication('administrator');
// Load the User state.
$pk = $app->input->getInt('id');
$this->setState($this->getName() . '.id', $pk);
$context = $app->input->get('context',
'com_content.article');
$this->setState('field.context', $context);
$parts = FieldsHelper::extract($context);
// Extract the component name
$this->setState('field.component', $parts[0]);
// Extract the optional section name
$this->setState('field.section', (count($parts) > 1) ?
$parts[1] : null);
// Load the parameters.
$params = JComponentHelper::getParams('com_fields');
$this->setState('params', $params);
}
/**
* A protected method to get a set of ordering conditions.
*
* @param JTable $table A JTable object.
*
* @return array An array of conditions to add to ordering queries.
*
* @since 3.7.0
*/
protected function getReorderConditions($table)
{
return 'context = ' .
$this->_db->quote($table->context);
}
/**
* Method to get the data that should be injected in the form.
*
* @return array The default data is an empty array.
*
* @since 3.7.0
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$app = JFactory::getApplication();
$data = $app->getUserState('com_fields.edit.field.data',
array());
if (empty($data))
{
$data = $this->getItem();
// Pre-select some filters (Status, Language, Access) in edit form
// if those have been selected in Category Manager
if (!$data->id)
{
// Check for which context the Category Manager is used and
// get selected fields
$filters = (array)
$app->getUserState('com_fields.fields.filter');
$data->set('state',
$app->input->getInt('state',
((isset($filters['state']) && $filters['state']
!== '') ? $filters['state'] : null)));
$data->set('language',
$app->input->getString('language',
(!empty($filters['language']) ? $filters['language'] :
null)));
$data->set('group_id',
$app->input->getString('group_id',
(!empty($filters['group_id']) ? $filters['group_id'] :
null)));
$data->set(
'access',
$app->input->getInt('access',
(!empty($filters['access']) ? $filters['access'] :
JFactory::getConfig()->get('access')))
);
// Set the type if available from the request
$data->set('type',
$app->input->getWord('type',
$this->state->get('field.type',
$data->get('type'))));
}
if ($data->label &&
!isset($data->params['label']))
{
$data->params['label'] = $data->label;
}
}
$this->preprocessData('com_fields.field', $data);
return $data;
}
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return array|boolean Array of filtered data if valid, false
otherwise.
*
* @see JFormRule
* @see JFilterInput
* @since 3.9.23
*/
public function validate($form, $data, $group = null)
{
if (!JFactory::getUser()->authorise('core.admin',
'com_fields'))
{
if (isset($data['rules']))
{
unset($data['rules']);
}
}
return parent::validate($form, $data, $group);
}
/**
* Method to allow derived classes to preprocess the form.
*
* @param JForm $form A JForm object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @see JFormField
* @since 3.7.0
* @throws Exception if there is an error in the form event.
*/
protected function preprocessForm(JForm $form, $data, $group =
'content')
{
$component = $this->state->get('field.component');
$section = $this->state->get('field.section');
$dataObject = $data;
if (is_array($dataObject))
{
$dataObject = (object) $dataObject;
}
if (isset($dataObject->type))
{
$form->setFieldAttribute('type', 'component',
$component);
// Not allowed to change the type of an existing record
if ($dataObject->id)
{
$form->setFieldAttribute('type', 'readonly',
'true');
}
// Allow to override the default value label and description through the
plugin
$key = 'PLG_FIELDS_' . strtoupper($dataObject->type) .
'_DEFAULT_VALUE_LABEL';
if (JFactory::getLanguage()->hasKey($key))
{
$form->setFieldAttribute('default_value',
'label', $key);
}
$key = 'PLG_FIELDS_' . strtoupper($dataObject->type) .
'_DEFAULT_VALUE_DESC';
if (JFactory::getLanguage()->hasKey($key))
{
$form->setFieldAttribute('default_value',
'description', $key);
}
// Remove placeholder field on list fields
if ($dataObject->type == 'list')
{
$form->removeField('hint', 'params');
}
}
// Setting the context for the category field
$cat = JCategories::getInstance(str_replace('com_',
'', $component) . '.' . $section);
// If there is no category for the component and section, so check the
component only
if (!$cat)
{
$cat = JCategories::getInstance(str_replace('com_',
'', $component));
}
if ($cat && $cat->get('root')->hasChildren())
{
$form->setFieldAttribute('assigned_cat_ids',
'extension', $cat->getExtension());
}
else
{
$form->removeField('assigned_cat_ids');
}
$form->setFieldAttribute('type', 'component',
$component);
$form->setFieldAttribute('group_id', 'context',
$this->state->get('field.context'));
$form->setFieldAttribute('rules', 'component',
$component);
// Looking first in the component models/forms folder
$path = JPath::clean(JPATH_ADMINISTRATOR . '/components/' .
$component . '/models/forms/fields/' . $section .
'.xml');
if (file_exists($path))
{
$lang = JFactory::getLanguage();
$lang->load($component, JPATH_BASE, null, false, true);
$lang->load($component, JPATH_BASE . '/components/' .
$component, null, false, true);
if (!$form->loadFile($path, false))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
}
// Trigger the default form events.
parent::preprocessForm($form, $data, $group);
}
/**
* Clean the cache
*
* @param string $group The cache group
* @param integer $clientId The ID of the client
*
* @return void
*
* @since 3.7.0
*/
protected function cleanCache($group = null, $clientId = 0)
{
$context =
JFactory::getApplication()->input->get('context');
switch ($context)
{
case 'com_content':
parent::cleanCache('com_content');
parent::cleanCache('mod_articles_archive');
parent::cleanCache('mod_articles_categories');
parent::cleanCache('mod_articles_category');
parent::cleanCache('mod_articles_latest');
parent::cleanCache('mod_articles_news');
parent::cleanCache('mod_articles_popular');
break;
default:
parent::cleanCache($context);
break;
}
}
/**
* Batch copy fields to a new group.
*
* @param integer $value The new value matching a fields group.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return array|boolean new IDs if successful, false otherwise and
internal error is set.
*
* @since 3.7.0
*/
protected function batchCopy($value, $pks, $contexts)
{
// Set the variables
$user = JFactory::getUser();
$table = $this->getTable();
$newIds = array();
$component = $this->state->get('filter.component');
$value = (int) $value;
foreach ($pks as $pk)
{
if ($user->authorise('core.create', $component .
'.fieldgroup.' . $value))
{
$table->reset();
$table->load($pk);
$table->group_id = $value;
// Reset the ID because we are making a copy
$table->id = 0;
// Unpublish the new field
$table->state = 0;
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Get the new item ID
$newId = $table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'));
return false;
}
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move fields to a new group.
*
* @param integer $value The new value matching a fields group.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 3.7.0
*/
protected function batchMove($value, $pks, $contexts)
{
// Set the variables
$user = JFactory::getUser();
$table = $this->getTable();
$context = explode('.',
JFactory::getApplication()->getUserState('com_fields.fields.context'));
$value = (int) $value;
foreach ($pks as $pk)
{
if ($user->authorise('core.edit', $context[0] .
'.fieldgroup.' . $value))
{
$table->reset();
$table->load($pk);
$table->group_id = $value;
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
}
fields/fieldcontexts.php000064400000002742151164035040011402
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* Fields Contexts
*
* @since 3.7.0
*/
class JFormFieldFieldcontexts extends JFormFieldList
{
public $type = 'Fieldcontexts';
/**
* Method to get the field input markup for a generic list.
* Use the multiple attribute to enable multiselect.
*
* @return string The field input markup.
*
* @since 3.7.0
*/
protected function getInput()
{
return $this->getOptions() ? parent::getInput() : '';
}
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.7.0
*/
protected function getOptions()
{
$parts = explode('.', $this->value);
$eName = str_replace('com_', '', $parts[0]);
$file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' .
$parts[0] . '/helpers/' . $eName . '.php');
$contexts = array();
if (!file_exists($file))
{
return array();
}
$prefix = ucfirst($eName);
$cName = $prefix . 'Helper';
JLoader::register($cName, $file);
if (class_exists($cName) && is_callable(array($cName,
'getContexts')))
{
$contexts = $cName::getContexts();
}
if (!$contexts || !is_array($contexts) || count($contexts) == 1)
{
return array();
}
return $contexts;
}
}
fields/fieldgroups.php000064400000003122151164035040011043 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JFormHelper::loadFieldClass('list');
/**
* Fields Groups
*
* @since 3.7.0
*/
class JFormFieldFieldgroups extends JFormFieldList
{
public $type = 'Fieldgroups';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.7.0
*/
protected function getOptions()
{
$context = (string) $this->element['context'];
$states = $this->element['state'] ?: '0,1';
$states = ArrayHelper::toInteger(explode(',', $states));
$user = JFactory::getUser();
$viewlevels =
ArrayHelper::toInteger($user->getAuthorisedViewLevels());
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('title AS text, id AS value, state');
$query->from('#__fields_groups');
$query->where('state IN (' . implode(',', $states)
. ')');
$query->where('context = ' . $db->quote($context));
$query->where('access IN (' . implode(',',
$viewlevels) . ')');
$query->order('ordering asc, id asc');
$db->setQuery($query);
$options = $db->loadObjectList();
foreach ($options AS $option)
{
if ($option->state == 0)
{
$option->text = '[' . $option->text . ']';
}
if ($option->state == 2)
{
$option->text = '{' . $option->text . '}';
}
}
return array_merge(parent::getOptions(), $options);
}
}
fields/fieldlayout.php000064400000011066151164035040011047 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.filesystem.folder');
/**
* Form Field to display a list of the layouts for a field from
* the extension or template overrides.
*
* @since 3.9.0
*/
class JFormFieldFieldlayout extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 3.9.0
*/
protected $type = 'FieldLayout';
/**
* Method to get the field input for a field layout field.
*
* @return string The field input.
*
* @since 3.9.0
*/
protected function getInput()
{
$extension = explode('.',
$this->form->getValue('context'));
$extension = $extension[0];
if ($extension)
{
// Get the database object and a new query object.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Build the query.
$query->select('element, name')
->from('#__extensions')
->where('client_id = 0')
->where('type = ' . $db->quote('template'))
->where('enabled = 1');
// Set the query and load the templates.
$db->setQuery($query);
$templates = $db->loadObjectList('element');
// Build the search paths for component layouts.
$component_path = JPath::clean(JPATH_SITE . '/components/' .
$extension . '/layouts/field');
// Prepare array of component layouts
$component_layouts = array();
// Prepare the grouped list
$groups = array();
// Add "Use Default"
$groups[]['items'][] = JHtml::_('select.option',
'', JText::_('JOPTION_USE_DEFAULT'));
// Add the layout options from the component path.
if (is_dir($component_path) && ($component_layouts =
JFolder::files($component_path, '^[^_]*\.php$', false, true)))
{
// Create the group for the component
$groups['_'] = array();
$groups['_']['id'] = $this->id . '__';
$groups['_']['text'] =
JText::sprintf('JOPTION_FROM_COMPONENT');
$groups['_']['items'] = array();
foreach ($component_layouts as $i => $file)
{
// Add an option to the component group
$value = basename($file, '.php');
$component_layouts[$i] = $value;
if ($value === 'render')
{
continue;
}
$groups['_']['items'][] =
JHtml::_('select.option', $value, $value);
}
}
// Loop on all templates
if ($templates)
{
foreach ($templates as $template)
{
$files = array();
$template_paths = array(
JPath::clean(JPATH_SITE . '/templates/' .
$template->element . '/html/layouts/' . $extension .
'/field'),
JPath::clean(JPATH_SITE . '/templates/' .
$template->element . '/html/layouts/com_fields/field'),
JPath::clean(JPATH_SITE . '/templates/' .
$template->element . '/html/layouts/field'),
);
// Add the layout options from the template paths.
foreach ($template_paths as $template_path)
{
if (is_dir($template_path))
{
$files = array_merge($files, JFolder::files($template_path,
'^[^_]*\.php$', false, true));
}
}
foreach ($files as $i => $file)
{
$value = basename($file, '.php');
// Remove the default "render.php" or layout files that
exist in the component folder
if ($value === 'render' || in_array($value,
$component_layouts))
{
unset($files[$i]);
}
}
if (count($files))
{
// Create the group for the template
$groups[$template->name] = array();
$groups[$template->name]['id'] = $this->id .
'_' . $template->element;
$groups[$template->name]['text'] =
JText::sprintf('JOPTION_FROM_TEMPLATE', $template->name);
$groups[$template->name]['items'] = array();
foreach ($files as $file)
{
// Add an option to the template group
$value = basename($file, '.php');
$groups[$template->name]['items'][] =
JHtml::_('select.option', $value, $value);
}
}
}
}
// Compute attributes for the grouped list
$attr = $this->element['size'] ? ' size="' .
(int) $this->element['size'] . '"' :
'';
$attr .= $this->element['class'] ? '
class="' . (string) $this->element['class'] .
'"' : '';
// Prepare HTML code
$html = array();
// Compute the current selected values
$selected = array($this->value);
// Add a grouped list
$html[] = JHtml::_(
'select.groupedlist', $groups, $this->name,
array('id' => $this->id, 'group.id' =>
'id', 'list.attr' => $attr, 'list.select'
=> $selected)
);
return implode($html);
}
return '';
}
}
fields/section.php000064400000004047151164035040010173 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* Fields Section
*
* @since 3.7.0
*/
class JFormFieldSection extends JFormFieldList
{
public $type = 'Section';
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @since 3.7.0
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
// Onchange must always be the change context function
$this->onchange =
'fieldsChangeContext(jQuery(this).val());';
return $return;
}
/**
* Method to get the field input markup for a generic list.
* Use the multiple attribute to enable multiselect.
*
* @return string The field input markup.
*
* @since 3.7.0
*/
protected function getInput()
{
// Add the change context function to the document
JFactory::getDocument()->addScriptDeclaration(
"function fieldsChangeContext(context)
{
var regex = new
RegExp(\"([?;&])context[^&;]*[;&]?\");
var url = window.location.href;
var query = url.replace(regex, \"$1\").replace(/&$/,
'');
window.location.href = (query.length > 2 ? query +
\"&\" : \"?\") + (context ? \"context=\"
+ context : '');
}"
);
return parent::getInput();
}
}
fields.php000064400000025426151164035040006533 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
/**
* Fields Model
*
* @since 3.7.0
*/
class FieldsModelFields extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JModelLegacy
* @since 3.7.0
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'type', 'a.type',
'name', 'a.name',
'state', 'a.state',
'access', 'a.access',
'access_level',
'language', 'a.language',
'ordering', 'a.ordering',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'created_time', 'a.created_time',
'created_user_id', 'a.created_user_id',
'group_title', 'g.title',
'category_id', 'a.category_id',
'group_id', 'a.group_id',
'assigned_cat_ids'
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* This method should only be called once per instantiation and is
designed
* to be called on the first call to the getState() method unless the
model
* configuration flag to ignore the request is set.
*
* 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 3.7.0
*/
protected function populateState($ordering = null, $direction = null)
{
// List state information.
parent::populateState('a.ordering', 'asc');
$context = $this->getUserStateFromRequest($this->context .
'.context', 'context', 'com_content.article',
'CMD');
$this->setState('filter.context', $context);
// Split context into component and optional section
$parts = FieldsHelper::extract($context);
if ($parts)
{
$this->setState('filter.component', $parts[0]);
$this->setState('filter.section', $parts[1]);
}
}
/**
* Method to get a store id based on the model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id An identifier string to generate the store id.
*
* @return string A store id.
*
* @since 3.7.0
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.context');
$id .= ':' .
serialize($this->getState('filter.assigned_cat_ids'));
$id .= ':' . $this->getState('filter.state');
$id .= ':' . $this->getState('filter.group_id');
$id .= ':' .
serialize($this->getState('filter.language'));
return parent::getStoreId($id);
}
/**
* Method to get a JDatabaseQuery object for retrieving the data set from
a database.
*
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data
set.
*
* @since 3.7.0
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
$app = JFactory::getApplication();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'DISTINCT a.id, a.title, a.name, a.checked_out,
a.checked_out_time, a.note' .
', a.state, a.access, a.created_time, a.created_user_id,
a.ordering, a.language' .
', a.fieldparams, a.params, a.type, a.default_value, a.context,
a.group_id' .
', a.label, a.description, a.required'
)
);
$query->from('#__fields AS a');
// Join over the language
$query->select('l.title AS language_title, l.image AS
language_image')
->join('LEFT', $db->quoteName('#__languages')
. ' AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS
editor')->join('LEFT', '#__users AS uc ON
uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS
access_level')->join('LEFT', '#__viewlevels AS ag ON
ag.id = a.access');
// Join over the users for the author.
$query->select('ua.name AS
author_name')->join('LEFT', '#__users AS ua ON ua.id
= a.created_user_id');
// Join over the field groups.
$query->select('g.title AS group_title, g.access as group_access,
g.state AS group_state, g.note as group_note');
$query->join('LEFT', '#__fields_groups AS g ON g.id =
a.group_id');
// Filter by context
if ($context = $this->getState('filter.context'))
{
$query->where('a.context = ' . $db->quote($context));
}
// Filter by access level.
if ($access = $this->getState('filter.access'))
{
if (is_array($access))
{
$access = ArrayHelper::toInteger($access);
$query->where('a.access in (' . implode(',',
$access) . ')');
}
else
{
$query->where('a.access = ' . (int) $access);
}
}
if (($categories =
$this->getState('filter.assigned_cat_ids')) &&
$context)
{
$categories = (array) $categories;
$categories = ArrayHelper::toInteger($categories);
$parts = FieldsHelper::extract($context);
if ($parts)
{
// Get the category
$cat = JCategories::getInstance(str_replace('com_',
'', $parts[0]) . '.' . $parts[1]);
// If there is no category for the component and section, so check the
component only
if (!$cat)
{
$cat = JCategories::getInstance(str_replace('com_',
'', $parts[0]));
}
if ($cat)
{
foreach ($categories as $assignedCatIds)
{
// Check if we have the actual category
$parent = $cat->get($assignedCatIds);
if ($parent)
{
$categories[] = (int) $parent->id;
// Traverse the tree up to get all the fields which are attached to
a parent
while ($parent->getParent() &&
$parent->getParent()->id != 'root')
{
$parent = $parent->getParent();
$categories[] = (int) $parent->id;
}
}
}
}
}
$categories = array_unique($categories);
// Join over the assigned categories
$query->join('LEFT',
$db->quoteName('#__fields_categories') . ' AS fc ON
fc.field_id = a.id');
if (in_array('0', $categories))
{
$query->where('(fc.category_id IS NULL OR fc.category_id IN
(' . implode(',', $categories) . '))');
}
else
{
$query->where('fc.category_id IN (' .
implode(',', $categories) . ')');
}
}
// Implement View Level Access
if (!$app->isClient('administrator') ||
!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ') AND
(a.group_id = 0 OR g.access IN (' . $groups . '))');
}
// Filter by state
$state = $this->getState('filter.state');
// Include group state only when not on on back end list
$includeGroupState = !$app->isClient('administrator') ||
$app->input->get('option') != 'com_fields' ||
$app->input->get('view') != 'fields';
if (is_numeric($state))
{
$query->where('a.state = ' . (int) $state);
if ($includeGroupState)
{
$query->where('(a.group_id = 0 OR g.state = ' . (int)
$state . ')');
}
}
elseif (!$state)
{
$query->where('a.state IN (0, 1)');
if ($includeGroupState)
{
$query->where('(a.group_id = 0 OR g.state IN (0, 1))');
}
}
$groupId = $this->getState('filter.group_id');
if (is_numeric($groupId))
{
$query->where('a.group_id = ' . (int) $groupId);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (! empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
elseif (stripos($search, 'author:') === 0)
{
$search = $db->quote('%' . $db->escape(substr($search,
7), true) . '%');
$query->where('(ua.name LIKE ' . $search . ' OR
ua.username LIKE ' . $search . ')');
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('(a.title LIKE ' . $search . ' OR
a.name LIKE ' . $search . ' OR a.note LIKE ' . $search .
')');
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$language = (array) $language;
foreach ($language as $key => $l)
{
$language[$key] = $db->quote($l);
}
$query->where('a.language in (' . implode(',',
$language) . ')');
}
// Add the list ordering clause
$listOrdering = $this->state->get('list.ordering',
'a.ordering');
$orderDirn = $this->state->get('list.direction',
'ASC');
$query->order($db->escape($listOrdering) . ' ' .
$db->escape($orderDirn));
return $query;
}
/**
* Gets an array of objects from the results of database query.
*
* @param string $query The query.
* @param integer $limitstart Offset.
* @param integer $limit The number of records.
*
* @return array An array of results.
*
* @since 3.7.0
* @throws RuntimeException
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$result = parent::_getList($query, $limitstart, $limit);
if (is_array($result))
{
foreach ($result as $field)
{
$field->fieldparams = new Registry($field->fieldparams);
$field->params = new Registry($field->params);
}
}
return $result;
}
/**
* Get the filter form
*
* @param array $data data
* @param boolean $loadData load current data
*
* @return JForm|false the JForm object or false
*
* @since 3.7.0
*/
public function getFilterForm($data = array(), $loadData = true)
{
$form = parent::getFilterForm($data, $loadData);
if ($form)
{
$form->setValue('context', null,
$this->getState('filter.context'));
$form->setFieldAttribute('group_id', 'context',
$this->getState('filter.context'), 'filter');
$form->setFieldAttribute('assigned_cat_ids',
'extension',
$this->state->get('filter.component'), 'filter');
}
return $form;
}
/**
* Get the groups for the batch method
*
* @return array An array of groups
*
* @since 3.7.0
*/
public function getGroups()
{
$user = JFactory::getUser();
$viewlevels =
ArrayHelper::toInteger($user->getAuthorisedViewLevels());
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select('title AS text, id AS value, state');
$query->from('#__fields_groups');
$query->where('state IN (0,1)');
$query->where('context = ' .
$db->quote($this->state->get('filter.context')));
$query->where('access IN (' . implode(',',
$viewlevels) . ')');
$db->setQuery($query);
return $db->loadObjectList();
}
}
forms/field.xml000064400000016071151164035040007503 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_categories/models/fields"
>
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
default="0"
class="readonly"
readonly="true"
/>
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<field
name="context"
type="hidden"
/>
<field
name="group_id"
type="fieldgroups"
label="COM_FIELDS_FIELD_GROUP_LABEL"
description="COM_FIELDS_FIELD_GROUP_DESC"
>
<option value="0">JNONE</option>
</field>
<field
name="assigned_cat_ids"
type="category"
label="JCATEGORY"
description="JFIELD_FIELDS_CATEGORY_DESC"
extension="com_content"
multiple="true"
>
<option value="">JALL</option>
</field>
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="JFIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="name"
type="text"
label="JFIELD_NAME_LABEL"
description="JFIELD_NAME_DESC"
hint="JFIELD_NAME_PLACEHOLDER"
size="45"
/>
<field
name="type"
type="type"
label="COM_FIELDS_FIELD_TYPE_LABEL"
description="COM_FIELDS_FIELD_TYPE_DESC"
default="text"
required="true"
/>
<field
name="required"
type="radio"
label="COM_FIELDS_FIELD_REQUIRED_LABEL"
description="COM_FIELDS_FIELD_REQUIRED_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="default_value"
type="textarea"
label="COM_FIELDS_FIELD_DEFAULT_VALUE_LABEL"
description="COM_FIELDS_FIELD_DEFAULT_VALUE_DESC"
filter="raw"
/>
<field
name="state"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
class="chzn-color-state"
default="1"
size="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="buttonspacer"
type="spacer"
label="JGLOBAL_ACTION_PERMISSIONS_LABEL"
description="JGLOBAL_ACTION_PERMISSIONS_DESCRIPTION"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="created_user_id"
type="user"
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
description="JGLOBAL_FIELD_CREATED_BY_DESC"
/>
<field
name="created_time"
type="calendar"
label="JGLOBAL_CREATED_DATE"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="modified_by"
type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
filter="unset"
/>
<field
name="modified_time"
type="calendar"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
class="readonly"
translateformat="true"
showtime="true"
size="22"
readonly="true"
filter="user_utc"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_FIELDS_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
<field
name="note"
type="text"
label="COM_FIELDS_FIELD_NOTE_LABEL"
description="COM_FIELDS_FIELD_NOTE_DESC"
class="span12"
size="40"
/>
<field
name="label"
type="text"
label="COM_FIELDS_FIELD_LABEL_LABEL"
description="COM_FIELDS_FIELD_LABEL_DESC"
size="40"
hint="JFIELD_ALIAS_PLACEHOLDER"
/>
<field
name="description"
type="textarea"
label="JGLOBAL_DESCRIPTION"
description="COM_FIELDS_FIELD_DESCRIPTION_DESC"
size="40"
filter="HTML"
/>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
/>
<field
name="rules"
type="rules"
label="JFIELD_RULES_LABEL"
id="rules"
translate_label="false"
filter="rules"
validate="rules"
section="field"
/>
<field
name="ordering"
type="text"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
class="inputbox"
/>
</fieldset>
<fields name="params"
label="COM_FIELDS_FIELD_BASIC_LABEL">
<fieldset name="basic">
<field
name="formoptions"
type="note"
label="COM_FIELDS_FIELD_FORMOPTIONS_HEADING"
/>
<field
name="hint"
type="text"
label="COM_FIELDS_FIELD_PLACEHOLDER_LABEL"
description="COM_FIELDS_FIELD_PLACEHOLDER_DESC"
class="input-xxlarge"
size="40"
/>
<field
name="class"
type="textarea"
label="COM_FIELDS_FIELD_CLASS_LABEL"
description="COM_FIELDS_FIELD_CLASS_DESC"
class="input-xxlarge"
size="40"
/>
<field
name="label_class"
type="textarea"
label="COM_FIELDS_FIELD_LABEL_FORM_CLASS_LABEL"
description="COM_FIELDS_FIELD_LABEL_FORM_CLASS_DESC"
class="input-xxlarge"
size="40"
/>
<field
name="show_on"
type="radio"
label="COM_FIELDS_FIELD_EDITABLE_IN_LABEL"
description="COM_FIELDS_FIELD_EDITABLE_IN_DESC"
class="btn-group btn-group-yesno"
default=""
>
<option
value="1">COM_FIELDS_FIELD_EDITABLE_IN_SITE</option>
<option
value="2">COM_FIELDS_FIELD_EDITABLE_IN_ADMIN</option>
<option
value="">COM_FIELDS_FIELD_EDITABLE_IN_BOTH</option>
</field>
<field
name="renderoptions"
type="note"
label="COM_FIELDS_FIELD_RENDEROPTIONS_HEADING"
/>
<field
name="render_class"
type="textarea"
label="COM_FIELDS_FIELD_RENDER_CLASS_LABEL"
description="COM_FIELDS_FIELD_RENDER_CLASS_DESC"
class="input-xxlarge"
size="40"
/>
<field
name="showlabel"
type="radio"
label="COM_FIELDS_FIELD_SHOWLABEL_LABEL"
description="COM_FIELDS_FIELD_SHOWLABEL_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="label_render_class"
type="textarea"
label="COM_FIELDS_FIELD_LABEL_RENDER_CLASS_LABEL"
description="COM_FIELDS_FIELD_LABEL_RENDER_CLASS_DESC"
class="input-xxlarge"
size="40"
showon="showlabel:1"
/>
<field
name="display"
type="list"
label="COM_FIELDS_FIELD_DISPLAY_LABEL"
description="COM_FIELDS_FIELD_DISPLAY_DESC"
default="2"
>
<option
value="1">COM_FIELDS_FIELD_DISPLAY_AFTER_TITLE</option>
<option
value="2">COM_FIELDS_FIELD_DISPLAY_BEFORE_DISPLAY</option>
<option
value="3">COM_FIELDS_FIELD_DISPLAY_AFTER_DISPLAY</option>
<option
value="0">COM_FIELDS_FIELD_DISPLAY_NO_DISPLAY</option>
</field>
<field
name="layout"
type="fieldlayout"
label="COM_FIELDS_FIELD_LAYOUT_LABEL"
description="COM_FIELDS_FIELD_LAYOUT_DESC"
/>
<field
name="display_readonly"
type="radio"
label="JFIELD_DISPLAY_READONLY_LABEL"
description="JFIELD_DISPLAY_READONLY_DESC"
class="btn-group btn-group-yesno"
default="2"
>
<option value="2">JGLOBAL_INHERIT</option>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</form>
forms/filter_fields.xml000064400000005365151164035040011237
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset name="group">
<field
name="context"
type="fieldcontexts"
onchange="this.form.submit();"
/>
</fieldset>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label=""
description="COM_FIELDS_FIELDS_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
class="js-stools-search-string"
/>
<field
name="state"
type="status"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="group_id"
type="fieldgroups"
state="0,1,2"
onchange="this.form.submit();"
>
<option
value="">COM_FIELDS_VIEW_FIELDS_SELECT_GROUP</option>
</field>
<field
name="assigned_cat_ids"
type="category"
onchange="this.form.submit();"
>
<option
value="">COM_FIELDS_VIEW_FIELDS_SELECT_CATEGORY</option>
</field>
<field
name="access"
type="accesslevel"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_ACCESS</option>
</field>
<field
name="language"
type="contentlanguage"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
statuses="*,0,1,2,-2"
onchange="this.form.submit();"
default="a.ordering ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.type
ASC">COM_FIELDS_VIEW_FIELDS_SORT_TYPE_ASC</option>
<option value="a.type
DESC">COM_FIELDS_VIEW_FIELDS_SORT_TYPE_DESC</option>
<option value="g.title
ASC">COM_FIELDS_VIEW_FIELDS_SORT_GROUP_ASC</option>
<option value="g.title
DESC">COM_FIELDS_VIEW_FIELDS_SORT_GROUP_DESC</option>
<option value="a.access
ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="a.access
DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="a.language
ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="a.language
DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_FIELDS_LIST_LIMIT"
description="COM_FIELDS_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
fields/componentscategory.php000064400000003421151164367550012463
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JFormHelper::loadFieldClass('list');
/**
* Components Category field.
*
* @since 1.6
*/
class JFormFieldComponentsCategory extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.7.0
*/
protected $type = 'ComponentsCategory';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*
* @since 3.7.0
*/
protected function getOptions()
{
// Initialise variable.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT a.name AS text, a.element AS value')
->from('#__extensions as a')
->where('a.enabled >= 1')
->where('a.type =' . $db->quote('component'))
->join('INNER', '#__categories as b ON
a.element=b.extension');
$items = $db->setQuery($query)->loadObjectList();
if (count($items))
{
$lang = JFactory::getLanguage();
foreach ($items as &$item)
{
// Load language
$extension = $item->value;
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null,
false, true)
|| $lang->load("$extension.sys", $source, null, false,
true);
// Translate component name
$item->text = JText::_($item->text);
}
// Sort by component name
$items = ArrayHelper::sortObjects($items, 'text', 1, true,
true);
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $items);
return $options;
}
}
fields/menuitembytype.php000064400000014402151164367550011621
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('groupedlist');
// Import the com_menus helper.
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR .
'/components/com_menus/helpers/menus.php');
/**
* Supports an HTML grouped select list of menu item grouped by menu
*
* @since 3.8.0
*/
class JFormFieldMenuitemByType extends JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 3.8.0
*/
public $type = 'MenuItemByType';
/**
* The menu type.
*
* @var string
* @since 3.8.0
*/
protected $menuType;
/**
* The client id.
*
* @var string
* @since 3.8.0
*/
protected $clientId;
/**
* The language.
*
* @var array
* @since 3.8.0
*/
protected $language;
/**
* The published status.
*
* @var array
* @since 3.8.0
*/
protected $published;
/**
* The disabled status.
*
* @var array
* @since 3.8.0
*/
protected $disable;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.8.0
*/
public function __get($name)
{
switch ($name)
{
case 'menuType':
case 'clientId':
case 'language':
case 'published':
case 'disable':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.8.0
*/
public function __set($name, $value)
{
switch ($name)
{
case 'menuType':
$this->menuType = (string) $value;
break;
case 'clientId':
$this->clientId = (int) $value;
break;
case 'language':
case 'published':
case 'disable':
$value = (string) $value;
$this->$name = $value ? explode(',', $value) : array();
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.8.0
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result == true)
{
$menuType = (string) $this->element['menu_type'];
if (!$menuType)
{
$app = JFactory::getApplication('administrator');
$currentMenuType =
$app->getUserState('com_menus.items.menutype', '');
$menuType = $app->input->getString('menutype',
$currentMenuType);
}
$this->menuType = $menuType;
$this->clientId = (int) $this->element['client_id'];
$this->published = $this->element['published'] ?
explode(',', (string) $this->element['published']) :
array();
$this->disable = $this->element['disable'] ?
explode(',', (string) $this->element['disable']) :
array();
$this->language = $this->element['language'] ?
explode(',', (string) $this->element['language']) :
array();
}
return $result;
}
/**
* Method to get the field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 3.8.0
*/
protected function getGroups()
{
$groups = array();
$menuType = $this->menuType;
// Get the menu items.
$items = MenusHelper::getMenuLinks($menuType, 0, 0, $this->published,
$this->language, $this->clientId);
// Build group for a specific menu type.
if ($menuType)
{
// If the menutype is empty, group the items by menutype.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__menu_types'))
->where($db->quoteName('menutype') . ' = ' .
$db->quote($menuType));
$db->setQuery($query);
try
{
$menuTitle = $db->loadResult();
}
catch (RuntimeException $e)
{
$menuTitle = $menuType;
}
// Initialize the group.
$groups[$menuTitle] = array();
// Build the options array.
foreach ($items as $key => $link)
{
// Unset if item is menu_item_root
if ($link->text === 'Menu_Item_Root')
{
unset($items[$key]);
continue;
}
$levelPrefix = str_repeat('- ', max(0, $link->level - 1));
// Displays language code if not set to All
if ($link->language !== '*')
{
$lang = ' (' . $link->language . ')';
}
else
{
$lang = '';
}
$groups[$menuTitle][] = JHtml::_('select.option',
$link->value, $levelPrefix . $link->text . $lang,
'value',
'text',
in_array($link->type, $this->disable)
);
}
}
// Build groups for all menu types.
else
{
// Build the groups arrays.
foreach ($items as $menu)
{
// Initialize the group.
$groups[$menu->title] = array();
// Build the options array.
foreach ($menu->links as $link)
{
$levelPrefix = str_repeat('- ', max(0, $link->level -
1));
// Displays language code if not set to All
if ($link->language !== '*')
{
$lang = ' (' . $link->language . ')';
}
else
{
$lang = '';
}
$groups[$menu->title][] = JHtml::_('select.option',
$link->value,
$levelPrefix . $link->text . $lang,
'value',
'text',
in_array($link->type, $this->disable)
);
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
}
fields/menuordering.php000064400000004716151164367550011246
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* Menu Ordering field.
*
* @since 1.6
*/
class JFormFieldMenuOrdering extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.7
*/
protected $type = 'MenuOrdering';
/**
* Method to get the list of siblings in a menu.
* The method requires that parent be set.
*
* @return array The field option objects or false if the parent field
has not been set
*
* @since 1.7
*/
protected function getOptions()
{
$options = array();
// Get the parent
$parent_id = $this->form->getValue('parent_id', 0);
if (empty($parent_id))
{
return false;
}
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.id AS value, a.title AS text, a.client_id AS '
. $db->quoteName('clientId'))
->from('#__menu AS a')
->where('a.published >= 0')
->where('a.parent_id =' . (int) $parent_id);
if ($menuType = $this->form->getValue('menutype'))
{
$query->where('a.menutype = ' . $db->quote($menuType));
}
else
{
$query->where('a.menutype != ' .
$db->quote(''));
}
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
// Allow translation of custom admin menus
foreach ($options as &$option)
{
if ($option->clientId != 0)
{
$option->text = JText::_($option->text);
}
}
$options = array_merge(
array(array('value' => '-1', 'text'
=> JText::_('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_FIRST'))),
$options,
array(array('value' => '-2', 'text'
=> JText::_('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_LAST')))
);
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.7
*/
protected function getInput()
{
if ($this->form->getValue('id', 0) == 0)
{
return '<span class="readonly">' .
JText::_('COM_MENUS_ITEM_FIELD_ORDERING_TEXT') .
'</span>';
}
else
{
return parent::getInput();
}
}
}
fields/menuparent.php000064400000004524151164367550010723 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* Menu Parent field.
*
* @since 1.6
*/
class JFormFieldMenuParent extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'MenuParent';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.6
*/
protected function getOptions()
{
$options = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT(a.id) AS value, a.title AS text, a.level,
a.lft')
->from('#__menu AS a');
// Filter by menu type.
if ($menuType = $this->form->getValue('menutype'))
{
$query->where('a.menutype = ' . $db->quote($menuType));
}
else
{
// Skip special menu types
$query->where('a.menutype != ' .
$db->quote(''));
$query->where('a.menutype != ' .
$db->quote('main'));
}
// Filter by client id.
$clientId = $this->getAttribute('clientid');
if (!is_null($clientId))
{
$query->where($db->quoteName('a.client_id') . ' =
' . (int) $clientId);
}
// Prevent parenting to children of this item.
if ($id = $this->form->getValue('id'))
{
$query->join('LEFT', $db->quoteName('#__menu')
. ' AS p ON p.id = ' . (int) $id)
->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
}
$query->where('a.published != -2')
->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
// Pad the option text with spaces using depth level as a multiplier.
for ($i = 0, $n = count($options); $i < $n; $i++)
{
if ($clientId != 0)
{
// Allow translation of custom admin menus
$options[$i]->text = str_repeat('- ',
$options[$i]->level) . JText::_($options[$i]->text);
}
else
{
$options[$i]->text = str_repeat('- ',
$options[$i]->level) . $options[$i]->text;
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
fields/menupreset.php000064400000001732151164367550010732 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Menu\MenuHelper;
JFormHelper::loadFieldClass('list');
/**
* Administrator Menu Presets list field.
*
* @since 3.8.0
*/
class JFormFieldMenuPreset extends JFormFieldList
{
/**
* The form field type.
*
* @var string
*
* @since 3.8.0
*/
protected $type = 'MenuPreset';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.8.0
*/
protected function getOptions()
{
$options = array();
$presets = MenuHelper::getPresets();
foreach ($presets as $preset)
{
$options[] = JHtml::_('select.option', $preset->name,
JText::_($preset->title));
}
return array_merge(parent::getOptions(), $options);
}
}
fields/menutype.php000064400000006657151164367550010424 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JFormHelper::loadFieldClass('list');
/**
* Menu Type field.
*
* @since 1.6
*/
class JFormFieldMenutype extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'menutype';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$html = array();
$recordId = (int) $this->form->getValue('id');
$size = (string) ($v = $this->element['size']) ? '
size="' . $v . '"' : '';
$class = (string) ($v = $this->element['class']) ? '
class="' . $v . '"' :
'class="text_area"';
$required = (string) $this->element['required'] ? '
required="required"' : '';
$clientId = (int) $this->element['clientid'] ?: 0;
// Get a reverse lookup of the base link URL to Title
switch ($this->value)
{
case 'url':
$value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
break;
case 'alias':
$value = JText::_('COM_MENUS_TYPE_ALIAS');
break;
case 'separator':
$value = JText::_('COM_MENUS_TYPE_SEPARATOR');
break;
case 'heading':
$value = JText::_('COM_MENUS_TYPE_HEADING');
break;
case 'container':
$value = JText::_('COM_MENUS_TYPE_CONTAINER');
break;
default:
$link = $this->form->getValue('link');
/** @var MenusModelMenutypes $model */
$model = JModelLegacy::getInstance('Menutypes',
'MenusModel', array('ignore_request' => true));
$model->setState('client_id', $clientId);
$rlu = $model->getReverseLookup();
// Clean the link back to the option, view and layout
$value = JText::_(ArrayHelper::getValue($rlu,
MenusHelper::getLinkKey($link)));
break;
}
// Include jQuery
JHtml::_('jquery.framework');
// Add the script to the document head.
JFactory::getDocument()->addScriptDeclaration('
function jSelectPosition_' . $this->id . '(name) {
document.getElementById("' . $this->id .
'").value = name;
}
'
);
$link =
JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&client_id='
. $clientId . '&recordId=' . $recordId);
$html[] = '<span class="input-append"><input
type="text" ' . $required . '
readonly="readonly" id="' . $this->id
. '" value="' . $value . '" ' . $size
. $class . ' />';
$html[] = '<button type="button"
data-target="#menuTypeModal" class="btn btn-primary"
data-toggle="modal" title="' .
JText::_('JSELECT') . '">'
. '<span class="icon-list icon-white"
aria-hidden="true"></span> '
. JText::_('JSELECT') .
'</button></span>';
$html[] = JHtml::_(
'bootstrap.renderModal',
'menuTypeModal',
array(
'url' => $link,
'title' =>
JText::_('COM_MENUS_ITEM_FIELD_TYPE_LABEL'),
'width' => '800px',
'height' => '300px',
'modalWidth' => '80',
'bodyHeight' => '70',
'footer' => '<button type="button"
class="btn" data-dismiss="modal">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') .
'</button>'
)
);
$html[] = '<input class="input-small"
type="hidden" name="' . $this->name . '"
value="'
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') .
'" />';
return implode("\n", $html);
}
}
fields/modal/menu.php000064400000031665151164367550010613 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\LanguageHelper;
JHtml::_('bootstrap.tooltip', '.hasTooltip');
/**
* Supports a modal menu item picker.
*
* @since 3.7.0
*/
class JFormFieldModal_Menu extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 3.7.0
*/
protected $type = 'Modal_Menu';
/**
* Determinate, if the select button is shown
*
* @var boolean
* @since 3.7.0
*/
protected $allowSelect = true;
/**
* Determinate, if the clear button is shown
*
* @var boolean
* @since 3.7.0
*/
protected $allowClear = true;
/**
* Determinate, if the create button is shown
*
* @var boolean
* @since 3.7.0
*/
protected $allowNew = false;
/**
* Determinate, if the edit button is shown
*
* @var boolean
* @since 3.7.0
*/
protected $allowEdit = false;
/**
* Determinate, if the propagate button is shown
*
* @var boolean
* @since 3.9.0
*/
protected $allowPropagate = false;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.7.0
*/
public function __get($name)
{
switch ($name)
{
case 'allowSelect':
case 'allowClear':
case 'allowNew':
case 'allowEdit':
case 'allowPropagate':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.7.0
*/
public function __set($name, $value)
{
switch ($name)
{
case 'allowSelect':
case 'allowClear':
case 'allowNew':
case 'allowEdit':
case 'allowPropagate':
$value = (string) $value;
$this->$name = !($value === 'false' || $value ===
'off' || $value === '0');
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control
value. This acts as an array container for the field.
* For example if the field has
name="foo" and the group value is set to "bar" then the
* full field name would end up being
"bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.7.0
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->allowSelect = ((string) $this->element['select'])
!== 'false';
$this->allowClear = ((string) $this->element['clear'])
!== 'false';
$this->allowPropagate = ((string)
$this->element['propagate']) === 'true';
// Creating/editing menu items is not supported in frontend.
$isAdministrator =
JFactory::getApplication()->isClient('administrator');
$this->allowNew = $isAdministrator ? ((string)
$this->element['new']) === 'true' : false;
$this->allowEdit = $isAdministrator ? ((string)
$this->element['edit']) === 'true' : false;
}
return $return;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.7.0
*/
protected function getInput()
{
$clientId = (int) $this->element['clientid'];
$languages = LanguageHelper::getContentLanguages(array(0, 1));
// Load language
JFactory::getLanguage()->load('com_menus',
JPATH_ADMINISTRATOR);
// The active article id field.
$value = (int) $this->value > 0 ? (int) $this->value :
'';
// Create the modal id.
$modalId = 'Item_' . $this->id;
// Add the modal field script to the document head.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/modal-fields.js',
array('version' => 'auto', 'relative'
=> true));
// Script to proxy the select modal function to the modal-fields.js file.
if ($this->allowSelect)
{
static $scriptSelect = null;
if (is_null($scriptSelect))
{
$scriptSelect = array();
}
if (!isset($scriptSelect[$this->id]))
{
JFactory::getDocument()->addScriptDeclaration("
function jSelectMenu_" . $this->id . "(id, title, object)
{
window.processModalSelect('Item', '" .
$this->id . "', id, title, '', object);
}
"
);
JText::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
$scriptSelect[$this->id] = true;
}
}
// Setup variables for display.
$linkSuffix = '&layout=modal&client_id=' .
$clientId . '&tmpl=component&' .
JSession::getFormToken() . '=1';
$linkItems = 'index.php?option=com_menus&view=items' .
$linkSuffix;
$linkItem = 'index.php?option=com_menus&view=item' .
$linkSuffix;
$modalTitle = JText::_('COM_MENUS_CHANGE_MENUITEM');
if (isset($this->element['language']))
{
$linkItems .= '&forcedLanguage=' .
$this->element['language'];
$linkItem .= '&forcedLanguage=' .
$this->element['language'];
$modalTitle .= ' — ' .
$this->element['label'];
}
$urlSelect = $linkItems . '&function=jSelectMenu_' .
$this->id;
$urlEdit = $linkItem . '&task=item.edit&id=\'
+ document.getElementById("' . $this->id .
'_id").value + \'';
$urlNew = $linkItem . '&task=item.add';
if ($value)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__menu'))
->where($db->quoteName('id') . ' = ' . (int)
$value);
$db->setQuery($query);
try
{
$title = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
}
// Placeholder if option is present or not
if (empty($title))
{
if ($this->element->option && (string)
$this->element->option['value'] == '')
{
$title_holder = JText::_($this->element->option);
}
else
{
$title_holder = JText::_('COM_MENUS_SELECT_A_MENUITEM');
}
}
$title = empty($title) ? $title_holder : htmlspecialchars($title,
ENT_QUOTES, 'UTF-8');
// The current menu item display field.
$html = '<span class="input-append">';
$html .= '<input class="input-medium" id="' .
$this->id . '_name" type="text" value="' .
$title . '" disabled="disabled" size="35"
/>';
// Select menu item button
if ($this->allowSelect)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? '
hidden' : '') . '"'
. ' id="' . $this->id . '_select"'
. ' data-toggle="modal"'
. ' data-target="#ModalSelect' . $modalId .
'"'
. ' title="' .
JHtml::tooltipText('COM_MENUS_CHANGE_MENUITEM') .
'">'
. '<span class="icon-file"
aria-hidden="true"></span> ' .
JText::_('JSELECT')
. '</button>';
}
// New menu item button
if ($this->allowNew)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? '
hidden' : '') . '"'
. ' id="' . $this->id . '_new"'
. ' data-toggle="modal"'
. ' data-target="#ModalNew' . $modalId .
'"'
. ' title="' .
JHtml::tooltipText('COM_MENUS_NEW_MENUITEM') .
'">'
. '<span class="icon-new"
aria-hidden="true"></span> ' .
JText::_('JACTION_CREATE')
. '</button>';
}
// Edit menu item button
if ($this->allowEdit)
{
$html .= '<button'
. ' type="button"'
. ' class="btn hasTooltip' . ($value ? '' :
' hidden') . '"'
. ' id="' . $this->id . '_edit"'
. ' data-toggle="modal"'
. ' data-target="#ModalEdit' . $modalId .
'"'
. ' title="' .
JHtml::tooltipText('COM_MENUS_EDIT_MENUITEM') .
'">'
. '<span class="icon-edit"
aria-hidden="true"></span> ' .
JText::_('JACTION_EDIT')
. '</button>';
}
// Clear menu item button
if ($this->allowClear)
{
$html .= '<button'
. ' type="button"'
. ' class="btn' . ($value ? '' : '
hidden') . '"'
. ' id="' . $this->id . '_clear"'
. ' onclick="window.processModalParent(\'' .
$this->id . '\'); return false;">'
. '<span class="icon-remove"
aria-hidden="true"></span>' .
JText::_('JCLEAR')
. '</button>';
}
// Propagate menu item button
if ($this->allowPropagate && count($languages) > 2)
{
// Strip off language tag at the end
$tagLength = (int) strlen($this->element['language']);
$callbackFunctionStem = substr("jSelectMenu_" . $this->id,
0, -$tagLength);
$html .= '<a'
. ' class="btn hasTooltip' . ($value ? '' :
' hidden') . '"'
. ' id="' . $this->id . '_propagate"'
. ' href="#"'
. ' title="' .
JHtml::tooltipText('JGLOBAL_ASSOCIATIONS_PROPAGATE_TIP') .
'"'
. ' onclick="Joomla.propagateAssociation(\'' .
$this->id . '\', \'' . $callbackFunctionStem .
'\');">'
. '<span class="icon-refresh"
aria-hidden="true"></span>' .
JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_BUTTON')
. '</a>';
}
$html .= '</span>';
// Select menu item modal
if ($this->allowSelect)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalSelect' . $modalId,
array(
'title' => $modalTitle,
'url' => $urlSelect,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button"
class="btn" data-dismiss="modal">' .
JText::_('JLIB_HTML_BEHAVIOR_CLOSE') .
'</button>',
)
);
}
// New menu item modal
if ($this->allowNew)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalNew' . $modalId,
array(
'title' =>
JText::_('COM_MENUS_NEW_MENUITEM'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlNew,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button"
class="btn"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'add\', \'item\',
\'cancel\', \'item-form\'); return
false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') .
'</button>'
. '<button type="button" class="btn
btn-primary"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'add\', \'item\',
\'save\', \'item-form\'); return false;">'
. JText::_('JSAVE') . '</button>'
. '<button type="button" class="btn
btn-success"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'add\', \'item\',
\'apply\', \'item-form\'); return
false;">'
. JText::_('JAPPLY') . '</button>',
)
);
}
// Edit menu item modal
if ($this->allowEdit)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalEdit' . $modalId,
array(
'title' =>
JText::_('COM_MENUS_EDIT_MENUITEM'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlEdit,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<button type="button"
class="btn"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'edit\', \'item\',
\'cancel\', \'item-form\'); return
false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') .
'</button>'
. '<button type="button" class="btn
btn-primary"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'edit\', \'item\',
\'save\', \'item-form\'); return false;">'
. JText::_('JSAVE') . '</button>'
. '<button type="button" class="btn
btn-success"'
. ' onclick="window.processModalEdit(this, \'' .
$this->id . '\', \'edit\', \'item\',
\'apply\', \'item-form\'); return
false;">'
. JText::_('JAPPLY') . '</button>',
)
);
}
// Note: class='required' for client side validation.
$class = $this->required ? ' class="required
modal-value"' : '';
// Placeholder if option is present or not when clearing field
if ($this->element->option && (string)
$this->element->option['value'] == '')
{
$title_holder = JText::_($this->element->option);
}
else
{
$title_holder = JText::_('COM_MENUS_SELECT_A_MENUITEM');
}
$html .= '<input type="hidden" id="' .
$this->id . '_id" ' . $class . '
data-required="' . (int) $this->required . '"
name="' . $this->name
. '" data-text="' . htmlspecialchars($title_holder,
ENT_COMPAT, 'UTF-8') . '" value="' . $value .
'" />';
return $html;
}
/**
* Method to get the field label markup.
*
* @return string The field label markup.
*
* @since 3.7.0
*/
protected function getLabel()
{
return str_replace($this->id, $this->id . '_id',
parent::getLabel());
}
}
forms/filter_items.xml000064400000007406151164367560011127 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<field
name="client_id"
type="list"
label=""
filtermode="selector"
onchange="this.form.submit();"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
</field>
<field
name="menutype"
type="menu"
label="COM_MENUS_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
accesstype="manage"
clientid=""
showAll="false"
filtermode="selector"
onchange="this.form.submit();"
>
<option value="">COM_MENUS_SELECT_MENU</option>
</field>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_MENUS_ITEMS_SEARCH_FILTER_LABEL"
description="COM_MENUS_ITEMS_SEARCH_FILTER"
hint="JSEARCH_FILTER"
noresults="JGLOBAL_NO_MATCHING_RESULTS"
/>
<field
name="published"
type="status"
label="COM_MENUS_FILTER_PUBLISHED"
description="COM_MENUS_FILTER_PUBLISHED_DESC"
filter="*,0,1,-2"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_ACCESS</option>
</field>
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
<field
name="parent_id"
type="menuitembytype"
label="COM_MENUS_FILTER_PARENT_MENU_ITEM_LABEL"
description="COM_MENUS_FILTER_PARENT_MENU_ITEM_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_MENUS_FILTER_SELECT_PARENT_MENU_ITEM</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
statuses="*,0,1,2,-2"
onchange="this.form.submit();"
default="a.lft ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.lft
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.lft
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="menutype_title
ASC">COM_MENUS_HEADING_MENU_ASC</option>
<option value="menutype_title
DESC">COM_MENUS_HEADING_MENU_DESC</option>
<option value="a.home
ASC">COM_MENUS_HEADING_HOME_ASC</option>
<option value="a.home
DESC">COM_MENUS_HEADING_HOME_DESC</option>
<option value="a.access
ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="a.access
DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="association ASC"
requires="associations">JASSOCIATIONS_ASC</option>
<option value="association DESC"
requires="associations">JASSOCIATIONS_DESC</option>
<option value="language
ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="language
DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_MENUS_LIST_LIMIT"
description="COM_MENUS_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_itemsadmin.xml000064400000004667151164367560012146
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<field
name="client_id"
type="list"
label=""
filtermode="selector"
onchange="this.form.submit();"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
</field>
<field
name="menutype"
type="menu"
label="COM_MENUS_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
accesstype="manage"
clientid=""
showAll="false"
filtermode="selector"
onchange="this.form.submit();"
>
<option value="">COM_MENUS_SELECT_MENU</option>
</field>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_MENUS_ITEMS_SEARCH_FILTER_LABEL"
description="COM_MENUS_ITEMS_SEARCH_FILTER"
hint="JSEARCH_FILTER"
noresults="JGLOBAL_NO_MATCHING_RESULTS"
/>
<field
name="published"
type="status"
label="COM_MENUS_FILTER_PUBLISHED"
description="COM_MENUS_FILTER_PUBLISHED_DESC"
filter="*,0,1,-2"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
statuses="*,0,1,2,-2"
onchange="this.form.submit();"
default="a.lft ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.lft
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.lft
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="menutype_title
ASC">COM_MENUS_HEADING_MENU_ASC</option>
<option value="menutype_title
DESC">COM_MENUS_HEADING_MENU_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_MENUS_LIST_LIMIT"
description="COM_MENUS_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/filter_menus.xml000064400000002231151164367560011124 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<field
name="client_id"
type="list"
label=""
filtermode="selector"
onchange="this.form.submit();"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
</field>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_MENUS_MENUS_FILTER_SEARCH_LABEL"
description="COM_MENUS_MENUS_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.title ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.title
ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title
DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="5"
onchange="this.form.submit();"
/>
</fields>
</form>
forms/item.xml000064400000011253151164367560007372 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="hidden"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
class="readonly"
default="0"
filter="int"
readonly="true"
/>
<field
name="title"
type="text"
label="COM_MENUS_ITEM_FIELD_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="alias"
type="alias"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER"
size="40"
/>
<field
name="note"
type="text"
label="JFIELD_NOTE_LABEL"
description="COM_MENUS_ITEM_FIELD_NOTE_DESC"
maxlength="255"
class="span12"
size="40"
/>
<field
name="link"
type="link"
label="COM_MENUS_ITEM_FIELD_LINK_LABEL"
description="COM_MENUS_ITEM_FIELD_LINK_DESC"
readonly="true"
class="input-xxlarge"
size="50"
/>
<field
name="menutype"
type="menu"
label="COM_MENUS_ITEM_FIELD_ASSIGNED_LABEL"
description="COM_MENUS_ITEM_FIELD_ASSIGNED_DESC"
required="true"
clientid="0"
size="1"
>
<option value="">COM_MENUS_SELECT_MENU</option>
</field>
<field
name="type"
type="menutype"
label="COM_MENUS_ITEM_FIELD_TYPE_LABEL"
description="COM_MENUS_ITEM_FIELD_TYPE_DESC"
class="input-medium"
required="true"
size="40"
/>
<field
name="published"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
id="published"
class="chzn-color-state"
size="1"
default="1"
filter="integer"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="parent_id"
type="menuparent"
label="COM_MENUS_ITEM_FIELD_PARENT_LABEL"
description="COM_MENUS_ITEM_FIELD_PARENT_DESC"
default="1"
filter="int"
clientid="0"
size="1"
>
<option value="1">COM_MENUS_ITEM_ROOT</option>
</field>
<field
name="menuordering"
type="menuordering"
label="COM_MENUS_ITEM_FIELD_ORDERING_LABEL"
description="COM_MENUS_ITEM_FIELD_ORDERING_DESC"
filter="int"
size="1">
</field>
<field
name="component_id"
type="hidden"
filter="int"
/>
<field
name="browserNav"
type="list"
label="COM_MENUS_ITEM_FIELD_BROWSERNAV_LABEL"
description="COM_MENUS_ITEM_FIELD_BROWSERNAV_DESC"
default="0"
filter="int"
>
<option
value="0">COM_MENUS_FIELD_VALUE_PARENT</option>
<option
value="1">COM_MENUS_FIELD_VALUE_NEW_WITH_NAV</option>
<option
value="2">COM_MENUS_FIELD_VALUE_NEW_WITHOUT_NAV</option>
</field>
<field
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
id="access"
filter="integer"
/>
<field
name="template_style_id"
type="templatestyle"
label="COM_MENUS_ITEM_FIELD_TEMPLATE_LABEL"
description="COM_MENUS_ITEM_FIELD_TEMPLATE_DESC"
client="site"
filter="int"
showon="type!:alias[OR]params.alias_redirect:0"
>
<option value="0">JOPTION_USE_DEFAULT</option>
</field>
<field
name="home"
type="radio"
label="COM_MENUS_ITEM_FIELD_HOME_LABEL"
description="COM_MENUS_ITEM_FIELD_HOME_DESC"
default="0"
class="btn-group btn-group-yesno"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
<field
name="path"
type="hidden"
filter="unset"
/>
<field
name="level"
type="hidden"
filter="unset"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="lft"
type="hidden"
filter="unset"
/>
<field
name="rgt"
type="hidden"
filter="unset"
/>
<field
name="toggle_modules_assigned"
type="radio"
label="COM_MENUS_ITEM_FIELD_HIDE_UNASSIGNED_LABEL"
description="COM_MENUS_ITEM_FIELD_HIDE_UNASSIGNED_DESC"
default="1"
class="btn-group btn-group-yesno"
filter="integer"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="toggle_modules_published"
type="radio"
label="COM_MENUS_ITEM_FIELD_HIDE_UNPUBLISHED_LABEL"
description="COM_MENUS_ITEM_FIELD_HIDE_UNPUBLISHED_DESC"
default="1"
class="btn-group btn-group-yesno"
filter="integer"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
</fieldset>
<fields name="params">
</fields>
</form>
forms/itemadmin.xml000064400000006451151164367560010407 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="hidden"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
class="readonly"
default="0"
filter="int"
readonly="true"
/>
<field
name="title"
type="text"
label="COM_MENUS_ITEM_FIELD_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
/>
<field
name="alias"
type="alias"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER"
size="40"
/>
<field
name="note"
type="text"
label="JFIELD_NOTE_LABEL"
description="COM_MENUS_ITEM_FIELD_NOTE_DESC"
maxlength="255"
class="span12"
size="40"
/>
<field
name="link"
type="link"
label="COM_MENUS_ITEM_FIELD_LINK_LABEL"
description="COM_MENUS_ITEM_FIELD_LINK_DESC"
readonly="true"
class="input-xxlarge"
size="50"
/>
<field
name="menutype"
type="menu"
label="COM_MENUS_ITEM_FIELD_ASSIGNED_LABEL"
description="COM_MENUS_ITEM_FIELD_ASSIGNED_DESC"
required="true"
clientid="1"
size="1"
>
<option value="">COM_MENUS_SELECT_MENU</option>
</field>
<field
name="type"
type="menutype"
label="COM_MENUS_ITEM_FIELD_TYPE_LABEL"
description="COM_MENUS_ITEM_FIELD_TYPE_DESC"
class="input-medium"
required="true"
size="40"
/>
<field
name="published"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
class="chzn-color-state"
id="published"
size="1"
default="1"
filter="integer"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="parent_id"
type="menuparent"
label="COM_MENUS_ITEM_FIELD_PARENT_LABEL"
description="COM_MENUS_ITEM_FIELD_PARENT_DESC"
default="1"
filter="int"
clientid="1"
size="1"
>
<option value="1">COM_MENUS_ITEM_ROOT</option>
</field>
<field
name="menuordering"
type="menuordering"
label="COM_MENUS_ITEM_FIELD_ORDERING_LABEL"
description="COM_MENUS_ITEM_FIELD_ORDERING_DESC"
filter="int"
size="1"
/>
<field
name="component_id"
type="hidden"
filter="int"
/>
<field
name="browserNav"
type="list"
label="COM_MENUS_ITEM_FIELD_BROWSERNAV_LABEL"
description="COM_MENUS_ITEM_FIELD_BROWSERNAV_DESC"
default="0"
filter="int"
>
<option
value="0">COM_MENUS_FIELD_VALUE_PARENT</option>
<option
value="1">COM_MENUS_FIELD_VALUE_NEW_WITH_NAV</option>
</field>
<field
name="home"
type="hidden"
default="0"
/>
<field
name="access"
type="hidden"
id="access"
default="0"
/>
<field
name="template_style_id"
type="hidden"
default="0"
/>
<field
name="language"
type="hidden"
default="*"
/>
<field
name="path"
type="hidden"
filter="unset"
/>
<field
name="level"
type="hidden"
filter="unset"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="lft"
type="hidden"
filter="unset"
/>
<field
name="rgt"
type="hidden"
filter="unset"
/>
</fieldset>
<fields name="params">
</fields>
</form>
forms/itemadmin_alias.xml000064400000003604151164367560011555
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<!-- Add fields to the request variables for the layout. -->
<fields name="params">
<fieldset name="aliasoptions">
<field
name="aliasoptions"
type="modal_menu"
label="COM_MENUS_ITEM_FIELD_ALIAS_MENU_LABEL"
description="COM_MENUS_ITEM_FIELD_ALIAS_MENU_DESC"
clientid="1"
required="true"
select="true"
new="true"
edit="true"
clear="true"
/>
</fieldset>
<fieldset
name="menu-options"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
>
<field
name="menu-anchor_title"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
/>
<field
name="menu-anchor_css"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
/>
<field
name="menu_image"
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
/>
<field
name="menu_image_css"
type="text"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
/>
<field
name="menu_text"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="menu_show"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_ALIAS"/>
</form>
forms/itemadmin_component.xml000064400000003003151164367560012457
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="params"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL">
<fieldset name="menu-options"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
>
<field
name="menu-anchor_title"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
/>
<field
name="menu-anchor_css"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
/>
<field
name="menu_image"
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
/>
<field
name="menu_image_css"
type="text"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
/>
<field
name="menu_text"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="menu_show"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</form>
forms/itemadmin_container.xml000064400000003646151164367560012454
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<!-- Container type menu item does not have a navigation -->
<field
name="link"
type="hidden"
/>
<field
name="browserNav"
type="hidden"
default="0"
/>
</fieldset>
<fields name="params">
<fieldset name="menu-options"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL">
<field
name="menu-anchor_title"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
/>
<field
name="menu-anchor_css"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
/>
<field
name="menu_image"
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
/>
<field
name="menu_image_css"
type="text"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
/>
<field
name="menu_text"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="menu_show"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
<field
name="hideitems"
type="checkboxes"
label="COM_MENUS_ITEM_FIELD_COMPONENTS_CONTAINER_HIDE_ITEMS_LABEL"
description="COM_MENUS_ITEM_FIELD_COMPONENTS_CONTAINER_HIDE_ITEMS_DESC"
filter="array"
/>
</fields>
<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_CONTAINER"/>
</form>
forms/itemadmin_heading.xml000064400000003310151164367560012055
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<!-- Heading type menu item does not have a navigation -->
<field
name="link"
type="hidden"
/>
<field
name="browserNav"
type="hidden"
default="0"
/>
</fieldset>
<fields name="params">
<fieldset name="menu-options"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL">
<field
name="menu-anchor_title"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
/>
<field
name="menu-anchor_css"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
/>
<field
name="menu_image"
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
/>
<field
name="menu_image_css"
type="text"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
/>
<field
name="menu_text"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="menu_show"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_HEADING"/>
</form>
forms/itemadmin_separator.xml000064400000001253151164367560012462
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<!-- Text separator type menu item does not have a navigation -->
<field
name="link"
type="hidden"
/>
<field
name="browserNav"
type="hidden"
default="0"
/>
<fields name="params">
<field
name="text_separator"
type="radio"
label="COM_MENUS_ITEM_FIELD_TEXT_SEPARATOR_LABEL"
description="COM_MENUS_ITEM_FIELD_TEXT_SEPARATOR_DESC"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fields>
</fieldset>
<help key="JHELP_MENUS_MENU_ITEM_TEXT_SEPARATOR" />
</form>
forms/itemadmin_url.xml000064400000004111151164367560011260
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="params">
<fieldset name="menu-options"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL">
<field
name="menu-anchor_title"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
/>
<field
name="menu-anchor_css"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
/>
<field
name="menu-anchor_rel"
type="list"
label="COM_MENUS_ITEM_FIELD_ANCHOR_REL_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_REL_DESC"
default=""
>
<option value="">JNONE</option>
<option value="alternate"/>
<option value="author"/>
<option value="bookmark"/>
<option value="help"/>
<option value="license"/>
<option value="next"/>
<option value="nofollow"/>
<option value="noreferrer"/>
<option value="prefetch"/>
<option value="prev"/>
<option value="search"/>
<option value="tag"/>
</field>
<field
name="menu_image"
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
/>
<field
name="menu_image_css"
type="text"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
/>
<field
name="menu_text"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
class="btn-group btn-group-yesno"
default="1" filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="menu_show"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
<help key="JHELP_MENUS_MENU_ITEM_EXTERNAL_URL" />
</form>
forms/item_alias.xml000064400000004315151164367560010544 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<!-- Add fields to the request variables for the layout. -->
<fields name="params">
<fieldset name="aliasoptions">
<field
name="aliasoptions"
type="modal_menu"
label="COM_MENUS_ITEM_FIELD_ALIAS_MENU_LABEL"
description="COM_MENUS_ITEM_FIELD_ALIAS_MENU_DESC"
clientid="0"
required="true"
select="true"
new="true"
edit="true"
clear="true"
/>
<field
name="alias_redirect"
type="radio"
label="COM_MENUS_ITEM_FIELD_ALIAS_REDIRECT_LABEL"
description="COM_MENUS_ITEM_FIELD_ALIAS_REDIRECT_DESC"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
<fieldset name="menu-options"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
>
<field
name="menu-anchor_title"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
/>
<field
name="menu-anchor_css"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
/>
<field
name="menu_image"
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
/>
<field
name="menu_image_css"
type="text"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
/>
<field
name="menu_text"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="menu_show"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
default="1"
filter="integer"
class="btn-group btn-group-yesno"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_ALIAS" />
</form>
forms/item_component.xml000064400000007016151164367560011456
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="params"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
>
<fieldset name="menu-options"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL">
<field
name="menu-anchor_title"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
/>
<field
name="menu-anchor_css"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
/>
<field
name="menu_image"
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
/>
<field
name="menu_image_css"
type="text"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
/>
<field
name="menu_text"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
class="btn-group btn-group-yesno"
default="1" filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="menu_show"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
<fieldset name="page-options"
label="COM_MENUS_PAGE_OPTIONS_LABEL">
<field
name="page_title"
type="text"
label="COM_MENUS_ITEM_FIELD_PAGE_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_PAGE_TITLE_DESC"
useglobal="true"
/>
<field
name="show_page_heading"
type="list"
label="COM_MENUS_ITEM_FIELD_SHOW_PAGE_HEADING_LABEL"
description="COM_MENUS_ITEM_FIELD_SHOW_PAGE_HEADING_DESC"
class="chzn-color"
default=""
useglobal="true"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="page_heading"
type="text"
label="COM_MENUS_ITEM_FIELD_PAGE_HEADING_LABEL"
description="COM_MENUS_ITEM_FIELD_PAGE_HEADING_DESC"
/>
<field
name="pageclass_sfx"
type="text"
label="COM_MENUS_ITEM_FIELD_PAGE_CLASS_LABEL"
description="COM_MENUS_ITEM_FIELD_PAGE_CLASS_DESC"
/>
</fieldset>
<fieldset name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<field
name="menu-meta_description"
type="textarea"
label="JFIELD_META_DESCRIPTION_LABEL"
description="JFIELD_META_DESCRIPTION_DESC"
rows="3"
cols="40"
/>
<field
name="menu-meta_keywords"
type="textarea"
label="JFIELD_META_KEYWORDS_LABEL"
description="JFIELD_META_KEYWORDS_DESC"
rows="3"
cols="40"
/>
<field
name="robots"
type="list"
label="JFIELD_METADATA_ROBOTS_LABEL"
description="JFIELD_METADATA_ROBOTS_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="index, follow"></option>
<option value="noindex, follow"></option>
<option value="index, nofollow"></option>
<option value="noindex, nofollow"></option>
</field>
<field
name="secure"
type="list"
label="COM_MENUS_ITEM_FIELD_SECURE_LABEL"
description="COM_MENUS_ITEM_FIELD_SECURE_DESC"
default="0"
filter="integer"
>
<option value="-1">JOFF</option>
<option value="1">JON</option>
<option
value="0">COM_MENUS_FIELD_VALUE_IGNORE</option>
</field>
</fieldset>
</fields>
</form>
forms/item_heading.xml000064400000003022151164367560011044 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields name="params">
<fieldset name="menu-options"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
>
<field
name="menu-anchor_title"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
/>
<field
name="menu-anchor_css"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
/>
<field
name="menu_image"
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
/>
<field
name="menu_image_css"
type="text"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
/>
<field
name="menu_text"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="menu_show"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_HEADING" />
</form>
forms/item_separator.xml000064400000002542151164367560011453
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="params">
<fieldset name="menu-options"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
>
<field
name="menu-anchor_css"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
/>
<field
name="menu_image"
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
/>
<field
name="menu_image_css"
type="text"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
/>
<field
name="menu_text"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="menu_show"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
<help key="JHELP_MENUS_MENU_ITEM_TEXT_SEPARATOR" />
</form>
forms/item_url.xml000064400000004253151164367560010256 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fields name="params">
<fieldset name="menu-options"
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
>
<field
name="menu-anchor_title"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
/>
<field
name="menu-anchor_css"
type="text"
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
/>
<field
name="menu-anchor_rel"
type="list"
label="COM_MENUS_ITEM_FIELD_ANCHOR_REL_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_REL_DESC"
default=""
>
<option value="">JNONE</option>
<option value="alternate"/>
<option value="author"/>
<option value="bookmark"/>
<option value="help"/>
<option value="license"/>
<option value="next"/>
<option value="nofollow"/>
<option value="noopener"/>
<option value="noreferrer"/>
<option value="prefetch"/>
<option value="prev"/>
<option value="search"/>
<option value="sponsored"/>
<option value="tag"/>
<option value="ugc"/>
</field>
<field
name="menu_image"
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
/>
<field
name="menu_image_css"
type="text"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
/>
<field
name="menu_text"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="menu_show"
type="radio"
label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
<help key="JHELP_MENUS_MENU_ITEM_EXTERNAL_URL" />
</form>
forms/menu.xml000064400000002771151164367560007405 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="hidden"
id="id"
default="0"
filter="int"
readonly="true"
/>
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<field
name="menutype"
type="text"
label="COM_MENUS_MENU_MENUTYPE_LABEL"
description="COM_MENUS_MENU_MENUTYPE_DESC"
id="menutype"
size="30"
maxlength="24"
required="true"
/>
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="COM_MENUS_MENU_TITLE_DESC"
id="title"
size="30"
maxlength="48"
required="true"
/>
<field
name="description"
type="text"
label="JGLOBAL_DESCRIPTION"
description="COM_MENUS_MENU_DESCRIPTION_DESC"
id="menudescription"
size="30"
maxlength="255"
/>
<field
name="client_id"
type="radio"
label="COM_MENUS_MENU_CLIENT_ID_LABEL"
description="COM_MENUS_MENU_CLIENT_ID_DESC"
id="client_id"
default="0"
class="btn-group btn-group-yesno btn-group-reversed"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
</field>
<field
name="preset"
type="menuPreset"
label="COM_MENUS_FIELD_PRESET_LABEL"
description="COM_MENUS_FIELD_PRESET_DESC"
showon="client_id:1"
>
<option value="">JNONE</option>
</field>
<field
name="rules"
type="rules"
label="JFIELD_RULES_LABEL"
translate_label="false"
filter="rules"
component="com_menus"
section="menu"
validate="rules"
/>
</fieldset>
</form>
item.php000064400000125451151164367560006241 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
jimport('joomla.filesystem.path');
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR .
'/components/com_menus/helpers/menus.php');
/**
* Menu Item Model for Menus.
*
* @since 1.6
*/
class MenusModelItem extends JModelAdmin
{
/**
* The type alias for this content type.
*
* @var string
* @since 3.4
*/
public $typeAlias = 'com_menus.item';
/**
* The context used for the associations table
*
* @var string
* @since 3.4.4
*/
protected $associationsContext = 'com_menus.item';
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_MENUS_ITEM';
/**
* @var string The help screen key for the menu item.
* @since 1.6
*/
protected $helpKey = 'JHELP_MENUS_MENU_ITEM_MANAGER_EDIT';
/**
* @var string The help screen base URL for the menu item.
* @since 1.6
*/
protected $helpURL;
/**
* @var boolean True to use local lookup for the help screen.
* @since 1.6
*/
protected $helpLocal = false;
/**
* Batch copy/move command. If set to false,
* the batch copy/move command is not supported
*
* @var string
*/
protected $batch_copymove = 'menu_id';
/**
* Allowed batch commands
*
* @var array
*/
protected $batch_commands = array(
'assetgroup_id' => 'batchAccess',
'language_id' => 'batchLanguage'
);
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (empty($record->id) || $record->published != -2)
{
return false;
}
$menuTypeId = 0;
if (!empty($record->menutype))
{
$menuTypeId = $this->getMenuTypeId($record->menutype);
}
return JFactory::getUser()->authorise('core.delete',
'com_menus.menu.' . (int) $menuTypeId);
}
/**
* Method to test whether the state of a record can be edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission for the component.
*
* @since 3.6
*/
protected function canEditState($record)
{
$menuTypeId = !empty($record->menutype) ?
$this->getMenuTypeId($record->menutype) : 0;
$assetKey = $menuTypeId ? 'com_menus.menu.' . (int)
$menuTypeId : 'com_menus';
return JFactory::getUser()->authorise('core.edit.state',
$assetKey);
}
/**
* Batch copy menu items to a new menu or parent.
*
* @param integer $value The new menu or sub-item.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 1.6
*/
protected function batchCopy($value, $pks, $contexts)
{
// $value comes as {menutype}.{parent_id}
$parts = explode('.', $value);
$menuType = $parts[0];
$parentId = ArrayHelper::getValue($parts, 1, 0, 'int');
$table = $this->getTable();
$db = $this->getDbo();
$query = $db->getQuery(true);
$newIds = array();
// Check that the parent exists
if ($parentId)
{
if (!$table->load($parentId))
{
if ($error = $table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Non-fatal error
$this->setError(JText::_('JGLOBAL_BATCH_MOVE_PARENT_NOT_FOUND'));
$parentId = 0;
}
}
}
// If the parent is 0, set it to the ID of the root item in the tree
if (empty($parentId))
{
if (!$parentId = $table->getRootId())
{
$this->setError($db->getErrorMsg());
return false;
}
}
// Check that user has create permission for menus
$user = JFactory::getUser();
$menuTypeId = (int) $this->getMenuTypeId($menuType);
if (!$user->authorise('core.create',
'com_menus.menu.' . $menuTypeId))
{
$this->setError(JText::_('COM_MENUS_BATCH_MENU_ITEM_CANNOT_CREATE'));
return false;
}
// We need to log the parent ID
$parents = array();
// Calculate the emergency stop count as a precaution against a runaway
loop bug
$query->select('COUNT(id)')
->from($db->quoteName('#__menu'));
$db->setQuery($query);
try
{
$count = $db->loadResult();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Parent exists so we let's proceed
while (!empty($pks) && $count > 0)
{
// Pop the first id off the stack
$pk = array_shift($pks);
$table->reset();
// Check that the row actually exists
if (!$table->load($pk))
{
if ($error = $table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JGLOBAL_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Copy is a bit tricky, because we also need to copy the children
$query->clear()
->select('id')
->from($db->quoteName('#__menu'))
->where('lft > ' . (int) $table->lft)
->where('rgt < ' . (int) $table->rgt);
$db->setQuery($query);
$childIds = $db->loadColumn();
// Add child ID's to the array only if they aren't already
there.
foreach ($childIds as $childId)
{
if (!in_array($childId, $pks))
{
$pks[] = $childId;
}
}
// Make a copy of the old ID and Parent ID
$oldId = $table->id;
$oldParentId = $table->parent_id;
// Reset the id because we are making a copy.
$table->id = 0;
// If we a copying children, the Old ID will turn up in the parents list
// otherwise it's a new top level item
$table->parent_id = isset($parents[$oldParentId]) ?
$parents[$oldParentId] : $parentId;
$table->menutype = $menuType;
// Set the new location in the tree for the node.
$table->setLocation($table->parent_id, 'last-child');
// TODO: Deal with ordering?
// $table->ordering = 1;
$table->level = null;
$table->lft = null;
$table->rgt = null;
$table->home = 0;
// Alter the title & alias
list($title, $alias) = $this->generateNewTitle($table->parent_id,
$table->alias, $table->title);
$table->title = $title;
$table->alias = $alias;
// Check the row.
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Store the row.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Get the new item ID
$newId = $table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
// Now we log the old 'parent' to the new 'parent'
$parents[$oldId] = $table->id;
$count--;
}
// Rebuild the hierarchy.
if (!$table->rebuild())
{
$this->setError($table->getError());
return false;
}
// Rebuild the tree path.
if (!$table->rebuildPath($table->id))
{
$this->setError($table->getError());
return false;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move menu items to a new menu or parent.
*
* @param integer $value The new menu or sub-item.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True on success.
*
* @since 1.6
*/
protected function batchMove($value, $pks, $contexts)
{
// $value comes as {menutype}.{parent_id}
$parts = explode('.', $value);
$menuType = $parts[0];
$parentId = ArrayHelper::getValue($parts, 1, 0, 'int');
$table = $this->getTable();
$db = $this->getDbo();
$query = $db->getQuery(true);
// Check that the parent exists.
if ($parentId)
{
if (!$table->load($parentId))
{
if ($error = $table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Non-fatal error
$this->setError(JText::_('JGLOBAL_BATCH_MOVE_PARENT_NOT_FOUND'));
$parentId = 0;
}
}
}
// Check that user has create and edit permission for menus
$user = JFactory::getUser();
$menuTypeId = (int) $this->getMenuTypeId($menuType);
if (!$user->authorise('core.create',
'com_menus.menu.' . $menuTypeId))
{
$this->setError(JText::_('COM_MENUS_BATCH_MENU_ITEM_CANNOT_CREATE'));
return false;
}
if (!$user->authorise('core.edit',
'com_menus.menu.' . $menuTypeId))
{
$this->setError(JText::_('COM_MENUS_BATCH_MENU_ITEM_CANNOT_EDIT'));
return false;
}
// We are going to store all the children and just moved the menutype
$children = array();
// Parent exists so we let's proceed
foreach ($pks as $pk)
{
// Check that the row actually exists
if (!$table->load($pk))
{
if ($error = $table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JGLOBAL_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// Set the new location in the tree for the node.
$table->setLocation($parentId, 'last-child');
// Set the new Parent Id
$table->parent_id = $parentId;
// Check if we are moving to a different menu
if ($menuType != $table->menutype)
{
// Add the child node ids to the children array.
$query->clear()
->select($db->quoteName('id'))
->from($db->quoteName('#__menu'))
->where($db->quoteName('lft') . ' BETWEEN '
. (int) $table->lft . ' AND ' . (int) $table->rgt);
$db->setQuery($query);
$children = array_merge($children, (array) $db->loadColumn());
}
// Check the row.
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Store the row.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Rebuild the tree path.
if (!$table->rebuildPath())
{
$this->setError($table->getError());
return false;
}
}
// Process the child rows
if (!empty($children))
{
// Remove any duplicates and sanitize ids.
$children = array_unique($children);
$children = ArrayHelper::toInteger($children);
// Update the menutype field in all nodes where necessary.
$query->clear()
->update($db->quoteName('#__menu'))
->set($db->quoteName('menutype') . ' = ' .
$db->quote($menuType))
->where($db->quoteName('id') . ' IN (' .
implode(',', $children) . ')');
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to check if you can save a record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function canSave($data = array(), $key = 'id')
{
return JFactory::getUser()->authorise('core.edit',
$this->option);
}
/**
* Method to get the row form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// The folder and element vars are passed when saving the form.
if (empty($data))
{
$item = $this->getItem();
// The type should already be set.
$this->setState('item.link', $item->link);
}
else
{
$this->setState('item.link', ArrayHelper::getValue($data,
'link'));
$this->setState('item.type', ArrayHelper::getValue($data,
'type'));
}
$clientId = $this->getState('item.client_id');
// Get the form.
if ($clientId == 1)
{
$form = $this->loadForm('com_menus.item.admin',
'itemadmin', array('control' => 'jform',
'load_data' => $loadData), true);
}
else
{
$form = $this->loadForm('com_menus.item', 'item',
array('control' => 'jform', 'load_data'
=> $loadData), true);
}
if (empty($form))
{
return false;
}
if ($loadData)
{
$data = $this->loadFormData();
}
// Modify the form based on access controls.
if (!$this->canEditState((object) $data))
{
// Disable fields for display.
$form->setFieldAttribute('menuordering',
'disabled', 'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
// The controller has already verified this is an article you can edit.
$form->setFieldAttribute('menuordering',
'filter', 'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// Filter available menus
$action = $this->getState('item.id') > 0 ?
'edit' : 'create';
$form->setFieldAttribute('menutype', 'accesstype',
$action);
$form->setFieldAttribute('type', 'clientid',
$clientId);
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data, providing it has
an ID and it is the same.
$itemData = (array) $this->getItem();
$sessionData = (array)
JFactory::getApplication()->getUserState('com_menus.edit.item.data',
array());
// Only merge if there is a session and itemId or itemid is null.
if (isset($sessionData['id']) &&
isset($itemData['id']) && $sessionData['id']
=== $itemData['id']
|| is_null($itemData['id']))
{
$data = array_merge($itemData, $sessionData);
}
else
{
$data = $itemData;
}
// For a new menu item, pre-select some filters (Status, Language,
Access) in edit form if those have been selected in Menu Manager
if ($this->getItem()->id == 0)
{
// Get selected fields
$filters =
JFactory::getApplication()->getUserState('com_menus.items.filter');
$data['parent_id'] = (isset($filters['parent_id']) ?
$filters['parent_id'] : null);
$data['published'] = (isset($filters['published']) ?
$filters['published'] : null);
$data['language'] = (isset($filters['language']) ?
$filters['language'] : null);
$data['access'] = (!empty($filters['access']) ?
$filters['access'] :
JFactory::getConfig()->get('access'));
}
if (isset($data['menutype']) &&
!$this->getState('item.menutypeid'))
{
$menuTypeId = (int)
$this->getMenuTypeId($data['menutype']);
$this->setState('item.menutypeid', $menuTypeId);
}
$data = (object) $data;
$this->preprocessData('com_menus.item', $data);
return $data;
}
/**
* Get the necessary data to load an item help screen.
*
* @return object An object with key, url, and local properties for
loading the item help screen.
*
* @since 1.6
*/
public function getHelp()
{
return (object) array('key' => $this->helpKey,
'url' => $this->helpURL, 'local' =>
$this->helpLocal);
}
/**
* Method to get a menu item.
*
* @param integer $pk An optional id of the object to get, otherwise
the id from the model state is used.
*
* @return mixed Menu item data object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
$pk = (!empty($pk)) ? $pk : (int)
$this->getState('item.id');
// Get a level row instance.
$table = $this->getTable();
// Attempt to load the row.
$table->load($pk);
// Check for a table object error.
if ($error = $table->getError())
{
$this->setError($error);
return false;
}
// Prime required properties.
if ($type = $this->getState('item.type'))
{
$table->type = $type;
}
if (empty($table->id))
{
$table->parent_id = $this->getState('item.parent_id');
$table->menutype = $this->getState('item.menutype');
$table->client_id = $this->getState('item.client_id');
$table->params = '{}';
}
// If the link has been set in the state, possibly changing link type.
if ($link = $this->getState('item.link'))
{
// Check if we are changing away from the actual link type.
if (MenusHelper::getLinkKey($table->link) !==
MenusHelper::getLinkKey($link) && (int) $table->id === (int)
$this->getState('item.id'))
{
$table->link = $link;
}
}
switch ($table->type)
{
case 'alias':
$table->component_id = 0;
$args = array();
parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
break;
case 'separator':
case 'heading':
case 'container':
$table->link = '';
$table->component_id = 0;
break;
case 'url':
$table->component_id = 0;
$args = array();
parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
break;
case 'component':
default:
// Enforce a valid type.
$table->type = 'component';
// Ensure the integrity of the component_id field is maintained,
particularly when changing the menu item type.
$args = array();
parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
if (isset($args['option']))
{
// Load the language file for the component.
$lang = JFactory::getLanguage();
$lang->load($args['option'], JPATH_ADMINISTRATOR, null,
false, true)
|| $lang->load($args['option'], JPATH_ADMINISTRATOR .
'/components/' . $args['option'], null, false, true);
// Determine the component id.
$component =
JComponentHelper::getComponent($args['option']);
if (isset($component->id))
{
$table->component_id = $component->id;
}
}
break;
}
// We have a valid type, inject it into the state for forms to use.
$this->setState('item.type', $table->type);
// Convert to the JObject before adding the params.
$properties = $table->getProperties(1);
$result = ArrayHelper::toObject($properties);
// Convert the params field to an array.
$registry = new Registry($table->params);
$result->params = $registry->toArray();
// Merge the request arguments in to the params for a component.
if ($table->type == 'component')
{
// Note that all request arguments become reserved parameter names.
$result->request = $args;
$result->params = array_merge($result->params, $args);
// Special case for the Login menu item.
// Display the login or logout redirect URL fields if not empty
if ($table->link ==
'index.php?option=com_users&view=login')
{
if (!empty($result->params['login_redirect_url']))
{
$result->params['loginredirectchoice'] = '0';
}
if (!empty($result->params['logout_redirect_url']))
{
$result->params['logoutredirectchoice'] = '0';
}
}
}
if ($table->type == 'alias')
{
// Note that all request arguments become reserved parameter names.
$result->params = array_merge($result->params, $args);
}
if ($table->type == 'url')
{
// Note that all request arguments become reserved parameter names.
$result->params = array_merge($result->params, $args);
}
// Load associated menu items, only supported for frontend for now
if ($this->getState('item.client_id') == 0 &&
JLanguageAssociations::isEnabled())
{
if ($pk != null)
{
$result->associations = MenusHelper::getAssociations($pk);
}
else
{
$result->associations = array();
}
}
$result->menuordering = $pk;
return $result;
}
/**
* Get the list of modules not in trash.
*
* @return mixed An array of module records (id, title, position), or
false on error.
*
* @since 1.6
*/
public function getModules()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
// Currently any setting that affects target page for a backend menu is
not supported, hence load no modules.
if ($this->getState('item.client_id') == 1)
{
return false;
}
/**
* Join on the module-to-menu mapping table.
* We are only interested if the module is displayed on ALL or THIS menu
item (or the inverse ID number).
* sqlsrv changes for modulelink to menu manager
*/
$query->select('a.id, a.title, a.position, a.published,
map.menuid')
->from('#__modules AS a')
->join('LEFT', sprintf('#__modules_menu AS map ON
map.moduleid = a.id AND map.menuid IN (0, %1$d, -%1$d)',
$this->getState('item.id')))
->select('(SELECT COUNT(*) FROM #__modules_menu WHERE moduleid =
a.id AND menuid < 0) AS ' . $db->quoteName('except'));
// Join on the asset groups table.
$query->select('ag.title AS access_title')
->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access')
->where('a.published >= 0')
->where('a.client_id = ' . (int)
$this->getState('item.client_id'))
->order('a.position, a.ordering');
$db->setQuery($query);
try
{
$result = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
return $result;
}
/**
* Get the list of all view levels
*
* @return array|boolean An array of all view levels (id, title).
*
* @since 3.4
*/
public function getViewLevels()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
// Get all the available view levels
$query->select($db->quoteName('id'))
->select($db->quoteName('title'))
->from($db->quoteName('#__viewlevels'))
->order($db->quoteName('id'));
$db->setQuery($query);
try
{
$result = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
return $result;
}
/**
* A protected method to get the where clause for the reorder.
* This ensures that the row will be moved relative to a row with the same
menutype.
*
* @param JTableMenu $table instance.
*
* @return array An array of conditions to add to add to ordering
queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
return array('menutype = ' .
$this->_db->quote($table->get('menutype')));
}
/**
* Returns a Table object, always creating it
*
* @param string $type The table type to instantiate.
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable|JTableNested A database object.
*
* @since 1.6
*/
public function getTable($type = 'Menu', $prefix =
'MenusTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication('administrator');
// Load the User state.
$pk = $app->input->getInt('id');
$this->setState('item.id', $pk);
if (!($parentId =
$app->getUserState('com_menus.edit.item.parent_id')))
{
$parentId = $app->input->getInt('parent_id');
}
$this->setState('item.parent_id', $parentId);
$menuType =
$app->getUserStateFromRequest('com_menus.items.menutype',
'menutype', '', 'string');
// If we have a menutype we take client_id from there, unless forced
otherwise
if ($menuType)
{
$menuTypeObj = $this->getMenuType($menuType);
// An invalid menutype will be handled as clientId = 0 and menuType =
''
$menuType = (string) $menuTypeObj->menutype;
$menuTypeId = (int) $menuTypeObj->client_id;
$clientId = (int) $menuTypeObj->client_id;
}
else
{
$menuTypeId = 0;
$clientId =
$app->getUserState('com_menus.items.client_id', 0);
}
// Forced client id will override/clear menuType if conflicted
$forcedClientId = $app->input->get('client_id', null,
'string');
// Current item if not new, we don't allow changing client id at all
if ($pk)
{
$table = $this->getTable();
$table->load($pk);
$forcedClientId = $table->get('client_id',
$forcedClientId);
}
if (isset($forcedClientId) && $forcedClientId != $clientId)
{
$clientId = $forcedClientId;
$menuType = '';
$menuTypeId = 0;
}
// Set the menu type and client id on the list view state, so we return
to this menu after saving.
$app->setUserState('com_menus.items.menutype', $menuType);
$app->setUserState('com_menus.items.client_id', $clientId);
$this->setState('item.menutype', $menuType);
$this->setState('item.client_id', $clientId);
$this->setState('item.menutypeid', $menuTypeId);
if (!($type =
$app->getUserState('com_menus.edit.item.type')))
{
$type = $app->input->get('type');
/**
* Note: a new menu item will have no field type.
* The field is required so the user has to change it.
*/
}
$this->setState('item.type', $type);
if ($link = $app->getUserState('com_menus.edit.item.link'))
{
$this->setState('item.link', $link);
}
// Load the parameters.
$params = JComponentHelper::getParams('com_menus');
$this->setState('params', $params);
}
/**
* Loads the menutype object by a given menutype string
*
* @param string $menutype The given menutype
*
* @return stdClass
*
* @since 3.7.0
*/
protected function getMenuType($menutype)
{
$table = $this->getTable('MenuType', 'JTable');
$table->load(array('menutype' => $menutype));
return (object) $table->getProperties();
}
/**
* Loads the menutype ID by a given menutype string
*
* @param string $menutype The given menutype
*
* @return integer
*
* @since 3.6
*/
protected function getMenuTypeId($menutype)
{
$menu = $this->getMenuType($menutype);
return (int) $menu->id;
}
/**
* Method to preprocess the form.
*
* @param JForm $form A JForm object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import.
*
* @return void
*
* @since 1.6
* @throws Exception if there is an error in the form event.
*/
protected function preprocessForm(JForm $form, $data, $group =
'content')
{
$link = $this->getState('item.link');
$type = $this->getState('item.type');
$clientId = $this->getState('item.client_id');
$formFile = false;
// Load the specific type file
$typeFile = $clientId == 1 ? 'itemadmin_' . $type :
'item_' . $type;
$clientInfo = JApplicationHelper::getClientInfo($clientId);
// Initialise form with component view params if available.
if ($type == 'component')
{
$link = htmlspecialchars_decode($link);
// Parse the link arguments.
$args = array();
parse_str(parse_url(htmlspecialchars_decode($link), PHP_URL_QUERY),
$args);
// Confirm that the option is defined.
$option = '';
$base = '';
if (isset($args['option']))
{
// The option determines the base path to work with.
$option = $args['option'];
$base = $clientInfo->path . '/components/' . $option;
}
if (isset($args['view']))
{
$view = $args['view'];
// Determine the layout to search for.
if (isset($args['layout']))
{
$layout = $args['layout'];
}
else
{
$layout = 'default';
}
// Check for the layout XML file. Use standard xml file if it exists.
$tplFolders = array(
$base . '/views/' . $view . '/tmpl',
$base . '/view/' . $view . '/tmpl'
);
$path = JPath::find($tplFolders, $layout . '.xml');
if (is_file($path))
{
$formFile = $path;
}
// If custom layout, get the xml file from the template folder
// template folder is first part of file name -- template:folder
if (!$formFile && (strpos($layout, ':') > 0))
{
list($altTmpl, $altLayout) = explode(':', $layout);
$templatePath = JPath::clean($clientInfo->path .
'/templates/' . $altTmpl . '/html/' . $option .
'/' . $view . '/' . $altLayout . '.xml');
if (is_file($templatePath))
{
$formFile = $templatePath;
}
}
}
// Now check for a view manifest file
if (!$formFile)
{
if (isset($view))
{
$metadataFolders = array(
$base . '/view/' . $view,
$base . '/views/' . $view
);
$metaPath = JPath::find($metadataFolders, 'metadata.xml');
if (is_file($path = JPath::clean($metaPath)))
{
$formFile = $path;
}
}
else
{
// Now check for a component manifest file
$path = JPath::clean($base . '/metadata.xml');
if (is_file($path))
{
$formFile = $path;
}
}
}
}
if ($formFile)
{
// If an XML file was found in the component, load it first.
// We need to qualify the full path to avoid collisions with component
file names.
if ($form->loadFile($formFile, true, '/metadata') == false)
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
// Attempt to load the xml file.
if (!$xml = simplexml_load_file($formFile))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
// Get the help data from the XML file if present.
$help = $xml->xpath('/metadata/layout/help');
}
else
{
// We don't have a component. Load the form XML to get the help
path
$xmlFile = JPath::find(JPATH_ADMINISTRATOR .
'/components/com_menus/models/forms', $typeFile .
'.xml');
if ($xmlFile)
{
if (!$xml = simplexml_load_file($xmlFile))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
// Get the help data from the XML file if present.
$help = $xml->xpath('/form/help');
}
}
if (!empty($help))
{
$helpKey = trim((string) $help[0]['key']);
$helpURL = trim((string) $help[0]['url']);
$helpLoc = trim((string) $help[0]['local']);
$this->helpKey = $helpKey ?: $this->helpKey;
$this->helpURL = $helpURL ?: $this->helpURL;
$this->helpLocal = (($helpLoc == 'true') || ($helpLoc ==
'1') || ($helpLoc == 'local')) ? true : false;
}
if (!$form->loadFile($typeFile, true, false))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
// Association menu items, we currently do not support this for admin
menu… may be later
if ($clientId == 0 && JLanguageAssociations::isEnabled())
{
$languages = JLanguageHelper::getContentLanguages(false, true, null,
'ordering', 'asc');
if (count($languages) > 1)
{
$addform = new SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name',
'item_associations');
foreach ($languages as $language)
{
$field = $fieldset->addChild('field');
$field->addAttribute('name', $language->lang_code);
$field->addAttribute('type', 'modal_menu');
$field->addAttribute('language',
$language->lang_code);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label',
'false');
$field->addAttribute('select', 'true');
$field->addAttribute('new', 'true');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
$field->addAttribute('propagate', 'true');
$option = $field->addChild('option',
'COM_MENUS_ITEM_FIELD_ASSOCIATION_NO_VALUE');
$option->addAttribute('value', '');
}
$form->load($addform, false);
}
}
// Trigger the default form events.
parent::preprocessForm($form, $data, $group);
}
/**
* Method rebuild the entire nested set tree.
*
* @return boolean|JException Boolean true on success, boolean false or
JException instance on error
*
* @since 1.6
*/
public function rebuild()
{
// Initialise variables.
$db = $this->getDbo();
$query = $db->getQuery(true);
$table = $this->getTable();
try
{
$rebuildResult = $table->rebuild();
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
if (!$rebuildResult)
{
$this->setError($table->getError());
return false;
}
$query->select('id, params')
->from('#__menu')
->where('params NOT LIKE ' . $db->quote('{%'))
->where('params <> ' . $db->quote(''));
$db->setQuery($query);
try
{
$items = $db->loadObjectList();
}
catch (RuntimeException $e)
{
return JError::raiseWarning(500, $e->getMessage());
}
foreach ($items as &$item)
{
$registry = new Registry($item->params);
$params = (string) $registry;
$query->clear();
$query->update('#__menu')
->set('params = ' . $db->quote($params))
->where('id = ' . $item->id);
try
{
$db->setQuery($query)->execute();
}
catch (RuntimeException $e)
{
return JError::raiseWarning(500, $e->getMessage());
}
unset($registry);
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$dispatcher = JEventDispatcher::getInstance();
$pk = (!empty($data['id'])) ? $data['id'] :
(int) $this->getState('item.id');
$isNew = true;
$table = $this->getTable();
$context = $this->option . '.' . $this->name;
// Include the plugins for the on save events.
JPluginHelper::importPlugin($this->events_map['save']);
// Load the row if saving an existing item.
if ($pk > 0)
{
$table->load($pk);
$isNew = false;
}
if (!$isNew)
{
if ($table->parent_id == $data['parent_id'])
{
// If first is chosen make the item the first child of the selected
parent.
if ($data['menuordering'] == -1)
{
$table->setLocation($data['parent_id'],
'first-child');
}
// If last is chosen make it the last child of the selected parent.
elseif ($data['menuordering'] == -2)
{
$table->setLocation($data['parent_id'],
'last-child');
}
// Don't try to put an item after itself. All other ones put after
the selected item.
// $data['id'] is empty means it's a save as copy
elseif ($data['menuordering'] && $table->id !=
$data['menuordering'] || empty($data['id']))
{
$table->setLocation($data['menuordering'],
'after');
}
// Just leave it where it is if no change is made.
elseif ($data['menuordering'] && $table->id ==
$data['menuordering'])
{
unset($data['menuordering']);
}
}
// Set the new parent id if parent id not matched and put in last
position
else
{
$table->setLocation($data['parent_id'],
'last-child');
}
}
// We have a new item, so it is not a change.
else
{
$menuType = $this->getMenuType($data['menutype']);
$data['client_id'] = $menuType->client_id;
$table->setLocation($data['parent_id'],
'last-child');
}
// Bind the data.
if (!$table->bind($data))
{
$this->setError($table->getError());
return false;
}
// Alter the title & alias for save as copy. Also, unset the home
record.
if (!$isNew && $data['id'] == 0)
{
list($title, $alias) = $this->generateNewTitle($table->parent_id,
$table->alias, $table->title);
$table->title = $title;
$table->alias = $alias;
$table->published = 0;
$table->home = 0;
}
// Check the data.
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Trigger the before save event.
$result = $dispatcher->trigger($this->event_before_save,
array($context, &$table, $isNew));
// Store the data.
if (in_array(false, $result, true)|| !$table->store())
{
$this->setError($table->getError());
return false;
}
// Trigger the after save event.
$dispatcher->trigger($this->event_after_save, array($context,
&$table, $isNew));
// Rebuild the tree path.
if (!$table->rebuildPath($table->id))
{
$this->setError($table->getError());
return false;
}
$this->setState('item.id', $table->id);
$this->setState('item.menutype', $table->menutype);
// Load associated menu items, for now not supported for admin menu…
may be later
if ($table->get('client_id') == 0 &&
JLanguageAssociations::isEnabled())
{
// Adding self to the association
$associations = isset($data['associations']) ?
$data['associations'] : array();
// Unset any invalid associations
$associations = Joomla\Utilities\ArrayHelper::toInteger($associations);
foreach ($associations as $tag => $id)
{
if (!$id)
{
unset($associations[$tag]);
}
}
// Detecting all item menus
$all_language = $table->language == '*';
if ($all_language && !empty($associations))
{
JError::raiseNotice(403,
JText::_('COM_MENUS_ERROR_ALL_LANGUAGE_ASSOCIATED'));
}
// Get associationskey for edited item
$db = $this->getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('key'))
->from($db->quoteName('#__associations'))
->where($db->quoteName('context') . ' = ' .
$db->quote($this->associationsContext))
->where($db->quoteName('id') . ' = ' . (int)
$table->id);
$db->setQuery($query);
$old_key = $db->loadResult();
// Deleting old associations for the associated items
$query = $db->getQuery(true)
->delete($db->quoteName('#__associations'))
->where($db->quoteName('context') . ' = ' .
$db->quote($this->associationsContext));
if ($associations)
{
$query->where('(' . $db->quoteName('id') .
' IN (' . implode(',', $associations) . ') OR
'
. $db->quoteName('key') . ' = ' .
$db->quote($old_key) . ')'
);
}
else
{
$query->where($db->quoteName('key') . ' = ' .
$db->quote($old_key));
}
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Adding self to the association
if (!$all_language)
{
$associations[$table->language] = (int) $table->id;
}
if (count($associations) > 1)
{
// Adding new association for these items
$key = md5(json_encode($associations));
$query->clear()
->insert('#__associations');
foreach ($associations as $id)
{
$query->values(((int) $id) . ',' .
$db->quote($this->associationsContext) . ',' .
$db->quote($key));
}
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
}
// Clean the cache
$this->cleanCache();
if (isset($data['link']))
{
$base = JUri::base();
$juri = JUri::getInstance($base . $data['link']);
$option = $juri->getVar('option');
// Clean the cache
parent::cleanCache($option);
}
if (Factory::getApplication()->input->get('task') ==
'editAssociations')
{
return $this->redirectToAssociations($data);
}
return true;
}
/**
* Method to save the reordered nested set tree.
* First we save the new order values in the lft values of the changed
ids.
* Then we invoke the table rebuild to implement the new ordering.
*
* @param array $idArray Rows identifiers to be reordered
* @param array $lftArray lft values of rows to be reordered
*
* @return boolean false on failure or error, true otherwise.
*
* @since 1.6
*/
public function saveorder($idArray = null, $lftArray = null)
{
// Get an instance of the table object.
$table = $this->getTable();
if (!$table->saveorder($idArray, $lftArray))
{
$this->setError($table->getError());
return false;
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to change the home state of one or more items.
*
* @param array $pks A list of the primary keys to change.
* @param integer $value The value of the home state.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function setHome(&$pks, $value = 1)
{
$table = $this->getTable();
$pks = (array) $pks;
$languages = array();
$onehome = false;
// Remember that we can set a home page for different languages,
// so we need to loop through the primary key array.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
if (!array_key_exists($table->language, $languages))
{
$languages[$table->language] = true;
if ($table->home == $value)
{
unset($pks[$i]);
JError::raiseNotice(403,
JText::_('COM_MENUS_ERROR_ALREADY_HOME'));
}
elseif ($table->menutype == 'main')
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('COM_MENUS_ERROR_MENUTYPE_HOME'));
}
else
{
$table->home = $value;
if ($table->language == '*')
{
$table->published = 1;
}
if (!$this->canSave($table))
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED'));
}
elseif (!$table->check())
{
// Prune the items that failed pre-save checks.
unset($pks[$i]);
JError::raiseWarning(403, $table->getError());
}
elseif (!$table->store())
{
// Prune the items that could not be stored.
unset($pks[$i]);
JError::raiseWarning(403, $table->getError());
}
}
}
else
{
unset($pks[$i]);
if (!$onehome)
{
$onehome = true;
JError::raiseNotice(403,
JText::sprintf('COM_MENUS_ERROR_ONE_HOME'));
}
}
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array $pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function publish(&$pks, $value = 1)
{
$table = $this->getTable();
$pks = (array) $pks;
// Default menu item existence checks.
if ($value != 1)
{
foreach ($pks as $i => $pk)
{
if ($table->load($pk) && $table->home &&
$table->language == '*')
{
// Prune items that you can't change.
JError::raiseWarning(403,
JText::_('JLIB_DATABASE_ERROR_MENU_UNPUBLISH_DEFAULT_HOME'));
unset($pks[$i]);
break;
}
}
}
// Clean the cache
$this->cleanCache();
// Ensure that previous checks doesn't empty the array
if (empty($pks))
{
return true;
}
return parent::publish($pks, $value);
}
/**
* Method to change the title & alias.
*
* @param integer $parentId The id of the parent.
* @param string $alias The alias.
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
* @since 1.6
*/
protected function generateNewTitle($parentId, $alias, $title)
{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias,
'parent_id' => $parentId)))
{
if ($title == $table->title)
{
$title = StringHelper::increment($title);
}
$alias = StringHelper::increment($alias, 'dash');
}
return array($title, $alias);
}
/**
* Custom clean the cache
*
* @param string $group Cache group name.
* @param integer $clientId Application client id.
*
* @return void
*
* @since 1.6
*/
protected function cleanCache($group = null, $clientId = 0)
{
parent::cleanCache('com_menus', 0);
parent::cleanCache('com_modules');
parent::cleanCache('mod_menu', 0);
parent::cleanCache('mod_menu', 1);
}
}
items.php000064400000041510151164367570006416 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Menu Item List Model for Menus.
*
* @since 1.6
*/
class MenusModelItems extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'menutype', 'a.menutype',
'menutype_title',
'title', 'a.title',
'alias', 'a.alias',
'published', 'a.published',
'access', 'a.access', 'access_level',
'language', 'a.language',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'lft', 'a.lft',
'rgt', 'a.rgt',
'level', 'a.level',
'path', 'a.path',
'client_id', 'a.client_id',
'home', 'a.home',
'parent_id', 'a.parent_id',
'a.ordering'
);
$app = JFactory::getApplication();
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$config['filter_fields'][] = 'association';
}
}
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.6
*/
protected function populateState($ordering = 'a.lft', $direction
= 'asc')
{
$app = JFactory::getApplication('administrator');
$user = JFactory::getUser();
$forcedLanguage = $app->input->get('forcedLanguage',
'', 'cmd');
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Adjust the context to support forced languages.
if ($forcedLanguage)
{
$this->context .= '.' . $forcedLanguage;
}
$search = $this->getUserStateFromRequest($this->context .
'.search', 'filter_search');
$this->setState('filter.search', $search);
$published = $this->getUserStateFromRequest($this->context .
'.published', 'filter_published', '');
$this->setState('filter.published', $published);
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access');
$this->setState('filter.access', $access);
$parentId = $this->getUserStateFromRequest($this->context .
'.filter.parent_id', 'filter_parent_id');
$this->setState('filter.parent_id', $parentId);
$level = $this->getUserStateFromRequest($this->context .
'.filter.level', 'filter_level');
$this->setState('filter.level', $level);
// Watch changes in client_id and menutype and keep sync whenever needed.
$currentClientId = $app->getUserState($this->context .
'.client_id', 0);
$clientId = $app->input->getInt('client_id',
$currentClientId);
// Load mod_menu.ini file when client is administrator
if ($clientId == 1)
{
JFactory::getLanguage()->load('mod_menu',
JPATH_ADMINISTRATOR, null, false, true);
}
$currentMenuType = $app->getUserState($this->context .
'.menutype', '');
$menuType = $app->input->getString('menutype',
$currentMenuType);
// If client_id changed clear menutype and reset pagination
if ($clientId != $currentClientId)
{
$menuType = '';
$app->input->set('limitstart', 0);
$app->input->set('menutype', '');
}
// If menutype changed reset pagination.
if ($menuType != $currentMenuType)
{
$app->input->set('limitstart', 0);
}
if (!$menuType)
{
$app->setUserState($this->context . '.menutype',
'');
$this->setState('menutypetitle', '');
$this->setState('menutypeid', '');
}
// Special menu types, if selected explicitly, will be allowed as a
filter
elseif ($menuType == 'main')
{
// Adjust client_id to match the menutype. This is safe as client_id was
not changed in this request.
$app->input->set('client_id', 1);
$app->setUserState($this->context . '.menutype',
$menuType);
$this->setState('menutypetitle', ucfirst($menuType));
$this->setState('menutypeid', -1);
}
// Get the menutype object with appropriate checks.
elseif ($cMenu = $this->getMenu($menuType, true))
{
// Adjust client_id to match the menutype. This is safe as client_id was
not changed in this request.
$app->input->set('client_id', $cMenu->client_id);
$app->setUserState($this->context . '.menutype',
$menuType);
$this->setState('menutypetitle', $cMenu->title);
$this->setState('menutypeid', $cMenu->id);
}
// This menutype does not exist, leave client id unchanged but reset
menutype and pagination
else
{
$menuType = '';
$app->input->set('limitstart', 0);
$app->input->set('menutype', $menuType);
$app->setUserState($this->context . '.menutype',
$menuType);
$this->setState('menutypetitle', '');
$this->setState('menutypeid', '');
}
// Client id filter
$clientId = (int) $this->getUserStateFromRequest($this->context .
'.client_id', 'client_id', 0, 'int');
$this->setState('filter.client_id', $clientId);
// Use a different filter file when client is administrator
if ($clientId == 1)
{
$this->filterFormName = 'filter_itemsadmin';
}
$this->setState('filter.menutype', $menuType);
$language = $this->getUserStateFromRequest($this->context .
'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
// Component parameters.
$params = JComponentHelper::getParams('com_menus');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
// Force a language.
if (!empty($forcedLanguage))
{
$this->setState('filter.language', $forcedLanguage);
}
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.language');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.parent_id');
$id .= ':' . $this->getState('filter.menutype');
$id .= ':' . $this->getState('filter.client_id');
return parent::getStoreId($id);
}
/**
* Builds an SQL query to load the list data.
*
* @return JDatabaseQuery A query object.
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
$app = JFactory::getApplication();
// Select all fields from the table.
$query->select(
$this->getState(
'list.select',
$db->quoteName(
array(
'a.id', 'a.menutype', 'a.title',
'a.alias', 'a.note', 'a.path',
'a.link', 'a.type', 'a.parent_id',
'a.level', 'a.published',
'a.component_id', 'a.checked_out',
'a.checked_out_time', 'a.browserNav',
'a.access', 'a.img',
'a.template_style_id', 'a.params', 'a.lft',
'a.rgt', 'a.home', 'a.language',
'a.client_id'
),
array(
null, null, null, null, null, null, null, null, null,
null, 'a.published', null, null, null, null,
null, null, null, null, null, null, null, null, null
)
)
)
);
$query->select(
'CASE ' .
' WHEN a.type = ' . $db->quote('component') .
' THEN a.published+2*(e.enabled-1) ' .
' WHEN a.type = ' . $db->quote('url') . '
AND a.published != -2 THEN a.published+2 ' .
' WHEN a.type = ' . $db->quote('url') . '
AND a.published = -2 THEN a.published-1 ' .
' WHEN a.type = ' . $db->quote('alias') . '
AND a.published != -2 THEN a.published+4 ' .
' WHEN a.type = ' . $db->quote('alias') . '
AND a.published = -2 THEN a.published-1 ' .
' WHEN a.type = ' . $db->quote('separator') .
' AND a.published != -2 THEN a.published+6 ' .
' WHEN a.type = ' . $db->quote('separator') .
' AND a.published = -2 THEN a.published-1 ' .
' WHEN a.type = ' . $db->quote('heading') .
' AND a.published != -2 THEN a.published+8 ' .
' WHEN a.type = ' . $db->quote('heading') .
' AND a.published = -2 THEN a.published-1 ' .
' WHEN a.type = ' . $db->quote('container') .
' AND a.published != -2 THEN a.published+8 ' .
' WHEN a.type = ' . $db->quote('container') .
' AND a.published = -2 THEN a.published-1 ' .
' END AS published '
);
$query->from($db->quoteName('#__menu') . ' AS
a');
// Join over the language
$query->select('l.title AS language_title, l.image AS
language_image, l.sef AS language_sef')
->join('LEFT', $db->quoteName('#__languages')
. ' AS l ON l.lang_code = a.language');
// Join over the users.
$query->select('u.name AS editor')
->join('LEFT', $db->quoteName('#__users') .
' AS u ON u.id = a.checked_out');
// Join over components
$query->select('c.element AS componentname')
->join('LEFT', $db->quoteName('#__extensions')
. ' AS c ON c.extension_id = a.component_id');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
// Join over the menu types.
$query->select($db->quoteName(array('mt.id',
'mt.title'), array('menutype_id',
'menutype_title')))
->join('LEFT', $db->quoteName('#__menu_types',
'mt') . ' ON ' . $db->qn('mt.menutype') .
' = ' . $db->qn('a.menutype'));
// Join over the associations.
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$subQuery = $db->getQuery(true)
->select('COUNT(' .
$db->quoteName('asso1.id') . ') > 1')
->from($db->quoteName('#__associations',
'asso1'))
->join('INNER',
$db->quoteName('#__associations', 'asso2') . '
ON ' . $db->quoteName('asso1.key') . ' = ' .
$db->quoteName('asso2.key'))
->where(
array(
$db->quoteName('asso1.id') . ' = ' .
$db->quoteName('a.id'),
$db->quoteName('asso1.context') . ' = ' .
$db->quote('com_menus.item'),
)
);
$query->select('(' . $subQuery . ') AS ' .
$db->quoteName('association'));
}
// Join over the extensions
$query->select('e.name AS name')
->join('LEFT', '#__extensions AS e ON e.extension_id =
a.component_id');
// Exclude the root category.
$query->where('a.id > 1')
->where('a.client_id = ' . (int)
$this->getState('filter.client_id'));
// Filter on the published state.
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('a.published IN (0, 1)');
}
// Filter by search in title, alias or id
if ($search = trim($this->getState('filter.search')))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
elseif (stripos($search, 'link:') === 0)
{
if ($search = substr($search, 5))
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('a.link LIKE ' . $search);
}
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('(' . 'a.title LIKE ' . $search .
' OR a.alias LIKE ' . $search . ' OR a.note LIKE ' .
$search . ')');
}
}
// Filter the items over the parent id if set.
$parentId = $this->getState('filter.parent_id');
if (!empty($parentId))
{
$level = $this->getState('filter.level');
// Create a subquery for the sub-items list
$subQuery = $db->getQuery(true)
->select('sub.id')
->from('#__menu as sub')
->join('INNER', '#__menu as this ON sub.lft >
this.lft AND sub.rgt < this.rgt')
->where('this.id = ' . (int) $parentId);
if ($level)
{
$subQuery->where('sub.level <= this.level + ' . (int)
($level - 1));
}
// Add the subquery to the main query
$query->where('(a.parent_id = ' . (int) $parentId . '
OR a.parent_id IN (' . (string) $subQuery . '))');
}
// Filter on the level.
elseif ($level = $this->getState('filter.level'))
{
$query->where('a.level <= ' . (int) $level);
}
// Filter the items over the menu id if set.
$menuType = $this->getState('filter.menutype');
// A value "" means all
if ($menuType == '')
{
// Load all menu types we have manage access
$query2 = $this->getDbo()->getQuery(true)
->select($this->getDbo()->qn(array('id',
'menutype')))
->from('#__menu_types')
->where('client_id = ' . (int)
$this->getState('filter.client_id'))
->order('title');
// Show protected items on explicit filter only
$query->where('a.menutype != ' .
$db->q('main'));
$menuTypes =
$this->getDbo()->setQuery($query2)->loadObjectList();
if ($menuTypes)
{
$types = array();
foreach ($menuTypes as $type)
{
if ($user->authorise('core.manage',
'com_menus.menu.' . (int) $type->id))
{
$types[] = $query->q($type->menutype);
}
}
$query->where($types ? 'a.menutype IN(' .
implode(',', $types) . ')' : 0);
}
}
// Default behavior => load all items from a specific menu
elseif (strlen($menuType))
{
$query->where('a.menutype = ' . $db->quote($menuType));
}
// Empty menu type => error
else
{
$query->where('1 != 1');
}
// Filter on the access level.
if ($access = $this->getState('filter.access'))
{
$query->where('a.access = ' . (int) $access);
}
// Implement View Level Access
if (!$user->authorise('core.admin'))
{
$groups = $user->getAuthorisedViewLevels();
if (!empty($groups))
{
$query->where('a.access IN (' . implode(',',
$groups) . ')');
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$query->where('a.language = ' . $db->quote($language));
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.lft')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Method to allow derived classes to preprocess the form.
*
* @param JForm $form A JForm object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @since 3.2
* @throws Exception if there is an error in the form event.
*/
protected function preprocessForm(JForm $form, $data, $group =
'content')
{
$name = $form->getName();
if ($name == 'com_menus.items.filter')
{
$clientId = $this->getState('filter.client_id');
$form->setFieldAttribute('menutype', 'clientid',
$clientId);
}
elseif (false !== strpos($name, 'com_menus.items.modal.'))
{
$form->removeField('client_id');
$clientId = $this->getState('filter.client_id');
$form->setFieldAttribute('menutype', 'clientid',
$clientId);
}
}
/**
* Get the client id for a menu
*
* @param string $menuType The menutype identifier for the menu
* @param boolean $check Flag whether to perform check against ACL
as well as existence
*
* @return integer
*
* @since 3.7.0
*/
protected function getMenu($menuType, $check = false)
{
$query = $this->_db->getQuery(true);
$query->select('a.*')
->from($this->_db->qn('#__menu_types',
'a'))
->where('menutype = ' . $this->_db->q($menuType));
$cMenu = $this->_db->setQuery($query)->loadObject();
if ($check)
{
// Check if menu type exists.
if (!$cMenu)
{
JLog::add(JText::_('COM_MENUS_ERROR_MENUTYPE_NOT_FOUND'),
JLog::ERROR, 'jerror');
return false;
}
// Check if menu type is valid against ACL.
elseif (!JFactory::getUser()->authorise('core.manage',
'com_menus.menu.' . $cMenu->id))
{
JLog::add(JText::_('JERROR_ALERTNOAUTHOR'), JLog::ERROR,
'jerror');
return false;
}
}
return $cMenu;
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 3.0.1
*/
public function getItems()
{
$store = $this->getStoreId();
if (!isset($this->cache[$store]))
{
$items = parent::getItems();
$lang = JFactory::getLanguage();
$client = $this->state->get('filter.client_id');
if ($items)
{
foreach ($items as $item)
{
if ($extension = $item->componentname)
{
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null,
false, true)
|| $lang->load("$extension.sys", JPATH_ADMINISTRATOR .
'/components/' . $extension, null, false, true);
}
// Translate component name
if ($client === 1)
{
$item->title = JText::_($item->title);
}
}
}
$this->cache[$store] = $items;
}
return $this->cache[$store];
}
}
menu.php000064400000020617151164367570006246 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
/**
* Menu Item Model for Menus.
*
* @since 1.6
*/
class MenusModelMenu extends JModelForm
{
/**
* The prefix to use with controller messages.
*
* @var string
* @since 1.6
*/
protected $text_prefix = 'COM_MENUS_MENU';
/**
* Model context string.
*
* @var string
*/
protected $_context = 'com_menus.menu';
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
return JFactory::getUser()->authorise('core.delete',
'com_menus.menu.' . (int) $record->id);
}
/**
* Method to test whether the state of a record can be edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
return $user->authorise('core.edit.state',
'com_menus.menu.' . (int) $record->id);
}
/**
* Returns a Table object, always creating it
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'MenuType', $prefix =
'JTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication('administrator');
// Load the User state.
$id = $app->input->getInt('id');
$this->setState('menu.id', $id);
// Load the parameters.
$params = JComponentHelper::getParams('com_menus');
$this->setState('params', $params);
}
/**
* Method to get a menu item.
*
* @param integer $itemId The id of the menu item to get.
*
* @return mixed Menu item data object on success, false on failure.
*
* @since 1.6
*/
public function &getItem($itemId = null)
{
$itemId = (!empty($itemId)) ? $itemId : (int)
$this->getState('menu.id');
// Get a menu item row instance.
$table = $this->getTable();
// Attempt to load the row.
$return = $table->load($itemId);
// Check for a table object error.
if ($return === false && $table->getError())
{
$this->setError($table->getError());
return false;
}
$properties = $table->getProperties(1);
$value = ArrayHelper::toObject($properties, 'JObject');
return $value;
}
/**
* Method to get the menu item form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_menus.menu', 'menu',
array('control' => 'jform', 'load_data'
=> $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_menus.edit.menu.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
else
{
unset($data['preset']);
}
$this->preprocessData('com_menus.menu', $data);
return $data;
}
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return array|boolean Array of filtered data if valid, false
otherwise.
*
* @see JFormRule
* @see JFilterInput
* @since 3.9.23
*/
public function validate($form, $data, $group = null)
{
if (!JFactory::getUser()->authorise('core.admin',
'com_menus'))
{
if (isset($data['rules']))
{
unset($data['rules']);
}
}
return parent::validate($form, $data, $group);
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$dispatcher = JEventDispatcher::getInstance();
$id = (!empty($data['id'])) ? $data['id'] :
(int) $this->getState('menu.id');
$isNew = true;
// Get a row instance.
$table = $this->getTable();
// Include the plugins for the save events.
JPluginHelper::importPlugin('content');
// Load the row if saving an existing item.
if ($id > 0)
{
$isNew = false;
$table->load($id);
}
// Bind the data.
if (!$table->bind($data))
{
$this->setError($table->getError());
return false;
}
// Check the data.
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Trigger the before event.
$result = $dispatcher->trigger('onContentBeforeSave',
array($this->_context, &$table, $isNew));
// Store the data.
if (in_array(false, $result, true) || !$table->store())
{
$this->setError($table->getError());
return false;
}
// Trigger the after save event.
$dispatcher->trigger('onContentAfterSave',
array($this->_context, &$table, $isNew));
$this->setState('menu.id', $table->id);
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to delete groups.
*
* @param array $itemIds An array of item ids.
*
* @return boolean Returns true on success, false on failure.
*
* @since 1.6
*/
public function delete($itemIds)
{
$dispatcher = JEventDispatcher::getInstance();
// Sanitize the ids.
$itemIds = ArrayHelper::toInteger((array) $itemIds);
// Get a group row instance.
$table = $this->getTable();
// Include the plugins for the delete events.
JPluginHelper::importPlugin('content');
// Iterate the items to delete each one.
foreach ($itemIds as $itemId)
{
if ($table->load($itemId))
{
// Trigger the before delete event.
$result = $dispatcher->trigger('onContentBeforeDelete',
array($this->_context, $table));
if (in_array(false, $result, true) || !$table->delete($itemId))
{
$this->setError($table->getError());
return false;
}
// Trigger the after delete event.
$dispatcher->trigger('onContentAfterDelete',
array($this->_context, $table));
// TODO: Delete the menu associations - Menu items and Modules
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Gets a list of all mod_mainmenu modules and collates them by menutype
*
* @return array
*
* @since 1.6
*/
public function &getModules()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->from('#__modules as a')
->select('a.id, a.title, a.params, a.position')
->where('module = ' . $db->quote('mod_menu'))
->select('ag.title AS access_title')
->join('LEFT', '#__viewlevels AS ag ON ag.id =
a.access');
$db->setQuery($query);
$modules = $db->loadObjectList();
$result = array();
foreach ($modules as &$module)
{
$params = new Registry($module->params);
$menuType = $params->get('menutype');
if (!isset($result[$menuType]))
{
$result[$menuType] = array();
}
$result[$menuType][] = & $module;
}
return $result;
}
/**
* Custom clean the cache
*
* @param string $group Cache group name.
* @param integer $clientId Application client id.
*
* @return void
*
* @since 1.6
*/
protected function cleanCache($group = null, $clientId = 0)
{
parent::cleanCache('com_menus', 0);
parent::cleanCache('com_modules');
parent::cleanCache('mod_menu', 0);
parent::cleanCache('mod_menu', 1);
}
}
menus.php000064400000013653151164367570006433 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Menu List Model for Menus.
*
* @since 1.6
*/
class MenusModelMenus extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'menutype', 'a.menutype',
'client_id', 'a.client_id',
);
}
parent::__construct($config);
}
/**
* Overrides the getItems method to attach additional metrics to the list.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 1.6.1
*/
public function getItems()
{
// Get a storage key.
$store = $this->getStoreId('getItems');
// Try to load the data from internal storage.
if (!empty($this->cache[$store]))
{
return $this->cache[$store];
}
// Load the list items.
$items = parent::getItems();
// If empty or an error, just return.
if (empty($items))
{
return array();
}
// Getting the following metric by joins is WAY TOO SLOW.
// Faster to do three queries for very large menu trees.
// Get the menu types of menus in the list.
$db = $this->getDbo();
$menuTypes = ArrayHelper::getColumn((array) $items,
'menutype');
// Quote the strings.
$menuTypes = implode(
',',
array_map(array($db, 'quote'), $menuTypes)
);
// Get the published menu counts.
$query = $db->getQuery(true)
->select('m.menutype, COUNT(DISTINCT m.id) AS
count_published')
->from('#__menu AS m')
->where('m.published = 1')
->where('m.menutype IN (' . $menuTypes . ')')
->group('m.menutype');
$db->setQuery($query);
try
{
$countPublished = $db->loadAssocList('menutype',
'count_published');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Get the unpublished menu counts.
$query->clear('where')
->where('m.published = 0')
->where('m.menutype IN (' . $menuTypes . ')');
$db->setQuery($query);
try
{
$countUnpublished = $db->loadAssocList('menutype',
'count_published');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Get the trashed menu counts.
$query->clear('where')
->where('m.published = -2')
->where('m.menutype IN (' . $menuTypes . ')');
$db->setQuery($query);
try
{
$countTrashed = $db->loadAssocList('menutype',
'count_published');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Inject the values back into the array.
foreach ($items as $item)
{
$item->count_published = isset($countPublished[$item->menutype])
? $countPublished[$item->menutype] : 0;
$item->count_unpublished =
isset($countUnpublished[$item->menutype]) ?
$countUnpublished[$item->menutype] : 0;
$item->count_trashed = isset($countTrashed[$item->menutype]) ?
$countTrashed[$item->menutype] : 0;
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
return $this->cache[$store];
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select all fields from the table.
$query->select($this->getState('list.select', 'a.id,
a.menutype, a.title, a.description, a.client_id'))
->from($db->quoteName('#__menu_types') . ' AS
a')
->where('a.id > 0');
$query->where('a.client_id = ' . (int)
$this->getState('client_id'));
// Filter by search in title or menutype
if ($search = trim($this->getState('filter.search')))
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('(' . 'a.title LIKE ' . $search .
' OR a.menutype LIKE ' . $search . ')');
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.id')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* 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.6
*/
protected function populateState($ordering = 'a.title',
$direction = 'asc')
{
$search = $this->getUserStateFromRequest($this->context .
'.search', 'filter_search');
$this->setState('filter.search', $search);
$clientId = (int) $this->getUserStateFromRequest($this->context .
'.client_id', 'client_id', 0, 'int');
$this->setState('client_id', $clientId);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Gets the extension id of the core mod_menu module.
*
* @return integer
*
* @since 2.5
*/
public function getModMenuId()
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('e.extension_id')
->from('#__extensions AS e')
->where('e.type = ' . $db->quote('module'))
->where('e.element = ' .
$db->quote('mod_menu'))
->where('e.client_id = ' . (int)
$this->getState('client_id'));
$db->setQuery($query);
return $db->loadResult();
}
/**
* Gets a list of all mod_mainmenu modules and collates them by menutype
*
* @return array
*
* @since 1.6
*/
public function &getModules()
{
$model = JModelLegacy::getInstance('Menu',
'MenusModel', array('ignore_request' => true));
$result = $model->getModules();
return $result;
}
}
menutypes.php000064400000036065151164367570007337 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.path');
/**
* Menu Item Types Model for Menus.
*
* @since 1.6
*/
class MenusModelMenutypes extends JModelLegacy
{
/**
* A reverse lookup of the base link URL to Title
*
* @var array
*/
protected $rlu = array();
/**
* Method to auto-populate the model state.
*
* This method should only be called once per instantiation and is
designed
* to be called on the first call to the getState() method unless the
model
* configuration flag to ignore the request is set.
*
* @return void
*
* @note Calling getState in this method will result in recursion.
* @since 3.0.1
*/
protected function populateState()
{
parent::populateState();
$app = JFactory::getApplication();
$clientId = $app->input->get('client_id', 0);
$this->state->set('client_id', $clientId);
}
/**
* Method to get the reverse lookup of the base link URL to Title
*
* @return array Array of reverse lookup of the base link URL to Title
*
* @since 1.6
*/
public function getReverseLookup()
{
if (empty($this->rlu))
{
$this->getTypeOptions();
}
return $this->rlu;
}
/**
* Method to get the available menu item type options.
*
* @return array Array of groups with menu item types.
*
* @since 1.6
*/
public function getTypeOptions()
{
jimport('joomla.filesystem.file');
$lang = JFactory::getLanguage();
$list = array();
// Get the list of components.
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('name, element AS ' .
$db->quoteName('option'))
->from('#__extensions')
->where('type = ' . $db->quote('component'))
->where('enabled = 1')
->order('name ASC');
$db->setQuery($query);
$components = $db->loadObjectList();
foreach ($components as $component)
{
$options = $this->getTypeOptionsByComponent($component->option);
if ($options)
{
$list[$component->name] = $options;
// Create the reverse lookup for link-to-name.
foreach ($options as $option)
{
if (isset($option->request))
{
$this->addReverseLookupUrl($option);
if (isset($option->request['option']))
{
$componentLanguageFolder = JPATH_ADMINISTRATOR .
'/components/' . $option->request['option'];
$lang->load($option->request['option'] .
'.sys', JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load($option->request['option'] .
'.sys', $componentLanguageFolder, null, false, true);
}
}
}
}
}
// Allow a system plugin to insert dynamic menu types to the list shown
in menus:
JEventDispatcher::getInstance()->trigger('onAfterGetMenuTypeOptions',
array(&$list, $this));
return $list;
}
/**
* Method to create the reverse lookup for link-to-name.
* (can be used from onAfterGetMenuTypeOptions handlers)
*
* @param JObject $option with request array or string and title
public variables
*
* @return void
*
* @since 3.1
*/
public function addReverseLookupUrl($option)
{
$this->rlu[MenusHelper::getLinkKey($option->request)] =
$option->get('title');
}
/**
* Get menu types by component.
*
* @param string $component Component URL option.
*
* @return array
*
* @since 1.6
*/
protected function getTypeOptionsByComponent($component)
{
$options = array();
$client =
JApplicationHelper::getClientInfo($this->getState('client_id'));
$mainXML = $client->path . '/components/' . $component .
'/metadata.xml';
if (is_file($mainXML))
{
$options = $this->getTypeOptionsFromXml($mainXML, $component);
}
if (empty($options))
{
$options = $this->getTypeOptionsFromMvc($component);
}
if ($client->id == 1 && empty($options))
{
$options = $this->getTypeOptionsFromManifest($component);
}
return $options;
}
/**
* Get the menu types from an XML file
*
* @param string $file File path
* @param string $component Component option as in URL
*
* @return array|boolean
*
* @since 1.6
*/
protected function getTypeOptionsFromXml($file, $component)
{
$options = array();
// Attempt to load the xml file.
if (!$xml = simplexml_load_file($file))
{
return false;
}
// Look for the first menu node off of the root node.
if (!$menu = $xml->xpath('menu[1]'))
{
return false;
}
else
{
$menu = $menu[0];
}
// If we have no options to parse, just add the base component to the
list of options.
if (!empty($menu['options']) &&
$menu['options'] == 'none')
{
// Create the menu option for the component.
$o = new JObject;
$o->title = (string) $menu['name'];
$o->description = (string) $menu['msg'];
$o->request = array('option' => $component);
$options[] = $o;
return $options;
}
// Look for the first options node off of the menu node.
if (!$optionsNode = $menu->xpath('options[1]'))
{
return false;
}
else
{
$optionsNode = $optionsNode[0];
}
// Make sure the options node has children.
if (!$children = $optionsNode->children())
{
return false;
}
// Process each child as an option.
foreach ($children as $child)
{
if ($child->getName() == 'option')
{
// Create the menu option for the component.
$o = new JObject;
$o->title = (string) $child['name'];
$o->description = (string) $child['msg'];
$o->request = array('option' => $component,
(string) $optionsNode['var'] => (string)
$child['value']);
$options[] = $o;
}
elseif ($child->getName() == 'default')
{
// Create the menu option for the component.
$o = new JObject;
$o->title = (string) $child['name'];
$o->description = (string) $child['msg'];
$o->request = array('option' => $component);
$options[] = $o;
}
}
return $options;
}
/**
* Get menu types from MVC
*
* @param string $component Component option like in URLs
*
* @return array|boolean
*
* @since 1.6
*/
protected function getTypeOptionsFromMvc($component)
{
$options = array();
$client =
JApplicationHelper::getClientInfo($this->getState('client_id'));
// Get the views for this component.
if (is_dir($client->path . '/components/' . $component))
{
$folders = JFolder::folders($client->path . '/components/'
. $component, '^view[s]?$', false, true);
}
$path = '';
if (!empty($folders[0]))
{
$path = $folders[0];
}
if (is_dir($path))
{
$views = JFolder::folders($path);
}
else
{
return false;
}
foreach ($views as $view)
{
// Ignore private views.
if (strpos($view, '_') !== 0)
{
// Determine if a metadata file exists for the view.
$file = $path . '/' . $view . '/metadata.xml';
if (is_file($file))
{
// Attempt to load the xml file.
if ($xml = simplexml_load_file($file))
{
// Look for the first view node off of the root node.
if ($menu = $xml->xpath('view[1]'))
{
$menu = $menu[0];
// If the view is hidden from the menu, discard it and move on to
the next view.
if (!empty($menu['hidden']) &&
$menu['hidden'] == 'true')
{
unset($xml);
continue;
}
// Do we have an options node or should we process layouts?
// Look for the first options node off of the menu node.
if ($optionsNode = $menu->xpath('options[1]'))
{
$optionsNode = $optionsNode[0];
// Make sure the options node has children.
if ($children = $optionsNode->children())
{
// Process each child as an option.
foreach ($children as $child)
{
if ($child->getName() == 'option')
{
// Create the menu option for the component.
$o = new JObject;
$o->title = (string) $child['name'];
$o->description = (string) $child['msg'];
$o->request = array('option' => $component,
'view' => $view, (string) $optionsNode['var'] =>
(string) $child['value']);
$options[] = $o;
}
elseif ($child->getName() == 'default')
{
// Create the menu option for the component.
$o = new JObject;
$o->title = (string) $child['name'];
$o->description = (string) $child['msg'];
$o->request = array('option' => $component,
'view' => $view);
$options[] = $o;
}
}
}
}
else
{
$options = array_merge($options, (array)
$this->getTypeOptionsFromLayouts($component, $view));
}
}
unset($xml);
}
}
else
{
$options = array_merge($options, (array)
$this->getTypeOptionsFromLayouts($component, $view));
}
}
}
return $options;
}
/**
* Get menu types from Component manifest
*
* @param string $component Component option like in URLs
*
* @return array|boolean
*
* @since 3.7.0
*/
protected function getTypeOptionsFromManifest($component)
{
// Load the component manifest
$fileName = JPATH_ADMINISTRATOR . '/components/' . $component .
'/' . str_replace('com_', '', $component) .
'.xml';
if (!is_file($fileName))
{
return false;
}
if (!($manifest = simplexml_load_file($fileName)))
{
return false;
}
// Check for a valid XML root tag.
if ($manifest->getName() != 'extension')
{
return false;
}
$options = array();
// Start with the component root menu.
$rootMenu = $manifest->administration->menu;
// If the menu item doesn't exist or is hidden do nothing.
if (!$rootMenu || in_array((string) $rootMenu['hidden'],
array('true', 'hidden')))
{
return $options;
}
// Create the root menu option.
$ro = new stdClass;
$ro->title = (string) trim($rootMenu);
$ro->description = '';
$ro->request = array('option' => $component);
// Process submenu options.
$submenu = $manifest->administration->submenu;
if (!$submenu)
{
return $options;
}
foreach ($submenu->menu as $child)
{
$attributes = $child->attributes();
$o = new stdClass;
$o->title = (string) trim($child);
$o->description = '';
if ((string) $attributes->link)
{
parse_str((string) $attributes->link, $request);
}
else
{
$request = array();
$request['option'] = $component;
$request['act'] = (string) $attributes->act;
$request['task'] = (string) $attributes->task;
$request['controller'] = (string) $attributes->controller;
$request['view'] = (string) $attributes->view;
$request['layout'] = (string) $attributes->layout;
$request['sub'] = (string) $attributes->sub;
}
$o->request = array_filter($request, 'strlen');
$options[] = new JObject($o);
// Do not repeat the default view link (index.php?option=com_abc).
if (count($o->request) == 1)
{
$ro = null;
}
}
if ($ro)
{
$options[] = new JObject($ro);
}
return $options;
}
/**
* Get the menu types from component layouts
*
* @param string $component Component option as in URLs
* @param string $view Name of the view
*
* @return array
*
* @since 1.6
*/
protected function getTypeOptionsFromLayouts($component, $view)
{
$options = array();
$layouts = array();
$layoutNames = array();
$lang = JFactory::getLanguage();
$path = '';
$client =
JApplicationHelper::getClientInfo($this->getState('client_id'));
// Get the views for this component.
if (is_dir($client->path . '/components/' . $component))
{
$folders = JFolder::folders($client->path . '/components/'
. $component, '^view[s]?$', false, true);
}
if (!empty($folders[0]))
{
$path = $folders[0] . '/' . $view . '/tmpl';
}
if (is_dir($path))
{
$layouts = array_merge($layouts, JFolder::files($path,
'.xml$', false, true));
}
else
{
return $options;
}
// Build list of standard layout names
foreach ($layouts as $layout)
{
// Ignore private layouts.
if (strpos(basename($layout), '_') === false)
{
// Get the layout name.
$layoutNames[] = basename($layout, '.xml');
}
}
// Get the template layouts
// TODO: This should only search one template -- the current template for
this item (default of specified)
$folders = JFolder::folders($client->path . '/templates',
'', false, true);
// Array to hold association between template file names and templates
$templateName = array();
foreach ($folders as $folder)
{
if (is_dir($folder . '/html/' . $component . '/' .
$view))
{
$template = basename($folder);
$lang->load('tpl_' . $template . '.sys',
$client->path, null, false, true)
|| $lang->load('tpl_' . $template . '.sys',
$client->path . '/templates/' . $template, null, false, true);
$templateLayouts = JFolder::files($folder . '/html/' .
$component . '/' . $view, '.xml$', false, true);
foreach ($templateLayouts as $layout)
{
// Get the layout name.
$templateLayoutName = basename($layout, '.xml');
// Add to the list only if it is not a standard layout
if (array_search($templateLayoutName, $layoutNames) === false)
{
$layouts[] = $layout;
// Set template name array so we can get the right template for the
layout
$templateName[$layout] = basename($folder);
}
}
}
}
// Process the found layouts.
foreach ($layouts as $layout)
{
// Ignore private layouts.
if (strpos(basename($layout), '_') === false)
{
$file = $layout;
// Get the layout name.
$layout = basename($layout, '.xml');
// Create the menu option for the layout.
$o = new JObject;
$o->title = ucfirst($layout);
$o->description = '';
$o->request = array('option' => $component,
'view' => $view);
// Only add the layout request argument if not the default layout.
if ($layout != 'default')
{
// If the template is set, add in format template:layout so we save
the template name
$o->request['layout'] = isset($templateName[$file]) ?
$templateName[$file] . ':' . $layout : $layout;
}
// Load layout metadata if it exists.
if (is_file($file))
{
// Attempt to load the xml file.
if ($xml = simplexml_load_file($file))
{
// Look for the first view node off of the root node.
if ($menu = $xml->xpath('layout[1]'))
{
$menu = $menu[0];
// If the view is hidden from the menu, discard it and move on to
the next view.
if (!empty($menu['hidden']) &&
$menu['hidden'] == 'true')
{
unset($xml);
unset($o);
continue;
}
// Populate the title and description if they exist.
if (!empty($menu['title']))
{
$o->title = trim((string) $menu['title']);
}
if (!empty($menu->message[0]))
{
$o->description = trim((string) $menu->message[0]);
}
}
}
}
// Add the layout to the options array.
$options[] = $o;
}
}
return $options;
}
}
blank.php000064400000016343151164762160006364 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 10th April, 2021
@created 10th April, 2021
@package Blank
@subpackage blank.php
@author Mojtaba Taheri <http://lmskaran.com/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Blank Model
*/
class BlankModelBlank extends JModelList
{
public function getIcons()
{
// load user for access menus
$user = JFactory::getUser();
// reset icon array
$icons = array();
// view groups array
$viewGroups = array(
'main' => array()
);
// view access array
$viewAccess = array(
'blankadmins.submenu' => 'blankadmin.submenu');
// loop over the $views
foreach($viewGroups as $group => $views)
{
$i = 0;
if (BlankHelper::checkArray($views))
{
foreach($views as $view)
{
$add = false;
// external views (links)
if (strpos($view,'||') !== false)
{
$dwd = explode('||', $view);
if (count($dwd) == 3)
{
list($type, $name, $url) = $dwd;
$viewName = $name;
$alt = $name;
$url = $url;
$image = $name . '.' . $type;
$name = 'COM_BLANK_DASHBOARD_' .
BlankHelper::safeString($name,'U');
}
}
// internal views
elseif (strpos($view,'.') !== false)
{
$dwd = explode('.', $view);
if (count($dwd) == 3)
{
list($type, $name, $action) = $dwd;
}
elseif (count($dwd) == 2)
{
list($type, $name) = $dwd;
$action = false;
}
if ($action)
{
$viewName = $name;
switch($action)
{
case 'add':
$url = 'index.php?option=com_blank&view=' . $name .
'&layout=edit';
$image = $name . '_' . $action. '.' . $type;
$alt = $name . ' ' . $action;
$name =
'COM_BLANK_DASHBOARD_'.BlankHelper::safeString($name,'U').'_ADD';
$add = true;
break;
default:
// check for new convention (more stable)
if (strpos($action, '_qpo0O0oqp_') !== false)
{
list($action, $extension) = (array)
explode('_qpo0O0oqp_', $action);
$extension = str_replace('_po0O0oq_', '.',
$extension);
}
else
{
$extension = 'com_blank.' . $name;
}
$url =
'index.php?option=com_categories&view=categories&extension='
. $extension;
$image = $name . '_' . $action . '.' . $type;
$alt = $viewName . ' ' . $action;
$name = 'COM_BLANK_DASHBOARD_' .
BlankHelper::safeString($name,'U') . '_' .
BlankHelper::safeString($action,'U');
break;
}
}
else
{
$viewName = $name;
$alt = $name;
$url = 'index.php?option=com_blank&view=' . $name;
$image = $name . '.' . $type;
$name = 'COM_BLANK_DASHBOARD_' .
BlankHelper::safeString($name,'U');
$hover = false;
}
}
else
{
$viewName = $view;
$alt = $view;
$url = 'index.php?option=com_blank&view=' . $view;
$image = $view . '.png';
$name = ucwords($view).'<br /><br />';
$hover = false;
}
// first make sure the view access is set
if (BlankHelper::checkArray($viewAccess))
{
// setup some defaults
$dashboard_add = false;
$dashboard_list = false;
$accessTo = '';
$accessAdd = '';
// access checking start
$accessCreate = (isset($viewAccess[$viewName.'.create'])) ?
BlankHelper::checkString($viewAccess[$viewName.'.create']):false;
$accessAccess = (isset($viewAccess[$viewName.'.access'])) ?
BlankHelper::checkString($viewAccess[$viewName.'.access']):false;
// set main controllers
$accessDashboard_add =
(isset($viewAccess[$viewName.'.dashboard_add'])) ?
BlankHelper::checkString($viewAccess[$viewName.'.dashboard_add']):false;
$accessDashboard_list =
(isset($viewAccess[$viewName.'.dashboard_list'])) ?
BlankHelper::checkString($viewAccess[$viewName.'.dashboard_list']):false;
// check for adding access
if ($add && $accessCreate)
{
$accessAdd = $viewAccess[$viewName.'.create'];
}
elseif ($add)
{
$accessAdd = 'core.create';
}
// check if access to view is set
if ($accessAccess)
{
$accessTo = $viewAccess[$viewName.'.access'];
}
// set main access controllers
if ($accessDashboard_add)
{
$dashboard_add =
$user->authorise($viewAccess[$viewName.'.dashboard_add'],
'com_blank');
}
if ($accessDashboard_list)
{
$dashboard_list =
$user->authorise($viewAccess[$viewName.'.dashboard_list'],
'com_blank');
}
if (BlankHelper::checkString($accessAdd) &&
BlankHelper::checkString($accessTo))
{
// check access
if($user->authorise($accessAdd, 'com_blank') &&
$user->authorise($accessTo, 'com_blank') &&
$dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (BlankHelper::checkString($accessTo))
{
// check access
if($user->authorise($accessTo, 'com_blank') &&
$dashboard_list)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (BlankHelper::checkString($accessAdd))
{
// check access
if($user->authorise($accessAdd, 'com_blank') &&
$dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
$i++;
}
}
else
{
$icons[$group][$i] = false;
}
}
return $icons;
}
}
blankadmin.php000064400000051201151164762160007365 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 10th April, 2021
@created 10th April, 2021
@package Blank
@subpackage blankadmin.php
@author Mojtaba Taheri <http://lmskaran.com/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Blank Blankadmin Model
*/
class BlankModelBlankadmin extends JModelAdmin
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array();
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_BLANK';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_blank.blankadmin';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'blankadmin', $prefix =
'BlankTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR .
'/components/com_blank/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
if (!empty($item->id))
{
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id,
'com_blank.blankadmin');
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
* @param array $options Optional array of options for the form
creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options =
array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_blank.blankadmin',
'blankadmin', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = JFactory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we
need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to
0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 &&
(!$user->authorise('core.edit.state',
'com_blank.blankadmin.' . (int) $id))
|| ($id == 0 &&
!$user->authorise('core.edit.state', 'com_blank')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled',
'true');
$form->setFieldAttribute('published', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter',
'unset');
$form->setFieldAttribute('published', 'filter',
'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if (!$user->authorise('core.edit.created_by',
'com_blank'))
{
// Disable fields for display.
$form->setFieldAttribute('created_by',
'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by',
'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter',
'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if (!$user->authorise('core.edit.created',
'com_blank'))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled',
'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter',
'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null,
'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView,
'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId,
'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return
'administrator/components/com_blank/models/forms/blankadmin.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = JFactory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete',
'com_blank.blankadmin.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record.
Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('core.edit.state',
'com_blank.blankadmin.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absense of better information, revert to the component
permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check specific edit permission then general edit permission.
return JFactory::getUser()->authorise('core.edit',
'com_blank.blankadmin.'. ((int) isset($data[$key]) ? $data[$key]
: 0)) or parent::allowEdit($data, $key);
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__blank_blankadmin'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_blank.edit.blankadmin.data',
array());
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_blank.blankadmin', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return false;
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type =
$this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = BlankHelper::getActions('blankadmin');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver =
$this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy',
'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands,
$pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on
failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = BlankHelper::getActions('blankadmin');
}
if (!$this->canDo->get('core.create') ||
!$this->canDo->get('core.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
$values['published'] = 0;
}
$newIds = array();
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values
if (BlankHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (BlankHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField =
$this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal
error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = BlankHelper::getActions('blankadmin');
}
if (!$this->canDo->get('core.edit') &&
!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) &&
!$this->canDo->get('core.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit',
$contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND',
$pk));
continue;
}
}
// insert all set values.
if (BlankHelper::checkArray($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 &&
isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk,
$this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) &&
isset($data['metadata']['author']))
{
$data['metadata']['author'] =
$filter->clean($data['metadata']['author'],
'TRIM');
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the Params Items to data
if (isset($data['params']) &&
is_array($data['params']))
{
$params = new JRegistry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (BlankHelper::checkArray($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] =
$this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
}
blankadmins.php000064400000014276151164762160007563 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 10th April, 2021
@created 10th April, 2021
@package Blank
@subpackage blankadmins.php
@author Mojtaba Taheri <http://lmskaran.com/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Blankadmins Model
*/
class BlankModelBlankadmins extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by'
);
}
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
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited =
$app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context .
'.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context .
'.filter.created_by', 'filter_created_by',
'');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context .
'.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context .
'.filter.sorting', 'filter_sorting', 0,
'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the blank_item table
$query->from($db->quoteName('#__blank_blankadmin',
'a'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering',
'a.id');
$orderDirn = $this->state->get('list.direction',
'desc');
if ($orderCol != '')
{
$query->order($db->escape($orderCol . ' ' .
$orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' .
$this->getState('filter.modified_by');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a
set time.
*
* @return a bool
*
*/
protected function checkInNow()
{
// Get set check in time
$time =
JComponentHelper::getParams('com_blank')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
// reset query
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__blank_blankadmin'));
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date
$date = JFactory::getDate()->modify($time)->toSql();
// reset query
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') .
'=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') .
'<\''.$date.'\''
);
// Check table
$query->update($db->quoteName('#__blank_blankadmin'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
return false;
}
}
forms/blankadmin.js000064400000002036151164762160010342
0ustar00/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 10th April, 2021
@created 10th April, 2021
@package Blank
@subpackage blankadmin.js
@author Mojtaba Taheri <http://lmskaran.com/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
forms/blankadmin.xml000064400000001227151164762160010527 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_blank/models/rules"
addfieldpath="/administrator/components/com_blank/models/fields"
>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this blankadmin"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_blank"
section="blankadmin"
/>
</fieldset>
</form>forms/filter_blankadmins.xml000064400000003065151164762160012261
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_blank/models/rules"
addfieldpath="/administrator/components/com_blank/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_BLANK_FILTER_SEARCH"
description="COM_BLANK_FILTER_SEARCH_BLANKADMINS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_BLANK_FILTER_PUBLISHED"
description="COM_BLANK_FILTER_PUBLISHED_BLANKADMINS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<input type="hidden" name="form_submited"
value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published
ASC">JSTATUS_ASC</option>
<option value="a.published
DESC">JSTATUS_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>