Fork me on GitHub

pnSecAtuh questions??  Bottom

  • Hey all I wanted to say thanks to all that have helped me with my module dev, especially jediping & markwest without you two I would have never overcome the issues I had so thank you very much.

    Anyway on to my question I need to setup some permissions for users on my system for different views of the data returned from my functions. Now after taking a look at the example module I am not sure that things are working the way I think they should. I have an if statement in my module like this:

    Code

    if (pnSecAuthAction(0, 'pnDiagram::', "$item[site_name]::$item[tid]", ACCESS_OVERVIEW)) {
                $pnRender->assign($item);
                if (pnSecAuthAction(0, 'pnDiagram::', "$item[site_name]::$item[tid]", ACCESS_READ)) {
                    $pnDiagramitems[] = $pnRender->fetch('pnDiagram_user_row_read.htm', $item['tid']);
                } else {
                    $pnDiagramitems[] = $pnRender->fetch('pnDiagram_user_row_overview.htm', $item['tid']);
                }
            }


    Now if I am correct this should test for the given users level of access to the given item/id and return a template for that in the form of overview or read is that correct or I am reading this wrong as I can see no difference.


    Thanks all
    -SUNADMN
  • That's correct. The overview template will be used for those users with only overview permissions and the read template for those with read permissions. Obviously if the templates are both the same then everyone will see the same.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • OK mark I wasn't sure that I was thinking correctly there so good deal I was correct and I just need to add a new edit template. Now another quick question on that would be can I do an options loop and add those to the returned valuse as in the pnadmin file?? I guess the correct question here is what would be the corret method of adding those options for edit to the template.


    Thanks
    -SUNADMN
  • OK well after playing around with things a bit I tried the following:

    Code

    foreach ($items as $item) {

            if (pnSecAuthAction(0, 'pnDiagram::', "$item[site_name]::$item[tid]", ACCESS_OVERVIEW)) {
                $pnRender->assign($item);
                        if (pnSecAuthAction(0, 'pnDiagram::', "$item[site_name]::$item[tid]", ACCESS_READ)) {
                    $pnDiagramitems[] = $pnRender->fetch('pnDiagram_user_row_read.htm', $item['tid']);
                } elseif (pnSecAuthAction(0, 'pnDiagram::', "$item[site_name]::$item[tid]", ACCESS_EDIT)) {
                    $pnDiagramitems[] = $pnRender->fetch('pnDiagram_user_row_edit.htm', $item[tid]);
                } else {
                    $pnDiagramitems[] = $pnRender->fetch('pnDiagram_user_row_overview.htm', $item['tid']);
                }

            }

        }


    This works for the most part, but the issue I have is that when I view my items I get two links for the given item I have added edit permissions too, i.e.:

    Code

    This is our Read file
    Amherst  [link here]
    This is our edit file
    Amherst [link here]


    So here again am I doing the permissions wrong here can I not have three views for the items??


    Thanks all
    -SUNADMN
  • sunadmn


    Code

    foreach ($items as $item) {
            if (pnSecAuthAction(0, 'pnDiagram::', "$item[site_name]::$item[tid]", ACCESS_OVERVIEW)) {
                $pnRender->assign($item);
                        if (pnSecAuthAction(0, 'pnDiagram::', "$item[site_name]::$item[tid]", ACCESS_READ)) {
                    $pnDiagramitems[] = $pnRender->fetch('pnDiagram_user_row_read.htm', $item['tid']);
                } elseif (pnSecAuthAction(0, 'pnDiagram::', "$item[site_name]::$item[tid]", ACCESS_EDIT)) {
                    $pnDiagramitems[] = $pnRender->fetch('pnDiagram_user_row_edit.htm', $item[tid]);
                } else {
                    $pnDiagramitems[] = $pnRender->fetch('pnDiagram_user_row_overview.htm', $item['tid']);
                }
            }
        }



    This code isn't exactly the same as the code you sent me in your Private Message, but the advice stays the same. Reverse the order of the ACCESS_EDIT and ACCESS_READ sections.

    Anyone who has ACCESS_EDIT status will also have ACCESS_READ status which means they will always get the 'read' template rather than the edit template.

    -Chris
  • 0 users

This list is based on users active over the last 60 minutes.