Come creare sezione upload documenti nel pannello personale

Esempio: creare una sezione raggiungibile dal pannello utente che permetta di vedere degli allegati inseriti da altri utenti social network e nella quale poter inserire/gestire i propri documenti. Solo gli amministratori del social hanno il permesso di modificare eliminare tutti i documenti inseriti. Ogni documento può essere categorizzato.

Per Creare una sezione documenti visibili per alcuni ruoli, installare i seguenti moduli:

Private upload: permette di definire se gli allegati che vengono caricati nel tipo documento "documento" sono privati o pubblici ovvero se copiamo il link di un allegato e non siamo loggati non possiamo vederlo.

Node privacy byrole: Permette di definire per un tipo di nodo quali ruoli possono visualizzarlo, questo per nascondere gli allegati ai ruoli che non dovrebbero vederli.

Come prima cosa creaimo un tipo di nodo "Documento", nelle impostazioni definiamo quali campi vogliamo utilizzare, io ho creato una tendina con delle categorie per categorizzare i tipi di upload immagini, files. Nelle pimpostazioni di node privacy by role definiamo i permessi, io li ho definiti in questo modo:

- Default View Permissions
admin - admin social - utente social

-Default Edit Permission
admin - admin social - utente social

- Default Delete Permissions
admin - admin social - utente social

- Roles with rights to update permissions (chi può modificare i permessi per il tipo documento)
admin - admin social

Per gli altri parametri del documento ho eliminato le parti che non mi interessa mostrare durante la creazione ti tipo documento.

Ora entriamo anche nella gestione permessi generica e per il tipo nodo "Documento" definiamo i permessi di chi può creare, modificare il nodo.

Ora è necessario creare due viste, tutte e due le viste avranno i permessi solo per i ruoli "admin - amm social utente social" una visa mostrerà l'elenco di tutti gli allegati inseriti da altri utenti e la seconda vista mostra solo i propri documenti, sarà presente anche un bottone per creare un nuovo documento. Solo gli amministratori potranno eliminare modificare direttamente i documenti di tutti gli utenti.

Andiamo ora in admin/settings/private_upload e definiamo il tipo di upload standard come deve essere, privato o pubblico. Io ho messo di default pubblico sarà poi l'utente che decide se renderlo privato o no.

Nota: Il modulo ha un bug sovrascrivere con queste righe quelle presenti nel file del modulo private_upload.module riga 650

