37 Posts
PierreP
8 years ago
0
Topic

Hello,

Thank you to the Seblod equip for their great job !!!

I've got a category front-end form with a 42 field which creates a viewlevel for this category.

This is the code :

$myAccess = new stdClass();
$myAccess->title = 'PR - ' . $config['post']['cat_title'];
$myAccess->ordering = 0;
$myAccess->rules =
'[' . $config['post'][myField'] . ']';

$table = JTable::getInstance('viewlevel', 'JTable');
$data = (array)$myAccess;


if (!$table->bind($data)) {
     JFactory::getApplication()->enqueueMessage('Erreur : le niveau d\'accès n\'a pas pu être créé.', 'error');
} elseif (!$table->check()) {
     JFactory::getApplication()->enqueueMessage('Erreur : le niveau d\'accès n\'a pas pu être vérifié.', 'error');
} elseif (!$table->store()) {
     JFactory::getApplication()->enqueueMessage('Erreur : le niveau d\'accès n\'a pas pu être enregistrée.', 'error');
} else {

     // get the new view level id
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select($db->quoteName('id'));
     $query->from($db->quoteName('#__viewlevels'));
     $query->where($db->quoteName('title')." = ".$db->quote($myAccess->title));
     $db->setQuery($query);
     $idAccess = $db->loadResult();


     if (! is_null($idAccess)) {
         $config['storages']['#__categories']['access'] = $idAccess;
     }
}


This code works : it creates the category and the view level and the new category has the good access.

The only problem is after that, every content or category I create in the front end is created but not visible in Seblod list : I need to re-login to see them. Even the category with the special view level isn't visible in the list of all category in the front end. I need to re-login to see it. I am sure that's not a access problem because if I re-login I see them.

Can you help me please ?

Thank you in advance !

Get a VIP membership