admin.php
7 years ago
backup-handler.php
7 years ago
backup.php
7 years ago
cap-helper.php
7 years ago
filters-woocommerce.php
7 years ago
filters.php
7 years ago
handler.php
7 years ago
inflect-cme.php
7 years ago
manager.php
7 years ago
network.php
7 years ago
pp-handler.php
7 years ago
pp-ui.php
7 years ago
backup.php
155 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Capability Manager Backup Tool. |
| 4 | * Provides backup and restore functionality to Capability Manager. |
| 5 | * |
| 6 | * @version $Rev: 198515 $ |
| 7 | * @author Jordi Canals |
| 8 | * @copyright Copyright (C) 2009, 2010 Jordi Canals |
| 9 | * @license GNU General Public License version 2 |
| 10 | * @link http://alkivia.org |
| 11 | * @package Alkivia |
| 12 | * @subpackage CapsMan |
| 13 | * |
| 14 | |
| 15 | Copyright 2009, 2010 Jordi Canals <devel@jcanals.cat> |
| 16 | |
| 17 | This program is free software; you can redistribute it and/or |
| 18 | modify it under the terms of the GNU General Public License |
| 19 | version 2 as published by the Free Software Foundation. |
| 20 | |
| 21 | This program is distributed in the hope that it will be useful, |
| 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | GNU General Public License for more details. |
| 25 | |
| 26 | You should have received a copy of the GNU General Public License |
| 27 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 28 | */ |
| 29 | |
| 30 | ?> |
| 31 | <div class="wrap"> |
| 32 | <div id="icon-capsman-admin" class="icon32"></div> |
| 33 | <h2><?php printf( __('Backup Tool for %1$sCapability Manager%2$s', 'capsman-enhanced'), '<a href="admin.php?page=capsman">', '</a>' );?></h2> |
| 34 | |
| 35 | <form method="post" action="tools.php?page=<?php echo $this->ID ?>-tool"> |
| 36 | <?php wp_nonce_field('capsman-backup-tool'); ?> |
| 37 | <fieldset> |
| 38 | <table id="akmin"> |
| 39 | <tr> |
| 40 | <td class="content"> |
| 41 | <dl> |
| 42 | <dt><?php _e('Backup and Restore', 'capsman-enhanced'); ?></dt> |
| 43 | <dd> |
| 44 | <table width='100%' class="form-table"> |
| 45 | <tr> |
| 46 | <th scope="row"><?php _e('Select action:', 'capsman-enhanced'); ?></th> |
| 47 | <td> |
| 48 | <select name="action"> |
| 49 | <option value="backup"> <?php _e('Backup roles and capabilities', 'capsman-enhanced'); ?> </option> |
| 50 | |
| 51 | <?php |
| 52 | if ( $initial = get_option( 'capsman_backup_initial' ) ):?> |
| 53 | <option value="restore_initial"> <?php _e('Restore initial backup', 'capsman-enhanced'); ?> </option> |
| 54 | <?php endif;?> |
| 55 | |
| 56 | <option value="restore"> <?php _e('Restore last saved backup', 'capsman-enhanced'); ?> </option> |
| 57 | </select> |
| 58 | <input type="submit" name="Perform" value="<?php _e('Do Action', 'capsman-enhanced') ?>" class="button-primary" /> |
| 59 | </td> |
| 60 | </tr> |
| 61 | </table> |
| 62 | </dd> |
| 63 | |
| 64 | <p> |
| 65 | <?php if( ! empty( $initial ) ):?> |
| 66 | <a id="cme_show_initial" href="javascript:void(0)"><?php _e('Show initial backup', 'capsman-enhanced');?></a> • |
| 67 | <?php endif;?> |
| 68 | <a id="cme_show_last" href="javascript:void(0)"><?php _e('Show last backup', 'capsman-enhanced');?></a> |
| 69 | </p> |
| 70 | |
| 71 | <script type="text/javascript"> |
| 72 | /* <![CDATA[ */ |
| 73 | jQuery(document).ready( function($) { |
| 74 | $( '#cme_show_initial').click( function() { |
| 75 | $('#cme_display_capsman_backup_initial').show(); |
| 76 | $('#cme_display_capsman_backup').hide(); |
| 77 | }); |
| 78 | $( '#cme_show_last').click( function() { |
| 79 | $('#cme_display_capsman_backup_initial').hide(); |
| 80 | $('#cme_display_capsman_backup').show(); |
| 81 | }); |
| 82 | }); |
| 83 | /* ]]> */ |
| 84 | </script> |
| 85 | |
| 86 | <?php |
| 87 | global $wp_roles; |
| 88 | |
| 89 | $initial_caption = ( $backup_datestamp = get_option( 'capsman_backup_initial_datestamp' ) ) ? sprintf( __('Initial Backup - %s', 'capsman-enhanced'), date( 'j M Y, g:i a', $backup_datestamp ) ) : __('Initial Backup', 'capsman-enhanced'); |
| 90 | $last_caption = ( $backup_datestamp = get_option( 'capsman_backup_datestamp' ) ) ? sprintf( __('Last Backup - %s', 'capsman-enhanced'), date( 'j M Y, g:i a', $backup_datestamp ) ) : __('Last Backup', 'capsman-enhanced'); |
| 91 | |
| 92 | $backups = array( |
| 93 | 'capsman_backup_initial' => $initial_caption, |
| 94 | 'capsman_backup' => $last_caption, |
| 95 | ); |
| 96 | |
| 97 | foreach( $backups as $name => $caption ) { |
| 98 | if ( $backup_data = get_option( $name ) ) :?> |
| 99 | <div id="cme_display_<?php echo $name;?>" style="display:none;padding-left:20px;"> |
| 100 | <h3><?php printf( __( "%s (%s roles)", 'capsman-enhanded' ), $caption, count($backup_data) ); ?></h3> |
| 101 | |
| 102 | <?php foreach( $backup_data as $role => $props ) :?> |
| 103 | <?php if ( ! isset( $props['name'] ) ) continue;?> |
| 104 | <?php |
| 105 | $level = 0; |
| 106 | for( $i=10; $i>=0; $i--) { |
| 107 | if ( ! empty( $props['capabilities']["level_{$i}"] ) ) { |
| 108 | $level = $i; |
| 109 | break; |
| 110 | } |
| 111 | } |
| 112 | ?> |
| 113 | <?php |
| 114 | $role_caption = $props['name']; |
| 115 | if ( empty( $wp_roles->role_objects[$role] ) ) $role_caption = "<span class='cme-plus' style='color:green;font-weight:800'>$role_caption</span>";?> |
| 116 | <h4><?php printf( __( '%s (level %s)', 'capsman-enhanced' ), $role_caption, $level );?></h4> |
| 117 | <ul style="list-style:disc;padding-left:30px"> |
| 118 | |
| 119 | <?php |
| 120 | ksort( $props['capabilities'] ); |
| 121 | foreach( $props['capabilities'] as $cap_name => $val ) : |
| 122 | if ( 0 === strpos( $cap_name, 'level_' ) ) continue; |
| 123 | ?> |
| 124 | <?php if ( $val && ( empty( $wp_roles->role_objects[$role] ) || empty( $wp_roles->role_objects[$role]->capabilities[$cap_name] ) ) ) $cap_name = "<span class='cme-plus' style='color:green;font-weight:800'>$cap_name</span>";?> |
| 125 | <li><?php echo ( $val ) ? $cap_name : "<strike>$cap_name</strike>";?></li> |
| 126 | <?php endforeach;?> |
| 127 | |
| 128 | </ul> |
| 129 | <?php endforeach;?> |
| 130 | </div> |
| 131 | <?php endif; |
| 132 | } |
| 133 | ?> |
| 134 | </dl> |
| 135 | |
| 136 | <dl> |
| 137 | <dt><?php if ( defined('WPLANG') && WPLANG && ( 'en_EN' != WPLANG ) ) _e('Reset WordPress Defaults', 'capsman-enhanced'); else echo 'Reset Roles to WordPress Defaults';?></dt> |
| 138 | <dd> |
| 139 | <p style="text-align:center;"><strong><span style="color:red;"><?php _e('WARNING:', 'capsman-enhanced'); ?></span> <?php if ( defined('WPLANG') && WPLANG && ( 'en_EN' != WPLANG ) ) _e('Reseting default Roles and Capabilities will set them to the WordPress install defaults.', 'capsman-enhanced'); else echo 'This will delete and/or modify stored role definitions.'; ?></strong><br /> |
| 140 | <br /> |
| 141 | <?php |
| 142 | _e('If you have installed any plugin that adds new roles or capabilities, these will be lost.', 'capsman-enhanced')?><br /> |
| 143 | <strong><?php if ( defined('WPLANG') && WPLANG && ( 'en_EN' != WPLANG ) ) _e('It is recommended to use this only as a last resource!'); else echo('It is recommended to use this only as a last resort!');?></strong></p> |
| 144 | <p style="text-align:center;"><a class="ak-delete" title="<?php echo esc_attr(__('Reset Roles and Capabilities to WordPress defaults', 'capsman-enhanced')) ?>" href="<?php echo wp_nonce_url("tools.php?page={$this->ID}-tool&action=reset-defaults", 'capsman-reset-defaults'); ?>" onclick="if ( confirm('<?php echo esc_js(__("You are about to reset Roles and Capabilities to WordPress defaults.\n 'Cancel' to stop, 'OK' to reset.", 'capsman-enhanced')); ?>') ) { return true;}return false;"><?php _e('Reset to WordPress defaults', 'capsman-enhanced')?></a> |
| 145 | |
| 146 | </dd> |
| 147 | </dl> |
| 148 | |
| 149 | </td> |
| 150 | </tr> |
| 151 | </table> |
| 152 | </fieldset> |
| 153 | </form> |
| 154 | </div> |
| 155 |