Skip to content

Commit

Permalink
First commit for timeslotentry.
Browse files Browse the repository at this point in the history
Miss update code for the moment
  • Loading branch information
David Durieux committed Mar 13, 2014
1 parent de1157e commit c4c0efb
Show file tree
Hide file tree
Showing 14 changed files with 1,008 additions and 2 deletions.
90 changes: 90 additions & 0 deletions front/timeslot.form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

/*
------------------------------------------------------------------------
FusionInventory
Copyright (C) 2010-2013 by the FusionInventory Development Team.
http://www.fusioninventory.org/ http://forge.fusioninventory.org/
------------------------------------------------------------------------
LICENSE
This file is part of FusionInventory project.
FusionInventory is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FusionInventory is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with FusionInventory. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------
@package FusionInventory
@author David Durieux
@co-author
@copyright Copyright (c) 2010-2013 FusionInventory team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link http://www.fusioninventory.org/
@link http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
@since 2014
------------------------------------------------------------------------
*/

include ("../../../inc/includes.php");

Session::checkRight('plugin_fusioninventory_task', READ);

if (!isset($_GET["id"])) {
$_GET["id"] = "";
}



$pfTimeslot = new PluginFusioninventoryTimeslot();
//Add a new timeslot
if (isset($_POST["add"])) {
$pfTimeslot->check(-1, CREATE, $_POST);
if ($newID = $pfTimeslot->add($_POST)) {
if ($_SESSION['glpibackcreated']) {
Html::redirect($pfTimeslot->getFormURL()."?id=".$newID);
}
}
Html::back();

// delete a timeslot
} else if (isset($_POST["delete"])) {
$pfTimeslot->check($_POST['id'], DELETE);
$ok = $pfTimeslot->delete($_POST);
$pfTimeslot->redirectToList();

} else if (isset($_POST["purge"])) {
$pfTimeslot->check($_POST['id'], PURGE);
$pfTimeslot->delete($_POST,1);
$pfTimeslot->redirectToList();

//update a timeslot
} else if (isset($_POST["update"])) {
$pfTimeslot->check($_POST['id'], UPDATE);
$pfTimeslot->update($_POST);
Html::back();

} else {//print timeslot information
Html::header(PluginFusioninventoryTimeslot::GetTypeName(2),
$_SERVER['PHP_SELF'],
"plugins",
"pluginfusioninventorymenu",
"timeslot");
$pfTimeslot->display(array('id' => $_GET["id"]));
Html::footer();
}
?>
53 changes: 53 additions & 0 deletions front/timeslot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/*
------------------------------------------------------------------------
FusionInventory
Copyright (C) 2010-2013 by the FusionInventory Development Team.
http://www.fusioninventory.org/ http://forge.fusioninventory.org/
------------------------------------------------------------------------
LICENSE
This file is part of FusionInventory project.
FusionInventory is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FusionInventory is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with FusionInventory. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------
@package FusionInventory
@author David Durieux
@co-author
@copyright Copyright (c) 2010-2013 FusionInventory team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link http://www.fusioninventory.org/
@link http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
@since 2014
------------------------------------------------------------------------
*/

include ("../../../inc/includes.php");

Session::checkRight('plugin_fusioninventory_task', READ);

Html::header(__('FusionInventory', 'fusioninventory'), $_SERVER["PHP_SELF"],
"plugins", "pluginfusioninventorymenu", "timeslot");

Search::show('PluginFusioninventoryTimeslot');

Html::footer();
?>
56 changes: 56 additions & 0 deletions front/timeslotentry.form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/*
------------------------------------------------------------------------
FusionInventory
Copyright (C) 2010-2013 by the FusionInventory Development Team.
http://www.fusioninventory.org/ http://forge.fusioninventory.org/
------------------------------------------------------------------------
LICENSE
This file is part of FusionInventory project.
FusionInventory is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FusionInventory is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with FusionInventory. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------
@package FusionInventory
@author David Durieux
@co-author
@copyright Copyright (c) 2010-2013 FusionInventory team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link http://www.fusioninventory.org/
@link http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
@since 2014
------------------------------------------------------------------------
*/

include ("../../../inc/includes.php");

Session::checkRight('plugin_fusioninventory_task', READ);

if (!isset($_GET["id"])) {
$_GET["id"] = "";
}

$pfTimeslotEntry = new PluginFusioninventoryTimeslotEntry();

$pfTimeslotEntry->addEntry($_POST);

