Plugin Directory

Changeset 163529


Ignore:
Timestamp:
10/15/2009 02:11:29 AM (16 years ago)
Author:
johncoswell
Message:

bunch of bug fixes and per-user permissions

Location:
what-did-they-say/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • what-did-they-say/trunk/classes/WDTSTranscript.inc

    r161898 r163529  
    173173    return array_keys($languages);
    174174  }
     175
     176  function count() {
     177    return count($this->get_transcripts());
     178  }
    175179}
    176180
  • what-did-they-say/trunk/classes/WhatDidTheySayAdmin.inc

    r163323 r163529  
    336336
    337337    if (current_user_can('approve_transcriptions')) {
     338      // edit posts notification
     339      add_filter('manage_posts_columns', array(&$this, 'manage_posts_columns'));
     340      add_action('manage_posts_custom_column', array(&$this, 'manage_posts_custom_column'), 10, 2);
     341
     342      // dashboard widget
     343      //wp_add_dashboard_widget('dashboard_transcripts', __('Recent Queued Transcripts', 'what-did-they-say'), array(&$this, 'dashboard_transcripts'));
     344      //add_action('wp_dashboard_setup', array(&$this, 'add_dashboard_transcripts'));
     345
    338346      if (strpos($pagenow, "post") === 0) {
    339347        add_meta_box(
     
    372380  }
    373381
     382  /**
     383   * The edit posts column header.
     384   */
     385  function manage_posts_columns($columns) {
     386    $keys = array_keys($columns);
     387    $values = array_values($columns);
     388   
     389    $index = array_search('comments', $keys);
     390    if ($index === false) { $index = count($keys); }
     391
     392    array_splice($keys, $index, 0, array('transcripts'));
     393    array_splice($values, $index, 0, __('Trans'));
     394
     395    return array_combine($keys, $values);
     396  }
     397
     398  /**
     399   * The edit posts column. Needs a pretty icon.
     400   */
     401  function manage_posts_custom_column($name, $post_id) {
     402    if ($name === "transcripts") {
     403      $queued_transcript_object = new WDTSQueuedTranscript($post_id);
     404
     405      if (($queued_count = $queued_transcript_object->count()) > 0) {
     406        printf(__('%s queued', 'what-did-they-say'), $queued_count);
     407      }
     408    }
     409  }
    374410
    375411  /** Transcript Search Filters **/
     
    453489   * @return array The list of capabilities this user now has.
    454490   */
    455   function user_has_cap($capabilities, $requested_capabilities, $capability_name) {
     491  function user_has_cap($capabilities, $requested_capabilities, $args) {
     492    list($capability_name, $user_id) = $args;
     493   
    456494    $options = get_option('what-did-they-say-options');
    457495    if (is_array($options)) {
     
    467505      foreach ($requested_capabilities as $requested_capability) {
    468506        if (in_array($options['capabilities'][$requested_capability], $allowed_roles)) {
     507          $capabilities[$requested_capability] = true;
     508        }
     509      }
     510    }
     511
     512    $user_capabilities = get_usermeta($user_id, 'transcript_capabilities');
     513
     514    if (is_array($user_capabilities)) {
     515      foreach ($requested_capabilities as $requested_capability) {
     516        if (isset($user_capabilities[$requested_capability])) {
    469517          $capabilities[$requested_capability] = true;
    470518        }
     
    790838
    791839  /**
     840   * Update per-user capabilities.
     841   */
     842  function handle_update_user_capabilities($info) {
     843    global $wpdb;
     844
     845    $updated = false;
     846    if (current_user_can('edit_users')) {
     847      $users = $wpdb->get_results("SELECT ID, user_login from $wpdb->users ORDER BY user_login");
     848
     849      foreach ((array)$users as $user) {
     850        $user_capabilities = array();
     851
     852        foreach (array_keys($this->capabilities) as $key) {
     853          if (isset($info['user_capabilities'][$user->ID])) {
     854            if (isset($info['user_capabilities'][$user->ID][$key])) {
     855              $user_capabilities[$key] = true;
     856            }
     857          }
     858        }
     859
     860        if (!empty($user_capabilities)) {
     861          update_usermeta($user->ID, 'transcript_capabilities', $user_capabilities);
     862        } else {
     863          delete_usermeta($user->ID, 'transcript_capabilities');
     864        }
     865      }
     866     
     867      $updated = __('Per-user permissions updated.', 'what-did-they-say');
     868    }
     869    return $updated;
     870  }
     871
     872  /**
    792873   * Handle resettings what-did-they-say-options.
    793874   * @param array $info The part of the $_POST array for What Did They Say?!?
     
    909990    $suggested_amount = 20 + ($this->transcript_count * 0.1);
    910991
     992    $users = $wpdb->get_results("SELECT ID, user_login from $wpdb->users ORDER BY user_login");
     993
    911994    include('partials/admin.inc');
    912995  }
  • what-did-they-say/trunk/classes/partials/_capabilities.inc

    r161898 r163529  
    3030    </table>
    3131  </form>
     32
     33    <h3><?php _e('Per-user Permissions', 'what-did-they-say') ?></h3>
     34
     35    <p><?php _e('Give specified users permissions above and beyond their role permissions.', 'what-did-they-say') ?></p>
     36
     37  <form method="post">
     38    <input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
     39    <input type="hidden" name="wdts[module]" value="user-capabilities" />
     40    <table class="widefat fixed">
     41      <tr>
     42        <th width="15%">Login</th>
     43        <th colspan="3">Capabilities</th>
     44      </tr>
     45      <?php foreach ((array)$users as $user) {
     46        $user_capabilities = get_usermeta($user->ID, 'transcript_capabilities');
     47        if (!is_array($user_capabilities)) { $user_capabilities = array(); }
     48        ?>
     49        <tr>
     50          <th scope="row">
     51            <?php echo get_avatar($user->ID, 20) ?>
     52            <?php echo $user->user_login ?>
     53          </th>
     54          <?php foreach ($this->capabilities as $key => $label) { ?>
     55            <td>
     56              <label style="white-space: nowrap">
     57                <input type="checkbox"
     58                       name="wdts[user_capabilities][<?php echo $user->ID ?>][<?php echo $key ?>]"
     59                       value="yes"
     60                       <?php echo (isset($user_capabilities[$key])) ? 'checked="checked"' : '' ?>
     61                       />
     62                <?php echo $label ?>
     63              </label>
     64            </td>
     65          <?php } ?>
     66        </tr>
     67      <?php } ?>
     68      <tr>
     69        <td>&nbsp;</td>
     70        <td colspan="3">
     71          <input class="button" type="submit" value="<?php _e('Update per-user permissions', 'what-did-they-say') ?>" />
     72        </td>
     73      </tr>
     74    </table>
     75  </form>
    3276<?php } ?>
    3377
  • what-did-they-say/trunk/classes/partials/_manage-queued-transcripts.inc

    r163323 r163529  
    2020    <h3 style="margin-top: 0.5em"><?php echo $title ?></h3>
    2121    <?php
    22       foreach ($transcripts_to_show as $transcript) {
    23         include('_display-queued-transcript.inc');
    24       }
     22      foreach ($transcripts_to_show as $transcript) { include('_display-queued-transcript.inc'); }
    2523    ?>
    2624  <?php } ?>
  • what-did-they-say/trunk/classes/partials/_queued-transcript-contents.inc

    r161898 r163529  
    33<input type="hidden" name="wdts[post_id]" value="<?php echo $post->ID ?>" />
    44<input type="hidden" name="wdts[key]" value="<?php echo $transcript['key'] ?>" />
    5 <p><?php
     5<p>
     6  <?php
     7  echo get_avatar($transcript['user_id'], 20);
    68  printf(
    7     __('From <strong>%s</strong> in <strong>%s</strong>:', 'what-did-they-say'),
     9    __('<strong>%s</strong> in <strong>%s</strong>:', 'what-did-they-say'),
    810    $transcript_user->display_name,
    911    $language_options->get_language_name($transcript['language'])
  • what-did-they-say/trunk/classes/partials/admin.inc

    r163323 r163529  
    107107  };
    108108
    109   $('wdts-filters-to-use').observe('change', load_sample_transcript);
    110   $('refresh-filter-preview').observe('click', function(e) {
    111     Event.stop(e);
    112     load_sample_transcript();
    113   });
     109  if ($('wdts-filters-to-user')) {
     110    $('wdts-filters-to-use').observe('change', load_sample_transcript);
     111    $('refresh-filter-preview').observe('click', function(e) {
     112      Event.stop(e);
     113      load_sample_transcript();
     114    });
    114115
    115   Event.observe(window, 'load', load_sample_transcript);
     116    Event.observe(window, 'load', load_sample_transcript);
     117  }
    116118
    117119  <?php if (isset($_POST['wdts']['return_page'])) { ?>
  • what-did-they-say/trunk/readme.txt

    r163323 r163529  
    44Tags: admin, comics, webcomics, transcript, video, audio
    55Requires at least: 2.8
    6 Tested up to: 2.8.4
    7 Stable tag: 0.9.1
     6Tested up to: 2.9
     7Stable tag: 0.9.2
    88
    99What Did They Say?!? lets your users provide multilingual transcriptions to your media, in their language, quickly and securely.
     
    2424filters, create the directory `wp-content/transcript-filters`.
    2525
    26 **What Did They Say?!?** puts a menu item under Options. It also adds a meta box to post editing.
     26**What Did They Say?!?** puts a menu item under Options. It also adds a meta box to post editing and a new column in the Edit Posts lists which
     27indicates how many transcripts are awaiting approval.
    2728
    2829== Frequently Asked Questions ==
     
    6667* If a user submits a transcript to the queue, they can delete it before it's approved.
    6768
    68 Permissions are handed out based on role and is set under the *Capabilities* tab.
     69Permissions are handed out in two ways and are set under the *Capabilities* tab.
     70
     71* Based on role (Subscriber, Administrator, etc.)
     72* Per user
    6973
    7074= How do short codes work? =
     
    8993== Changelog ==
    9094
     95= 0.9.2 =
     96* JavaScript bugfixes.
     97* Per-user permissions.
     98* Visual feedback for number of queued transcripts per post.
    9199= 0.9.1 =
    92100* Bugfixes for transcript submission and theme editor global variable name collision.
  • what-did-they-say/trunk/test/WhatDidTheySayAdminTest.php

    r163323 r163529  
    6262    ), $result['capabilities']);
    6363  }
    64 
    65   function testHandleUpdateLanguages() {
    66     $this->markTestIncomplete();
    67   }
    6864}
    6965
  • what-did-they-say/trunk/test/selenium/TestDeletePost.html

    r161898 r163529  
    1919<tr>
    2020    <td>click</td>
    21     <td>link=Delete</td>
     21    <td>//a[contains(@class, &quot;submitdelete&quot;)]</td>
    2222    <td></td>
    2323</tr>
  • what-did-they-say/trunk/what-did-they-say.php

    r163323 r163529  
    44Plugin URI: http://www.coswellproductions.com/wordpress/wordpress-plugins/
    55Description: Manage and display text transcriptions of comics, videos, or other media.
    6 Version: 0.9.1
     6Version: 0.9.2
    77Author: John Bintz
    88Author URI: http://www.coswellproductions.com/wordpress/
     
    215215      ?>
    216216      <div style="display:none">
    217         <span id="wdts-opener-<?php echo $id = md5(rand()) ?>">[ <a href="#"><?php _e('Edit/Add Transcripts', 'what-did-they-say') ?></a> ]</span>
     217        <span id="wdts-opener-<?php echo $id = md5(rand()) ?>">[
     218          <a href="#"><?php _e('Edit/Add Transcripts', 'what-did-they-say') ?></a>
     219          <?php if (current_user_can('approve_transcriptions')) {
     220            if (($queued_count = $queued_transcript_object->count()) > 0) { ?>
     221              (<strong><?php printf(__('%d queued', 'what-did-they-say'), $queued_count) ?></strong>)
     222            <?php }
     223          } ?>
     224        ]</span>
    218225      </div>
    219226      <noscript>
  • what-did-they-say/trunk/what-did-they-say.pot

    r163323 r163529  
    77msgid ""
    88msgstr ""
    9 "Project-Id-Version: what-did-they-say 0.9.1\n"
     9"Project-Id-Version: what-did-they-say 0.9.2\n"
    1010"Report-Msgid-Bugs-To: \n"
    11 "POT-Creation-Date: 2009-10-14 07:54-0400\n"
     11"POT-Creation-Date: 2009-10-14 21:53-0400\n"
    1212"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1717"Content-Transfer-Encoding: 8bit\n"
    1818
    19 #: what-did-they-say.php:207
     19#: what-did-they-say.php:218
    2020msgid "Edit/Add Transcripts"
     21msgstr ""
     22
     23#: what-did-they-say.php:221
     24#, php-format
     25msgid "%d queued"
    2126msgstr ""
    2227
     
    7883
    7984#: classes/partials/meta-box.inc:37
    80 #: classes/partials/_manage-queued-transcripts.inc:37
     85#: classes/partials/_manage-queued-transcripts.inc:35
    8186msgid "Language:"
    8287msgstr ""
     
    9398msgstr ""
    9499
    95 #: classes/partials/_queued-transcript-contents.inc:7
    96 #, php-format
    97 msgid "From <strong>%s</strong> in <strong>%s</strong>:"
     100#: classes/partials/_queued-transcript-contents.inc:9
     101#, php-format
     102msgid "<strong>%s</strong> in <strong>%s</strong>:"
    98103msgstr ""
    99104
     
    625630msgstr ""
    626631
    627 #: classes/partials/_manage-queued-transcripts.inc:29
     632#: classes/partials/_manage-queued-transcripts.inc:27
    628633msgid "Submit a New Transcript:"
    629634msgstr ""
    630635
    631 #: classes/partials/_manage-queued-transcripts.inc:48
     636#: classes/partials/_manage-queued-transcripts.inc:46
    632637msgid "Submit For Approval"
    633638msgstr ""
     
    649654#: classes/partials/_capabilities.inc:27
    650655msgid "Change capabilities"
     656msgstr ""
     657
     658#: classes/partials/_capabilities.inc:33
     659msgid "Per-user Permissions"
     660msgstr ""
     661
     662#: classes/partials/_capabilities.inc:35
     663msgid ""
     664"Give specified users permissions above and beyond their role permissions."
     665msgstr ""
     666
     667#: classes/partials/_capabilities.inc:71
     668msgid "Update per-user permissions"
    651669msgstr ""
    652670
     
    802820msgstr ""
    803821
    804 #: classes/WhatDidTheySayAdmin.inc:341
     822#: classes/WhatDidTheySayAdmin.inc:349
    805823msgid "Manage Transcripts"
    806824msgstr ""
    807825
    808 #: classes/WhatDidTheySayAdmin.inc:551
     826#: classes/WhatDidTheySayAdmin.inc:393
     827msgid "Trans"
     828msgstr ""
     829
     830#: classes/WhatDidTheySayAdmin.inc:406
     831#, php-format
     832msgid "%s queued"
     833msgstr ""
     834
     835#: classes/WhatDidTheySayAdmin.inc:599
    809836msgid "Transcript added to queue."
    810837msgstr ""
    811838
    812 #: classes/WhatDidTheySayAdmin.inc:553
     839#: classes/WhatDidTheySayAdmin.inc:601
    813840msgid "Transcript not added to queue."
    814841msgstr ""
    815842
    816 #: classes/WhatDidTheySayAdmin.inc:629
     843#: classes/WhatDidTheySayAdmin.inc:677
    817844msgid "Transcripts updated."
    818845msgstr ""
    819846
    820 #: classes/WhatDidTheySayAdmin.inc:698
     847#: classes/WhatDidTheySayAdmin.inc:746
    821848msgid "Default styles option updated."
    822849msgstr ""
    823850
    824 #: classes/WhatDidTheySayAdmin.inc:714
     851#: classes/WhatDidTheySayAdmin.inc:762
    825852msgid "Insertion level updated."
    826853msgstr ""
    827854
    828 #: classes/WhatDidTheySayAdmin.inc:732
     855#: classes/WhatDidTheySayAdmin.inc:780
    829856#, php-format
    830857msgid "%s deleted."
    831858msgstr ""
    832859
    833 #: classes/WhatDidTheySayAdmin.inc:734
     860#: classes/WhatDidTheySayAdmin.inc:782
    834861msgid "Language not deleted!"
    835862msgstr ""
    836863
    837 #: classes/WhatDidTheySayAdmin.inc:741
     864#: classes/WhatDidTheySayAdmin.inc:789
    838865#, php-format
    839866msgid "%s added."
    840867msgstr ""
    841868
    842 #: classes/WhatDidTheySayAdmin.inc:743
     869#: classes/WhatDidTheySayAdmin.inc:791
    843870msgid "Language not added!"
    844871msgstr ""
    845872
    846 #: classes/WhatDidTheySayAdmin.inc:749
     873#: classes/WhatDidTheySayAdmin.inc:797
    847874#, php-format
    848875msgid "%s set as default."
    849876msgstr ""
    850877
    851 #: classes/WhatDidTheySayAdmin.inc:751
     878#: classes/WhatDidTheySayAdmin.inc:799
    852879msgid "Language not set as default!"
    853880msgstr ""
    854881
    855 #: classes/WhatDidTheySayAdmin.inc:757
     882#: classes/WhatDidTheySayAdmin.inc:805
    856883#, php-format
    857884msgid "%1$s renamed to %2$s."
    858885msgstr ""
    859886
    860 #: classes/WhatDidTheySayAdmin.inc:759
     887#: classes/WhatDidTheySayAdmin.inc:807
    861888msgid "Language not renamed!"
    862889msgstr ""
    863890
    864 #: classes/WhatDidTheySayAdmin.inc:782
     891#: classes/WhatDidTheySayAdmin.inc:830
    865892msgid "User capabilities updated."
    866893msgstr ""
    867894
    868 #: classes/WhatDidTheySayAdmin.inc:801
     895#: classes/WhatDidTheySayAdmin.inc:867
     896msgid "Per-user permissions updated."
     897msgstr ""
     898
     899#: classes/WhatDidTheySayAdmin.inc:882
    869900msgid "<strong>What Did They Say?!?</strong> options reset."
    870901msgstr ""
    871902
    872 #: classes/WhatDidTheySayAdmin.inc:820
     903#: classes/WhatDidTheySayAdmin.inc:901
    873904msgid "<strong>What Did They Say?!?</strong> core options changed."
    874905msgstr ""
Note: See TracChangeset for help on using the changeset viewer.