Merge remote branch 'upstream/master'

This commit is contained in:
Brayan Osmar Pereyra Suxo
2013-05-08 12:43:47 -04:00
29 changed files with 499 additions and 88 deletions

View File

@@ -769,6 +769,7 @@ var G_Grid = function(oForm, sGridName){
var iRow = Number(sRow);
var iRowAux = iRow + 1;
var lastItem = oObj.oGrid.rows.length - 2;
var elemNodeName = "";
var elem2ParentNode;
var elem2Id = "";
var elem2Name = "";
@@ -776,13 +777,17 @@ var G_Grid = function(oForm, sGridName){
deleteRowOnDynaform(oObj, iRow);
var i = 0;
while (iRowAux <= (lastItem)) {
for (i = 1; i < oObj.oGrid.rows[iRowAux - 1].cells.length; i++) {
var oCell1 = oObj.oGrid.rows[iRowAux - 1].cells[i];
var oCell2 = oObj.oGrid.rows[iRowAux].cells[i];
switch (oCell1.innerHTML.replace(/^\s+|\s+$/g, '').substr(0, 6).toLowerCase()){
case '<input':
elemNodeName = oCell1.innerHTML.substring(oCell1.innerHTML.indexOf("<") + 1, oCell1.innerHTML.indexOf(" ")).toLowerCase();
switch (elemNodeName) {
case "input":
aObjects1 = oCell1.getElementsByTagName('input');
aObjects2 = oCell2.getElementsByTagName('input');
@@ -838,7 +843,7 @@ var G_Grid = function(oForm, sGridName){
}
break;
case "<selec":
case "select":
aObjects1 = oCell1.getElementsByTagName("select");
aObjects2 = oCell2.getElementsByTagName("select");
@@ -849,7 +854,7 @@ var G_Grid = function(oForm, sGridName){
aObjects1[0].className = aObjects2[0].className;
}
break;
case '<texta':
case "textarea":
aObjects1 = oCell1.getElementsByTagName('textarea');
aObjects2 = oCell2.getElementsByTagName('textarea');
if (aObjects1 && aObjects2) {
@@ -857,14 +862,35 @@ var G_Grid = function(oForm, sGridName){
aObjects1[0].className = aObjects2[0].className;
}
break;
case "a":
aObjects1 = oCell1.getElementsByTagName("a");
aObjects2 = oCell2.getElementsByTagName("a");
if (aObjects1 && aObjects2) {
if (oCell1.innerHTML.indexOf("deleteGridRow") == -1) {
var iAux = 0;
var swLink = 0;
for (iAux = 0; iAux <= aObjects1[0].attributes.length - 1; iAux++) {
if (aObjects1[0].attributes[iAux].name == "pm:field" && aObjects1[0].attributes[iAux].value == "pm:field") {
swLink = 1;
break;
}
}
if (swLink == 1) {
aObjects1[0].href = aObjects2[0].href;
aObjects1[0].innerHTML = aObjects2[0].innerHTML;
} else {
oCell1.innerHTML = oCell2.innerHTML;
}
}
}
break;
default:
if (( oCell2.innerHTML.indexOf('changeValues') == 111 || oCell2.innerHTML.indexOf('changeValues') == 115 ) ) {
break;
}
if (oCell2.innerHTML.toLowerCase().indexOf('deletegridrow') == -1) {
oCell1.innerHTML = oCell2.innerHTML;
}
break;
}
}
@@ -874,8 +900,6 @@ var G_Grid = function(oForm, sGridName){
//Delete row
this.oGrid.deleteRow(lastItem);
var i = 0;
for (i = 0; i <= this.aFields.length - 1; i++) {
this.aElements.pop();
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -61,19 +61,43 @@ class Form extends XmlForm
* @access public
* @return string
*/
public function setDefaultValues ()
{
foreach ($this->fields as $name => $content) {
if (is_object( $content ) && get_class( $content ) != '__PHP_Incomplete_Class') {
if (isset( $content->defaultValue )) {
$this->values[$name] = $content->defaultValue;
switch ($content->type) {
case "checkgroup":
case "listbox":
$defaultValueAux = trim($content->defaultValue);
if ($defaultValueAux != "") {
$this->values[$name] = $content->defaultValue;
} else {
$this->values[$name] = "__NULL__";
}
break;
default:
$this->values[$name] = $content->defaultValue;
break;
}
} else {
$this->values[$name] = '';
switch ($content->type) {
case "checkgroup":
case "listbox":
$this->values[$name] = "__NULL__";
break;
default:
$this->values[$name] = "";
break;
}
}
} else {
$this->values[$name] = '';
}
}
foreach ($this->fields as $k => $v) {
if (is_object( $v )) {
//julichu
@@ -117,6 +141,7 @@ class Form extends XmlForm
trigger_error( 'Faild to create cache file "' . $xmlform->parsedFile . '".', E_USER_ERROR );
}
$this->setDefaultValues();
//to do: review if you can use the same form twice. in order to use once or not.
//DONE: Use require to be able to use the same xmlform more than once.
foreach ($this->fields as $k => $v) {
@@ -229,6 +254,7 @@ class Form extends XmlForm
if (! is_array( $newValues )) {
return;
}
foreach ($this->fields as $k => $v) {
if (array_key_exists( $k, $newValues )) {
if (is_array( $newValues[$k] )) {
@@ -362,9 +388,9 @@ class Form extends XmlForm
$values[$k] = $values[$k . "_label"] = null;
foreach ($newValues[$k] as $i => $value) {
//if $value is empty continue with the next loop, because this is a not selected/checked item
if (trim( $value ) == '') {
continue;
}
//if (trim( $value ) == '') {
// continue;
//}
$values[$k] .= (($i != 0) ? "|" : null) . $value;
@@ -510,8 +536,12 @@ class Form extends XmlForm
}
}
} else {
if ($v->type == 'checkgroup') {
$values[$k] = null;
switch ($v->type) {
case "checkgroup":
case "listbox":
//This value is added when the user does not mark any checkbox
$values[$k] = "__NULL__";
break;
}
}
} else {

181
gulliver/system/class.g.php Normal file → Executable file
View File

@@ -313,12 +313,13 @@ class G
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 );
if (! @mkdir( $parent_folder_path, $rights)) {
error_log( "Can't create folder \"$parent_folder_path\"");
//umask( $oldumask );
}
}
}
umask($oldumask);
}
/**
@@ -359,6 +360,53 @@ class G
}
}
/**
* Delete all the directory tree cotents.
* @param string $dir
* @return void
*/
public function delTree($dir)
{
$files = glob( $dir . '*', GLOB_MARK );
foreach ($files as $file ) {
if (substr( $file, -1 ) == '/' ) {
$this->delTree( $file );
} else {
unlink( $file );
}
}
if (is_dir($dir)) {
rmdir( $dir );
}
}
/**
* Recursive copy
* @param string $source
* @param string $destination
* @return boolean
*/
function recursive_copy ($source, $destination) {
if ($source == $destination) {
return false;
}
$dir = opendir($source);
if (! file_exists($destination)) {
@mkdir($destination);
}
while (false !== ( $file = readdir($dir))) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($source . '/' . $file) ) {
self::recursive_copy($source . '/' . $file, $destination . '/' . $file);
} else {
copy($source . '/' . $file, $destination . '/' . $file);
}
}
}
closedir($dir);
return true;
}
/**
* verify path
*
@@ -2414,6 +2462,133 @@ class G
return $new_val;
}
/**
* Extract the structure version value from serializated table field and check it.
* @return true if the version is bigger than 1
*/
public function gotDirectoryStructureVer2()
{
G::LoadClass( "configuration" );
$configuration = new Configurations();
if (defined('SYS_SYS') && $configuration->exists("ENVIRONMENT_SETTINGS")) {
return ($configuration->getDirectoryStructureVer() > 1);
}
return false;
}
/**
* Get the default blank directory 0 for external files
*/
public function getBlackHoleDir()
{
//len32:12345678901234567890123456789012
return "00000000000000000000000000000000";
}
/**
* Funtion used to fix 32K issue related to ext3 max subdirectory storage, but checking Version first.
* @param string $uid
* @param int $splitSize
* @param int $pieces
* @return string xxx/xxx/xxx/xxxxxxxxxxxxxxxxxxxxx
*/
public function getPathFromUID($uid, $splitSize = 3, $pieces = 3)
{
if (! G::gotDirectoryStructureVer2()) {
return $uid;
}
return G::getPathFromUIDPlain($uid, $splitSize, $pieces);
}
/**
* Funtion used to fix 32K issue related to ext3 max subdirectory storage.
* @param string $uid
* @param int $splitSize
* @param int $pieces
* @return string xxx/xxx/xxx/xxxxxxxxxxxxxxxxxxxxx
*/
public function getPathFromUIDPlain($uid, $splitSize = 3, $pieces = 3)
{
$dirArray = array();
if (is_string($uid) && strlen($uid) >= 32 && $uid != G::getBlackHoleDir()) {
for ($i = 0; $i < $pieces; $i++) {
$dirArray[] = substr($uid, 0, $splitSize);
$len = strlen($uid);
$uid = substr($uid, $splitSize, $len);
}
}
$dirArray[] = $uid;
$newfileStructure = implode($dirArray, '/');
return $newfileStructure;
}
/**
* Get the uid from the splitted directory + filename.
* @param string $path
* @return string
*/
public function getUIDfromPath($path)
{
$uid = '';
$item = explode($path, '/');
$len = sizeof($item);
for ($i = 0; $i < $len; $i++) {
$uid .= $item[$i];
}
if (strlen($uid) != 32){
return "invalid";
}
return $uid;
}
/**
* Get the file stored in '0' dir as splitted, but checking version first.
* @param string $appUid
* @param string $fileUid
* @param int $splitSize
* @param int $pieces
* @return array index:0 got the path, index:1 got the filename
*/
public function getPathFromFileUID($appUid, $fileUid, $splitSize = 3, $pieces = 3)
{
if (! G::gotDirectoryStructureVer2()) {
$response = array();
$response[] = '';
$response[] = $fileUid;
return $response;
}
return G::getPathFromFileUIDPlain($appUid, $fileUid, $splitSize, $pieces);
}
/**
* Get the file stored in '0' dir as splitted.
* @param string $appUid
* @param string $fileUid
* @param int $splitSize
* @param int $pieces
* @return array index:0 got the path, index:1 got the filename
*/
public function getPathFromFileUIDPlain($appUid, $fileUid, $splitSize = 3, $pieces = 3)
{
$response = array();
if ($appUid == G::getBlackHoleDir()) {
$dirArray = array();
if (is_string($fileUid) && strlen($fileUid) >= 32) {
for ($i = 0; $i < $pieces; $i++) {
$dirArray[] = substr($fileUid, 0, $splitSize);
$len = strlen($fileUid);
$fileUid = substr($fileUid, $splitSize, $len);
}
}
$response[] = implode($dirArray, '/') . '/';
$response[] = $fileUid;
} else {
$response[] = '';
$response[] = $fileUid;
}
return $response;
}
/**
* Upload a file and then copy to path+ nameToSave
*

View File

@@ -160,6 +160,8 @@ class XmlForm_Field_WYSIWYG_EDITOR extends XmlForm_Field
var formProcessID = document.getElementById("form[PRO_UID]").value;
var formDynaformID = document.getElementById("form[DYN_UID]").value;
var actualCaretPositionBookmark;
if (tinyMCE.activeEditor == null){
tinyMCE.activeEditor="created";
tinyMCE.init({
theme : "advanced",
plugins : "advhr,advimage,advlink,advlist,autolink,autoresize,contextmenu,directionality,emotions,example,example_dependency,fullpage,fullscreen,iespell,inlinepopups,insertdatetime,layer,legacyoutput,lists,media,nonbreaking,noneditable,pagebreak,paste,preview,print,save,searchreplace,style,tabfocus,table,template,visualblocks,visualchars,wordcount,xhtmlxtras,style,table,noneditable,pmFieldPicker",
@@ -199,6 +201,8 @@ class XmlForm_Field_WYSIWYG_EDITOR extends XmlForm_Field
}
});
}
';
break;
default:
@@ -228,4 +232,3 @@ class XmlForm_Field_WYSIWYG_EDITOR extends XmlForm_Field
return $editorDefinition;
}
}

View File

@@ -3599,6 +3599,15 @@ class XmlForm_Field_Listbox extends XmlForm_Field
if (! is_array( $value )) {
$value = explode( '|', $value );
}
$arrayAux = array();
foreach ($value as $index2 => $value2) {
$arrayAux[] = $value2 . "";
}
$value = $arrayAux;
if ($this->mode === 'edit') {
$itemWidth = '';
if ($this->width != '') {
@@ -3606,10 +3615,10 @@ class XmlForm_Field_Listbox extends XmlForm_Field
}
$html = '<select multiple="multiple" id="form[' . $this->name . ']" name="form[' . $this->name . '][]" size="' . $this->size . '" ' . $itemWidth . ' ' . $this->NSFieldType() . '>';
foreach ($this->option as $optionName => $option) {
$html .= '<option value="' . $optionName . '" ' . ((in_array( $optionName, $value )) ? 'selected' : '') . '>' . $option . '</option>';
$html .= "<option value=\"" . $optionName . "\" " . ((in_array( $optionName . "", $value )) ? "selected=\"selected\"" : "") . ">" . $option . "</option>";
}
foreach ($this->sqlOption as $optionName => $option) {
$html .= '<option value="' . $optionName . '" ' . ((in_array( $optionName, $value )) ? 'selected' : '') . '>' . $option . '</option>';
$html .= "<option value=\"" . $optionName . " \" " . ((in_array( $optionName . "", $value )) ? "selected=\"selected\" " : "") . ">" . $option . "</option>";
}
$html .= '</select>';
@@ -3618,17 +3627,17 @@ class XmlForm_Field_Listbox extends XmlForm_Field
} elseif ($this->mode === 'view') {
$html = '<select multiple="multiple" id="form[' . $this->name . ']" name="form[' . $this->name . '][]" size="' . $this->size . '" ' . $this->NSFieldType() . ' style="background: none;" disabled="disabled">';
foreach ($this->option as $optionName => $option) {
$html .= '<option value="' . $optionName . '" ' . ((in_array( $optionName, $value )) ? 'class="module_ListBoxView" selected="selected"' : '') . '>' . $option . '</option>';
$html .= "<option value=\"" . $optionName . " \" " . ((in_array( $optionName . "", $value )) ? "class=\"module_ListBoxView\" selected=\"selected\"" : "") . ">" . $option . "</option>";
}
foreach ($this->sqlOption as $optionName => $option) {
$html .= '<option value="' . $optionName . '" ' . ((in_array( $optionName, $value )) ? 'class="module_ListBoxView" selected="selected"' : '') . '>' . $option . '</option>';
$html .= "<option value=\"" . $optionName . " \" " . ((in_array( $optionName . "", $value )) ? "class=\"module_ListBoxView\" selected=\"selected\"" : "") . ">" . $option . "</option>";
}
$html .= '</select>';
foreach ($this->option as $optionName => $option) {
$html .= '<input type="hidden" id="form[' . $this->name . ']" name="form[' . $this->name . '][]" value="' . ((in_array( $optionName, $value )) ? $optionName : '') . '">';
$html .= "<input type=\"hidden\" id=\"form[" . $this->name . "]\" name=\"form[" . $this->name . "][]\" value=\"" . ((in_array( $optionName . "", $value )) ? $optionName : "__NULL__") . "\">";
}
foreach ($this->sqlOption as $optionName => $option) {
$html .= '<input type="hidden" id="form[' . $this->name . ']" name="form[' . $this->name . '][]" value="' . ((in_array( $optionName, $value )) ? $optionName : '') . '">';
$html .= "<input type=\"hidden\" id=\"form[" . $this->name . "]\" name=\"form[" . $this->name . "][]\" value=\"" . ((in_array( $optionName . "", $value )) ? $optionName : "__NULL__") . "\">";
}
return $html;
} else {
@@ -3802,11 +3811,21 @@ class XmlForm_Field_CheckGroup extends XmlForm_Field
if (! is_array( $value )) {
$value = explode( '|', $value );
}
$arrayAux = array();
foreach ($value as $index2 => $value2) {
$arrayAux[] = $value2 . "";
}
$value = $arrayAux;
if ($this->mode === 'edit') {
$i = 0;
$html = '';
foreach ($this->options as $optionName => $option) {
$html .= '<input id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][]" type=\'checkbox\' value="' . $optionName . '"' . (in_array( $optionName, $value ) ? 'checked' : '') . '><span class="FormCheck"><label for="form[' . $this->name . '][' . $optionName . ']">' . $option . '</label></span></input>';
$html .= "<input type=\"checkbox\" id=\"form[" . $this->name . "][" . $optionName . "]\" name=\"form[" . $this->name . "][]\" value=\"" . $optionName . "\"" . (in_array( $optionName . "", $value ) ? "checked = \"checked\" " : "") . "><span class=\"FormCheck\"><label for=\"form[" . $this->name . "][" . $optionName . "]\">" . $option . "</label></span></input>";
if (++ $i == count( $this->options )) {
$html .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $this->renderHint();
}
@@ -3816,8 +3835,8 @@ class XmlForm_Field_CheckGroup extends XmlForm_Field
} elseif ($this->mode === 'view') {
$html = '';
foreach ($this->options as $optionName => $option) {
$html .= '<input class="FormCheck" id="form[' . $this->name . '][' . $optionName . ']" type=\'checkbox\' value="' . $optionName . '"' . (in_array( $optionName, $value ) ? 'checked' : '') . ' disabled><span class="FormCheck"><label for="form[' . $this->name . '][' . $optionName . ']">' . $option . '</label></span></input><br>';
$html .= '<input type="hidden" name="form[' . $this->name . '][]" value="' . ((in_array( $optionName, $value )) ? $optionName : '') . '">';
$html .= "<input class=\"FormCheck\" type=\"checkbox\" id=\"form[" . $this->name . "][" . $optionName . "]\" value=\"" . $optionName . "\"" . (in_array( $optionName . "", $value ) ? " checked=\"checked\" " : "") . " disabled=\"disabled\"><span class=\"FormCheck\"><label for=\"form[" . $this->name . "][" . $optionName . "]\">" . $option . "</label></span></input><br />";
$html .= "<input type=\"hidden\" name=\"form[" . $this->name . "][]\" value=\"" . ((in_array( $optionName . "", $value )) ? $optionName : "__NULL__") . "\">";
}
return $html;
} else {

View File

@@ -230,20 +230,28 @@ class Applications
}
*/
if ($dateFrom != '') {
if ($dateTo != '') {
if ($dateFrom != "") {
if ($dateTo != "") {
if ($dateFrom == $dateTo) {
$dateAux = $dateFrom;
$dateFrom = $dateAux . " 00:00:00";
$dateTo = $dateAux . " 23:23:59";
}
$dateSame = $dateFrom;
$dateFrom = $dateSame . " 00:00:00";
$dateTo = $dateSame . " 23:59:59";
} else {
$dateFrom = $dateFrom . " 00:00:00";
$dateTo = $dateTo . " 23:59:59";
}
$Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ) ) );
$CriteriaCount->add( $CriteriaCount->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ) ) );
} else {
$dateFrom = $dateFrom . " 00:00:00";
$Criteria->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL );
$CriteriaCount->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL );
}
} elseif ($dateTo != '') {
} elseif ($dateTo != "") {
$dateTo = $dateTo . " 23:59:59";
$Criteria->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL );
$CriteriaCount->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL );
}

