/**
     * Displays/updates the "DB Tracking" settings field.
     * @access public
     */
    public function tracked_tables_callback()
    {
        if ($this->is_updated('db_tracking')) {
            revisr()->git->set_config('revisr', 'db-tracking', revisr()->options['db_tracking']);
        }
        if ($db_tracking = revisr()->git->get_config('revisr', 'db-tracking')) {
            if ($db_tracking == 'custom' && $this->is_updated('tracked_tables')) {
                revisr()->git->run('config', array('--unset-all', 'revisr.tracked-tables'));
                $tables = revisr()->options['tracked_tables'];
                foreach ($tables as $table) {
                    revisr()->git->run('config', array('--add', 'revisr.tracked-tables', $table));
                }
            } elseif ($db_tracking != 'custom') {
                revisr()->git->run('config', array('--unset-all', 'revisr.tracked-tables'));
            }
        } else {
            $db_tracking = '';
        }
        ?>
		<select id="db-tracking-select" name="revisr_database_settings[db_tracking]">
			<option value="all_tables" <?php 
        selected($db_tracking, 'all_tables');
        ?>
><?php 
        _e('All Tables', 'revisr');
        ?>
</option>
			<option value="custom" <?php 
        selected($db_tracking, 'custom');
        ?>
><?php 
        _e('Let me decide...', 'revisr');
        ?>
</option>
			<option value="none" <?php 
        selected($db_tracking, 'none');
        ?>
><?php 
        _e('None', 'revisr');
        ?>
</option>
		</select>

		<?php 
        // Allows the user to select the tables they want to track.
        $db = new Revisr_DB();
        $tables = $db->get_tables();
        $sizes = $db->get_sizes();
        echo '<div id="advanced-db-tracking" style="display:none;"><br><select name="revisr_database_settings[tracked_tables][]" multiple="multiple" style="width:35em;height:250px;">';
        if (is_array($tables)) {
            foreach ($tables as $table) {
                $size = isset($sizes[$table]) ? $sizes[$table] : '';
                $table_selected = '';
                if (in_array($table, $db->get_tracked_tables())) {
                    $table_selected = ' selected';
                }
                echo "<option value='{$table}'{$table_selected}>{$table} {$size}</option>";
            }
        }
        echo '</select></div>';
    }
 /**
  * Returns if a pull was successful.
  * @access public
  */
 public function success_pull($output = '', $args = '')
 {
     if ($args == '0') {
         $msg = __('The local repository is already up-to-date with the remote repository.', 'revisr');
         Revisr_Admin::alert($msg);
     } else {
         $msg = sprintf(_n('Successfully pulled %s commit from %s/%s.', 'Successfully pulled %s commits from %s/%s.', $args, 'revisr'), $args, $this->remote, $this->branch);
         Revisr_Admin::alert($msg);
         if ($this->config_revisr_option('import-pulls') === 'true') {
             $db = new Revisr_DB();
             $db->import();
         }
     }
 }
<?php

/**
 * pull-remote-form.php
 * 
 * Displays the form to delete a branch.
 *
 * @package   Revisr
 * @license   GPLv3
 * @link      https://revisr.io
 * @copyright 2014 Expanded Fronts, LLC
 */
$styles_url = REVISR_URL . "assets/css/thickbox.css";
$git = new Revisr_Git();
$db = new Revisr_DB();
$tables = $db->get_tables_not_in_db();
?>
<link href="<?php 
echo $styles_url;
?>
" rel="stylesheet" type="text/css">
<div class="container" style="padding:10px">
	<form action="<?php 
echo get_admin_url();
?>
admin-post.php" method="post">
		<p><?php 
_e('The following new tables were added to the repository, but not automatically imported due to your tracking settings. Check any tables that you\'d like to import and click "Import" to continue.', 'revisr');
?>
</p>
		<?php 
    /**
     * Displays/updates the "DB Tracking" settings field.
     * @access public
     */
    public function tracked_tables_callback()
    {
        if ($this->is_updated('db_tracking')) {
            $this->git->config_revisr_option('db-tracking', $this->options['db_tracking']);
        }
        $check_tracking = $this->git->run('config revisr.db-tracking');
        if (is_array($check_tracking)) {
            $db_tracking = $check_tracking[0];
            if ($db_tracking == 'custom') {
                if ($this->is_updated('tracked_tables')) {
                    $this->git->run('config --unset-all revisr.tracked-tables');
                    $tables = $this->options['tracked_tables'];
                    foreach ($tables as $table) {
                        $this->git->run("config --add revisr.tracked-tables {$table}");
                    }
                }
            } else {
                $this->git->run('config --unset-all revisr.tracked-tables');
            }
        } else {
            $db_tracking = '';
        }
        ?>
		<select id="db-tracking-select" name="revisr_database_settings[db_tracking]">
			<option value="all_tables" <?php 
        selected($db_tracking, 'all_tables');
        ?>
><?php 
        _e('All Tables', 'revisr');
        ?>
</option>
			<option value="custom" <?php 
        selected($db_tracking, 'custom');
        ?>
><?php 
        _e('Let me decide...', 'revisr');
        ?>
</option>
			<option value="none" <?php 
        selected($db_tracking, 'none');
        ?>
><?php 
        _e('None', 'revisr');
        ?>
</option>
		</select>

		<?php 
        // Allows the user to select the tables they want to track.
        $db = new Revisr_DB();
        $tables = $db->get_tables();
        echo '<div id="advanced-db-tracking"><br><select name="revisr_database_settings[tracked_tables][]" multiple="multiple" style="width:35em;height:250px;">';
        if (is_array($tables)) {
            foreach ($tables as $table) {
                $table_selected = '';
                if (in_array($table, $db->get_tracked_tables())) {
                    $table_selected = ' selected';
                }
                echo "<option value='{$table}'{$table_selected}>{$table}</option>";
            }
        }
        echo '</select></div>';
    }
Esempio n. 5
0
 /**
  * Checks out an existing branch.
  * @access public
  * @param string  $args 			The branch to checkout.
  * @param boolean $new_branch 	Whether the branch being checked out is a new branch.
  */
 public function checkout($args, $new_branch = false)
 {
     if (isset($this->options['reset_db'])) {
         $db = new Revisr_DB();
         $db->backup();
     }
     if ($args == '') {
         $branch = escapeshellarg($_REQUEST['branch']);
     } else {
         $branch = $args;
     }
     Revisr_Git::run('reset --hard HEAD');
     Revisr_Git::run("checkout {$branch}");
     if (isset($this->options['reset_db']) && $new_branch === false) {
         $db->restore(true);
     }
     $msg = sprintf(__('Checked out branch: %s.', 'revisr'), $branch);
     $email_msg = sprintf(__('%s was switched to branch %s.', 'revisr'), get_bloginfo(), $branch);
     Revisr_Admin::log($msg, "branch");
     Revisr_Admin::notify(get_bloginfo() . __(' - Branch Changed', 'revisr'), $email_msg);
     $url = get_admin_url() . "admin.php?page=revisr&branch={$branch}&checkout=success";
     wp_redirect($url);
 }