Skip to content
Newer
Older
100644 125 lines (106 sloc) 3.74 KB
4f9b238 @zagraves initial commit
zagraves authored
1 <?php
e54b9da @zagraves added license headers
zagraves authored
2 /**
3 * Yahoo! Updates Wordpress Plugin
4 *
5 * Find documentation and support on Yahoo! Developer Network: http://developer.yahoo.com
6 *
7 * Hosted on GitHub: http://github.com/yahoo/yos-updates-wordpress/tree/master
8 *
9 * @package yos-updates-wordpress
10 * @subpackage yahoo
11 *
2428313 @zagraves updated authors
zagraves authored
12 * @author Ryan Kennedy
13 * @author Lawrence Morrisroe <lem@yahoo-inc.com>,
6304536 @zagraves fixed my email address in the comments, also updated the ico warning
zagraves authored
14 * @author Zach Graves <zachg@yahoo-inc.com>
e54b9da @zagraves added license headers
zagraves authored
15 * @copyright Copyrights for code authored by Yahoo! Inc. is licensed under the following terms:
16 * @license BSD Open Source License
17 *
18 * Permission is hereby granted, free of charge, to any person obtaining a copy
19 * of this software and associated documentation files (the "Software"), to deal
20 * in the Software without restriction, including without limitation the rights
21 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22 * copies of the Software, and to permit persons to whom the Software is
23 * furnished to do so, subject to the following conditions:
24 *
25 * The above copyright notice and this permission notice shall be included in
26 * all copies or substantial portions of the Software.
27 *
28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 * THE SOFTWARE.
35 **/
4f9b238 @zagraves initial commit
zagraves authored
36
37 define("YUPDATES_USER_OPTION", "yupdates_updates_widget_users");
38 define("YUPDATES_CONSUMER_KEY_OPTION", "yupdates_consumer_key");
39 define("YUPDATES_CONSUMER_SECRET_OPTION", "yupdates_consumer_secret");
40 define("YUPDATES_APPLICATION_ID_OPTION", "yupdates_application_id");
41 define("YUPDATES_WIDGET_COUNT_OPTION", "yupdates_widget_count");
42 define("YUPDATES_TITLE_TEMPLATE_OPTION", "yupdates_title_template");
43
44 $updateUsers = get_option(YUPDATES_USER_OPTION);
3ea505c @zagraves CCK API support
zagraves authored
45
4f9b238 @zagraves initial commit
zagraves authored
46 if(is_bool($updateUsers) && !$updateUsers) {
9e4d21d @zagraves soft tabs
zagraves authored
47 $updateUsers = array();
48 } else if(!is_array($updateUsers)) {
49 $updateUsers = array();
50 delete_option(YUPDATES_USER_OPTION);
4f9b238 @zagraves initial commit
zagraves authored
51 }
52
9e4d21d @zagraves soft tabs
zagraves authored
53 //////////////////////
54 // yupdates_db_utils
55 //////////////////////
4f9b238 @zagraves initial commit
zagraves authored
56
9e4d21d @zagraves soft tabs
zagraves authored
57 function yupdatesdb_hasApplicationInfo()
58 {
59 return get_option(YUPDATES_CONSUMER_KEY_OPTION) &&
60 get_option(YUPDATES_CONSUMER_SECRET_OPTION) &&
61 get_option(YUPDATES_APPLICATION_ID_OPTION);
4f9b238 @zagraves initial commit
zagraves authored
62 }
63
9e4d21d @zagraves soft tabs
zagraves authored
64 function yupdatesdb_getApplicationInfo()
65 {
66 $info = array();
67 $info["ck"] = get_option(YUPDATES_CONSUMER_KEY_OPTION);
68 $info["cks"] = get_option(YUPDATES_CONSUMER_SECRET_OPTION);
69 $info["appid"] = get_option(YUPDATES_APPLICATION_ID_OPTION);
70
71 return $info;
4f9b238 @zagraves initial commit
zagraves authored
72 }
73
9e4d21d @zagraves soft tabs
zagraves authored
74 function yupdatesdb_addUpdatesUser($user)
75 {
76 global $updateUsers;
77 $updateUsers[$user] = true;
78 update_option(YUPDATES_USER_OPTION, $updateUsers);
4f9b238 @zagraves initial commit
zagraves authored
79 }
80
9e4d21d @zagraves soft tabs
zagraves authored
81 function yupdatesdb_removeUpdatesUser($user)
82 {
83 global $updateUsers;
84 $updateUsers[$user] = false;
85 update_option(YUPDATES_USER_OPTION, $updateUsers);
4f9b238 @zagraves initial commit
zagraves authored
86 }
87
9e4d21d @zagraves soft tabs
zagraves authored
88 function yupdatesdb_isUpdatesUser($user)
89 {
90 global $updateUsers;
91 return array_key_exists($user, $updateUsers) && $updateUsers[$user];
92 }
4f9b238 @zagraves initial commit
zagraves authored
93
9e4d21d @zagraves soft tabs
zagraves authored
94 function yupdatesdb_listUpdatesUsers()
95 {
96 global $updateUsers;
4f9b238 @zagraves initial commit
zagraves authored
97
9e4d21d @zagraves soft tabs
zagraves authored
98 $users = array();
99 foreach($updateUsers as $user => $active) {
100 if($active) {
101 $users[] = $user;
102 }
103 }
104
105 return $users;
4f9b238 @zagraves initial commit
zagraves authored
106 }
107
9e4d21d @zagraves soft tabs
zagraves authored
108 function yupdatesdb_getWidgetCount()
109 {
110 $count = get_option(YUPDATES_WIDGET_COUNT_OPTION);
111
112 if(is_bool($count) || !is_numeric($count)) {
113 $count = 5;
114 }
115
116 return $count;
4f9b238 @zagraves initial commit
zagraves authored
117 }
118
9e4d21d @zagraves soft tabs
zagraves authored
119 function yupdatesdb_setWidgetCount($count)
120 {
121 update_option(YUPDATES_WIDGET_COUNT_OPTION, $count);
4f9b238 @zagraves initial commit
zagraves authored
122 }
123
124 ?>
Something went wrong with that request. Please try again.