PluginProbe
wp-forecast / 3.1
wp-forecast v3.1
10.0 trunk 1.4 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3..5 3..8 3.0 3.1 3.2 3.3 3.4 3.6 All 86 releases
wp-forecast / setup.php

setup.php in wp-forecast 3.1, at setup.php

211 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /* This file is part of the wp-forecast plugin for wordpress */
3
4 /* Copyright 2006-2010 Hans Matzen (email : webmaster at tuxlog dot de)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 //
22 // setting up the default options in table wp-options during
23 // plugin activation from the plugins page
24 //
25 function wp_forecast_activate()
26 {
27 pdebug(1,"Start of wp_forecast_activate ()");
28
29 // add number of widgets, default: 1
30 $count=get_option("wp-forecast-count");
31
32 if ($count == "") {
33 $count="1";
34 wpf_add_option("wp-forecast-count",$count);
35 };
36
37 // add timeout for accuweather connections, default: 30
38 $timeout=get_option("wp-forecast-timeout");
39
40 if ($timeout == "") {
41 $timeout="10";
42 wpf_add_option("wp-forecast-timeout",$timeout);
43 };
44
45 // add switch to control option deletion during plugin deactivation
46 $delopt=get_option("wp-forecast-delopt");
47
48 if ($delopt == "") {
49 $delopt="0";
50 wpf_add_option("wp-forecast-delopt",$delopt);
51 };
52
53 // add preselected transport method for wp-forecast
54 $pre_trans=get_option("wp-forecast-pre-transport");
55
56 if ($pre_trans == "") {
57 $pre_trans="default";
58 wpf_add_option("wp-forecast-pre-transport",$pre_trans);
59 };
60
61 // add transport to use by wordpress only for wp-forecast
62 $wp_trans=get_option("wp-forecast-wp-transport");
63
64 if ($wp_trans == "") {
65 $wp_trans="default";
66 wpf_add_option("wp-forecast-wp-transport",$wp_trans);
67 };
68
69 for ($i=0;$i<$count;$i++) {
70 $wpfcid = get_widget_id( $i );
71
72 // get all widget options
73 $av=get_wpf_opts($wpfcid);
74 $weather = get_option("wp-forecast-cache".$wpfcid);
75 $expire = get_option("wp-forecast-expire".$wpfcid);
76
77 // if the options dont exists, add the defaults
78 if ( empty($av['service']) or $av['service']=="" ) {
79 $av=array();
80
81 $av['service']="accu"; // specify the weatherservice to use
82 $av['apikey1']=""; // Partner ID or API Code for weatherbug or weather.com
83 $av['apikey2']=""; // License Key for weather.com
84 $av['location']="EUR|DE|GM007|FRANKFURT AM MAIN"; // location code
85 $av['locname']="Frankfurt am Main"; // user defined location name
86 $av['refresh']="1800"; // the intervall the local weather data is renewed
87 $av['metric']="1"; // 1 if you want to use metric scheme, else 0
88 $av['wpf_language']="en_US"; // language code for this widget
89 $av['daytime']="000000000"; // Switches for Daytime forecast
90 $av['nighttime']="000000000"; // Switches for Nighttime forecast
91 $av['currtime']="1"; // 1 if you want to use current time, else 0
92 $av['timeoffset']="0"; // offset to correct wrong accuweather time
93 $av['title']=__("The Weather","wp-forecast_".$av['wpf_language']); // the widget title
94 // Displayconfigurationmatrix
95 // CC FC Day FC Night
96 // Icon 0 10 14
97 // Datum 18 - -
98 // Zeit 1 - -
99 // Shorttext 2 11 15
100 // Temperatur 3 12 16
101 // gef. Temp 4 - -
102 // Luftdruck 5 - -
103 // Luftfeuchte 6 - -
104 // Wind 7 13 17
105 // Windboen 22 23 24
106 // Sonnenaufgang 8 - -
107 // Sonnenuntergang 9 - -
108 // Copyright 21 - -
109 // accuweather link 25 - -
110 // open in new window 26 - -
111 //
112 $av['dispconfig']="111111111111111111111111111";
113 $av['windunit']="ms"; // Choose between ms, kmh, mph or kts
114 $av['pdforecast']="0"; // pulldown forecast 0=No, 1=Yes
115 $av['pdfirstday']="0"; // day to start pulldown with
116
117 wpf_add_option( "wp-forecast-opts".$wpfcid, serialize($av) );
118 }
119
120 if ($weather == "") {
121 $weather="";
122 wpf_add_option("wp-forecast-cache".$wpfcid,$weather);
123 };
124
125 if ($expire == "") {
126 $expire="0";
127 wpf_add_option("wp-forecast-expire".$wpfcid, $expire );
128 };
129 } // end of for
130
131 global $blog_id;
132 if ( function_exists("is_multisite") && is_multisite() && $blog_id!=1) {
133 // add options for super admin on multisites
134 $wpf_sa_defaults = get_option("wpf_sa_defaults");
135 $wpf_sa_allowed = get_option("wpf_sa_allowed");
136
137 $allallowed = array(
138 "ue_wp-forecast-count" => 1,
139 "ue_wp-forecast-timeout" => 1,
140 "ue_wp-forecast-pre-transport" => 1,
141 "ue_wp-forecast-delopt" => 1,
142 "ue_service" => 1,
143 "ue_apikey1" => 1,
144 "ue_location" => 1,
145 "ue_locname" => 1,
146 "ue_refresh" => 1,
147 "ue_metric" => 1,
148 "ue_currtime" => 1,
149 "ue_timeoffset" => 1,
150 "ue_windunit" => 1,
151 "ue_wpf_language" => 1,
152 "ue_pdforecast" => 1,
153 "ue_pdfirstday" => 1,
154 "ue_dispconfig" => 1,
155 "ue_forecast" => 1,
156 "ue_daytime" => 1,
157 "ue_nighttime" => 1
158 );
159
160 if (!$wpf_sa_defaults) {
161 $wpf_sa_defaults = serialize(array());
162 add_blog_option(1,"wpf_sa_defaults",$wpf_sa_defaults);
163 }
164
165 if (!$wpf_sa_allowed) {
166 $wpf_sa_allowed = serialize($allallowed);
167 add_blog_option(1,"wpf_sa_allowed",$wpf_sa_allowed);
168 }
169 }
170
171 pdebug(1,"End of wp_forecast_activate ()");
172 }
173
174 //
175 // is called when plugin is deactivated and removes all
176 // the wp-forecast options from the database
177 //
178 function wp_forecast_deactivate($wpfcid)
179 {
180 pdebug(1,"Start of wp_forecast_deactivate ()");
181
182 global $wpf_maxwidgets;
183
184 $delopt=get_option('wp-forecast-delopt');
185
186 // only delete options when switch is set
187 if ($delopt == 1)
188 {
189 $count = $wpf_maxwidgets; //get_option('wp-forecast-count');
190
191 for ($i=0;$i<$count;$i++)
192 {
193 $wpfcid = get_widget_id( $i );
194
195 delete_option("wp-forecast-opts".$wpfcid);
196 delete_option("wp-forecast-cache".$wpfcid);
197 delete_option("wp-forecast-expire".$wpfcid);
198 }
199 delete_option('wp-forecast-timeout');
200 delete_option('wp-forecast-count');
201 delete_option('wp-forecast-delopt');
202 delete_option("wp-forecast-pre-transport");
203 delete_option("wp-forecast-wp-transport");
204 // delete options for superadmin on multisites
205 delete_option("wpf_sa_defaults");
206 delete_option("wpf_sa_allowed");
207 }
208
209 pdebug(1,"End of wp_forecast_deactivate ()");
210 }
211 ?>