View File

@@ -3602,7 +3602,7 @@ class Cases
$docVersion = $appDocument->getDocVersion();
$arrayInfo = pathinfo($appDocument->getAppDocFilename());
$extension = (isset($arrayInfo["extension"])) ? $arrayInfo["extension"] : null;
$strPathName = PATH_DOCUMENT . $applicationUid . PATH_SEP;
$strPathName = PATH_DOCUMENT . G::getPathFromUID($applicationUid) . PATH_SEP;
$strFileName = $appDocUid . "_" . $docVersion . "." . $extension;
switch ($option) {

View File

@@ -46,8 +46,16 @@ class CLI
public static function taskName ($name)
{
self::$currentTask = $name;
self::$tasks[$name] = array ('name' => $name,'description' => null,'args' => array (),'function' => null,'opt' => array ('short' => '','long' => array (),'descriptions' => array ()
)
self::$tasks[$name] = array (
'name' => $name,
'description' => null,
'args' => array (),
'function' => null,
'opt' => array (
'short' => '',
'long' => array (),
'descriptions' => array ()
)
);
}

View File

@@ -915,5 +915,29 @@ class Configurations // extends Configuration
return array("caseColumns" => $caseColumns, "caseReaderFields" => $caseReaderFields, "rowsperpage" => 20, "dateformat" => "M d, Y");
}
/**
* Set the current Directory structure version, default value 1.
* Note.- TAKE CARE for the version value, input/output couln't work at the wrong version.
* @param integer $version
*/
public function setDirectoryStructureVer($version = 1)
{
$obj = '';
$this->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
$this->aConfig['directoryStructure'] = $version;
$this->saveConfig('ENVIRONMENT_SETTINGS', $obj);
}
/**
* Get the current directory structure version if the array iten 'directoryStructure' doesn't exists it will returns 1.
* @return integer
*/
public function getDirectoryStructureVer()
{
$obj = '';
$this->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
$ver = isset($this->aConfig['directoryStructure']) ? $this->aConfig['directoryStructure'] : 1;
return $ver;
}
}

