--- /dev/null
+<?php
+include ("../../../inc/includes.php");
+
+Session::checkRight("computer", "w");
+
+$computer = new PluginAufComputer();
+
+if (isset($_POST['update_computer'])) {
+ $computer->update($_POST);
+ Html::back();
+}
+?>
--- /dev/null
+<?php
+include ("../../../inc/includes.php");
+
+Session::checkRight("profile", "r");
+
+$prof = new PluginAufProfile();
+
+if (isset($_POST['update_user_profile'])) {
+ $prof->update($_POST);
+ Html::back();
+}
+?>
Copyright (C) 2014 AUF -- www.auf.org
*/
+function plugin_auf_getAddSearchOptions($itemtype) {
+ $sopt = array();
+ if ($itemtype == 'Computer') {
+ $i = 5250;
+ $sopt[$i]['table'] = 'glpi_plugin_auf_categories';
+ $sopt[$i]['field'] = 'name';
+ $sopt[$i]['linkfield'] = 'auf_categories_id';
+ $sopt[$i]['name'] = 'AUF - Catégorie';
+ $sopt[$i]['datatype'] = 'dropdown';
+ $sopt[$i]['massiveaction'] = FALSE;
+ $sopt[$i]['joinparams'] = array('beforejoin'
+ => array('table' => 'glpi_plugin_auf_computers',
+ 'joinparams' => array('jointype' => 'child',
+ 'linkfield' => 'id') ) );
+ $i++;
+ $sopt[$i]['table'] = 'glpi_plugin_auf_utilisations';
+ $sopt[$i]['field'] = 'name';
+ $sopt[$i]['linkfield'] = 'auf_utilisations_id';
+ $sopt[$i]['name'] = 'AUF - Utilisation';
+ $sopt[$i]['datatype'] = 'dropdown';
+ $sopt[$i]['massiveaction'] = FALSE;
+ $sopt[$i]['joinparams'] = array('beforejoin'
+ => array('table' => 'glpi_plugin_auf_computers',
+ 'joinparams' => array('jointype' => 'child',
+ 'linkfield' => 'id') ) );
+ $i++;
+ $sopt[$i]['table'] = 'glpi_plugin_auf_computers';
+ $sopt[$i]['field'] = 'annee_acquisition';
+ $sopt[$i]['linkfield'] = 'id';
+ $sopt[$i]['name'] = 'AUF - Année d\'acquisition';
+ $sopt[$i]['datatype'] = 'number';
+ $sopt[$i]['massiveaction'] = FALSE;
+ $i++;
+ $sopt[$i]['table'] = 'glpi_plugin_auf_computers';
+ $sopt[$i]['field'] = 'est_virtuel';
+ $sopt[$i]['linkfield'] = 'id';
+ $sopt[$i]['name'] = 'AUF - Virtuel';
+ $sopt[$i]['datatype'] = 'bool';
+ // $sopt[$i]['joinparams'] = array('jointype' => 'child');
+ $sopt[$i]['massiveaction'] = FALSE;
+ }
+ return $sopt;
+}
+
function plugin_auf_install() {
+ global $DB;
+
+ $migration = new Migration(100);
+ // Création de la table uniquement lors de la première installation
+ if (!TableExists("glpi_plugin_auf_profiles")) {
+ // requête de création de la table
+ $query = "CREATE TABLE `glpi_plugin_auf_profiles` (
+ `id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',
+ `right` char(1) collate utf8_unicode_ci default NULL,
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
+ $DB->queryOrDie($query, $DB->error());
+ $migration->migrationOneTable("glpi_plugin_auf_profiles");
+ // creation du premier accès nécessaire lors de l'installation du plugin
+ include_once(GLPI_ROOT."/plugins/auf/inc/profile.class.php");
+ PluginAufProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
+ }
+
+ if (!TableExists("glpi_plugin_auf_computers")) {
+ // requête de création de la table
+ $query = "CREATE TABLE `glpi_plugin_auf_computers` (
+ `id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_computers (id)',
+ `auf_categories_id` int(11) NOT NULL DEFAULT '0',
+ `auf_utilisations_id` int(11) NOT NULL DEFAULT '0',
+ `annee_acquisition` int(11) NOT NULL DEFAULT '0',
+ `est_virtuel` tinyint(1) NOT NULL DEFAULT '0',
+ `affectation` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
+ $DB->queryOrDie($query, $DB->error());
+ }
+
+ if (!TableExists("glpi_plugin_auf_categories")) {
+ // requête de création de la table
+ $query = "CREATE TABLE `glpi_plugin_auf_categories` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `comment` text DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `name` (`name`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
+ $DB->queryOrDie($query, $DB->error());
+ $query = "INSERT INTO `glpi_plugin_auf_categories` VALUES
+ (1, 'Infrastructure', ''),
+ (2, 'Poste interne', ''),
+ (3, 'Poste public', '')";
+ $DB->queryOrDie($query, $DB->error());
+ }
+
+ if (!TableExists("glpi_plugin_auf_utilisations")) {
+ // requête de création de la table
+ $query = "CREATE TABLE `glpi_plugin_auf_utilisations` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `comment` text DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `name` (`name`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
+ $DB->queryOrDie($query, $DB->error());
+ $query = "INSERT INTO `glpi_plugin_auf_utilisations` VALUES
+ (1, 'Production', ''),
+ (2, 'Test', ''),
+ (3, 'Réserve', 'stock, mission, formation, …')";
+ $DB->queryOrDie($query, $DB->error());
+ }
+
+ $migration->executeMigration();
return TRUE;
}
function plugin_auf_uninstall() {
+ global $DB;
+
+ $tables = array(); // "glpi_plugin_auf_profiles", // "glpi_plugin_auf_computers",
+ // "glpi_plugin_auf_categories", "glpi_plugin_auf_utilisations");
+ foreach($tables as $table) {
+ $DB->query("DROP TABLE IF EXISTS `$table`;");
+ }
+
return TRUE;
}
--- /dev/null
+<?php
+/*
+ AUF plugin for GLPI
+ Copyright (C) 2014 AUF -- www.auf.org
+ */
+if (!defined('GLPI_ROOT')) {
+ die("Sorry. You can't access directly to this file");
+}
+
+class PluginAufComputer extends CommonDBTM {
+
+ static function canCreate() {
+ if (isset($_SESSION["glpi_plugin_auf_profile"])) {
+ return ($_SESSION["glpi_plugin_auf_profile"]['auf'] == 'w');
+ }
+ return false;
+ }
+
+ static function canView() {
+ if (isset($_SESSION["glpi_plugin_auf_profile"])) {
+ return ($_SESSION["glpi_plugin_auf_profile"]['auf'] == 'w'
+ || $_SESSION["glpi_plugin_auf_profile"]['auf'] == 'r');
+ }
+ return false;
+ }
+
+ function createInfos($ID) {
+ $this->add(array('id' => $ID));
+ }
+
+ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
+ if ($item->getType() == 'Computer') {
+ return "Infos AUF";
+ }
+ return '';
+ }
+
+ static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
+ if ($item->getType() == 'Computer') {
+ $ID = $item->getID();
+ $computer = new self();
+ // si la machine n'existe pas dans la base, je l'ajoute
+ if (!$computer->GetfromDB($ID)) {
+ $computer->createInfos($ID);
+ }
+ $computer->showForm($ID);
+ }
+ return true;
+ }
+
+ function showForm($id, $options=array()) {
+ $target = $this->getFormURL();
+ if (isset($options['target'])) {
+ $target = $options['target'];
+ }
+
+ if (!Session::haveRight("computer", "r")) {
+ return false;
+ }
+
+ $canedit = Session::haveRight("computer", "w");
+ $computer = new Computer();
+ if ($id){
+ $this->getFromDB($id);
+ $computer->getFromDB($id);
+ }
+
+ echo "<form action='".$target."' method='post'>";
+ echo "<table class='tab_cadre_fixe'>";
+ echo "<tr><th colspan='4'>Infos AUF</th></tr>";
+
+ echo "<tr class='tab_bg_1'>";
+ echo "<td>Catégorie</td><td>";
+ // $elements = getDataFromTable("glpi_plugin_auf_categories");
+ $elements = array("0"=>"-----", "1"=>"Infrastructure", "2"=>"Poste interne", "3"=>"Poste public");
+ Dropdown::showFromArray("auf_categories_id", $elements,
+ array("value" => $this->fields["auf_categories_id"]));
+ echo "</td>";
+ echo "<td>Utilisation</td><td>";
+ // $elements = getDataFromTable("glpi_plugin_auf_utilisations");
+ $elements = array("0"=>"-----", "1"=>"Production", "2"=>"Test", "3"=>"Réserve (stock, mission, formation, …)");
+ Dropdown::showFromArray("auf_utilisations_id", $elements,
+ array("value" => $this->fields["auf_utilisations_id"]));
+ echo "</td>";
+ echo "</tr>";
+
+ echo "<tr class='tab_bg_1'>";
+ echo "<td>Machine virtuelle</td><td>";
+ Dropdown::showYesNo('est_virtuel', $this->fields["est_virtuel"]);
+ echo "</td>";
+ echo "<td>Année d'acquisition</td><td>";
+ echo "<input size='4' name='annee_acquisition' value='".$this->fields["annee_acquisition"]."' />";
+ echo "</td>";
+ echo "</tr>";
+
+ if ($canedit) {
+ echo "<tr class='tab_bg_1'>";
+ echo "<td class='center' colspan='4'>";
+ echo "<input type='hidden' name='id' value=$id>";
+ echo "<input type='submit' name='update_computer' value='Mettre à jour' class='submit'>";
+ echo "</td></tr>";
+ }
+
+ echo "</table>";
+ Html::closeForm();
+ }
+
+}
+
+?>
--- /dev/null
+<?php
+/*
+ AUF plugin for GLPI
+ Copyright (C) 2014 AUF -- www.auf.org
+ */
+if (!defined('GLPI_ROOT')) {
+ die("Sorry. You can't access directly to this file");
+}
+
+class PluginAufProfile extends CommonDBTM {
+
+ static function canCreate() {
+ if (isset($_SESSION["glpi_plugin_auf_profile"])) {
+ return ($_SESSION["glpi_plugin_auf_profile"]['auf'] == 'w');
+ }
+ return false;
+ }
+
+ static function canView() {
+ if (isset($_SESSION["glpi_plugin_auf_profile"])) {
+ return ($_SESSION["glpi_plugin_auf_profile"]['auf'] == 'w'
+ || $_SESSION["glpi_plugin_auf_profile"]['auf'] == 'r');
+ }
+ return false;
+ }
+
+ static function createAdminAccess($ID) {
+ $myProf = new self();
+ // si le profile n'existent pas déjà dans la table profile de mon plugin
+ if (!$myProf->getFromDB($ID)) {
+ // ajouter un champ dans la table comprenant l'ID du profil de la
+ // personne connectée et le droit d'écriture
+ $myProf->add(array('id' => $ID, 'right' => 'w'));
+ }
+ }
+
+ function createAccess($ID) {
+ $this->add(array('id' => $ID));
+ }
+
+ static function changeProfile() {
+ $prof = new self();
+ if ($prof->getFromDB($_SESSION['glpiactiveprofile']['id'])) {
+ $_SESSION["glpi_plugin_auf_profile"] = $prof->fields;
+ } else {
+ unset($_SESSION["glpi_plugin_auf_profile"]);
+ }
+ }
+
+ function showForm($id, $options=array()) {
+ $target = $this->getFormURL();
+ if (isset($options['target'])) {
+ $target = $options['target'];
+ }
+
+ if (!Session::haveRight("profile", "r")) {
+ return false;
+ }
+
+ $canedit = Session::haveRight("profile", "w");
+ $prof = new Profile();
+ if ($id){
+ $this->getFromDB($id);
+ $prof->getFromDB($id);
+ }
+
+ echo "<form action='".$target."' method='post'>";
+ echo "<table class='tab_cadre_fixe'>";
+ echo "<tr><th colspan='2' class='center b'>".sprintf(__('%1$s %2$s'),
+ ('Gestion des droits -'), Dropdown::getDropdownName("glpi_profiles",
+ $this->fields["id"]));
+ echo "</th></tr>";
+
+ echo "<tr class='tab_bg_2'>";
+ echo "<td>Infos AUF</td><td>";
+ Profile::dropdownNoneReadWrite("right", $this->fields["right"], 1, 1, 1);
+ echo "</td></tr>";
+
+ if ($canedit) {
+ echo "<tr class='tab_bg_1'>";
+ echo "<td class='center' colspan='2'>";
+ echo "<input type='hidden' name='id' value=$id>";
+ echo "<input type='submit' name='update_user_profile' value='Mettre à jour' class='submit'>";
+ echo "</td></tr>";
+ }
+ echo "</table>";
+ Html::closeForm();
+ }
+
+ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
+ if ($item->getType() == 'Profile') {
+ return "Infos AUF";
+ }
+ return '';
+ }
+
+ static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
+ if ($item->getType() == 'Profile') {
+ $ID = $item->getID();
+ $prof = new self();
+ // si le profil n'existe pas dans la base, je l'ajoute
+ if (!$prof->GetfromDB($ID)) {
+ $prof->createAccess($ID);
+ }
+ $prof->showForm($ID);
+ }
+ return true;
+ }
+
+}
+
+?>
-<?php echo "À venir…"; ?>
+<?php
+//Options for GLPI 0.71 and newer : need slave db to access the report
+$USEDBREPLICATE=1;
+$DBCONNECTION_REQUIRED=0;
+
+include ("../../inc/includes.php");
+
+Session::checkRight("reports", "r");
+Session::checkRight("computer", "r");
+
+#Html::header(Report::getTypeName(2), $_SERVER['PHP_SELF'], "utils", "report");
+Html::header("Suivi de la migration vers Ubuntu 12.04.", $_SERVER['PHP_SELF'], "utils", "report");
+Report::title();
+
+echo "\n<p class='big b' style='text-align: center'>Suivi de la migration vers Ubuntu 12.04</p><br><br>";
+
+echo "<p style=\"font-size: 120%; text-align: center;\">Les données du rapport de migration Ubuntu seront disponibles à partir du lundi 21 avril 2014.<br />En attendant vous pouvez déjà consulter les rapports sur le <a href=\"https://glpi.auf.org/glpi/plugins/auf/report.computers.php\">parc machine</a> et sur les <a href=\"https://glpi.auf.org/glpi/plugins/auf/report.operatingsystems.php\">systèmes d'exploitation</a>.</p>";
+
+Html::footer();
+?>
$computer = new Computer();
-$state_sql = "";
-if (($state != "") AND ($state != "0")) {
- $state_sql = " AND `states_id` = '".$state."' ";
-}
-
$itemtype = 'Computer';
$table_item = getTableForItemType($itemtype);
return $svg;
}
-echo "\n<span class='big b'>Ordinateurs par implantation</span><br><br>";
+//echo "\n<span class='big b'>Ordinateurs par implantation</span><br><br>";
echo "<table class='tab_cadrehov'>";
echo "<tr class='tab_bg_1'><th rowspan='2' colspan='2'>Implantation</th>";
echo "<th colspan='2'>".svg_circle('red')." Serveurs</th>";
echo "<tr class='tab_bg_1'><th>Total</th><th>Production</th>";
echo "<th>Total</th><th>Attribué</th><th>Total</th><th>Attribué</th></tr>\n";
+$grand_serveurs_total = 0; $grand_serveurs_prod = 0;
+$grand_internes_total = 0; $grand_internes_prod = 0;
+$grand_publics_total = 0; $grand_publics_prod = 0;
+$grand_total = 0; $grand_virtuels_total = 0;
+$grand_autres_total = 0;
# récupération de la liste des régions
-$grand_total = 0;
$query = "SELECT id FROM glpi_entities WHERE (id=0 OR entities_id=0)";
$query .= " ".getEntitiesRestrictRequest("AND", "glpi_entities")." ORDER BY name";
$region_result = $DB->query($query);
$computer = new Computer();
-$state_sql = "";
-if (($state != "") AND ($state != "0")) {
- $state_sql = " AND `states_id` = '".$state."' ";
-}
-
$itemtype = 'Computer';
$table_item = getTableForItemType($itemtype);
-echo "<span class='big b'>Systèmes d'exploitation par implantation</span><br><br>";
+//echo "<span class='big b'>Systèmes d'exploitation par implantation</span><br><br>";
echo "<table class='tab_cadrehov'>";
echo "<tr class='tab_bg_1'><th>Implantation</th><th>Système d'exploitation</th><th>Quantité</th></tr>";
$green_grand_total = 0;
$PLUGIN_HOOKS['csrf_compliant']['auf'] = TRUE;
$Plugin = new Plugin();
+ $moduleId = 0;
if ($Plugin->isActivated('auf')) { // check if plugin is active
- if (Session::getLoginUserID()) {
- $PLUGIN_HOOKS['add_css']['auf'] = "auf.css";
- }
+
+ Plugin::registerClass('PluginAufProfile',
+ array('addtabon'=>array('Profile')));
+ Plugin::registerClass('PluginAufComputer',
+ array('addtabon'=>array('Computer')));
+
+
+ $PLUGIN_HOOKS['change_profile']['auf'] = array('PluginAufProfile', 'changeProfile');
+
+ $PLUGIN_HOOKS['add_css']['auf'] = "auf.css";
+
+ // if (Session::getLoginUserID()) {
+ // }
+
if (isset($_SESSION["glpiname"])) {
$report_list = array();
if (Session::haveRight("computer", "r")) {
// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_auf_check_prerequisites() {
if (version_compare(GLPI_VERSION,'0.84','lt') || version_compare(GLPI_VERSION,'0.85','ge')) {
- _e('This plugin requires GLPI >= 0.84', 'auf');
+ echo 'This plugin requires GLPI >= 0.84 and GLPI < 0.85';
return FALSE;
}
return TRUE;
}
-// Uninstall process for plugin : need to return true if succeeded : may display messages or add to message after redirect
+// Uninstall process for plugin : need to return true if succeeded ;
+// may display messages or add to message after redirect
function plugin_auf_check_config() {
return TRUE;
}