Exemple #1
0
    /**
     * LazyestAdmin::editorbox()
     * Box with Author and ditor information
     * @todo add editor functionality
     * @since 1.1.0
     * @return void
     */
    function editorbox()
    {
        if (!(current_user_can('manage_lazyest_files') || current_user_can('manage_options'))) {
            return;
        }
        global $wp_roles;
        $blogusers = lg_get_users_of_blog();
        $mcnt = $acnt = $ecnt = $vcnt = 0;
        $admins = $authors = $editors = $viewers = array();
        $option = '<option value="%s">%s</option>';
        foreach ($blogusers as $user) {
            $user_nicename = esc_attr($user->user_nicename);
            $optionval = sprintf($option, $user->ID, $user_nicename);
            if ($user->has_cap('manage_lazyest_files')) {
                // user has admin capabilities
                if (6 > $mcnt) {
                    $admins[] = $user_nicename;
                }
                if (6 == $mcnt) {
                    $admins[] = '&hellip;';
                }
            } else {
                if ($user->has_cap('create_lazyest_folder')) {
                    // user has editor capabilities
                    $eoptions['has'][] = $optionval;
                    if (6 > $ecnt) {
                        $editors[] = $user_nicename;
                    }
                    if (6 == $ecnt) {
                        $editors[] = '&hellip;';
                    }
                    $acnt++;
                } else {
                    $eoptions['not'][] = $optionval;
                    if ($user->has_cap('edit_lazyest_fields')) {
                        // user has author capabilities
                        $aoptions['has'][] = $optionval;
                        if (6 > $acnt) {
                            $authors[] = $user_nicename;
                        }
                        if (6 == $acnt) {
                            $authors[] .= '&hellip;';
                        }
                    } else {
                        $aoptions['not'][] = $optionval;
                    }
                }
            }
        }
        $addremove = __('Add / Remove', 'lazyest-gallery');
        $add = __('Add &raquo;', 'lazyest-gallery');
        $remove = __('&laquo; Remove', 'lazyest-gallery');
        $users = __('Users', 'lazyest-gallery');
        $authorstyle = isset($_REQUEST['edit']) && $_REQUEST['edit'] == 'authors' ? 'display:block;' : 'display:none;';
        $editorstyle = isset($_REQUEST['edit']) && $_REQUEST['edit'] == 'editors' ? 'display:block;' : 'display:none;';
        ?>

    <div class="postbox" id="editordiv">
      <h3 class="hndle"><span><?php 
        echo $users;
        ?>
</span></h3>
      <div class="inside"> 
        <div id="lazyest-admins" class="misc-pub-section">
          <p><?php 
        esc_html_e('Administrators');
        ?>
: <strong><?php 
        echo implode(', ', $admins);
        ?>
</strong></p>
        </div>
        <div id="lazyest-editors" class="misc-pub-section misc-pub-section-last">
          <p><?php 
        esc_html_e('Editors', 'lazyest-gallery');
        ?>
: <span id="list-editors" class="users-list"><?php 
        echo implode(', ', $editors);
        ?>
</span></p><p><a id="add-remove-editor" class="button-secondary" href="<?php 
        echo add_query_arg('edit', 'editors');
        ?>
"><?php 
        echo $addremove;
        ?>
</a></p>           
          <div id="edit_editors" style="<?php 
        echo $editorstyle;
        ?>
">
            <div id="not-editor" class="has_role">
              <p><strong><?php 
        echo $users;
        ?>
</strong></p>
              <select class="multiple" id="not-editors" name="not-editors[]" multiple="multiple" size="5">
                <?php 
        if (isset($eoptions['not'])) {
            echo implode($eoptions['not']);
        }
        ?>
                             
              </select>
              <p class="authorbutton"><input class="button-secondary" id="add-editor" name="add-editor" type="submit" value="<?php 
        echo $add;
        ?>
" /> <img alt="" id="editor-ajax-loading" src="<?php 
        echo admin_url('images/wpspin_light.gif');
        ?>
" class="ajax-loading" /></p>      
            </div>
            <div id="is-editor" class="has_role">
              <p><strong><?php 
        esc_html_e('Editors', 'lazyest-gallery');
        ?>
</strong></p>
              <select class="multiple" id="is-editors" name="is-editors[]" multiple="multiple" size="5">
                <?php 
        if (isset($eoptions['has'])) {
            echo implode($eoptions['has']);
        }
        ?>
                             
              </select>      
              <p class="authorbutton"><input class="button-secondary" id="remove-editor" name="remove-editor" type="submit" value="<?php 
        echo $remove;
        ?>
" /></p>
            </div>
          <div class="clear"></div> 
          </div>
        </div>
        <div id="lazyest-authors" class="misc-pub-section misc-pub-section-last">
          <p><?php 
        esc_html_e('Authors', 'lazyest-gallery');
        ?>
: <span id="list-authors" class="users-list"><?php 
        echo implode(', ', $authors);
        ?>
</span></p>
          <p><a id="add-remove-author" class="button-secondary" href="<?php 
        echo add_query_arg('edit', 'authors');
        ?>
"><?php 
        esc_html_e($addremove);
        ?>
</a></p>           
          <div id="edit_authors" style="<?php 
        echo $authorstyle;
        ?>
">
            <div id="not-author" class="has_role">
              <p><strong><?php 
        echo $users;
        ?>
</strong></p>
              <select class="multiple" id="not-authors" name="not-authors[]" multiple="multiple" size="5">
                <?php 
        if (isset($aoptions['not'])) {
            echo implode($aoptions['not']);
        }
        ?>
                             
              </select>
              <p class="authorbutton"><input class="button-secondary" id="add-author" name="add-author" type="submit" value="<?php 
        esc_html_e($add);
        ?>
" /> <img alt="" id="author-ajax-loading" src="<?php 
        echo admin_url('images/wpspin_light.gif');
        ?>
" class="ajax-loading" /></p>      
            </div>
            <div id="is-author" class="has_role">
              <p><strong><?php 
        esc_html_e('Authors', 'lazyest-gallery');
        ?>
</strong></p>
              <select class="multiple" id="is-authors" name="is-authors[]" multiple="multiple" size="5">
                <?php 
        if (isset($aoptions['has'])) {
            echo implode($aoptions['has']);
        }
        ?>
                             
              </select>      
              <p class="authorbutton"><input class="button-secondary" id="remove-author" name="remove-author" type="submit" value="<?php 
        esc_html_e($remove);
        ?>
" /></p>
            </div>
            <div class="clear"></div>   
          </div>                     
        </div>  
      </div>
    </div>
    <?php 
    }
 /**
  * LazyestGallery::_update_roles()
  * Applies new Lazyest Gallery roles according to pre 1.1 roles
  * 
  * @since 1.1
  * @return void
  */
 function _update_roles()
 {
     global $wp_roles;
     // at the time we do the update, pluggable has not been loaded yet
     require_once ABSPATH . 'wp-includes/pluggable.php';
     $gallery_secure = $this->get_option('gallery_secure');
     if (version_compare($gallery_secure, '1.1', '<')) {
         foreach ($wp_roles->role_names as $role => $name) {
             // clean up capabilities from wordpress roles
             $arole = $wp_roles->get_role($role);
             if ($arole->has_cap('manage_lazyest_files')) {
                 $arole->remove_cap('manage_lazyest_files');
             }
         }
         // move roles to user capabilities, old managers will become editors, wp admins will become new managers
         $roles = $this->get_option('manager_roles');
         if ($roles) {
             // roles have been read
             $blogusers = lg_get_users_of_blog();
             foreach ($blogusers as $user) {
                 // check if users have one or more roles and add role lazyest_editor
                 if (!$user->has_cap('lazyest_manager') && !$user->has_cap('lazyest_editor')) {
                     if ($user->has_cap('administrator')) {
                         $user->add_role('lazyest_manager');
                     } else {
                         foreach ($roles as $role) {
                             if ($user->has_cap($role)) {
                                 $user->add_role('lazyest_editor');
                                 break 1;
                             }
                         }
                     }
                 }
             }
         }
         $this->update_option('gallery_secure', LG_SECURE_VERSION);
     }
 }