View File

@@ -1708,7 +1708,7 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu
}
$sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion;
$pathOutput = PATH_DOCUMENT . $sApplication . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die;
$pathOutput = PATH_DOCUMENT . G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die;
G::mk_dir( $pathOutput );
$aProperties = array ();
@@ -1747,7 +1747,7 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu
$oAppDocument1 = new AppDocument();
$oAppDocument1->update( $aFields );
$sPathName = PATH_DOCUMENT . $sApplication . PATH_SEP;
$sPathName = PATH_DOCUMENT . G::getPathFromUID($sApplication) . PATH_SEP;
$oData['APP_UID'] = $sApplication;
$oData['ATTACHMENT_FOLDER'] = true;

View File

@@ -4426,6 +4426,7 @@ class processMap
$aDirectories[] = array('PATH' => ($sCurrentDirectory != '' ? $sCurrentDirectory . PATH_SEP : '') . $sObject, 'DIRECTORY' => $sObject );
} else {
$aAux = pathinfo($sPath);
$aAux['extension'] = (isset($aAux['extension'])?$aAux['extension']:'');
$aFiles[] = array('FILE' => $sObject, 'EXT' => $aAux['extension'] );
}
}

View File

@@ -89,6 +89,13 @@ class workspaceTools
$stop = microtime(true);
$final = $stop - $start;
CLI::logging("<*> Process Updating cache view carried out in $final seconds.\n");
$start = microtime(true);
CLI::logging("> Updating cases directories structure...\n");
$this->upgradeCasesDirectoryStructure($workSpace);
$stop = microtime(true);
$final = $stop - $start;
CLI::logging("<*> Process Updating directories structure carried out in $final seconds.\n");
}
/**
@@ -482,6 +489,97 @@ class workspaceTools
// end of reset
}
/**
* fix the 32K issue, by migrating /files directory structure to an uid tree structure based.
* @param $workspace got the site(s) the manager wants to upgrade
*/
public function upgradeCasesDirectoryStructure ($workspace)
{
define('PATH_DOCUMENT', PATH_DATA . 'sites/' . $workspace . '/' . 'files/');
$doclevel = explode('/', PATH_DOCUMENT);
$length = sizeof(PATH_DOCUMENT);
$filesDir = $doclevel[$length - 1];
if (is_dir(PATH_DOCUMENT) && is_writable($filesDir)) {
CLI::logging(CLI::error("Error:" . PATH_DOCUMENT . " is not writable... please check the su permissions.\n"));
return;
}
$directory = array();
$blackHoleDir = G::getBlackHoleDir();
$directory = glob(PATH_DOCUMENT . "*", GLOB_ONLYDIR);
$dirslength = sizeof($directory);
if (! @chdir(PATH_DOCUMENT)) {
CLI::logging(CLI::error("Cannot use Document directory. The upgrade must be done as root.\n"));
return;
}
//Start migration
for ($index = 0; $index < $dirslength; $index++) {
$depthdirlevel = explode('/', $directory[$index]);
$lastlength = sizeof($depthdirlevel);
$UIdDir = $depthdirlevel[$lastlength - 1];
$lenDir = strlen($UIdDir);
if ($lenDir == 32 && $UIdDir != $blackHoleDir) {
$len = count(scandir($UIdDir));
if ($len > 2) {
//lenght = 2, because the function check . and .. dir links
$newDiretory = G::getPathFromUIDPlain($UIdDir);
CLI::logging("Migrating $UIdDir to $newDiretory\n");
G::mk_dir($newDiretory);
//echo `cp -R $UIdDir/* $newDiretory/`;
if (G::recursive_copy($UIdDir, $newDiretory)) {
CLI::logging("Removing $UIdDir...\n");
G::rm_dir($UIdDir);
rmdir($UIdDir);//remove the diretory itself, G::rm_dir cannot do it
} else {
CLI::logging(CLI::error("Error: Failure at coping from $UIdDir...\n"));
}
} else {
CLI::logging("$UIdDir is empty, removing it\n");
rmdir($UIdDir);//remove the diretory itself
}
}
}
//Start '0' directory migration
$black = PATH_DOCUMENT . $blackHoleDir . '/';
if (is_dir($black)) {
$newpattern = array();
$file = glob($black . '*.*');//files only
$dirlen = count($file);
for ($index = 0; $index < $dirlen; $index++) {
$levelfile = explode('/', $file[$index]);
$lastlevel = sizeof($levelfile);
$goalFile = $levelfile[$lastlevel - 1];
$newpattern = G::getPathFromFileUIDPlain($blackHoleDir, $goalFile);
CLI::logging("Migrating $blackHoleDir file: $goalFile\n");
G::mk_dir($blackHoleDir . '/' . $newpattern[0]);
//echo `cp -R $black$goalFile $black$newpattern[0]/$newpattern[1]`;
if (copy($black . $goalFile, $black . $newpattern[0] . '/' . $newpattern[1])) {
unlink($file[$index]);
} else {
CLI::logging(CLI::error("Error: Failure at copy $file[$index] files...\n"));
}
}
}
//Set value of 2 to the directory structure version.
$this->initPropel(true);
G::LoadClass("configuration");
$conf = new Configurations();
if ($conf->exists("ENVIRONMENT_SETTINGS")) {
$conf->setDirectoryStructureVer(2);
CLI::logging(CLI::info("Version Directory Structure is 2 now.\n"));
} else {
CLI::logging(CLI::error("Error: found at try to use ENVIRONMENT_SETTINGS row.\n"));
return;
}
}
/**
* Upgrade this workspace database to the latest plugins schema
*/

