[ghelda-devel] [50] Update Requests.php |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/ghelda-devel Archives
]
Revision: 50
Author: odyx
Date: 2009-05-20 13:48:29 +0200 (Wed, 20 May 2009)
Log Message:
-----------
Update Requests.php
Modified Paths:
--------------
trunk/plugins/Requests.php
Added Paths:
-----------
trunk/plugins/Requests/
trunk/plugins/Requests/config_core.php
Added: trunk/plugins/Requests/config_core.php
===================================================================
--- trunk/plugins/Requests/config_core.php (rev 0)
+++ trunk/plugins/Requests/config_core.php 2009-05-20 11:48:29 UTC (rev 50)
@@ -0,0 +1,27 @@
+<?php
+/*
+ * Ghelda - Gestion Hiérarchisée En Ligne D'Adresses
+ * - Online Hierarchical Handling Of Adresses
+ *
+ * Copyright (C) 2009 Didier Raboud
+ *
+ * This program 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.
+ *
+ * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// All fields values _must_ be lowercase due to MSDB2 weird handling of field names.
+
+// Required
+$conf['n_conditions_per_plugin'] = 1;
+
+?>
\ No newline at end of file
Modified: trunk/plugins/Requests.php
===================================================================
--- trunk/plugins/Requests.php 2009-05-20 11:48:27 UTC (rev 49)
+++ trunk/plugins/Requests.php 2009-05-20 11:48:29 UTC (rev 50)
@@ -3,7 +3,7 @@
* Ghelda - Gestion Hiérarchisée En Ligne D'Adresses
* - Online Hierarchical Handling Of Adresses
*
- * Copyright (C) 2008 Didier Raboud
+ * Copyright (C) 2009 Didier Raboud
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -22,7 +22,7 @@
define('G_REQUESTS_URL_MODE','mode');
define('G_REQUESTS_DEFAULT_MODE','list');
define('G_REQUESTS_ID_NEW','-1');
-define('G_REQUESTS_ID','group_id');
+define('G_REQUESTS_ID','request_id');
class Requests extends Plugin {
@@ -99,27 +99,6 @@
private function m_edit($id,&$fieldsSpec)
{
- // Modification asked
- if($_POST[$this->configH['URL']['action']] == 'change') {
- }
-
- $functionalityResult = $this->_parent->functionality('Requests.FieldsList');
-
- // Go along the plugins
- foreach($functionalityResult as $pluginName => $pFunctionalityResult){
- $fieldsSpec[$pluginName]['type'] = 'SELECT';
- $fieldsSpec[$pluginName]['name'] = $pFunctionalityResult['name'];
- $fieldsSpec[$pluginName]['multiple'] = true;
- // Go along all fields and attribute to each the name and the name only
- foreach($pFunctionalityResult['fieldsList'] as $fieldIdentifier => $fieldSpec){
- if( array_key_exists('noShow',$fieldSpec) ) continue;
- $name = $fieldSpec['name'];
- $fieldsSpec[$pluginName]['values'][$fieldIdentifier] = is_array($name) ? $name[0] : $name;
- }
- }
-
- $fullFieldsSpec[$this->name] = $fieldsSpec;
-
// SELECT
// FieldsList
// `G_groups`.`group_id`,
@@ -143,14 +122,65 @@
// ORDER BY
// Ordering
// `G_people_groups`.`start_date` DESC
+ // Modification asked
+ if($_POST[$this->configH['URL']['action']] == 'change') {
+ $functionalityResult = $this->_parent->functionality('Requests.FormattedRequest', $_POST);
+ }
+
+ // This functionality expects an array with two keyed values:
+ // "name" => Translated name of the plugin
+ // "values" => keyed array of the various values
+ $functionalityResult = $this->_parent->functionality('Requests.FieldsList');
+
+ // Go along the plugins to mungle what they provided
+ foreach($functionalityResult as $pluginName => $pFunctionalityResult){
+ // For the selection of fields
+ $fieldsSpec[$pluginName.'[]']['type'] = 'SELECT';
+ $fieldsSpec[$pluginName.'[]']['name'] = $pFunctionalityResult['name'];
+ $fieldsSpec[$pluginName.'[]']['multiple'] = true;
+ // Go along all fields and attribute to each the name and the name only
+ foreach($pFunctionalityResult['fieldsList'] as $fieldIdentifier => $fieldSpec){
+ if( array_key_exists('noShow',$fieldSpec) ||
+ array_key_exists('dontRequest', $fieldSpec) )
+ continue;
+ $name = $fieldSpec['name'];
+ $fieldsSpec[$pluginName.'[]']['values'][$fieldIdentifier] = is_array($name) ? $name[0] : $name;
+ }
+ // Get the fieldNames
+ $values = array(0 => '');
+ $values = array_merge($values,$fieldsSpec[$pluginName.'[]']['values']);
+
+ // For the selection of conditions on the fields
+ for( $i = 0; $i < $this->configH[$this->name]['n_conditions_per_plugin']; $i++) {
+ $fieldsSpec[$pluginName.'_condition_field['.$i.']'] = array(
+ "type" => 'SELECT',
+ "name" => sprintf(T_('Condition #%d'),$i+1),
+ "multiple" => false,
+ "values" => $values
+ );
+ // !!! BIG WARNING !!! This IS VULNERABLE TO SQL INJECTION.
+ $fieldsSpec[$pluginName.'_condition_val['.$i.']'] = array(
+ "type" => 'VARCHAR( 256 )',
+ "name" => '',
+ );
+ }
+ }
+ // Create the index field and its value
+ $fieldsSpec[G_REQUESTS_ID] = array(
+ "restricted" => true,
+ 'type' => 'INT( 10 )',
+ 'noShow' => true
+ );
+ $fieldsValues[G_REQUESTS_ID] = G_REQUESTS_ID_NEW;
+
$displayOptions['title'] = T_('New request');
$displayOptions['id'] = 'Requests_edit';
$displayOptions['command'] = T_('Create request');
$displayOptions['target'] = $this->url->getURL();
$displayOptions['action'] = 'change';
- $this->output->displayFields($fullFieldsSpec,array(),$displayOptions);
+ $this->output->displayFields($fieldsSpec,$fieldsValues,$displayOptions,$this->name);
}
}
?>
\ No newline at end of file