I need to create a User-Specific content page, I have registered users and I need to create a module/page/menu/feed or whatever that displays articles that are for only one or some users.

For example, in my site, I show to public some projects (articles redacted as some architecturing project) for example: news, finished projects, etc, some people register and can access to other content that is intended for registered users, for example: new projects that only registered clients would be interested, so far, I managed to make this work, but now, I have work that is for a specific user and he/she only can see it in his/her feed, for example: status of their project made by us, some galleries with photos of the work in progress, etc.

So, This feed must be a module/page/menu that shows articles with a specific category and for registered users. But I want to be able to post an article that is only intended for a specific user or a set of users and shows in this feed (module) or at least a whole new module that shows user-specific content without having to create a category and an access level for each user.

Is there an extension or plug-in that helps me do this?

有帮助吗?

解决方案

you need to make do two things:

  • Make a new user-group (Users->User group) as a sub-group of registered. Add the users that need the special permission to this group.
  • Make a new access-level (Users->access-levels) and add you new user-group to this access level
  • Set the access-level on the article(s) that you want to restrict access on.

The module should check the access-level before it displays it to the users, and only display the restricted articles to those that have the correct privileges.

其他提示

The system don't really support what you ask for, but you could use the following setup:

Make a content-plugin (http://docs.joomla.org/J2.5:Creating_a_content_plugin). In the event onContentPrepareForm, you modify the created_by_alias-field to use it for your special user allowed to view this content article.

function onContentPrepareForm($form, $data){
    // first check that context is right
    // Then change the type of the field. This should allow to select 
    // the user when you create the article. 
    $form->getField('created_by_alias')->__set('type', 'user'); 
}

In the event onContentPrepareData, check if the data in the created_by_alias references a valid user in the user group your users shoud be in

public function onContentPrepare($context, $article, $params, $page){
    // first check that context is right
    //Then fetch the user data: 

    if(is_int($article->created_by_alias)){ // ( Optionally check if the article is in a specific category )
        $db=JFactory::getDbo(); 
        $currentuser=JFactory::getUser(); 
        $allowedgroup=2; // the registered users group
        $sql="select u.id from #__users inner join #__user_usergroup_map ug (u.id=ug.user_id) where ug.group_id={$allowedgroup}";  
        $db->setQuery($sql);
        $user=$db->loadObject();  
        if($user->id==$currentuser){
            $data->user=$user; 
        }
        else{
            //Unset the article content to prevent unothorized users from seeing the content. 
            unset($article); 
        }
}

Finally, create a module (http://docs.joomla.org/Creating_a_simple_module) that feeds articles for a particular user, containing at least:

$list=array(); 
$user=Jfactory::getUser(); 
if($user->id>0){
    $sql="select * from #__content where created_by_alias={$user->id}"; 
    // ( also add sql to check that the user has access, 
    // the article is published, the correct category etc)
    $db=Jfactory::getDbo(); 
    $db->setQuery($sql); 
    $list=$db->loadObjectList(); 
    if(!count($list)) return; 
}
else return; 
print_r($list); // Prints the content articles

This scheme should protect unauthorized users from viewing the content of the articles ment for a specific user. The module should (after nicely outputting what you want to display) display a list of articles for the logged inn user. The module can link to the article in the normal way, and the authorized user will have access. So it should be "safe enough", and provide the functionality you need without too much hassle.

I'll try anotherone here: You could just install a messageing system on your site. UddeIM is one such system. This will allow you to make specific content for your users. UddeIM can be configured so only administrators can send messages. There is also some modules for this component to show latest messages etc.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top