2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* fields_Edit.php
|
|
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
|
|
|
|
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
|
|
|
|
*
|
|
|
|
|
* 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
|
2012-10-18 11:53:05 -04:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-12-02 23:34:41 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2012-10-18 11:53:05 -04:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
|
|
|
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
|
|
|
|
*/
|
2012-10-18 11:53:05 -04:00
|
|
|
if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) {
|
|
|
|
|
return $RBAC_Response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//G::genericForceLogin( 'WF_MYINFO' , 'login/noViewPage', $urlLogin = 'login/login' );
|
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
if (! (isset( $_GET['A'] ) && $_GET['A'] !== '')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
$file = G::decrypt( $_GET['A'], URL_KEY );
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
$dbc = new DBConnection( PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml' );
|
|
|
|
|
$ses = new DBSession( $dbc );
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
//TODO: Improve how to obtain the PRO_UID.
|
|
|
|
|
$aFile = explode( '/', str_replace( '\\', '/', $file ) );
|
|
|
|
|
$proUid = $aFile[0];
|
|
|
|
|
$dynUid = str_replace( "_tmp0", "", $aFile[1] );
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
require_once 'classes/model/Dynaform.php';
|
|
|
|
|
$k = new Criteria( 'workflow' );
|
|
|
|
|
$k->addSelectColumn( DynaformPeer::DYN_TYPE );
|
|
|
|
|
$k->add( DynaformPeer::DYN_UID, $dynUid );
|
|
|
|
|
$ods = DynaformPeer::doSelectRS( $k );
|
|
|
|
|
$ods->next();
|
|
|
|
|
$row = $ods->getRow();
|
|
|
|
|
$dynType = $row[0];
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
$Fields['PME_DYN_TYPE'] = $dynType;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
$fields = new DynaFormField( $dbc );
|
|
|
|
|
$fields->Fields['XMLNODE_NAME'] = (isset( $_GET['XMLNODE_NAME'] )) ? urldecode( $_GET['XMLNODE_NAME'] ) : '';
|
|
|
|
|
$fields->Load( $fields->Fields['XMLNODE_NAME'] );
|
|
|
|
|
|
|
|
|
|
/* Start Comment: Modify the options grid to set dynamically the language
|
2010-12-02 23:34:41 +00:00
|
|
|
* label columns.
|
|
|
|
|
*/
|
|
|
|
|
// $dbc2 = new DBConnection( PATH_XMLFORM . 'dynaforms/fields/_options.xml' ,'','','','myxml' );
|
|
|
|
|
// $ses2 = new DBSession($dbc2);
|
|
|
|
|
// $ses2->execute("DELETE FROM dynaForm WHERE XMLNODE_NAME like 'LABEL_%' ");
|
|
|
|
|
// $ses2->execute("DELETE FROM dynaForm WHERE XMLNODE_NAME = '' ");
|
|
|
|
|
// $langs=array(SYS_LANG/*,'es','fa'*/);
|
|
|
|
|
// foreach( $langs as $lang ) {
|
|
|
|
|
// $LANG = strtoupper($lang);
|
|
|
|
|
// $Label = 'Label';
|
|
|
|
|
// $ses2->execute("INSERT INTO dynaForm (XMLNODE_NAME,XMLNODE_TYPE,XMLNODE_VALUE) VALUES ('', 'cdata', '\n') ");
|
|
|
|
|
// $ses2->execute("INSERT INTO dynaForm (XMLNODE_NAME,TYPE) VALUES ('LABEL_{$LANG}', 'text') ");
|
|
|
|
|
// $ses2->execute("INSERT INTO dynaForm.LABEL_{$LANG} (XMLNODE_NAME,XMLNODE_VALUE) VALUES ('".SYS_LANG."', '{$Label} ({$lang})') ");
|
|
|
|
|
// $ses2->execute("INSERT INTO dynaForm (XMLNODE_NAME,XMLNODE_TYPE,XMLNODE_VALUE) VALUES ('', 'cdata', '\n') ");
|
|
|
|
|
// }
|
2012-10-18 11:53:05 -04:00
|
|
|
/* End Comment: */
|
|
|
|
|
|
|
|
|
|
define( 'DB_XMLDB_HOST', PATH_DYNAFORM . $file . '.xml' );
|
|
|
|
|
define( 'DB_XMLDB_USER', '' );
|
|
|
|
|
define( 'DB_XMLDB_PASS', '' );
|
|
|
|
|
define( 'DB_XMLDB_NAME', '' );
|
|
|
|
|
define( 'DB_XMLDB_TYPE', 'myxml' );
|
|
|
|
|
|
|
|
|
|
$form = new Form( $file, PATH_DYNAFORM, SYS_LANG, true );
|
|
|
|
|
|
|
|
|
|
if (is_array( $fields->Fields )) {
|
|
|
|
|
foreach ($fields->Fields as $key => $value) {
|
|
|
|
|
$Fields['PME_' . $key] = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$Fields['PME_A'] = $_GET['A'];
|
|
|
|
|
$Fields['PME_PRO_UID'] = $proUid;
|
|
|
|
|
$Fields['PME_XMLNODE_NAME_OLD'] = (isset( $Fields['PME_XMLNODE_NAME'] ) ? $Fields['PME_XMLNODE_NAME'] : '');
|
|
|
|
|
|
|
|
|
|
$G_PUBLISH = new Publisher();
|
|
|
|
|
|
|
|
|
|
if (! (isset( $fields->Fields['XMLNODE_NAME'] ) && ($fields->Fields['XMLNODE_NAME'] !== ''))) {
|
|
|
|
|
$type = strtolower( $_GET['TYPE'] );
|
|
|
|
|
} else {
|
|
|
|
|
$type = strtolower( $fields->Fields['TYPE'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($type == 'suggest' || $type == 'checkgroup' || $type == 'dropdown' || $type == 'radiogroup' || $type == 'text' || $type == 'listbox' || $type == 'currency' || $type == 'percentage' || $type == 'textarea' || $type == 'hidden') {
|
|
|
|
|
|
|
|
|
|
$aDefaultConnections = array ();
|
|
|
|
|
$aDBConn = array ();
|
|
|
|
|
$oDBConn = new DbConnections();
|
|
|
|
|
$aDefaultConnections = array (array ('DBS_UID' => '','DBS_NAME' => ''
|
|
|
|
|
),array ('DBS_UID' => 'dbarray','DBS_NAME' => 'dbarray'
|
|
|
|
|
),array ('DBS_UID' => 'workflow','DBS_NAME' => 'Workflow'
|
|
|
|
|
),array ('DBS_UID' => 'rbac','DBS_NAME' => 'RBAC'
|
|
|
|
|
),array ('DBS_UID' => 'rp','DBS_NAME' => 'REPORT'
|
|
|
|
|
)
|
2010-12-02 23:34:41 +00:00
|
|
|
);
|
2011-05-26 11:45:20 -04:00
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
$aDBConn = $oDBConn->getConnectionsProUid( $proUid );
|
|
|
|
|
$aDbConnections = array_merge( $aDefaultConnections, $aDBConn );
|
|
|
|
|
$_DBArray['DB_CONNECTIONS'] = $aDbConnections;
|
2010-12-02 23:34:41 +00:00
|
|
|
$_SESSION['_DBArray'] = $_DBArray;
|
2012-10-18 11:53:05 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
if (! (isset( $fields->Fields['XMLNODE_NAME'] ) && ($fields->Fields['XMLNODE_NAME'] !== ''))) {
|
2010-12-02 23:34:41 +00:00
|
|
|
$type = strtolower( $_GET['TYPE'] );
|
|
|
|
|
$Fields['PME_TYPE'] = $type;
|
2012-10-18 11:53:05 -04:00
|
|
|
|
|
|
|
|
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'dynaforms/fields/' . $type, '', $Fields, SYS_URI . 'dynaforms/fields_Save', SYS_URI . 'dynaforms/fields_Ajax' );
|
|
|
|
|
} else {
|
2010-12-02 23:34:41 +00:00
|
|
|
$Fields['PME_LABEL'] = $form->fields[$fields->Fields['XMLNODE_NAME']]->label;
|
2012-10-18 11:53:05 -04:00
|
|
|
if (isset( $form->fields[$fields->Fields['XMLNODE_NAME']]->code )) {
|
|
|
|
|
$Fields['PME_CODE'] = $form->fields[$fields->Fields['XMLNODE_NAME']]->code;
|
|
|
|
|
}
|
|
|
|
|
$options = isset( $form->fields[$fields->Fields['XMLNODE_NAME']]->option ) ? $form->fields[$fields->Fields['XMLNODE_NAME']]->option : array ();
|
|
|
|
|
if (! is_array( $options ) || count( $options ) == 0) {
|
|
|
|
|
$options = array ('' => '' );
|
|
|
|
|
}
|
2013-03-27 09:57:22 -04:00
|
|
|
|
|
|
|
|
$arrayOptionName = array_keys($options);
|
|
|
|
|
$arrayOptionLabel = array_values($options);
|
|
|
|
|
$arrayOptionOptGroup = array();
|
|
|
|
|
|
|
|
|
|
foreach ($arrayOptionName as $value) {
|
|
|
|
|
$arrayOptionOptGroup[] = (preg_match("/^optgroup\d+$/", $value))? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$Fields["PME_OPTIONS"] = array("NAME" => $arrayOptionName, "LABEL" => $arrayOptionLabel, "OPTGROUP" => $arrayOptionOptGroup);
|
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
$type = strtolower( $fields->Fields['TYPE'] );
|
2012-10-18 11:53:05 -04:00
|
|
|
if ($type === 'checkbox') {
|
|
|
|
|
if ($Fields['PME_DEFAULTVALUE'] === $Fields['PME_VALUE']) {
|
|
|
|
|
$Fields['PME_DEFAULTVALUE'] = 'On';
|
|
|
|
|
} else {
|
|
|
|
|
$Fields['PME_DEFAULTVALUE'] = 'Off';
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
if (isset( $Fields['PME_HINT'] )) {
|
|
|
|
|
$Fields['PME_HINT'] = stripslashes( $Fields['PME_HINT'] );
|
|
|
|
|
$Fields['PME_HINT'] = htmlspecialchars_decode( $Fields['PME_HINT'] );
|
|
|
|
|
$Fields['PME_HINT'] = str_replace( "'", "'", $Fields['PME_HINT'] );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 11:53:05 -04:00
|
|
|
if (file_exists( PATH_XMLFORM . 'dynaforms/fields/' . $type . '.xml' )) {
|
|
|
|
|
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'dynaforms/fields/' . $type, '', $Fields, SYS_URI . 'dynaforms/fields_Save', SYS_URI . 'dynaforms/fields_Ajax' );
|
2010-12-02 23:34:41 +00:00
|
|
|
} else {
|
2012-10-18 11:53:05 -04:00
|
|
|
print (G::LoadTranslation( 'ID_UNKNOWN_FIELD_TYPE' )) ;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 11:53:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G::RenderPage( "publish", "raw" );
|
2010-12-02 23:34:41 +00:00
|
|
|
|