Exemple #3
0
    /**
     * LazyestAdminFolder::editorbox()
     * Box with Author and ditor information
     * 
     * @since 1.1.0
     * @return void
     */
    function editorbox()
    {
        global $wp_roles;
        $blogusers = lg_get_users_of_blog();
        $aoptions = $foptions = $authors = array();
        $editor = $this->editor == 0 ? $current_user->ID : $this->editor;
        $acnt = 0;
        $selected = -1 == $this->editor ? 'selected="selected"' : '';
        $editor = esc_html__('Not selected', 'lazyest-gallery');
        $foptions[] = sprintf('<option value="-1" %s>%s </option>', $selected, $editor);
        foreach ($blogusers as $user) {
            $selected = '';
            if ($user->ID == $this->editor) {
                $selected = 'selected="selected"';
                $editor = $user->user_nicename;
            }
            $optionval = sprintf('<option value="%s" %s>%s </option>', $user->ID, $selected, $user->user_nicename);
            if (!$user->has_cap('manage_lazyest_files')) {
                $foptions[] = $optionval;
                if (in_array($user->ID, $this->authors) && $user->ID != $this->editor) {
                    // user has folder author capabilities
                    $aoptions['has'][] = $optionval;
                    if (6 > $acnt) {
                        $authors[] = $user->user_nicename;
                    }
                    if (6 == $acnt) {
                        $authors[] .= '&hellip;';
                    }
                } else {
                    if ($user->ID != $this->editor) {
                        $aoptions['not'][] = $optionval;
                    }
                }
            }
        }
        $addremove = esc_html__('Add / Remove', 'lazyest-gallery');
        $add = esc_html__('Add', 'lazyest-gallery') . ' &raquo;';
        $remove = '&laquo; ' . esc_html__('Remove', 'lazyest-gallery');
        $users = esc_html__('Users', 'lazyest-gallery');
        $authorstyle = isset($_REQUEST['edit']) && $_REQUEST['edit'] == 'authors' ? 'display:block;' : 'display:none;';
        $authorclass = isset($_REQUEST['edit']) && $_REQUEST['edit'] == 'authors' ? 'lazyest' : 'hide-if-ajax';
        ?>
    <div class="postbox" id="editordiv">
      <h3 class="hndle"><span><?php 
        esc_html_e('Users', 'lazyest-gallery');
        ?>
</span></h3>
      <div class="inside">
        <div id="lazyest-editor" class="misc-pub-section">
          <label for="editor"><?php 
        esc_html_e('Editor', 'lazyest-gallery');
        ?>
          <?php 
        if (current_user_can('manage_lazyest_files') || current_user_can('manage_options')) {
            ?>
        
          <select id="editor" name="folder_editor">
            <?php 
            echo implode($foptions);
            ?>
          </select></label>
          <?php 
        } else {
            ?>
          <p><?php 
            echo $editor;
            ?>
</p></label>
          <input type="hidden" name="folder_editor" value="<?php 
            echo $this->editor;
            ?>
" />
          <?php 
        }
        ?>
        </div>
        <div id="lazyest-authors" class="misc-pub-section misc-pub-section-last">
          <p><?php 
        esc_html_e('Authors', 'lazyest-gallery');
        ?>
: <span id="list-authors" class="users-list"><?php 
        echo implode(', ', $authors);
        ?>
</span></p>
          <?php 
        if ($this->user_can('editor')) {
            ?>
          <p class="hide-if-no-ajax"><a id="add-remove-author" class="button-secondary" href="<?php 
            echo add_query_arg('edit', 'authors');
            ?>
"><?php 
            echo $addremove;
            ?>
</a></p>           
          <div id="edit_authors" class="<?php 
            echo $authorclass;
            ?>
" style="<?php 
            echo $authorstyle;
            ?>
">
            <div id="not-author" class="has_role">
              <p><strong><?php 
            echo $users;
            ?>
</strong></p>
              <select class="multiple" id="not-authors" name="not-authors[]" multiple="multiple" size="5">
                <?php 
            if (isset($aoptions['not'])) {
                echo implode($aoptions['not']);
            }
            ?>
                             
              </select>
              <p class="authorbutton"><input class="button-secondary" id="add-fauthor" name="add-author" type="submit" value="<?php 
            echo $add;
            ?>
" /> <img alt="" id="author-ajax-loading" src="images/wpspin_light.gif" class="ajax-loading" /></p>      
            </div>
            <div id="is-author" class="has_role">
              <p><strong><?php 
            esc_html_e('Authors', 'lazyest-gallery');
            ?>
</strong></p>
              <select class="multiple" id="is-authors" name="is-authors[]" multiple="multiple" size="5">
                <?php 
            if (isset($aoptions['has'])) {
                echo implode($aoptions['has']);
            }
            ?>
                             
              </select>      
              <p class="authorbutton"><input class="button-secondary" id="remove-fauthor" name="remove-author" type="submit" value="<?php 
            echo $remove;
            ?>
" /></p>
            </div>
            <div class="clear"></div>   
          </div>
          <?php 
        }
        ?>
                     
        </div>
      </div>
    </div>
    <?php 
    }
