User access to menu

General Forum
coolsteph
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 20 May 2008, 21:46
Location: France
Contact:

First, sorry for my

Post by coolsteph »

First, sorry for my bad english
Secondary, I'm not sur that is the good topic to post this

I use phocagallery (1.8.2) with Joomla 1.5 and and I find this very interesting component especially the users management functionality that allows users to to view a only certains gallery. But, even if they can't view de gallery, they see the menu link to all gallery, so i do a path to hide unnecessary links in ./modules/mod_mainmenu/helper.php, I replace the addNode by :

function addNode(&$params, $item)
{
// Get menu item data
$data = $this->_getItemData($params, $item);

/* Par dĂŠfaut, ajout du node */
$ajout = 1;

/* Analyse du lien (vĂŠrification pointage vers phocagallery) */
$loc_motif = "#option=(.*?)&#i";
preg_match_all($loc_motif,$item->link,$loc_option,PREG_SET_ORDER);
if (isset($loc_option[0][1]) && ($loc_option[0][1]== "com_phocagallery"))
{
/* Le lien pointe vers le composant : com_phocagallery *
* => recherche de l'id de la gallerie */
$loc_motif = "#id=(.*?)$#i";
preg_match_all($loc_motif,$item->link,$loc_id,PREG_SET_ORDER);

/* RĂŠcupĂŠration de l'objet database */
$db =& JFactory::getDBO();

/* Recherche de la catĂŠgorie Ă  laquelle appartient la gallerie */
$query = "SELECT * FROM #__phocagallery_categories WHERE id=".$loc_id[0][1].";";
$db->setQuery($query);
$category = $db->loadObjectList();

// Extraction des droits d'accès de la catÊgorie
$loc_motif = "#accessuserid=(.*?);#i";
preg_match_all($loc_motif,$category[0]->params,$list_id,PREG_SET_ORDER);

// Si rĂŠservĂŠ aux utilisateurs enregistrĂŠs (=-1)
if ($list_id[0][1] != -1)
{
/* Lecture de l'id de l'utilisateur connectĂŠ */
$user =& JFactory::getUser();
if( is_object($user) )
{
$userid = ",".$user->id.",";
}
else
{
$userid = ",0,";
}

/* Si le user connectĂŠ n'est pas dans la liste des users autorisĂŠs */
if (strpos(",,".$list_id[0][1],$userid) == FALSE)
{
/* L'item courant n'est pas ajoutĂŠ Ă  la liste */
$ajout = 0;
}
}
}

if ($ajout == 1)
{
// Create the node and add it
$node = new JMenuNode($item->id, $item->name, $item->access, $data);

if (isset($item->mid)) {
$nid = $item->mid;
} else {
$nid = $item->id;
}
$this->_nodeHash[$nid] =& $node;
$this->_current =& $this->_nodeHash[$item->parent];

if ($this->_current) {
$this->addChild($node, true);
} else {
// sanity check
JError::raiseError( 500, 'Orphan Error. Could not find parent for Item '.$item->id );
}
}
}



If someone have a better idea
CoolSteph.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

thank you for this i

Post by Jan »

thank you for this info...

Jan
If you find Phoca extensions useful, please support the project
Post Reply