Impostazioni salvate.

"; include_once(dirname (__FILE__) .'/functions.inc.php'); /* Various functions used throughout */ define("Albo_URL",plugin_dir_url(dirname (__FILE__).'/AlboPretorio.php')); define("Albo_DIR",dirname (__FILE__)); if (!class_exists('AlboPretorio')) { class AlboPretorio { var $version = '1.4'; var $minium_WP = '3.1'; var $options = ''; function AlboPretorio() { // Inizializzazioni $this->define_tables(); $this->load_dependencies(); $this->plugin_name = plugin_basename(__FILE__); // Hook per attivazione/disattivazione pluggin register_activation_hook( $this->plugin_name, array('AlboPretorio', 'activate')); register_deactivation_hook( $this->plugin_name, array('AlboPretorio', 'deactivate') ); // Hook disinstallazione register_uninstall_hook( $this->plugin_name, array('AlboPretorio', 'uninstall') ); // Hook di inizializzazione che registra il punto di avvio del pluggin add_action('init', array('AlboPretorio', 'update_AlboPretorio_settings')); if (!is_admin()) if (!function_exists('albo_styles')) add_action('wp_print_styles', array('AlboPretorio','albo_styles')); add_shortcode('Albo', array('AlboPretorio', 'VisualizzaAtti')); add_action('wp_head', array('AlboPretorio','head_Front_End')); } function head_Front_End() { ?> APAdminPanel = new APAdminPanel(); } } function VisualizzaAtti($Parametri){ extract(shortcode_atts(array( 'Stato' => '1', 'Per_Page' => '20' ), $Parametri)); require_once ( dirname (__FILE__) . '/admin/frontend.php' ); // return "Albo Pretorio".$Correnti." ".$Paginazione." ".$per_page." ".$default_order; } function AP_menu(){ global $wpdb; if ($_REQUEST['action']=="setta-anno"){ update_option('opt_AP_AnnoProgressivo',date("Y") ); $_SERVER['REQUEST_URI'] = remove_query_arg(array('action'), $_SERVER['REQUEST_URI']); } $n_atti = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->table_name_Atti;" ) ); $n_atti_dapub = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->table_name_Atti Where Numero=0;")); $n_atti_attivi = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->table_name_Atti Where DataInizio <= now() And DataFine>= now() And Numero>0;")); $n_atti_storico=$n_atti-$n_atti_attivi-$n_atti_dapub; $n_allegati = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->table_name_Allegati;" ) ); $n_categorie = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->table_name_Categorie;" ) ); echo '
Icona Atti

Albo Pretorio

Sommario

Statistiche
Oggetto N. In Attesa di Pubblicazione Attivi Scaduti
Atti '.$n_atti.' '.$n_atti_dapub.' '.$n_atti_attivi.' '.$n_atti_storico.'
Categorie '.$n_categorie.'
Allegati '.$n_allegati.'
'; if(get_option('opt_AP_AnnoProgressivo')!=date("Y")){ echo '
'; } } function AP_config(){ global $current_user,$stato; if ($_REQUEST['action']=="setta-anno"){ update_option('opt_AP_AnnoProgressivo',date("Y") ); $_SERVER['REQUEST_URI'] = remove_query_arg(array('action'), $_SERVER['REQUEST_URI']); } get_currentuserinfo(); $ente = stripslashes(get_option('opt_AP_Ente')); $nprog = get_option('opt_AP_NumeroProgressivo'); $nanno=get_option('opt_AP_AnnoProgressivo'); if (!$nanno){ $nanno=date("Y"); } $dirUpload = stripslashes(get_option('opt_AP_FolderUpload')); print('
Icona configurazione

AlboPretorio Configurazione

'.$stato.'
/ '.$nanno.'

