Search and Find actions

A place for users and developers of the Xataface to discuss and receive support.

Postby njw » Thu Aug 24, 2006 10:18 am

Is there a simple way to remove these options - I don't want users to be able to use search, I want them to use the defined hierarchy.

I guess it's something to do with permissions, but can't see how.

Many thanks for any help.
njw
 
Posts: 280
Joined: Wed Dec 31, 1969 5:00 pm

Postby Aoirthoir » Thu Aug 24, 2006 6:10 pm

You could use the ploneCustom.css to remove them. If you are running firefox you can go to http://www.userstyles.org/ and follow the links to download and install the extension. Then look into a copy of the source for any dataface page. Find the element you want to remove. Look for its ID then in css the code would be

#IDNAME {
display: none !important;
}

Or you can look for its class. Then type:

.classname {
display: none !important;
}

Or if you have several things you do not want to display you type

.classname, #idname, tagname, table, whatever, you, get idea {
display: none !important;
}

The reason to try it in userstyles first is to see if it actually works. Rarely you will have to refresh the page, as most times it will make the change immediately when you save your style.

When you are satisfied with the code you have working, go into ploneCustom.css and insert you code there. This file does not exist by default, so you will have to create it. Then somewhere near the beginning of plone.css you have the following line:

@import url(customPlone.css);

After saving, restart your browser.

For instance to remove your search at the top it is:

.search_form {
display: none !important;
}

To remove the Find tab just add this:

#table-tabs-find {
display: none !important;
}

So to sum up, you can add the following code to the top of plone.css in the dataface installation directory:

@import url(customPlone.css);

Then create customPlone.css and add these lines to it (along with any comments you wish to document why):


.search_form {
display: none !important;
}

#table-tabs-find {
display: none !important;
}

That is all you have to do.

Hope that helps bro.
Aoirthoir
 
Posts: 420
Joined: Wed Dec 31, 1969 5:00 pm

Postby Aoirthoir » Thu Aug 24, 2006 6:34 pm

Ok a couple explanations here. When I say the dataface source, I meant the GENERATED HTML PAGE...so in your browser on any page, click VIEW SOURCE...

The reason I do it this way, rather than looking at the generatING code..is because I can see my actual data. Then I can do a search on that data right in the view source window...and jump to it. I dont have to guess by looking at the dataface PHP..is this where my company name will go? is this where the list will go? Instead I am right there instantly.

Second the code in ploneCustom.css could be shortened to this:

.search_form, #table-tabs-find {
display: none !important;
}

That will get rid of your find and your search.
Aoirthoir
 
Posts: 420
Joined: Wed Dec 31, 1969 5:00 pm

Postby ierg » Thu Aug 24, 2006 11:15 pm

Thanks to Aoirthoir for the stylesheet solution.

There is another way, however, that is undocumented (I apologize for that).

To hide the search field in the upper right add the following to the beginning of your conf.ini file:

Code: Select all
hide_search=1


To disable the find tab, you would use permissions. The name of the permission is "find".
Hope this helps a little. I can elaborate if you want some more details on strategies.

Best regards

Steve
ierg
 

Postby shannah » Thu Aug 24, 2006 11:17 pm

Whoops,
was logged in under a different account for that last post... but it was me :)
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby njw » Fri Aug 25, 2006 1:21 am

Thanks Steve & Aoithoir. Can I assume that any of the prefs.* variables in can be set in conf.ini in the same way. E.g. show_table_tabs and show_tables_menu?
njw
 
Posts: 280
Joined: Wed Dec 31, 1969 5:00 pm

Postby njw » Fri Aug 25, 2006 1:48 am

Sorry Steve. I can see, just about how to get the current state of a permission, but I can't see how to amend it. Any chance of a scrap of code that shows how to disable the find permission?

Many thanks

Neil
njw
 
Posts: 280
Joined: Wed Dec 31, 1969 5:00 pm

Postby Aoirthoir » Fri Aug 25, 2006 7:49 am

Thanks for that info Mr. Steve.

As I delve into what you have done here with Dataface, I am more and more amazed. So many ways to change things. We've got that list I posted a while ago, and are going to consolidate it this week then shoot all those ideas over to the tracker for you and also make some more requests for on the clock type things. Ive been moved out of shipping now and am only going to be programming. So we want to speed our projects up a bit.
Aoirthoir
 
Posts: 420
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Fri Aug 25, 2006 11:32 am

Hi Neil,

There are a few ways to go about this. The cleanest way is to create a new role. You can do this by creating a permissions.ini file in your application folder. Roles are designated by sections of the permissions.ini file.

For example, let's make a new role that is the same as ADMIN but doesn't have access to the find tab:

Code: Select all
[MY_ADMIN extends ADMIN]
find=0


You can set a user as having these permissions using the getRolePermissions() method of the Dataface_PermissionsTool class as follows:

Code: Select all
function getPermissions(&$record){
    $perms =& Dataface_PermissionsTool::getRolePermissions('MY_ADMIN');
    return $perms;
}


Alternatively, if you can modify the permissions programatically by changing the array that is returned by getRolePermissions() etc..

e.g.

Code: Select all
function getPermissions(&$record){
    $perms = Dataface_PermissionsTool::ALL();
        //$perms contains all permissions now..
    // let's remove the find permission
    $perms['find'] = 0;
    return $perms;
}


Hope this helps a little.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby njw » Fri Aug 25, 2006 3:25 pm

Many thanks Steve. The extends bit is clever - should solve the problem fine.

Neil
njw
 
Posts: 280
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved