Keyword

Solved: Proteggere articolo con password

More
5 years 3 weeks ago #171617 by Gians
Proteggere articolo con password was created by Gians
Buonasera, ho cercato in altre discussioni ma non sono riuscito a trovare una risposta precisa. L'argomento è stato trattato ma, credo, non risolto. In pratica io sto costruendo un portale, con l'integrazione di K2, all'interno del quale ogni utente può vedere solo l'elenco degli articoli di cui è autore, cioè devono essere privati. A parte l'Admin, ogni autore deve poter vedere solo e soltanto i suoi articoli. Ho studiato, forse non abbastanza, i permessi di Joomla, ma arrivo ad organizzarmi per categorie e non per singolo utente. Vorrei che la "privatizzazione" fosse automatica, cioè quando l'utente si registra automaticamente è abilitato solo per i suoi articoli, vorrei non dover intervenire io dopo ogni iscrizione per creare una categoria unica con permessi unici. Esiste un modo per far sì dunque che ciascuno veda solo quello che ha pubblicato, anche con K2? Lo scopo finale è che ogni utente possa vedere solo quello che lui ha pubblicato, ma non quello che gli altri hanno pubblicato. Grazie alla buna anima che mi aiuterà...

Please Log in or Create an account to join the conversation.

More
5 years 3 weeks ago #171631 by JoomlaWorks
Replied by JoomlaWorks on topic Proteggere articolo con password
It is possible but it requires some workarounds...

- First off, you only need a single "Submissions" category for all users. Either way, when editing items, users will only ever see their own items only.
- The K2 User module already has a link to your user's page. So you can use that as a quick way for the user to visit their page.
- The only thing that is left to "hide" is the link to the category "Submissions" and tags (in case a common tag is used in items by other users). If you do that, it will be much harder for the user to navigate somewhere else, except their user page.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
5 years 3 weeks ago #171635 by Gians
Replied by Gians on topic Proteggere articolo con password
So nice of you, I've tried and it can works, but the links of the articles are sequential (192, 193...), so I saw that if one changes the number, he can see the profile and the items of another user. I need an automated and complex link generator (for example agsdsd/&%=dsdafasd8.html), otherwise if anyone can change the number in the url and view other profiles. The item lists are hidden, but if the links are sequential, anyone can find them at random, isn't?
Thank you

Please Log in or Create an account to join the conversation.

More
5 years 3 weeks ago #171638 by JoomlaWorks
Replied by JoomlaWorks on topic Proteggere articolo con password
You can utilize some PHP code to check for the current user in K2 content and display pages IF the content matches the active user.

This could be at the top of your K2 template overrides for example (e.g. in item.php):
<?php

// Get current user object
$user = JFactory::getUser();

// Compare with current K2 content user (author)
if ($user->id == $this->item->author->id) {
   // Your item.php content goes here because the current user matches the K2 author
} else {
    echo 'You are now allowed to view this content';
}

This would probably be better served as a system plugin.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
5 years 3 weeks ago #171641 by Gians
Replied by Gians on topic Proteggere articolo con password
Thank you,
I made this, I've copied your code at begin of edit.php file, but:

1) every user still can see all items of all users;

2) is impossible to view the single item, even his own, because there's a white page with an error.

Can you help me?
Thanks, so nice of you

Please Log in or Create an account to join the conversation.

More
5 years 3 weeks ago #171647 by Gians
Replied by Gians on topic Update: Proteggere articolo con password
Hey, I did a lot of other tests: I've pushed the code into the "item.php" file, I did it directly and by override, I entered the code in various positions, but the result is always the same: each user still see the list of articles of all other users, so the privacy intervention did not work. Furthermore, if the user tries to enter the single article, both his own and that of other users, a blank page appears without any error. Am I wrong? Maybe it's not right where I added the script? Thank you

Please Log in or Create an account to join the conversation.

More
5 years 2 weeks ago #171666 by Gians
Replied by Gians on topic Solved: Proteggere articolo con password
Ehi, I solved in this way: when the user put in an item, I keep it in "unpublished mode", so only author can see all items that he wrote. With a little customization, the Admin can see all items, also unpublished. In this way, every user can't see items of other users. It works.
Thanks

Please Log in or Create an account to join the conversation.

More
5 years 1 week ago #171730 by JoomlaWorks
Replied by JoomlaWorks on topic Solved: Proteggere articolo con password
The code I gave you should go on the public listings, so on category.php, item.php and so on, NOT the edit form. That's why things didn't work out as expected.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum