| 1 |
<?php |
| 2 |
|
| 3 |
function get_meta_values( $key = '', $type = 'avcp', $status = 'publish' ) { |
| 4 |
global $wpdb; |
| 5 |
if( empty( $key ) ) |
| 6 |
return; |
| 7 |
$r = $wpdb->get_col( $wpdb->prepare( " |
| 8 |
SELECT pm.meta_value FROM {$wpdb->postmeta} pm |
| 9 |
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id |
| 10 |
WHERE pm.meta_key = '%s' |
| 11 |
AND p.post_status = '%s' |
| 12 |
AND p.post_type = '%s' |
| 13 |
", $key, $status, $type ) ); |
| 14 |
return $r; |
| 15 |
} |
| 16 |
|
| 17 |
/* =========== Settings Menu ============ */ |
| 18 |
add_action('admin_menu', 'avcp_setting_menu'); |
| 19 |
add_action('admin_init', 'avcp_reg_settings'); |
| 20 |
if ( is_admin() ){ // admin actions |
| 21 |
|
| 22 |
} else { |
| 23 |
// non-admin enqueues, actions, and filters |
| 24 |
} |
| 25 |
|
| 26 |
function avcp_reg_settings() { |
| 27 |
register_setting( 'avcp_options', 'avcp_version_number'); update_option( 'avcp_version_number', '2.0' ); |
| 28 |
register_setting( 'avcp_options', 'avcp_denominazione_ente'); |
| 29 |
register_setting( 'avcp_options', 'avcp_codicefiscale_ente'); |
| 30 |
register_setting( 'avcp_options', 'avcp_autopublish'); |
| 31 |
register_setting( 'avcp_options', 'avcp_dis_archivioditte'); |
| 32 |
register_setting( 'avcp_options', 'avcp_dis_archivioanni'); |
| 33 |
register_setting( 'avcp_options', 'avcp_dis_styledbackend'); |
| 34 |
register_setting( 'avcp_options', 'avcp_tab_jqueryui'); |
| 35 |
register_setting( 'avcp_options', 'avcp_showxml'); |
| 36 |
register_setting( 'avcp_options', 'avcp_showlove'); |
| 37 |
} |
| 38 |
|
| 39 |
function avcp_setting_menu() |
| 40 |
{ |
| 41 |
add_submenu_page('edit.php?post_type=avcp', 'Impostazioni', 'Impostazioni', 'manage_options', 'avcp_settings', 'avcp_settings_menu'); |
| 42 |
} |
| 43 |
|
| 44 |
function avcp_settings_menu() |
| 45 |
{ |
| 46 |
if (!current_user_can('manage_options')) { |
| 47 |
wp_die(__('You do not have sufficient permissions to access this page.')); |
| 48 |
} |
| 49 |
|
| 50 |
if(isset($_POST['XMLgenBUTTON'])) { |
| 51 |
$terms = get_terms( 'annirif', array('hide_empty' => 0) ); |
| 52 |
$count = count($terms); |
| 53 |
if ( $count > 0 ){ |
| 54 |
foreach ( $terms as $term ) { |
| 55 |
creafilexml ($term->name); |
| 56 |
$verificafilecreati = $term->name . ' - ' . $verificafilecreati; |
| 57 |
echo '<div class="updated"><p>'; |
| 58 |
printf(__('AVCP | Il seguente file .xml รจ stato creato correttamente: <b>' . $term->name . '</b>')); |
| 59 |
echo "</p></div>"; |
| 60 |
} |
| 61 |
} else { |
| 62 |
echo '<div class="error"><p>'; |
| 63 |
printf(__('AVCP | Impossibile creare il file .xml!<br/>Controlla che sia presente qualche gara e che siano collegate al proprio "Anno di Riferimento"...')); |
| 64 |
echo "</p></div>"; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
if(isset($_POST['Submit'])) { |
| 69 |
$get_avcp_denominazione_ente = $_POST["avcp_denominazione_ente_n"]; |
| 70 |
update_option( 'avcp_denominazione_ente', $get_avcp_denominazione_ente ); |
| 71 |
$get_avcp_codicefiscale_ente = $_POST["avcp_codicefiscale_ente_n"]; |
| 72 |
update_option( 'avcp_codicefiscale_ente', $get_avcp_codicefiscale_ente ); |
| 73 |
if (isset($_POST['avcp_autopublish_n'])){ |
| 74 |
update_option('avcp_autopublish', '1'); |
| 75 |
} else { |
| 76 |
update_option('avcp_autopublish', '0'); |
| 77 |
} |
| 78 |
if (isset($_POST['avcp_dis_archivioditte_n'])){ |
| 79 |
update_option('avcp_dis_archivioditte', '0'); //Invertito |
| 80 |
} else { |
| 81 |
update_option('avcp_dis_archivioditte', '1'); |
| 82 |
} |
| 83 |
if (isset($_POST['avcp_dis_archivioanni_n'])){ |
| 84 |
update_option('avcp_dis_archivioanni', '0'); //Invertito |
| 85 |
} else { |
| 86 |
update_option('avcp_dis_archivioanni', '1'); |
| 87 |
} |
| 88 |
if (isset($_POST['avcp_dis_styledbackend_n'])){ |
| 89 |
update_option('avcp_dis_styledbackend', '0'); //Invertito |
| 90 |
} else { |
| 91 |
update_option('avcp_dis_styledbackend', '1'); |
| 92 |
} |
| 93 |
if (isset($_POST['avcp_tab_jqueryui_n'])){ |
| 94 |
update_option('avcp_tab_jqueryui', '1'); |
| 95 |
} else { |
| 96 |
update_option('avcp_tab_jqueryui', '0'); |
| 97 |
} |
| 98 |
if (isset($_POST['avcp_showxml_n'])){ |
| 99 |
update_option('avcp_showxml', '1'); |
| 100 |
} else { |
| 101 |
update_option('avcp_showxml', '0'); |
| 102 |
} |
| 103 |
if (isset($_POST['avcp_showlove_n'])){ |
| 104 |
update_option('avcp_showlove', '1'); |
| 105 |
} else { |
| 106 |
update_option('avcp_showlove', '0'); |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
echo '<div class="wrap">'; |
| 111 |
screen_icon(); |
| 112 |
printf( |
| 113 |
' |
| 114 |
<div style="float:right;"> |
| 115 |
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> |
| 116 |
<input type="hidden" name="cmd" value="_s-xclick"> |
| 117 |
<input type="hidden" name="hosted_button_id" value="F2JK36SCXKTE2"> |
| 118 |
<input type="image" src="https://www.paypalobjects.com/it_IT/IT/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - Il metodo rapido, affidabile e innovativo per pagare e farsi pagare."> |
| 119 |
<img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1"> |
| 120 |
</form> |
| 121 |
</div> |
| 122 |
|
| 123 |
<h2>AVCP XML v' . get_option('avcp_version_number') . ' <a href="http://wordpress.org/plugins/avcp/installation/" target="_blank" class="add-new-h2">Installazione</a><a href="http://marcomilesi.ml/supporto" target="_blank" class="add-new-h2">Forum di Supporto</a><a href="http://wordpress.org/plugins/avcp/changelog/" target="_blank" class="add-new-h2">CHANGELOG</a></h2>' |
| 124 |
); |
| 125 |
|
| 126 |
// SYSTEM CHECK |
| 127 |
echo '<form method="post" name="options" target="_self">'; |
| 128 |
settings_fields('avcp_options'); |
| 129 |
echo '<div id="welcome-panel" style="margin:10px;width:50%;float:left;" class="welcome-panel"> |
| 130 |
<h3><span>Generazione file .xml</span></h3> |
| 131 |
I file .xml generati sono pubblicamente accessibili da: <b><a class="add-new-h2" href="' . get_site_url() . '/avcp' . '" target="_blank">' . get_site_url() . '/avcp' . '</a></b><br/> |
| 132 |
<center><p class="submit"><input type="submit" class="button-primary" name="XMLgenBUTTON" value="Genera XML" /><br/>Clicca qui per generare manualmente i file .xml (verranno creati i file divisi per anno prendendo come riferimento il campo "Anno di Riferimento" inserito nelle varie voci).<br/>Per <b>cancellare</b> i file, accedere via ftp!</p><p style="color:red;">Attenzione! Questa funzione non sostituisce la comunicazione obbligatoria dell\'url del file .xml ad AVCP, secondo le disposizioni normative vigenti.</p></center>'; |
| 133 |
|
| 134 |
echo '</div>'; |
| 135 |
echo ' |
| 136 |
<div id="alert" style="margin:10px;width:40%;float:left;" class="welcome-panel"> |
| 137 |
<h3><span>System Check-UP</span></h3>'; |
| 138 |
|
| 139 |
$dir = ABSPATH . 'avcp'; |
| 140 |
$file = $dir . '/index.php'; |
| 141 |
echo '<br/>'; |
| 142 |
$system_ok = true; |
| 143 |
if(is_dir($dir)) { |
| 144 |
echo 'Presenza cartella /avcp<font style="color:green;font-weight:bold;"> ==> OK</font>'; |
| 145 |
} else { |
| 146 |
echo 'Presenza cartella /avcp<font style="color:red;font-weight:bold;"> ==> NON TROVATA</font>'; |
| 147 |
$system_ok = false; |
| 148 |
} |
| 149 |
echo '<br/>'; |
| 150 |
if (is_writeable($dir)) { |
| 151 |
echo 'Permessi scrittura cartella /avcp<font style="color:green;font-weight:bold;"> ==> OK</font>'; |
| 152 |
} else { |
| 153 |
echo 'Permessi scrittura cartella /avcp<font style="color:red;font-weight:bold;"> ==> NON CORRISPONDENTI</font>'; |
| 154 |
$system_ok = false; |
| 155 |
} |
| 156 |
echo '<br/>'; |
| 157 |
|
| 158 |
if (file_exists($file)) { |
| 159 |
echo 'Presenza index.php /avcp<font style="color:green;font-weight:bold;"> ==> OK</font>'; |
| 160 |
} else { |
| 161 |
echo 'Presenza index.php /avcp<font style="color:red;font-weight:bold;"> ==> NON TROVATO</font>'; |
| 162 |
$system_ok = false; |
| 163 |
} |
| 164 |
echo '<br/>'; |
| 165 |
|
| 166 |
$urlcheck = get_site_url() . '/avcp/index.php'; |
| 167 |
|
| 168 |
$agent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; pt-pt) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27"; |
| 169 |
|
| 170 |
// initializes curl session |
| 171 |
$ch=curl_init(); |
| 172 |
|
| 173 |
// sets the URL to fetch |
| 174 |
curl_setopt ($ch, CURLOPT_URL,$urlcheck ); |
| 175 |
|
| 176 |
// sets the content of the User-Agent header |
| 177 |
curl_setopt($ch, CURLOPT_USERAGENT, $agent); |
| 178 |
|
| 179 |
// return the transfer as a string |
| 180 |
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); |
| 181 |
|
| 182 |
// disable output verbose information |
| 183 |
curl_setopt ($ch,CURLOPT_VERBOSE,false); |
| 184 |
|
| 185 |
// max number of seconds to allow cURL function to execute |
| 186 |
curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
| 187 |
|
| 188 |
curl_exec($ch); |
| 189 |
|
| 190 |
// get HTTP response code |
| 191 |
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 192 |
|
| 193 |
curl_close($ch); |
| 194 |
|
| 195 |
if($httpcode==200) { |
| 196 |
echo 'Test Accesso pubblico /avcp<font style="color:green;font-weight:bold;"> ==> OK [200]</font>'; |
| 197 |
} else if($httpcode==500) { |
| 198 |
echo 'Test Accesso pubblico /avcp<font style="color:red;font-weight:bold;"> ==> ERRORE 500 ISE</font>'; |
| 199 |
$headers = get_headers($urlcheck); |
| 200 |
echo ' - ' . $headers[0]; |
| 201 |
$system_ok = false; |
| 202 |
} else { |
| 203 |
echo 'Test Accesso pubblico /avcp<font style="color:red;font-weight:bold;"> ==> ERRORE ' . $httpcode . '</font>'; |
| 204 |
$headers = get_headers($urlcheck); |
| 205 |
echo ' - ' . $headers[0]; |
| 206 |
$system_ok = false; |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
echo '<h4>Esito:</h4>'; |
| 211 |
if ($system_ok) { |
| 212 |
echo 'Nessun problema rilevato con il server. Molto bene!'; |
| 213 |
} else { |
| 214 |
echo ' |
| 215 |
<style> |
| 216 |
#alert { |
| 217 |
background: white url(' . plugin_dir_url(__FILE__) . 'includes/alert.jpg) no-repeat center; |
| 218 |
} |
| 219 |
</style>'; |
| 220 |
echo 'Sono stati trovati alcuni problemi <b>critici</b>. Affinchรจ AVCP funzioni correttamente รจ necessario risolvere al piรน presto questi problemi. Consultare la documentazione del plugin per conoscere le cause piรน probabili di questo problema!'; |
| 221 |
} |
| 222 |
echo '</div> |
| 223 |
<div class="clear"></div>'; |
| 224 |
|
| 225 |
//Qui inizia la sezione delle impostazioni |
| 226 |
|
| 227 |
echo ' |
| 228 |
<div class="postbox-container" style="width: 100%"> |
| 229 |
<div class="metabox-holder"> |
| 230 |
|
| 231 |
<div class="postbox" id="second"> |
| 232 |
<h3 class="hndle"><span>Impostazioni Ente</span></h3> |
| 233 |
<div class="inside"> |
| 234 |
|
| 235 |
<table class="form-table"><tbody>'; |
| 236 |
|
| 237 |
echo '<tr>'; |
| 238 |
echo '<th><label>Denominazione Ente</label></th>'; |
| 239 |
echo '<td><input type="text" name="avcp_denominazione_ente_n" value="'; echo get_option('avcp_denominazione_ente'); echo '" class="regular-text">'; |
| 240 |
echo '<span class="description">Inserire la denominazione dell\'Ente # massimo 250 caratteri</span></td>'; |
| 241 |
echo '</tr>'; |
| 242 |
|
| 243 |
echo '<tr>'; |
| 244 |
echo '<th><label>Codice Fiscale Ente</label></th>'; |
| 245 |
echo '<td><input type="text" name="avcp_codicefiscale_ente_n" value="'; echo get_option('avcp_codicefiscale_ente'); echo '" class="regular-text">'; |
| 246 |
echo '<span class="description">Inserire il codice fiscale/partita iva dell\'ente # 9 caratteri.</span></td>'; |
| 247 |
echo '</tr>'; |
| 248 |
|
| 249 |
echo '<tr>'; |
| 250 |
echo '<th><label>.XML Automatico</label></th>'; |
| 251 |
echo '<td><input type="checkbox" name="avcp_autopublish_n" '; |
| 252 |
$get_avcp_autopublish = get_option('avcp_autopublish'); |
| 253 |
if ($get_avcp_autopublish == '1') { |
| 254 |
echo 'checked="checked" '; |
| 255 |
} |
| 256 |
echo '><span class="description">Spunta questa casella se vuoi generare aggiungere automaticamente le gare al corrispettivo file .xml (in base all\'anno di riferimento impostato).<br/><small>Attenzione! Con questa funzione ad ogni nuova pubblicazione viene ricreato solo file .xml relativo all\'anno di riferimento della gara. Per creare i file .xml relativi ad ogni anno di riferimento รจ comunque necessario cliccare sul pulsante di questa pagina, in alto.</small></span></td>'; |
| 257 |
echo '</tr>'; |
| 258 |
|
| 259 |
echo'</tbody></table> |
| 260 |
</div></div>'; |
| 261 |
|
| 262 |
echo ' |
| 263 |
<div class="postbox" id="second"> |
| 264 |
<h3 class="hndle"><span>Impostazioni Tabella</span></h3> |
| 265 |
<div class="inside"> |
| 266 |
|
| 267 |
<table class="form-table"><tbody>'; |
| 268 |
|
| 269 |
echo '<tr>'; |
| 270 |
echo '<th><label>JQuery UI</label></th>'; |
| 271 |
echo '<td><input type="checkbox" name="avcp_tab_jqueryui_n" '; |
| 272 |
$get_avcp_tab_jqueryui = get_option('avcp_tab_jqueryui'); |
| 273 |
if ($get_avcp_tab_jqueryui == '1') { |
| 274 |
echo 'checked="checked" '; |
| 275 |
} |
| 276 |
echo '><span class="description">Spunta questa casella se vuoi abilitare il tema jQueryUI Themeroller per la tabella</span></td>'; |
| 277 |
echo '</tr>'; |
| 278 |
|
| 279 |
echo '<tr>'; |
| 280 |
echo '<th><label>Mostra Link XML</label></th>'; |
| 281 |
echo '<td><input type="checkbox" name="avcp_showxml_n" '; |
| 282 |
$get_avcp_showxml = get_option('avcp_showxml'); |
| 283 |
if ($get_avcp_showxml == '1') { |
| 284 |
echo 'checked="checked" '; |
| 285 |
} |
| 286 |
echo '><span class="description">Spunta questa casella se vuoi mostrare il collegamento alla pagina dei file .xml generati (vedi in alto)</span></td>'; |
| 287 |
echo '</tr>'; |
| 288 |
|
| 289 |
echo '<tr>'; |
| 290 |
echo '<th><label>Mostra un po\' di Amore</label></th>'; |
| 291 |
echo '<td><input type="checkbox" name="avcp_showlove_n" '; |
| 292 |
$get_avcp_showlove = get_option('avcp_showlove'); |
| 293 |
if ($get_avcp_showlove == '1') { |
| 294 |
echo 'checked="checked" '; |
| 295 |
} |
| 296 |
echo '><span class="description">Spunta questa casella se vuoi mostrare il link al plugin sotto alla tabella generata</span></td>'; |
| 297 |
echo '</tr>'; |
| 298 |
|
| 299 |
echo '</tbody></table> |
| 300 |
</div></div>'; |
| 301 |
|
| 302 |
echo ' |
| 303 |
<div class="postbox" id="second"> |
| 304 |
<h3 class="hndle"><span>Visualizzazioni archivio</span></h3> |
| 305 |
<div class="inside"> |
| 306 |
|
| 307 |
<table class="form-table"><tbody>'; |
| 308 |
|
| 309 |
echo '<tr>'; |
| 310 |
echo '<th><label>Archivio Ditte</label></th>'; |
| 311 |
echo '<td><input type="checkbox" name="avcp_dis_archivioditte_n" '; |
| 312 |
$get_avcp_dis_archivioditte = get_option('avcp_dis_archivioditte'); |
| 313 |
if ($get_avcp_dis_archivioditte == '0') { |
| 314 |
echo 'checked="checked" '; |
| 315 |
} |
| 316 |
echo '><span class="description">Abilita i link con la visualizzazione archivio delle ditte con i bandi a cui la ditta ha partecipato</span></td>'; |
| 317 |
echo '</tr>'; |
| 318 |
|
| 319 |
echo '<tr>'; |
| 320 |
echo '<th><label>Archivio Annuale</label></th>'; |
| 321 |
echo '<td><input type="checkbox" name="avcp_dis_archivioanni_n" '; |
| 322 |
$get_avcp_dis_archivioanni = get_option('avcp_dis_archivioanni'); |
| 323 |
if ($get_avcp_dis_archivioanni == '0') { |
| 324 |
echo 'checked="checked" '; |
| 325 |
} |
| 326 |
echo '><span class="description">Abilita i link con la visualizzazione archivio su base annuale dei bandi</span></td>'; |
| 327 |
echo '</tr>'; |
| 328 |
|
| 329 |
echo '</tbody></table> |
| 330 |
</div></div>'; |
| 331 |
|
| 332 |
echo ' |
| 333 |
<div class="postbox" id="second"> |
| 334 |
<h3 class="hndle"><span>Altre Impostazioni</span></h3> |
| 335 |
<div class="inside"> |
| 336 |
|
| 337 |
<table class="form-table"><tbody>'; |
| 338 |
|
| 339 |
echo '<tr>'; |
| 340 |
echo '<th><label>CSS Backend</label></th>'; |
| 341 |
echo '<td><input type="checkbox" name="avcp_dis_styledbackend_n" '; |
| 342 |
$get_avcp_dis_styledbackend = get_option('avcp_dis_styledbackend'); |
| 343 |
if ($get_avcp_dis_styledbackend == '0') { |
| 344 |
echo 'checked="checked" '; |
| 345 |
} |
| 346 |
echo '><span class="description">Abilita il caricamento di css aggiuntivo per le pagine di amministrazione AVCP</span></td>'; |
| 347 |
echo '</tr>'; |
| 348 |
|
| 349 |
echo '</tbody></table> |
| 350 |
</div></div> |
| 351 |
</div></div> |
| 352 |
<p class="submit"><input type="submit" class="button-primary" name="Submit" value="AGGIORNA IMPOSTAZIONI" /></p>'; |
| 353 |
|
| 354 |
echo '</form>'; |
| 355 |
|
| 356 |
//Qui finisce la sezione delle impostazione |
| 357 |
|
| 358 |
echo '<center><h3>Scopri gli altri plugin pensati per la Pubblica Amministrazione</h3> |
| 359 |
<hr/> |
| 360 |
<a href="http://wordpress.org/plugins/amministrazione-trasparente" target="_blank" title="Plugin Wordpress per la gestione della sezione AMMINISTRAZIONE TRASPARENTE prevista dal d.lgs 33/2013"> |
| 361 |
<img src="' . plugin_dir_url(__FILE__) . 'includes/at.png"/></a> |
| 362 |
<hr/> |
| 363 |
<a href="http://wordpress.org/plugins/amministrazione-aperta/" target="_blank" title="Plugin Wordpress per la gestione di Spese, Contributi, Concessioni, Incarichi..."> |
| 364 |
<img src="' . plugin_dir_url(__FILE__) . 'includes/aa.png"/></a> |
| 365 |
<hr/> |
| 366 |
Sviluppo e ideazione Wordpress a cura di <a href="http://marcomilesi.ml" target="_blank" title="www.marcomilesi.ml">Marco Milesi</a><br/><small>Per la preparazione di questo programma sono state impiegate diverse ore a titolo volontario. Se vuoi, puoi effettuare una piccola donazione utilizzando il link che trovi in alto a destra.<br/>Per qualsiasi informazione e per segnalare un problema รจ attivo il forum di supporto su <a href="http://marcomilesi.ml/supporto" target="_blank" title="www.marcomilesi.ml/supporto">www.marcomilesi.ml/supporto</a></small></center> |
| 367 |
</div>'; |
| 368 |
|
| 369 |
} |
| 370 |
?> |