Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
CCK API support
Browse files Browse the repository at this point in the history
  • Loading branch information
zagraves committed Jan 23, 2010
1 parent 4036257 commit 3ea505c
Show file tree
Hide file tree
Showing 6 changed files with 431 additions and 317 deletions.
158 changes: 77 additions & 81 deletions yupdates.php
Expand Up @@ -9,7 +9,7 @@
* @package yos-updates-wordpress
* @subpackage yahoo
*
* @author Ryan Kennedy <rckenned@yahoo-inc.com>, Lawrence Morrisroe <lem@yahoo-inc.com>, Zach Graves <zachg@yahoo-inc.com>
* @author Ryan Kennedy <rckenned@yahoo-inc.com>, Lawrence Morrisroe <lem@yahoo-inc.com>, Zach Graves <zachg@yahoo-incnc.com>
* @copyright Copyrights for code authored by Yahoo! Inc. is licensed under the following terms:
* @license BSD Open Source License
*
Expand Down Expand Up @@ -41,100 +41,96 @@
*/
?>
<?php
define("YUPDATES_WIDGET_ENABLED", true);
define("YUPDATES_WIDGET_ENABLED", true);

define("PLUGIN_OPTIONS_URI","options-general.php?page=yupdates_plugin_options");
define("USER_MENU_URI","users.php?page=yupdates_menu");

require_once("lib/OAuth/OAuth.php");
require_once("lib/Yahoo/YahooOAuthApplication.class.php");

// require_once("yupdates_application.php");
require_once("yupdates_sessionstore.php");
require_once("yupdates_utils.php");
require_once("yupdates_menu.php");
require_once("yupdates_options.php");
require_once("yupdates_hooks.php");
require_once("yupdates_db.php");

if(YUPDATES_WIDGET_ENABLED) {
require_once("yupdates_widgets.php");
}

add_action("admin_menu", "yupdates_plugin_menu");
add_action("init", "yupdates_auth_init");
add_action("publish_post", "yupdates_publish_post");
// add_action("delete_post", "yupdates_delete_post");
// add_action("edit_post", "yupdates_edit_post");

function yupdates_plugin_menu() {
add_submenu_page("users.php", "Yahoo! Updates Page", "Yahoo! Updates Authorization", 0, "yupdates_menu", "yupdates_menu");
add_options_page("Yahoo! Updates Plugin Options", "Yahoo! Updates Plugin", 8, "yupdates_plugin_options", "yupdates_plugin_options");
}