Html::back();
?>
6 changes: 6 additions & 0 deletions inc/menu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static function getAdditionalMenuOptions() {
$elements = array(
'iprange' => 'PluginFusioninventoryIPRange',
'task' => 'PluginFusioninventoryTask',
'timeslot' => 'PluginFusioninventoryTimeslot',
'unknowndevice' => 'PluginFusioninventoryUnknownDevice',
'inventoryruleimport' => 'PluginFusioninventoryInventoryRuleImport',
'inventoryruleentity' => 'PluginFusioninventoryInventoryRuleEntity',
Expand Down Expand Up @@ -227,6 +228,11 @@ static function displayMenu($type = "big") {
$a_menu[11]['pic'] = $CFG_GLPI['root_doc']."/plugins/fusioninventory/pics/menu_task.png";
$a_menu[11]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryCollect');
}
if(Session::haveRight('plugin_fusioninventory_task', READ)) {
$a_menu[12]['name'] = __('Time slot', 'fusioninventory');
$a_menu[12]['pic'] = "";
$a_menu[12]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryTimeslot');
}

if (!empty($a_menu)) {
$width_status = PluginFusioninventoryMenu::htmlMenu(__('Tasks', 'fusioninventory'),
Expand Down
2 changes: 1 addition & 1 deletion inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function getRightsGeneral() {
'label' => __('Configuration', 'fusioninventory'),
'field' => 'plugin_fusioninventory_configuration'),
array('itemtype' => 'PluginFusioninventoryTask',
'label' => _n('Task', 'Tasks', 2),
'label' => _n('Task', 'Tasks', 2, 'fusioninventory'),
'field' => 'plugin_fusioninventory_task'),
array('rights' => CommonDBTM::getRights(),
'label' => __('Wake On LAN', 'fusioninventory'),
Expand Down
148 changes: 148 additions & 0 deletions inc/timeslot.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?php

/*
------------------------------------------------------------------------
FusionInventory
Copyright (C) 2010-2014 by the FusionInventory Development Team.
http://www.fusioninventory.org/ http://forge.fusioninventory.org/
------------------------------------------------------------------------
LICENSE
This file is part of FusionInventory project.
FusionInventory is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FusionInventory is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with FusionInventory. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------
@package FusionInventory
@author David Durieux
@co-author
@copyright Copyright (c) 2010-2013 FusionInventory team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link http://www.fusioninventory.org/
@link http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
@since 2014
------------------------------------------------------------------------
*/

if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access directly to this file");
}

class PluginFusioninventoryTimeslot extends CommonDBTM {

public $dohistory = TRUE;

static $rightname = 'plugin_fusioninventory_task';


/**
* Get name of this type
*
* @return text name of this type by language of the user connected
*
**/
static function getTypeName($nb=0) {
return __('Time slot', 'fusioninventory');
}



function getSearchOptions() {

$tab = array();

$tab['common'] = __('Time slot', 'fusioninventory');

$tab[1]['table'] = $this->getTable();
$tab[1]['field'] = 'name';
$tab[1]['linkfield'] = 'name';
$tab[1]['name'] = __('Name');
$tab[1]['datatype'] = 'itemlink';

$tab[2]['table'] = 'glpi_entities';
$tab[2]['field'] = 'completename';
$tab[2]['name'] = __('Entity');

$tab[3]['table'] = $this->getTable();
$tab[3]['field'] = 'is_recursive';
$tab[3]['linkfield'] = 'is_recursive';
$tab[3]['name'] = __('Child entities');
$tab[3]['datatype'] = 'bool';

$tab[4]['table'] = $this->getTable();
$tab[4]['field'] = 'name';
$tab[4]['linkfield'] = '';
$tab[4]['name'] = __('Name');
$tab[4]['datatype'] = 'string';

return $tab;
}



function defineTabs($options=array()){

$ong = array();
$this->addDefaultFormTab($ong);

return $ong;
}



/**
* Display form for agent configuration
*
* @param $computers_id integer ID of the agent
* @param $options array
*
* @return bool TRUE if form is ok
*
**/
function showForm($ID, $options=array()) {

$this->initForm($ID, $options);
$this->showFormHeader($options);

echo "<tr class='tab_bg_1'>";
//TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
echo "<td>".sprintf(__('%1$s%2$s'),__('Name'),
(isset($options['withtemplate']) && $options['withtemplate']?"*":"")).
"</td>";
echo "<td>";
$objectName = autoName($this->fields["name"], "name",
(isset($options['withtemplate']) && ( $options['withtemplate']== 2)),
$this->getType(), $this->fields["entities_id"]);
Html::autocompletionTextField($this, 'name', array('value' => $objectName));
echo "</td>";
echo "<td>".__('Comments')."</td>";
echo "<td class='middle'>";
echo "<textarea cols='45' rows='4' name='comment' >".$this->fields["comment"];
echo "</textarea></td></tr>\n";

$this->showFormButtons($options);

$pf = new PluginFusioninventoryTimeslotEntry();
$pf->formEntry($ID);

return true;
}
}

?>
Loading

0 comments on commit c4c0efb

Please sign in to comment.