'); if(get_option('opt_AP_AnnoProgressivo')!=date("Y")){ echo '
'; } } function define_tables() { global $wpdb,$table_prefix; // add database pointer $wpdb->table_name_Atti = $table_prefix . "albopretorio_atti"; $wpdb->table_name_Categorie = $table_prefix . "albopretorio_categorie"; $wpdb->table_name_Allegati = $table_prefix . "albopretorio_allegati"; $wpdb->table_name_Log=$table_prefix . "albopretorio_log"; } static function activate() { global $wpdb; $role =& get_role( 'administrator' ); /* Aggiunta dei ruoli all'Amministratore */ if ( !empty( $role ) ) { $role->add_cap( 'admin_albo' ); $role->add_cap( 'gest_atti_albo' ); } /* Creazione ruolo di Amministratore */ add_role( 'amministratore_albo', 'Amministratore Albo', array( 'read' => true, 'admin_albo' => true, 'gest_atti_albo' => true) ); /* Creazione del ruolo di Redattore */ add_role( 'gestore_albo', 'Redattore Albo', array('read' => true, 'gest_atti_albo' => true) ); // Add the admin menu if(get_option('opt_AP_Ente' == '') || !get_option('opt_AP_Ente')){ add_option('opt_AP_Ente', 'Ente non definito'); } if(get_option('opt_AP_AnnoProgressivo' == '') || !get_option('opt_AP_AnnoProgressivo')){ add_option('opt_AP_AnnoProgressivo', ''.date("Y").''); } if(get_option('opt_AP_NumeroProgressivo' == '') || !get_option('opt_AP_NumeroProgressivo')){ add_option('opt_AP_NumeroProgressivo', '0'); } if(get_option('opt_AP_FolderUpload' == '') || !get_option('opt_AP_FolderUpload')){ add_option('opt_AP_FolderUpload', $dirUpload); } $sql_Atti = "CREATE TABLE ".$wpdb->table_name_Atti." ( `IdAtto` int(11) NOT NULL auto_increment, `Numero` int(4) NOT NULL default 0, `Anno` int(4) NOT NULL default 0, `Data` date NOT NULL default '0000-00-00', `Riferimento` varchar(20) NOT NULL, `Oggetto` varchar(150) NOT NULL default '', `DataInizio` date NOT NULL default '0000-00-00', `DataFine` date default '0000-00-00', `Informazioni` varchar(255) NOT NULL default '', `IdCategoria` int(11) NOT NULL default 0, PRIMARY KEY (`IdAtto`));"; $sql_Allegati = "CREATE TABLE ".$wpdb->table_name_Allegati." ( `IdAllegato` int(11) NOT NULL auto_increment, `TitoloAllegato` varchar(255) NOT NULL default '', `Allegato` varchar(255) NOT NULL default '', `IdAtto` int(11) NOT NULL default 0, PRIMARY KEY (`IdAllegato`));"; $sql_Categorie = "CREATE TABLE ".$wpdb->table_name_Categorie." ( `IdCategoria` int(11) NOT NULL auto_increment, `Nome` varchar(255) NOT NULL default '', `Descrizione` varchar(255) NOT NULL default '', `Genitore` int(11) NOT NULL default 0, `Giorni` smallint(3) NOT NULL DEFAULT '0', PRIMARY KEY (`IdCategoria`));"; $sql_Log = "CREATE TABLE ".$wpdb->table_name_Log." ( `Data` timestamp NOT NULL default CURRENT_TIMESTAMP, `Utente` varchar(60) NOT NULL default '', `IPAddress` varchar(16) NOT NULL default '', `Oggetto` int(1) NOT NULL default 1, `IdOggetto` int(11) NOT NULL default 1, `IdAtto` int(11) NOT NULL default 0, `TipoOperazione` int(1) NOT NULL default 1, `Operazione` text);"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql_Atti); dbDelta($sql_Allegati); dbDelta($sql_Categorie); dbDelta($sql_Log); } static function deactivate() { remove_shortcode('Albo'); } static function uninstall() { global $wpdb; // Eliminazioni ruoli //Amministratore $role =& get_role( 'administrator' ); if ( !empty( $role ) ) { $role->remove_cap( 'admin_albo' ); $role->remove_cap( 'gest_atti_albo' ); } /* Array dei ruoli da eliminare */ $roles_to_delete = array( 'admin_albo', 'gest_atti_albo'); /* Ciclo che elimona i ruoli solo se non ci sono utenti assegnati a quel ruolo, altrimenti non disinstalla */ foreach ( $roles_to_delete as $role ) { $users = get_users( array( 'role' => $role ) ); if ( count( $users ) <= 0 ) { remove_role( $role ); } } // Eliminazione Tabelle data Base $wpdb->query("DROP TABLE IF EXISTS ".$wpdb->table_name_Atti); $wpdb->query("DROP TABLE IF EXISTS ".$wpdb->table_name_Allegati); $wpdb->query("DROP TABLE IF EXISTS ".$wpdb->table_name_Categorie); $wpdb->query("DROP TABLE IF EXISTS ".$wpdb->table_name_Log); // Eliminazioni Opzioni delete_option( 'opt_AP_Ente' ); delete_option( 'opt_AP_NumeroProgressivo' ); delete_option( 'opt_AP_AnnoProgressivo' ); delete_option( 'opt_AP_NumeroProtocollo' ); } function update_AlboPretorio_settings(){ if($_POST['AlboPretorio_submit_button'] == 'Salva Modifiche'){ update_option('opt_AP_Ente',$_POST['c_Ente'] ); update_option('opt_AP_AnnoProgressivo',$_POST['c_AnnoProgressivo'] ); update_option('opt_AP_NumeroProgressivo',$_POST['c_NumeroProgressivo'] ); update_option('opt_AP_FolderUpload',$_POST['c_dirUpload'] ); header('Location: '.get_bloginfo('wpurl').'/wp-admin/admin.php?page=config&update=true'); } } function albo_styles() { $myStyleUrl = plugins_url('css/style.css', __FILE__); $myStyleFile = Albo_DIR.'/css/style.css'; if ( file_exists($myStyleFile) ) { wp_register_style('AlboPretorio', $myStyleUrl); wp_enqueue_style( 'AlboPretorio'); } $myStyleUrl = plugins_url('css/epoch_styles.css', __FILE__); $myStyleFile = Albo_DIR.'/css/epoch_styles.css'; if ( file_exists($myStyleFile) ) { wp_register_style('AlboPretorioCalendario', $myStyleUrl); wp_enqueue_style( 'AlboPretorioCalendario'); } } } global $AP_OnLine; $AP_OnLine = new AlboPretorio(); } ?>