From 8e3601cda526364395e0ca694c5714fed828a025 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sat, 15 Aug 2009 15:38:12 -0400 Subject: [PATCH] working on permissions --- classes/WhatDidTheySayAdmin.php | 49 +++++++++++++++++++++++++++++---- classes/admin.inc | 45 +++++++++++++++++++++--------- 2 files changed, 76 insertions(+), 18 deletions(-) diff --git a/classes/WhatDidTheySayAdmin.php b/classes/WhatDidTheySayAdmin.php index 1061c96..f5bda31 100644 --- a/classes/WhatDidTheySayAdmin.php +++ b/classes/WhatDidTheySayAdmin.php @@ -10,9 +10,16 @@ class WhatDidTheySayAdmin { 'de' ), 'only_allowed_users' => false, - 'users' => array() + 'users' => array(), + 'capabilities' => array( + 'submit_transcription' => 'administrator', + 'approve_transcription' => 'administrator', + 'change_languages' => 'administrator' + ) ); + var $capabilities = array(); + var $language_file; var $all_languages = array(); var $notices = array(); @@ -24,8 +31,19 @@ class WhatDidTheySayAdmin { function init($what_did_they_say) { $this->what_did_they_say = $what_did_they_say; + $this->capabilities = array( + 'submit_transcription' => __('Submit transcriptions to a post', 'what-did-they-say'), + 'approve_transcription' => __('Approve transcriptions to a post', 'what-did-they-say'), + 'change_languages' => __('Change the available languages', 'what-did-they-say') + ); + add_action('admin_menu', array(&$this, 'admin_menu')); add_action('admin_notices', array(&$this, 'admin_notices')); + + if (current_user_can('edit_users')) { + add_action('edit_user_profile', array(&$this, 'edit_user_profile')); + add_action('show_user_profile', array(&$this, 'edit_user_profile')); + } wp_enqueue_script('prototype'); if (isset($_REQUEST['wdts'])) { @@ -115,6 +133,14 @@ class WhatDidTheySayAdmin { $this->_update_options('allowed_users', $allowed_users); } + + function handle_update_capabilities($capabilities) { + $options = get_option('what-did-they-say-options'); + $updated = false; + switch ($language_info['action']) { + case "capabilities": + } + } function handle_update_options($requested_options) { $updated_options = array( @@ -200,10 +226,6 @@ class WhatDidTheySayAdmin { $nonce = wp_create_nonce('what-did-they-say'); - $url = 'edit-comments.php?page=manage-transcriptions-wdts'; - - $nonce_url = add_query_arg('wdts[_nonce]', $nonce, $url); - include(dirname(__FILE__) . '/admin.inc'); } @@ -212,6 +234,23 @@ class WhatDidTheySayAdmin { var_dump($post->ID); } + + function edit_user_profile($user) { + $options = get_option('what-did-they-say-options'); + + if ($options['only_allowed_users']) { + $nonce = wp_create_nonce('what-did-they-say'); + $active = in_array($user->ID, $options['allowed_users']); ?> +

+ + + +
+ /> +
+ \ No newline at end of file diff --git a/classes/admin.inc b/classes/admin.inc index d96a227..4392950 100644 --- a/classes/admin.inc +++ b/classes/admin.inc @@ -1,7 +1,36 @@
-

+

-

+ +
+ + +

+ + + + + + + capabilities as $key => $label) { ?> + + + + + + + + + +
+ +
  + +
+
+

@@ -68,17 +97,7 @@ - - -

- - +