Skip to content

Commit

Permalink
change this plugin to be a network wide plugin now.
Browse files Browse the repository at this point in the history
so the wptc client will be loaded network wide, and
any blog can get connect with trac repository.
  • Loading branch information
seanchen committed Feb 1, 2013
1 parent 562c4ea commit 1e48ad4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
18 changes: 9 additions & 9 deletions wp-trac-client/admin-settings.php
Expand Up @@ -6,9 +6,9 @@
$_POST['wptc_settings_form_submit'] == 'Y') {

// save settings submit. save user input to database.
update_blog_option(get_current_blog_id(), 'wptc_rpcurl', $_POST['wptc_rpcurl']);
update_blog_option(get_current_blog_id(), 'wptc_username', $_POST['wptc_username']);
update_blog_option(get_current_blog_id(), 'wptc_password', $_POST['wptc_password']);
update_site_option('wptc_rpcurl', $_POST['wptc_rpcurl']);
update_site_option('wptc_username', $_POST['wptc_username']);
update_site_option('wptc_password', $_POST['wptc_password']);

// show the message.
echo '<div class="updated"><p><strong>Settings Updated</strong></p></div>';
Expand All @@ -17,9 +17,9 @@
if (isset($_POST['wptc_quicktest_form_submit']) &&
$_POST['wptc_quicktest_form_submit'] == 'Y') {

$rpcurl = get_blog_option(get_current_blog_id(), 'wptc_rpcurl');
$username = get_blog_option(get_current_blog_id(), 'wptc_username');
$password = get_blog_option(get_current_blog_id(), 'wptc_password');
$rpcurl = get_site_option('wptc_rpcurl');
$username = get_site_option('wptc_username');
$password = get_site_option('wptc_password');
if ($rpcurl) {
require_once 'Zend/XmlRpc/Client.php';
$client = new Zend_XmlRpc_Client($rpcurl);
Expand Down Expand Up @@ -49,19 +49,19 @@
<tr>
<th>Trac XML-RPC URL: </th>
<td><input type="text" id="wptc_rpcurl" name="wptc_rpcurl"
value="<?php echo get_blog_option(get_current_blog_id(), 'wptc_rpcurl'); ?>" size="88"/>
value="<?php echo get_site_option('wptc_rpcurl'); ?>" size="88"/>
</td>
</tr>
<tr>
<th>Trac User Name: </th>
<td><input type="text" id="wptc_username" name="wptc_username"
value="<?php echo get_blog_option(get_current_blog_id(), 'wptc_username'); ?>" size="58"/>
value="<?php echo get_site_option('wptc_username'); ?>" size="58"/>
</td>
</tr>
<tr>
<th scope="row">Trac Password: </th>
<td><input type="password" id="wptc_password" name="wptc_password"
value="<?php echo get_blog_option(get_current_blog_id(), 'wptc_password'); ?>" size="58"/>
value="<?php echo get_site_option('wptc_password'); ?>" size="58"/>
</td>
</tr>
<tr>
Expand Down
30 changes: 16 additions & 14 deletions wp-trac-client/wp-trac-client.php
Expand Up @@ -23,21 +23,23 @@
// this will work for symlink path too.
$my_plugin_file = __FILE__;

if (isset($plugin)) {
$my_plugin_file = $plugin;
}
else if (isset($mu_plugin)) {
$my_plugin_file = $mu_plugin;
}
else if (isset($network_plugin)) {
$my_plugin_file = $network_plugin;
}
//if (isset($plugin)) {
// $my_plugin_file = $plugin;
//}
//else if (isset($mu_plugin)) {
// $my_plugin_file = $mu_plugin;
//}
//else if (isset($network_plugin)) {
// $my_plugin_file = $network_plugin;
//}

//var_dump($my_plugin_file);

define('MY_PLUGIN_FILE', $my_plugin_file);
define('MY_PLUGIN_PATH', WP_PLUGIN_DIR.'/'.basename(dirname($my_plugin_file)));

// load the Zend Framework.

// show error message.
ini_set('display_errors', 1);
add_action('plugins_loaded', 'zend_framework_init');
function zend_framework_init() {
Expand Down Expand Up @@ -96,9 +98,9 @@ function register_resources() {
function get_wptc_client() {

// get the settings from current blog
$rpcurl = get_blog_option(get_current_blog_id(), 'wptc_rpcurl');
$username = get_blog_option(get_current_blog_id(), 'wptc_username');
$password = get_blog_option(get_current_blog_id(), 'wptc_password');
$rpcurl = get_site_option('wptc_rpcurl');
$username = get_site_option('wptc_username');
$password = get_site_option('wptc_password');
if ($rpcurl) {
require_once 'Zend/XmlRpc/Client.php';
$wptc_client = new Zend_XmlRpc_Client($rpcurl);
Expand All @@ -109,7 +111,7 @@ function get_wptc_client() {
}

// we need a admin page on dashboard for configuration.
add_action('admin_menu', 'wptc_admin_init');
add_action('network_admin_menu', 'wptc_admin_init');
/**
* the main function to set up admin page.
*/
Expand Down

0 comments on commit 1e48ad4

Please sign in to comment.