Ejemplo n.º 1
0
/**
 * Single Sign-on administration page.
 */
function vf_sso_admin_page()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $options = get_option(VF_OPTIONS_NAME);
    $sso_enabled = vf_get_value('sso-enabled', $options, '');
    $sso_create_users_on_register = vf_get_value('sso-create-users-on-register', $options, '');
    $sso_clientid = vf_get_value('sso-clientid', $options, vf_format_url(get_option('blogname')));
    $sso_secret = vf_get_value('sso-secret', $options, '');
    $vanilla_url = vf_get_value('url', $options);
    ?>
<style type="text/css">
.wrap strong {
	display: block;
	font-size: 14px;
}
.TextBox {
	width: 300px;
}
.form-container {
	background: #f0f0f0;
	display: block;
	max-width: 800px;
	padding: 10px;
	margin: 0 0 20px;
}
.form-container label {
	display: block;
	padding: 0 0 16px;
}
.form-container label:last-child {
	padding: 0;
}
.form-container span {
	display: block;
}
.info-container {
	background: #f0f0f0;
	display: block;
	max-width: 800px;
	padding: 10px;
}
.form-container label,
.info-container label {
	cursor: auto;
}
.CopyBox {
	font-size: 12px;
	border: 1px solid #ddd;
	background: #fff;
	padding: 3px 6px;
	font-family: monospace;
	margin-bottom: 10px;
	border-radius: 2px;
	-moz-border-radius: 2px;
	-webkit-border-radius: 2px;
}
.important {
	font-weight: bold;
	font-style: italic;
}
</style>
<script type="text/javascript">
jQuery(document).ready(function($) {
	$('.generate-secret').click(function() {
		$.ajax({
			url: $(this).attr('href'),
			success: function(data) {
				$('input.sso-secret').val(data);
			}
			
		});
		return false;
	});
});
</script>
<div class="wrap">
   <div id="icon-options-general" class="icon32"><br /></div>
   <h2><?php 
    _e('Vanilla Single Sign-on Integration');
    ?>
</h2>
	<?php 
    vf_open_form('sso-form');
    ?>
	<br />
	<strong>Security Settings for Single Sign-on</strong>
	<div class="form-container">
		<label>
			<strong>Enable</strong>
			<input type="checkbox" name="<?php 
    echo vf_get_option_name('sso-enabled');
    ?>
" value="1" <?php 
    echo $sso_enabled == '1' ? ' checked="checked"' : '';
    ?>
 />
			Allow users to sign into Vanilla through WordPress.
		</label>
		<label>
			<strong>Enable creating user in vanilla on Wordpress user creation</strong>
			<input type="checkbox" name="<?php 
    echo vf_get_option_name('sso-create-users-on-register');
    ?>
" <?php 
    echo $sso_create_users_on_register == 'on' ? ' checked="checked"' : '';
    ?>
 />
			Create vanilla forum user immediatelly after wordpress user registration
		</label>

		<label>
			<strong>Client ID</strong>
			<span>The client id is a url-friendly value that identifies your WordPress site to Vanilla.</span>
			<input class="TextBox" type="text" name="<?php 
    echo vf_get_option_name('sso-clientid');
    ?>
" value="<?php 
    echo $sso_clientid;
    ?>
" />
		</label>

		<label>
			<strong>Secret</strong>
			<span>This is a "secret" value that Vanilla uses to ensure that your WordPress site is a trusted source.</span>
			<input class="TextBox sso-secret" type="text" name="<?php 
    echo vf_get_option_name('sso-secret');
    ?>
" value="<?php 
    echo $sso_secret;
    ?>
" />
			<a class="generate-secret" href="<?php 
    echo site_url('?VFRequest=generate-secret');
    ?>
">Generate</a>
		</label>
	</div>
	<strong>Other information for Vanilla</strong>
	<div class="info-container">
		<label>
			<strong>Authenticate Url</strong>
			<div class="CopyBox"><?php 
    echo site_url('?VFRequest=connect');
    ?>
</div>
		</label>
		<label>
			<strong>Sign In Url</strong>
			<div class="CopyBox"><?php 
    echo wp_login_url();
    ?>
?redirect_to={Target}</div>
		</label>
		<label>
			<strong>Register Url</strong>
			<div class="CopyBox"><?php 
    echo site_url('wp-login.php?action=register', 'login');
    ?>
</div>
		</label>
		<label>
			<strong>SignOut Url</strong>
			<div class="CopyBox"><?php 
    echo add_query_arg(array('action' => 'logout', '_wpnonce' => '{Nonce}', 'redirect_to' => '{Redirect}'), site_url('wp-login.php', 'login'));
    ?>
</div>
		</label>
	</div>

	<p class="important">Make sure that <u>all</u> of the values above are copied into <a href="<?php 
    echo vf_combine_paths(array($vanilla_url, 'dashboard/settings/jsconnect'));
    ?>
