Okay, as the title suggest, I need help four (more or less) unrelated issues that I'm struggling with. But let me set up the background a bit first.
I am developing a workflow driven site where users can submit articles. When submitting the article, they can choose from one of two workflow states. The first is to place the article in the approval queue, from where editors will continue the process by reviewing it and either approving or rejecting it. The second workflow state places the article in what I called a Article drafts folder (ADF). The article is not yet submitted for publication, but temporarily parked so the author can continue working on it at a later moment. The ADF is available to the author through a View. Only the author and the main administrator can access a user's ADF.
View menu item not playing nice
The above setup is currently working as described permission-wise. However, there is a two-part problem I'm having with the View that creates the ADF. The first one is probably simple to solve, but I'm apparently missing it. I want a menu item pointing to the ADF in the Navigation menu. Unfortunately, the menu item refused to be listed as anything other than child link to the My account menu item. This means a user must first click on my account, before being able to access his ADF. However, I don't want it listed as a child link.
As said, the content of the ADF is only available to the author of the articles and the main admin. This is done through a url like user/1/drafts. But, other users can of course manually replace the uid with someone else's. The ADF will not show the articles in the ADF to other users. In other words, user 2 cannot view the contents of user 3 ADF. So far so good, but instead of showing an Access denied, the View returns its empty text. Ideally, I'd rather have the page as unauthorized for anybody else but the author.
Change of comment permission
I have a supporting role called moderator. Moderators on my site are responsible for modering the replies to submitted articles and for all forum topics/posts. I want them to be able to bulk moderator comments through the admin/content/comment page, which indeed works. Unfortunately, this page comes with two tabs (List and Settings) that appear to be accessible with the same access permission, namely: administer comments. And that's just about the thing I didn't want. Moderators should only have access to the listing, administrators may obviously access both. So I tried to apply a quick and dirty core hack. Emphesis on tried. What I did was replacing line 177 in the comment.module with this:
//'access' => $access,
'access' => (user_access('access administration pages')),
The remarked one is the original, the second one my try at reassigning access permissions to the settings page. I had success doing a similar operation in a contrib module, but whatever I do, the comment module still provides the settings tab. I even tried testing by setting access to FALSE, but to no avail. Admittingly, it's been only since very recently that I started modifying Drupal code, so I may be overlooking something simple. Please note: I realize hacking the core modules is frowned upon. I will try to clean this up at a later stadium, unless someone has a better solution at hands.
Partial IMCE upload deactivation
This one revolves around the fact that I want users to be able to upload files through IMCE in a shared folder. But, they should only have the upload controls when they are submitting an article. Users who are posting a forum topic/post should be able to add files from the shared folder through IMCE, but should not have the upload controls at the bottom. The following code in imce.module is involved (lines 160-169):
if ($set->upload) {
$uploadform = '<form action="'.url('imce/upload').'" method="post" id="uploadform" enctype="multipart/form-data">
<input type="file" name="thefile" id="thefile" size="30" />
<input type="hidden" name="token" value="'. $token .'" />
<input type="submit" name="submit" value="'.t('Upload File').'" />'.
($set->nolimit ? '<input type="checkbox" checked="checked" name="scale" />'.t('Scale if necessary') : ($set->scale ? '<input type="hidden" value="1" name="scale" />' : '')).
($set->twidth&&$set->theight ? '<input type="checkbox" name="thumb" />'.t('Create thumbnail').' ('. $set->twidth .'x'. $set->theight .')' : '').'
</form>
<div class="limits">'. ($set->nolimit ? t('Dimensions for scaling') .' = <strong>'. $set->width .'x'. $set->height .'</strong>, '. t('Quota') .' = <strong>'. format_size($_SESSION['imcetotal']).'</strong>/'.t('Unlimited') : '<strong>'. t('Limits') .'</strong>: '. t('File size') .' = <strong>'. $set->filesize .' KB</strong>, '. t('Dimensions') .' = <strong>'. $set->width .'x'. $set->height .'</strong>, '. t('Quota') .' = <strong>'. format_size($_SESSION['imcetotal']) .'</strong>/'. $set->quota .' KB').'</div>';
}
I need to put this piece of code in an if statement, which would do something like this:
if (!(posting or editing a forum node or comment)) {
show upload controls as shown above
}
Unfortunately, I have no idea what I should be testing for. I tried testing for !($node->type == 'forum') but that always results in the controls showing. I also realize that users can still upload files for forum use by starting an article submission, but I want to try to prevent uploading non-article files as much as possible.
So...
All in all, I have four questions:
- How do I detach the View menu item from the My account menu item?
- How do I prevent other user's from accessing an author's ADF completely, instead of displaying a View's empty text?
- What am I doing wrong in my quick and diry comment fix, and is a better solution at hand?
- How can I disable the uploads controls in IMCE when a user accesses IMCE from a forum topic/post?
Many, many thanks in advance for your thoughts about this! :)
Comments
...
Hmmm... don't stack 4 issues together. It makes the post long and tedious.
Probably because the menus are cached (it's a $may_cache section), Either clear the cache or:
You can use the 'path_access' module to revoke access to the '.../comments/settings' path.
But it's not all you want/need. I guess you want to have a tab on the user page, and you want managers to have access to the ADF tab of any user.
There are quite a few details here. Each of the details can be managed by a line or two of code, or even by not coding at all. But if you want all the details, all the requirements, fulfilled, then you have to write some more code. Not much. Mainly to implement hook_menu().
Yes, I see your point. But here's not the best place for us to discuss IMCE hacks. Please open an issue against IMCE. I'd suggest a very simple scheme: the ability to pass one word, a CSS class, to the IMCE window. In your forum pages this class could be 'minimal'. Then, in your stylesheet you could do:
html.minimal upload-form {
display: none;
}
--
Help save BLOCKQUOTE
Thanks
I know. I was doubting about it prior to posting, but eventually decided on posting it this way instead of three posts right after each other. I probably should have gone that way afterall.
As for the rest, that will definitively help me get started in the right direction. It was indeed a menu caching problem. But Path Access does the job, although it still leaves the menu item in place. Not a major issue though, as it's only one link that is only available to site staff.
The ADF issue is something I'll probably need to look into later on though. For now it works, albeit not very pretty. Then again, the site is still in development, so it returns to the todo for now. What you said about access to managers is already in place. I got that part working with Workflow and Views alone.
Thanks again.