so i need to change the behavior of comments, so that an authenticated user can only administer the comments attached to nodes that user created. i'm just going to run through my thought process and what i did. i suspect i'm not understanding the proper way of doing things, so maybe someone can straighten me out.
i started out making a super simple module. two functions: hook_perm() added a 'administrate comments on own nodes' to the ACL. hook_db_rewrite_sql() grabbed the query used to list the comments on the comment_admin_overview page when user_access('administrate comments on own nodes') was true, and add an additional join, and an additional where clause so that the query only returned comments with nids (node ids) from nodes where the uid = $user->uid.
the first problem i had was getting the hook to grab the query. $primary_table = 'comments' and $primary_field = 'cid' failed to find the query i was looking for.
could someone describe exactly what the primary_field/table of a query is (or where i can find a definition)? never heard that terminology before, and google doesn't have much to say. here is the query:
SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid FROM comments c INNER JOIN users u ON u.uid = c.uid WHERE c.status = 0 ORDER BY timestamp DESC LIMIT 0, 50