Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/0.85'
Browse files Browse the repository at this point in the history
  • Loading branch information
Walid committed Aug 9, 2015
2 parents dbcada1 + 9793065 commit 7189cf7
Show file tree
Hide file tree
Showing 41 changed files with 2,513 additions and 850 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
log_filter.settings.php
Empty file modified ajax/remove.txt
100755 → 100644
Empty file.
64 changes: 64 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Menu entry wrapper
*/
.genericobject_menu_wrapper {
display: block;
position: relative;
margin: 0;
padding: 0;
}

/*
* Icon positionning
*/
.genericobject_menu_icon {
height: 16px;
width: 16px;
vertical-align: middle;
display: inline-block;
}
.icon_preview {
height: 32px;
width: 32px;
}

.icon_preview > .genericobject_menu_icon {
display: block;
margin: 0 auto;
height: initial;
width: initial;
max-height: 32px;
max-width: 32px;
}

.genericobject_menu_text {
padding-left: 5px;
margin: 0;
display: inline-block;
}


/*
* Fields Form
*/

.genericobject_fields.add_new {
width: 80%;
}

.genericobject_fields.add_new td.label {
width: 20%;
}

.genericobject_fields.add_new td.dropdown {
width: 100%;
}

/*
* Type's Profile tab : specific alignment
*/

.genericobject_type_profiles tr > td {
width : 10%;
}

4 changes: 4 additions & 0 deletions docs/examples/car.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"name"; "manufacturer"; "model"; "color"; "license plate"
"Renault Scénic - 1234"; "Renault"; "Scénic"; "bleu"; "1234"
"Peugeot 308 - 2345"; "Peugeot"; "308"; "bleu"; "2345"
"Ferrari 458 Italia - 45677"; "Ferrari"; "458 Italia"; "rouge"; "45677"
12 changes: 7 additions & 5 deletions fields/field.constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,23 @@
$GO_FIELDS['types_id']['name'] = __("Type");
$GO_FIELDS['types_id']['linkfield'] = 'type';
$GO_FIELDS['types_id']['input_type'] = 'dropdown';
$GO_FIELDS['types_id']['dropdown_type'] = 'global'; //Means that
// The 'isolated' dropdown type will create a isolated table for each type that will be assigned
// with this field.
$GO_FIELDS['types_id']['dropdown_type'] = 'isolated';

$GO_FIELDS['models_id']['name'] = __("Model");
$GO_FIELDS['models_id']['input_type'] = 'dropdown';
$GO_FIELDS['models_id']['dropdown_type'] = 'global';
$GO_FIELDS['models_id']['dropdown_type'] = 'isolated';

$GO_FIELDS['categories_id']['name'] = __("Category");
$GO_FIELDS['categories_id']['input_type'] = 'dropdown';
$GO_FIELDS['categories_id']['dropdown_type'] = 'global';
$GO_FIELDS['categories_id']['dropdown_type'] = 'isolated';

$GO_FIELDS['entities_id']['name'] = __("Entity");
$GO_FIELDS['entities_id']['input_type'] = 'dropdown';
$GO_FIELDS['entities_id']['massiveaction'] = false;

$GO_FIELDS['template_name']['name'] = __("Template name");
$GO_FIELDS['template_name']['name'] = __("Template name");
$GO_FIELDS['template_name']['input_type'] = 'text';
$GO_FIELDS['template_name']['massiveaction'] = false;

Expand Down Expand Up @@ -138,4 +140,4 @@

$GO_FIELDS['groups_id_tech']['name'] = __("Group in charge of the hardware");
$GO_FIELDS['groups_id_tech']['input_type'] = 'dropdown';
$GO_FIELDS['groups_id_tech']['condition'] = '`is_assign`';
$GO_FIELDS['groups_id_tech']['condition'] = '`is_assign`';
41 changes: 41 additions & 0 deletions front/commondropdown.form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/*
This file is part of the genericobject plugin.
Genericobject plugin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Genericobject plugin 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Genericobject. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
@package genericobject
@author the genericobject plugin team
@copyright Copyright (c) 2010-2014 Generic Object plugin team
@license GPLv2+
http://www.gnu.org/licenses/gpl.txt
@link https://forge.indepnet.net/projects/genericobject
@link http://www.glpi-project.org/
@since 2014
---------------------------------------------------------------------- */

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

if ( isset($_REQUEST['itemtype']) ) {
$itemtype = $_REQUEST['itemtype'];
if (class_exists($itemtype)) {
$dropdown = new $itemtype();
include (GLPI_ROOT . "/front/dropdown.common.form.php");
} else {
Html::displayErrorAndDie(__('The requested dropdown does not exists', 'genericobject'));
}
} else {

Html::displayErrorAndDie(__('Not Found!'));
}
18 changes: 18 additions & 0 deletions front/commondropdown.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

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

if ( isset($_REQUEST['itemtype']) ) {
$itemtype = $_REQUEST['itemtype'];
if (class_exists($itemtype)) {
$dropdown = new $itemtype();
include (GLPI_ROOT . "/front/dropdown.common.php");
} else {
Html::displayErrorAndDie(__('The requested dropdown does not exists', 'genericobject'));
}
} else {

Html::displayErrorAndDie(__('Not Found!'));
}


41 changes: 41 additions & 0 deletions front/commontreedropdown.form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/*
This file is part of the genericobject plugin.
Genericobject plugin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Genericobject plugin 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Genericobject. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
@package genericobject
@author the genericobject plugin team
@copyright Copyright (c) 2010-2014 Generic Object plugin team
@license GPLv2+
http://www.gnu.org/licenses/gpl.txt
@link https://forge.indepnet.net/projects/genericobject
@link http://www.glpi-project.org/
@since 2014
---------------------------------------------------------------------- */

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

