Plugin Directory

Changeset 487342


Ignore:
Timestamp:
01/10/2012 03:58:19 AM (14 years ago)
Author:
aueda
Message:

media file manager 1.1.0

Location:
media-file-manager
Files:
22 added
2 edited

Legend:

Unmodified
Added
Removed
  • media-file-manager/trunk/media-relocator.php

    r477345 r487342  
    44Plugin URI: http://tempspace.net/plugins/?page_id=111
    55Description: You can make sub-directories in the upload directory, and move files into them. At the same time, this plugin modifies the URLs/path names in the database. Also an alternative file-selector is added in the editing post/page screen, so you can pick up media files from the subfolders easily.
    6 Version: 1.0.2
     6Version: 1.1.0
    77Author: Atsushi Ueda
    88Author URI: http://tempspace.net/plugins/
     
    2020$mrelocator_uploadurl = mrl_adjpath($mrelocator_uploaddir_t['baseurl'], true);
    2121
     22
    2223function mrelocator_init() {
    2324    wp_enqueue_script('jquery');
     
    3738function mrelocator_plugin_menu()
    3839{
    39     /*  設定画面の追加  */
    40     add_submenu_page('upload.php', 'Media File Manager', 'Media File Manager', 'manage_options', 'mrelocator-submenu-handle', 'mrelocator_magic_function');
     40    $current_user = wp_get_current_user();
     41    if ( !($current_user instanceof WP_User) ) return;
     42    $roles = $current_user->roles;
     43    $accepted_roles = get_option("mediafilemanager_accepted_roles", "administrator");
     44    $accepted = explode(",", $accepted_roles);
     45
     46    for ($i=0; $i<count($accepted); $i++) {
     47        for ($j=0; $j<count($roles); $j++) {
     48            if ($accepted[$i] == $roles[$j]) {
     49                /*  設定画面の追加  */
     50                add_submenu_page('upload.php', 'Media File Manager', 'Media File Manager', $roles[$j], 'mrelocator-submenu-handle', 'mrelocator_magic_function');
     51                return;
     52            }
     53        }
     54    }
    4155}
    4256
     
    88102        </div>
    89103<div id="debug">.<br></div>
    90 <div id="mrl_test" style="display:none;">test<br></div>
     104<div id="mrl_test" style="display:nonee;">test<br></div>
    91105
    92106    </div>
     
    569583}
    570584
     585
     586
     587
     588// Add a link to the config page on the setting menu of wordpress
     589add_action('admin_menu', 'mrelocator_admin_plugin_menu');
     590function mrelocator_admin_plugin_menu()
     591{
     592    /*  Add a setting page  */
     593    add_submenu_page('options-general.php',
     594        'Media File Manager plugin Configuration',
     595        'Media File Manager',
     596        'manage_options',
     597        'mrelocator_submenu-handle',
     598        'mrelocator_admin_magic_function'
     599    );
     600}
     601
     602function mrelocator_get_roles(&$ret)
     603{
     604    global $wp_roles;
     605    $i=0;
     606    foreach($wp_roles->roles as $key=> $value1) {
     607        $ret[$i++] = $key;
     608    }
     609}
     610
     611/*  Display config page  */
     612function mrelocator_admin_magic_function()
     613{
     614    $roles = Array();
     615    mrelocator_get_roles(&$roles);
     616
     617    /*  Store setting information which POST has when this func is called by pressing [Save Change] btn  */
     618    if ( isset($_POST['update_mrelocator_setting'] ) ) {
     619        echo '<div id="message" class="updated fade"><p><strong>Options saved.</strong></p></div>';
     620        //update_option('th_linklist_vnum', $_POST['th_linklist_vnum']);
     621        $roles_val = "";
     622        for ($i=0; $i<count($roles); $i++) {
     623            if (!empty($_POST['roles_'.$roles[$i]])) {
     624                if ($roles_val != "") $roles_val .= ",";
     625                $roles_val .= $roles[$i];
     626            }
     627        }
     628        update_option('mediafilemanager_accepted_roles', $roles_val);
     629    }
     630
     631    ?>
     632    <div class="wrap">
     633        <h2>Media File Manager plugin configurations</h2>
     634
     635        <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
     636        <?php
     637        wp_nonce_field('update-options');
     638        $accepted_roles = get_option("mediafilemanager_accepted_roles", "administrator");
     639        ?>
     640        <table class="form-table">
     641        <tr>
     642        <th>This plugin can be used by </th>
     643        <td style="text-align: left;">
     644<?php
     645    $accepted = explode(",", $accepted_roles);
     646    for($i=0; $i<count($roles); $i++) {
     647        $key = $roles[$i];
     648
     649        $ck = "";
     650        for ($j=0; $j<count($accepted); $j++) {
     651            if ($key == $accepted[$j]) {
     652                $ck = "checked";
     653                break;
     654            }
     655        }
     656
     657        echo '<input type="checkbox" name="roles_'.$key.'" id="roles_'.$key.'" '.$ck.'>'.$key.'</input><br>';
     658    }
     659?>
     660
     661        </td>
     662        </tr>
     663
     664        </table>
     665        <input type="hidden" name="action" value="update" />
     666        <p class="submit">
     667            <input type="submit" name="update_mrelocator_setting" class="button-primary" value="<?php _e('Save  Changes')?>" onclick="" />
     668        </p>
     669        </form>
     670
     671
     672    </div>
     673    <?php
     674    if ( isset($_POST['update_th_linklist_Setting'] ) ) {
     675        //echo '<script type="text/javascript">alert("Options Saved.");</script>';
     676    }
     677}
     678
     679
     680
     681
     682
     683
     684
    571685function mrelocator_test()
    572686{
    573687    global $wpdb;
     688global $wp_roles;
     689global $current_user;
     690//print_r($wp_roles);
     691//print_r($current_user);
     692
     693
     694$current_user = wp_get_current_user();
     695if ( !($current_user instanceof WP_User) )
     696   return;
     697$roles = $current_user->roles;
     698print_r($roles);
     699
     700return;
    574701
    575702    $res = wp_get_attachment_metadata( 4272);
    576703    print_r($res);
    577 return;
    578704
    579705    //print_r(wp_get_attachment_metadata( 2916));
  • media-file-manager/trunk/readme.txt

    r477347 r487342  
    44Tags: media,file,manager,explorer,relocate,folder,folders,files,rename,make directory,directories,organize,organizer,select,selector,database
    55Requires at least: 3.2.0
    6 Tested up to: 3.3
    7 Stable tag: 1.0.2
     6Tested up to: 3.3.1
     7Stable tag: 1.1.0
    88
    99You can make sub-directories in the upload directory, and move files into them.
     
    5656== Changelog ==
    5757
     58= 1.1.0 =
     59* Added user access control by role.
     60
    5861= 1.0.2 =
    5962* Solve the problem that file manager shows root directory of your server when the upload directory is not writeable by the server.
Note: See TracChangeset for help on using the changeset viewer.