Currently I am trying to use group access level code under public static function. File is belong to 3rd part component and stays under the administrator folder. 3rd part component has own custom filed management and this file is containing classes about them.
I have two different access level for frontend users. For the commercial users I have tried to add below code but it doesn't work.
$user = JFactory::getUser();
if ($user->get('Commercial') == 1) {
Here is full code page.
<?php
// Access the file from Joomla environment
defined('_JEXEC') or die('Restricted access');
class JHtmlEditRAuction
{
/**
* DisplayFieldsHtml
*
* @param $row
* @param $fieldlist
* @param string $style
*
* @return null
*/
public static function DisplayFieldsHtml(&$row, $fieldlist, $style = 'div')
{
if (!count($fieldlist)) return NULL;
$page = $fieldlist[0]->page;
$cfg = CustomFieldsFactory::getConfig();
$category_filter = array();
if ($cfg['has_category'][$page]) {
$db = JFactory::getDBO();
$db->setQuery("SELECT `fid` FROM `#__" . APP_PREFIX . "_fields_categories` WHERE `cid` = '" . $row->cat . "'");
$category_filter = $db->loadColumn();
}
$flist = array();
$field_object = JTable::getInstance('FieldsTable', 'JTheFactory');
foreach ($fieldlist as $field) {
if ($field->categoryfilter && !in_array($field->id, $category_filter))
continue;
$field_type = CustomFieldsFactory::getFieldType($field->ftype);
$field_object->bind($field);
$f = new stdClass();
$f->field = clone $field;
$f->value = $row->{$field->db_name};
$f->html = $field_type->getFieldHTML($field_object, $row->{$field->db_name});
$flist[] = $f;
}
$func = 'DisplayFieldsHtml_' . ucfirst($style);
$html = self::$func($flist);
return $html;
}
/**
* DisplayFieldsHtml_Div
*
* @param $flist
*
* @return null|string
*/
public static function DisplayFieldsHtml_Div($flist)
{
if (!count($flist)) return NULL;
$html = '<div>';
foreach ($flist as $f) {
$tooltip = '';
if ($f->field->help) $tooltip = JHtml::_('tooltip', $f->field->help, NULL, JUri::root() . 'components/com_rbids/images/tooltip.png');
$html .= '<div class="auction_edit_field_container ';
// This is required as helper for 'required' handler in js validator
if ($f->field->compulsory) {
$html .= 'required">';
} else {
$html .= '">';
}
// Here is acces level code that I tried to use
$user = JFactory::getUser();
if ($user->get('Commercial') == 1)
{
if($f->field->css_class == 'commercialclass')
{
$html .= '<div class=" span3 auction_edit_field_label rbids_custom_field">' . JText::_($f->field->name) . '</div>
<div class=" span9 auction_edit_field_input">' . $f->html . $tooltip;
if ($f->field->compulsory) {
$html .= ' ' . JHtml::image(JUri::root() . 'components/com_rbids/images/requiredfield.gif', 'Required');
}
$html .= '</div>
<div style="clear: both;"></div>
</div>';
}
}
}
$html .= '</div>';
return $html;
}
}
I don't get any error on the page but also nothing comes to the page about related part.
To be honest I am not a PHP expert. I have learned everything on stackexchange and stackoverflow and keep trying to find answers here.
Hope somebody can help me about it.
Thanks in advance.
Regards