View File

@@ -434,7 +434,7 @@ class AppFolder extends BaseAppFolder
$info = pathinfo($oAppDocument->getAppDocFilename());
$version = (!empty($docVersion))? "_" . $docVersion : "_1";
$outDocPath = PATH_DOCUMENT . $row1["APP_UID"] . PATH_SEP . "outdocs" . PATH_SEP;
$outDocPath = PATH_DOCUMENT . G::getPathFromUID($row1["APP_UID"]) . PATH_SEP . "outdocs" . PATH_SEP;
if (file_exists($outDocPath . $appDocUid . $version . ".pdf") ||
file_exists($outDocPath . $info["basename"] . $version . ".pdf") ||

View File

@@ -177,8 +177,12 @@ class Translation extends BaseTranslation
//$json = new Services_JSON(); DEPRECATED
$f = fopen( $cacheFileJS, 'w' );
fwrite( $f, "var G_STRINGS =" . Bootstrap::json_encode( $translationJS ) . ";\n" );
fclose( $f );
if ($f == false) {
error_log("Error: Cannot write into cachefilejs: $cacheFileJS\n");
} else {
fwrite( $f, "var G_STRINGS =" . Bootstrap::json_encode( $translationJS ) . ";\n");
fclose( $f );
}
$res['cacheFile'] = $cacheFile;
$res['cacheFileJS'] = $cacheFileJS;
@@ -409,7 +413,6 @@ class Translation extends BaseTranslation
if (! file_exists( $filePath )) {
//the transaltions table file doesn't exist, then build it
if (! is_dir( dirname( $this->envFilePath ) )) {
G::mk_dir( dirname( $this->envFilePath ) );
}
@@ -418,7 +421,7 @@ class Translation extends BaseTranslation
$params = self::getInfoFromPOFile( $basePOFile );
$this->addTranslationEnvironment( $params['LOCALE'], $params['HEADERS'], $params['COUNT'] );
//getting more lanuguage translations
//getting more language translations
$files = glob( $translationsPath . "*.po" );
foreach ($files as $file) {
$params = self::getInfoFromPOFile( $file );

2
workflow/engine/controllers/installer.php Normal file → Executable file
View File

@@ -216,7 +216,6 @@ class Installer extends Controller
public function getPermissionInfo ()
{
$this->setResponseType( 'json' );
$info = new StdClass();
$info->success = true;
$noWritableFiles = array ();
@@ -289,6 +288,7 @@ class Installer extends Controller
if (is_dir( $aux['dirname'] )) {
if (! file_exists( $_REQUEST['pathLogFile'] )) {
@file_put_contents( $_REQUEST['pathLogFile'], '' );
chmod($_REQUEST['pathShared'], 0770);
}
}
}

View File

@@ -1258,7 +1258,7 @@ function uploadExternalDocument()
$aID=array('INP_DOC_DESTINATION_PATH'=>$folderStructure['PATH']);
}
$oAppDocument = new AppDocument();
//Get the Custom Folder ID (create if necessary)
$oFolder=new AppFolder();
@@ -1272,6 +1272,7 @@ function uploadExternalDocument()
$fileTags="EXTERNAL";
}
foreach ($quequeUpload as $key => $fileObj) {
$oAppDocument = new AppDocument();
switch ($actionType) {
case "R":
//replace
@@ -1333,15 +1334,18 @@ function uploadExternalDocument()
}
$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 . $appId . PATH_SEP;
$sFileName = $sAppDocUid . "_".$iDocVersion. '.' . $ext;
G::uploadFile($fileObj['tempName'], $sPathName, $sFileName);
$sPathName = PATH_DOCUMENT . G::getPathFromUID($appId) . PATH_SEP;
$file = G::getPathFromFileUID($appId, $sAppDocUid);
$sPathName .= $file[0];
$sFileName = $file[1] . "_" . $iDocVersion . '.' . $ext;
G::uploadFile($fileObj['tempName'], $sPathName, $sFileName); //upload
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry =& PMPluginRegistry::getSingleton();

View File

@@ -123,7 +123,7 @@ try {
//save the file
if (!empty($_FILES['form'])) {
if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) {
$sPathName = PATH_DOCUMENT . $appId . PATH_SEP;
$sPathName = PATH_DOCUMENT . G::getPathFromUID($appId) . PATH_SEP;
$sFileName = $sAppDocUid . "_" . $iDocVersion . '.' . $ext;
G::uploadFile($_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $sPathName, $sFileName);

View File

@@ -53,9 +53,9 @@ function casesShowOuputDocumentExist ($url)
$ver = '_1';
}
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $sAppDocUid . $ver . '.' . $ext;
$realPath1 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $info['basename'] . $ver . '.' . $ext;
$realPath2 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $info['basename'] . '.' . $ext;
$realPath = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $sAppDocUid . $ver . '.' . $ext;
$realPath1 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $info['basename'] . $ver . '.' . $ext;
$realPath2 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $info['basename'] . '.' . $ext;
$sw_file_exists = false;
if (file_exists( $realPath )) {
$sw_file_exists = true;

View File

@@ -225,6 +225,7 @@ try {
//Get the Custom Folder ID (create if necessary)
$oFolder = new AppFolder();
$documentFileStructure = $oFolder->getFolderStructure();
$aFields = array ("APP_UID" => $_SESSION["APPLICATION"],"DEL_INDEX" => $_SESSION["INDEX"],"USR_UID" => $_SESSION["USER_LOGGED"],"DOC_UID" => $indocUid,"APP_DOC_TYPE" => "INPUT","APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),"APP_DOC_COMMENT" => "","APP_DOC_TITLE" => "","APP_DOC_FILENAME" => $arrayFileName[$i],"FOLDER_UID" => $oFolder->createFromPath( $aID["INP_DOC_DESTINATION_PATH"] ),"APP_DOC_TAGS" => $oFolder->parseTags( $aID["INP_DOC_TAGS"] ),"APP_DOC_FIELDNAME" => $fieldName
);
@@ -240,9 +241,9 @@ try {
$sAppDocUid = $oAppDocument->getAppDocUid();
$aInfo = pathinfo( $oAppDocument->getAppDocFilename() );
$sExtension = ((isset( $aInfo["extension"] )) ? $aInfo["extension"] : "");
$sPathName = PATH_DOCUMENT . $_SESSION["APPLICATION"] . PATH_SEP;
$pathUID = G::getPathFromUID($_SESSION["APPLICATION"]);
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;// . $documentFileStructure;
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
G::uploadFile( $arrayFileTmpName[$i], $sPathName, $sFileName );
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document

View File

@@ -29,6 +29,9 @@
require_once ("classes/model/AppDocumentPeer.php");
//v = Version
//a = Case UID
$oAppDocument = new AppDocument();
if (! isset( $_GET['v'] )) {
//Load last version of the document
@@ -42,7 +45,7 @@ $oAppDocument->Fields = $oAppDocument->load( $_GET['a'], $docVersion );
$sAppDocUid = $oAppDocument->getAppDocUid();
$iDocVersion = $oAppDocument->getDocVersion();
$info = pathinfo( $oAppDocument->getAppDocFilename() );
$ext = $info['extension'];
$ext = (isset($info['extension'])?$info['extension']:'');//BUG fix: must handle files without any extension
if (isset( $_GET['b'] )) {
if ($_GET['b'] == '0') {
@@ -54,8 +57,11 @@ if (isset( $_GET['b'] )) {
$bDownload = true;
}
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/' . $sAppDocUid . '_' . $iDocVersion . '.' . $ext;
$realPath1 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/' . $sAppDocUid . '.' . $ext;
$app_uid = G::getPathFromUID($oAppDocument->Fields['APP_UID']);
$file = G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
$realPath = PATH_DOCUMENT . $app_uid . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
$realPath1 = PATH_DOCUMENT . $app_uid . '/' . $file[0] . $file[1] . '.' . $ext;
$sw_file_exists = false;
if (file_exists( $realPath )) {
$sw_file_exists = true;
@@ -65,7 +71,7 @@ if (file_exists( $realPath )) {
}
if (! $sw_file_exists) {
$error_message = "'" . $oAppDocument->Fields['APP_DOC_FILENAME'] . "' " . G::LoadTranslation( 'ID_ERROR_STREAMING_FILE' );
$error_message = G::LoadTranslation( 'ID_ERROR_STREAMING_FILE' );
if ((isset( $_POST['request'] )) && ($_POST['request'] == true)) {
$res['success'] = 'failure';
$res['message'] = $error_message;
@@ -83,7 +89,7 @@ if (! $sw_file_exists) {
$res['message'] = $oAppDocument->Fields['APP_DOC_FILENAME'];
print G::json_encode( $res );
} else {
G::streamFile( $realPath, $bDownload, $oAppDocument->Fields['APP_DOC_FILENAME'] );
G::streamFile( $realPath, $bDownload, $oAppDocument->Fields['APP_DOC_FILENAME'] ); //download
}
}

View File

@@ -48,9 +48,9 @@ $ver = (isset( $_GET['v'] ) && $_GET['v'] != '') ? '_' . $_GET['v'] : '';
if (! $ver) //This code is in the case the outputdocument won't be versioned
$ver = '_1';
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $sAppDocUid . $ver . '.' . $ext;
$realPath1 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $info['basename'] . $ver . '.' . $ext;
$realPath2 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $info['basename'] . '.' . $ext;
$realPath = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $sAppDocUid . $ver . '.' . $ext;
$realPath1 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $info['basename'] . $ver . '.' . $ext;
$realPath2 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $info['basename'] . '.' . $ext;
$sw_file_exists = false;
if (file_exists( $realPath )) {

View File

@@ -57,6 +57,6 @@ if (! isset( $_GET['ext'] )) {
}
}
$realPath = PATH_DOCUMENT . $_SESSION['APPLICATION'] . '/outdocs/' . $info['basename'] . '.' . $ext;
$realPath = PATH_DOCUMENT . G::getPathFromUID($_SESSION['APPLICATION']) . '/outdocs/' . $info['basename'] . '.' . $ext;
G::streamFile( $realPath, true );

View File

@@ -411,7 +411,7 @@ try {
$sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion;
$pathOutput = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs' . PATH_SEP;
$pathOutput = PATH_DOCUMENT . G::getPathFromUID($_SESSION['APPLICATION']) . PATH_SEP . 'outdocs' . PATH_SEP;
G::mk_dir( $pathOutput );
switch ($aOD['OUT_DOC_TYPE']) {
case 'HTML':
@@ -518,7 +518,7 @@ try {
if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) {
$triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
$sPathName = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP;
$sPathName = PATH_DOCUMENT . G::getPathFromUID($_SESSION['APPLICATION']) . PATH_SEP;
$oData['APP_UID'] = $_SESSION['APPLICATION'];
$oData['ATTACHMENT_FOLDER'] = true;

View File

@@ -36,7 +36,7 @@ try {
//save the file
if (! empty( $_FILES['form'] )) {
if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) {
$sPathName = PATH_DOCUMENT . $_GET['APP_UID'] . PATH_SEP;
$sPathName = PATH_DOCUMENT . G::getPathFromUID($_GET['APP_UID']) . PATH_SEP;
$sFileName = $sAppDocUid . '.' . $ext;
G::uploadFile( $_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $sPathName, $sFileName );

View File

@@ -106,7 +106,7 @@ if (isset( $_FILES ) && $_FILES["ATTACH_FILE"]["error"] == 0) {
$ext = (isset( $info["extension"] )) ? $info["extension"] : "";
//Save the file
echo $sPathName = PATH_DOCUMENT . $sAppUid . PATH_SEP;
echo $sPathName = PATH_DOCUMENT . G::getPathFromUID($sAppUid) . PATH_SEP;
echo $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $ext;
print G::uploadFile( $_FILES["ATTACH_FILE"]["tmp_name"], $sPathName, $sFileName );
print ("* The file " . $_FILES["ATTACH_FILE"]["name"] . " was uploaded successfully in case " . $sAppUid . " as input document..\n") ;

View File

@@ -47,8 +47,8 @@ if (isset( $_GET['b'] )) {
$bDownload = true;
}
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/' . $sAppDocUid . '_' . $iDocVersion . '.' . $ext;
$realPath1 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/' . $sAppDocUid . '.' . $ext;
$realPath = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/' . $sAppDocUid . '_' . $iDocVersion . '.' . $ext;
$realPath1 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/' . $sAppDocUid . '.' . $ext;
$sw_file_exists = false;
if (file_exists( $realPath )) {
$sw_file_exists = true;

View File

@@ -47,9 +47,9 @@ $ver = (isset( $_GET['v'] ) && $_GET['v'] != '') ? '_' . $_GET['v'] : '';
if (! $ver) //This code is in the case the outputdocument won't be versioned
$ver = '_1';
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $sAppDocUid . $ver . '.' . $ext;
$realPath1 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $info['basename'] . $ver . '.' . $ext;
$realPath2 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $info['basename'] . '.' . $ext;
$realPath = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $sAppDocUid . $ver . '.' . $ext;
$realPath1 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $info['basename'] . $ver . '.' . $ext;
$realPath2 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $info['basename'] . '.' . $ext;
$sw_file_exists = false;
if (file_exists( $realPath )) {
$sw_file_exists = true;