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('
AlboPretorio Configurazione
'.$stato.'
');
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();
}
?>