diff -rud customfields-1.4.0-psv/front/config.form.php plugins/customfields/front/config.form.php
--- customfields-1.4.0-psv/front/config.form.php 2013-06-09 18:53:14.042480022 +0200
+++ plugins/customfields/front/config.form.php 2013-06-01 18:19:33.377059065 +0200
@@ -33,10 +33,12 @@
// Project Website: http://www.opensourcegov.net
// Purpose of file: Main configuration page
// ----------------------------------------------------------------------
+
if (!defined('GLPI_ROOT')) {
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT . '/inc/includes.php');
}
+
$plugin = new Plugin();
// Check if plugin is installed and enabled
if ($plugin->isActivated("customfields")) {
@@ -91,7 +93,7 @@
}
if (strstr($_SERVER['PHP_SELF'],"popup")) {
- popFooter();
+ Html::popFooter();
} else {
Html::footer();
}
diff -rud customfields-1.4.0-psv/front/dropdown.php plugins/customfields/front/dropdown.php
--- customfields-1.4.0-psv/front/dropdown.php 2013-06-09 18:53:51.744436792 +0200
+++ plugins/customfields/front/dropdown.php 2013-06-01 18:25:19.289059652 +0200
@@ -37,7 +37,6 @@
// ----------------------------------------------------------------------
define('GLPI_ROOT', '../../..');
-define('DROPDOWN_EMPTY_VALUE', '');
include (GLPI_ROOT.'/inc/includes.php');
Session::checkRight('config', 'r');
@@ -79,7 +78,7 @@
: $LANG['plugin_customfields']['Custom_Dropdown'];
if ($_POST['system_name']=='') {// use label for system name if no system name was provided
- $system_name = plugin_customfields_make_system_name($label);
+ $system_name = plugin_customfields_make_system_name($name);
} else {
$system_name = plugin_customfields_make_system_name($_POST['system_name']);
}
@@ -223,7 +222,7 @@
$item = new PluginCustomfieldsDropdown();
$table = $item->getTable();
$rand = mt_rand();
- $name = DROPDOWN_EMPTY_VALUE;
+ $name = Dropdown::EMPTY_VALUE;
$comment = "";
$tmpname = Dropdown::getDropdownName($table,'',1);
if ($tmpname["name"]!=" ") {
diff -rud customfields-1.4.0-psv/front/manage.php plugins/customfields/front/manage.php
--- customfields-1.4.0-psv/front/manage.php 2013-06-09 18:53:51.744436792 +0200
+++ plugins/customfields/front/manage.php 2013-06-08 12:13:34.490807335 +0200
@@ -69,13 +69,14 @@
}
Session::addMessageAfterRedirect($LANG['plugin_customfields']['cf_enabled']);
}
- Html::redirect($_SERVER['HTTP_REFERER']); // So clicking refresh on browser will not send post data again
+
+ Html::back();
}
if (isset($_POST['disable'])) {// Disable custom fields for this device type
plugin_customfields_disable_device($itemtype);
- Html::redirect($_SERVER['HTTP_REFERER']); // So clicking refresh on browser will send post data again
-
+
+ Html::back();
} else if(isset($_POST['delete'])) {// Delete a field
foreach($_POST['delete'] as $id => $garbage) {
$sql = "SELECT *
@@ -307,7 +308,7 @@
$DB->query($sql);
}
}
- glpi_header($_SERVER['HTTP_REFERER']);
+ Html::back();
}
diff -rud customfields-1.4.0-psv/front/profile.form.php plugins/customfields/front/profile.form.php
--- customfields-1.4.0-psv/front/profile.form.php 2013-06-09 18:53:14.054480648 +0200
+++ plugins/customfields/front/profile.form.php 2013-05-30 22:05:47.964129057 +0200
@@ -36,7 +36,7 @@
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php");
-checkRight("profile", "r");
+Session::checkRight("profile", "r");
$prof = new pluginCustomfieldsProfile();
//Save profile
diff -rud customfields-1.4.0-psv/hook.php plugins/customfields/hook.php
--- customfields-1.4.0-psv/hook.php 2013-06-09 18:53:14.008478259 +0200
+++ plugins/customfields/hook.php 2013-06-09 12:15:13.968302609 +0200
@@ -133,10 +133,42 @@
$sopt[$i]['linkfield'] = '';
$sopt[$i]['name'] = $LANG['plugin_customfields']['title']." - ".$search['label'];
$sopt[$i]['massiveaction'] = false;
-
+ //PS Add
+ $sopt[$i]['injectable'] = true;
+ if ($search['data_type'] == "general") {
+ $opt[$i]['checktype'] = "text";
+ $opt[$i]['displaytype'] = "text";
+ }
+ if ($search['data_type'] == "number") {
+ $opt[$i]['checktype'] = "integer";
+ $opt[$i]['displaytype'] = "integer";
+ }
+ if ($search['data_type'] == "yesno") {
+ $opt[$i]['checktype'] = "bool";
+ $opt[$i]['displaytype'] = "bool";
+ }
+ if ($search['data_type'] == "date") {
+ $opt[$i]['checktype'] = "date";
+ $opt[$i]['displaytype'] = "date";
+ }
+ if ($search['data_type'] == "money") {
+ $opt[$i]['checktype'] = "float";
+ $opt[$i]['displaytype'] = "decimal";
+ }
+ if ($search['data_type'] == "note") { //this is a notepad, equivalency ?
+ $opt[$i]['checktype'] = "multiline_text";
+ $opt[$i]['displaytype'] = "multiline_text";
+ }
+ if ($search['data_type'] == "text") {
+ $opt[$i]['checktype'] = "multiline_text";
+ $opt[$i]['displaytype'] = "multiline_text";
+ }
+ if ($search['data_type'] == "sectionhead") {
+ $opt[$i]['injectable'] = false;
+ }
//no option for disable displaypreferences, check page executed
- if (strpos($_SERVER['SCRIPT_NAME'], "displaypreference.tabs.php") === false) {
+ if (strpos($_SERVER['SCRIPT_NAME'], "common.tabs.php") === false) {
$sopt[$i+2000]['table'] = plugin_customfields_table($itemtype);
$sopt[$i+2000]['field'] = $search['system_name'];
$sopt[$i+2000]['linkfield'] = $search['system_name'];
@@ -366,17 +398,17 @@
break;
case 'date' :
- showDateFormItem($field, '', true, true);
+ Html::showDateFormItem($field, '', true, true);
break;
case 'money' :
echo '';
+ Html::formatNumber(0,true).'" name="'.$field.'"/>';
break;
default :
$item = new $type;
- autocompletionTextField($item, $field);
+ Html::autocompletionTextField($item, $field);
break;
}
return true;
@@ -501,12 +533,12 @@
break;
case 'date' :
- echo convDate($data[$NAME.$num]);
- return convDate($data[$NAME.$num]);
+ Html::convDate($data[$NAME.$num]);
+ return Html::convDate($data[$NAME.$num]);
break;
case 'money' :
- return formatNumber($data[$NAME.$num]);
+ return Html::formatNumber($data[$NAME.$num]);
break;
default :
@@ -530,4 +562,9 @@
return pluginCustomfieldsUninstall();
}
+function plugin_datainjection_populate_customfields() {
+ global $INJECTABLE_TYPES;
+
+ $INJECTABLE_TYPES['PluginCustomFieldsCustomFieldInjection'] = 'customfields';
+}
?>
Only in plugins/customfields/inc: customfieldsinjection.class.php
diff -rud customfields-1.4.0-psv/inc/function.php plugins/customfields/inc/function.php
--- customfields-1.4.0-psv/inc/function.php 2013-06-09 18:53:51.745436845 +0200
+++ plugins/customfields/inc/function.php 2013-06-08 18:17:28.712798364 +0200
@@ -242,10 +242,12 @@
FROM `$table`
WHERE `id`= '$ID'";
$result = $DB->query($query);
- $number = $DB->numrows($result);
- if ($number==1) {
- $data = $DB->fetch_array($result);
- $entity = $data['entities_id'];
+ if ( $result != FALSE ) {
+ $number = $DB->numrows($result);
+ if ($number==1) {
+ $data = $DB->fetch_array($result);
+ $entity = $data['entities_id'];
+ }
}
}
@@ -297,6 +299,7 @@
if ($fields['restricted']) {
$checkfield = $fields['itemtype'].'_'.$fields['system_name'];
$prof = new pluginCustomfieldsProfile();
+ if (!$prof->fieldHaveRight($checkfield, 'r')) { continue; }
if (!$prof->fieldHaveRight($checkfield, 'w')) {
$readonly = true;
}
@@ -394,16 +397,16 @@
case 'money' :
if (!$readonly) {
- echo '';
} else {
- plugin_customfields_showValue(formatNumber($value, true));
+ plugin_customfields_showValue(Html::formatNumber($value, true));
}
break;
case 'yesno' :
if (!$readonly) {
- echo Dropdown::showYesNo($field_name, $value);
+ Dropdown::showYesNo($field_name, $value);
} else {
plugin_customfields_showValue(Dropdown::getYesNo($field_name, $value));
}
diff -rud customfields-1.4.0-psv/inc/install.function.php plugins/customfields/inc/install.function.php
--- customfields-1.4.0-psv/inc/install.function.php 2013-06-09 18:53:14.108483450 +0200
+++ plugins/customfields/inc/install.function.php 2013-06-02 17:04:32.514025548 +0200
@@ -63,7 +63,11 @@
('NetworkPort'), ('Peripheral'), ('Printer'), ('CartridgeItem'),
('ConsumableItem'), ('Phone'), ('Ticket'), ('Contact'),
('Supplier'), ('Contract'), ('Document'), ('User'),
- ('Group'), ('Entity')";
+ ('Group'), ('Entity'), ('DeviceProcessor'), ('DeviceMemory'),
+ ('DeviceMotherBoard'), ('DeviceNetworkCard'), ('DeviceHardDrive'),
+ ('DeviceDrive'), ('DeviceControl'), ('DeviceGraphicCard'),
+ ('DeviceSoundCard'), ('DeviceCase'), ('DevicePowerSupply'),
+ ('DevicePci')";
$DB->query($query) or die($DB->error());
@@ -243,7 +247,7 @@
plugin_customfields_upgradeto116();
echo 'finished.';
- glpi_flush();
+ Html::glpi_flush();
}
if ($oldversion < 117) {
@@ -389,7 +393,7 @@
while ($data=$DB->fetch_array($result)) {
echo '.';
- glpi_flush();
+ Html::glpi_flush();
$table = plugin_customfields_table($data['itemtype']);
$field = $data['system_name'];
$newtype = $transform[$data['data_type']];
@@ -424,7 +428,7 @@
$DB->query($query) or die($DB->error());
echo 'finished.';
- glpi_flush();
+ Html::glpi_flush();
}
Only in customfields-1.4.0-psv/inc: plugin_customfields.function.php
diff -rud customfields-1.4.0-psv/inc/profile.class.php plugins/customfields/inc/profile.class.php
--- customfields-1.4.0-psv/inc/profile.class.php 2013-06-09 18:53:14.106483346 +0200
+++ plugins/customfields/inc/profile.class.php 2013-05-31 21:22:23.215093649 +0200
@@ -76,7 +76,7 @@
Html::redirect($CFG_GLPI['root_doc'] . '/index.php');
exit ();
}
- displayRightError();
+ Html::displayRightError();
}
}
Only in customfields-1.4.0-psv: patch
diff -rud customfields-1.4.0-psv/setup.php plugins/customfields/setup.php
--- customfields-1.4.0-psv/setup.php 2013-06-09 18:53:14.145485370 +0200
+++ plugins/customfields/setup.php 2013-06-08 14:15:26.758804040 +0200
@@ -118,7 +118,7 @@
}
// Define how to import data into custom fields with the Data_Injection plugin
- $PLUGIN_HOOKS['data_injection']['customfields'] = 'plugin_customfields_data_injection_variables';
+ $PLUGIN_HOOKS['data_injection_populate']['customfields'] = 'plugin_datainjection_populate_customfields';
// added back - is it used?
$PLUGIN_HOOKS['use_massive_action']['customfields']=1; //for custom massive action category
@@ -128,6 +128,7 @@
'PluginCustomfieldsDropdownsItem' => 'PluginCustomfieldsDropdownsItem::item_empty'
);
}
+
// Indicate where the configuration page can be found
if ( Session::haveRight('config','w')) {
$PLUGIN_HOOKS['config_page']['customfields'] = 'front/config.form.php';