[Midas] getActionMenu params

Michael Grauer michael.grauer at kitware.com
Wed Jul 4 17:28:58 EDT 2012


I'm going to trace this one a bit further back to give you more insight
into the inner workings...

So the Notification.php of that that module registers for a callback of
CALLBACK_CORE_ITEM_VIEW_ACTIONMENU.  This is found in the
core/views/item/view.phtml file, which gets displayed when the
ItemController.viewAction is called.  In that view.phtml file we have this
line:

$htmltArray =
Zend_Registry::get('notifier')->callback("CALLBACK_CORE_ITEM_VIEW_ACTIONMENU",
array('item' => $this->itemDao, 'isModerator' => $this->isModerator,
'isAdmin' => $this->isAdmin));

This calls the callback in question with these params, which means any
module that registers with this callback will have its registered callback
handler called with these params.  These params are the itemDao, and then
permissions for the currently logged-in user, isModerator and isAdmin say
whether the current user has these permissions for the itemDao (the item
currently being viewed).  Moderator means the user can write to the item
and edit, Admin means the user has delete permissions on the item (and if
they are Admin, they are automatically Moderator also).

To tie this in a bit with writing controllers and views, in the view.phtml,
the "$this" in question is the view object.  The values of the view object
properties get populated in the controller, so looking in the
ItemController.php viewAction method, we see these two lines

$this->view->isAdmin = $this->Item->policyCheck($itemDao,
$this->userSession->Dao, MIDAS_POLICY_ADMIN);
$this->view->isModerator = $this->Item->policyCheck($itemDao,
$this->userSession->Dao, MIDAS_POLICY_WRITE);

Here the "$this" is the controller object, which populates its view object
(which is the "$this" in view.phtml) with values for isAdmin and
isModerator, and then once we are in the view object itself (in
view.pthml), we can refer to them by $this->isAdmin, etc.


Relating back to the question you actually asked   :)  , in your equivalent
of getActionMenu, maybe you only want to display an action link in the item
view for items where the current user is a moderator or admin (doesn't make
sense to display an action link to a user with read only access on an item,
or an anonymous/non-logged in user, if the link will lead them to some
behavior where they'll be editing the item, or if you don't want these
users to be able to execute this action).

I hope this answer helped more than it confused.

-Mike



On Wed, Jul 4, 2012 at 5:03 PM, Mona Wong <mona at sdsc.edu> wrote:

>
>         I see from the remoteprocessing/Notification.php that it has:
>
>   public function getActionMenu($params)
>     {
>     if($this->isExecutable($params) && $params['isModerator'] &&
> $params['item'] instanceof ItemDao)
>
>         I'm wondering what is the $params['isModerator'] used for and
> whether I should do the same checking as that module on the incoming
> parameters?
>
> Mona
>
> *********************************************
>     Mona Wong
>     Web & iPad Application Developer
>     San Diego Supercomputer Center
>
>     You are the light you wish to see.
> *********************************************
>
>
>
> _______________________________________________
> Midas mailing list
> Midas at public.kitware.com
> http://public.kitware.com/cgi-bin/mailman/listinfo/midas
>



-- 
Thanks,
Michael Grauer
R & D Engineer
Kitware, Inc.
919 969 6990 x322
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/midas/attachments/20120704/bf0e4a3d/attachment.html>


More information about the Midas mailing list