if ( isset($_REQUEST['itemtype']) ) {
$itemtype = $_REQUEST['itemtype'];
if (class_exists($itemtype)) {
$dropdown = new $itemtype();
include (GLPI_ROOT . "/front/dropdown.common.form.php");
} else {
Html::displayErrorAndDie(__('The requested dropdown does not exists', 'genericobject'));
}
} else {

Html::displayErrorAndDie(__('Not Found!'));
}
4 changes: 4 additions & 0 deletions front/commontreedropdown.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

include ("../../../inc/includes.php");
include ("./commondropdown.php");
10 changes: 5 additions & 5 deletions front/field.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@link http://www.glpi-project.org/
@since 2009
---------------------------------------------------------------------- */

include ("../../../inc/includes.php");
if (isset ($_POST["delete"])) {
$type = new PluginGenericobjectType();
Expand All @@ -33,7 +33,7 @@
PluginGenericobjectType::registerOneType($itemtype);

foreach ($_POST["fields"] as $field => $value) {
if ($type->can($_POST["id"], "w")
if ($type->can($_POST["id"], PURGE)
&& $value == 1
&& PluginGenericobjectField::checkNecessaryFieldsDelete($itemtype, $field)) {
PluginGenericobjectField::deleteField(getTableForItemType($itemtype), $field);
Expand All @@ -42,10 +42,9 @@
}
} elseif (isset ($_POST["add_field"])) {
$type = new PluginGenericobjectType();
if ($_POST["new_field"] && $type->can($_POST["id"], "w")) {
if ($_POST["new_field"] && $type->can($_POST["id"], UPDATE)) {
$itemtype = $type->fields['itemtype'];
PluginGenericobjectType::registerOneType($itemtype);

PluginGenericobjectField::addNewField(getTableForItemType($itemtype), $_POST["new_field"]);
Session::addMessageAfterRedirect(__("Field added successfully", "genericobject"));
}
Expand All @@ -54,4 +53,5 @@
PluginGenericobjectField::changeFieldOrder($_POST);
}

Html::back();
Html::back();

112 changes: 78 additions & 34 deletions front/object.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,86 @@
@since 2009
---------------------------------------------------------------------- */

if (!isset($_REQUEST['id'])) {
$id = -1;
} else {
$id = $_REQUEST['id'];
}

if (!isset($_GET["withtemplate"])) {
$_GET["withtemplate"] = "";
}
include ("../../../inc/includes.php");

$itemtype = null;

if (isset($_REQUEST['itemtype'])) {

$types = array_keys(PluginGenericobjectType::getTypes());

$requested_type = $_REQUEST['itemtype'];
$error = array();

if (!in_array($requested_type, $types) ){
$error[] = __('The requested type has not been defined yet!');
if (!PluginGenericobjectType::canCreate()) {
$error[] = __('Please ask your administrator to create this type of object');
};
} else if (!class_exists($requested_type)) {
$error[]= __('The generated files for the requested type of object are missing!');
$error[]= __('You might need to regenerate the files under '.GENERICOBJECT_DOC_DIR.'.');
}

if(count($error) > 0) {
Html::header(__('Type not found!'));
Html::displayErrorAndDie(implode('<br/>', $error));

if (isset ($_POST["add"])) {
$item->check($id, 'w');
$item->add($_POST);
Html::back();
} elseif (isset ($_POST["update"])) {
$item->check($id, 'w');
$item->update($_POST);
Html::back();
} elseif (isset ($_POST["restore"])) {
$item->check($id, 'w');
$item->restore($_POST);
Html::back();
} elseif (isset($_POST["purge"])) {
$item->check($id, 'w');
$item->delete($_POST, 1);
$item->redirectToList();
} elseif (isset($_POST["delete"])) {
$item->check($id, 'w');
$item->delete($_POST);
$item->redirectToList();
} else {
$itemtype = $requested_type;
}
}
$itemtype = get_class($item);
Html::header($itemtype::getTypeName(), $_SERVER['PHP_SELF'],
"plugins", "genericobject", $itemtype);

$item->title();
$item->showForm($id, array('withtemplate' => $_GET["withtemplate"]));
if (!is_null($itemtype)) {

if (!isset($_REQUEST['id'])) {
$id = -1;
} else {
$id = $_REQUEST['id'];
}

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

$item = new $itemtype();

if (isset ($_POST["add"])) {
$item->check($id, CREATE);
$newID = $item->add($_POST);

if ($_SESSION['glpibackcreated']) {
Html::redirect($itemtype::getFormURL()."&id=".$newID);
} else {
Html::back();
}
} elseif (isset ($_POST["update"])) {
$item->check($id, UPDATE);
$item->update($_POST);
Html::back();
} elseif (isset ($_POST["restore"])) {
$item->check($id, DELETE);
$item->restore($_POST);
Html::back();
} elseif (isset($_POST["purge"])) {
$item->check($id, PURGE);
$item->delete($_POST, 1);
$item->redirectToList();
} elseif (isset($_POST["delete"])) {
$item->check($id, DELETE);
$item->delete($_POST);
$item->redirectToList();
}
//$itemtype = get_class($item);
Html::header($itemtype::getTypeName(), $_SERVER['PHP_SELF'],
"assets", $itemtype);

$item->display($_GET, array( 'withtemplate' => $_GET["withtemplate"]));

Html::footer();
} else {
Html::header(__('Access Denied!'));
Html::DisplayErrorAndDie(__("You can't access to this page directly!"));
}

Html::footer();
Loading

0 comments on commit 7189cf7

Please sign in to comment.