Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help me understand action items 1

Status
Not open for further replies.

Hypermommy

Programmer
May 23, 2003
75
0
0
US
Hi all,

I'm stumped on how the function WriteActions works. Actually, I'm stumped on the whole actions thing. I list out the whole WriteActions() function here (unless asked) because everyone has it in their available.csp file that came standard with CE.

During the loop in WriteActions where it's building the action menu (line starts "actionMenu += " and then it goes on to add the latest actionItem to the menu) it appears that realObj (which I believe is a handle to a report instance) has an actions property. Is that right so far?

I guess what I'd like to do is find out:
1) How can I modify what properties are available with the various reports? Some of them we don't want to allow the users to "view". We'd rather they "schedule" it becuase it's better for the server, from what our tech says.

2) Is the actionitem something that's stored in the database or is it built somewhere else in the code? If built in the code, I could comment it out but if stored in the database I wouldn't want to delete it because then (if we change our minds) I'd have to back and re-add everything.

Am I on track here? I'm trying to exclude the action items of "View" and "View Latest Instance". I'm also trying to temporarily exclude the "Ad Hoc" action item.

Thanks all!

-= Hypermommy =-
 
whether a user can view or schedule is set up in the Crystal Management Console and these rights will be respected whether you are using eportfolio, modified eportfolio or a completely customised / self-written interface to CE.
i.e. if you set up a user/user group to be only able to schedule in the CMC, then when you log onto eportfolio that user will only see schedule, view latest instance & history in the menu that appears when they leftclick on a report.

hth

Icytrue

icytrue@hotmail.com

 
First off, thank you very much for your willingness to help. I don't want anything I say below to seem like I'm arguing... I'm just trying to understand ... and it's important to me that you know how much I appreciate the help.

Okay, so users rights are set up in the CMC. I understand that part. And I see in the code where it's checking the users rights to see if they're allowed to do an action item. But it appears to be comparing their rights to do an action item against something, presumably some record of the action item itself?

Or to put it another way, it seems that there are certain action items (View, View Latest, History, Schedule, etc.) and these seem to be kept somewhere. Then, when it's time to show them, the system does something to check which the user is allowed to see and only shows the user the allowable ones. But the items themselves, the potential items that could be shown to the user if they have the rights to see them, where does the system keep track of those?

Like, I've noticed that View Latest isn't available if there isn't a previously run instance of report. So there must be something in the running of a report that "flips a switch" as it were when the report is run that will let CE know, in the future, that there is a valid instance so View Latest is a potentially showable action item.

I hope I'm being clear. I'm very confused and haven't had enough coffee yet :)

-= Hypermommy =-
 
Did you ever get any real help on this item? The commnent you got did not really answer your questions.

I am currently trying to modify the action item list to add my OWN CUSTOM Action items. I supposed it's to be done in write actions but where all the informaiton comes from I do not know and cannot find.

Any help would be appreciated mui mucho!
 
No, I never really received anything. Wish i could help but I don't really understand it myself.

-= Hypermommy =-
 
Hi,
The rights are kept as part of the APS database ( CMS if using V10) and are coded in when you set them in the CMC..It is there , and only there, that it should be done.
There is no need to write custom code ( nor is it a simple task, without risking unexpected consequences) to set these standard access rights.

[profile]
 
As Turkbear says, the Actions come out of the APS, but customization is possible.

We have changed the names of the actions to be more understandable for our users.

We have also disabled View Last Report (View Latest Instance) if the latest instance is not owned by the logged-on user, unless the user or owner is Administrator. This was done using actionItemID == -10008, which identifies the View Latest Instance action. Unfortunately, I do not recall offhand where I found this correlation, but you may be able to find it by searching for string 10008 in the .csp and .js files.

Code:
function WriteActions(obj, realObj, index, instId)
...
//if( secinfoObj.CheckAction(actionItem.ID) )// Replaced
if( secinfoObj.CheckAction(actionItem.ID) //...
  && lcSecurity( actionItem.ID, instId, username) )// Added
{
   if(!actionMap[actionItem.Name]) 
   {
    var theAction = LC_ConvertAction( actionItem.Name);//Added
    actionMenu += ",[\"" + theAction + "\", \"javascript:SetPreviewVars("+GetID(obj)+",'"+realObj.Properties.Item("SI_PROGID")+"','"+Server.HTMLEncode(JSEncode(JSEncode(obj.Title)))+"',"+IsShortCut(obj)+"," + instId + "); handleAction(" + realObj.ID + " ,'" + actionItem.ID + "');\",1,0,0]"; // Define menu with converted action name.
...

function lcSecurity( actionItemID, instId, username)//Added
// This function is used to disable View Last Report if the
// (latest) instance is not owned by the logged-on user 
// (unless the user or owner is Administrator).
{
if ( actionItemID == -10008 && instId != -1)//-10008 is View Last Report
	try
	{
	var lastInstOwner = rsLastInst.Item("#" + instId).Properties.Item("SI_OWNER").value;
	if ( username != "Administrator" 
	  && username != lastInstOwner 
	  &&  lastInstOwner != "Administrator")
		return false;
	}
	catch(e)
	{
		return true;
	}
return true;
}

// Convert action names to Larimer County preferences.
function LC_ConvertAction( actionName)
{
switch( actionName)
{
case "View":			return "View From Database";
case "View Latest Instance":	return "View Last Report";
case "History":			return "Display Report History";
case "Schedule":		return "Set Report Schedule";
default: return actionName;
}
}
 
Sorry, the code was snipped from available.csp in the eportfolio folder. Search for "function WriteActions" in the file. I've got it at line 1985, but it's a highly customized version so your mile marker may vary. I put my custom functions right behind the WriteActions function.

You may also want to re-format the code. I left-justified a lot for posting here.

- Mike
 
I think I have solutions for a lot of people's problems....

To add a custom menu item is pretty easy. This is done in additions.csp and additions.js. The comments in these files say how to add items. Another good one to look at is actionscripts.js, if you need any kind of crazy javascript abilities for your menu item. It's pretty easy to figure out.

Setting security rules for your new menu item is a little bit more tricky. the WriteActions function in available.csp contains the required code... The first loop in this function checks out the default menu items. We want the next loop, the one that goes through gActionArray.

The CheckAction function will tell you if an object has rights to a certain action or not. This worked well for my project, because I only wanted the custom menu item to be visible when the default "View" option was inabled. A quick peek at actionscripts.js told me that the actionID for View was "-10000", so I put the following in WriteActions:
Code:
	for(var k in gActionArray)
	{
		if(realObj.Properties.Item("SI_PROGID") == gActionArray[k].progid)
		{
			var secinfoObj = realObj.SecurityInfo;
			if(secinfoObj.CheckAction("-10000")){
				actionMenu += ",[\"" + gActionArray[k].name + "\", \"javascript:SetPreviewVars("+GetID(obj)+",'"+realObj.Properties.Item("SI_PROGID")+"','"+Server.HTMLEncode(JSEncode(JSEncode(obj.Title)))+"',"+IsShortCut(obj)+"," + instId + "); handleAction(" + realObj.ID + " ,'" + gActionArray[k].id + "');\",1,0,0]";
				bNoActions = false;
			}
		}
	}

One drawback here is that this only works with predefined rights. So to block your custom menu, you'll have to block a regular one too (or find another way to do it).

I hope that helps everybody out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top