function theme_private_upload_form($form) {
$header = array(t('Delete'), t('List'), t('Private'), t('Description'), t('Weight'), t('Size'), '');
drupal_add_tabledrag('upload-attachments', 'order', 'sibling', 'upload-weight');

Nota2: nelle impostazioni del modulo viene mostrato un errore, cercando ho letto che comunque il modulo funziona correttamente infatti ho testato la cosa.

Incollo qui l'export della vista per il pannello personale con tutte le impostazioni e le configurazioni pronte, inserisce già il link documenti all'interno del pannello:


$view = new view;
$view->name = 'elenco_documenti_pann_personale';
$view->description = 'Elenco documenti pannello personale';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Predefinite', 'default');
$handler->override_option('fields', array(
'title' => array(
'label' => 'Nome Allegato',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'created' => array(
'label' => 'Data di inserimento',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'date_format' => 'medium',
'custom_date_format' => '',
'exclude' => 0,
'id' => 'created',
'table' => 'node',
'field' => 'created',
'relationship' => 'none',
),
'teaser' => array(
'label' => 'Descrizione Allegato',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'teaser',
'table' => 'node_revisions',
'field' => 'teaser',
'relationship' => 'none',
),
'name' => array(
'label' => 'Inserito da',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_user' => 1,
'overwrite_anonymous' => 0,
'anonymous_text' => '',
'exclude' => 0,
'id' => 'name',
'table' => 'users',
'field' => 'name',
'relationship' => 'none',
),
'upload_fid' => array(
'label' => 'File allegati',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'type' => 'ol',
'separator' => ', ',
'link_to_file' => 1,
'only_listed' => 1,
'exclude' => 0,
'id' => 'upload_fid',
'table' => 'node',
'field' => 'upload_fid',
'relationship' => 'none',
),
'edit_node' => array(
'id' => 'edit_node',
'table' => 'node',
'field' => 'edit_node',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'documento_allegato' => 'documento_allegato',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
'field_cat_documento_value_many_to_one' => array(
'operator' => 'or',
'value' => array(),
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 0,
'operator' => 'field_cat_documento_value_many_to_one_op',
'identifier' => 'cat_documento',
'label' => 'Tipologia Documento',
'optional' => 1,
'single' => 1,
'remember' => 0,
'reduce' => 0,
),
'id' => 'field_cat_documento_value_many_to_one',
'table' => 'node_data_field_cat_documento',
'field' => 'field_cat_documento_value_many_to_one',
'relationship' => 'none',
'reduce_duplicates' => 1,
),
'uid_current' => array(
'id' => 'uid_current',
'table' => 'users',
'field' => 'uid_current',
),
));
$handler->override_option('access', array(
'type' => 'role',
'role' => array(
'3' => 3,
'7' => 7,
'8' => 8,
),
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('items_per_page', 15);
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'title' => 'title',
'created' => 'created',
'teaser' => 'teaser',
'name' => 'name',
'upload_fid' => 'upload_fid',
),
'info' => array(
'title' => array(
'sortable' => 1,
'separator' => '',
),
'created' => array(
'sortable' => 1,
'separator' => '',
),
'teaser' => array(
'separator' => '',
),
'name' => array(
'sortable' => 1,
'separator' => '',
),
'upload_fid' => array(
'separator' => '',
),
),
'default' => '-1',
));
$handler = $view->new_display('page', 'Tutti i documenti', 'page_1');
$handler->override_option('fields', array(
'title' => array(
'label' => 'Nome Allegato',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'created' => array(
'label' => 'Data di inserimento',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'date_format' => 'medium',
'custom_date_format' => '',
'exclude' => 0,
'id' => 'created',
'table' => 'node',
'field' => 'created',
'relationship' => 'none',
),
'teaser' => array(
'label' => 'Descrizione Allegato',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'teaser',
'table' => 'node_revisions',
'field' => 'teaser',
'relationship' => 'none',
),
'name' => array(
'label' => 'Inserito da',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_user' => 1,
'overwrite_anonymous' => 0,
'anonymous_text' => '',
'exclude' => 0,
'id' => 'name',
'table' => 'users',
'field' => 'name',
'relationship' => 'none',
),
'upload_fid' => array(
'label' => 'File allegati',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'type' => 'ol',
'separator' => ', ',
'link_to_file' => 1,
'only_listed' => 1,
'exclude' => 0,
'id' => 'upload_fid',
'table' => 'node',
'field' => 'upload_fid',
'relationship' => 'none',
),
'edit_node' => array(
'label' => 'Modifica',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'text' => '',
'exclude' => 0,
'id' => 'edit_node',
'table' => 'node',
'field' => 'edit_node',
'override' => array(
'button' => 'Usa predefinito',
),
'relationship' => 'none',
),
'delete_node' => array(
'label' => 'Elimina',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'text' => '',
'exclude' => 0,
'id' => 'delete_node',
'table' => 'node',
'field' => 'delete_node',
'override' => array(
'button' => 'Usa predefinito',
),
'relationship' => 'none',
),
));
$handler->override_option('title', 'Tutti i documenti');
$handler->override_option('header', '');
$handler->override_option('header_format', '2');
$handler->override_option('header_empty', 1);
$handler->override_option('empty', 'Nessun Documento allegato presente.');
$handler->override_option('empty_format', '2');
$handler->override_option('path', 'documenti');
$handler->override_option('menu', array(
'type' => 'normal',
'title' => 'Documenti',
'description' => 'Documenti',
'weight' => '-1',
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler = $view->new_display('page', 'I Miei Documenti', 'page_2');
$handler->override_option('fields', array(
'title' => array(
'label' => 'Nome Allegato',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'created' => array(
'label' => 'Data di inserimento',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'date_format' => 'medium',
'custom_date_format' => '',
'exclude' => 0,
'id' => 'created',
'table' => 'node',
'field' => 'created',
'relationship' => 'none',
),
'teaser' => array(
'label' => 'Descrizione Allegato',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'teaser',
'table' => 'node_revisions',
'field' => 'teaser',
'relationship' => 'none',
),
'name' => array(
'label' => 'Inserito da',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_user' => 1,
'overwrite_anonymous' => 0,
'anonymous_text' => '',
'exclude' => 0,
'id' => 'name',
'table' => 'users',
'field' => 'name',
'relationship' => 'none',
),
'upload_fid' => array(
'label' => 'File allegati',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'type' => 'ol',
'separator' => ', ',
'link_to_file' => 1,
'only_listed' => 1,
'exclude' => 0,
'id' => 'upload_fid',
'table' => 'node',
'field' => 'upload_fid',
'relationship' => 'none',
),
'edit_node' => array(
'label' => 'Modifica',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'text' => '',
'exclude' => 0,
'id' => 'edit_node',
'table' => 'node',
'field' => 'edit_node',
'override' => array(
'button' => 'Usa predefinito',
),
'relationship' => 'none',
),
'delete_node' => array(
'label' => 'Elimina',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'text' => '',
'exclude' => 0,
'id' => 'delete_node',
'table' => 'node',
'field' => 'delete_node',
'override' => array(
'button' => 'Usa predefinito',
),
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'documento_allegato' => 'documento_allegato',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
'field_cat_documento_value_many_to_one' => array(
'operator' => 'or',
'value' => array(),
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 0,
'operator' => 'field_cat_documento_value_many_to_one_op',
'identifier' => 'cat_documento',
'label' => 'Tipologia Documento',
'optional' => 1,
'single' => 1,
'remember' => 0,
'reduce' => 0,
),
'id' => 'field_cat_documento_value_many_to_one',
'table' => 'node_data_field_cat_documento',
'field' => 'field_cat_documento_value_many_to_one',
'relationship' => 'none',
'reduce_duplicates' => 1,
),
'uid_current' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'uid_current',
'table' => 'users',
'field' => 'uid_current',
'override' => array(
'button' => 'Usa predefinito',
),
'relationship' => 'none',
),
));
$handler->override_option('title', 'I Miei Documenti');
$handler->override_option('header', '');
$handler->override_option('header_format', '2');
$handler->override_option('header_empty', 1);
$handler->override_option('empty', 'Nessun Documento presente, crea un nuovo documento');
$handler->override_option('empty_format', '3');
$handler->override_option('path', 'i-miei-documenti');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));

Nessun commento:

Posta un commento