Hi,
I have installed dhtmlxSpreadsheet plugin into my joomla ver. 2.5 webSite, but toolbar is avaible only by “Super User” joomla group.
I have tried to add a “newgroup” into file “spreadsheet_data.php” (and in Joomla User group of course), the Spreadsheet in front-end is correct but the toolbar is always missing, I dont’ know which is the problem.
Can you help me, please?
<?php
/*------------------------------------------------------------------------
# com_spreadsheet
# ------------------------------------------------------------------------
# author DHTMLX
# copyright (c) DHTMLX Ltd, 2011
# @license - [gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html) GNU/GPL
# Websites: [dhtmlx.com](http://www.dhtmlx.com)
# Technical Support: [forum.dhtmlx.com/](http://forum.dhtmlx.com/)
-------------------------------------------------------------------------*/
define('_JEXEC', 1);
// no direct access
defined('_JEXEC') or die('Restricted access');
define('DS', DIRECTORY_SEPARATOR);
$path = dirname(__FILE__);
$max = 0;
while (!file_exists($path.DS.'configuration.php') && $max < 10) {
$path .= DS."..";
$max++;
}
define('JPATH_BASE', $path);
require_once(JPATH_BASE.DS.'configuration.php');
require_once(JPATH_BASE.DS.'includes'.DS.'defines.php');
require_once(JPATH_BASE.DS.'includes'.DS.'framework.php');
require_once(JPATH_BASE.DS.'libraries'.DS.'joomla'.DS.'user'.DS.'helper.php');
$mainframe =& JFactory::getApplication ('site');
$mainframe->initialise ();
$mainframe->route();
require_once("./codebase/php/grid_cell_connector.php");
$cfg = new JConfig;
$db_host = $cfg->host;
$db_user = $cfg->user;
$db_pass = $cfg->password;
$db_name = $cfg->db;
$db_prefix = $cfg->dbprefix."dhx_";
$available_to = Array(
'Super Users' => true,
'superadministrator' => true,
'administrator' => true,
[b]'newgroup' => true,[/b]
'manager' => true
);
$res = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name, $res);
$user =& JFactory::getUser();
if (method_exists("JUserHelper", "getUserGroups")) {
// get user type in Joomla 1.6
$user =& JFactory::getUser();
$gr = Array();
// multiple user groups
$groups = $user->groups;
$names = dhx_getGroups();
foreach ($groups as $k => $v) {
$id = (string) $v;
$gr[] = $names[$id];
}
$usergroups = $gr;
} else {
// get user type in Joomla less then 1.6
switch($user->usertype) {
case '':
$usergroups = array('guest');
break;
case 'Super Administrator':
$usergroups = array('superadministrator');
break;
case 'New Group':
[b]$usergroups = array('newgroup');[/b]
break;
default:
$usergroups = array(strtolower($user->usertype));
}
}
$conn = new GridCellConnector($res, $db_prefix);
if (!dhx_can($available_to, $usergroups))
$conn->set_read_only(true);
$conn->render();
// gets all user groups list
function dhx_getGroups() {
$db = JFactory::getDBO();
$db->setQuery(
'SELECT a.id AS id, a.title AS title'.
' FROM #__usergroups AS a' .
' LEFT JOIN #__usergroups AS b ON a.lft > b.lft AND a.rgt < b.rgt' .
' GROUP BY a.id ORDER BY a.lft ASC'
);
$options = $db->loadObjectList();
$groups = array();
if ($options) {
foreach ($options as &$option)
$groups[$option->id] = $option->title;
} else {
$groups = array(
'registered' => 'Registered',
'author' => 'Author',
'editor' => 'Editor',
'publisher' => 'Publisher',
'manager' => 'Manager',
'administrator' => 'Administrator',
[b]'newsgroup' => 'New Group',[/b]
'superadministrator' => 'Super administrator'
);
}
return $groups;
}
function dhx_can($available_to, $usergroups) {
for ($i = 0; $i < count($usergroups); $i++)
if (isset($available_to[$usergroups[$i]]))
return true;
return false;
}
?>