"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/files/model/Folder.php" between
groupoffice-6.3.62-php-71.tar.gz and groupoffice-6.3.63-php-71.tar.gz

About: GroupOffice is a web-based office suit: Calendar, CRM, E-mail, File sharing, Projects, Synchronization (6.3 series for PHP 7.1; community version).

Folder.php  (groupoffice-6.3.62-php-71):Folder.php  (groupoffice-6.3.63-php-71)
skipping to change at line 291 skipping to change at line 291
if(!$currentFolder) if(!$currentFolder)
return $ids; return $ids;
while ($currentFolder = $currentFolder->parent) { while ($currentFolder = $currentFolder->parent) {
$ids[] = $currentFolder->id; $ids[] = $currentFolder->id;
} }
return $ids; return $ids;
} }
protected function getFsFolder() { protected function getFsFolder() {
//\go\core\util\StringUtil::debugUTF8($this->path);
return new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . $this->path); return new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . $this->path);
} }
private function _checkParentId(){ private function _checkParentId(){
if($this->isModified("parent_id") && !empty($this->id)){ if($this->isModified("parent_id") && !empty($this->id)){
$currentFolder=$this; $currentFolder=$this;
while ($currentFolder = $currentFolder->parent) { while ($currentFolder = $currentFolder->parent) {
if($currentFolder->id==$this->id){ if($currentFolder->id==$this->id){
$this->setValidationError ("parent_id", " Can not move folder into this folder because it's a child"); $this->setValidationError ("parent_id", " Can not move folder into this folder because it's a child");
skipping to change at line 353 skipping to change at line 356
}else{ }else{
$parentPath = $this->parent ? $this->parent->path.'/' : ' '; $parentPath = $this->parent ? $this->parent->path.'/' : ' ';
$oldPath = \GO::config()->file_storage_path . $parentPath .$filename; $oldPath = \GO::config()->file_storage_path . $parentPath .$filename;
} }
return new \GO\Base\Fs\Folder($oldPath); return new \GO\Base\Fs\Folder($oldPath);
} }
public function checkNormalization() { public function checkNormalization() {
if(!\Normalizer::isNormalized($this->name, \Normalizer::FORM_D))
{
\GO::debug("Normalizing $this->id to Unicode Form D");
$name = \Normalizer::normalize($this->name, \Normalizer:: if(!\go\core\util\StringUtil::isNormalized($this->name)) {
FORM_D); \GO::debug("Normalizing $this->name to Unicode Form C");
$this->getFsFolder()->rename($name);
GO()->getDbConnection()->update('fs_folders',['name' => $ $name = \go\core\util\StringUtil::normalize($this->name);
name], ['id' => $this->id])->execute();
if($this->getFsFolder()->exists()) {
$this->getFsFolder()->rename($name);
}
if(!$this->getIsNew()) {
GO()->getDbConnection()->update('fs_folders',['na
me' => $name], ['id' => $this->id])->execute();
}
$this->name = $name; $this->name = $name;
$this->_path = null;
} }
} }
protected function beforeSave() { protected function beforeSave() {
//Normalize UTF-8. ONly form D works on MacOS webdav! //Normalize UTF-8. ONly form D works on MacOS webdav!
$this->name = \Normalizer::normalize($this->name, \Normalizer::FO $this->checkNormalization();
RM_D); //$this->name = \Normalizer::normalize($this->name, \Normalizer::
FORM_D);
//check permissions on the filesystem //check permissions on the filesystem
if($this->isNew){ if($this->isNew){
if(!$this->fsFolder->firstExistingParent()->isWritable()) { if(!$this->fsFolder->firstExistingParent()->isWritable()) {
throw new \Exception("Folder ".$this->fsFolder->f irstExistingParent()->stripFileStoragePath()." (Creating ".$this->name.") is rea d only on the filesystem. Please check the file system permissions (hint: chown -R www-data:www-data /home/groupoffice)"); throw new \Exception("Folder ".$this->fsFolder->f irstExistingParent()->stripFileStoragePath()." (Creating ".$this->name.") is rea d only on the filesystem. Please check the file system permissions (hint: chown -R www-data:www-data /home/groupoffice)");
} }
}else }else
{ {
if($this->isModified('name') || $this->isModified('parent _id')){ if($this->isModified('name') || $this->isModified('parent _id')){
skipping to change at line 794 skipping to change at line 806
GO::$disableModelCache=$recurseAll; GO::$disableModelCache=$recurseAll;
// if(class_exists("GO\Filesearch\FilesearchModule")) // if(class_exists("GO\Filesearch\FilesearchModule"))
// \GO\Filesearch\FilesearchModule::$disableIndexing=true; // \GO\Filesearch\FilesearchModule::$disableIndexing=true;
if($this->fsFolder->exists()){ if($this->fsFolder->exists()){
$items = $this->fsFolder->ls(); $items = $this->fsFolder->ls();
foreach ($items as $item) { foreach ($items as $item) {
try{ // try{
//\GO::debug("FS SYNC: Adding fs ".$item->name(). " to database"); //\GO::debug("FS SYNC: Adding fs ".$item->name(). " to database");
if ($item->isFile()) { if ($item->isFile()) {
$file = $this->hasFile($item->nam e()); $file = $this->hasFile($item->nam e());
if (!$file){ if (!$file){
$this->addFile($item->nam e()); $this->addFile($item->nam e());
}else }else
{ {
//this will update timest amp and size of file //this will update timest amp and size of file
if($file->mtime != $file- >fsFile->mtime()){ if($file->mtime != $file- >fsFile->mtime()){
$file->save(); $file->save();
} }
} }
}else }else
{ {
$willSync = $recurseOneLevel || $ recurseAll; $willSync = $recurseOneLevel || $ recurseAll;
$folder = $this->hasFolder($item- >name()); $folder = $this->hasFolder($item- >name());
if(!$folder) if(!$folder) {
$folder = $this->addFolde r($item->name(), false, !$willSync); $folder = $this->addFolde r($item->name(), false, !$willSync);
}
if($willSync) if($willSync)
$folder->syncFilesystem($ recurseAll, false); $folder->syncFilesystem($ recurseAll, false);
} }
} // }
catch(\Exception $e){ // catch(\Exception $e){
echo "<span style='color:red;'>".$e->getM // echo "<span style='color:red;'>".$e->getM
essage()."</span>\n"; essage()."</span>\n";
} // }
} }
}else }else
{ {
$this->fsFolder->create(); $this->fsFolder->create();
} }
//make sure no filesystem items are deleted. Sometimes folders ar e stored as files somehow. //make sure no filesystem items are deleted. Sometimes folders ar e stored as files somehow.
$oldFileDeleteInDatabaseOnly = File::$deleteInDatabaseOnly; $oldFileDeleteInDatabaseOnly = File::$deleteInDatabaseOnly;
$oldFolderDeleteInDatabaseOnly = Folder::$deleteInDatabaseOnly; $oldFolderDeleteInDatabaseOnly = Folder::$deleteInDatabaseOnly;
File::$deleteInDatabaseOnly=true; File::$deleteInDatabaseOnly=true;
Folder::$deleteInDatabaseOnly=true; Folder::$deleteInDatabaseOnly=true;
$stmt= $this->folders(); $stmt= $this->folders();
while($folder = $stmt->fetch()){ while($folder = $stmt->fetch()){
try{ // try{
if(!$folder->fsFolder->exists() || $folder->fsFol der->isFile()) if(!$folder->fsFolder->exists() || $folder->fsFol der->isFile())
$folder->delete(true); $folder->delete(true);
}catch(\Exception $e){ // }catch(\Exception $e){
echo "<span style='color:red;'>".$e->getMessage() // echo "<span style='color:red;'>".$e->getMessage()
."</span>\n"; ."</span>\n";
} // }
} }
$stmt= $this->files(); $stmt= $this->files();
while($file = $stmt->fetch()){ while($file = $stmt->fetch()){
try{ // try{
if(!$file->fsFile->exists() || $file->fsFile->isF older()) if(!$file->fsFile->exists() || $file->fsFile->isF older())
$file->delete(true); $file->delete(true);
}catch(\Exception $e){ // }catch(\Exception $e){
echo "<span style='color:red;'>".$e->getMessage() // echo "<span style='color:red;'>".$e->getMessage()
."</span>\n"; ."</span>\n";
} // }
} }
$this->mtime=$this->fsFolder->mtime(); $this->mtime=$this->fsFolder->mtime();
$this->save(true); $this->save(true);
\GO::$disableModelCache=$oldCache; \GO::$disableModelCache=$oldCache;
\GO::setIgnoreAclPermissions($oldIgnoreAcl); \GO::setIgnoreAclPermissions($oldIgnoreAcl);
File::$deleteInDatabaseOnly=$oldFileDeleteInDatabaseOnly; File::$deleteInDatabaseOnly=$oldFileDeleteInDatabaseOnly;
 End of changes. 13 change blocks. 
27 lines changed or deleted 38 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)