diff --git a/gulliver/js/form/core/form.js b/gulliver/js/form/core/form.js index dda581c76..2648f4d54 100755 --- a/gulliver/js/form/core/form.js +++ b/gulliver/js/form/core/form.js @@ -284,7 +284,7 @@ function G_Field ( form, element, name ) return me.element.value; }; this.toJSONString=function() { - return '{'+me.name+':'+me.element.value.toJSONString()+'}'; + return '{"'+me.name+'":'+me.element.value.toJSONString()+'}'; }; this.highLight=function(){ try{ @@ -3060,18 +3060,22 @@ var validateForm = function(sRequiredFields) { } else { var arrayForm = document.getElementsByTagName("form"); + var inputAux; + var id = ""; + var i1 = 0; + var i2 = 0; - for (var i = 0; i <= arrayForm.length - 1; i++) { - var frm = arrayForm[i]; + for (i1 = 0; i1 <= arrayForm.length - 1; i1++) { + var frm = arrayForm[i1]; - for (var i = 0; i <= frm.elements.length - 1; i++) { - var elem = frm.elements[i]; + for (i2 = 0; i2 <= frm.elements.length - 1; i2++) { + var elem = frm.elements[i2]; if (elem.type == "checkbox" && elem.disabled && elem.checked) { - var id = elem.id + "_"; + id = elem.id + "_"; if (!document.getElementById(id)) { - var inputAux = document.createElement("input"); + inputAux = document.createElement("input"); inputAux.type = "hidden"; inputAux.id = id; inputAux.name = elem.name; @@ -3081,7 +3085,47 @@ var validateForm = function(sRequiredFields) { } } } + + var arrayLink = frm.getElementsByTagName("a"); + + for (i2 = 0; i2 <= arrayLink.length - 1; i2++) { + var link = arrayLink[i2]; + + if (typeof link.id != "undefined" && link.id != "" && link.id != "form[DYN_BACKWARD]" && link.id != "form[DYN_FORWARD]") { + var strHtml = link.parentNode.innerHTML; + + strHtml = stringReplace("\\x0A", "", strHtml); //\n 10 + strHtml = stringReplace("\\x0D", "", strHtml); //\r 13 + strHtml = stringReplace("\\x09", "", strHtml); //\t 9 + + if (/^.*pm:field.*$/.test(strHtml)) { + id = link.id + "_"; + + if (!document.getElementById(id)) { + var strAux = link.id.replace("form[", ""); + strAux = strAux.substring(0, strAux.length - 1); + + inputAux = document.createElement("input"); + inputAux.type = "hidden"; + inputAux.id = id; + inputAux.name = link.id; + inputAux.value = link.href; + + frm.appendChild(inputAux); + + inputAux = document.createElement("input"); + inputAux.type = "hidden"; + inputAux.id = id + "label"; + inputAux.name = "form[" + strAux + "_label]"; + inputAux.value = link.innerHTML; + + frm.appendChild(inputAux); + } + } + } + } } + return true; } }; diff --git a/gulliver/js/maborak/core/maborak.js b/gulliver/js/maborak/core/maborak.js index 92a315c83..1bc94bef2 100644 --- a/gulliver/js/maborak/core/maborak.js +++ b/gulliver/js/maborak/core/maborak.js @@ -960,7 +960,7 @@ var callServer;callServer=new leimnud.module.rpc.xmlhttp({url:me.form.ajaxServer else{for(var i=0;i1)dd.remove(0);}else{for(var key in dd.options){dd.options[key]=null;}} for(var o=0;o0){systemMessaggeInvalid+="\n \n"+G_STRINGS.ID_REQUIRED_FIELDS+": \n \n [ "+sMessage+" ]";} if(fielEmailInvalid.length>0){systemMessaggeInvalid+="\n \n"+G_STRINGS.ID_VALIDATED_FIELDS+": \n \n [ "+emailInvalidMessage+" ]";} alert(systemMessaggeInvalid);return false;} -else{var arrayForm=document.getElementsByTagName("form");for(var i=0;i<=arrayForm.length-1;i++){var frm=arrayForm[i];for(var i=0;i<=frm.elements.length-1;i++){var elem=frm.elements[i];if(elem.type=="checkbox"&&elem.disabled&&elem.checked){var id=elem.id+"_";if(!document.getElementById(id)){var inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id;inputAux.name=elem.name;inputAux.value=elem.value;frm.appendChild(inputAux);}}}} +else{var arrayForm=document.getElementsByTagName("form");var inputAux;var id="";var i1=0;var i2=0;for(i1=0;i1<=arrayForm.length-1;i1++){var frm=arrayForm[i1];for(i2=0;i2<=frm.elements.length-1;i2++){var elem=frm.elements[i2];if(elem.type=="checkbox"&&elem.disabled&&elem.checked){id=elem.id+"_";if(!document.getElementById(id)){inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id;inputAux.name=elem.name;inputAux.value=elem.value;frm.appendChild(inputAux);}}} +var arrayLink=frm.getElementsByTagName("a");for(i2=0;i2<=arrayLink.length-1;i2++){var link=arrayLink[i2];if(typeof link.id!="undefined"&&link.id!=""&&link.id!="form[DYN_BACKWARD]"&&link.id!="form[DYN_FORWARD]"){var strHtml=link.parentNode.innerHTML;strHtml=stringReplace("\\x0A","",strHtml);strHtml=stringReplace("\\x0D","",strHtml);strHtml=stringReplace("\\x09","",strHtml);if(/^.*pm:field.*$/.test(strHtml)){id=link.id+"_";if(!document.getElementById(id)){var strAux=link.id.replace("form[","");strAux=strAux.substring(0,strAux.length-1);inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id;inputAux.name=link.id;inputAux.value=link.href;frm.appendChild(inputAux);inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id+"label";inputAux.name="form["+strAux+"_label]";inputAux.value=link.innerHTML;frm.appendChild(inputAux);}}}}} return true;}};var getObject=function(sObject){var i;var oAux=null;var iLength=__aObjects__.length;for(i=0;i0){oAux[0].action+='&_REFRESH_=1';oAux[0].submit();}}};var saveForm=function(oObject){if(oObject){ajax_post(oObject.form.action,oObject.form,'POST');} diff --git a/gulliver/js/maborak/core/maborak.loader.js b/gulliver/js/maborak/core/maborak.loader.js index 455df0069..7e23c8033 100644 --- a/gulliver/js/maborak/core/maborak.loader.js +++ b/gulliver/js/maborak/core/maborak.loader.js @@ -723,6 +723,8 @@ return this.dom;}.extend(this);this.dom.remove=function() {if(radio_name[i].value==radio_value) {return radio_name[i];}} return false;}}}); +var $=function(el) +{var d=(typeof el=="string")?document.getElementById(el):el;return new leimnud.module.dom.methods(d);};var button=leimnud.module.dom.button;var input=leimnud.module.dom.input;var DOM=leimnud.module.dom.create;var panel=leimnud.module.panel;var select=leimnud.module.dom.select; leimnud.Package.Public({info:{Class:"maborak",File:"module.dashboard.js",Name:"dashboard",Type:"module",Version:"0.1"},content:function(){this.elements={};this.make=function(options) {this.options={drag:true,panel:[],data:[]}.concat(options||{});this.drop=new this.parent.module.drop();this.drop.make();var width=this.options.target.offsetWidth-50;this.columns=this.options.data.length;this.widthColumn=(width/this.columns);this.elements.column=[];this.elements.table=$dce('table');$(this.elements.table).setStyle({width:width,borderCollapse:'collapse'}) this.elements.tr=this.elements.table.insertRow(-1);this.options.target.append(this.elements.table);this.matriz=[];for(var i=0;i. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - - /*NEXT LINE: Runs any configuration defined to be executed before dependent fields recalc*/ - if ( isset($_SESSION['CURRENT_PAGE_INITILIZATION']) ) - eval($_SESSION['CURRENT_PAGE_INITILIZATION']); - - - G::LoadThirdParty('pear/json','class.json'); - - $json=new Services_JSON(); - if (!defined('XMLFORM_AJAX_PATH')) define('XMLFORM_AJAX_PATH',PATH_XMLFORM); - - $_DBArray = array(); - if (isset($_SESSION['_DBArray'])) { - $_DBArray = $_SESSION['_DBArray']; - } - - $xmlFile = G::getUIDName(urlDecode($_POST['form'])); - $sPath = XMLFORM_AJAX_PATH; - - //if the xmlform file doesn't exist, then try with the plugins folders - if ( !is_file ( XMLFORM_AJAX_PATH . $xmlFile ) ) { - $aux = explode ( PATH_SEP, $xmlFile ); - //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment - if ( count($aux) == 2 && defined ( 'G_PLUGIN_CLASS' ) ) { - $oPluginRegistry =& PMPluginRegistry::getSingleton(); - if ( $oPluginRegistry->isRegisteredFolder($aux[0]) ) { - $sPath = PATH_PLUGINS; - } - } - } - $G_FORM=new form( $xmlFile , $sPath ); - $G_FORM->id=urlDecode($_POST['form']); - $G_FORM->values=isset($_SESSION[$G_FORM->id]) ? $_SESSION[$G_FORM->id] : array(); - $newValues=($json->decode(urlDecode(stripslashes($_POST['fields'])))); - if (isset($_POST['grid'])) { - $_POST['row'] = (int)$_POST['row']; - $aAux = array(); - foreach ($newValues as $sKey => $newValue) { - $newValue = (array)$newValue; - $aKeys = array_keys($newValue); - $aValues = array(); - for ($i = 1; $i <= ($_POST['row'] - 1); $i++) { - $aValues[$i] = array($aKeys[0] => ''); - } - $aValues[$_POST['row']] = array($aKeys[0] => $newValue[$aKeys[0]]); - $newValues[$sKey]->$_POST['grid'] = $aValues; - unset($newValues[$sKey]->$aKeys[0]); - } - } - - //Next Lines re-build newValues array to send multiple dependent fields merged by row into a grid. - if (sizeof($newValues)>1 && isset($_POST['grid'])){ - $fieldBase = array(); - foreach ($newValues as $key => $values){ - for ($r2=1; $r2 <= $_POST['row']; $r2++){ - foreach ($values as $class => $value){ - if ($class == $_POST['grid']){ - $value = (array) $value; - $arrayK = $value[$r2]; - foreach ($arrayK as $key2 => $val) { - $fieldBase[$r2][$key2] = is_array($val)? $val[$key2] : $val; - } - } - } - } - } - $newValues = array(); +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +/*NEXT LINE: Runs any configuration defined to be executed before dependent fields recalc*/ +if (isset( $_SESSION['CURRENT_PAGE_INITILIZATION'] )) + eval( $_SESSION['CURRENT_PAGE_INITILIZATION'] ); + + // G::LoadThirdParty('pear/json','class.json'); + // $json=new Services_JSON(); +if (! defined( 'XMLFORM_AJAX_PATH' )) + define( 'XMLFORM_AJAX_PATH', PATH_XMLFORM ); + +$_DBArray = array (); +if (isset( $_SESSION['_DBArray'] )) { + $_DBArray = $_SESSION['_DBArray']; +} + +$xmlFile = G::getUIDName( urlDecode( $_POST['form'] ) ); +$sPath = XMLFORM_AJAX_PATH; + +//if the xmlform file doesn't exist, then try with the plugins folders +if (! is_file( XMLFORM_AJAX_PATH . $xmlFile )) { + $aux = explode( PATH_SEP, $xmlFile ); + //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment + if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + $sPath = PATH_PLUGINS; + } + } +} +$G_FORM = new form( $xmlFile, $sPath ); +$G_FORM->id = urlDecode( $_POST['form'] ); +$G_FORM->values = isset( $_SESSION[$G_FORM->id] ) ? $_SESSION[$G_FORM->id] : array (); +$newValues = (Bootstrap::json_decode( urlDecode( stripslashes( $_POST['fields'] ) ) )); +if (isset( $_POST['grid'] )) { + $_POST['row'] = (int) $_POST['row']; + $aAux = array (); + foreach ($newValues as $sKey => $newValue) { + $newValue = (array) $newValue; + $aKeys = array_keys( $newValue ); + $aValues = array (); + for ($i = 1; $i <= ($_POST['row'] - 1); $i ++) { + $aValues[$i] = array ($aKeys[0] => '' + ); + } + $aValues[$_POST['row']] = array ($aKeys[0] => $newValue[$aKeys[0]] + ); + $newValues[$sKey]->$_POST['grid'] = $aValues; + unset( $newValues[$sKey]->$aKeys[0] ); + } +} + +//Next Lines re-build newValues array to send multiple dependent fields merged by row into a grid. +if (sizeof( $newValues ) > 1 && isset( $_POST['grid'] )) { + $fieldBase = array (); + foreach ($newValues as $key => $values) { + for ($r2 = 1; $r2 <= $_POST['row']; $r2 ++) { + foreach ($values as $class => $value) { + if ($class == $_POST['grid']) { + $value = (array) $value; + $arrayK = $value[$r2]; + foreach ($arrayK as $key2 => $val) { + $fieldBase[$r2][$key2] = is_array( $val ) ? $val[$key2] : $val; + } + } + } + } + } + $newValues = array (); //$fieldBase = (array) $fieldBase; - $newValues[0]->$_POST['grid'] = $fieldBase; - } - - //Resolve dependencies - //Returns an array ($dependentFields) with the names of the fields - //that depends of fields passed through AJAX ($_GET/$_POST) - $dependentFields=array(); $aux=array(); - for($r=0;$rsetValues($newValues[$r]); - //Search dependent fields - foreach($newValues[$r] as $k => $v) { - if (!is_array($v)) { - $myDependentFields = subDependencies( $k , $G_FORM , $aux ); - $_SESSION[$G_FORM->id][$k] = $v; - } - else { - foreach($v[$_POST['row']] as $k1 => $v1) { - $myDependentFields = subDependencies( $k1 , $G_FORM , $aux, $_POST['grid'] ); - $_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1; - } - } - $dependentFields=array_merge($dependentFields, $myDependentFields); - } - } - if (isset($_POST['grid'])) $G_FORM->values=isset($_SESSION[$G_FORM->id]) ? $_SESSION[$G_FORM->id] : array(); - - $dependentFields=array_unique($dependentFields); - - //Parse and update the new content - $template = PATH_CORE . 'templates/xmlform.html'; - $newContent=$G_FORM->getFields($template, (isset($_POST['row']) ? $_POST['row'] : -1)); - //Returns the dependentFields's content - $sendContent=array(); - $r=0; - - foreach($dependentFields as $d) { - $sendContent[$r]->name=$d; - $sendContent[$r]->content=NULL; - if (!isset($_POST['grid'])) { - if (isset($G_FORM->fields[$d])) { - foreach($G_FORM->fields[$d] as $attribute => $value) { - switch($attribute) { - case 'type': - $sendContent[$r]->content->{$attribute}=$value;break; - case 'options': - $sendContent[$r]->content->{$attribute}=toJSArray($value, $sendContent[$r]->content->type); break; - } - } - $sendContent[$r]->value=isset($G_FORM->values[$d]) ? $G_FORM->values[$d] : ''; - } - } - else { - foreach($G_FORM->fields[$_POST['grid']]->fields[$d] as $attribute => $value) { - switch($attribute) { - case 'type': - $sendContent[$r]->content->{$attribute}=$value; break; - case 'options': - if ($sendContent[$r]->content->type != 'text') { - $sendContent[$r]->content->{$attribute}=toJSArray($value); - } - else { - $sendContent[$r]->content->{$attribute}=toJSArray((isset($value[$_POST['row']]) ? array($value[$_POST['row']]) : array())); - } - break; - } - } - $sendContent[$r]->value=isset($G_FORM->values[$_POST['grid']][$_POST['row']][$d]) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : ''; - } - $r++; - } - echo($json->encode($sendContent)); - - function toJSArray($array, $type= '') - { - $result=array(); - foreach($array as $k => $v){ - $o=NULL; - $o->key=$k; - // TODO: review the condition to make the differentiation to dependent dropdowns in a grid function. - // this way of validation is if you have a dependent field in text fields - $o->value= ($type =='text' || $type =='textarea')? $k:$v; - $result[]=$o; - } - return $result; - } - - function subDependencies( $k , &$G_FORM , &$aux, $grid = '') { - if (array_search( $k, $aux )!==FALSE) return array(); - if ($grid == '') { - if (!array_key_exists( $k , $G_FORM->fields )) return array(); - if (!isset($G_FORM->fields[$k]->dependentFields)) return array(); - $aux[] = $k; - if (strpos($G_FORM->fields[$k]->dependentFields, ',') !== false) { - $myDependentFields = explode( ',', $G_FORM->fields[$k]->dependentFields); - } - else { - $myDependentFields = explode( '|', $G_FORM->fields[$k]->dependentFields); - } - for( $r=0 ; $r < sizeof($myDependentFields) ; $r++ ) { - if ($myDependentFields[$r]=="") unset($myDependentFields[$r]); - } - // $mD = $myDependentFields; - // foreach( $mD as $ki) { - // $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux ) ); - // } - } - else { - if (!array_key_exists( $k , $G_FORM->fields[$grid]->fields )) return array(); - if (!isset($G_FORM->fields[$grid]->fields[$k]->dependentFields)) return array(); - $aux[] = $k; - if (strpos($G_FORM->fields[$grid]->fields[$k]->dependentFields, ',') !== false) { - $myDependentFields = explode( ',', $G_FORM->fields[$grid]->fields[$k]->dependentFields); - } - else { - $myDependentFields = explode( '|', $G_FORM->fields[$grid]->fields[$k]->dependentFields); - } - for( $r=0 ; $r < sizeof($myDependentFields) ; $r++ ) { - if ($myDependentFields[$r]=="") unset($myDependentFields[$r]); - } -// $mD = $myDependentFields; -// foreach( $mD as $ki) { -// $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux, $grid) ); -// } - } - return $myDependentFields; - } -?> + $newValues[0]->$_POST['grid'] = $fieldBase; +} + +//Resolve dependencies +//Returns an array ($dependentFields) with the names of the fields +//that depends of fields passed through AJAX ($_GET/$_POST) +$dependentFields = array (); +$aux = array (); +for ($r = 0; $r < sizeof( $newValues ); $r ++) { + $newValues[$r] = (array) $newValues[$r]; + $G_FORM->setValues( $newValues[$r] ); + //Search dependent fields + foreach ($newValues[$r] as $k => $v) { + if (! is_array( $v )) { + $myDependentFields = subDependencies( $k, $G_FORM, $aux ); + $_SESSION[$G_FORM->id][$k] = $v; + } else { + foreach ($v[$_POST['row']] as $k1 => $v1) { + $myDependentFields = subDependencies( $k1, $G_FORM, $aux, $_POST['grid'] ); + $_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1; + } + } + $dependentFields = array_merge( $dependentFields, $myDependentFields ); + } +} +if (isset( $_POST['grid'] )) + $G_FORM->values = isset( $_SESSION[$G_FORM->id] ) ? $_SESSION[$G_FORM->id] : array (); + +$dependentFields = array_unique( $dependentFields ); + +//Parse and update the new content +$template = PATH_CORE . 'templates/xmlform.html'; +$newContent = $G_FORM->getFields( $template, (isset( $_POST['row'] ) ? $_POST['row'] : - 1) ); +//Returns the dependentFields's content +$sendContent = array (); +$r = 0; + +foreach ($dependentFields as $d) { + $sendContent[$r]->name = $d; + $sendContent[$r]->content = NULL; + if (! isset( $_POST['grid'] )) { + if (isset( $G_FORM->fields[$d] )) { + foreach ($G_FORM->fields[$d] as $attribute => $value) { + switch ($attribute) { + case 'type': + $sendContent[$r]->content->{$attribute} = $value; + break; + case 'options': + $sendContent[$r]->content->{$attribute} = toJSArray( $value, $sendContent[$r]->content->type ); + break; + } + } + $sendContent[$r]->value = isset( $G_FORM->values[$d] ) ? $G_FORM->values[$d] : ''; + } + } else { + foreach ($G_FORM->fields[$_POST['grid']]->fields[$d] as $attribute => $value) { + switch ($attribute) { + case 'type': + $sendContent[$r]->content->{$attribute} = $value; + break; + case 'options': + if ($sendContent[$r]->content->type != 'text') { + $sendContent[$r]->content->{$attribute} = toJSArray( $value ); + } else { + $sendContent[$r]->content->{$attribute} = toJSArray( (isset( $value[$_POST['row']] ) ? array ($value[$_POST['row']] + ) : array ()) ); + } + break; + } + } + $sendContent[$r]->value = isset( $G_FORM->values[$_POST['grid']][$_POST['row']][$d] ) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : ''; + } + $r ++; +} +echo (Bootstrap::json_encode( $sendContent )); + +function toJSArray ($array, $type = '') +{ + $result = array (); + foreach ($array as $k => $v) { + $o = NULL; + $o->key = $k; + // TODO: review the condition to make the differentiation to dependent dropdowns in a grid function. + // this way of validation is if you have a dependent field in text fields + $o->value = ($type == 'text' || $type == 'textarea') ? $k : $v; + $result[] = $o; + } + return $result; +} + +function subDependencies ($k, &$G_FORM, &$aux, $grid = '') +{ + if (array_search( $k, $aux ) !== FALSE) + return array (); + if ($grid == '') { + if (! array_key_exists( $k, $G_FORM->fields )) + return array (); + if (! isset( $G_FORM->fields[$k]->dependentFields )) + return array (); + $aux[] = $k; + if (strpos( $G_FORM->fields[$k]->dependentFields, ',' ) !== false) { + $myDependentFields = explode( ',', $G_FORM->fields[$k]->dependentFields ); + } else { + $myDependentFields = explode( '|', $G_FORM->fields[$k]->dependentFields ); + } + for ($r = 0; $r < sizeof( $myDependentFields ); $r ++) { + if ($myDependentFields[$r] == "") + unset( $myDependentFields[$r] ); + } + // $mD = $myDependentFields; + // foreach( $mD as $ki) { + // $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux ) ); + // } + } else { + if (! array_key_exists( $k, $G_FORM->fields[$grid]->fields )) + return array (); + if (! isset( $G_FORM->fields[$grid]->fields[$k]->dependentFields )) + return array (); + $aux[] = $k; + if (strpos( $G_FORM->fields[$grid]->fields[$k]->dependentFields, ',' ) !== false) { + $myDependentFields = explode( ',', $G_FORM->fields[$grid]->fields[$k]->dependentFields ); + } else { + $myDependentFields = explode( '|', $G_FORM->fields[$grid]->fields[$k]->dependentFields ); + } + for ($r = 0; $r < sizeof( $myDependentFields ); $r ++) { + if ($myDependentFields[$r] == "") + unset( $myDependentFields[$r] ); + } + // $mD = $myDependentFields; + // foreach( $mD as $ki) { + // $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux, $grid) ); + // } + } + return $myDependentFields; +} diff --git a/gulliver/methods/defaultAjaxDynaform.php b/gulliver/methods/defaultAjaxDynaform.php index 27d0d6384..c96168904 100755 --- a/gulliver/methods/defaultAjaxDynaform.php +++ b/gulliver/methods/defaultAjaxDynaform.php @@ -24,4 +24,4 @@ */ define('XMLFORM_AJAX_PATH',PATH_DYNAFORM); require_once(PATH_GULLIVER_HOME.'/methods/defaultAjax.php'); -?> \ No newline at end of file + diff --git a/gulliver/methods/propelTableAjax.php b/gulliver/methods/propelTableAjax.php index 735e1c330..a0f06a5cc 100755 --- a/gulliver/methods/propelTableAjax.php +++ b/gulliver/methods/propelTableAjax.php @@ -36,8 +36,8 @@ //THIS BLOCK SET THE FILTER VARIABLES if (isset($ntable->filterForm_Id) && ($ntable->filterForm_Id!=='')) { - - $sPath = PATH_XMLFORM; + + $sPath = PATH_XMLFORM; //if the xmlform file doesn't exist, then try with the plugins folders if ( !is_file ( $sPath . G::getUIDName( $ntable->filterForm_Id ) ) ) { $aux = explode ( PATH_SEP, G::getUIDName( $ntable->filterForm_Id ) ); @@ -49,11 +49,11 @@ } } } - + $filterForm=new filterForm(G::getUIDName( $ntable->filterForm_Id ),$sPath); - - - + + + $filterForm->values=$_SESSION[$filterForm->id]; parse_str( urldecode(get_ajax_value('filter')) , $newValues); if (isset($newValues['form'])) { @@ -77,10 +77,10 @@ //order by $orderBy = get_ajax_value('order'); - if (isset($orderBy)) { - $orderBy = urldecode($orderBy); - $ntable->orderBy = $orderBy; - } + if (isset($orderBy)) { + $orderBy = urldecode($orderBy); + $ntable->orderBy = $orderBy; + } if ( isset($page) && $page!=='' ) $ntable->currentPage = (int) $page; diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php new file mode 100644 index 000000000..7eece039c --- /dev/null +++ b/gulliver/system/class.bootstrap.php @@ -0,0 +1,2697 @@ + 0,'debug_sql' => 0,'debug_time' => 0,'debug_calendar' => 0,'wsdl_cache' => 1,'memory_limit' => '128M','time_zone' => 'America/New_York','memcached' => 0,'memcached_server' => '','default_skin' => 'classic','default_lang' => 'en','proxy_host' => '','proxy_port' => '','proxy_user' => '','proxy_pass' => '' + ); + + // read the global env.ini configuration file + if ($readGlobalIniFile && ($globalConf = @parse_ini_file( $globalIniFile )) !== false) { + $config = array_merge( $config, $globalConf ); + } + + // Workspace environment configuration + if ($readWsIniFile && ($wsConf = @parse_ini_file( $wsIniFile )) !== false) { + $config = array_merge( $config, $wsConf ); + } + + // validation debug config, only binary value is valid; debug = 1, to enable + $config['debug'] = $config['debug'] == 1 ? 1 : 0; + + if ($config['proxy_pass'] != '') { + $config['proxy_pass'] = G::decrypt( $config['proxy_pass'], 'proxy_pass' ); + } + + $md5 = array (); + if ($readGlobalIniFile) { + $md5[] = md5_file( $globalIniFile ); + } + if ($readWsIniFile) { + $md5[] = md5_file( $wsIniFile ); + } + $hash = implode( '-', $md5 ); + + $_SESSION['PROCESSMAKER_ENV'] = $config; + $_SESSION['PROCESSMAKER_ENV_HASH'] = $hash; + + return $config; + } + + + //below this line, still not approved methods + + /** + * mk_dir , copied from class.G.php + * + * @return void + */ + public function mk_dir($strPath, $rights = 0777) { + $folder_path = array ( $strPath ); + $oldumask = umask ( 0 ); + while ( ! @is_dir ( dirname ( end ( $folder_path ) ) ) && dirname ( end ( $folder_path ) ) != '/' && dirname ( end ( $folder_path ) ) != '.' && dirname ( end ( $folder_path ) ) != '' ) { + array_push ( $folder_path, dirname ( end ( $folder_path ) ) ); + // var_dump($folder_path); + // die; + } + + while ( $parent_folder_path = array_pop ( $folder_path ) ) { + if (! @is_dir ( $parent_folder_path )) { + if (! @mkdir ( $parent_folder_path, $rights )) { + // trigger_error ("Can't create folder + // \"$parent_folder_path\".", E_USER_WARNING); + umask ( $oldumask ); + } + } + } + } + + /** + * verify if all files & directories passed by param. + * are writable + * + * @author Erik Amaru Ortiz + * @param $resources array + * a list of files to verify write access + */ + public function verifyWriteAccess($resources) { + $noWritable = array (); + foreach ( $resources as $i => $resource ) { + if (! is_writable ( $resource )) { + $noWritable [] = $resource; + } + } + + if (count ( $noWritable ) > 0) { + $e = new Exception ( "Write access not allowed for ProcessMaker resources" ); + $e->files = $noWritable; + throw $e; + } + } + + /** + * render a smarty template + * + * @author Erik Amaru Ortiz + * @param $template string + * containing the template filename on /gulliver/templates/ + * directory + * @param $data associative + * array containig the template data + */ + public function renderTemplate($template, $data = array()) { + if (! defined ( 'PATH_THIRDPARTY' )) { + throw new Exception ( 'System constant (PATH_THIRDPARTY) is not defined!' ); + } + + require_once PATH_THIRDPARTY . 'smarty/libs/Smarty.class.php'; + $fInfo = pathinfo ( $template ); + + $tplExists = true; + + // file has absolute path + if (substr ( $template, 0, 1 ) != PATH_SEP) { + $template = PATH_TEMPLATE . $template; + } + + // fix for template that have dot in its name but is not a valid + // extension + if (isset ( $fInfo ['extension'] ) && ($fInfo ['extension'] != 'tpl' || $fInfo ['extension'] != 'html')) { + unset ( $fInfo ['extension'] ); + } + + if (! isset ( $fInfo ['extension'] )) { + if (file_exists ( $template . '.tpl' )) { + $template .= '.tpl'; + } elseif (file_exists ( $template . '.html' )) { + $template .= '.html'; + } else { + $tplExists = false; + } + } else { + if (! file_exists ( $template )) { + $tplExists = false; + } + } + + if (! $tplExists) { + throw new Exception ( "Template: $template, doesn't exist!" ); + } + + $smarty = new Smarty (); + $smarty->compile_dir = g::sys_get_temp_dir (); + $smarty->cache_dir = g::sys_get_temp_dir (); + $smarty->config_dir = PATH_THIRDPARTY . 'smarty/configs'; + + $smarty->template_dir = PATH_TEMPLATE; + $smarty->force_compile = true; + + foreach ( $data as $key => $value ) { + $smarty->assign ( $key, $value ); + } + + $smarty->display ( $template ); + } + + /** + * Load Gulliver Classes + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strClass + * @return void + */ + public function LoadSystem($strClass) { + require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); + } + + /** + * Get the temporal directory path on differents O.S. + * i.e. /temp -> linux, C:/Temp -> win + * + * @author + */ + public function sys_get_temp_dir() { + if (! function_exists ( 'sys_get_temp_dir' )) { + // Based on http://www.phpit.net/ + // article/creating-zip-tar-archives-dynamically-php/2/ + // Try to get from environment variable + if (! empty ( $_ENV ['TMP'] )) { + return realpath ( $_ENV ['TMP'] ); + } elseif (! empty ( $_ENV ['TMPDIR'] )) { + return realpath ( $_ENV ['TMPDIR'] ); + } elseif (! empty ( $_ENV ['TEMP'] )) { + return realpath ( $_ENV ['TEMP'] ); + } else { + // Detect by creating a temporary file + // Try to use system's temporary directory as random name + // shouldn't exist + $temp_file = tempnam ( md5 ( uniqid ( rand (), true ) ), '' ); + if ($temp_file) { + $temp_dir = realpath ( dirname ( $temp_file ) ); + unlink ( $temp_file ); + return $temp_dir; + } else { + return false; + } + } + } else { + return sys_get_temp_dir (); + } + } + + /** + * Transform a public URL into a local path. + * + * @author David S. Callizaya S. + * @access public + * @param string $url + * @param string $corvertionTable + * @param string $realPath + * = local path + * @return boolean + */ + public function virtualURI($url, $convertionTable, &$realPath) { + foreach ( $convertionTable as $urlPattern => $localPath ) { + // $urlPattern = addcslashes( $urlPattern , '/'); + $urlPattern = addcslashes ( $urlPattern, './' ); + $urlPattern = '/^' . str_replace ( array ( + '*', + '?' + ), array ( + '.*', + '.?' + ), $urlPattern ) . '$/'; + if (preg_match ( $urlPattern, $url, $match )) { + if ($localPath === false) { + $realPath = $url; + return false; + } + if ($localPath != 'jsMethod') { + $realPath = $localPath . $match [1]; + } else { + $realPath = $localPath; + } + return true; + } + } + $realPath = $url; + return false; + } + + /** + * streaming a file + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @param boolean $download + * @param string $downloadFileName + * @return string + */ + public function streamFile ($file, $download = false, $downloadFileName = '') + { + $folderarray = explode( '/', $file ); + $typearray = explode( '.', basename( $file ) ); + $typefile = $typearray[count( $typearray ) - 1]; + $filename = $file; + + //trick to generate the translation.language.js file , merging two files + if (strtolower( $typefile ) == 'js' && $typearray[0] == 'translation') { + Bootstrap::sendHeaders( $filename, 'text/javascript', $download, $downloadFileName ); + $output = Bootstrap::streamJSTranslationFile( $filename, $typearray[1] ); + echo $output; + return; + } + + //trick to generate the big css file for ext style . + if (strtolower( $typefile ) == 'css' && $folderarray[count( $folderarray ) - 2] == 'css') { + Bootstrap::sendHeaders( $filename, 'text/css', $download, $downloadFileName ); + $output = Bootstrap::streamCSSBigFile( $typearray[0] ); + echo $output; + return; + } + + if (file_exists( $filename )) { + switch (strtolower( $typefile )) { + case 'swf': + Bootstrap::sendHeaders( $filename, 'application/x-shockwave-flash', $download, $downloadFileName ); + break; + case 'js': + Bootstrap::sendHeaders( $filename, 'text/javascript', $download, $downloadFileName ); + break; + case 'htm': + case 'html': + Bootstrap::sendHeaders( $filename, 'text/html', $download, $downloadFileName ); + break; + case 'htc': + Bootstrap::sendHeaders( $filename, 'text/plain', $download, $downloadFileName ); + break; + case 'json': + Bootstrap::sendHeaders( $filename, 'text/plain', $download, $downloadFileName ); + break; + case 'gif': + Bootstrap::sendHeaders( $filename, 'image/gif', $download, $downloadFileName ); + break; + case 'png': + Bootstrap::sendHeaders( $filename, 'image/png', $download, $downloadFileName ); + break; + case 'jpg': + Bootstrap::sendHeaders( $filename, 'image/jpg', $download, $downloadFileName ); + break; + case 'css': + Bootstrap::sendHeaders( $filename, 'text/css', $download, $downloadFileName ); + break; + case 'xml': + Bootstrap::sendHeaders( $filename, 'text/xml', $download, $downloadFileName ); + break; + case 'txt': + Bootstrap::sendHeaders( $filename, 'text/html', $download, $downloadFileName ); + break; + case 'doc': + case 'pdf': + case 'pm': + case 'po': + Bootstrap::sendHeaders( $filename, 'application/octet-stream', $download, $downloadFileName ); + break; + case 'php': + if ($download) { + Bootstrap::sendHeaders( $filename, 'text/plain', $download, $downloadFileName ); + } else { + require_once ($filename); + return; + } + break; + case 'tar': + Bootstrap::sendHeaders( $filename, 'application/x-tar', $download, $downloadFileName ); + break; + default: + //throw new Exception ( "Unknown type of file '$file'. " ); + Bootstrap::sendHeaders( $filename, 'application/octet-stream', $download, $downloadFileName ); + break; + } + } else { + if (strpos( $file, 'gulliver' ) !== false) { + list ($path, $filename) = explode( 'gulliver', $file ); + } + + $_SESSION['phpFileNotFound'] = $file; + Bootstrap::header( "location: /errors/error404.php?l=" . $_SERVER['REQUEST_URI'] ); + } + + if ( substr($filename,-10) == "ext-all.js" ) { + $filename = PATH_GULLIVER_HOME . 'js/ext/min/ext-all.js'; + } + @readfile( $filename ); + } + + /** + * Parsing the URI + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $urlLink + * @return string + */ + static public function parseURI($uri, $isRestRequest = false) { + // *** process the $_POST with magic_quotes enabled + // The magic_quotes_gpc feature has been DEPRECATED as of PHP 5.3.0. + if (get_magic_quotes_gpc () === 1) { + $_POST = g::strip_slashes ( $_POST ); + } + + $aRequestUri = explode ( '/', $uri ); + if ($isRestRequest) { + $args = self::parseRestUri ( $aRequestUri ); + } else { + $args = self::parseNormalUri ( $aRequestUri ); + } + + define ( "SYS_LANG", $args ['SYS_LANG'] ); + define ( "SYS_SKIN", $args ['SYS_SKIN'] ); + define ( 'SYS_COLLECTION', $args ['SYS_COLLECTION'] ); + define ( 'SYS_TARGET', $args ['SYS_TARGET'] ); + + if ($args ['SYS_COLLECTION'] == 'js2') { + print "ERROR"; + die (); + } + } + + /** + * isPMUnderUpdating, Used to set a file flag to check if PM is upgrading. + * + * @setFlag Contains the flag to set or unset the temporary file: + * 0 to delete the temporary file flag + * 1 to set the temporary file flag. + * 2 or bigger to check if the temporary file exists. + * return true if the file exists, otherwise false. + */ + public function isPMUnderUpdating($setFlag = 2) { + if (!defined('PATH_DATA')) { + return false; + } + + $fileCheck = PATH_DATA . "UPDATE.dat"; + if ($setFlag == 0) { + if (file_exists ( $fileCheck )) { + unlink ( $fileCheck ); + } + } elseif ($setFlag == 1) { + $fp = fopen ( $fileCheck, 'w' ); + $line = fputs ( $fp, "true" ); + } + // checking temporary file + if ($setFlag >= 1) { + if (file_exists ( $fileCheck )) { + return true; + } + } + return false; + } + + /** + * parse a smarty template and return teh result as string + * + * @author Erik Amaru Ortiz + * @param $template string + * containing the template filename on /gulliver/templates/ + * directory + * @param $data associative + * array containig the template data + * @return $content string containing the parsed template content + */ + public function parseTemplate($template, $data = array()) { + $content = ''; + + ob_start (); + g::renderTemplate ( $template, $data ); + $content = ob_get_contents (); + ob_get_clean (); + + return $content; + } + + /** + * If the class is not defined by the aplication, it + * attempt to load the class from gulliver.system + * + * @author Fernando Ontiveros Lira , David S. Callizaya + * @access public + * @param string $strClass + * @return void + */ + public function LoadClass($strClass) { + $classfile = Bootstrap::ExpandPath ( "classes" ) . 'class.' . $strClass . '.php'; + if (! file_exists ( $classfile )) { + if (file_exists ( PATH_GULLIVER . 'class.' . $strClass . '.php' )) { + return require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); + } else { + return false; + } + } else { + return require_once ($classfile); + } + } + + /** + * Loads a Class. + * If the class is not defined by the aplication, it + * attempt to load the class from gulliver.system + * + * @author Fernando Ontiveros Lira , David S. Callizaya + * @access public + * @param string $strClass + * @return void + */ + public function LoadThirdParty($sPath, $sFile) { + $classfile = PATH_THIRDPARTY . $sPath . '/' . $sFile . ((substr ( $sFile, 0, - 4 ) !== '.php') ? '.php' : ''); + return require_once ($classfile); + } + + /** + * Function LoadTranslationObject + * It generates a global Translation variable that will be used in all the + * system. + * Per script + * + * @author Hugo Loza. + * @access public + * @param string lang + * @return void + */ + public function LoadTranslationObject($lang = SYS_LANG) { + $defaultTranslations = Array (); + $foreignTranslations = Array (); + + // if the default translations table doesn't exist we can't proceed + if (! is_file ( PATH_LANGUAGECONT . 'translation.en' )) { + return null; + } + // load the translations table + require_once (PATH_LANGUAGECONT . 'translation.en'); + $defaultTranslations = $translation; + + // if some foreign language was requested and its translation file + // exists + if ($lang != 'en' && file_exists ( PATH_LANGUAGECONT . 'translation.' . $lang )) { + require_once (PATH_LANGUAGECONT . 'translation.' . $lang); // load the foreign translations table + $foreignTranslations = $translation; + } + + global $translation; + if (defined ( "SHOW_UNTRANSLATED_AS_TAG" ) && SHOW_UNTRANSLATED_AS_TAG != 0) { + $translation = $foreignTranslations; + } else { + $translation = array_merge ( $defaultTranslations, $foreignTranslations ); + } + return true; + } + + /** + * Render Page + * + * @author Fernando Ontiveros Lira + * @access public + * @param object $objContent + * @param string $strTemplate + * @param string $strSkin + * @return void + */ + public function RenderPage($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = null, $layout = '') { + global $G_CONTENT; + global $G_TEMPLATE; + global $G_SKIN; + global $G_PUBLISH; + + $G_CONTENT = $objContent; + $G_TEMPLATE = $strTemplate; + $G_SKIN = $strSkin; + + try { + $file = Bootstrap::ExpandPath ( 'skinEngine' ) . 'skinEngine.php'; + include $file; + $skinEngine = new SkinEngine ( $G_TEMPLATE, $G_SKIN, $G_CONTENT ); + $skinEngine->setLayout ( $layout ); + $skinEngine->dispatch (); + } catch ( Exception $e ) { + global $G_PUBLISH; + if (is_null ( $G_PUBLISH )) { + $G_PUBLISH = new Publisher (); + } + if (count ( $G_PUBLISH->Parts ) == 1) { + array_shift ( $G_PUBLISH->Parts ); + } + global $oHeadPublisher; + $leimnudInitString = $oHeadPublisher->leimnudInitString; + $oHeadPublisher->clearScripts (); + $oHeadPublisher->leimnudInitString = $leimnudInitString; + $oHeadPublisher->addScriptFile ( '/js/maborak/core/maborak.js' ); + $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', null, array ( + 'MESSAGE' => $e->getMessage () + ) ); + if (class_exists ( 'SkinEngine' )) { + $skinEngine = new SkinEngine ( 'publish', 'blank', '' ); + $skinEngine->dispatch (); + } else { + die ( $e->getMessage () ); + } + } + } + + /** + * SendTemporalMessage + * + * @param string $msgID + * @param string $strType + * @param string $sType + * default value 'LABEL' + * @param date $time + * default value null + * @param integer $width + * default value null + * @param string $customLabels + * default value null + * + * @return void + */ + public function SendTemporalMessage($msgID, $strType, $sType = 'LABEL', $time = null, $width = null, $customLabels = null) { + if (isset ( $width )) { + $_SESSION ['G_MESSAGE_WIDTH'] = $width; + } + if (isset ( $time )) { + $_SESSION ['G_MESSAGE_TIME'] = $time; + } + switch (strtolower ( $sType )) { + case 'label' : + case 'labels' : + $_SESSION ['G_MESSAGE_TYPE'] = $strType; + $_SESSION ['G_MESSAGE'] = nl2br ( Bootstrap::LoadTranslation ( $msgID ) ); + break; + case 'string' : + $_SESSION ['G_MESSAGE_TYPE'] = $strType; + $_SESSION ['G_MESSAGE'] = nl2br ( $msgID ); + break; + } + if ($customLabels != null) { + $message = $_SESSION ['G_MESSAGE']; + foreach ( $customLabels as $key => $val ) { + $message = str_replace ( '{' . nl2br ( $key ) . '}', nl2br ( $val ), $message ); + } + $_SESSION ['G_MESSAGE'] = $message; + } + } + + /** + * Redirect URL + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $parameter + * @return string + */ + public function header($parameter) { + if (defined ( 'ENABLE_ENCRYPT' ) && (ENABLE_ENCRYPT == 'yes') && (substr ( $parameter, 0, 9 ) == 'location:')) { + $url = Bootstrap::encrypt ( substr ( $parameter, 10 ), URL_KEY ); + header ( 'location:' . $url ); + } else { + header ( $parameter ); + } + return; + } + + /** + * Include all model plugin files + * + * LoadAllPluginModelClasses + * + * @author Hugo Loza + * @access public + * @return void + */ + public function LoadAllPluginModelClasses() { + // Get the current Include path, where the plugins directories should be + if (! defined ( 'PATH_SEPARATOR' )) { + define ( 'PATH_SEPARATOR', (substr ( PHP_OS, 0, 3 ) == 'WIN') ? ';' : ':' ); + } + $path = explode ( PATH_SEPARATOR, get_include_path () ); + + foreach ( $path as $possiblePath ) { + if (strstr ( $possiblePath, "plugins" )) { + $baseDir = $possiblePath . 'classes' . PATH_SEP . 'model'; + if (file_exists ( $baseDir )) { + if ($handle = opendir ( $baseDir )) { + while ( false !== ($file = readdir ( $handle )) ) { + if (strpos ( $file, '.php', 1 ) && ! strpos ( $file, 'Peer.php', 1 )) { + require_once ($baseDir . PATH_SEP . $file); + } + } + } + // Include also the extendGulliverClass that could have some + // new definitions for fields + if (file_exists ( $possiblePath . 'classes' . PATH_SEP . 'class.extendGulliver.php' )) { + include_once $possiblePath . 'classes' . PATH_SEP . 'class.extendGulliver.php'; + } + } + } + } + } + + /** + * Expand the path using the path constants + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strPath + * @return string + */ + public function expandPath($strPath = '') { + $res = ""; + $res = PATH_CORE; + if ($strPath != "") { + $res .= $strPath . "/"; + } + return $res; + } + + /** + * This method allow dispatch rest services using 'Restler' thirdparty library + * + * @author Erik Amaru Ortiz + */ + public function dispatchRestService ($uri, $config, $apiClassesPath = '') + { + require_once 'restler/restler.php'; + + $rest = new Restler(); + $rest->setSupportedFormats( 'JsonFormat', 'XmlFormat' ); + // getting all services class + $restClasses = array (); + $restClassesList = Bootstrap::rglob( '*', 0, PATH_CORE . 'services/' ); + foreach ($restClassesList as $classFile) { + if (substr( $classFile, - 4 ) === '.php') { + $restClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; + } + } + if (! empty( $apiClassesPath )) { + $pluginRestClasses = array (); + $restClassesList = Bootstrap::rglob( '*', 0, $apiClassesPath . 'services/' ); + foreach ($restClassesList as $classFile) { + if (substr( $classFile, - 4 ) === '.php') { + $pluginRestClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; + } + } + $restClasses = array_merge( $restClasses, $pluginRestClasses ); + } + // hook to get rest api classes from plugins + if (class_exists( 'PMPluginRegistry' )) { + $pluginRegistry = & PMPluginRegistry::getSingleton(); + $pluginClasses = $pluginRegistry->getRegisteredRestClassFiles(); + $restClasses = array_merge( $restClasses, $pluginClasses ); + } + foreach ($restClasses as $key => $classFile) { + if (! file_exists( $classFile )) { + unset( $restClasses[$key] ); + continue; + } + //load the file, and check if exist the class inside it. + require_once $classFile; + $namespace = 'Services_Rest_'; + $className = str_replace( '.php', '', basename( $classFile ) ); + + // if the core class does not exists try resolve the for a plugin + if (! class_exists( $namespace . $className )) { + $namespace = 'Plugin_Services_Rest_'; + // Couldn't resolve the class name, just skipp it + if (! class_exists( $namespace . $className )) { + unset( $restClasses[$key] ); + continue; + } + } + // verify if there is an auth class implementing 'iAuthenticate' + $classNameAuth = $namespace . $className; + $reflClass = new ReflectionClass( $classNameAuth ); + // that wasn't from plugin + if ($reflClass->implementsInterface( 'iAuthenticate' ) && $namespace != 'Plugin_Services_Rest_') { + // auth class found, set as restler authentication class handler + $rest->addAuthenticationClass( $classNameAuth ); + } else { + // add api class + $rest->addAPIClass( $classNameAuth ); + } + } + //end foreach rest class + // resolving the class for current request + $uriPart = explode( '/', $uri ); + $requestedClass = ''; + if (isset( $uriPart[1] )) { + $requestedClass = ucfirst( $uriPart[1] ); + } + if (class_exists( 'Services_Rest_' . $requestedClass )) { + $namespace = 'Services_Rest_'; + } elseif (class_exists( 'Plugin_Services_Rest_' . $requestedClass )) { + $namespace = 'Plugin_Services_Rest_'; + } else { + $namespace = ''; + } + // end resolv. + // Send additional headers (if exists) configured on rest-config.ini + if (array_key_exists( 'HEADERS', $config )) { + foreach ($config['HEADERS'] as $name => $value) { + header( "$name: $value" ); + } + } + // to handle a request with "OPTIONS" method + if (! empty( $namespace ) && $_SERVER['REQUEST_METHOD'] === 'OPTIONS') { + $reflClass = new ReflectionClass( $namespace . $requestedClass ); + // if the rest class has not a "options" method + if (! $reflClass->hasMethod( 'options' )) { + header( 'Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEADERS' ); + header( 'Access-Control-Allow-Headers: authorization, content-type' ); + header( "Access-Control-Allow-Credentials", "false" ); + header( 'Access-Control-Max-Age: 60' ); + exit(); + } + } + // override global REQUEST_URI to pass to Restler library + $_SERVER['REQUEST_URI'] = '/' . strtolower( $namespace ) . ltrim( $uri, '/' ); + // handle the rest request + $rest->handle(); + } + + /** + * function to calculate the time used to render a page + */ + public function logTimeByPage() { + if (! defined ( PATH_DATA )) { + return false; + } + + $serverAddr = $_SERVER ['SERVER_ADDR']; + global $startingTime; + $endTime = microtime ( true ); + $time = $endTime - $startingTime; + $fpt = fopen ( PATH_DATA . 'log/time.log', 'a' ); + fwrite ( $fpt, sprintf ( "%s.%03d %15s %s %5.3f %s\n", date ( 'Y-m-d H:i:s' ), $time, getenv ( 'REMOTE_ADDR' ), substr ( $serverAddr, - 4 ), $time, $_SERVER ['REQUEST_URI'] ) ); + fclose ( $fpt ); + } + + /** + * streaming a big JS file with small js files + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @param boolean $download + * @param string $downloadFileName + * @return string + */ + public function streamJSTranslationFile($filename, $locale = 'en') { + header ( 'Content-Type: text/javascript' ); + + if (! Bootstrap::LoadTranslationObject ( $locale )) { + header ( 'Cache-Control: no-cache' ); + header ( 'Pragma: no-cache' ); + return; + } + + global $translation; + + // if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE + // behaivor. + $userAgent = strtolower ( $_SERVER ['HTTP_USER_AGENT'] ); + if (file_exists ( $filename )) { + $mtime = filemtime ( $filename ); + } else { + $mtime = date ( 'U' ); + } + + $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; + header ( 'Pragma: cache' ); + header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); + header ( "Last-Modified: " . $gmt_mtime ); + header ( 'Cache-Control: public' ); + header ( "Expires: " . gmdate ( "D, d M Y H:i:s", time () + 30 * 60 * 60 * 24 ) . " GMT" ); // 1 + // month + if (isset ( $_SERVER ['HTTP_IF_MODIFIED_SINCE'] )) { + if ($_SERVER ['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { + header ( 'HTTP/1.1 304 Not Modified' ); + exit (); + } + } + + if (isset ( $_SERVER ['HTTP_IF_NONE_MATCH'] )) { + if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { + header ( "HTTP/1.1 304 Not Modified" ); + exit (); + } + } + + return 'var TRANSLATIONS = ' . Bootstrap::json_encode ( $translation ) . ";\n"; + } + + /** + * streaming a big JS file with small js files + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @return string + */ + public function streamCSSBigFile ($filename) + { + header( 'Content-Type: text/css' ); + + //First get Skin info + $filenameParts = explode( "-", $filename ); + $skinName = $filenameParts[0]; + $skinVariant = "skin"; + + if (isset( $filenameParts[1] )) { + $skinVariant = strtolower( $filenameParts[1] ); + } + + $configurationFile = ''; + if ($skinName == "jscolors") { + $skinName = "classic"; + } + if ($skinName == "xmlcolors") { + $skinName = "classic"; + } + if ($skinName == "classic") { + $configurationFile = Bootstrap::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP . 'config.xml'; + } else { + $configurationFile = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml'; + + if (! is_file( $configurationFile )) { + $configurationFile = Bootstrap::ExpandPath( "skinEngine" ) . $skinName . PATH_SEP . 'config.xml'; + } + } + + $mtime = date ( 'U' ); + $gmt_mtime = gmdate( "D, d M Y H:i:s", $mtime ) . " GMT"; + header( 'Pragma: cache' ); + header( 'ETag: "' . md5( $mtime . $filename ) . '"' ); + header( "Last-Modified: " . $gmt_mtime ); + header( 'Cache-Control: public' ); + header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + 30 * 60 * 60 * 24 ) . " GMT" ); //1 month + //header("Expires: " . gmdate("D, d M Y H:i:s", time () + 60*60*24 ) . " GMT"); //1 day - tempor + if (isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] )) { + if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { + header( 'HTTP/1.1 304 Not Modified' ); + exit(); + } + } + + if (isset( $_SERVER['HTTP_IF_NONE_MATCH'] )) { + if (str_replace( '"', '', stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) == md5( $mtime . $filename )) { + header( "HTTP/1.1 304 Not Modified" ); + exit(); + } + } + + //Read Configuration File + $xmlConfiguration = file_get_contents( $configurationFile ); + $xmlConfigurationObj = Bootstrap::xmlParser( $xmlConfiguration ); + $baseSkinDirectory = dirname( $configurationFile ); + $directorySize = Bootstrap::getDirectorySize( $baseSkinDirectory ); + $mtime = $directorySize['maxmtime']; + + //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. + //$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); + + $outputHeader = "/* Autogenerated CSS file by gulliver framework \n"; + $outputHeader .= " Skin: $filename\n"; + $outputHeader .= " Configuration: $configurationFile\n"; + $mtimeNow = date( 'U' ); + $gmt_mtimeNow = gmdate( "D, d M Y H:i:s", $mtimeNow ) . " GMT"; + $outputHeader .= " Date: $gmt_mtimeNow*/\n"; + $output = ""; + + //Base files + switch (strtolower( $skinVariant )) { + case "extjs": + //Base + $baseCSSPath = PATH_SKIN_ENGINE . "base" . PATH_SEP . "baseCss" . PATH_SEP; + $output .= file_get_contents( $baseCSSPath . 'ext-all-notheme.css' ); + //$output .= file_get_contents ( $publicExtPath . 'ext-all.css' ); + + //Classic Skin + $extJsSkin = 'xtheme-gray'; + + break; + default: + break; + } + + //Get Browser Info + $infoBrowser = Bootstrap::get_current_browser(); + $browserName = $infoBrowser['browser_working']; + if (isset( $infoBrowser[$browserName . '_data'] )) { + if ($infoBrowser[$browserName . '_data'][0] != "") { + $browserName = $infoBrowser[$browserName . '_data'][0]; + } + } + + //Read Configuration File + $xmlConfiguration = file_get_contents ( $configurationFile ); + $xmlConfigurationObj = Bootstrap::xmlParser($xmlConfiguration); + + $skinFilesArray=$xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['cssFiles']['__CONTENT__'][$skinVariant]['__CONTENT__']['cssFile'] ; + foreach ($skinFilesArray as $keyFile => $cssFileInfo) { + $enabledBrowsers=explode(",",$cssFileInfo['__ATTRIBUTES__']['enabledBrowsers']); + $disabledBrowsers=explode(",",$cssFileInfo['__ATTRIBUTES__']['disabledBrowsers']); + + if (((in_array($browserName, $enabledBrowsers))||(in_array('ALL', $enabledBrowsers)))&&(!(in_array($browserName, $disabledBrowsers)))) { + if ($cssFileInfo['__ATTRIBUTES__']['file'] == 'rtl.css') { + Bootstrap::LoadClass('serverConfiguration'); + $oServerConf =& serverConf::getSingleton(); + if (!(defined('SYS_LANG'))) { + if (isset($_SERVER['HTTP_REFERER'])) { + $syss = explode('://', $_SERVER['HTTP_REFERER']); + $sysObjets = explode('/', $syss['1']); + $sysLang = $sysObjets['2']; + } else { + $sysLang = 'en'; + } + } else { + $sysLang = SYS_LANG; + } + if ($oServerConf->isRtl($sysLang)) { + $output .= file_get_contents ( $baseSkinDirectory . PATH_SEP.'css'.PATH_SEP.$cssFileInfo['__ATTRIBUTES__']['file'] ); + } + } else { + $output .= file_get_contents ( $baseSkinDirectory . PATH_SEP.'css'.PATH_SEP.$cssFileInfo['__ATTRIBUTES__']['file'] ); + } + } + } + + //Remove comments.. + $regex = array ("`^([\t\s]+)`ism" => '',"`^\/\*(.+?)\*\/`ism" => "","`([\n\A;]+)\/\*(.+?)\*\/`ism" => "$1","`([\n\A;\s]+)//(.+?)[\n\r]`ism" => "$1\n","`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism" => "\n" ); + $output = preg_replace( array_keys( $regex ), $regex, $output ); + $output = $outputHeader . $output; + + return $output; + } + + /** + * sendHeaders + * + * @param string $filename + * @param string $contentType + * default value '' + * @param boolean $download + * default value false + * @param string $downloadFileName + * default value '' + * + * @return void + */ + public function sendHeaders($filename, $contentType = '', $download = false, $downloadFileName = '') { + if ($download) { + if ($downloadFileName == '') { + $aAux = explode ( '/', $filename ); + $downloadFileName = $aAux [count ( $aAux ) - 1]; + } + header ( 'Content-Disposition: attachment; filename="' . $downloadFileName . '"' ); + } + header ( 'Content-Type: ' . $contentType ); + + // if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE + // behaivor. + $userAgent = strtolower ( $_SERVER ['HTTP_USER_AGENT'] ); + if (preg_match ( "/msie/i", $userAgent )) { + // if ( ereg("msie", $userAgent)) { + header ( 'Pragma: cache' ); + + if (file_exists ( $filename )) { + $mtime = filemtime ( $filename ); + } else { + $mtime = date ( 'U' ); + } + $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; + header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); + header ( "Last-Modified: " . $gmt_mtime ); + header ( 'Cache-Control: public' ); + header ( "Expires: " . gmdate ( "D, d M Y H:i:s", time () + 60 * 10 ) . " GMT" ); // ten + // minutes + return; + } + + if (! $download) { + + header ( 'Pragma: cache' ); + + if (file_exists ( $filename )) { + $mtime = filemtime ( $filename ); + } else { + $mtime = date ( 'U' ); + } + $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; + header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); + header ( "Last-Modified: " . $gmt_mtime ); + header ( 'Cache-Control: public' ); + header ( "Expires: " . gmdate ( "D, d M Y H:i:s", time () + 90 * 60 * 60 * 24 ) . " GMT" ); + if (isset ( $_SERVER ['HTTP_IF_MODIFIED_SINCE'] )) { + if ($_SERVER ['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { + header ( 'HTTP/1.1 304 Not Modified' ); + exit (); + } + } + + if (isset ( $_SERVER ['HTTP_IF_NONE_MATCH'] )) { + if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { + header ( "HTTP/1.1 304 Not Modified" ); + exit (); + } + } + } + } + + /** + * Get checksum from multiple files + * + * @author erik amaru ortiz + */ + public function getCheckSum ($files) + { + Bootstrap::LoadClass( 'system' ); + $key = System::getVersion(); + + if (! is_array( $files )) { + $tmp = $files; + $files = array (); + $files[0] = $tmp; + } + + $checkSum = ''; + foreach ($files as $file) { + if (is_file( $file )) { + $checkSum .= md5_file( $file ); + } + } + return md5( $checkSum . $key ); + } + + /** + * Get checksum from multiple files + * + * @author erik amaru ortiz + */ + public function getCacheFileNameByPattern ($path, $pattern) + { + if ($file = glob( $path . $pattern )) { + preg_match( '/[a-f0-9]{32}/', $file[0], $match ); + } else { + $file[0] = ''; + } + return array ('filename' => $file[0],'checksum' => (isset( $match[0] ) ? $match[0] : '')); + } + + /** + * trimSourceCodeFile + * + * @param string $filename + * + * @return string $output + */ + public function trimSourceCodeFile ($filename) + { + $handle = fopen( $filename, "r" ); + $lastChar = ''; + $firstChar = ''; + $content = ''; + $line = ''; + + if ($handle) { + while (! feof( $handle )) { + //$line = trim( fgets($handle, 16096) ) . "\n" ; + $line = fgets( $handle, 16096 ); + $content .= $line; + } + fclose( $handle ); + } + return $content; + + $index = 0; + $output = ''; + while ($index < strlen( $content )) { + $car = $content[$index]; + $index ++; + if ($car == '/' && isset( $content[$index] ) && $content[$index] == '*') { + $endComment = false; + $index ++; + while ($endComment == false && $index < strlen( $content )) { + if ($content[$index] == '*' && isset( $content[$index + 1] ) && $content[$index + 1] == '/') { + $endComment = true; + $index ++; + } + $index ++; + } + $car = ''; + } + $output .= $car; + } + return $output; + } + + + /** + * strip_slashes + * @param vVar + */ + public function strip_slashes ($vVar) + { + if (is_array( $vVar )) { + foreach ($vVar as $sKey => $vValue) { + if (is_array( $vValue )) { + Bootstrap::strip_slashes( $vVar[$sKey] ); + } else { + $vVar[$sKey] = stripslashes( $vVar[$sKey] ); + } + } + } else { + $vVar = stripslashes( $vVar ); + } + + return $vVar; + } + + + /** + * Function LoadTranslation + * + * @author Aldo Mauricio Veliz Valenzuela. + * @access public + * @param eter string msgID + * @param eter string file + * @param eter array data // erik: associative array within data input to replace for formatted string i.e "any messsage {replaced_label} that contains a replace label" + * @return string + */ + public function LoadTranslation ($msgID, $lang = SYS_LANG, $data = null) + { + global $translation; + + // if the second parameter $lang is an array does mean it was especified to use as data + if (is_array( $lang )) { + $data = $lang; + $lang = SYS_LANG; + } + + if (isset( $translation[$msgID] )) { + $translationString = preg_replace( "[\n|\r|\n\r]", ' ', $translation[$msgID] ); + + if (isset( $data ) && is_array( $data )) { + foreach ($data as $label => $value) { + $translationString = str_replace( '{' . $label . '}', $value, $translationString ); + } + } + + return $translationString; + } else { + if (defined( "UNTRANSLATED_MARK" )) { + $untranslatedMark = strip_tags( UNTRANSLATED_MARK ); + } else { + $untranslatedMark = "**"; + } + return $untranslatedMark . $msgID . $untranslatedMark; + } + + } + + /** + * Recursive version of glob php standard function + * + * @author Erik Amaru Ortiz + * + * @param $path path to scan recursively the write permission + * @param $flags to notive glob function + * @param $pattern pattern to filter some especified files + * @return array containing the recursive glob results + */ + public function rglob($pattern = '*', $flags = 0, $path = '') + { + $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); + $files = glob($path.$pattern, $flags); + foreach ($paths as $path) { + $files = array_merge($files, Bootstrap::rglob($pattern, $flags, $path)); + } + return $files; + } + + /** + * JSON encode + * + * @author Erik A.O. + */ + public function json_encode($Json) + { + if ( function_exists('json_encode') ) { + return json_encode($Json); + } else { + Bootstrap::LoadThirdParty('pear/json', 'class.json'); + $oJSON = new Services_JSON(); + return $oJSON->encode($Json); + } + } + + /** + * JSON decode + * + * @author Erik A.O. + */ + public function json_decode($Json) + { + if (function_exists('json_decode')) { + return json_decode($Json); + } else { + Bootstrap::LoadThirdParty('pear/json', 'class.json'); + $oJSON = new Services_JSON(); + return $oJSON->decode($Json); + } + } + + + /** + * ************************************* init ********************************************** + * Xml parse collection functions + * Returns a associative array within the xml structure and data + * + * @author Erik Amaru Ortiz + */ + public function xmlParser (&$string) + { + $parser = xml_parser_create(); + xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 ); + xml_parse_into_struct( $parser, $string, $vals, $index ); + + $mnary = array (); + $ary = &$mnary; + foreach ($vals as $r) { + $t = $r['tag']; + if ($r['type'] == 'open') { + if (isset( $ary[$t] )) { + if (isset( $ary[$t][0] )) { + $ary[$t][] = array (); + } else { + $ary[$t] = array ($ary[$t],array () ); + } + $cv = &$ary[$t][count( $ary[$t] ) - 1]; + } else { + $cv = &$ary[$t]; + } + if (isset( $r['attributes'] )) { + foreach ($r['attributes'] as $k => $v) { + $cv['__ATTRIBUTES__'][$k] = $v; + } + } + // note by gustavo cruz gustavo[at]colosa[dot]com + // minor adjustments to validate if an open node have a value attribute. + // for example a dropdown has many childs, but also can have a value attribute. + if (isset( $r['value'] ) && trim( $r['value'] ) != '') { + $cv['__VALUE__'] = $r['value']; + } + // end added code + $cv['__CONTENT__'] = array (); + $cv['__CONTENT__']['_p'] = &$ary; + $ary = &$cv['__CONTENT__']; + + } elseif ($r['type'] == 'complete') { + if (isset( $ary[$t] )) { + if (isset( $ary[$t][0] )) { + $ary[$t][] = array (); + } else { + $ary[$t] = array ($ary[$t],array ()); + } + $cv = &$ary[$t][count( $ary[$t] ) - 1]; + } else { + $cv = &$ary[$t]; + } + if (isset( $r['attributes'] )) { + foreach ($r['attributes'] as $k => $v) { + $cv['__ATTRIBUTES__'][$k] = $v; + } + } + $cv['__VALUE__'] = (isset( $r['value'] ) ? $r['value'] : ''); + + } elseif ($r['type'] == 'close') { + $ary = &$ary['_p']; + } + } + + self::_del_p( $mnary ); + + $obj_resp->code = xml_get_error_code( $parser ); + $obj_resp->message = xml_error_string( $obj_resp->code ); + $obj_resp->result = $mnary; + xml_parser_free( $parser ); + + return $obj_resp; + } + + /** + * + * @param unknown_type $path + * @param unknown_type $maxmtime + * @return Ambigous + */ + public function getDirectorySize ($path, $maxmtime = 0) + { + $totalsize = 0; + $totalcount = 0; + $dircount = 0; + if ($handle = opendir( $path )) { + while (false !== ($file = readdir( $handle ))) { + $nextpath = $path . '/' . $file; + if ($file != '.' && $file != '..' && ! is_link( $nextpath ) && $file != '.svn') { + if (is_dir( $nextpath )) { + $dircount ++; + $result = Bootstrap::getDirectorySize( $nextpath, $maxmtime ); + $totalsize += $result['size']; + $totalcount += $result['count']; + $dircount += $result['dircount']; + $maxmtime = $result['maxmtime'] > $maxmtime ? $result['maxmtime'] : $maxmtime; + } elseif (is_file( $nextpath )) { + $totalsize += filesize( $nextpath ); + $totalcount ++; + + $mtime = filemtime( $nextpath ); + if ($mtime > $maxmtime) { + $maxmtime = $mtime; + } + } + } + } + } + closedir( $handle ); + $total['size'] = $totalsize; + $total['count'] = $totalcount; + $total['dircount'] = $dircount; + $total['maxmtime'] = $maxmtime; + + return $total; + } + + + /** + * _del_p + * + * @param string &$ary + * + * @return void + */ + // _Internal: Remove recursion in result array + public function _del_p (&$ary) + { + foreach ($ary as $k => $v) { + if ($k === '_p') { + unset( $ary[$k] ); + } elseif (is_array( $ary[$k] )) { + self::_del_p( $ary[$k] ); + } + } + } + + /** + * Refactor function + * @author Ralph A. + * @return multitype:array containing browser name and type + */ + public function get_current_browser() + { + static $a_full_assoc_data, $a_mobile_data, $browser_user_agent; + static $browser_working, $moz_type, $webkit_type; + + //initialize all variables with default values to prevent error + $a_full_assoc_data = ''; + $a_mobile_data = ''; + $browser_temp = ''; + $browser_working = ''; + $mobile_test = ''; + $moz_type = ''; + $ua_type = 'bot';// default to bot since you never know with bots + $webkit_type = ''; + + /* + make navigator user agent string lower case to make sure all versions get caught + isset protects against blank user agent failure. tolower also lets the script use + strstr instead of stristr, which drops overhead slightly. + */ + $browser_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); + + // known browsers, list will be updated routinely, check back now and then + $a_browser_types = array( + array( 'opera', true, 'op', 'bro' ), + array( 'msie', true, 'ie', 'bro' ), + // webkit before gecko because some webkit ua strings say: like gecko + array( 'webkit', true, 'webkit', 'bro' ), + // konq will be using webkit soon + array( 'konqueror', true, 'konq', 'bro' ), + // covers Netscape 6-7, K-Meleon, Most linux versions, uses moz array below + array( 'gecko', true, 'moz', 'bro' ), + array( 'netpositive', false, 'netp', 'bbro' ),// beos browser + array( 'lynx', false, 'lynx', 'bbro' ), // command line browser + array( 'elinks ', false, 'elinks', 'bbro' ), // new version of links + array( 'elinks', false, 'elinks', 'bbro' ), // alternate id for it + array( 'links2', false, 'links2', 'bbro' ), // alternate links version + array( 'links ', false, 'links', 'bbro' ), // old name for links + array( 'links', false, 'links', 'bbro' ), // alternate id for it + array( 'w3m', false, 'w3m', 'bbro' ), // open source browser, more features than lynx/links + array( 'webtv', false, 'webtv', 'bbro' ),// junk ms webtv + array( 'amaya', false, 'amaya', 'bbro' ),// w3c browser + array( 'dillo', false, 'dillo', 'bbro' ),// linux browser, basic table support + array( 'ibrowse', false, 'ibrowse', 'bbro' ),// amiga browser + array( 'icab', false, 'icab', 'bro' ),// mac browser + array( 'crazy browser', true, 'ie', 'bro' ),// uses ie rendering engine + // search engine spider bots: + array( 'bingbot', false, 'bing', 'bot' ),// bing + array( 'exabot', false, 'exabot', 'bot' ),// exabot + array( 'googlebot', false, 'google', 'bot' ),// google + array( 'google web preview', false, 'googlewp', 'bot' ),// google preview + array( 'mediapartners-google', false, 'adsense', 'bot' ),// google adsense + array( 'yahoo-verticalcrawler', false, 'yahoo', 'bot' ),// old yahoo bot + array( 'yahoo! slurp', false, 'yahoo', 'bot' ), // new yahoo bot + array( 'yahoo-mm', false, 'yahoomm', 'bot' ), // gets Yahoo-MMCrawler and Yahoo-MMAudVid bots + array( 'inktomi', false, 'inktomi', 'bot' ), // inktomi bot + array( 'slurp', false, 'inktomi', 'bot' ), // inktomi bot + array( 'fast-webcrawler', false, 'fast', 'bot' ),// Fast AllTheWeb + array( 'msnbot', false, 'msn', 'bot' ),// msn search + array( 'ask jeeves', false, 'ask', 'bot' ), //jeeves/teoma + array( 'teoma', false, 'ask', 'bot' ),//jeeves teoma + array( 'scooter', false, 'scooter', 'bot' ),// altavista + array( 'openbot', false, 'openbot', 'bot' ),// openbot, from taiwan + array( 'ia_archiver', false, 'ia_archiver', 'bot' ),// ia archiver + array( 'zyborg', false, 'looksmart', 'bot' ),// looksmart + array( 'almaden', false, 'ibm', 'bot' ),// ibm almaden web crawler + array( 'baiduspider', false, 'baidu', 'bot' ),// Baiduspider asian search spider + array( 'psbot', false, 'psbot', 'bot' ),// psbot image crawler + array( 'gigabot', false, 'gigabot', 'bot' ),// gigabot crawler + array( 'naverbot', false, 'naverbot', 'bot' ),// naverbot crawler, bad bot, block + array( 'surveybot', false, 'surveybot', 'bot' ),// + array( 'boitho.com-dc', false, 'boitho', 'bot' ),//norwegian search engine + array( 'objectssearch', false, 'objectsearch', 'bot' ),// open source search engine + array( 'answerbus', false, 'answerbus', 'bot' ),// http://www.answerbus.com/, web questions + array( 'sohu-search', false, 'sohu', 'bot' ),// chinese media company, search component + array( 'iltrovatore-setaccio', false, 'il-set', 'bot' ), + // various http utility libaries + array( 'w3c_validator', false, 'w3c', 'lib' ), // uses libperl, make first + array( 'wdg_validator', false, 'wdg', 'lib' ), // + array( 'libwww-perl', false, 'libwww-perl', 'lib' ), + array( 'jakarta commons-httpclient', false, 'jakarta', 'lib' ), + array( 'python-urllib', false, 'python-urllib', 'lib' ), + // download apps + array( 'getright', false, 'getright', 'dow' ), + array( 'wget', false, 'wget', 'dow' ),// open source downloader, obeys robots.txt + // netscape 4 and earlier tests, put last so spiders don't get caught + array( 'mozilla/4.', false, 'ns', 'bbro' ), + array( 'mozilla/3.', false, 'ns', 'bbro' ), + array( 'mozilla/2.', false, 'ns', 'bbro' ) + ); + /* + moz types array + note the order, netscape6 must come before netscape, which is how netscape 7 id's itself. + rv comes last in case it is plain old mozilla. firefox/netscape/seamonkey need to be later + Thanks to: http://www.zytrax.com/tech/web/firefox-history.html + */ + $a_moz_types = array( 'bonecho', 'camino', 'epiphany', 'firebird', 'flock', 'galeon', 'iceape', 'icecat', 'k-meleon', 'minimo', 'multizilla', 'phoenix', 'songbird', 'swiftfox', 'seamonkey', 'shiretoko', 'iceweasel', 'firefox', 'minefield', 'netscape6', 'netscape', 'rv' ); + + /* + webkit types, this is going to expand over time as webkit b$browser_namerowsers spread + konqueror is probably going to move to webkit, so this is preparing for that + It will now default to khtml. gtklauncher is the temp id for epiphany, might + change. Defaults to applewebkit, and will all show the webkit number. + */ + $a_webkit_types = array( 'arora', 'chrome', 'epiphany', 'gtklauncher', 'konqueror', 'midori', 'omniweb', 'safari', 'uzbl', 'applewebkit', 'webkit' ); + + /* + run through the browser_types array, break if you hit a match, if no match, assume old browser + or non dom browser. + */ + $i_count = count( $a_browser_types ); + for ($i = 0; $i < $i_count; $i++) { + //unpacks browser array, assigns to variables, need to not assign til found in string + $browser_temp = $a_browser_types[$i][0];// text string to id browser from array + if ( strstr( $browser_user_agent, $browser_temp ) ) { + $browser_working = $a_browser_types[$i][2];// working name for browser + $ua_type = $a_browser_types[$i][3];// sets whether bot or browser + + switch ( $browser_working ) { + case 'moz': + // this is to pull out specific mozilla versions, firebird, netscape etc.. + $j_count = count( $a_moz_types ); + for ($j = 0; $j < $j_count; $j++) { + if ( strstr( $browser_user_agent, $a_moz_types[$j] ) ) { + $moz_type = $a_moz_types[$j]; + break; + } + } + if ( $moz_type == 'rv' ) { + $moz_type = 'mozilla'; + } + break; + case 'webkit': + // this is to pull out specific webkit versions, safari, google-chrome etc.. + $j_count = count( $a_webkit_types ); + for ($j = 0; $j < $j_count; $j++) { + if (strstr( $browser_user_agent, $a_webkit_types[$j])) { + $webkit_type = $a_webkit_types[$j]; + break; + } + } + break; + default: + break; + } + break; + } + } + + $mobile_test = Bootstrap::check_is_mobile( $browser_user_agent ); + if ( $mobile_test ) { + $a_mobile_data = Bootstrap::get_mobile_data( $browser_user_agent ); + $ua_type = 'mobile'; + } + + $a_full_assoc_data = array( + 'browser_working' => $browser_working, + 'ua_type' => $ua_type, + 'moz_data' => array($moz_type), + 'webkit_data' => array($webkit_type), + 'mobile_data' => array($a_mobile_data), + ); + + return $a_full_assoc_data; + } + + /** + * track total script execution time + */ + public function script_time () + { + static $script_time; + $elapsed_time = ''; + /* + note that microtime(true) requires php 5 or greater for microtime(true) + */ + if (sprintf( "%01.1f", phpversion() ) >= 5) { + if (is_null( $script_time )) { + $script_time = microtime( true ); + } else { + // note: (string)$var is same as strval($var) + // $elapsed_time = (string)( microtime(true) - $script_time ); + $elapsed_time = (microtime( true ) - $script_time); + $elapsed_time = sprintf( "%01.8f", $elapsed_time ); + $script_time = null; // can't unset a static variable + return $elapsed_time; + } + } + } + + /** + * + * @param unknown_type $pv_browser_user_agent + * @param unknown_type $pv_search_string + * @param unknown_type $pv_b_break_last + * @param unknown_type $pv_extra_search + * @return string + */ + public function get_item_version($pv_browser_user_agent, $pv_search_string, $pv_b_break_last = '', $pv_extra_search = '') + { + $substring_length = 15; + $start_pos = 0; // set $start_pos to 0 for first iteration + $string_working_number = ''; + for ($i = 0; $i < 4; $i++) { + //start the search after the first string occurrence + if (strpos( $pv_browser_user_agent, $pv_search_string, $start_pos ) !== false) { + $start_pos = strpos( $pv_browser_user_agent, $pv_search_string, $start_pos ) + strlen( $pv_search_string ); + if (!$pv_b_break_last || ( $pv_extra_search && strstr( $pv_browser_user_agent, $pv_extra_search ) )) { + break; + } + } else { + break; + } + } + + $start_pos += Bootstrap::get_set_count( 'get' ); + $string_working_number = substr( $pv_browser_user_agent, $start_pos, $substring_length ); + $string_working_number = substr( $string_working_number, 0, strcspn($string_working_number, ' );/') ); + if (!is_numeric( substr( $string_working_number, 0, 1 ))) { + $string_working_number = ''; + } + return $string_working_number; + } + + /** + * + * @param unknown_type $pv_type + * @param unknown_type $pv_value + */ + public function get_set_count($pv_type, $pv_value = '') + { + static $slice_increment; + $return_value = ''; + switch ( $pv_type ) { + case 'get': + if ( is_null( $slice_increment ) ) { + $slice_increment = 1; + } + $return_value = $slice_increment; + $slice_increment = 1; // reset to default + return $return_value; + break; + case 'set': + $slice_increment = $pv_value; + break; + } + } + + /** + * gets which os from the browser string + */ + public function get_os_data ($pv_browser_string, $pv_browser_name, $pv_version_number) + { + // initialize variables + $os_working_type = ''; + $os_working_number = ''; + /* + packs the os array. Use this order since some navigator user agents will put 'macintosh' + in the navigator user agent string which would make the nt test register true + */ + $a_mac = array( 'intel mac', 'ppc mac', 'mac68k' );// this is not used currently + // same logic, check in order to catch the os's in order, last is always default item + $a_unix_types = array( 'dragonfly', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'unixware', 'solaris', 'sunos', 'sun4', 'sun5', 'suni86', 'sun', 'irix5', 'irix6', 'irix', 'hpux9', 'hpux10', 'hpux11', 'hpux', 'hp-ux', 'aix1', 'aix2', 'aix3', 'aix4', 'aix5', 'aix', 'sco', 'unixware', 'mpras', 'reliant', 'dec', 'sinix', 'unix' ); + // only sometimes will you get a linux distro to id itself... + $a_linux_distros = array( 'ubuntu', 'kubuntu', 'xubuntu', 'mepis', 'xandros', 'linspire', 'winspire', 'jolicloud', 'sidux', 'kanotix', 'debian', 'opensuse', 'suse', 'fedora', 'redhat', 'slackware', 'slax', 'mandrake', 'mandriva', 'gentoo', 'sabayon', 'linux' ); + $a_linux_process = array ( 'i386', 'i586', 'i686' );// not use currently + // note, order of os very important in os array, you will get failed ids if changed + $a_os_types = array( 'android', 'blackberry', 'iphone', 'palmos', 'palmsource', 'symbian', 'beos', 'os2', 'amiga', 'webtv', 'mac', 'nt', 'win', $a_unix_types, $a_linux_distros ); + + //os tester + $i_count = count( $a_os_types ); + for ($i = 0; $i < $i_count; $i++) { + // unpacks os array, assigns to variable $a_os_working + $os_working_data = $a_os_types[$i]; + /* + assign os to global os variable, os flag true on success + !strstr($pv_browser_string, "linux" ) corrects a linux detection bug + */ + if (!is_array($os_working_data) && strstr($pv_browser_string, $os_working_data ) && !strstr( $pv_browser_string, "linux")) { + $os_working_type = $os_working_data; + + switch ($os_working_type) { + // most windows now uses: NT X.Y syntax + case 'nt': + if (strstr( $pv_browser_string, 'nt 6.1' )) { + $os_working_number = 6.1; + } elseif (strstr( $pv_browser_string, 'nt 6.0')) { + $os_working_number = 6.0; + } elseif (strstr( $pv_browser_string, 'nt 5.2')) { + $os_working_number = 5.2; + } elseif (strstr( $pv_browser_string, 'nt 5.1') || strstr( $pv_browser_string, 'xp')) { + $os_working_number = 5.1;// + } elseif (strstr( $pv_browser_string, 'nt 5') || strstr( $pv_browser_string, '2000')) { + $os_working_number = 5.0; + } elseif (strstr( $pv_browser_string, 'nt 4')) { + $os_working_number = 4; + } elseif (strstr( $pv_browser_string, 'nt 3')) { + $os_working_number = 3; + } + break; + case 'win': + if (strstr( $pv_browser_string, 'vista')) { + $os_working_number = 6.0; + $os_working_type = 'nt'; + } elseif ( strstr( $pv_browser_string, 'xp')) { + $os_working_number = 5.1; + $os_working_type = 'nt'; + } elseif ( strstr( $pv_browser_string, '2003')) { + $os_working_number = 5.2; + $os_working_type = 'nt'; + } + elseif ( strstr( $pv_browser_string, 'windows ce' ) )// windows CE + { + $os_working_number = 'ce'; + $os_working_type = 'nt'; + } + elseif ( strstr( $pv_browser_string, '95' ) ) + { + $os_working_number = '95'; + } + elseif ( ( strstr( $pv_browser_string, '9x 4.9' ) ) || ( strstr( $pv_browser_string, ' me' ) ) ) + { + $os_working_number = 'me'; + } + elseif ( strstr( $pv_browser_string, '98' ) ) + { + $os_working_number = '98'; + } + elseif ( strstr( $pv_browser_string, '2000' ) )// windows 2000, for opera ID + { + $os_working_number = 5.0; + $os_working_type = 'nt'; + } + break; + case 'mac': + if (strstr($pv_browser_string, 'os x')) { + if (strstr($pv_browser_string, 'os x ')) { + $os_working_number = str_replace( '_', '.', Bootstrap::get_item_version( $pv_browser_string, 'os x' ) ); + } else { + $os_working_number = 10; + } + } elseif ( ( $pv_browser_name == 'saf' ) || ( $pv_browser_name == 'cam' ) || + ( ( $pv_browser_name == 'moz' ) && ( $pv_version_number >= 1.3 ) ) || + ( ( $pv_browser_name == 'ie' ) && ( $pv_version_number >= 5.2 ) ) ) { + $os_working_number = 10; + } + break; + case 'iphone': + $os_working_number = 10; + break; + default: + break; + } + break; + } elseif ( is_array( $os_working_data ) && ( $i == ( $i_count - 2 ) ) ) { + $j_count = count($os_working_data); + for ($j = 0; $j < $j_count; $j++) { + if (strstr( $pv_browser_string, $os_working_data[$j])) { + $os_working_type = 'unix'; //if the os is in the unix array, it's unix, obviously... + $os_working_number = ( $os_working_data[$j] != 'unix' ) ? $os_working_data[$j] : '';// assign sub unix version from the unix array + break; + } + } + } elseif (is_array( $os_working_data ) && ( $i == ( $i_count - 1 ))) { + $j_count = count($os_working_data); + for ($j = 0; $j < $j_count; $j++) { + if ( strstr( $pv_browser_string, $os_working_data[$j] )) { + $os_working_type = 'lin'; + // assign linux distro from the linux array, there's a default + //search for 'lin', if it's that, set version to '' + $os_working_number = ( $os_working_data[$j] != 'linux' ) ? $os_working_data[$j] : ''; + break; + } + } + } + } + + // pack the os data array for return to main function + $a_os_data = array( $os_working_type, $os_working_number ); + + return $a_os_data; + } + + /** + * + * @param unknown_type $pv_browser_user_agent + * @return string + */ + public function check_is_mobile($pv_browser_user_agent) + { + $mobile_working_test = ''; + $a_mobile_search = array( + 'android', 'epoc', 'linux armv', 'palmos', 'palmsource', 'windows ce', 'windows phone os', 'symbianos', 'symbian os', 'symbian', 'webos', + // devices - ipod before iphone or fails + 'benq', 'blackberry', 'danger hiptop', 'ddipocket', ' droid', 'ipad', 'ipod', 'iphone', 'kindle', 'lge-cx', 'lge-lx', 'lge-mx', 'lge vx', 'lge ', 'lge-', 'lg;lx', 'nintendo wii', 'nokia', 'palm', 'pdxgw', 'playstation', 'sagem', 'samsung', 'sec-sgh', 'sharp', 'sonyericsson', 'sprint', 'zune', 'j-phone', 'n410', 'mot 24', 'mot-', 'htc-', 'htc_', 'htc ', 'sec-', 'sie-m', 'sie-s', 'spv ', 'vodaphone', 'smartphone', 'armv', 'midp', 'mobilephone', + // browsers + 'avantgo', 'blazer', 'elaine', 'eudoraweb', 'iemobile', 'minimo', 'mobile safari', 'mobileexplorer', 'opera mobi', 'opera mini', 'netfront', 'opwv', 'polaris', 'semc-browser', 'up.browser', 'webpro', 'wms pie', 'xiino', + // services - astel out of business + 'astel', 'docomo', 'novarra-vision', 'portalmmm', 'reqwirelessweb', 'vodafone' + ); + + // then do basic mobile type search, this uses data from: get_mobile_data() + $j_count = count( $a_mobile_search ); + for ($j = 0; $j < $j_count; $j++) { + if (strstr( $pv_browser_user_agent, $a_mobile_search[$j] )) { + $mobile_working_test = $a_mobile_search[$j]; + break; + } + } + return $mobile_working_test; + } + + /** + * + * @param unknown_type $pv_browser_user_agent + */ + public function get_mobile_data ($pv_browser_user_agent) + { + $mobile_browser = ''; + $mobile_browser_number = ''; + $mobile_device = ''; + $mobile_device_number = ''; + $mobile_os = ''; // will usually be null, sorry + $mobile_os_number = ''; + $mobile_server = ''; + $mobile_server_number = ''; + + $a_mobile_browser = array( 'avantgo', 'blazer', 'elaine', 'eudoraweb', 'iemobile', 'minimo', 'mobile safari', 'mobileexplorer', 'opera mobi', 'opera mini', 'netfront', 'opwv', 'polaris', 'semc-browser', 'up.browser', 'webpro', 'wms pie', 'xiino' ); + $a_mobile_device = array( 'benq', 'blackberry', 'danger hiptop', 'ddipocket', ' droid', 'htc_dream', 'htc espresso', 'htc hero', 'htc halo', 'htc huangshan', 'htc legend', 'htc liberty', 'htc paradise', 'htc supersonic', 'htc tattoo', 'ipad', 'ipod', 'iphone', 'kindle', 'lge-cx', 'lge-lx', 'lge-mx', 'lge vx', 'lg;lx', 'nintendo wii', 'nokia', 'palm', 'pdxgw', 'playstation', 'sagem', 'samsung', 'sec-sgh', 'sharp', 'sonyericsson', 'sprint', 'zunehd', 'zune', 'j-phone', 'milestone', 'n410', 'mot 24', 'mot-', 'htc-', 'htc_', 'htc ', 'lge ', 'lge-', 'sec-', 'sie-m', 'sie-s', 'spv ', 'smartphone', 'armv', 'midp', 'mobilephone' ); + $a_mobile_os = array( 'android', 'epoc', 'cpu os', 'iphone os', 'palmos', 'palmsource', 'windows phone os', 'windows ce', 'symbianos', 'symbian os', 'symbian', 'webos', 'linux armv' ); + $a_mobile_server = array( 'astel', 'docomo', 'novarra-vision', 'portalmmm', 'reqwirelessweb', 'vodafone' ); + + $k_count = count( $a_mobile_browser ); + for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_browser[$k] )) { + $mobile_browser = $a_mobile_browser[$k]; + $mobile_browser_number = Bootstrap::get_item_version( $pv_browser_user_agent, $mobile_browser ); + break; + } + } + $k_count = count( $a_mobile_device ); + for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_device[$k] )) { + $mobile_device = trim ( $a_mobile_device[$k], '-_' ); // but not space trims yet + if ($mobile_device == 'blackberry') { + Bootstrap::get_set_count( 'set', 0 ); + } + $mobile_device_number = Bootstrap::get_item_version( $pv_browser_user_agent, $mobile_device ); + $mobile_device = trim( $mobile_device ); // some of the id search strings have white space + break; + } + } + $k_count = count( $a_mobile_os ); + for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_os[$k] )) { + $mobile_os = $a_mobile_os[$k]; + $mobile_os_number = str_replace( '_', '.', Bootstrap::get_item_version( $pv_browser_user_agent, $mobile_os ) ); + break; + } + } + $k_count = count( $a_mobile_server ); + for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_server[$k] )) { + $mobile_server = $a_mobile_server[$k]; + $mobile_server_number = Bootstrap::get_item_version( $pv_browser_user_agent, $mobile_server ); + break; + } + } + // just for cases where we know it's a mobile device already + if (!$mobile_os && ( $mobile_browser || $mobile_device || $mobile_server ) && strstr( $pv_browser_user_agent, 'linux' ) ) { + $mobile_os = 'linux'; + $mobile_os_number = Bootstrap::get_item_version( $pv_browser_user_agent, 'linux' ); + } + + $a_mobile_data = array( $mobile_device, $mobile_browser, $mobile_browser_number, $mobile_os, $mobile_os_number, $mobile_server, $mobile_server_number, $mobile_device_number ); + return $a_mobile_data; + } + + /** + * + * @param unknown_type $requestUri + */ + public function parseRestUri ($requestUri) + { + $args = array (); + //$args['SYS_TEMP'] = $requestUri[1]; + define( 'SYS_TEMP', $requestUri[2] ); + $restUri = ''; + + for ($i = 3; $i < count( $requestUri ); $i ++) { + $restUri .= '/' . $requestUri[$i]; + } + + $args['SYS_LANG'] = 'en'; // TODO, this can be set from http header + $args['SYS_SKIN'] = ''; + $args['SYS_COLLECTION'] = ''; + $args['SYS_TARGET'] = $restUri; + + return $args; + } + + /** + * + * @param unknown_type $aRequestUri + * @return multitype:string mixed Ambigous + */ + public function parseNormalUri ($aRequestUri) + { + if (substr( $aRequestUri[1], 0, 3 ) == 'sys') { + define( 'SYS_TEMP', substr( $aRequestUri[1], 3 ) ); + } else { + define( "ENABLE_ENCRYPT", 'yes' ); + define( 'SYS_TEMP', $aRequestUri[1] ); + $plain = '/sys' . SYS_TEMP; + + for ($i = 2; $i < count( $aRequestUri ); $i ++) { + $decoded = Bootstrap::decrypt( urldecode( $aRequestUri[$i] ), URL_KEY ); + if ($decoded == 'sWì›') { + $decoded = $VARS[$i]; //this is for the string "../" + } + $plain .= '/' . $decoded; + } + $_SERVER["REQUEST_URI"] = $plain; + } + + $work = explode( '?', $_SERVER["REQUEST_URI"] ); + + if (count( $work ) > 1) { + define( 'SYS_CURRENT_PARMS', $work[1] ); + } else { + define( 'SYS_CURRENT_PARMS', '' ); + } + + define( 'SYS_CURRENT_URI', $work[0] ); + + if (! defined( 'SYS_CURRENT_PARMS' )) { + define( 'SYS_CURRENT_PARMS', $work[1] ); + } + + $preArray = explode( '&', SYS_CURRENT_PARMS ); + $buffer = explode( '.', $work[0] ); + + if (count( $buffer ) == 1) { + $buffer[1] = ''; + } + + //request type + define( 'REQUEST_TYPE', ($buffer[1] != "" ? $buffer[1] : 'html') ); + + $toparse = substr( $buffer[0], 1, strlen( $buffer[0] ) - 1 ); + $uriVars = explode( '/', $toparse ); + + unset( $work ); + unset( $buffer ); + unset( $toparse ); + array_shift( $uriVars ); + + $args = array (); + $args['SYS_LANG'] = array_shift( $uriVars ); + $args['SYS_SKIN'] = array_shift( $uriVars ); + $args['SYS_COLLECTION'] = array_shift( $uriVars ); + $args['SYS_TARGET'] = array_shift( $uriVars ); + + //to enable more than 2 directories...in the methods structure + while (count( $uriVars ) > 0) { + $args['SYS_TARGET'] .= '/' . array_shift( $uriVars ); + } + + /* Fix to prevent use uxs skin outside siplified interface, + because that skin is not compatible with others interfaces*/ + if ($args['SYS_SKIN'] == 'uxs' && $args['SYS_COLLECTION'] != 'home' && $args['SYS_COLLECTION'] != 'cases') { + $config = System::getSystemConfiguration(); + $args['SYS_SKIN'] = $config['default_skin']; + } + + return $args; + } + + /** + * * Encrypt and decrypt functions *** + */ + /** + * Encrypt string + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $string + * @param string $key + * @return string + */ + public function encrypt ($string, $key) + { + //print $string; + // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { + if (strpos( $string, '|', 0 ) !== false) { + return $string; + } + $result = ''; + for ($i = 0; $i < strlen( $string ); $i ++) { + $char = substr( $string, $i, 1 ); + $keychar = substr( $key, ($i % strlen( $key )) - 1, 1 ); + $char = chr( ord( $char ) + ord( $keychar ) ); + $result .= $char; + } + + $result = base64_encode( $result ); + $result = str_replace( '/', '°', $result ); + $result = str_replace( '=', '', $result ); + return $result; + } + + /** + * Decrypt string + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $string + * @param string $key + * @return string + */ + public function decrypt ($string, $key) + { + // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { + //if (strpos($string, '|', 0) !== false) return $string; + $result = ''; + $string = str_replace( '°', '/', $string ); + $string_jhl = explode( "?", $string ); + $string = base64_decode( $string ); + $string = base64_decode( $string_jhl[0] ); + + for ($i = 0; $i < strlen( $string ); $i ++) { + $char = substr( $string, $i, 1 ); + $keychar = substr( $key, ($i % strlen( $key )) - 1, 1 ); + $char = chr( ord( $char ) - ord( $keychar ) ); + $result .= $char; + } + if (! empty( $string_jhl[1] )) { + $result .= '?' . $string_jhl[1]; + } + return $result; + } + + /** + * + * @param unknown_type $model + * @return unknown + */ + public function getModel($model) + { + require_once "classes/model/$model.php"; + return new $model(); + } + + /** + * Create an encrypted unique identifier based on $id and the selected scope id. + * + * @author David S. Callizaya S. + * @access public + * @param string $scope + * @param string $id + * @return string + */ + public function createUID ($scope, $id) + { + $e = $scope . $id; + $e = Bootstrap::encrypt( $e, URL_KEY ); + $e = str_replace( array ('+','/','=' + ), array ('__','_','___' + ), base64_encode( $e ) ); + return $e; + } + + /** + * (Create an encrypted unique identificator based on $id and the selected scope id.) ^-1 + * getUIDName + * + * @author David S. Callizaya S. + * @access public + * @param string $id + * @param string $scope + * @return string + */ + public function getUIDName ($uid, $scope = '') + { + $e = str_replace( array ('=','+','/' + ), array ('___','__','_' + ), $uid ); + $e = base64_decode( $e ); + $e = Bootstrap::decrypt( $e, URL_KEY ); + $e = substr( $e, strlen( $scope ) ); + return $e; + } + + /** + * Merge 2 arrays + * + * @author Fernando Ontiveros Lira + * @access public + * @return array + */ + public function array_merges () + { + $array = array (); + $arrays = & func_get_args(); + foreach ($arrays as $array_i) { + if (is_array( $array_i )) { + Bootstrap::array_merge_2( $array, $array_i ); + } + } + return $array; + } + + /** + * Merge 2 arrays + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $array + * @param string $array_i + * @return array + */ + public function array_merge_2 (&$array, &$array_i) + { + foreach ($array_i as $k => $v) { + if (is_array( $v )) { + if (! isset( $array[$k] )) { + $array[$k] = array (); + } + Bootstrap::array_merge_2( $array[$k], $v ); + } else { + if (isset( $array[$k] ) && is_array( $array[$k] )) { + $array[$k][0] = $v; + } else { + if (isset( $array ) && ! is_array( $array )) { + $temp = $array; + $array = array(); + $array[0] = $temp; + } + $array[$k] = $v; + } + } + } + } + + /* Returns a sql string with @@parameters replaced with its values defined + * in array $result using the next notation: + * NOTATION: + * @@ Quoted parameter acording to the SYSTEM's Database + * @Q Double quoted parameter \\ \" + * @q Single quoted parameter \\ \' + * @% URL string + * @# Non-quoted parameter + * @! Evaluate string : Replace the parameters in value and then in the sql string + * @fn() Evaluate string with the function "fn" + * @author David Callizaya + */ + public function replaceDataField ($sqlString, $result, $DBEngine = 'mysql') + { + if (! is_array( $result )) { + $result = array (); + } + $result = $result + Bootstrap::getSystemConstants(); + $__textoEval = ""; + $u = 0; + //$count=preg_match_all('/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))/',$sqlString,$match,PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); + $count = preg_match_all( '/\@(?:([\@\%\#\=\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $sqlString, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ); + if ($count) { + for ($r = 0; $r < $count; $r ++) { + if (! isset( $result[$match[2][$r][0]] )) { + $result[$match[2][$r][0]] = ''; + } + if (! is_array( $result[$match[2][$r][0]] )) { + $__textoEval .= substr( $sqlString, $u, $match[0][$r][1] - $u ); + $u = $match[0][$r][1] + strlen( $match[0][$r][0] ); + //Mysql quotes scape + if (($match[1][$r][0] == '@') && (isset( $result[$match[2][$r][0]] ))) { + $__textoEval .= "\"" . Bootstrap::sqlEscape( $result[$match[2][$r][0]], $DBEngine ) . "\""; + continue; + } + //URL encode + if (($match[1][$r][0]=='%')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=urlencode($result[$match[2][$r][0]]); + continue; + } + //Double quoted parameter + if (($match[1][$r][0]=='Q')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.='"'.addcslashes($result[$match[2][$r][0]],'\\"').'"'; + continue; + } + //Single quoted parameter + if (($match[1][$r][0]=='q')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.="'".addcslashes($result[$match[2][$r][0]],'\\\'')."'"; + continue; + } + //Substring (Sub replaceDataField) + if (($match[1][$r][0]=='!')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=Bootstrap::replaceDataField($result[$match[2][$r][0]],$result); + continue; + } + //Call function + if (($match[1][$r][0]==='')&&($match[2][$r][0]==='')&&($match[3][$r][0]!=='')) { + eval('$strAux = ' . $match[3][$r][0] . '(\'' . addcslashes(Bootstrap::replaceDataField(stripslashes($match[4][$r][0]),$result),'\\\'') . '\');'); + + if ($match[3][$r][0] == "Bootstrap::LoadTranslation") { + $arraySearch = array("'"); + $arrayReplace = array("\\'"); + $strAux = str_replace($arraySearch, $arrayReplace, $strAux); + } + + $__textoEval .= $strAux; + continue; + } + //Non-quoted + if (($match[1][$r][0]=='#')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=Bootstrap::replaceDataField($result[$match[2][$r][0]],$result); + continue; + } + //Non-quoted = + if (($match[1][$r][0]=='=')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=Bootstrap::replaceDataField($result[$match[2][$r][0]],$result); + continue; + } + } + } + } + $__textoEval.=substr($sqlString,$u); + return $__textoEval; + } + + /** + * microtime_float + * + * @return array_sum(explode(' ',microtime())) + */ + /*public static*/ + public function microtime_float () + { + return array_sum( explode( ' ', microtime() ) ); + } + + /** + * Return the System defined constants and Application variables + * Constants: SYS_* + * Sessions : USER_* , URS_* + */ + public function getSystemConstants($params = null) + { + $t1 = Bootstrap::microtime_float(); + $sysCon = array(); + + if (defined("SYS_LANG")) { + $sysCon["SYS_LANG"] = SYS_LANG; + } + + if (defined("SYS_SKIN")) { + $sysCon["SYS_SKIN"] = SYS_SKIN; + } + + if (defined("SYS_SYS")) { + $sysCon["SYS_SYS"] = SYS_SYS; + } + + $sysCon["APPLICATION"] = (isset($_SESSION["APPLICATION"]))? $_SESSION["APPLICATION"] : ""; + $sysCon["PROCESS"] = (isset($_SESSION["PROCESS"]))? $_SESSION["PROCESS"] : ""; + $sysCon["TASK"] = (isset($_SESSION["TASK"]))? $_SESSION["TASK"] : ""; + $sysCon["INDEX"] = (isset($_SESSION["INDEX"]))? $_SESSION["INDEX"] : ""; + $sysCon["USER_LOGGED"] = (isset($_SESSION["USER_LOGGED"]))? $_SESSION["USER_LOGGED"] : ""; + $sysCon["USR_USERNAME"] = (isset($_SESSION["USR_USERNAME"]))? $_SESSION["USR_USERNAME"] : ""; + + //############################################################################################### + // Added for compatibility betweek aplication called from web Entry that uses just WS functions + //############################################################################################### + + if ($params != null) { + if (isset($params->option)) { + switch ($params->option) { + case "STORED SESSION": + if (isset($params->SID)) { + Bootstrap::LoadClass("sessions"); + + $oSessions = new Sessions($params->SID); + $sysCon = array_merge($sysCon, $oSessions->getGlobals()); + } + break; + } + } + + if (isset($params->appData) && is_array($params->appData)) { + $sysCon["APPLICATION"] = $params->appData["APPLICATION"]; + $sysCon["PROCESS"] = $params->appData["PROCESS"]; + $sysCon["TASK"] = $params->appData["TASK"]; + $sysCon["INDEX"] = $params->appData["INDEX"]; + + if (empty($sysCon["USER_LOGGED"])) { + $sysCon["USER_LOGGED"] = $params->appData["USER_LOGGED"]; + $sysCon["USR_USERNAME"] = $params->appData["USR_USERNAME"]; + } + } + } + + return $sysCon; + } + + /** + * Escapes special characters in a string for use in a SQL statement + * @author David Callizaya + * @param string $sqlString The string to be escaped + * @param string $DBEngine Target DBMS + */ + public function sqlEscape ($sqlString, $DBEngine = DB_ADAPTER) + { + $DBEngine = DB_ADAPTER; + switch ($DBEngine) { + case 'mysql': + $con = Propel::getConnection( 'workflow' ); + return mysql_real_escape_string( stripslashes( $sqlString ), $con->getResource() ); + break; + case 'myxml': + $sqlString = str_replace( '"', '""', $sqlString ); + return str_replace( "'", "''", $sqlString ); + break; + default: + return addslashes( stripslashes( $sqlString ) ); + break; + } + } + + /** + * Load a template + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strTemplateName + * @return void + */ + public function LoadTemplate ($strTemplateName) + { + if ($strTemplateName == '') { + return; + } + + $temp = $strTemplateName . ".php"; + $file = Bootstrap::ExpandPath( 'templates' ) . $temp; + // Check if its a user template + if (file_exists( $file )) { + //require_once( $file ); + include ($file); + } else { + // Try to get the global system template + $file = PATH_TEMPLATE . PATH_SEP . $temp; + //require_once( $file ); + if (file_exists( $file )) { + include ($file); + } + } + } + + /** + * verify path + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strPath path + * @param boolean $createPath if true this public function will create the path + * @return boolean + */ + public function verifyPath ($strPath, $createPath = false) + { + $folder_path = strstr( $strPath, '.' ) ? dirname( $strPath ) : $strPath; + + if (file_exists( $strPath ) || @is_dir( $strPath )) { + return true; + } else { + if ($createPath) { + //TODO:: Define Environment constants: Devel (0777), Production (0770), ... + Bootstrap::mk_dir( $strPath, 0777 ); + } else { + return false; + } + } + return false; + } + + /** + * getformatedDate + * + * @param date $date + * @param string $format default value 'yyyy-mm-dd', + * @param string $lang default value '' + * + * @return string $ret + */ + public function getformatedDate ($date, $format = 'yyyy-mm-dd', $lang = '') + { + /** + * ****************************************************************************************************** + * if the year is 2008 and the format is yy then -> 08 + * if the year is 2008 and the format is yyyy then -> 2008 + * + * if the month is 05 and the format is mm then -> 05 + * if the month is 05 and the format is m and the month is less than 10 then -> 5 else digit normal + * if the month is 05 and the format is MM or M then -> May + * + * if the day is 5 and the format is dd then -> 05 + * if the day is 5 and the format is d and the day is less than 10 then -> 5 else digit normal + * if the day is 5 and the format is DD or D then -> five + * ******************************************************************************************************* + */ + + //scape the literal + switch ($lang) { + case 'es': + $format = str_replace( ' de ', '[of]', $format ); + break; + } + + //first we must formatted the string + $format = str_replace( 'yyyy', '{YEAR}', $format ); + $format = str_replace( 'yy', '{year}', $format ); + + $format = str_replace( 'mm', '{YONTH}', $format ); + $format = str_replace( 'm', '{month}', $format ); + $format = str_replace( 'M', '{XONTH}', $format ); + + $format = str_replace( 'dd', '{DAY}', $format ); + $format = str_replace( 'd', '{day}', $format ); + + $format = str_replace( 'h', '{h}', $format ); + $format = str_replace( 'i', '{i}', $format ); + $format = str_replace( 's', '{s}', $format ); + + if ($lang === '') { + $lang = defined( SYS_LANG ) ? SYS_LANG : 'en'; + } + $aux = explode( ' ', $date ); //para dividir la fecha del dia + $date = explode( '-', isset( $aux[0] ) ? $aux[0] : '00-00-00' ); //para obtener los dias, el mes, y el año. + $time = explode( ':', isset( $aux[1] ) ? $aux[1] : '00:00:00' ); //para obtener las horas, minutos, segundos. + + + $year = (int) ((isset( $date[0] )) ? $date[0] : '0'); //year + $month = (int) ((isset( $date[1] )) ? $date[1] : '0'); //month + $day = (int) ((isset( $date[2] )) ? $date[2] : '0'); //day + + + $h = isset( $time[0] ) ? $time[0] : '00'; //hour + $i = isset( $time[1] ) ? $time[1] : '00'; //minute + $s = isset( $time[2] ) ? $time[2] : '00'; //second + + + $MONTHS = Array (); + for ($i = 1; $i <= 12; $i ++) { + $MONTHS[$i] = Bootstrap::LoadTranslation( "ID_MONTH_$i", $lang ); + } + + $d = (int) $day; + $dd = Bootstrap::complete_field( $day, 2, 1 ); + + //missing D + + + $M = $MONTHS[$month]; + $m = (int) $month; + $mm = Bootstrap::complete_field( $month, 2, 1 ); + + $yy = substr( $year, strlen( $year ) - 2, 2 ); + $yyyy = $year; + + $names = array ('{day}','{DAY}','{month}','{YONTH}','{XONTH}','{year}','{YEAR}','{h}','{i}','{s}' + ); + $values = array ($d,$dd,$m,$mm,$M,$yy,$yyyy,$h,$i,$s + ); + + $ret = str_replace( $names, $values, $format ); + + //recovering the original literal + switch ($lang) { + case 'es': + $ret = str_replace( '[of]', ' de ', $ret ); + break; + } + + return $ret; + } + + /** + * + * @author Erik Amaru Ortiz + * @name complete_field($string, $lenght, $type={1:number/2:string/3:float}) + */ + public function complete_field ($campo, $long, $tipo) + { + $campo = trim( $campo ); + switch ($tipo) { + case 1: //number + $long = $long - strlen( $campo ); + for ($i = 1; $i <= $long; $i ++) { + $campo = "0" . $campo; + } + break; + case 2: //string + $long = $long - strlen( $campo ); + for ($i = 1; $i <= $long; $i ++) { + $campo = " " . $campo; + } + break; + case 3: //float + if ($campo != "0") { + $vals = explode( ".", $long ); + $ints = $vals[0]; + + $decs = $vals[1]; + + $valscampo = explode( ".", $campo ); + + $intscampo = $valscampo[0]; + $decscampo = $valscampo[1]; + + $ints = $ints - strlen( $intscampo ); + + for ($i = 1; $i <= $ints; $i ++) { + $intscampo = "0" . $intscampo; + } + + //los decimales pueden ser 0 uno o dos + $decs = $decs - strlen( $decscampo ); + for ($i = 1; $i <= $decs; $i ++) { + $decscampo = $decscampo . "0"; + } + + $campo = $intscampo . "." . $decscampo; + } else { + $vals = explode( ".", $long ); + $ints = $vals[0]; + $decs = $vals[1]; + + $campo = ""; + for ($i = 1; $i <= $ints; $i ++) { + $campo = "0" . $campo; + } + $campod = ""; + for ($i = 1; $i <= $decs; $i ++) { + $campod = "0" . $campod; + } + + $campo = $campo . "." . $campod; + } + break; + } + return $campo; + } + + + /** + * evalJScript + * + * @param string $c + * + * @return void + */ + public function evalJScript ($c) + { + print ("") ; + } + + /** + * Generate random number + * + * @author Fernando Ontiveros Lira + * @access public + * @return int + */ + public function generateUniqueID () + { + do { + $sUID = str_replace( '.', '0', uniqid( rand( 0, 999999999 ), true ) ); + } while (strlen( $sUID ) != 32); + return $sUID; + //return strtoupper(substr(uniqid(rand(0, 9), false),0,14)); + } + + /** + * Encrypt URL + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $urlLink + * @return string + */ + public function encryptlink ($url) + { + if (defined( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes') { + return urlencode( Bootstrap::encrypt( $url, URL_KEY ) ); + } else { + return $url; + } + } + } diff --git a/gulliver/system/class.form.php b/gulliver/system/class.form.php index 1c335d25c..b0d1c1a8e 100755 --- a/gulliver/system/class.form.php +++ b/gulliver/system/class.form.php @@ -236,6 +236,14 @@ class Form extends XmlForm foreach ($newValues[$k] as $j => $item) { if ($this->fields[$k]->validateValue( $newValues[$k][$j], $this )) { $this->values[$k][$j] = $newValues[$k][$j]; + + switch ($this->fields[$k]->type) { + case "link": + if (isset($newValues[$k . "_label"][$j])) { + $this->values[$k . "_label"][$j] = $newValues[$k . "_label"][$j]; + } + break; + } } } if ((sizeof( $this->values[$k] ) === 1) && ($v->type !== 'grid') && isset( $this->values[$k][0] )) { @@ -247,6 +255,14 @@ class Form extends XmlForm } else { if ($this->fields[$k]->validateValue( $newValues[$k], $this )) { $this->values[$k] = $newValues[$k]; + + switch ($this->fields[$k]->type) { + case "link": + if (isset($newValues[$k . "_label"])) { + $this->values[$k . "_label"] = $newValues[$k . "_label"]; + } + break; + } } } } @@ -331,7 +347,6 @@ class Form extends XmlForm if (($v->type != 'submit')) { if ($v->type != 'file') { if (array_key_exists( $k, $newValues )) { - switch ($v->type) { case 'radiogroup': $values[$k] = $newValues[$k]; @@ -414,6 +429,10 @@ class Form extends XmlForm } } break; + case "link": + $values[$k] = $newValues[$k]; + $values[$k . "_label"] = $newValues[$k . "_label"]; + break; case 'grid': foreach ($newValues[$k] as $j => $item) { if (is_array( $item )) { @@ -457,6 +476,10 @@ class Form extends XmlForm } } break; + case "link": + $values[$k][$j] = $newValues[$k][$j]; + $values[$k][$j][$kk . "_label"] = $newValues[$k][$j][$kk . "_label"]; + break; default: //If there are no dropdowns previously setted and the evaluated field is not a dropdown //only then rewritte the $values diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index acaadbfd0..60abaaf81 100755 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -214,231 +214,6 @@ class G { return array_sum( explode( ' ', microtime() ) ); } - /* custom error functions */ - - /** - * &setFatalErrorHandler - * - * @param string $newFatalErrorHandler default value null - * - * @return boolean true - */ - public function &setFatalErrorHandler ($newFatalErrorHandler = null) - { - if (isset( $newFatalErrorHandler )) { - set_error_handler( $newFatalErrorHandler ); - } else { - ob_start( array ('G','fatalErrorHandler' - ) ); - } - return true; - } - - /** - * setErrorHandler - * - * @param string setErrorHandler - * @param object $newCustomErrorHandler - * - * @return boolean true - */ - /*public static*/ - public function setErrorHandler ($newCustomErrorHandler = null) - { - if (isset( $newCustomErrorHandler )) { - set_error_handler( $newCustomErrorHandler ); - } else { - set_error_handler( array ("G","customErrorHandler") ); - } - return true; - } - - /** - * fatalErrorHandler - * - * @param string $buffer - * - * @return string $errorBox or $buffer - */ - /*public static*/ - public function fatalErrorHandler ($buffer) - { - // The ereg function has been DEPRECATED as of PHP 5.3.0. - // if (ereg("(error:)(.+)(:)(.+)(/", "", $regs[2] ); - G::customErrorLog( 'FATAL', $err, '', 0, '' ); - $ip_addr = G::getIpAddress(); - $errorBox = "
" . "" . "" . " " . "
ERROR CAUGHT check log file
IP address: $ip_addr
"; - return $errorBox; - } - return $buffer; - } - /** - * customErrorHandler - * - * @param string $errno - * @param string $msg - * @param string $file - * @param string $line - * @param string $context - * - * @return void - */ - /*public static*/ - public function customErrorHandler ($errno, $msg, $file, $line, $context) - { - switch ($errno) { - case E_ERROR: - case E_USER_ERROR: - $type = "FATAL"; - G::customErrorLog( $type, $msg, $file, $line ); - G::verboseError( $type, $errno, $msg, $file, $line, $context ); - if (defined( "ERROR_SHOW_SOURCE_CODE" ) && ERROR_SHOW_SOURCE_CODE) { - G::showErrorSource( $type, $msg, $file, $line, "#c00000" ); - } - die(); - break; - case E_WARNING: - case E_USER_WARNING: - $type = "WARNING"; - G::customErrorLog( $type, $msg, $file, $line ); - break; - case E_NOTICE: - case E_USER_NOTICE: - $type = "NOTICE"; - if (defined( "ERROR_LOG_NOTICE_ERROR" ) && ERROR_LOG_NOTICE_ERROR) { - G::customErrorLog( $type, $msg, $file, $line ); - } - break; - case E_STRICT: - $type = "STRICT"; //dont show STRICT Errors - break; - default: - $type = "ERROR ($errno)"; - G::customErrorLog( $type, $msg, $file, $line ); - break; - } - if (defined( "ERROR_SHOW_SOURCE_CODE" ) && ERROR_SHOW_SOURCE_CODE && $errno != E_STRICT) { - G::showErrorSource( $type, $msg, $file, $line ); - } - } - - /** - * public function showErrorSource - * - * @author David S. Callizaya S. - * @access public - * @param eter string type - * @param eter string msg - * @param eter string file - * @param eter string line - * @return string - */ - public function showErrorSource ($type, $msg, $file, $line) - { - global $__src_array; - $line_offset = 3; - - if (! isset( $__src_array[$file] )) { - $__src_array[$file] = @file( $file ); - } - if (! $__src_array[$file]) { - return; - } - if ($line - $line_offset < 1) { - $start = 1; - } else { - $start = $line - $line_offset; - } - if ($line + $line_offset > count( $__src_array[$file] )) { - $end = count( $__src_array[$file] ); - } else { - $end = $line + $line_offset; - } - print "
"; - print ""; - print " - - - "; - for ($i = $start; $i <= $end; $i ++) { - $str = @highlight_string( "", true ); - - $pos1 = strpos( $str, "<?" ); - $pos2 = strrpos( $str, "?>" ); - - $str = substr( $str, 0, $pos1 ) . substr( $str, $pos1 + 5, $pos2 - ($pos1 + 5) ) . substr( $str, $pos2 + 5 ); - - ($i == $line) ? $bgcolor = "bgcolor=#ffccaa" : $bgcolor = "bgcolor=#ffffff"; - print " - "; - } - - print "
$type: $msg
File: $file
$i$str

"; - } - - /** - * customErrorLog - * - * @param string $type - * @param string $msg - * @param string $file - * @param string $line - * - * @return void - */ - public function customErrorLog ($type, $msg, $file, $line) - { - global $HTTP_X_FORWARDED_FOR, $REMOTE_ADDR, $HTTP_USER_AGENT, $REQUEST_URI; - - $ip_addr = G::getIpAddress(); - - if (defined( 'APPLICATION_CODE' )) { - $name = APPLICATION_CODE; - } else { - $name = "php"; - } - if ($file != '') { - $msg .= " in $file:$line "; - } - $date = date( 'Y-m-d H:i:s' ); - $REQUEST_URI = getenv( 'REQUEST_URI' ); - $HTTP_USER_AGENT = getenv( 'HTTP_USER_AGENT' ); - error_log( "[$date] [$ip_addr] [$name] $type: $msg [$HTTP_USER_AGENT] URI: $REQUEST_URI", 0 ); - } - - /** - * verboseError - * - * @param string $type - * @param string $errno - * @param string $msg - * @param string $file - * @param string $line - * @param string $context - * - * @return void - */ - /*public static*/ - public function verboseError ($type, $errno, $msg, $file, $line, $context) - { - global $SERVER_ADMIN; - - print "

Error!

"; - print "An error occurred while executing this script. Please - contact the $SERVER_ADMIN to - report this error."; - print "

"; - print "Here is the information provided by the script:"; - print "


";
-        print "Error type: $type (code: $errno)
"; - print "Error message: $msg
"; - print "Script name and line number of error: $file:$line
"; - print "Variable context when error occurred:
"; - print_r( $context ); - print "

"; - } /** * * Encrypt and decrypt functions *** @@ -1331,129 +1106,10 @@ class G G::header( "location: /errors/error404.php?l=" . $_SERVER['REQUEST_URI'] ); } - switch (strtolower( $typefile )) { - case "js": - $paths = explode( '/', $filename ); - $jsName = $paths[count( $paths ) - 1]; - $output = ''; - $pathJs = PATH_GULLIVER_HOME . PATH_SEP . 'js' . PATH_SEP; - switch ($jsName) { - case 'draw2d.js': - $filename = PATH_GULLIVER_HOME . 'js/ext/min/draw2d.js'; - @readfile( $filename ); - /* this code is commented, because in run time we dont generate the file ext-all.js - the file was generate once and the committed to git. If there are changes in the included - files we need to regenerate the file manually. - $cachePath = PATH_C . 'ExtJs' . PATH_SEP; - $checksum = G::getCheckSum( array ($pathJs . 'ext/wz_jsgraphics.js',$pathJs . 'ext/mootools.js',$pathJs . 'ext/moocanvas.js' - ) ); - - $cf = $cachePath . "ext-draw2d-cache.$checksum.js"; - $cfStored = G::getCacheFileNameByPattern( $cachePath, 'ext-draw2d-cache.*.js' ); - //error_log("draw2d.js ".$checksum ."==". $cfStored['checksum']); - if (is_file( $cfStored['filename'] ) && $checksum == $cfStored['checksum']) { - $output = file_get_contents( $cf ); - } else { - if (is_file( $cfStored['filename'] )) { - @unlink( $cfStored['filename'] ); - } - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/wz_jsgraphics.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/mootools.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/moocanvas.js' ) ); - $output .= file_get_contents( $pathJs . 'ext/draw2d.js' ); //already minified - file_put_contents( $cf, $output ); - } - */ - break; - case 'ext-all.js': - $filename = PATH_GULLIVER_HOME . 'js/ext/min/ext-all.js'; - @readfile( $filename ); - /* this code is commented, because in run time we dont generate the file ext-all.js - the file was generate once and the committed to git. If there are changes in the included - files we need to regenerate the file manually. - $cachePath = PATH_C . 'ExtJs' . PATH_SEP; - $checksum = G::getCheckSum( array ($pathJs . 'ext/pmos-common.js',$pathJs . 'ext/ux/miframe.js',$pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js',$pathJs . 'ext/ux.statusbar/ext-statusbar.js',$pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' - ) ); - - $cfStored = G::getCacheFileNameByPattern( $cachePath, 'ext-all-cache.*.js' ); - $cf = PATH_C . 'ExtJs' . PATH_SEP . "ext-all-cache.$checksum.js"; - if (is_file( $cfStored['filename'] ) && $checksum == $cfStored['checksum']) { - $output = file_get_contents( $cf ); - } else { - if (is_file( $cfStored['filename'] )) { - @unlink( $cfStored['filename'] ); - } - $output .= file_get_contents( $pathJs . 'ext/ext-all.js' ); //already minified - $output .= file_get_contents( $pathJs . 'ext/ux/ux-all.js' ); //already minified - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/pmos-common.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux/miframe.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux.statusbar/ext-statusbar.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' ) ); - file_put_contents( $cf, $output ); - } - */ - break; - default: - @readfile( $filename ); - break; - } - print $output; - break; - case 'css': - print G::trimSourceCodeFile( $filename ); - break; - default: - @readfile( $filename ); - break; + if ( substr($filename,-10) == "ext-all.js" ) { + $filename = PATH_GULLIVER_HOME . 'js/ext/min/ext-all.js'; } - } - - /** - * trimSourceCodeFile - * - * @param string $filename - * - * @return string $output - */ - public function trimSourceCodeFile ($filename) - { - $handle = fopen( $filename, "r" ); - $lastChar = ''; - $firstChar = ''; - $content = ''; - $line = ''; - - if ($handle) { - while (! feof( $handle )) { - //$line = trim( fgets($handle, 16096) ) . "\n" ; - $line = fgets( $handle, 16096 ); - $content .= $line; - } - fclose( $handle ); - } - return $content; - - $index = 0; - $output = ''; - while ($index < strlen( $content )) { - $car = $content[$index]; - $index ++; - if ($car == '/' && isset( $content[$index] ) && $content[$index] == '*') { - $endComment = false; - $index ++; - while ($endComment == false && $index < strlen( $content )) { - if ($content[$index] == '*' && isset( $content[$index + 1] ) && $content[$index + 1] == '/') { - $endComment = true; - $index ++; - } - $index ++; - } - $car = ''; - } - $output .= $car; - } - return $output; + @readfile( $filename ); } /** @@ -3372,7 +3028,7 @@ class G /** * Validate and emai address in complete forms, * - * @author Erik A.O. + * @author Erik A.O. * i.e. if the param. is 'erik a.o. ' * -> returns a object within $o->email => erik@colosa.com and $o->name => erik A.O. in other case returns false * @@ -3405,7 +3061,7 @@ class G /** * JSON encode * - * @author Erik A.O. + * @author Erik A.O. */ public function json_encode($Json) { @@ -3421,7 +3077,7 @@ class G /** * JSON decode * - * @author Erik A.O. + * @author Erik A.O. */ public function json_decode($Json) { @@ -3695,11 +3351,11 @@ class G return $infoUser; } - public function getModel($model) - { - require_once "classes/model/$model.php"; - return new $model(); - } + //public function getModel($model) + //{ + // require_once "classes/model/$model.php"; + // return new $model(); + //} /** * Recursive Is writeable function diff --git a/gulliver/system/class.headPublisher.php b/gulliver/system/class.headPublisher.php index 894a3380f..4d71d8e92 100755 --- a/gulliver/system/class.headPublisher.php +++ b/gulliver/system/class.headPublisher.php @@ -18,7 +18,7 @@ * 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 + * You should have received a copy of the GNU Affero General Public LicensegetExtJsLibraries * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., @@ -40,7 +40,6 @@ class headPublisher /* extJsSkin init coreLoad flag*/ var $extJsInit = 'false'; - /* extJsSkin store the current skin for the ExtJs*/ var $extJsSkin = ''; @@ -62,6 +61,8 @@ class headPublisher /* tplVariable array, to store the variables for template power */ var $tplVariable = array (); + var $translationsFile; + var $leimnudInitString = ' var leimnud = new maborak(); leimnud.make({ zip:true, @@ -90,6 +91,7 @@ class headPublisher public function __construct () { $this->addScriptFile( "/js/maborak/core/maborak.js" ); + $this->translationsFile = "/js/ext/translation." . SYS_LANG . ".js"; } function &getSingleton () @@ -211,12 +213,16 @@ class headPublisher $this->addScriptFile( "/js/widgets/js-calendar/unicode-letter.js" ); //$this->addScriptFile( "/js/widgets/js-calendar/lang/" . $sysLang . ".js" ); - + $head = ''; $head .= '' . $this->title . "\n"; foreach ($this->scriptFiles as $file) { $head .= "\n"; } + if(!in_array( $this->translationsFile, $this->scriptFiles)) { + $head .= "\n"; + } + $head .= "\n"; + $head .= "\n"; return $head; } @@ -306,7 +313,7 @@ class headPublisher $head .= $this->getExtJsLibraries(); // $head .= " \n"; - $head .= " \n"; + // $head .= " \n"; if (! isset( $this->extJsSkin ) || $this->extJsSkin == '') { $this->extJsSkin = 'xtheme-gray'; @@ -326,7 +333,7 @@ class headPublisher function getExtJsStylesheets ($skinName) { $script = " \n"; - $script .= " \n"; + //$script .= " \n"; /* $script .= " \n"; $script .= " \n"; @@ -390,13 +397,16 @@ class headPublisher } function getExtJsLibraries () - { + { $script = ''; if (isset( $this->extJsLibrary ) && is_array( $this->extJsLibrary )) { foreach ($this->extJsLibrary as $file) { $script .= " \n"; } } + if(!in_array( $this->translationsFile, $this->extJsLibrary)) { + $script .= " \n"; + } return $script; } diff --git a/gulliver/system/class.webResource.php b/gulliver/system/class.webResource.php index a64d3596d..021d00ba9 100755 --- a/gulliver/system/class.webResource.php +++ b/gulliver/system/class.webResource.php @@ -109,7 +109,7 @@ class WebResource } /* end class WebResource */ -if (! function_exists( 'json_encode' )) { +/*if (! function_exists( 'json_encode' )) { G::LoadThirdParty( 'pear/json', 'class.json' ); function json_encode (&$value) @@ -127,5 +127,5 @@ if (! function_exists( 'json_decode' )) { $json = new Services_JSON(); return $json->decode( $value ); } -} +}*/ diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index e86f1e98e..589007a0c 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -522,7 +522,6 @@ class XmlForm_Field public function getAttributes () { $attributes = array (); - $json = new Services_JSON(); foreach ($this as $attribute => $value) { switch ($attribute) { case 'sql': @@ -540,7 +539,9 @@ class XmlForm_Field if (sizeof( $attributes ) < 1) { return '{}'; } - return $json->encode( $attributes ); + //$json = new Services_JSON(); + //return $json->encode( $attributes ); + return G::json_encode( $attributes ); } /** @@ -553,7 +554,6 @@ class XmlForm_Field public function getEvents () { $events = array (); - $json = new Services_JSON(); foreach ($this as $attribute => $value) { if (substr( $attribute, 0, 2 ) === 'on') { $events[$attribute] = $value; @@ -562,7 +562,9 @@ class XmlForm_Field if (sizeof( $events ) < 1) { return '{}'; } - return $json->encode( $events ); + //$json = new Services_JSON(); + //return $json->encode( $events ); + return G::json_encode( $events ); } /** @@ -805,7 +807,7 @@ class XmlForm_Field public function NSGridLabel ($show = false) { - $idv = 'pm:label="' . $this->pmLabel . '"'; + $idv = 'pm:label="' . htmlentities($this->pmLabel, ENT_COMPAT, 'utf-8') . '"'; if ($show) { return $idv; } else { @@ -1336,7 +1338,6 @@ class XmlForm_Field_Suggest extends XmlForm_Field_SimpleText //by neyek } $hash = str_rot13( base64_encode( $this->sql . '@|' . $this->sqlConnection ) ); - // $sOptions = 'script:"'.$this->ajaxServer.'?request=suggest&json=true&limit='.$this->maxresults.'&hash='.$hash.'&dependentFields='. $this->dependentFields .'&field=" + getField(\''. $this->name .'\').value + "&",'; $sSQL = $this->sql; $nCount = preg_match_all( '/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $sSQL, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ); @@ -2494,19 +2495,54 @@ class XmlForm_Field_Link extends XmlForm_Field * @param string value * @return string */ - public function render ($value = null, $owner = null) + public function render($value = null, $label = null, $owner = null, $row = -1) { - $onclick = G::replaceDataField( $this->onclick, $owner->values ); - $link = G::replaceDataField( $this->link, $owner->values ); - $target = G::replaceDataField( $this->target, $owner->values ); - $value = G::replaceDataField( $this->value, $owner->values ); - $label = G::replaceDataField( $this->label, $owner->values ); - $html = 'htmlentities( $link, ENT_QUOTES, 'utf-8' ) . '\''; - $html .= 'id="form[' . $this->name . ']" name="form[' . $this->name . ']" style="' . htmlentities( $this->style, ENT_QUOTES, 'utf-8' ) . '" '; - $html .= (($this->onclick) ? ' onclick="' . htmlentities( $onclick, ENT_QUOTES, 'utf-8' ) . '"' : ''); - $html .= (($this->target) ? ' target="' . htmlentities( $target, ENT_QUOTES, 'utf-8' ) . '"' : '') . '>'; - $html .= $this->htmlentities( $this->value === '' ? $label : $value, ENT_QUOTES, 'utf-8' ) . ''; - $html .= $this->renderHint(); + $id = null; + $v = null; + + switch ($owner->type) { + case "grid": + $id = $owner->name . "][" . $row . "][" . $this->name; + $v = (isset($owner->values[$owner->name][$row]))? $owner->values[$owner->name][$row] : array(); + break; + default: + $id = $this->name; + $v = $owner->values; + break; + } + + $link = (!empty($value))? $value : G::replaceDataField($this->link, $v); + $labelAux1 = (!empty($label))? $label : G::replaceDataField($this->label, $v); + $labelAux2 = (!empty($label))? $label : G::replaceDataField($this->value, $v); + $onclick = G::replaceDataField($this->onclick, $v); + $target = G::replaceDataField($this->target, $v); + + $html = "htmlentities($link, ENT_QUOTES, "utf-8") . "\""; + $html = $html . " id=\"form[$id]\" name=\"form[$id]\" pm:field=\"pm:field\""; + $html = $html . (($this->onclick)? " onclick=\"" . htmlentities($onclick, ENT_QUOTES, "utf-8") . "\"" : null); + $html = $html . (($this->target)? " target=\"" . htmlentities($target, ENT_QUOTES, "utf-8") . "\"" : null); + + switch ($owner->type) { + case "grid": + if ($this->mode == "view") { + $html = $html . " style=\"color: #006699; text-decoration: none; font-weight: normal;\""; + } + break; + default: + $html = $html . " style=\"" . htmlentities($this->style, ENT_QUOTES, "utf-8") . "\""; + break; + } + + $html = $html . ">" . $this->htmlentities(($this->value == "")? $labelAux1 : $labelAux2, ENT_QUOTES, "utf-8") . ""; + + switch ($owner->type) { + case "grid": + break; + default: + $html = $html . $this->renderHint(); + break; + } + return $html; } @@ -2517,30 +2553,22 @@ class XmlForm_Field_Link extends XmlForm_Field * @param $owner * @return */ - public function renderGrid ($values = array(), $owner = null) + public function renderGrid($value = array(), $label = array(), $owner = null) { - $result = array (); - $r = 1; - foreach ($values as $v) { - $_aData_ = (isset( $owner->values[$owner->name][$r] ) ? $owner->values[$owner->name][$r] : array ()); - $onclick = G::replaceDataField( $this->onclick, $_aData_ ); - $link = G::replaceDataField( $this->link, $_aData_ ); - $target = G::replaceDataField( $this->target, $_aData_ ); - $value = G::replaceDataField( $this->value, $_aData_ ); - $label = G::replaceDataField( $this->label, $_aData_ ); - $html = 'htmlentities( $link, ENT_QUOTES, 'utf-8' ) . '\''; - $html .= 'id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"'; - $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"'; - $html .= (($this->onclick) ? ' onclick="' . htmlentities( $onclick, ENT_QUOTES, 'utf-8' ) . '"' : ''); - $html .= (($this->target) ? ' target="' . htmlentities( $target, ENT_QUOTES, 'utf-8' ) . '"' : ''); - if ($this->mode == 'view') { - $html .= 'style="color: #006699; text-decoration: none;font-weight: normal;"'; - } - $html .= '>' . $this->htmlentities( $this->value === '' ? $label : $value, ENT_QUOTES, 'utf-8' ) . ''; - $result[] = $html; - $r ++; + $arrayResult = array(); + $row = 1; + + foreach ($value as $index => $v) { + $arrayResult[] = $this->render( + (isset($value[$index]))? $value[$index] : null, + (isset($label[$index]))? $label[$index] : null, + $owner, + $row + ); + $row = $row + 1; } - return $result; + + return $arrayResult; } /** @@ -3005,13 +3033,14 @@ class XmlForm_Field_Submit extends XmlForm_Field // return 'label .'\' disabled/>'; return "style}\" class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; } elseif ($this->mode === 'view') { - // return "style};display:none\" disabled='disabled' class='module_app_button___gray module_app_buttonDisabled___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; + //return "style};display:none\" disabled='disabled' class='module_app_button___gray module_app_buttonDisabled___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; //$sLinkNextStep = 'window.open("' . $owner->fields['__DYNAFORM_OPTIONS']->xmlMenu->values['NEXT_STEP'] . '", "_self");'; $html = ''; if (isset( $_SESSION['CURRENT_DYN_UID'] )) { $sLinkNextStep = 'window.location=("casesSaveDataView?UID=' . $_SESSION['CURRENT_DYN_UID'] . '");'; $html = ''; } + $html .= 'name . ']" '; $html .= 'name="form[' . $this->name . ']" '; @@ -4922,8 +4951,9 @@ class XmlForm } } - $oJSON = new Services_JSON(); - $this->objectRequiredFields = str_replace( '"', "%27", str_replace( "'", "%39", $oJSON->encode( $this->requiredFields ) ) ); + //$oJSON = new Services_JSON(); + $jsonRequired = G::json_encode( $this->requiredFields ); + $this->objectRequiredFields = str_replace( '"', "%27", str_replace( "'", "%39", $jsonRequired ) ); //Load the default values //$this->setDefaultValues(); @@ -5243,7 +5273,18 @@ class xmlformTemplate extends Smarty } $result['form'][$k] = $form->fields[$k]->renderGrid( $aAux, $form ); } else { - $result['form'][$k] = $form->fields[$k]->render( $value, $form ); + switch ($v->type) { + case "link": + $result["form"][$k] = $form->fields[$k]->render( + $value, + (isset($form->values[$k . "_label"]))? $form->values[$k . "_label"] : null, + $form + ); + break; + default: + $result["form"][$k] = $form->fields[$k]->render($value, $form); + break; + } } } else { /*if (isset ( $form->owner )) { @@ -5267,6 +5308,13 @@ class xmlformTemplate extends Smarty case "file": $result["form"][$k] = $form->fields[$k]->renderGrid( $value, $form, $therow ); break; + case "link": + $result["form"][$k] = $form->fields[$k]->renderGrid( + $value, + (isset($form->values[$k . "_label"]))? $form->values[$k . "_label"] : array(), + $form + ); + break; default: $result["form"][$k] = $form->fields[$k]->renderGrid( $value, $form ); break; diff --git a/rbac/engine/classes/plugins/class.ldap.php b/rbac/engine/classes/plugins/class.ldap.php index 1bd1f1872..42d6d50a9 100755 --- a/rbac/engine/classes/plugins/class.ldap.php +++ b/rbac/engine/classes/plugins/class.ldap.php @@ -147,18 +147,21 @@ class LDAP $sKeyword .= '*'; } } + + $additionalFilter = isset($aAuthSource['AUTH_SOURCE_DATA']['AUTH_SOURCE_ADDITIONAL_FILTER']) ? trim($aAuthSource['AUTH_SOURCE_DATA']['AUTH_SOURCE_ADDITIONAL_FILTER']) : ''; + $sFilter = '(&(|(objectClass=*))'; - + if ( isset( $aAuthSource['AUTH_SOURCE_DATA']['LDAP_TYPE']) && $aAuthSource['AUTH_SOURCE_DATA']['LDAP_TYPE'] == 'ad' ) { - $sFilter = "(&(|(objectClass=*))(|(samaccountname=$sKeyword)(userprincipalname=$sKeyword))(objectCategory=person))"; + $sFilter = "(&(|(objectClass=*))(|(samaccountname=$sKeyword)(userprincipalname=$sKeyword))$additionalFilter)"; } else - $sFilter = "(&(|(objectClass=*))(|(uid=$sKeyword)(cn=$sKeyword)))"; + $sFilter = "(&(|(objectClass=*))(|(uid=$sKeyword)(cn=$sKeyword))$additionalFilter)"; //G::pr($sFilter); $aUsers = array(); $oSearch = @ldap_search($oLink, $aAuthSource['AUTH_SOURCE_BASE_DN'], $sFilter, array('dn','uid','samaccountname', 'cn','givenname','sn','mail','userprincipalname','objectcategory', 'manager')); - + if ($oError = @ldap_errno($oLink)) { return $aUsers; } @@ -179,7 +182,7 @@ class LDAP 'sFirstname' => isset($aAttr['givenname']) ? $aAttr['givenname'] : '', 'sLastname' => isset($aAttr['sn']) ? $aAttr['sn'] : '', 'sEmail' => isset($aAttr['mail']) ? $aAttr['mail'] : ( isset($aAttr['userprincipalname'])?$aAttr['userprincipalname'] : '') , - 'sDN' => $aAttr['dn'] ); + 'sDN' => $aAttr['dn'] ); } } while ($oEntry = @ldap_next_entry($oLink, $oEntry)); } diff --git a/workflow/engine/bin/cron_single.php b/workflow/engine/bin/cron_single.php index 9a2b984b3..0aa1f4ced 100755 --- a/workflow/engine/bin/cron_single.php +++ b/workflow/engine/bin/cron_single.php @@ -89,12 +89,62 @@ if (!defined('PATH_HOME')) { define ('TIME_ZONE', $config['time_zone']); } -require_once ("classes/model/Configuration.php"); -require_once ("classes/model/AppCacheView.php"); -require_once ("classes/model/AppDelegation.php"); -require_once ("classes/model/Event.php"); -require_once ("classes/model/AppEvent.php"); -require_once ("classes/model/CaseScheduler.php"); +require_once (PATH_GULLIVER . PATH_SEP . 'class.bootstrap.php'); +//define( 'PATH_GULLIVER_HOME', PATH_TRUNK . 'gulliver' . PATH_SEP ); + +spl_autoload_register(array('Bootstrap', 'autoloadClass')); + +Bootstrap::registerClass('BaseConfiguration', PATH_HOME . "engine/classes/model/om/BaseConfiguration.php"); +Bootstrap::registerClass('Configuration', PATH_HOME . "engine/classes/model/Configuration.php"); + +Bootstrap::registerClass('EventPeer', PATH_HOME . "engine/classes/model/EventPeer.php"); +Bootstrap::registerClass('ApplicationPeer', PATH_HOME . "engine/classes/model/ApplicationPeer.php"); + +Bootstrap::registerClass('BaseGroupUser', PATH_HOME . "engine/classes/model/om/BaseGroupUser.php"); +Bootstrap::registerClass('BaseUsers', PATH_HOME . "engine/classes/model/om/BaseUsers.php"); +Bootstrap::registerClass('BaseProcess', PATH_HOME . "engine/classes/model/om/BaseProcess.php"); +Bootstrap::registerClass('BaseContentPeer', PATH_HOME . "engine/classes/model/om/BaseContentPeer.php"); +Bootstrap::registerClass('BaseContent', PATH_HOME . "engine/classes/model/om/BaseContent.php"); +Bootstrap::registerClass('BaseLogCasesScheduler', PATH_HOME . "engine/classes/model/om/BaseLogCasesScheduler.php"); +Bootstrap::registerClass('BaseApplication', PATH_HOME . "engine/classes/model/om/BaseApplication.php"); +Bootstrap::registerClass('BaseEvent', PATH_HOME . "engine/classes/model/om/BaseEvent.php"); +Bootstrap::registerClass('BaseEventPeer', PATH_HOME . "engine/classes/model/om/BaseEventPeer.php"); +Bootstrap::registerClass('BaseTriggers', PATH_HOME . "engine/classes/model/om/BaseTriggers.php"); +Bootstrap::registerClass('BaseTriggersPeer', PATH_HOME . "engine/classes/model/om/BaseTriggersPeer.php"); +Bootstrap::registerClass('BaseAppMessage', PATH_HOME . "engine/classes/model/om/BaseAppMessage.php"); +Bootstrap::registerClass('BaseAppMessagePeer', PATH_HOME . "engine/classes/model/om/BaseAppMessagePeer.php"); + +Bootstrap::registerClass('BaseAppDelegation', PATH_HOME . "engine/classes/model/om/BaseAppDelegation.php"); +Bootstrap::registerClass('BaseHoliday', PATH_HOME . "engine/classes/model/om/BaseHoliday.php"); +Bootstrap::registerClass('BaseHolidayPeer', PATH_HOME . "engine/classes/model/om/BaseHolidayPeer.php"); +Bootstrap::registerClass('BaseTask', PATH_HOME . "engine/classes/model/om/BaseTask.php"); +Bootstrap::registerClass('BaseTaskPeer', PATH_HOME . "engine/classes/model/om/BaseTaskPeer.php"); +Bootstrap::registerClass('HolidayPeer', PATH_HOME . "engine/classes/model/HolidayPeer.php"); +Bootstrap::registerClass('Holiday', PATH_HOME . "engine/classes/model/Holiday.php"); + +Bootstrap::registerClass('Task', PATH_HOME . "engine/classes/model/Task.php"); +Bootstrap::registerClass('TaskPeer', PATH_HOME . "engine/classes/model/TaskPeer.php"); +Bootstrap::registerClass('dates', PATH_HOME . "engine/classes/class.dates.php"); +Bootstrap::registerClass('AppDelegation', PATH_HOME . "engine/classes/model/AppDelegation.php"); +Bootstrap::registerClass('AppDelegationPeer', PATH_HOME . "engine/classes/model/AppDelegationPeer.php"); +Bootstrap::registerClass('BaseAppDelay', PATH_HOME . "engine/classes/model/om/BaseAppDelay.php"); +Bootstrap::registerClass('AppDelayPeer', PATH_HOME . "engine/classes/model/AppDelayPeer.php"); +Bootstrap::registerClass('AppDelay', PATH_HOME . "engine/classes/model/AppDelay.php"); +Bootstrap::registerClass('BaseAdditionalTables',PATH_HOME . "engine/classes/model/om/BaseAdditionalTables.php"); +Bootstrap::registerClass('AdditionalTables', PATH_HOME . "engine/classes/model/AdditionalTables.php"); +Bootstrap::registerClass('BaseAppCacheView', PATH_HOME . "engine/classes/model/om/BaseAppCacheView.php"); +Bootstrap::registerClass('AppCacheView', PATH_HOME . "engine/classes/model/AppCacheView.php"); +Bootstrap::registerClass('AppCacheViewPeer', PATH_HOME . "engine/classes/model/AppCacheViewPeer.php"); + +Bootstrap::registerClass('BaseEvent', PATH_HOME . "engine/classes/model/om/BaseEvent.php"); +Bootstrap::registerClass('Event', PATH_HOME . "engine/classes/model/Event.php"); + +Bootstrap::registerClass('BaseAppEvent', PATH_HOME . "engine/classes/model/om/BaseAppEvent.php"); +Bootstrap::registerClass('AppEvent', PATH_HOME . "engine/classes/model/AppEvent.php"); +Bootstrap::registerClass('AppEventPeer', PATH_HOME . "engine/classes/model/AppEventPeer.php"); + +Bootstrap::registerClass('BaseCaseScheduler', PATH_HOME . "engine/classes/model/om/BaseCaseScheduler.php"); +Bootstrap::registerClass('CaseScheduler', PATH_HOME . "engine/classes/model/CaseScheduler.php"); G::LoadClass("case"); G::LoadClass("dates"); diff --git a/workflow/engine/bin/tasks/libraries.json b/workflow/engine/bin/tasks/libraries.json index 0281a861e..c7365cd89 100755 --- a/workflow/engine/bin/tasks/libraries.json +++ b/workflow/engine/bin/tasks/libraries.json @@ -135,6 +135,12 @@ "mini": "gulliver/js/maborak/core/module.dom.js", "minify": true }, + { + "name": "module.abbr", + "full": "gulliver/js/maborak/core/module.abbr.js", + "mini": "gulliver/js/maborak/core/module.abbr.js", + "minify": true + }, { "name": "module.dashboard", "full": "gulliver/js/maborak/core/module.dashboard.js", diff --git a/workflow/engine/classes/class.AppSolr.php b/workflow/engine/classes/class.AppSolr.php index d55e9b06a..cff4a82de 100755 --- a/workflow/engine/classes/class.AppSolr.php +++ b/workflow/engine/classes/class.AppSolr.php @@ -22,20 +22,20 @@ * */ -require_once ("classes" . PATH_SEP . "model" . PATH_SEP . "AppCacheView.php"); -require_once "classes/model/Application.php"; -require_once "classes/model/AppDelegation.php"; -require_once "classes/model/AppThread.php"; -require_once "classes/model/Content.php"; -require_once "classes/model/Users.php"; -require_once "classes/model/GroupUser.php"; -require_once "classes/model/Task.php"; -require_once "classes/model/TaskUser.php"; -require_once "classes/model/Dynaform.php"; -require_once "entities/SolrRequestData.php"; -require_once "entities/SolrUpdateDocument.php"; -require_once "entities/AppSolrQueue.php"; -require_once "classes/model/AppSolrQueue.php"; +//require_once ("classes" . PATH_SEP . "model" . PATH_SEP . "AppCacheView.php"); +//require_once "classes/model/Application.php"; +//require_once "classes/model/AppDelegation.php"; +//require_once "classes/model/AppThread.php"; +//require_once "classes/model/Content.php"; +//require_once "classes/model/Users.php"; +//require_once "classes/model/GroupUser.php"; +//require_once "classes/model/Task.php"; +//require_once "classes/model/TaskUser.php"; +//require_once "classes/model/Dynaform.php"; +//require_once "entities/SolrRequestData.php"; +//require_once "entities/SolrUpdateDocument.php"; +//require_once "entities/AppSolrQueue.php"; +//require_once "classes/model/AppSolrQueue.php"; /** * Invalid search text for Solr exception diff --git a/workflow/engine/classes/class.applications.php b/workflow/engine/classes/class.applications.php index 8a17cc8f5..c251509b0 100755 --- a/workflow/engine/classes/class.applications.php +++ b/workflow/engine/classes/class.applications.php @@ -35,13 +35,13 @@ class Applications G::LoadClass("BasePeer"); G::LoadClass("configuration"); - require_once ("classes/model/AppCacheView.php"); - require_once ("classes/model/AppDelegation.php"); - require_once ("classes/model/AdditionalTables.php"); - require_once ("classes/model/AppDelay.php"); - require_once ("classes/model/Fields.php"); - require_once ("classes/model/Users.php"); - require_once ("classes/model/Process.php"); + //require_once ("classes/model/AppCacheView.php"); + //require_once ("classes/model/AppDelegation.php"); + //require_once ("classes/model/AdditionalTables.php"); + //require_once ("classes/model/AppDelay.php"); + //require_once ("classes/model/Fields.php"); + //require_once ("classes/model/Users.php"); + //require_once ("classes/model/Process.php"); $oAppCache = new AppCacheView(); @@ -693,14 +693,14 @@ class Applications public function getSteps ($appUid, $index, $tasUid, $proUid) { - require_once 'classes/model/Step.php'; - require_once 'classes/model/Content.php'; - require_once 'classes/model/AppDocument.php'; - require_once 'classes/model/InputDocumentPeer.php'; - require_once 'classes/model/OutputDocument.php'; - require_once 'classes/model/Dynaform.php'; + //require_once 'classes/model/Step.php'; + //require_once 'classes/model/Content.php'; + //require_once 'classes/model/AppDocument.php'; + //require_once 'classes/model/InputDocumentPeer.php'; + //require_once 'classes/model/OutputDocument.php'; + //require_once 'classes/model/Dynaform.php'; - G::LoadClass( 'pmScript' ); + //G::LoadClass( 'pmScript' ); G::LoadClass( 'case' ); $steps = Array (); diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 9a114126d..250ebe228 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -25,7 +25,7 @@ * */ -require_once ("classes/model/Application.php"); +/*require_once ("classes/model/Application.php"); require_once ("classes/model/AppCacheView.php"); require_once ("classes/model/AppDelay.php"); require_once ("classes/model/AppDelegation.php"); @@ -42,24 +42,24 @@ require_once ("classes/model/CaseTrackerObject.php"); require_once ("classes/model/Configuration.php"); require_once ("classes/model/Content.php"); require_once ("classes/model/DbSource.php"); -require_once ("classes/model/Dynaform.php"); -require_once ("classes/model/InputDocument.php"); -require_once ("classes/model/Language.php"); -require_once ("classes/model/ObjectPermission.php"); -require_once ("classes/model/OutputDocument.php"); -require_once ("classes/model/Process.php"); -require_once ("classes/model/ProcessUser.php"); -require_once ("classes/model/ReportTable.php"); -require_once ("classes/model/ReportVar.php"); -require_once ("classes/model/Route.php"); -require_once ("classes/model/Step.php"); -require_once ("classes/model/StepSupervisor.php"); -require_once ("classes/model/StepTrigger.php"); -require_once ("classes/model/SubApplication.php"); -require_once ("classes/model/Task.php"); -require_once ("classes/model/TaskUser.php"); -require_once ("classes/model/Triggers.php"); -require_once ("classes/model/Users.php"); +require_once ("classes/model/Dynaform.php");*/ +//require_once ("classes/model/InputDocument.php"); +//require_once ("classes/model/Language.php"); +//require_once ("classes/model/ObjectPermission.php"); +//require_once ("classes/model/OutputDocument.php"); +//require_once ("classes/model/Process.php"); +//require_once ("classes/model/ProcessUser.php"); +//require_once ("classes/model/ReportTable.php"); +//require_once ("classes/model/ReportVar.php"); +//require_once ("classes/model/Route.php"); +//require_once ("classes/model/Step.php"); +//require_once ("classes/model/StepSupervisor.php"); +//require_once ("classes/model/StepTrigger.php"); +//require_once ("classes/model/SubApplication.php"); +//require_once ("classes/model/Task.php"); +//require_once ("classes/model/TaskUser.php"); +//require_once ("classes/model/Triggers.php"); +//require_once ("classes/model/Users.php"); G::LoadClass("pmScript"); @@ -3467,6 +3467,201 @@ class Cases } } + /** + * Add a input document + * + * Return the application document ID + * + * @param string $inputDocumentUid Input document ID + * @param string $appDocUid Application document ID + * @param int $docVersion Document version + * @param string $appDocType Document type + * @param string $appDocComment Document comment + * @param string $inputDocumentAction Action, posible values: null or empty (Add), "R" (Replace), "NV" (New Version) + * @param string $applicationUid Application ID + * @param int $delIndex Delegation index + * @param string $taskUid Task ID + * @param string $userUid User ID + * @param string $option Option, posible values: "xmlform", "file" + * @param string $file File ($_FILES["form"]["name"]["APP_DOC_FILENAME"] or path to file) + * @param int $fileError File error ($_FILES["form"]["error"]["APP_DOC_FILENAME"] or 0) + * @param string $fileTmpName File temporal name ($_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"] or null) + * @return string Return application document ID + */ + public function addInputDocument( + $inputDocumentUid, + $appDocUid, + $docVersion, + $appDocType, + $appDocComment, + $inputDocumentAction, + $applicationUid, + $delIndex, + $taskUid, + $userUid, + $option, + $file, + $fileError = 0, + $fileTmpName = null + ) { + $appDocFileName = null; + $sw = 0; + + switch ($option) { + case "xmlform": + $appDocFileName = $file; + + if ($fileError == 0) { + $sw = 1; + } + break; + case "file": + $appDocFileName = basename($file); + + if (file_exists($file) && is_file($file)) { + $sw = 1; + } + break; + } + + if ($sw == 0) { + return null; + } + + //Info + $inputDocument = new InputDocument(); + $arrayInputDocumentData = $inputDocument->load($inputDocumentUid); + + //Get the Custom Folder ID (create if necessary) + $appFolder = new AppFolder(); + $folderId = $appFolder->createFromPath($arrayInputDocumentData["INP_DOC_DESTINATION_PATH"], $applicationUid); + + $tags = $appFolder->parseTags($arrayInputDocumentData["INP_DOC_TAGS"], $applicationUid); + + $appDocument = new AppDocument(); + $arrayField = array(); + + switch ($inputDocumentAction) { + case "R": + //Replace + $arrayField = array( + "APP_DOC_UID" => $appDocUid, + "APP_UID" => $applicationUid, + "DOC_VERSION" => $docVersion, + "DEL_INDEX" => $delIndex, + "USR_UID" => $userUid, + "DOC_UID" => $inputDocumentUid, + "APP_DOC_TYPE" => $appDocType, + "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), + "APP_DOC_COMMENT" => $appDocComment, + "APP_DOC_TITLE" => "", + "APP_DOC_FILENAME" => $appDocFileName, + "FOLDER_UID" => $folderId, + "APP_DOC_TAGS" => $tags + ); + + $appDocument->update($arrayField); + break; + case "NV": + //New Version + $arrayField = array( + "APP_DOC_UID" => $appDocUid, + "APP_UID" => $applicationUid, + "DEL_INDEX" => $delIndex, + "USR_UID" => $userUid, + "DOC_UID" => $inputDocumentUid, + "APP_DOC_TYPE" => $appDocType, + "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), + "APP_DOC_COMMENT" => $appDocComment, + "APP_DOC_TITLE" => "", + "APP_DOC_FILENAME" => $appDocFileName, + "FOLDER_UID" => $folderId, + "APP_DOC_TAGS" => $tags + ); + + $appDocument->create($arrayField); + break; + default: + //New + $arrayField = array( + "APP_UID" => $applicationUid, + "DEL_INDEX" => $delIndex, + "USR_UID" => $userUid, + "DOC_UID" => $inputDocumentUid, + "APP_DOC_TYPE" => $appDocType, + "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), + "APP_DOC_COMMENT" => $appDocComment, + "APP_DOC_TITLE" => "", + "APP_DOC_FILENAME" => $appDocFileName, + "FOLDER_UID" => $folderId, + "APP_DOC_TAGS" => $tags + ); + + $appDocument->create($arrayField); + break; + } + + //Save the file + $appDocUid = $appDocument->getAppDocUid(); + $docVersion = $appDocument->getDocVersion(); + $arrayInfo = pathinfo($appDocument->getAppDocFilename()); + $extension = (isset($arrayInfo["extension"]))? $arrayInfo["extension"] : null; + $strPathName = PATH_DOCUMENT . $applicationUid . PATH_SEP; + $strFileName = $appDocUid . "_" . $docVersion . "." . $extension; + + switch ($option) { + case "xmlform": + G::uploadFile($fileTmpName, $strPathName, $strFileName); + break; + case "file": + $umaskOld = umask(0); + + if (!is_dir($strPathName)) { + G::verifyPath($strPathName, true); + } + + copy($file, $strPathName . $strFileName); + chmod($strPathName . $strFileName, 0666); + umask($umaskOld); + break; + } + + //Plugin Hook PM_UPLOAD_DOCUMENT for upload document + $pluginRegistry = &PMPluginRegistry::getSingleton(); + + if ($pluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists("uploadDocumentData")) { + $triggerDetail = $pluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT); + $documentData = new uploadDocumentData( + $applicationUid, + $userUid, + $strPathName . $strFileName, + $arrayField["APP_DOC_FILENAME"], + $appDocUid, + $docVersion + ); + $uploadReturn = $pluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); + + if ($uploadReturn) { + $arrayField["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace; + + if (!isset($arrayField["APP_DOC_UID"])) { + $arrayField["APP_DOC_UID"] = $appDocUid; + } + + if (!isset($arrayField["DOC_VERSION"])) { + $arrayField["DOC_VERSION"] = $docVersion; + } + + $appDocument->update($arrayField); + + unlink($strPathName . $strFileName); + } + } + //End plugin + + return $appDocUid; + } + /* * Return the input documents list to Review * @@ -4717,10 +4912,10 @@ class Cases if ($sTo != null) { $oSpool = new spoolRun(); - if ($aConfiguration['MESS_RAUTH'] == false || (is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false')) { - $aConfiguration['MESS_RAUTH'] = 0; - } else { - $aConfiguration['MESS_RAUTH'] = 1; + if ($aConfiguration['MESS_RAUTH'] == false || (is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false')) { + $aConfiguration['MESS_RAUTH'] = 0; + } else { + $aConfiguration['MESS_RAUTH'] = 1; } $oSpool->setConfig(array( diff --git a/workflow/engine/classes/class.dashletRssReader.php b/workflow/engine/classes/class.dashletRssReader.php index 4e3d6e9ed..cc1b935ea 100755 --- a/workflow/engine/classes/class.dashletRssReader.php +++ b/workflow/engine/classes/class.dashletRssReader.php @@ -50,8 +50,8 @@ class dashletRssReader implements DashletInterface curl_setopt( $pCurl, CURLOPT_CONNECTTIMEOUT, 10 ); curl_setopt( $pCurl, CURLOPT_TIMEOUT, 20 ); - curl_setopt( $pCurl, CURLOPT_NOPROGRESS, false ); - curl_setopt( $pCurl, CURLOPT_VERBOSE, true ); + curl_setopt( $pCurl, CURLOPT_NOPROGRESS, true ); + curl_setopt( $pCurl, CURLOPT_VERBOSE, false ); //Apply proxy settings $sysConf = System::getSystemConfiguration(); diff --git a/workflow/engine/classes/class.dynaFormField.php b/workflow/engine/classes/class.dynaFormField.php index 4f490f97d..3d1ab37d1 100755 --- a/workflow/engine/classes/class.dynaFormField.php +++ b/workflow/engine/classes/class.dynaFormField.php @@ -25,8 +25,8 @@ * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ -G::LoadClass('xmlDb'); -G::LoadSystem('dynaformhandler'); +//G::LoadClass('xmlDb'); +//G::LoadSystem('dynaformhandler'); /** * Dynaform Field - DynaformField class diff --git a/workflow/engine/classes/class.dynaformEditor.php b/workflow/engine/classes/class.dynaformEditor.php index ec01b0181..308863436 100755 --- a/workflow/engine/classes/class.dynaformEditor.php +++ b/workflow/engine/classes/class.dynaformEditor.php @@ -219,6 +219,7 @@ class dynaformEditor extends WebResource //for showHide tab option @Neyek $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_CONDITIONS_EDITOR"), $sName . '[9]', 'dynaformEditor.changeToShowHide', 'dynaformEditor.saveShowHide'); $G_PUBLISH->AddContent('panel-close'); + $oHeadPublisher->addScriptFile("/js/maborak/core/maborak.loader.js",2); $oHeadPublisher->addScriptFile('/jscore/dynaformEditor/core/dynaformEditor.js'); //$oHeadPublisher->addScriptFile('/js/dveditor/core/dveditor.js'); //$oHeadPublisher->addScriptFile('/codepress/codepress.js',1); diff --git a/workflow/engine/classes/class.memcached.php b/workflow/engine/classes/class.memcached.php index b16ac6963..51cc4c864 100755 --- a/workflow/engine/classes/class.memcached.php +++ b/workflow/engine/classes/class.memcached.php @@ -66,7 +66,7 @@ class PMmemcached $this->version = $this->mem->getVersion(); } } else { - G::Loadclass( 'fileCache' ); + require_once ('classes/class.fileCache.php'); // create cache folder $cacheFolder = PATH_DATA . "sites/" . $workspace . "/cachefiles/"; if (! file_exists( $cacheFolder )) { diff --git a/workflow/engine/classes/class.pluginRegistry.php b/workflow/engine/classes/class.pluginRegistry.php index e5facf576..c3eb2f033 100755 --- a/workflow/engine/classes/class.pluginRegistry.php +++ b/workflow/engine/classes/class.pluginRegistry.php @@ -1102,7 +1102,7 @@ class PMPluginRegistry { try { $iPlugins = 0; - G::LoadClass( 'serverConfiguration' ); + require_once ( 'class.serverConfiguration.php' ); $oServerConf = & serverConf::getSingleton(); $oServerConf->addPlugin( SYS_SYS, $this->_aPluginDetails ); foreach ($this->_aPluginDetails as $namespace => $detail) { diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index c08b14391..f6cd3314a 100755 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -786,12 +786,25 @@ function getEmailConfiguration () * @param string(32) | $sTemplate | Name of the template | The name of the template file in plain text or HTML format which will produce the body of the email. * @param array | $aFields | An optional associative array | Optional parameter. An associative array where the keys are the variable names and the values are the variables' values. * @param array | $aAttachment | Attachment | An Optional arrray. An array of files (full paths) to be attached to the email. + * @param boolean | $showMessage = true | Show message | Optional parameter. + * @param int | $delIndex = 0 | Delegation index of the case | Optional parameter. The delegation index of the current task in the case. * @return int | $result | result | Result of sending email * */ //@param array | $aFields=array() | An associative array optional | Optional parameter. An associative array where the keys are the variable name and the values are the variable's value. -function PMFSendMessage ($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $aFields = array(), $aAttachment = array(), $showMessage = true) -{ +function PMFSendMessage( + $caseId, + $sFrom, + $sTo, + $sCc, + $sBcc, + $sSubject, + $sTemplate, + $aFields = array(), + $aAttachment = array(), + $showMessage = true, + $delIndex = 0 +) { global $oPMScript; if (isset( $oPMScript->aFields ) && is_array( $oPMScript->aFields )) { @@ -802,9 +815,22 @@ function PMFSendMessage ($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTempla } } - G::LoadClass( 'wsBase' ); + G::LoadClass("wsBase"); + $ws = new wsBase(); - $result = $ws->sendMessage( $caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $aFields, $aAttachment, $showMessage); + $result = $ws->sendMessage( + $caseId, + $sFrom, + $sTo, + $sCc, + $sBcc, + $sSubject, + $sTemplate, + $aFields, + $aAttachment, + $showMessage, + $delIndex + ); if ($result->status_code == 0) { return 1; @@ -1290,6 +1316,49 @@ function WSUnpauseCase ($caseUid, $delIndex, $userUid) return $response; } +/** + * + * @method Add case note. + * + * @name WSAddCaseNote + * @label WS Add case note + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#WSAddCaseNote.28.29 + * + * @param string(32) | $caseUid | ID of the case | The unique ID of the case. + * @param string(32) | $processUid | ID of the process | The unique ID of the process. + * @param string(32) | $taskUid | ID of the task | The unique ID of the task. + * @param string(32) | $userUid | ID user | The unique ID of the user who will add note case. + * @param string | $note | Note of the case | Note of the case. + * @param int | $sendMail = 1 | Send mail | Optional parameter. If set to 1, will send an email to all participants in the case. + * @return array | $response | WS array | A WS Response associative array. + * + */ +function WSAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1) +{ + $client = WSOpen(); + + $sessionId = $_SESSION["WS_SESSION_ID"]; + + $params = array( + "sessionId" => $sessionId, + "caseUid" => $caseUid, + "processUid" => $processUid, + "taskUid" => $taskUid, + "userUid" => $userUid, + "note" => $note, + "sendMail" => $sendMail + ); + + $result = $client->__soapCall("addCaseNote", array($params)); + + $response = array(); + $response["status_code"] = $result->status_code; + $response["message"] = $result->message; + $response["time_stamp"] = $result->timestamp; + + return $response; +} + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1377,6 +1446,65 @@ function PMFUserList () //its test was successfull return $rows; } +/** + * @method + * + * Add a input document. + * + * @name PMFAddInputDocument + * @label PMF Add a input document. + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFAddInputDocument.28.29 + * + * @param string(32) | $inputDocumentUid | ID of the input document | The unique ID of the input document. + * @param string(32) | $appDocUid | ID of the application document | The unique ID of the application document; if action is set to null or empty (Add), then this parameter it set to null or empty. + * @param int | $docVersion | Document version | Document version. + * @param string | $appDocType = "INPUT" | Document type | Document type. + * @param string | $appDocComment | Document comment | Document comment. + * @param string | $inputDocumentAction | Action | Action, posible values: null or empty (Add), "R" (Replace), "NV" (New Version). + * @param string(32) | $caseUid | ID of the case | The unique ID of the case. + * @param int | $delIndex | Delegation index of the case | The delegation index of the current task in the case. + * @param string(32) | $taskUid | ID of the task | The unique ID of the task. + * @param string(32) | $userUid | ID user | The unique ID of the user who will add a input document. + * @param string | $option = "file" | Option | Option, value: "file". + * @param string | $file = "path_to_file/myfile.txt" | File, path to file | File, path to file. + * @return string | $appDocUid | ID of the application document | Returns ID if it has added the input document successfully; otherwise, returns null or empty if an error occurred. + * + */ +function PMFAddInputDocument( + $inputDocumentUid, + $appDocUid, + $docVersion, + $appDocType = "INPUT", + $appDocComment, + $inputDocumentAction, + $caseUid, + $delIndex, + $taskUid, + $userUid, + $option = "file", + $file = "path_to_file/myfile.txt" +) { + G::LoadClass("case"); + $case = new Cases(); + + $appDocUid = $case->addInputDocument( + $inputDocumentUid, + $appDocUid, + $docVersion, + $appDocType, + $appDocComment, + $inputDocumentAction, + $caseUid, + $delIndex, + $taskUid, + $userUid, + $option, + $file + ); + + return $appDocUid; +} + /** * * @method Generates an Output Document @@ -1402,7 +1530,7 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu G::LoadClass( 'case' ); $oCase = new Cases(); - $oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'cases_List' ); + $oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'casesListExtJs' ); //require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new OutputDocument(); @@ -1981,7 +2109,7 @@ function jumping ($caseId, $delIndex) } catch (Exception $oException) { G::SendTemporalMessage( 'ID_NOT_DERIVATED', 'error', 'labels' ); } - G::header( 'Location: cases_List' ); + G::header( 'Location: casesListExtJs' ); } /** @@ -2296,10 +2424,13 @@ function PMFGetCaseNotes ($applicationID, $type = 'array', $userUid = '') /** * - * @method Delete a specified case. + * @method + * + * Delete a specified case. * * @name PMFDeleteCase * @label PMF Delete a specified case. + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFDeleteCase.28.29 * * @param string(32) | $caseUid | ID of the case | The unique ID of the case. * @return int | $result | Result of the elimination | Returns 1 if the case is delete successfully; otherwise, returns 0 if an error occurred. @@ -2321,10 +2452,13 @@ function PMFDeleteCase ($caseUid) /** * - * @method Cancel a specified case. + * @method + * + * Cancel a specified case. * * @name PMFCancelCase * @label PMF Cancel a specified case. + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFCancelCase.28.29 * * @param string(32) | $caseUid | ID of the case | The unique ID of the case. * @param int | $delIndex | Delegation index of the case | The delegation index of the current task in the case. @@ -2358,10 +2492,13 @@ function PMFCancelCase ($caseUid, $delIndex, $userUid) /** * - * @method Pauses a specified case. + * @method + * + * Pauses a specified case. * * @name PMFPauseCase * @label PMF Pauses a specified case. + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFPauseCase.28.29 * * @param string(32) | $caseUid | ID of the case | The unique ID of the case. * @param int | $delIndex | Delegation index of the case | The delegation index of the current task in the case. @@ -2396,10 +2533,13 @@ function PMFPauseCase ($caseUid, $delIndex, $userUid, $unpauseDate = null) /** * - * @method Unpause a specified case. + * @method + * + * Unpause a specified case. * * @name PMFUnpauseCase * @label PMF Unpause a specified case. + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFUnpauseCase.28.29 * * @param string(32) | $caseUid | ID of the case | The unique ID of the case. * @param int | $delIndex | Delegation index of the case | The delegation index of the current task in the case. @@ -2421,3 +2561,36 @@ function PMFUnpauseCase ($caseUid, $delIndex, $userUid) } } +/** + * + * @method + * + * Add case note. + * + * @name PMFAddCaseNote + * @label PMF Add case note + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFAddCaseNote.28.29 + * + * @param string(32) | $caseUid | ID of the case | The unique ID of the case. + * @param string(32) | $processUid | ID of the process | The unique ID of the process. + * @param string(32) | $taskUid | ID of the task | The unique ID of the task. + * @param string(32) | $userUid | ID user | The unique ID of the user who will add note case. + * @param string | $note | Note of the case | Note of the case. + * @param int | $sendMail = 1 | Send mail | Optional parameter. If set to 1, will send an email to all participants in the case. + * @return int | $result | Result of the add case note | Returns 1 if the note has been added to the case.; otherwise, returns 0 if an error occurred. + * + */ +function PMFAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1) +{ + G::LoadClass("wsBase"); + + $ws = new wsBase(); + $result = $ws->addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail); + + if ($result->status_code == 0) { + return 1; + } else { + return 0; + } +} + diff --git a/workflow/engine/classes/class.pmScript.php b/workflow/engine/classes/class.pmScript.php index 49237f580..f55e7786a 100755 --- a/workflow/engine/classes/class.pmScript.php +++ b/workflow/engine/classes/class.pmScript.php @@ -545,6 +545,7 @@ function handleErrors ($errno, $errstr, $errfile, $errline) if (isset($oPMScript) && isset($_SESSION['APPLICATION'])) { G::LoadClass( 'case' ); $oCase = new Cases(); + $oPMScript->aFields['__ERROR__'] = $errstr; $oCase->updateCase($_SESSION['APPLICATION'], array('APP_DATA' => $oPMScript->aFields)); } registerError( 1, $errstr, $errline - 1, $sCode ); @@ -578,6 +579,7 @@ function handleFatalErrors ($buffer) } global $oPMScript; if (isset($oPMScript) && isset($_SESSION['APPLICATION'])) { + $oPMScript->aFields['__ERROR__'] = $aAux[0]; $oCase->updateCase($_SESSION['APPLICATION'], array('APP_DATA' => $oPMScript->aFields)); } G::header( 'Location: ' . $aNextStep['PAGE'] ); @@ -586,6 +588,7 @@ function handleFatalErrors ($buffer) $_SESSION['_NO_EXECUTE_TRIGGERS_'] = 1; global $oPMScript; if (isset($oPMScript) && isset($_SESSION['APPLICATION'])) { + $oPMScript->aFields['__ERROR__'] = $aAux[0]; $oCase->updateCase($_SESSION['APPLICATION'], array('APP_DATA' => $oPMScript->aFields)); } G::header( 'Location: ' . $_SERVER['REQUEST_URI'] ); @@ -602,6 +605,7 @@ function handleFatalErrors ($buffer) } global $oPMScript; if (isset($oPMScript) && isset($_SESSION['APPLICATION'])) { + $oPMScript->aFields['__ERROR__'] = $aAux[0]; $oCase->updateCase($_SESSION['APPLICATION'], array('APP_DATA' => $oPMScript->aFields)); } G::header( 'Location: ' . $aNextStep['PAGE'] ); diff --git a/workflow/engine/classes/class.processMap.php b/workflow/engine/classes/class.processMap.php index 9e0b12506..35dd9ba6d 100755 --- a/workflow/engine/classes/class.processMap.php +++ b/workflow/engine/classes/class.processMap.php @@ -28,41 +28,41 @@ * * @package workflow.engine.ProcessMaker */ -G::LoadThirdParty( 'pear/json', 'class.json' ); -G::LoadClass( 'groups' ); -G::LoadClass( 'tasks' ); +//G::LoadThirdParty( 'pear/json', 'class.json' ); +//G::LoadClass( 'groups' ); +//G::LoadClass( 'tasks' ); G::LoadClass( 'xmlfield_InputPM' ); -G::LoadClass( 'calendar' ); +//G::LoadClass( 'calendar' ); -require_once 'classes/model/AppDelegation.php'; -require_once 'classes/model/CaseTracker.php'; -require_once 'classes/model/CaseTrackerObject.php'; -require_once 'classes/model/Configuration.php'; -require_once 'classes/model/Content.php'; -require_once 'classes/model/DbSource.php'; -require_once 'classes/model/Dynaform.php'; -require_once 'classes/model/Event.php'; -require_once 'classes/model/Groupwf.php'; -require_once 'classes/model/InputDocument.php'; -require_once 'classes/model/ObjectPermission.php'; -require_once 'classes/model/OutputDocument.php'; -require_once 'classes/model/Process.php'; -require_once 'classes/model/ProcessUser.php'; -require_once 'classes/model/ReportTable.php'; -require_once 'classes/model/Route.php'; -require_once 'classes/model/CaseScheduler.php'; -require_once 'classes/model/LogCasesScheduler.php'; -require_once 'classes/model/Step.php'; -require_once 'classes/model/StepSupervisor.php'; -require_once 'classes/model/StepTrigger.php'; -require_once 'classes/model/SubProcess.php'; -require_once 'classes/model/SwimlanesElements.php'; -require_once 'classes/model/Task.php'; -require_once 'classes/model/TaskUser.php'; -require_once 'classes/model/Triggers.php'; -require_once 'classes/model/Users.php'; -require_once 'classes/model/Gateway.php'; -require_once 'classes/model/om/BaseUsers.php'; +//require_once 'classes/model/AppDelegation.php'; +//require_once 'classes/model/CaseTracker.php'; +//require_once 'classes/model/CaseTrackerObject.php'; +//require_once 'classes/model/Configuration.php'; +//require_once 'classes/model/Content.php'; +//require_once 'classes/model/DbSource.php'; +//require_once 'classes/model/Dynaform.php'; +//require_once 'classes/model/Event.php'; +//require_once 'classes/model/Groupwf.php'; +//require_once 'classes/model/InputDocument.php'; +//require_once 'classes/model/ObjectPermission.php'; +//require_once 'classes/model/OutputDocument.php'; +//require_once 'classes/model/Process.php'; +//require_once 'classes/model/ProcessUser.php'; +//require_once 'classes/model/ReportTable.php'; +//require_once 'classes/model/Route.php'; +//require_once 'classes/model/CaseScheduler.php'; +//require_once 'classes/model/LogCasesScheduler.php'; +//require_once 'classes/model/Step.php'; +//require_once 'classes/model/StepSupervisor.php'; +//require_once 'classes/model/StepTrigger.php'; +//require_once 'classes/model/SubProcess.php'; +//require_once 'classes/model/SwimlanesElements.php'; +//require_once 'classes/model/Task.php'; +//require_once 'classes/model/TaskUser.php'; +//require_once 'classes/model/Triggers.php'; +//require_once 'classes/model/Users.php'; +//require_once 'classes/model/Gateway.php'; +//require_once 'classes/model/om/BaseUsers.php'; /** * processMap - Process Map class @@ -418,8 +418,8 @@ class processMap $oPM->taskOptions[] = $taskOption; } - $oJSON = new Services_JSON(); - return $oJSON->encode( $oPM ); + //$oJSON = new Services_JSON(); + return Bootstrap::json_encode($oPM);//$oJSON->encode( $oPM ); } catch (Exception $oError) { throw ($oError); } @@ -1426,9 +1426,8 @@ class processMap $oNewTask->statusIcons = array (); $oNewTask->statusIcons[] = array ('label' => '','icon' => '/images/alert.gif','message' => '','url' => '' ); - $oJSON = new Services_JSON(); - - return $oJSON->encode( $oNewTask ); + //$oJSON = new Services_JSON(); + return Bootstrap::json_encode($oNewTask);//$oJSON->encode( $oNewTask ); } catch (Exception $oError) { throw ($oError); } @@ -1669,8 +1668,8 @@ class processMap $oGateway->update( $aData ); } $oEncode->uid = $sGat_uid; - $oJSON = new Services_JSON(); - return $oJSON->encode( $oEncode ); + //$oJSON = new Services_JSON(); + return Bootstrap::json_encode($oEncode);//$oJSON->encode( $oEncode ); } catch (Exception $oError) { throw ($oError); } @@ -1700,8 +1699,8 @@ class processMap ) ); break; } - $oJSON = new Services_JSON(); - return $oJSON->encode( $oNewGuide ); + //$oJSON = new Services_JSON(); + return Bootstrap::json_encode($oNewGuide);//$oJSON->encode( $oNewGuide ); } catch (Exception $oError) { throw ($oError); } @@ -1791,8 +1790,8 @@ class processMap $oSL = new SwimlanesElements(); $oNewText->uid = $oSL->create( array ('PRO_UID' => $sProcessUID,'SWI_TYPE' => 'TEXT','SWI_TEXT' => $sLabel,'SWI_X' => $iX,'SWI_Y' => $iY,'SWI_NEXT_UID' => $sNext_uid ) ); - $oJSON = new Services_JSON(); - return $oJSON->encode( $oNewText ); + //$oJSON = new Services_JSON(); + return Bootstrap::json_encode($oNewText);//$oJSON->encode( $oNewText ); } catch (Exception $oError) { throw ($oError); } @@ -4660,14 +4659,14 @@ class processMap $oNewTask->label = 'Sub-Process'; //G::LoadTranslation('ID_TASK'); $oNewTask->uid = $oTask->create( array ('PRO_UID' => $sProcessUID,'TAS_TITLE' => $oNewTask->label,'TAS_POSX' => $iX,'TAS_POSY' => $iY,'TAS_TYPE' => 'SUBPROCESS' ) ); - $oJSON = new Services_JSON(); + //$oJSON = new Services_JSON(); $oOP = new SubProcess(); $aData = array ('SP_UID' => G::generateUniqueID(),'PRO_UID' => 0,'TAS_UID' => 0,'PRO_PARENT' => $sProcessUID,'TAS_PARENT' => $oNewTask->uid,'SP_TYPE' => 'SIMPLE','SP_SYNCHRONOUS' => 0,'SP_SYNCHRONOUS_TYPE' => 'ALL','SP_SYNCHRONOUS_WAIT' => 0,'SP_VARIABLES_OUT' => '','SP_VARIABLES_IN' => '','SP_GRID_IN' => '' ); $oOP->create( $aData ); - return $oJSON->encode( $oNewTask ); + return Bootstrap::json_endoce($oNewTask);//$oJSON->encode( $oNewTask ); } catch (Exception $oError) { throw ($oError); } @@ -5081,8 +5080,8 @@ class processMap ); $oDataset->next(); } - $oJSON = new Services_JSON(); - return $oJSON->encode( $aProcesses ); + //$oJSON = new Services_JSON(); + return Bootstrap::json_encode($aProcesses);//$oJSON->encode( $aProcesses ); } /* @@ -7396,8 +7395,8 @@ class processMap $oEvent->update( $aData ); } $oEncode->uid = $sEvn_uid; - $oJSON = new Services_JSON(); - return $oJSON->encode( $oEncode ); + //$oJSON = new Services_JSON(); + return Bootstrap::json_encode($oEncode);//$oJSON->encode( $oEncode ); } public function saveExtEvents ($oData) diff --git a/workflow/engine/classes/class.propelTable.php b/workflow/engine/classes/class.propelTable.php index c4f616b8a..0cbd101df 100755 --- a/workflow/engine/classes/class.propelTable.php +++ b/workflow/engine/classes/class.propelTable.php @@ -338,8 +338,13 @@ class propelTable $this->tpl->newBlock( "headers" ); $sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? 'DESC' : 'ASC'); $sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '' : $sortOrder); - $this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? (G::createUID( '', $this->fields[$r]['Name'] ) . '=' . $sortOrder) : '') . '&page=' . $this->currentPage; - $this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID( '', $this->fields[$r]['Name'] ) . '" , "' . $sortOrder . '");return false;'; + if ($this->style[$r]['titleVisibility'] != '0') { + $this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? (G::createUID( '', $this->fields[$r]['Name'] ) . '=' . $sortOrder) : '') . '&page=' . $this->currentPage; + $this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID( '', $this->fields[$r]['Name'] ) . '" , "' . $sortOrder . '");return false;'; + } else { + $this->style[$r]['href'] = '#'; + $this->style[$r]['onsort'] = 'return false;'; + } if (isset( $this->style[$r]['href'] )) { $this->tpl->assign( "href", $this->style[$r]['href'] ); } @@ -492,7 +497,7 @@ class propelTable } } //Hidden titles - if (! (strpos( ' linknew button endgrid2 ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) { + if (! (strpos( ' linknew button link endgrid2 ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) { $this->style[$r]['titleVisibility'] = '0'; } //Align titles diff --git a/workflow/engine/classes/class.wsBase.php b/workflow/engine/classes/class.wsBase.php index 83735c483..fe9a6f8dd 100755 --- a/workflow/engine/classes/class.wsBase.php +++ b/workflow/engine/classes/class.wsBase.php @@ -30,6 +30,7 @@ require_once ("classes/model/AppCacheView.php"); require_once ("classes/model/AppDelegation.php"); require_once ("classes/model/AppDocument.php"); require_once ("classes/model/AppDelay.php"); +require_once ("classes/model/AppNotes.php"); require_once ("classes/model/AppThread.php"); require_once ("classes/model/Department.php"); require_once ("classes/model/Dynaform.php"); @@ -728,10 +729,24 @@ class wsBase * @param string $sSubject * @param string $sTemplate * @param $appFields = null + * @param $aAttachment = null + * @param boolean $showMessage = true + * @param int $delIndex = 0 * @return $result will return an object */ - public function sendMessage ($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $appFields = null, $aAttachment = null, $showMessage = true) - { + public function sendMessage( + $caseId, + $sFrom, + $sTo, + $sCc, + $sBcc, + $sSubject, + $sTemplate, + $appFields = null, + $aAttachment = null, + $showMessage = true, + $delIndex = 0 + ) { try { G::loadClass( 'system' ); @@ -788,7 +803,21 @@ class wsBase } $showMessage = ($showMessage) ? 1 : 0 ; - $messageArray = array ('msg_uid' => '','app_uid' => $caseId,'del_index' => 0,'app_msg_type' => 'TRIGGER','app_msg_subject' => $sSubject,'app_msg_from' => $sFrom,'app_msg_to' => $sTo,'app_msg_body' => $sBody,'app_msg_cc' => $sCc,'app_msg_bcc' => $sBcc,'app_msg_attach' => $aAttachment,'app_msg_template' => '','app_msg_status' => 'pending', 'app_msg_show_message' => $showMessage + $messageArray = array( + "msg_uid" => "", + "app_uid" => $caseId, + "del_index" => $delIndex, + "app_msg_type" => "TRIGGER", + "app_msg_subject" => $sSubject, + "app_msg_from" => $sFrom, + "app_msg_to" => $sTo, + "app_msg_body" => $sBody, + "app_msg_cc" => $sCc, + "app_msg_bcc" => $sBcc, + "app_msg_attach" => $aAttachment, + "app_msg_template" => "", + "app_msg_status" => "pending", + "app_msg_show_message" => $showMessage ); $oSpool->create( $messageArray ); @@ -3026,5 +3055,75 @@ class wsBase return $result; } } + + /** + * Add case note + * + * @param string caseUid : ID of the case. + * @param string processUid : ID of the process. + * @param string taskUid : ID of the task. + * @param string userUid : The unique ID of the user who will add note case. + * @param string note : Note of the case. + * @param int sendMail : Optional parameter. If set to 1, will send an email to all participants in the case. + * @return $result will return an object + */ + public function addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1) + { + try { + if (empty($caseUid)) { + $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " caseUid"); + + return $result; + } + + if (empty($processUid)) { + $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " processUid"); + + return $result; + } + + if (empty($taskUid)) { + $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " taskUid"); + + return $result; + } + + if (empty($userUid)) { + $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " userUid"); + + return $result; + } + + if (empty($note)) { + $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " note"); + + return $result; + } + + $case = new Cases(); + + $respView = $case->getAllObjectsFrom($processUid, $caseUid, $taskUid, $userUid, "VIEW"); + $respBlock = $case->getAllObjectsFrom($processUid, $caseUid, $taskUid, $userUid, "BLOCK"); + + if ($respView["CASES_NOTES"] == 0 && $respBlock["CASES_NOTES"] == 0) { + $result = new wsResponse(100, G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")); + + return $result; + } + + //Add note case + $appNote = new AppNotes(); + $response = $appNote->addCaseNote($caseUid, $userUid, $note, $sendMail); + + //Response + $result = new wsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY")); + + return $result; + } catch (Exception $e) { + $result = new wsResponse(100, $e->getMessage()); + + return $result; + } + } } diff --git a/workflow/engine/classes/class.xmlfield_InputPM.php b/workflow/engine/classes/class.xmlfield_InputPM.php index c9109f607..1bae9495b 100755 --- a/workflow/engine/classes/class.xmlfield_InputPM.php +++ b/workflow/engine/classes/class.xmlfield_InputPM.php @@ -386,8 +386,10 @@ function getDynaformsVars ($sProcessUID, $bSystemVars = true, $bIncMulSelFields $aFields[] = array ('sName' => 'PIN','sType' => 'system','sLabel' => 'System variable' ); } - $aInvalidTypes = array ('title','subtitle','link','file','button','reset','submit','javascript'); - $aMultipleSelectionFields = array ('listbox','checkgroup','grid'); + + $aInvalidTypes = array("title", "subtitle", "file", "button", "reset", "submit", "javascript"); + $aMultipleSelectionFields = array("listbox", "checkgroup", "grid"); + if ($bIncMulSelFields != 0) { $aInvalidTypes = array_merge( $aInvalidTypes, $aMultipleSelectionFields ); } diff --git a/workflow/engine/classes/entities/AppSolrQueue.php b/workflow/engine/classes/entities/AppSolrQueue.php index 9f12d9cff..3e7d6d9f0 100755 --- a/workflow/engine/classes/entities/AppSolrQueue.php +++ b/workflow/engine/classes/entities/AppSolrQueue.php @@ -1,5 +1,5 @@ getAppMsgUid(); } } + + public function updateStatus($msgUid, $msgStatus) + { + $message = AppMessagePeer::retrieveByPk( $msgUid ); + $message->fromArray( $message, BasePeer::TYPE_FIELDNAME ); + $message->setAppMsgStatus($msgStatus); + $message->save(); + } } diff --git a/workflow/engine/classes/model/AppMessagePeer.php b/workflow/engine/classes/model/AppMessagePeer.php index a113f98b1..9d5decb4f 100755 --- a/workflow/engine/classes/model/AppMessagePeer.php +++ b/workflow/engine/classes/model/AppMessagePeer.php @@ -25,10 +25,10 @@ */ // include base peer class - require_once 'classes/model/om/BaseAppMessagePeer.php'; + //require_once 'classes/model/om/BaseAppMessagePeer.php'; // include object class - include_once 'classes/model/AppMessage.php'; + //include_once 'classes/model/AppMessage.php'; /** diff --git a/workflow/engine/classes/model/AppNotes.php b/workflow/engine/classes/model/AppNotes.php index 56ca7f3d0..b5b7e446d 100755 --- a/workflow/engine/classes/model/AppNotes.php +++ b/workflow/engine/classes/model/AppNotes.php @@ -1,6 +1,6 @@ '; $oSpool = new spoolRun(); - if ($aConfiguration['MESS_RAUTH'] == false || (is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false')) { - $aConfiguration['MESS_RAUTH'] = 0; - } else { - $aConfiguration['MESS_RAUTH'] = 1; + if ($aConfiguration['MESS_RAUTH'] == false || (is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false')) { + $aConfiguration['MESS_RAUTH'] = 0; + } else { + $aConfiguration['MESS_RAUTH'] = 1; } $oSpool->setConfig( array ('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],'MESS_SERVER' => $aConfiguration['MESS_SERVER'],'MESS_PORT' => $aConfiguration['MESS_PORT'],'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false,'SMTPSecure' => isset( $aConfiguration['SMTPSecure'] ) ? $aConfiguration['SMTPSecure'] : '') ); @@ -235,5 +235,30 @@ class AppNotes extends BaseAppNotes throw $oException; } } + + public function addCaseNote($applicationUid, $userUid, $note, $sendMail) + { + $response = $this->postNewNote($applicationUid, $userUid, $note, false); + + if ($sendMail == 1) { + G::LoadClass("case"); + + $case = new Cases(); + + $p = $case->getUsersParticipatedInCase($applicationUid); + $noteRecipientsList = array(); + + foreach ($p["array"] as $key => $userParticipated) { + $noteRecipientsList[] = $key; + } + + $noteRecipients = implode(",", $noteRecipientsList); + $note = stripslashes($note); + + $this->sendNoteNotification($applicationUid, $userUid, $note, $noteRecipients); + } + + return $response; + } } diff --git a/workflow/engine/classes/model/AppOwner.php b/workflow/engine/classes/model/AppOwner.php index afb1b3c5d..31e01e514 100755 --- a/workflow/engine/classes/model/AppOwner.php +++ b/workflow/engine/classes/model/AppOwner.php @@ -24,7 +24,7 @@ * */ -require_once 'classes/model/om/BaseAppOwner.php'; +//require_once 'classes/model/om/BaseAppOwner.php'; /** diff --git a/workflow/engine/classes/model/AppSolrQueue.php b/workflow/engine/classes/model/AppSolrQueue.php index b28e5ad86..b85ce67ca 100755 --- a/workflow/engine/classes/model/AppSolrQueue.php +++ b/workflow/engine/classes/model/AppSolrQueue.php @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + + + + + + diff --git a/workflow/engine/controllers/appProxy.php b/workflow/engine/controllers/appProxy.php index c2e198546..b9d31cd71 100755 --- a/workflow/engine/controllers/appProxy.php +++ b/workflow/engine/controllers/appProxy.php @@ -1,37 +1,37 @@ - - * @herits Controller - * @access public - */ - -class AppProxy extends HttpProxyController -{ - - /** - * Get Notes List - * - * @param int $httpData->start - * @param int $httpData->limit - * @param string $httpData->appUid (optionalif it is not passed try use $_SESSION['APPLICATION']) - * @return array containg the case notes - */ - function getNotesList ($httpData) - { - $appUid = null; - - if (isset( $httpData->appUid ) && trim( $httpData->appUid ) != "") { - $appUid = $httpData->appUid; - } else { - if (isset( $_SESSION['APPLICATION'] )) { - $appUid = $_SESSION['APPLICATION']; - } - } - - G::LoadClass( 'case' ); + + * @herits Controller + * @access public + */ + +class AppProxy extends HttpProxyController +{ + + /** + * Get Notes List + * + * @param int $httpData->start + * @param int $httpData->limit + * @param string $httpData->appUid (optionalif it is not passed try use $_SESSION['APPLICATION']) + * @return array containg the case notes + */ + function getNotesList ($httpData) + { + $appUid = null; + + if (isset( $httpData->appUid ) && trim( $httpData->appUid ) != "") { + $appUid = $httpData->appUid; + } else { + if (isset( $_SESSION['APPLICATION'] )) { + $appUid = $_SESSION['APPLICATION']; + } + } + + G::LoadClass( 'case' ); $case = new Cases(); $caseLoad = ''; @@ -39,236 +39,218 @@ class AppProxy extends HttpProxyController $caseLoad = $case->loadCase($appUid); $httpData->pro = $caseLoad['PRO_UID']; } - - $proUid = (!isset($httpData->pro)) ? $_SESSION['PROCESS'] : $httpData->pro; - $tasUid = (!isset($httpData->tas)) ? ((isset($_SESSION['TASK'])) ? $_SESSION['TASK'] : '') : $httpData->tas; - $usrUid = $_SESSION['USER_LOGGED']; - - $respView = $case->getAllObjectsFrom( $proUid, $appUid, $tasUid, $usrUid, 'VIEW' ); - $respBlock = $case->getAllObjectsFrom( $proUid, $appUid, $tasUid, $usrUid, 'BLOCK' ); - - if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { - return array ('totalCount' => 0,'notes' => array (),'noPerms' => 1 - ); - } - - require_once ("classes/model/AppNotes.php"); - - if (! isset( $appUid )) { - throw new Exception( 'Can\'t resolve the Apllication ID for this request.' ); - } - - $usrUid = isset( $_SESSION['USER_LOGGED'] ) ? $_SESSION['USER_LOGGED'] : ""; - $appNotes = new AppNotes(); - $response = $appNotes->getNotesList( $appUid, '', $httpData->start, $httpData->limit ); - - return $response['array']; - } - - /** - * post Note Action - * - * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION']) - * @return array containg the case notes - */ - function postNote ($httpData) - { + + $proUid = (!isset($httpData->pro)) ? $_SESSION['PROCESS'] : $httpData->pro; + $tasUid = (!isset($httpData->tas)) ? ((isset($_SESSION['TASK'])) ? $_SESSION['TASK'] : '') : $httpData->tas; + $usrUid = $_SESSION['USER_LOGGED']; + + $respView = $case->getAllObjectsFrom( $proUid, $appUid, $tasUid, $usrUid, 'VIEW' ); + $respBlock = $case->getAllObjectsFrom( $proUid, $appUid, $tasUid, $usrUid, 'BLOCK' ); + + if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { + return array ('totalCount' => 0,'notes' => array (),'noPerms' => 1 + ); + } + + require_once ("classes/model/AppNotes.php"); + + if (! isset( $appUid )) { + throw new Exception( 'Can\'t resolve the Apllication ID for this request.' ); + } + + $usrUid = isset( $_SESSION['USER_LOGGED'] ) ? $_SESSION['USER_LOGGED'] : ""; + $appNotes = new AppNotes(); + $response = $appNotes->getNotesList( $appUid, '', $httpData->start, $httpData->limit ); + + return $response['array']; + } + + /** + * post Note Action + * + * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION']) + * @return array containg the case notes + */ + function postNote ($httpData) + { + require_once ("classes/model/AppNotes.php"); + //extract(getExtJSParams()); - if (isset( $httpData->appUid ) && trim( $httpData->appUid ) != "") { - $appUid = $httpData->appUid; - } else { - $appUid = $_SESSION['APPLICATION']; - } - - if (! isset( $appUid )) { - throw new Exception( 'Can\'t resolve the Apllication ID for this request.' ); - } - - $usrUid = (isset( $_SESSION['USER_LOGGED'] )) ? $_SESSION['USER_LOGGED'] : ""; - require_once ("classes/model/AppNotes.php"); - - $appNotes = new AppNotes(); - $noteContent = addslashes( $httpData->noteText ); - - $result = $appNotes->postNewNote( $appUid, $usrUid, $noteContent, false ); - + if (isset( $httpData->appUid ) && trim( $httpData->appUid ) != "") { + $appUid = $httpData->appUid; + } else { + $appUid = $_SESSION['APPLICATION']; + } + + if (! isset( $appUid )) { + throw new Exception( 'Can\'t resolve the Apllication ID for this request.' ); + } + + $usrUid = (isset( $_SESSION['USER_LOGGED'] )) ? $_SESSION['USER_LOGGED'] : ""; + $noteContent = addslashes( $httpData->noteText ); + //Disabling the controller response because we handle a special behavior - $this->setSendResponse( false ); - + $this->setSendResponse(false); + + //Add note case + $appNote = new AppNotes(); + $response = $appNote->addCaseNote($appUid, $usrUid, $noteContent, intval($httpData->swSendMail)); + //Send the response to client - @ini_set( 'implicit_flush', 1 ); - ob_start(); - echo G::json_encode( $result ); - @ob_flush(); - @flush(); - @ob_end_flush(); - ob_implicit_flush( 1 ); - - //Send notification in background - if (intval( $httpData->swSendMail ) == 1) { - G::LoadClass( "case" ); - - $oCase = new Cases(); - - $p = $oCase->getUsersParticipatedInCase( $appUid ); - $noteRecipientsList = array (); - - foreach ($p["array"] as $key => $userParticipated) { - $noteRecipientsList[] = $key; - } - - $noteRecipients = implode( ",", $noteRecipientsList ); - $noteContent = stripslashes( $noteContent ); - - $appNotes->sendNoteNotification( $appUid, $usrUid, $noteContent, $noteRecipients ); - } - } - - /** - * request to open the case summary - * - * @param string $httpData->appUid - * @param string $httpData->delIndex - * @return object bool $result->succes, string $result->message(is an exception was thrown), string $result->dynUid - */ - function requestOpenSummary ($httpData) - { - global $RBAC; - $this->success = true; - $this->dynUid = ''; - - switch ($RBAC->userCanAccess( 'PM_CASES' )) { - case - 2: - throw new Exception( G::LoadTranslation( 'ID_USER_HAVENT_RIGHTS_SYSTEM' ) ); - break; - case - 1: - throw new Exception( G::LoadTranslation( 'ID_USER_HAVENT_RIGHTS_PAGE' ) ); - break; - } - - G::LoadClass( 'case' ); - $case = new Cases(); - - if ($RBAC->userCanAccess( 'PM_ALLCASES' ) < 0 && $case->userParticipatedInCase( $httpData->appUid, $_SESSION['USER_LOGGED'] ) == 0) { - throw new Exception( G::LoadTranslation( 'ID_NO_PERMISSION_NO_PARTICIPATED' ) ); - } - - if ($httpData->action == 'sent') { // Get the last valid delegation for participated list - $criteria = new Criteria(); - $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); - $criteria->add(AppDelegationPeer::APP_UID, $httpData->appUid); - $criteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); - $criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); - if (AppDelegationPeer::doCount($criteria) > 0) { - $dataset = AppDelegationPeer::doSelectRS($criteria); - $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $dataset->next(); - $row = $dataset->getRow(); - $httpData->delIndex = $row['DEL_INDEX']; - } - } - $applicationFields = $case->loadCase( $httpData->appUid, $httpData->delIndex ); - $process = new Process(); - $processData = $process->load( $applicationFields['PRO_UID'] ); - - if (isset( $processData['PRO_DYNAFORMS']['PROCESS'] )) { - $this->dynUid = $processData['PRO_DYNAFORMS']['PROCESS']; - } - - $_SESSION['_applicationFields'] = $applicationFields; - $_SESSION['_processData'] = $processData; - $_SESSION['APPLICATION'] = $httpData->appUid; - $_SESSION['INDEX'] = $httpData->delIndex; - $_SESSION['PROCESS'] = $applicationFields['PRO_UID']; - $_SESSION['TASK'] = $applicationFields['TAS_UID']; - $_SESSION['STEP_POSITION'] = ''; - } - - /** - * get the case summary data - * - * @param string $httpData->appUid - * @param string $httpData->delIndex - * @return array containg the case summary data - */ - function getSummary ($httpData) - { - $labels = array (); - $form = new Form( 'cases/cases_Resume', PATH_XMLFORM, SYS_LANG ); - G::LoadClass( 'case' ); - $case = new Cases(); - - foreach ($form->fields as $fieldName => $field) { - $labels[$fieldName] = $field->label; - } - - if (isset( $_SESSION['_applicationFields'] ) && $_SESSION['_processData']) { - $applicationFields = $_SESSION['_applicationFields']; - unset( $_SESSION['_applicationFields'] ); - $processData = $_SESSION['_processData']; - unset( $_SESSION['_processData'] ); - } else { - if ($httpData->action == 'sent') { // Get the last valid delegation for participated list - $criteria = new Criteria(); - $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); - $criteria->add(AppDelegationPeer::APP_UID, $httpData->appUid); - $criteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); - $criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); - if (AppDelegationPeer::doCount($criteria) > 0) { - $dataset = AppDelegationPeer::doSelectRS($criteria); - $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $dataset->next(); - $row = $dataset->getRow(); - $httpData->delIndex = $row['DEL_INDEX']; - } - } - $applicationFields = $case->loadCase( $httpData->appUid, $httpData->delIndex ); - $process = new Process(); - $processData = $process->load( $applicationFields['PRO_UID'] ); - } - - $data = array (); - $task = new Task(); - $taskData = $task->load( $applicationFields['TAS_UID'] ); - $currentUser = $applicationFields['CURRENT_USER'] != '' ? $applicationFields['CURRENT_USER'] : '[' . G::LoadTranslation( 'ID_UNASSIGNED' ) . ']'; - - $data[] = array ('label' => $labels['PRO_TITLE'],'value' => $processData['PRO_TITLE'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['TITLE'],'value' => $applicationFields['TITLE'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['APP_NUMBER'],'value' => $applicationFields['APP_NUMBER'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['STATUS'],'value' => $applicationFields['STATUS'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['APP_UID'],'value' => $applicationFields['APP_UID'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['CREATOR'],'value' => $applicationFields['CREATOR'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['CREATE_DATE'],'value' => $applicationFields['CREATE_DATE'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['UPDATE_DATE'],'value' => $applicationFields['UPDATE_DATE'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['DESCRIPTION'],'value' => $applicationFields['DESCRIPTION'],'section' => $labels['TITLE1'] - ); - + @ini_set("implicit_flush", 1); + ob_start(); + echo G::json_encode($response); + @ob_flush(); + @flush(); + @ob_end_flush(); + ob_implicit_flush(1); + } + + /** + * request to open the case summary + * + * @param string $httpData->appUid + * @param string $httpData->delIndex + * @return object bool $result->succes, string $result->message(is an exception was thrown), string $result->dynUid + */ + function requestOpenSummary ($httpData) + { + global $RBAC; + $this->success = true; + $this->dynUid = ''; + + switch ($RBAC->userCanAccess( 'PM_CASES' )) { + case - 2: + throw new Exception( G::LoadTranslation( 'ID_USER_HAVENT_RIGHTS_SYSTEM' ) ); + break; + case - 1: + throw new Exception( G::LoadTranslation( 'ID_USER_HAVENT_RIGHTS_PAGE' ) ); + break; + } + + G::LoadClass( 'case' ); + $case = new Cases(); + + if ($RBAC->userCanAccess( 'PM_ALLCASES' ) < 0 && $case->userParticipatedInCase( $httpData->appUid, $_SESSION['USER_LOGGED'] ) == 0) { + throw new Exception( G::LoadTranslation( 'ID_NO_PERMISSION_NO_PARTICIPATED' ) ); + } + + if ($httpData->action == 'sent') { // Get the last valid delegation for participated list + $criteria = new Criteria(); + $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); + $criteria->add(AppDelegationPeer::APP_UID, $httpData->appUid); + $criteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); + $criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); + if (AppDelegationPeer::doCount($criteria) > 0) { + $dataset = AppDelegationPeer::doSelectRS($criteria); + $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $dataset->next(); + $row = $dataset->getRow(); + $httpData->delIndex = $row['DEL_INDEX']; + } + } + $applicationFields = $case->loadCase( $httpData->appUid, $httpData->delIndex ); + $process = new Process(); + $processData = $process->load( $applicationFields['PRO_UID'] ); + + if (isset( $processData['PRO_DYNAFORMS']['PROCESS'] )) { + $this->dynUid = $processData['PRO_DYNAFORMS']['PROCESS']; + } + + $_SESSION['_applicationFields'] = $applicationFields; + $_SESSION['_processData'] = $processData; + $_SESSION['APPLICATION'] = $httpData->appUid; + $_SESSION['INDEX'] = $httpData->delIndex; + $_SESSION['PROCESS'] = $applicationFields['PRO_UID']; + $_SESSION['TASK'] = $applicationFields['TAS_UID']; + $_SESSION['STEP_POSITION'] = ''; + } + + /** + * get the case summary data + * + * @param string $httpData->appUid + * @param string $httpData->delIndex + * @return array containg the case summary data + */ + function getSummary ($httpData) + { + $labels = array (); + $form = new Form( 'cases/cases_Resume', PATH_XMLFORM, SYS_LANG ); + G::LoadClass( 'case' ); + $case = new Cases(); + + foreach ($form->fields as $fieldName => $field) { + $labels[$fieldName] = $field->label; + } + + if (isset( $_SESSION['_applicationFields'] ) && $_SESSION['_processData']) { + $applicationFields = $_SESSION['_applicationFields']; + unset( $_SESSION['_applicationFields'] ); + $processData = $_SESSION['_processData']; + unset( $_SESSION['_processData'] ); + } else { + if ($httpData->action == 'sent') { // Get the last valid delegation for participated list + $criteria = new Criteria(); + $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); + $criteria->add(AppDelegationPeer::APP_UID, $httpData->appUid); + $criteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); + $criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); + if (AppDelegationPeer::doCount($criteria) > 0) { + $dataset = AppDelegationPeer::doSelectRS($criteria); + $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $dataset->next(); + $row = $dataset->getRow(); + $httpData->delIndex = $row['DEL_INDEX']; + } + } + $applicationFields = $case->loadCase( $httpData->appUid, $httpData->delIndex ); + $process = new Process(); + $processData = $process->load( $applicationFields['PRO_UID'] ); + } + + $data = array (); + $task = new Task(); + $taskData = $task->load( $applicationFields['TAS_UID'] ); + $currentUser = $applicationFields['CURRENT_USER'] != '' ? $applicationFields['CURRENT_USER'] : '[' . G::LoadTranslation( 'ID_UNASSIGNED' ) . ']'; + + $data[] = array ('label' => $labels['PRO_TITLE'],'value' => $processData['PRO_TITLE'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['TITLE'],'value' => $applicationFields['TITLE'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['APP_NUMBER'],'value' => $applicationFields['APP_NUMBER'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['STATUS'],'value' => $applicationFields['STATUS'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['APP_UID'],'value' => $applicationFields['APP_UID'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['CREATOR'],'value' => $applicationFields['CREATOR'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['CREATE_DATE'],'value' => $applicationFields['CREATE_DATE'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['UPDATE_DATE'],'value' => $applicationFields['UPDATE_DATE'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['DESCRIPTION'],'value' => $applicationFields['DESCRIPTION'],'section' => $labels['TITLE1'] + ); + // note added by krlos pacha carlos[at]colosa[dot]com //getting this field if it doesn't exist. Related 7994 bug - $taskData['TAS_TITLE'] = (array_key_exists( 'TAS_TITLE', $taskData )) ? $taskData['TAS_TITLE'] : Content::Load( "TAS_TITLE", "", $applicationFields['TAS_UID'], SYS_LANG ); - - $data[] = array ('label' => $labels['TAS_TITLE'],'value' => $taskData['TAS_TITLE'],'section' => $labels['TITLE2'] - ); - $data[] = array ('label' => $labels['CURRENT_USER'],'value' => $currentUser,'section' => $labels['TITLE2'] - ); - $data[] = array ('label' => $labels['DEL_DELEGATE_DATE'],'value' => $applicationFields['DEL_DELEGATE_DATE'],'section' => $labels['TITLE2'] - ); - $data[] = array ('label' => $labels['DEL_INIT_DATE'],'value' => $applicationFields['DEL_INIT_DATE'],'section' => $labels['TITLE2'] - ); - $data[] = array ('label' => $labels['DEL_TASK_DUE_DATE'],'value' => $applicationFields['DEL_TASK_DUE_DATE'],'section' => $labels['TITLE2'] - ); - $data[] = array ('label' => $labels['DEL_FINISH_DATE'],'value' => $applicationFields['DEL_FINISH_DATE'],'section' => $labels['TITLE2'] - ); + $taskData['TAS_TITLE'] = (array_key_exists( 'TAS_TITLE', $taskData )) ? $taskData['TAS_TITLE'] : Content::Load( "TAS_TITLE", "", $applicationFields['TAS_UID'], SYS_LANG ); + + $data[] = array ('label' => $labels['TAS_TITLE'],'value' => $taskData['TAS_TITLE'],'section' => $labels['TITLE2'] + ); + $data[] = array ('label' => $labels['CURRENT_USER'],'value' => $currentUser,'section' => $labels['TITLE2'] + ); + $data[] = array ('label' => $labels['DEL_DELEGATE_DATE'],'value' => $applicationFields['DEL_DELEGATE_DATE'],'section' => $labels['TITLE2'] + ); + $data[] = array ('label' => $labels['DEL_INIT_DATE'],'value' => $applicationFields['DEL_INIT_DATE'],'section' => $labels['TITLE2'] + ); + $data[] = array ('label' => $labels['DEL_TASK_DUE_DATE'],'value' => $applicationFields['DEL_TASK_DUE_DATE'],'section' => $labels['TITLE2'] + ); + $data[] = array ('label' => $labels['DEL_FINISH_DATE'],'value' => $applicationFields['DEL_FINISH_DATE'],'section' => $labels['TITLE2'] + ); //$data[] = array('label'=>$labels['DYN_UID'] , 'value' => $processData['PRO_DYNAFORMS']['PROCESS'];, 'section'=>$labels['DYN_UID']); - return $data; - } -} - + return $data; + } +} + diff --git a/workflow/engine/controllers/main.php b/workflow/engine/controllers/main.php index a5c0b076e..4ae78856f 100755 --- a/workflow/engine/controllers/main.php +++ b/workflow/engine/controllers/main.php @@ -499,8 +499,7 @@ class Main extends Controller public function getLanguagesList () { - //translation - $Translations = G::getModel( "Translation" ); + $Translations = new Translation; $translationsTable = $Translations->getTranslationEnvironments(); if (($languagesList = $this->memcache->get( 'languagesList' )) === false) { diff --git a/workflow/engine/data/mssql/schema.sql b/workflow/engine/data/mssql/schema.sql index 1d96a5d99..fbe9133ce 100755 --- a/workflow/engine/data/mssql/schema.sql +++ b/workflow/engine/data/mssql/schema.sql @@ -165,6 +165,9 @@ CREATE TABLE [APP_DOCUMENT] CONSTRAINT APP_DOCUMENT_PK PRIMARY KEY ([APP_DOC_UID],[DOC_VERSION]) ); + +CREATE INDEX [indexAppDocument] ON [APP_DOCUMENT] ([FOLDER_UID],[APP_DOC_UID]); + /* ---------------------------------------------------------------------- */ /* APP_MESSAGE */ /* ---------------------------------------------------------------------- */ diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index f78743d52..13ad27add 100755 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -90,7 +90,9 @@ CREATE TABLE `APP_DOCUMENT` `APP_DOC_STATUS` VARCHAR(32) default 'ACTIVE' NOT NULL, `APP_DOC_STATUS_DATE` DATETIME, `APP_DOC_FIELDNAME` VARCHAR(150), - PRIMARY KEY (`APP_DOC_UID`,`DOC_VERSION`) + PRIMARY KEY (`APP_DOC_UID`,`DOC_VERSION`), + + KEY `indexAppDocument`(`FOLDER_UID`, `APP_DOC_UID`) )ENGINE=MyISAM DEFAULT CHARSET='utf8' COMMENT='Documents in an Application'; #----------------------------------------------------------------------------- #-- APP_MESSAGE diff --git a/workflow/engine/data/oracle/schema.sql b/workflow/engine/data/oracle/schema.sql index 1a6bf4140..59b6ef8ea 100755 --- a/workflow/engine/data/oracle/schema.sql +++ b/workflow/engine/data/oracle/schema.sql @@ -86,6 +86,8 @@ CREATE TABLE "APP_DOCUMENT" PRIMARY KEY ("APP_DOC_UID"); + CREATE INDEX "indexAppDocument" ON "APP_DOCUMENT" ("FOLDER_UID","APP_DOC_UID"); + /* ----------------------------------------------------------------------- APP_MESSAGE ----------------------------------------------------------------------- */ diff --git a/workflow/engine/js/dynaformEditor/core/dynaformEditor.js b/workflow/engine/js/dynaformEditor/core/dynaformEditor.js index 613354d92..c8ebfbfdc 100755 --- a/workflow/engine/js/dynaformEditor/core/dynaformEditor.js +++ b/workflow/engine/js/dynaformEditor/core/dynaformEditor.js @@ -264,6 +264,50 @@ var dynaformEditor={ url='dynaforms_Saveas'; popupWindow('Save as', url+'?DYN_UID='+this.dynUid+'&AA='+this.A , 500, 350); }, + importForm:function(){ + panelImportDyna = new leimnud.module.panel(); + panelImportDyna.options={ + limit : true, + size : {w:410,h:160}, + position : {x:0,y:0,center:true}, + title : '', + theme : 'processmaker', + statusBar: false, + control : {drag:false,resize:true,close:false}, + fx : {opacity:true,rolled:false,modal:true} + }; + panelImportDyna.setStyle = {modal: { + backgroundColor: 'white' + }}; + panelImportDyna.make(); + panelImportDyna.addContent('
'); + var oRPC = new leimnud.module.rpc.xmlhttp({ + url : '../dynaforms/fieldsHandlerAjax', + async : false, + method: 'POST', + args : 'request=showImportForm' + '&DYN_UID=' + this.dynUid + }); + oRPC.make(); + document.getElementById('importAjax').style.display = 'none'; + panelImportDyna.addContent(oRPC.xmlhttp.responseText); + }, + import:function(uidDynaSelect){ + document.getElementById('importAjax').style.display = 'block'; + document.getElementById('importForm').style.display = 'none'; + var oRPC = new leimnud.module.rpc.xmlhttp({ + url : '../dynaforms/fieldsHandlerAjax', + async : false, + method: 'POST', + args : 'request=import' + '&DYN_UID=' + this.dynUid + '&FILE=' + uidDynaSelect + }); + oRPC.make(); + resp = oRPC.xmlhttp.responseText; + if (resp == 'success') { + location.reload(true); + } else { + alert("Error: " + resp); + } + }, close:function() { if (!sessionPersits()) { diff --git a/workflow/engine/menus/setup.php b/workflow/engine/menus/setup.php index bd0fd6a6f..7f562e290 100755 --- a/workflow/engine/menus/setup.php +++ b/workflow/engine/menus/setup.php @@ -85,5 +85,6 @@ if ($RBAC->userCanAccess('PM_SETUP') == 1) { $G_TMP_MENU->AddIdRawOption('EVENT', '../events/eventList', G::LoadTranslation('ID_EVENTS'), '', '', 'logs'); $G_TMP_MENU->AddIdRawOption('LOG_CASE_SCHEDULER', '../cases/cases_Scheduler_Log', G::LoadTranslation('ID_CASE_SCHEDULER'), "icon-logs-list.png",'', 'logs'); $G_TMP_MENU->AddIdRawOption("CRON", "../setup/cron", G::LoadTranslation("ID_CRON_ACTIONS"), null, null, "logs"); + $G_TMP_MENU->AddIdRawOption('EMAILS', '../mails/emailList', ucfirst (strtolower ( G::LoadTranslation('ID_EMAILS'))), '', '', 'logs'); } diff --git a/workflow/engine/methods/cases/ajaxListener.php b/workflow/engine/methods/cases/ajaxListener.php index 35c120bab..f2d8a0f1f 100755 --- a/workflow/engine/methods/cases/ajaxListener.php +++ b/workflow/engine/methods/cases/ajaxListener.php @@ -28,12 +28,12 @@ * @date Jan 3th, 2010 */ -require_once 'classes/model/Application.php'; -require_once 'classes/model/Users.php'; -require_once 'classes/model/AppThread.php'; -require_once 'classes/model/AppDelay.php'; -require_once 'classes/model/Process.php'; -require_once 'classes/model/Task.php'; +//require_once 'classes/model/Application.php'; +//require_once 'classes/model/Users.php'; +//require_once 'classes/model/AppThread.php'; +//require_once 'classes/model/AppDelay.php'; +//require_once 'classes/model/Process.php'; +//require_once 'classes/model/Task.php'; G::LoadClass( 'case' ); $action = $_REQUEST['action']; diff --git a/workflow/engine/methods/cases/casesHistoryDynaformPage_Ajax.php b/workflow/engine/methods/cases/casesHistoryDynaformPage_Ajax.php index 3257165ed..f42d56a17 100755 --- a/workflow/engine/methods/cases/casesHistoryDynaformPage_Ajax.php +++ b/workflow/engine/methods/cases/casesHistoryDynaformPage_Ajax.php @@ -434,12 +434,27 @@ if ($actionAjax == 'historyDynaformGridPreview') { $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = '#'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'return false;'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['DYNUIDPRINT'] = $_POST['DYN_UID']; + ?> + + + AddContent( 'dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_POST['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' ); ?> -getConditionCasesList( 'to_do', $sUserToReassign ); - list ($oCriteriaDraft, $sXMLFile) = $oCases->getConditionCasesList( 'draft', $sUserToReassign ); + $oAppCache = new AppCacheView(); + + $oCriteriaToDo = $oAppCache->getToDoListCriteria($sUserToReassign); + $oCriteriaDraft = $oAppCache->getDraftListCriteria($sUserToReassign); $aCasesList = Array (); diff --git a/workflow/engine/methods/cases/cases_SaveData.php b/workflow/engine/methods/cases/cases_SaveData.php index 02c4ad0f9..8586c5335 100755 --- a/workflow/engine/methods/cases/cases_SaveData.php +++ b/workflow/engine/methods/cases/cases_SaveData.php @@ -39,7 +39,7 @@ try { //Load the variables $oCase = new Cases(); - $oCase->thisIsTheCurrentUser( $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "cases_List" ); + $oCase->thisIsTheCurrentUser( $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs" ); $Fields = $oCase->loadCase( $_SESSION["APPLICATION"] ); $Fields["APP_DATA"] = array_merge( $Fields["APP_DATA"], G::getSystemConstants() ); @@ -162,7 +162,7 @@ try { } //Save files - require_once ("classes/model/AppDocument.php"); + //require_once ("classes/model/AppDocument.php"); if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) { $arrayField = array (); @@ -218,8 +218,8 @@ try { } if ($indocUid != null) { - require_once ("classes/model/AppFolder.php"); - require_once ("classes/model/InputDocument.php"); + //require_once ("classes/model/AppFolder.php"); + //require_once ("classes/model/InputDocument.php"); $oInputDocument = new InputDocument(); $aID = $oInputDocument->load( $indocUid ); @@ -296,9 +296,9 @@ try { } $oForm->validatePost(); - $oJSON = new Services_JSON(); + //$oJSON = new Services_JSON(); $_POST['__notValidateThisFields__'] = (isset( $_POST['__notValidateThisFields__'] ) && $_POST['__notValidateThisFields__'] != '') ? $_POST['__notValidateThisFields__'] : $_POST['DynaformRequiredFields']; - if ($missing_req_values = $oForm->validateRequiredFields( $_POST['form'], $oJSON->decode( stripslashes( $_POST['__notValidateThisFields__'] ) ) )) { + if ($missing_req_values = $oForm->validateRequiredFields( $_POST['form'], Bootstrap::json_decode( stripslashes( $_POST['__notValidateThisFields__'] ) ) )) { $_POST['next_step'] = $aNextStep; $_POST['previous_step'] = $oCase->getPreviousStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); $_POST['req_val'] = $missing_req_values; diff --git a/workflow/engine/methods/cases/cases_SaveDocument.php b/workflow/engine/methods/cases/cases_SaveDocument.php index b9a5033f7..5e37770ea 100755 --- a/workflow/engine/methods/cases/cases_SaveDocument.php +++ b/workflow/engine/methods/cases/cases_SaveDocument.php @@ -59,136 +59,86 @@ if ((isset( $_FILES['form'] )) && ($_FILES['form']['error']['APP_DOC_FILENAME'] die(); } -$docUid = $_POST['form']['DOC_UID']; -$appDocUid = $_POST['form']['APP_DOC_UID']; -$docVersion = $_POST['form']['docVersion']; -$actionType = $_POST['form']['actionType']; +G::LoadClass("case"); -//load the variables -G::LoadClass( 'case' ); -$oCase = new Cases(); -$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List' ); -$Fields = $oCase->loadCase( $_SESSION['APPLICATION'] ); -$Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() ); +$inputDocumentUid = $_GET["UID"]; //$_POST["form"]["DOC_UID"] +$appDocUid = $_POST["form"]["APP_DOC_UID"]; +$docVersion = intval($_POST["form"]["docVersion"]); +$appDocType = $_POST["form"]["APP_DOC_TYPE"]; +$appDocComment = (isset($_POST["form"]["APP_DOC_COMMENT"]))? $_POST["form"]["APP_DOC_COMMENT"] : ""; +$actionType = $_POST["form"]["actionType"]; -#trigger debug routines... +$case = new Cases(); +$case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs"); +//Load the fields +$arrayField = $case->loadCase($_SESSION["APPLICATION"]); +$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], G::getSystemConstants()); -//cleaning debug variables -$_SESSION['TRIGGER_DEBUG']['ERRORS'] = Array (); -$_SESSION['TRIGGER_DEBUG']['DATA'] = Array (); -$_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = Array (); -$_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = Array (); +//Triggers +$arrayTrigger = $case->loadTriggers($_SESSION["TASK"], "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); -$triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'INPUT_DOCUMENT', $_GET['UID'], 'AFTER' ); +//Trigger debug routines +//Cleaning debug variables +$_SESSION["TRIGGER_DEBUG"]["ERRORS"] = array(); +$_SESSION["TRIGGER_DEBUG"]["DATA"] = array(); +$_SESSION["TRIGGER_DEBUG"]["TRIGGERS_NAMES"] = array(); +$_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = array(); -$_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] = count( $triggers ); -$_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER'; -if ($_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] != 0) { - $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); - $_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = $triggers; +$_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] = count($arrayTrigger); +$_SESSION["TRIGGER_DEBUG"]["TIME"] = "AFTER"; + +if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { + $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_NAMES"] = $case->getTriggerNames($arrayTrigger); + $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = $arrayTrigger; } -if ($_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] != 0) { - //Execute after triggers - Start - $Fields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], 'INPUT_DOCUMENT', $_GET['UID'], 'AFTER', $Fields['APP_DATA'] ); - //Execute after triggers - End +if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { + //Trigger - Execute after - Start + $arrayField["APP_DATA"] = $case->executeTriggers( + $_SESSION["TASK"], + "INPUT_DOCUMENT", + $inputDocumentUid, + "AFTER", + $arrayField["APP_DATA"] + ); + //Trigger - Execute after - End } -//save data -$aData = array (); -$aData['APP_NUMBER'] = $Fields['APP_NUMBER']; -$aData['APP_PROC_STATUS'] = $Fields['APP_PROC_STATUS']; -$aData['APP_DATA'] = $Fields['APP_DATA']; -$aData['DEL_INDEX'] = $_SESSION['INDEX']; -$aData['TAS_UID'] = $_SESSION['TASK']; -//$aData = $oCase->loadCase($_SESSION['APPLICATION']); -$oCase->updateCase( $_SESSION['APPLICATION'], $aData ); +//Save data +$arrayData = array(); +$arrayData["APP_NUMBER"] = $arrayField["APP_NUMBER"]; +$arrayData["APP_PROC_STATUS"] = $arrayField["APP_PROC_STATUS"]; +$arrayData["APP_DATA"] = $arrayField["APP_DATA"]; +$arrayData["DEL_INDEX"] = $_SESSION["INDEX"]; +$arrayData["TAS_UID"] = $_SESSION["TASK"]; -//save info +$case->updateCase($_SESSION["APPLICATION"], $arrayData); - -require_once ("classes/model/AppDocument.php"); -require_once ('classes/model/AppFolder.php'); -require_once ('classes/model/InputDocument.php'); - -$oInputDocument = new InputDocument(); -$aID = $oInputDocument->load( $_GET['UID'] ); - -$oAppDocument = new AppDocument(); - -//Get the Custom Folder ID (create if necessary) -$oFolder = new AppFolder(); -$folderId = $oFolder->createFromPath( $aID['INP_DOC_DESTINATION_PATH'] ); - -//Tags -$fileTags = $oFolder->parseTags( $aID['INP_DOC_TAGS'] ); - -switch ($actionType) { - case "R": //replace - $aFields = array ('APP_DOC_UID' => $appDocUid,'APP_UID' => $_SESSION['APPLICATION'],'DOC_VERSION' => $docVersion,'DEL_INDEX' => $_SESSION['INDEX'],'USR_UID' => $_SESSION['USER_LOGGED'],'DOC_UID' => $docUid,'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],'APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_COMMENT' => isset( $_POST['form']['APP_DOC_COMMENT'] ) ? $_POST['form']['APP_DOC_COMMENT'] : '','APP_DOC_TITLE' => '','APP_DOC_FILENAME' => isset( $_FILES['form']['name']['APP_DOC_FILENAME'] ) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '','FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags - ); - - $oAppDocument->update( $aFields ); - break; - case "NV": //New Version - - - $aFields = array ('APP_DOC_UID' => $appDocUid,'APP_UID' => $_SESSION['APPLICATION'],'DEL_INDEX' => $_SESSION['INDEX'],'USR_UID' => $_SESSION['USER_LOGGED'],'DOC_UID' => $docUid,'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],'APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_COMMENT' => isset( $_POST['form']['APP_DOC_COMMENT'] ) ? $_POST['form']['APP_DOC_COMMENT'] : '','APP_DOC_TITLE' => '','APP_DOC_FILENAME' => isset( $_FILES['form']['name']['APP_DOC_FILENAME'] ) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '','FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags - ); - - $oAppDocument->create( $aFields ); - break; - default: //New - $aFields = array ('APP_UID' => $_SESSION['APPLICATION'],'DEL_INDEX' => $_SESSION['INDEX'],'USR_UID' => $_SESSION['USER_LOGGED'],'DOC_UID' => $docUid,'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],'APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_COMMENT' => isset( $_POST['form']['APP_DOC_COMMENT'] ) ? $_POST['form']['APP_DOC_COMMENT'] : '','APP_DOC_TITLE' => '','APP_DOC_FILENAME' => isset( $_FILES['form']['name']['APP_DOC_FILENAME'] ) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '','FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags - ); - - $oAppDocument->create( $aFields ); - break; -} - -$sAppDocUid = $oAppDocument->getAppDocUid(); -$iDocVersion = $oAppDocument->getDocVersion(); -$info = pathinfo( $oAppDocument->getAppDocFilename() ); -$ext = (isset( $info['extension'] ) ? $info['extension'] : ''); - -//save the file -if (! empty( $_FILES['form'] )) { - if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) { - $sPathName = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP; - $sFileName = $sAppDocUid . "_" . $iDocVersion . '.' . $ext; - G::uploadFile( $_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $sPathName, $sFileName ); - - //Plugin Hook PM_UPLOAD_DOCUMENT for upload document - $oPluginRegistry = & PMPluginRegistry::getSingleton(); - if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) { - $triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT ); - $oData['APP_UID'] = $_SESSION['APPLICATION']; - $documentData = new uploadDocumentData( $_SESSION['APPLICATION'], $_SESSION['USER_LOGGED'], $sPathName . $sFileName, $aFields['APP_DOC_FILENAME'], $sAppDocUid, $iDocVersion ); - - $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); - if ($uploadReturn) { - $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace; - if (! isset( $aFields['APP_DOC_UID'] )) { - $aFields['APP_DOC_UID'] = $sAppDocUid; - } - if (! isset( $aFields['DOC_VERSION'] )) { - $aFields['DOC_VERSION'] = $iDocVersion; - } - //$oAppDocument1 = new AppDocument(); - //G::pr($aFields);die; - $oAppDocument->update( $aFields ); - unlink( $sPathName . $sFileName ); - } - } - //end plugin - } +//Add Input Document +if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { + $appDocUid = $case->addInputDocument( + $inputDocumentUid, + $appDocUid, + $docVersion, + $appDocType, + $appDocComment, + $actionType, + $_SESSION["APPLICATION"], + $_SESSION["INDEX"], + $_SESSION["TASK"], + $_SESSION["USER_LOGGED"], + "xmlform", + $_FILES["form"]["name"]["APP_DOC_FILENAME"], + $_FILES["form"]["error"]["APP_DOC_FILENAME"], + $_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"] + ); } //go to the next step //if (!isset($_POST['form']['MORE'])) { if (false) { - $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); + $aNextStep = $case->getNextStep($_SESSION["PROCESS"], $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["STEP_POSITION"]); $_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; if ($_SESSION['TRIGGER_DEBUG']['ISSET']) { @@ -212,7 +162,7 @@ if (false) { G::header( 'location: ' . $_SERVER['HTTP_REFERER'] ); die(); } else { - $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 ); + $aNextStep = $case->getNextStep($_SESSION["PROCESS"], $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["STEP_POSITION"] - 1); $_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; if ($_SESSION['TRIGGER_DEBUG']['ISSET']) { @@ -225,7 +175,7 @@ if (false) { die(); } } else { - $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 ); + $aNextStep = $case->getNextStep($_SESSION["PROCESS"], $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["STEP_POSITION"] - 1); $_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; if ($_SESSION['TRIGGER_DEBUG']['ISSET']) { diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index ca19a3982..92d484498 100755 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -160,7 +160,7 @@ if (isset( $_GET['breakpoint'] )) { #end trigger debug session....... -//$oCase->thisIsTheCurrentUser($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List'); +//$oCase->thisIsTheCurrentUser($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'casesListExtJs'); //Save data - Start @@ -297,8 +297,8 @@ try { $oHeadPublisher->addScriptCode( "documentName='{$titleDocument}';" ); break; case 'VIEW': - require_once 'classes/model/AppDocument.php'; - require_once 'classes/model/Users.php'; + //require_once 'classes/model/AppDocument.php'; + //require_once 'classes/model/Users.php'; $oAppDocument = new AppDocument(); $oAppDocument->Fields = $oAppDocument->load( $_GET['DOC'], $_GET['VERSION'] ); $Fields['POSITION'] = $_SESSION['STEP_POSITION']; @@ -325,7 +325,7 @@ try { case 'OUTPUT_DOCUMENT': //$G_PUBLISH->AddContent('smarty', 'cases/cases_title', '', '', $array); - require_once 'classes/model/OutputDocument.php'; + //require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new OutputDocument(); $aOD = $oOutputDocument->load( $_GET['UID'] ); if (! $aPreviousStep) { @@ -347,8 +347,8 @@ try { //END: If there is a Break Step registered from Plugin $sFilenameOriginal = $sFilename = preg_replace( '[^A-Za-z0-9_]', '_', G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'] ) ); - require_once 'classes/model/AppFolder.php'; - require_once 'classes/model/AppDocument.php'; + //require_once 'classes/model/AppFolder.php'; + //require_once 'classes/model/AppDocument.php'; //Get the Custom Folder ID (create if necessary) $oFolder = new AppFolder(); @@ -581,7 +581,7 @@ try { if ($noShowTitle == 0) { $G_PUBLISH->AddContent( 'smarty', 'cases/cases_title', '', '', $array ); } - require_once 'classes/model/AppDocument.php'; + //require_once 'classes/model/AppDocument.php'; $oAppDocument = new AppDocument(); $lastVersion = $oAppDocument->getLastAppDocVersion( $_GET['DOC'], $_SESSION['APPLICATION'] ); $aFields = $oAppDocument->load( $_GET['DOC'], $lastVersion ); @@ -594,7 +594,7 @@ try { $listing = $oPluginRegistry->executeTriggers( PM_CASE_DOCUMENT_LIST, $folderData ); } - require_once 'classes/model/OutputDocument.php'; + //require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new OutputDocument(); $aGields = $oOutputDocument->load( $aFields['DOC_UID'] ); diff --git a/workflow/engine/methods/dynaforms/dynaforms_Save.php b/workflow/engine/methods/dynaforms/dynaforms_Save.php index cbc1846b9..89dc6805c 100755 --- a/workflow/engine/methods/dynaforms/dynaforms_Save.php +++ b/workflow/engine/methods/dynaforms/dynaforms_Save.php @@ -30,8 +30,6 @@ if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { require_once ('classes/model/Dynaform.php'); require_once ('classes/model/Content.php'); -$oJSON = new Services_JSON(); - if (isset( $_POST['function'] )) { $sfunction = $_POST['function']; } elseif (isset( $_POST['functions'] )) { diff --git a/workflow/engine/methods/dynaforms/fieldsHandlerAjax.php b/workflow/engine/methods/dynaforms/fieldsHandlerAjax.php index 01c8002c1..83eed3f72 100755 --- a/workflow/engine/methods/dynaforms/fieldsHandlerAjax.php +++ b/workflow/engine/methods/dynaforms/fieldsHandlerAjax.php @@ -94,6 +94,118 @@ switch ($request) { $o->remove( '___pm_boot_strap___' ); } break; + case 'showImportForm': + require_once 'classes/model/Dynaform.php'; + require_once 'classes/model/Content.php'; + $uidDynafom = $_POST['DYN_UID']; + + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->clearSelectColumns(); + $oCriteria->addSelectColumn( DynaformPeer::DYN_FILENAME ); + $oCriteria->addAsColumn( 'DYNA_NAME', 'C_DYNA.CON_VALUE' ); + $oCriteria->addAsColumn( 'PROC_NAME', 'C_PROC.CON_VALUE' ); + + $oCriteria->addAlias("C_DYNA", "CONTENT"); + $oCriteria->addAlias("C_PROC", "CONTENT"); + + $arrayCondition = array(); + $arrayCondition[] = array(DynaformPeer::DYN_UID, "C_DYNA.CON_ID"); + $oCriteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN); + + $arrayCondition = array(); + $arrayCondition[] = array(DynaformPeer::PRO_UID, "C_PROC.CON_ID"); + $oCriteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN); + + $oCriteria->add( 'C_DYNA.CON_LANG', SYS_LANG ); + $oCriteria->add( 'C_DYNA.CON_CATEGORY', 'DYN_TITLE' ); + + $oCriteria->add( 'C_PROC.CON_LANG', SYS_LANG ); + $oCriteria->add( 'C_PROC.CON_CATEGORY', 'PRO_TITLE' ); + + $oCriteria->add( DynaformPeer::DYN_UID, $uidDynafom, Criteria::NOT_EQUAL); + + $oCriteria->addAscendingOrderByColumn ('PROC_NAME'); + $oCriteria->addAscendingOrderByColumn ('DYNA_NAME'); + $oDataset = DynaformPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + + + $select = ''; + $html = '
+ + + + + + + + + + + + +
+ ' . G::LoadTranslation('ID_SELECT_DYNAFORM_IMPORT') . ' +
+ + ' . $select . ' +
+   + +
'; + echo $html; + break; + case 'import': + require_once 'classes/model/Dynaform.php'; + $uidDynafom = $_POST['DYN_UID']; + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->clearSelectColumns(); + $oCriteria->addSelectColumn( DynaformPeer::DYN_FILENAME ); + $oCriteria->add( DynaformPeer::DYN_UID, $uidDynafom, Criteria::EQUAL); + $oDataset = DynaformPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + + $dynaFile = PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml'; + $importFile = PATH_DYNAFORM . $_POST['FILE'] . '.xml'; + + $importFp = fopen ($importFile, "r+"); + $fileText = fread($importFp, filesize($importFile)); + fclose ( $importFp ); + $newFile = str_replace($_POST['FILE'], $aRow['DYN_FILENAME'], $fileText); + + $dynaFileTmp = PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '_tmp0.xml'; + $dynafmFp = fopen ($dynaFileTmp,"w+"); + fwrite ( $dynafmFp, $newFile); + fclose ( $dynafmFp ); + + /* + $dynafmFp = fopen ($dynaFile,"w+"); + fwrite ( $dynafmFp, $newFile); + fclose ( $dynafmFp ); + */ + echo 'success'; + break; default: echo 'no request param.'; } diff --git a/workflow/engine/methods/inputdocs/inputdocs_Save.php b/workflow/engine/methods/inputdocs/inputdocs_Save.php index 0bbcc6554..4daa9be8d 100755 --- a/workflow/engine/methods/inputdocs/inputdocs_Save.php +++ b/workflow/engine/methods/inputdocs/inputdocs_Save.php @@ -36,16 +36,17 @@ try { break; } + $sfunction = ''; if (isset( $_POST['function'] )) { $sfunction = $_POST['function']; - } else { + } elseif (isset( $_POST['functions'] )){ $sfunction = $_POST['functions']; - } - + } + // Bootstrap::mylog("post:".$_POST['function']); switch ($sfunction) { case 'lookForNameInput': - require_once ('classes/model/Content.php'); - require_once ("classes/model/InputDocument.php"); + //require_once ('classes/model/Content.php'); + //require_once ("classes/model/InputDocument.php"); $snameInput = urldecode( $_POST['NAMEINPUT'] ); $sPRO_UID = urldecode( $_POST['proUid'] ); @@ -77,7 +78,7 @@ try { print $flag; break; default: - require_once 'classes/model/InputDocument.php'; + //require_once 'classes/model/InputDocument.php'; G::LoadClass( 'processMap' ); $oInputDocument = new InputDocument(); diff --git a/workflow/engine/methods/login/login.php b/workflow/engine/methods/login/login.php index f3e76dc88..3ba6bbde9 100755 --- a/workflow/engine/methods/login/login.php +++ b/workflow/engine/methods/login/login.php @@ -48,11 +48,11 @@ if (!isset($_SESSION['FAILED_LOGINS'])) { $sFailedLogins = $_SESSION['FAILED_LOGINS']; -require_once 'classes/model/LoginLog.php'; - $aFields['LOGIN_VERIFY_MSG'] = G::loadTranslation('LOGIN_VERIFY_MSG'); +//$aFields['LOGIN_VERIFY_MSG'] = Bootstrap::loadTranslation('LOGIN_VERIFY_MSG'); if (isset ($_SESSION['USER_LOGGED'])) { + require_once 'classes/model/LoginLog.php'; //close the session, if the current session_id was used in PM. $oCriteria = new Criteria('workflow'); @@ -120,7 +120,9 @@ if (strlen($msgType) > 0) { $_SESSION['FAILED_LOGINS'] = $sFailedLogins; //translation -$Translations = G::getModel("Translation"); +//$Translations = G::getModel("Translation"); +//require_once "classes/model/Translation.php"; +$Translations = new Translation(); $translationsTable = $Translations->getTranslationEnvironments(); $availableLangArray = array (); @@ -141,6 +143,7 @@ global $_DBArray; $_DBArray ['langOptions'] = $availableLangArray; G::LoadClass('configuration'); +//BootStrap::LoadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); @@ -151,7 +154,7 @@ $aFields['USER_LANG'] = isset($oConf->aConfig['login_defaultLanguage']) $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/login', '', $aFields, SYS_URI . 'login/authentication.php'); G::LoadClass('serverConfiguration'); - +//Bootstrap::LoadClass('serverConfiguration'); //get the serverconf singleton, and check if we can send the heartbeat $oServerConf = & serverConf::getSingleton(); @@ -190,12 +193,7 @@ if ($flagGettingStarted == 0) { $dummy = ''; -G::loadClass('configuration'); - -$oConf = new Configurations(); - $oConf->loadConfig($dummy, 'ENVIRONMENT_SETTINGS', ''); - $flagForgotPassword = isset($oConf->aConfig['login_enableForgotPassword']) ? $oConf->aConfig['login_enableForgotPassword'] : 'off'; diff --git a/workflow/engine/methods/login/sysLogin.php b/workflow/engine/methods/login/sysLogin.php index 81d6fd125..9628a4a09 100755 --- a/workflow/engine/methods/login/sysLogin.php +++ b/workflow/engine/methods/login/sysLogin.php @@ -83,10 +83,13 @@ function getWorkspacesAvailable() sort ($filesArray, SORT_STRING); return $filesArray; } + $availableWorkspace = getWorkspacesAvailable (); //Translations -$Translations = G::getModel("Translation"); +//$Translations = G::getModel("Translation"); <-- ugly way to get a class +require_once "classes/model/Translation.php"; +$Translations = new Translation(); $translationsTable = $Translations->getTranslationEnvironments(); $availableLangArray = array (); @@ -103,7 +106,6 @@ foreach ($translationsTable as $locale) { $availableLangArray [] = $aFields; } - $availableWorkspaceArray = array (); $availableWorkspaceArray [] = array ('ENV_ID' => 'char', 'ENV_NAME' => 'char'); foreach ($availableWorkspace as $envKey => $envName) { @@ -120,8 +122,9 @@ $_SESSION ['_DBArray'] = $_DBArray; $aField ['LOGIN_VERIFY_MSG'] = G::loadTranslation ('LOGIN_VERIFY_MSG'); $aField['USER_LANG'] = SYS_LANG; + //Get Server Configuration -G::LoadClass ('serverConfiguration'); +//G::LoadClass ('serverConfiguration'); //already called $oServerConf = & serverConf::getSingleton (); $G_PUBLISH = new Publisher (); @@ -131,8 +134,8 @@ if ($oServerConf->getProperty ('LOGIN_NO_WS')) { $G_PUBLISH->AddContent ('xmlform', 'xmlform', 'login/sysLogin', '', $aField, 'sysLogin'); } - G::RenderPage ("publish"); + ?>