page list permissions links

Permalink
Hi,

I have a page list menu and want to display page links with permission restrictions to all users.

when the user clicks on a restricted page they should be redirected to the login page.

is this possible ?

thanks :)

teknojunkey
 
cssninja replied on at Permalink Reply
cssninja
Yes, it is possible and very easy.

Click Edit page and on the top bar click Permissions.

Below you have "Who can view this page?"
Just uncheck first checkbox - Guest.

Now, when the user clicks on this page, will have to be logged in to see the text.
teknojunkey replied on at Permalink Reply
teknojunkey
thanks ... this removes the link so that the guest cannot see the page.

I want the guest to see the page link then on click be redirected to the login / register page.
Mnkras replied on at Permalink Reply
Mnkras
then change the settings of the autonav block to allow them to see things they don't have access to
teknojunkey replied on at Permalink Reply
teknojunkey
hmmm page list, i guess ill have to use the autonav cheers
HighContrast replied on at Permalink Reply
Hi all,
was there ever a solution to the original post? I'm trying to carry this functionality out with the Dojo Page Filter. Unfortunately, I'm working to a tight deadline here so any help at all is greatly appreciated!

Thanks :)

Joe
russellfeeed replied on at Permalink Reply
russellfeeed
I've just modified the Page List Plus addon to do this, but it should be easy to override the core Page List in a similar way.

Just copy it to your blocks folder and look at the core Auto Nav module for inspiration:


These are the changes I made...

db.xml
=======
- add
<field name="displayUnavailablePages" type="I1">
         <unsigned ></unsigned>
         <notnull ></notnull>
         <default value="0" ></default>
      </field>

and in Settings -> Database XML -> Refresh core database tables and blocks

That'll add a displayUnavailablePages field to the btpagelist table.

page_list_form.php
==================
- add
<div class="ccm-block-field-group">
      <strong><?php echo t('Viewing Permissions')?></strong><br/>
      <?php echo $form->checkbox('displayUnavailablePages', 1, $displayUnavailablePages); ?>
      <?php echo t('Display pages to users even when those users cannot access those pages.')?>
   </div>


That'll show the checkbox when you add or edit the Page List block so you can switch this on or off.

controller.php
==============

in save() you'll need
$args['displayUnavailablePages'] = isset($args['displayUnavailablePages']) ? 1 : 0;


just before the parent::save($args), to save youe setting in the btpagelist table for each block.

in getPages() add
if ($row['displayUnavailablePages'] == true) {
            $pl->ignorePermissions();
         }

just before the if ($num > 0) {

This will ignore permissions when building the page list.



Near the top of get pages, change the following code so it caters for displayUnavailablePages.

if ($this->bID) {
            $q = "select num, cParentID, cThis, orderBy, orderBy2, ctID, displayAliases, keyword, attributes, rss, displayUnavailablePages from btPageListPlus where bID = '$bID'";
            $r = $db->query($q);
            if ($r) {
               $row = $r->fetchRow();
               $row['attributes'] = $this->parseCAV($row['attributes']);
            }
         } else {
            $row['num'] = $this->num;
            $row['cParentID'] = $this->cParentID;
            $row['cThis'] = $this->cThis;
            $row['orderBy'] = $this->orderBy;
            $row['orderBy2'] = $this->orderBy2;
            $row['ctID'] = $this->ctID;
            $row['keyword'] = $this->keyword;

This ensures we read the selection before we prepare each Page List block

Hope that helps.

Russell