">your Vanilla jsConnect settings page</a>.</p>

   <p class="submit"><input type="submit" name="save" value="<?php 
    _e('Save Changes');
    ?>
" /></p>
	</form>
</div>

<?php 
}
Ejemplo n.º 2
0
function vf_user_photo($User, $Url, $CssClass = '')
{
    if ($User->Photo == '') {
        $User->Photo = vf_combine_paths(array($Url, 'applications/dashboard/design/images/usericon.gif'), '/');
    }
    $CssClass = $CssClass == '' ? '' : ' class="' . $CssClass . '"';
    $IsFullPath = strtolower(substr($User->Photo, 0, 7)) == 'http://' || strtolower(substr($User->Photo, 0, 8)) == 'https://';
    $PhotoUrl = $IsFullPath ? $User->Photo : vf_combine_paths(array($Url, 'uploads/' . vf_change_basename($User->Photo, 'n%s')), '/');
    return '<a href="' . vf_combine_paths(array($Url, '/profile/' . $User->UserID . '/' . urlencode($User->Name)), '/') . '"' . $CssClass . ' style="display: inline-block; margin: 0 2px 2px 0">' . '<img src="' . $PhotoUrl . '" alt="' . urlencode($User->Name) . '" style="width: ' . $User->IconWidth . 'px; height: ' . $User->IconWidth . 'px; overflow: hidden; display: inline-block;" />' . '</a>';
}
Ejemplo n.º 3
0
 function vf_widget_users($args)
 {
     extract($args);
     $options = get_option(VF_OPTIONS_NAME);
     $title = vf_get_value('widget-users-title', $options, '');
     $count = (int) vf_get_value('widget-users-count', $options, '');
     $width = (int) vf_get_value('widget-users-iconwidth', $options, 32);
     if ($count < 5) {
         $count = 5;
     }
     $url = vf_get_value('url', $options, '');
     $link_url = vf_get_link_url($options);
     $resturl = array($url, '?p=user/summary.json');
     // Retrieve the latest discussions from the Vanilla API
     $resturl = vf_combine_paths($resturl, '/');
     $data = json_decode(vf_rest($resturl));
     if (!is_object($data)) {
         return;
     }
     // These lines generate our output. Widgets can be very complex
     // but as you can see here, they can also be very, very simple.
     echo $before_widget . $before_title . $title . $after_title;
     echo '<div class="ForumUsers">';
     $i = 0;
     foreach ($data->UserData as $User) {
         $i++;
         if ($i > $count) {
             break;
         }
         $User->IconWidth = $width;
         echo vf_user_photo($User, $link_url) . ' ';
     }
     echo '</div>';
     echo $after_widget;
 }
Ejemplo n.º 4
0
/**
 * Vanilla Comments administration page.
 */
function vf_comment_admin_page()
{
    // Check that the user has the required capability
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $options = get_option(VF_OPTIONS_NAME);
    $embed_comments = vf_get_value('embed-comments', $options);
    $resturl = vf_get_value('url', $options, '');
    $resturl = vf_combine_paths(array($resturl, '?p=categories/all.json'), '/');
    $categoryid = vf_get_value('embed-categoryid', $options, '0');
    $matchCategories = vf_get_value('embed-matchcategories', $options, '0');
    $category_data = json_decode(vf_rest($resturl));
    $select_options = vf_get_select_option('No Category', '0', $categoryid);
    if (is_object($category_data)) {
        foreach ($category_data->Categories as $Category) {
            $select_options .= vf_get_select_option($Category->Name, $Category->CategoryID, $categoryid);
        }
    }
    ?>
<div class="wrap">
   <div id="icon-options-general" class="icon32"><br /></div>
   <h2><?php 
    _e('Vanilla Comment Integration');
    ?>
</h2>
	<?php 
    vf_open_form('embed-comments-form');
    ?>
	 <p>
		<label>
		  <input type="checkbox" name="<?php 
    echo vf_get_option_name('embed-comments');
    ?>
" value="1"<?php 
    echo $embed_comments == '1' ? ' checked="checked"' : '';
    ?>
 />
		  Replace your blog's native commenting system with Vanilla comments.
		</label>
	 </p>
	 <p>
		<label>
		  <select name="<?php 
    echo vf_get_option_name('embed-categoryid');
    ?>
"><?php 
    echo $select_options;
    ?>
</select>
		  <?php 
    echo __('Place embedded comments into the selected category.');
    ?>
		</label>
	 </p>
    <p>
       <label>
          <input type="checkbox" name="<?php 
    echo vf_get_option_name('embed-matchcategories');
    ?>
" value="1"<?php 
    echo $matchCategories == '1' ? ' checked="checked"' : '';
    ?>
 />
          <?php 
    echo __('Try and match your Wordpress category.');
    ?>
       </label>
    </p>
    <p class="submit"><input type="submit" name="save" value="<?php 
    _e('Save Changes');
    ?>
" /></p>
  </form>
</div>
<?php 
}