Exemple #4
0
 function uninstall_roles()
 {
     require_once ABSPATH . 'wp-includes/pluggable.php';
     $blogusers = lg_get_users_of_blog();
     foreach ($blogusers as $user) {
         // check if users have one or more roles and add role lazyest_editor
         if ($user->has_cap('lazyest_manager')) {
             $user->remove_role('lazyest_manager');
         }
         if ($user->has_cap('lazyest_editor')) {
             $user->remove_role('lazyest_editor');
         }
         if ($user->has_cap('lazyest_author')) {
             $user->remove_role('lazyest_author');
         }
     }
     remove_role('lazyest_manager');
     remove_role('lazyest_editor');
     remove_role('lazyest_author');
 }
Exemple #5
0
    /**
     * LazyestSettings::advanced_options()
     * 
     * @return void
     */
    function advanced_options()
    {
        global $lg_gallery;
        $add = esc_html__('Add', 'lazyest-gallery') . ' &raquo;';
        $remove = '&laquo; ' . esc_html__('Remove', 'lazyest-gallery');
        $users = esc_html__('Users', 'lazyest-gallery');
        $option = '<option value="%1s">%2s</option>';
        $blogusers = lg_get_users_of_blog();
        foreach ($blogusers as $user) {
            $user->get_role_caps();
            if (!$user->has_cap('manage_options')) {
                // Administrators are gallery administators by default. They cannot be removed from this role
                $optionval = sprintf($option, $user->ID, esc_attr($user->user_nicename));
                if ($user->has_cap('lazyest_manager')) {
                    // user has manager capabilities
                    $moptions['has'][] = $optionval;
                } else {
                    $moptions['not'][] = $optionval;
                }
            }
        }
        ?>
    <div id="lg_advanced_options" class="<?php 
        echo $this->installstyle;
        ?>
">
      <h3><?php 
        esc_html_e('Advanced Options', 'lazyest-gallery');
        ?>
</h3>
      <table id="lg_advanced_options_table" class="form-table">
        <tbody>
        <tr>
          <th scope="col"><?php 
        esc_html_e('Lazyest Gallery Administrators', 'lazyest-gallery');
        ?>
</th>
          <td>
          	<div id="lazyest-managers"> 
                <div id="not-manager" class="has_role">
                  <p><strong><?php 
        echo $users;
        ?>
</strong></p>
                  <select class="multiple" id="not-managers" name="lazyest-gallery[not-managers][]" multiple="multiple" size="10">
                    <?php 
        if (isset($moptions['not'])) {
            foreach ($moptions['not'] as $eoption) {
                echo $eoption;
            }
        }
        ?>
                             
                  </select>
                  <p class="authorbutton"><input class="button-secondary" id="add-manager" name="lazyest-gallery[add-manager]" type="submit" value="<?php 
        echo $add;
        ?>
" /> <img alt="" id="manager-ajax-loading" src="images/wpspin_light.gif" class="ajax-loading" /></p>      
                </div>
                <div id="is-manager" class="has_role">
                  <p><strong><?php 
        esc_html_e('Administrators', 'lazyest-gallery');
        ?>
</strong></p>
                  <select class="multiple" id="is-managers" name="lazyest-gallery[is-managers][]" multiple="multiple" size="10">
                    <?php 
        if (isset($moptions['has'])) {
            foreach ($moptions['has'] as $eoption) {
                echo $eoption;
            }
        }
        ?>
                             
                  </select>      
                  <p class="authorbutton"><input class="button-secondary" id="remove-manager" name="lazyest-gallery[remove-manager]" type="submit" value="<?php 
        echo $remove;
        ?>
" /></p>
                </div>
              <div class="clear"></div> 
            </div>
            <p class="description"><?php 
        esc_html_e('Blog Administrators are Lazyest Gallery Administrators by default', 'lazyest-gallery');
        ?>
</p>
          </td>
        </tr>      
        <tr>
          <th scope="col"><label for="use_permalinks"><?php 
        esc_html_e('Use Permalinks for the Gallery', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input type="checkbox" id="use_permalinks" name="lazyest-gallery[use_permalinks]" value="TRUE" <?php 
        checked('TRUE', $lg_gallery->get_option('use_permalinks'));
        ?>
 /><br />
            <p class="description"><?php 
        esc_html_e('Enable this to show Gallery Folders as subpages of your Gallery Page.', 'lazyest-gallery');
        ?>
</p>
          </td>
        </tr>
        <tr>
          <th scope="col"><label for="rel_canonical"><?php 
        esc_html_e('Use Canonical links', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input type="checkbox" id="rel_canonical" name="lazyest-gallery[rel_canonical]" value="TRUE" <?php 
        checked('TRUE', $lg_gallery->get_option('rel_canonical'));
        ?>
 /><br />
            <p class="description"><?php 
        esc_html_e('Enable this to add a canonical link for the gallery in your page header.', 'lazyest-gallery');
        ?>
</p>
            <p class="description"><?php 
        printf(esc_html__('This could interfere with SEO plugins. Please read %smore about canonical links%s', 'lazyest-gallery'), '<a href="http://brimosoft.nl/2011/09/05/canonical-urls-revisited/">', '</a>');
        ?>
</p> 
          </td>
        </tr>
        <tr>
          <th scope="col"><label for="append_search"><?php 
        esc_html_e('Append Gallery to Wordpress search results', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input type="checkbox" id="append_search" name="lazyest-gallery[append_search]" value="TRUE" <?php 
        checked('TRUE', $lg_gallery->get_option('append_search'));
        ?>
 /><br />
            <p class="description"><?php 
        esc_html_e('Enable this to show Gallery Folders and Images in the Wordpress search results.', 'lazyest-gallery');
        ?>
</p>
          </td>
        </tr>
        <tr>
          <th scope="col"><label for="excluded_folders_string"><?php 
        esc_html_e('Excluded Folders', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input name="lazyest-gallery[excluded_folders_string]" id="excluded_folders_string" value="<?php 
        echo implode(',', $lg_gallery->get_option('excluded_folders'));
        ?>
" size="60" class="code" type="text" /> <br />
            <p class="description"><?php 
        esc_html_e('List folders to exclude from the gallery.  Separate folders with commas (",") while omitting spaces.', 'lazyest-gallery');
        ?>
</p>
          </td>
        </tr>
        <tr>
          <th scope="col"><label for="resample_quality"><?php 
        esc_html_e('Image Resampling Quality', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input name="lazyest-gallery[resample_quality]" id="resample_quality" value="<?php 
        echo $lg_gallery->get_option('resample_quality');
        ?>
" size="10" class="code" type="text" /><br />
            <p class="description"><?php 
        esc_html_e('Valid settings range from 0 (low quality) to 100 (best quality).  This setting only applies to JPEG files.', 'lazyest-gallery');
        ?>
</p>
          </td>
        </tr>
        <tr>
          <th scope="col"><label for="link_to_gallery"><?php 
        esc_html_e('Shortcode links to Gallery', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input type="checkbox" id="link_to_gallery" name="lazyest-gallery[link_to_gallery]" value="TRUE" <?php 
        checked('TRUE', $lg_gallery->get_option('link_to_gallery'));
        ?>
 /><br />
            <p class="description"><?php 
        esc_html_e('Enable this to jump to the Gallery after a user clicks on an folder shortcode in a post.', 'lazyest-gallery');
        ?>
</p>
          </td>
        </tr>
        <tr>
          <th scope="col"><label for="listed_as"><?php 
        esc_html_e('The images in the Gallery should be listed as', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input name="lazyest-gallery[listed_as]" id="listed_as" value="<?php 
        echo $lg_gallery->get_option('listed_as');
        ?>
" size="12" type="text" />
          </td>
        </tr>
        <tr>
          <th scope="col"><label for="show_credits"><?php 
        esc_html_e('Credits', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input type="checkbox" name="lazyest-gallery[show_credits]" id="show_credits" value="TRUE" <?php 
        checked('TRUE', $lg_gallery->get_option('show_credits'));
        ?>
 /><br />
            <p class="description"><?php 
        esc_html_e('Enable this to support Lazyest Gallery by showing the "Powered by Lazyest Gallery" banner below your gallery', 'lazyest-gallery');
        ?>
</p>
          </td>
        </tr>
        <tr>
          <th><label for="memory_ok"><?php 
        esc_html_e('Do not check Memory before creating images', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input type="checkbox" id="memory_ok" name="lazyest-gallery[memory_ok]" value="TRUE" <?php 
        checked('TRUE', $lg_gallery->get_option('memory_ok'));
        ?>
 /><br />
            <p class="description"><?php 
        esc_html_e('Enable this to skip the memory check. Warning, this could crash your gallery.', 'lazyest-gallery');
        ?>
</p>
          </td>
        </tr>
        <tr>
          <th><label for="table_layout"><?php 
        esc_html_e('Use <table> element for gallery layout', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input type="checkbox" id="table_layout" name="lazyest-gallery[table_layout]" value="TRUE" <?php 
        checked('TRUE', $lg_gallery->get_option('table_layout'));
        ?>
 /><br />
            <p class="description"><?php 
        esc_html_e('Enable this to use a <table> element to display the gallery as in previous Lazyest Gallery versions.', 'lazyest-gallery');
        ?>
</p>
          </td>
        </tr>
        <tr>
          <th><label for="ajax_pagination"><?php 
        esc_html_e('Use AJAX to refresh thumbnail pages', 'lazyest-gallery');
        ?>
</label></th>
          <td>
            <input type="checkbox" id="ajax_pagination" name="lazyest-gallery[ajax_pagination]" value="TRUE" <?php 
        checked('TRUE', $lg_gallery->get_option('ajax_pagination'));
        ?>
 /><br />
            <p class="description"><?php 
        esc_html_e('Enable this to refresh the gallery without refreshing the whole page', 'lazyest-gallery');
        ?>
<br />
							 <?php 
        esc_html_e('Warning: This will stop lightbox or thickbox on secondary pages', 'lazyest-gallery');
        ?>
</p>
          </td>
        </tr>        
      	<?php 
        do_action('lazyest-gallery-settings_advanced');
        ?>
        </tbody>
      </table>
    </div>
    <?php 
    }