diff -u content_access.orgi/content_access.info content_access/content_access.info --- content_access.orgi/content_access.info 2008-06-11 02:02:14.000000000 +0200 +++ content_access/content_access.info 2008-06-13 10:45:49.000000000 +0200 @@ -2,8 +2,9 @@ name = Content Access description = Provides flexible content access control package = Access control +core = "6.x" ; Information added by drupal.org packaging script on 2008-06-11 -version = "5.x-1.x-dev" +version = "6.x-1.x-dev" project = "content_access" datestamp = "1213142534" diff -u content_access.orgi/content_access.install content_access/content_access.install --- content_access.orgi/content_access.install 2007-05-17 22:32:08.000000000 +0200 +++ content_access/content_access.install 2008-06-13 10:45:49.000000000 +0200 @@ -4,23 +4,8 @@ * Implementation of hook_install */ function content_access_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {content_access} ( - nid int(10) unsigned NOT NULL default '0', - settings mediumtext NOT NULL, - PRIMARY KEY (nid) - ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); - break; - case 'pgsql': - db_query("CREATE TABLE {content_access} ( - nid int_unsigned NOT NULL default '0', - settings text NOT NULL, - PRIMARY KEY (nid) - )"); - break; - } + // Create tables. + drupal_install_schema('content_access'); } /* @@ -28,5 +13,19 @@ */ function content_access_uninstall() { variable_del('content_access_settings'); - db_query('DROP TABLE {content_access}'); + // Remove tables. + drupal_uninstall_schema('content_access'); +} + /* + * Implementation of hook_schema + */ +function content_access_schema() { + $schema['content_access'] = array( + 'fields' => array( + 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), + 'settings' => array ('type' => 'text', 'not null' => FALSE, 'size' => 'medium'), + ), + 'primary key' => array('nid') + ); + return $schema; } diff -u content_access.orgi/content_access.module content_access/content_access.module --- content_access.orgi/content_access.module 2008-06-10 14:59:44.000000000 +0200 +++ content_access/content_access.module 2008-06-13 10:55:13.000000000 +0200 @@ -8,41 +8,30 @@ /* * Implementation of hook_menu(). */ -function content_access_menu($may_cache) { +function content_access_menu() { global $user; $items = array(); - if (!$may_cache) { - if (arg(0) == 'node' && is_numeric(arg(1))) { - $node = node_load(arg(1)); - if (!empty($node) && content_access_get_settings('per_node', $node->type)) { - $items[] = array('path' => 'node/'. $node->nid .'/access', 'title' => t('Access control'), - 'callback' => 'drupal_get_form', 'callback arguments' => array('content_access_page', $node->nid), - 'access' => user_access('grant content access') || (user_access('grant own content access') && ($user->uid == $node->uid)), - 'weight' => 5, - 'type' => MENU_LOCAL_TASK); - } - } - if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'types' && arg(3)) { - $type = str_replace('-', '_', arg(3)); - if ($type_name = node_get_types('name', $type)) { - $items[] = array( - 'path' => 'admin/content/types/'. arg(3) .'/edit', - 'title' => t('Edit'), - 'type' => MENU_DEFAULT_LOCAL_TASK, - ); - $items[] = array( - 'path' => 'admin/content/types/'. arg(3) .'/access', - 'title' => t('Access control'), - 'description' => t('Configure content access control.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('content_access_admin_settings', $type), - 'access' => user_access('administer nodes') && user_access('administer content types'), - 'type' => MENU_LOCAL_TASK, - 'weight' => 2, - ); - } - } + $items['node/%node/access'] = array( + 'title' => t('Access control'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('content_access_page', $node->nid), + // 'access' => user_access('grant content access') || (user_access('grant own content access') && ($user->uid == $node->uid)), + 'access arguments' => array ('grant content access'), + 'weight' => 5, + 'type' => MENU_LOCAL_TASK); + foreach (node_get_types('types', NULL, TRUE) as $type) { + $type_url_str = str_replace('_', '-', $type->type); + $items['admin/content/node-type/'. $type_url_str .'/access'] = array( + 'title' => t('Access control'), + 'description' => t('Configure content access control.'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('content_access_admin_settings'), + // 'access' => user_access('administer nodes') && user_access('administer content types'), + 'access arguments' => array ('administer content types'), + 'type' => MENU_LOCAL_TASK, + 'weight' => 2, + ); } return $items; } @@ -65,7 +54,8 @@ /* * Per node settings page. */ -function content_access_page($nid) { +function content_access_page() { + $nid = arg(1); $node = node_load($nid); drupal_set_title(check_plain($node->title)); @@ -159,7 +149,8 @@ return $form; } -function content_access_page_submit($form_id, $form_values) { +function content_access_page_submit($form_id, &$form_state) { + $form_values = $form_state['values']; $node = $form_values['node']; $settings = array(); foreach (array('view', 'update', 'delete') as $op) { @@ -183,7 +174,8 @@ /* * Per content type administration page form. */ -function content_access_admin_settings($type) { +function content_access_admin_settings() { + $type = arg(3); $roles = content_access_get_roles_and_author(); // Per node: $form['node'] = array( @@ -253,7 +245,8 @@ return $form; } -function content_access_admin_settings_submit($form_id, $form_values) { +function content_access_admin_settings_submit($form_id, &$form_state) { + $form_values = $form_state['values']; $per_node_old = content_access_get_settings('per_node', $form_values['type']); $settings = content_access_get_settings(); @@ -262,7 +255,7 @@ unset($form_values[$setting][0]); $form_values[$setting] = array_filter($form_values[$setting]); } - $settings[$setting][$form_values['type']] = $form_values[$setting]; + $settings[$setting][arg(3)] = $form_values[$setting]; } content_access_set_settings($settings);