"manage own content only" permission

caktux - January 30, 2009 - 09:46
Project:Content Management Filter
Version:5.x-1.4
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:by design
Description

needed that functionality, hope it helps

AttachmentSize
cmf.module-5.x-1.4--manage_own_content_perm.patch1.3 KB

#1

Als - March 2, 2009 - 10:51

Tried it on Drupal 5.10 with CMF 5.x-1.4: works fine.
It is a much needed option and does not add much to module code. Hope it gets added in next release!

#2

canen - March 13, 2009 - 21:12

The patch works fine except there doesn't seem to be anyway to allow access to just a user's content. The 'filter and manage site content' permission seems to still be needed. In addition a count query is needed since if there are 100 nodes and I only created 5 I'll only see 5 but the pager will account for 100, hence it will still show up. The query needs to look something like this:

<?php


switch ($kind) {
    case
'node':
     
$count_query = "SELECT COUNT(*) FROM {node} n INNER JOIN {users} u ON n.uid = u.uid {$filter['join']} {$filter['where']}";

      return
pager_query('
        SELECT n.nid, n.title, n.type, u.name AS username, u.uid, n.status, n.created, n.changed
        FROM {node} n INNER JOIN {users} u ON n.uid = u.uid '
. $filter['join'] .
       
$filter['where'] .
       
tablesort_sql($header),
        isset(
$_SESSION['cmf_max_rows']) ? $_SESSION['cmf_max_rows'] : 50, 0, $count_query, $filter['args']
      );
      break;
    
    
//-------------
?>

The other queries will need to be taken into account as well.

#3

canen - March 13, 2009 - 21:33

OK, some updates on the permission front. This patch requires that the user have 'filter and manage site content' permission to view their own nodes in addition it allows you to view any other users content. The menu function needs to be changed get a proper user only content listing:

<?php
  
global $user; // new
  
   // arg(1) now checks against the current user's id
   
if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0 && arg(1) == $user->uid ) {
     
$items[] = array(
       
'path'        => 'user/'. arg(1) .'/cmf',
       
'title'       => t('CMF'),
       
'description' => t('User-specific content management filter'),
       
'callback'    => 'cmf_admin_content_page',
       
'access'      => $owner_access || $view_access, // replaced $manage_access with $owner_access
       
'type'        => MENU_LOCAL_TASK,
      );
    }
?>

I am just making notes as I go along.

#4

NancyDru - July 16, 2009 - 16:31
Status:needs review» needs work

Per canen, changing status. FYI, the count query problem is fixed.

#5

NancyDru - July 16, 2009 - 16:34

Since there is the CMF tab on the "My account" page, why give a my-content-only user 'filter and manage site content' permission to start with?

#6

NancyDru - August 1, 2009 - 18:21
Status:needs work» by design

IMO, this is handled with the permissions changes to the user tab. Feel free to reopen if you disagree.

 
 

Drupal is a registered trademark of Dries Buytaert.