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

@@ -230,20 +230,28 @@ class Applications
}
*/
if ($dateFrom != '') {
if ($dateTo != '') {
if ($dateFrom == $dateTo) {
$dateAux = $dateFrom;
$dateFrom = $dateAux . " 00:00:00";
$dateTo = $dateAux . " 23:23:59";
}
$Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ) ) );
if ($dateFrom != "") {
if ($dateTo != "") {
if ($dateFrom == $dateTo) {
$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 );