function yupdates_auth_init() {
$session = yupdates_get_session();

define("PLUGIN_OPTIONS_URI","options-general.php?page=yupdates_plugin_options");
define("USER_MENU_URI","users.php?page=yupdates_menu");

require_once("lib/OAuth/OAuth.php");
require_once("lib/Yahoo/YahooOAuthApplication.class.php");

require_once("yupdates_sessionstore.php");
require_once("yupdates_utils.php");
require_once("yupdates_menu.php");
require_once("yupdates_options.php");
require_once("yupdates_hooks.php");
require_once("yupdates_db.php");

if(YUPDATES_WIDGET_ENABLED) {
require_once("yupdates_widgets.php");
}

add_action("admin_menu", "yupdates_plugin_menu");
add_action("init", "yupdates_auth_init");

add_action("publish_post", "yupdates_publish_post");
// add_action("delete_post", "yupdates_delete_post");
// add_action("edit_post", "yupdates_edit_post");
?>
<?php
function yupdates_plugin_menu() {
add_submenu_page("users.php", "Yahoo! Updates Page", "Yahoo! Updates Authorization", 0, "yupdates_menu", "yupdates_menu");
add_options_page("Yahoo! Updates Plugin Options", "Yahoo! Updates Plugin", 8, "yupdates_plugin_options", "yupdates_plugin_options");
// handle directions from auth flow
if(array_key_exists("yupdates_clearauthorization", $_REQUEST)) {
yupdates_clear_session();
} else if(array_key_exists("auth_popup", $_REQUEST)) {
yupdates_close_popup();
}

function yupdates_auth_init() {
$session = yupdates_get_session();

// handle directions from auth flow
if(array_key_exists("yupdates_clearauthorization", $_REQUEST))
{
yupdates_clear_session();
}
else if(array_key_exists("auth_popup", $_REQUEST))
{
yupdates_close_popup();
}

// show warnings
if($session->hasSession == false)
{
if($session->store->hasRequestToken()) {
$request_token = $session->store->fetchRequestToken();
if(is_null($request_token->key) && !is_null($request_token->oauth_problem)) {
add_action("admin_notices", "yupdates_requestTokenProblem_warning");
} else if(stripos($_SERVER["REQUEST_URI"], USER_MENU_URI) === FALSE) {
add_action("admin_notices", "yupdates_authorization_warning");
}
} else if(yupdatesdb_hasApplicationInfo() && stripos($_SERVER["REQUEST_URI"], USER_MENU_URI) === FALSE ) {
// show warnings
if($session->hasSession == false) {
if($session->store->hasRequestToken()) {
$request_token = $session->store->fetchRequestToken();
if($request_token && is_null($request_token->key) && !is_null($request_token->oauth_problem)) {
add_action("admin_notices", "yupdates_requestTokenProblem_warning");
} else if(stripos($_SERVER["REQUEST_URI"], USER_MENU_URI) === FALSE) {
add_action("admin_notices", "yupdates_authorization_warning");
} else if($session->store->hasAccessToken()) {
// do nothing, we're all set.
}
}

if(!yupdatesdb_hasApplicationInfo()
&& stripos($_SERVER["REQUEST_URI"], PLUGIN_OPTIONS_URI) === FALSE)
{
add_action("admin_notices", "yupdates_appinfo_warning");
}
}/* else if(yupdatesdb_hasApplicationInfo() && stripos($_SERVER["REQUEST_URI"], USER_MENU_URI) === FALSE ) {
echo "no request token";
add_action("admin_notices", "yupdates_authorization_warning");
} else if($session->store->hasAccessToken()) {
// do nothing, we're all set now.
} else {
echo "no tokens!";
}*/
}

function yupdates_requestTokenProblem_warning() {
$session_store = yupdates_get_currentUserSessionStore();
$token = $session_store->fetchRequestToken();
$oauth_problem = !is_null($token->oauth_problem) ? $token->oauth_problem : "Unknown Error";

echo <<<HTML
if(!yupdatesdb_hasApplicationInfo() && stripos($_SERVER["REQUEST_URI"], PLUGIN_OPTIONS_URI) === FALSE) {
add_action("admin_notices", "yupdates_appinfo_warning");
}
}

function yupdates_requestTokenProblem_warning() {
$session_store = yupdates_get_currentUserSessionStore();
$token = $session_store->fetchRequestToken();
$oauth_problem = !is_null($token->oauth_problem) ? $token->oauth_problem : "Unknown Error";

echo <<<HTML
<div id="yupdates-authorization-warning" class="updated fade">
<p><strong>OAuth Error: Request token $oauth_problem. <a href="options-general.php?page=yupdates_plugin_options#settings">Re-configure the plugin.</a></strong></p>
<p><strong>Yahoo! Updates - OAuth Error: Request token $oauth_problem. <a href="options-general.php?page=yupdates_plugin_options#settings">Re-configure the plugin.</a></strong></p>
</div>
HTML;
}
function yupdates_appinfo_warning() {
echo <<<HTML
}

function yupdates_appinfo_warning() {
echo <<<HTML
<div id="yupdates-appinfo-warning" class="updated fade">
<p><strong>You haven't configured the Yahoo! Updates Plugin yet. <a href="options-general.php?page=yupdates_plugin_options">Configure the plugin.</a></strong></p>
<p><strong>You haven't configured the Yahoo! Updates Plugin yet. <a href="options-general.php?page=yupdates_plugin_options">Configure the plugin.</a></strong></p>
</div>
HTML;
}
function yupdates_authorization_warning() {
echo <<<HTML
}

function yupdates_authorization_warning() {
echo <<<HTML
<div id="yupdates-authorization-warning" class="updated fade">
<p><strong>You haven't authorized the Yahoo! Updates Plugin yet. <a href="users.php?page=yupdates_menu">Authorize the plugin now.</a></strong></p>
<p><strong>You haven't authorized the Yahoo! Updates Plugin yet. <a href="users.php?page=yupdates_menu">Authorize the plugin now.</a></strong></p>
</div>
HTML;
}
}
?>
56 changes: 56 additions & 0 deletions yupdates_application.php
@@ -0,0 +1,56 @@
<?php
/**
* Yahoo! Updates Wordpress Plugin
*
* Find documentation and support on Yahoo! Developer Network: http://developer.yahoo.com
*
* Hosted on GitHub: http://github.com/yahoo/yos-updates-wordpress/tree/master
*
* @package yos-updates-wordpress
* @subpackage yahoo
*
* @author Ryan Kennedy,
* @author Lawrence Morrisroe <lem@yahoo-inc.com>
* @author Zach Graves <zachg@yahoo-inc.com>
* @author Micah Laaker <micahl@yahoo-inc.com>
* @copyright Copyrights for code authored by Yahoo! Inc. is licensed under the following terms:
* @license BSD Open Source License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
**/

function yupdates_plugin_application() {
$application_id = $_GET['appid'];
$consumer_key = $_GET['key'];
$consumer_secret = $_GET['secret'];

echo <<<HTML
<script type="text/javascript">
var opener = parent.opener;
if(opener.hasOwnProperty('yupdates_setCredentials') && typeof opener.yupdates_setCredentials == 'function') {
opener.yupdates_setCredentials("{$consumer_key}","{$consumer_secret}","{$application_id}");
}
</script>
HTML;
}

yupdates_plugin_application();
?>
1 change: 1 addition & 0 deletions yupdates_db.php
Expand Up @@ -40,6 +40,7 @@
define("YUPDATES_TITLE_TEMPLATE_OPTION", "yupdates_title_template");

$updateUsers = get_option(YUPDATES_USER_OPTION);

if(is_bool($updateUsers) && !$updateUsers) {
$updateUsers = array();
}
Expand Down

0 comments on commit 3ea505c

Please sign in to comment.