can('example','read')) return; $menuItems[] = array( 'sort'=>2, 'url'=>'index.php?module=example', 'label'=>'Example', 'icon'=> 'fas fa-users', 'color'=> '#3498db' ); } //Cette fonction va generer une page quand on clique sur Modele dans menu function example_page(){ global $_,$myUser; if(!isset($_['module']) || $_['module'] !='example') return; $page = !isset($_['page']) ? 'list' : $_['page']; $page = str_replace('..','',$page); $file = __DIR__.SLASH.'page.'.$page.'.php'; if(!file_exists($file)) throw new Exception("Page ".$page." inexistante"); require_once($file); } //Fonction executée lors de l'activation du plugin function example_install($id){ if($id != 'fr.sys1.example') return; Entity::install(__DIR__); } //Fonction executée lors de la désactivation du plugin function example_uninstall($id){ if($id != 'fr.sys1.example') return; Entity::uninstall(__DIR__); } //Déclaration des sections de droits du plugin function example_section(&$sections){ $sections['example'] = "Gestion des droits sur le plugin d'exemple"; } //Cette fonction comprends toutes les actions //du plugin qui ne nécessitent pas de vue html function example_action(){ require_once(__DIR__.SLASH.'action.php'); } //Déclaration du menu de réglages function example_menu_setting(&$settingMenu){ global $_, $myUser; if($myUser->can('example','configure')) { $settingMenu[]= array( 'sort' =>1, 'url' => 'setting.php?section=example', 'icon' => 'fas fa-angle-right', 'label' => 'Example' ); } } //Déclaration des pages de réglages function example_content_setting(){ global $_; if(file_exists(__DIR__.SLASH.'setting.'.$_['section'].'.php')) require_once(__DIR__.SLASH.'setting.'.$_['section'].'.php'); } function example_menu_account(&$accountMenu){ global $_, $myUser; if(!$myUser->can('example', 'read')) return; $accountMenu[]= array( 'sort' =>0, 'url' => 'account.php?section=example', 'icon' => 'fas fa-angle-right', 'label' => 'Example', ); $accountMenu[]= array( 'sort' =>0, 'url' => 'account.php?section=example.contact', 'icon' => 'fas fa-angle-right', 'label' => 'Example Contact', ); } //Déclaration des pages de réglages function example_content_account(){ global $_; if(file_exists(__DIR__.SLASH.'account.'.$_['section'].'.php')) require_once(__DIR__.SLASH.'account.'.$_['section'].'.php'); } function example_document_setting(){ $documents = array(); foreach(glob(__ROOT__.FILE_PATH.'contact'.SLASH.'documents'.SLASH.'settings'.SLASH.'*.*') as $file){ if(get_OS() === 'WIN') $file = utf8_encode($file); $documents[] = array( 'path' => 'contact'.SLASH.'documents'.SLASH.'settings'.SLASH.basename($file), 'url' => 'action.php?action=contact_download_document&path=settings'.SLASH.rawurlencode(basename($file)), 'name' => basename($file), 'icon' => getExtIcon(getExt($file)) ); } return $documents; } Configuration::setting('example',array( "Général", 'example_dropzone' => array("label"=>"Dropzone de fichiers","type"=>"dropzone","legend"=>"la légende","parameters"=>array( "data-allowed" => "docx,pdf,txt,jpg,bmp,gif,xlsx,png,iso", "data-label" => "Faites glisser vos documents", "data-delete" => "contact_delete_document", "documents" => json_encode(example_document_setting()) )), )); //Déclation des assets Plugin::addCss("/css/main.css"); Plugin::addJs("/js/main.js"); //Mapping hook / fonctions Plugin::addHook("install", "example_install"); Plugin::addHook("uninstall", "example_uninstall"); Plugin::addHook("section", "example_section"); Plugin::addHook("menu_main", "example_menu"); Plugin::addHook("page", "example_page"); Plugin::addHook("action", "example_action"); Plugin::addHook("menu_setting", "example_menu_setting"); Plugin::addHook("content_setting", "example_content_setting"); Plugin::addHook("menu_account", "example_menu_account"); Plugin::addHook("content_account", "example_content_account"); global $myFirm; if($myFirm->has_plugin('fr.sys1.export')){ require_once(__ROOT__.PLUGIN_PATH.'export'.SLASH.'ExportModel.class.php'); ExportModel::add('example','contact-sheet', 'Fiche contact', function($parameters){ global $myUser; require_once(__DIR__.SLASH.'Contact.class.php'); $contact = new Contact(); if(isset($parameters['description']) && $parameters['description']!=true && !empty($parameters['id'])) $contact = Contact::getById($parameters['id']); $data['contact'] = array('label'=>'Contact', 'type'=>'object','value' => array()); $data['contact']['value']['libellé'] = array('label' => 'Libellé du contact','value' => $contact->label); $data['contact']['value']['téléphone'] = array('label' => 'N° de téléphone du contact','value' => $contact->phone); $data['contact']['value']['anniversaire'] = array('label' => 'Date de naissance/d\'anniversaire du contact','value' => date('d/m/Y',$contact->birth)); $data['contact']['value']['identifiant'] = array('label' => 'Identifiant du contact','value'=>$contact->login); $data['contact']['value']['photo'] = array( 'label'=>'Image de profil du contact', 'type'=>'image', 'value' => file_get_contents($contact->get_image('path')) ); return $data; }); ExportModel::add('example','contact-list','Liste de contacts',function($parameters){ global $myUser; require_once(__DIR__.SLASH.'Contact.class.php'); $contacts = array(new Contact()); if(isset($parameters['description']) && $parameters['description']!=true) $contacts = Contact::loadAll(); $data['contacts'] = array('label'=>'Boucle sur les contacts', 'type'=>'list','value' => array()); $data['contacts']['nombre'] = array('label' => 'Nombre de contacts au total', 'value' => count($contacts)); foreach($contacts as $contact){ $data['contacts']['value'][] = array( 'libellé' => array('label' => 'Libellé du contact' , 'value' => $contact->label ), 'téléphone' => array('label' => 'N° de téléphone du contact' , 'value' => $contact->phone ), 'anniversaire' => array('label' => 'Date de naissance/d\'anniversaire du contact' , 'value' => $contact->birth ), 'identifiant' => array('label' => 'Identifiant du contact' , 'value' => $contact->login ), 'photo' => array( 'label' => 'Image de profil du contact', 'type'=>'image' , 'value' => file_get_contents($contact->get_image('path')) ), ); } return $data; }); } ?>