? .DS_Store ? viewOwn.patch Index: coherent_access.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/coherent_access/coherent_access.module,v retrieving revision 1.10 diff -u -p -r1.10 coherent_access.module --- coherent_access.module 2 Feb 2009 21:27:22 -0000 1.10 +++ coherent_access.module 9 Jul 2009 19:32:55 -0000 @@ -23,6 +23,15 @@ function _coherent_access_is_coherently_ return $accessible; } + +/** + * Implementation of hook_perm(). + */ +function coherent_access_perm() { + return array('access own content'); +} + + /** * Implementation of hook_form_alter */ @@ -186,6 +195,14 @@ function coherent_access_menu() { 'access callback' => 'coherent_access_access_user_shared_posts', 'access arguments' => array(1), ); + + $items['view_own_content'] = array( + 'title' => 'My content', + 'page callback' => 'coherent_access_pageView', + 'access arguments' => array('access own content'), + 'type' => MENU_NORMAL_ITEM + ); + return $items; } @@ -819,3 +836,57 @@ function coherent_access_access_user_sha return FALSE; } } + + +/* + * Creates the "Own Content" page. + */ +function coherent_access_pageView() { + global $user; + + //Add simple stylesheet. + drupal_add_css(drupal_get_path('module', 'coherent_view') . '/coherent-view-style.css'); + + //Get current types and nodes. + $types = variable_get('coherent_access_types', ''); + $nodes = coherent_access_get_user_nodes($user->uid); + + $list['viewer'] = t('View Only'); + $list['mine'] = t('Author'); + $list['editor'] = t('Editor'); + + if (!empty($nodes)) { + $newArray = array(); + + //Resort the data by node type. + foreach($nodes as $mode => $node) { + foreach($node as $nid => $info) { + $newArray[ $info['type'] ][$nid] = array(); + $newArray[ $info['type'] ][$nid]['title'] = $info['title']; + $newArray[ $info['type'] ][$nid]['permission'] = $list[$mode]; + } + } + + //Sort the array alphabetically by type. + ksort($newArray); + + $output = array(); + + //Create the output. + foreach($newArray as $type => $node) { + asort($node); + $output[$type]['data'] = ucfirst($type); + $output[$type]['class'] = 'node-type'; + $output[$type]['children'] = array(); + + foreach($node as $nid => $info) { + $output[$type]['children'][] = l($info['title'] . ' (' . $info['permission'] .')', 'node/'. $nid); + } + } + + return '