/** * When a folder is created for a project we must attach the parent folders * to the projects as well. * * @param \GO\Projects2\Model\Folder $model * @param \GO\Files\Model\Folder $folder */ public static function createParentFolders($model, $folder) { if (is_a($model, "GO\\Projects2\\Model\\Project")) { if ($project = $model->parent()) { GO::debug("Checking folder: " . $project->path); $folderController = new \GO\Files\Controller\FolderController(); $folderController->checkModelFolder($project, true, true); } } }
/** * A function that checks the consistency with the database. * Generally this is called by r=maintenance/checkDabase */ public function checkDatabase() { //$this->save(); echo "Checking " . (is_array($this->pk) ? implode(',', $this->pk) : $this->pk) . " " . $this->className() . "\n"; flush(); if ($this->aclField() && !$this->isJoinedAclField) { $acl = $this->acl; if (!$acl) { $this->setNewAcl(); } else { $user_id = empty($this->user_id) ? 1 : $this->user_id; $acl->user_id = $user_id; $acl->description = $this->tableName() . '.' . $this->aclField(); $acl->save(); } } if ($this->hasFiles() && GO::modules()->isInstalled('files')) { //ACL must be generated here. $fc = new \GO\Files\Controller\FolderController(); $this->files_folder_id = $fc->checkModelFolder($this); } //normalize crlf foreach ($this->columns as $field => $attr) { if (($attr['gotype'] == 'textfield' || $attr['gotype'] == 'textarea') && !empty($this->_attributes[$field])) { $this->{$field} = \GO\Base\Util\String::normalizeCrlf($this->_attributes[$field], "\n"); } } //fill in empty required attributes that have defaults $defaults = $this->getDefaultAttributes(); foreach ($this->columns as $field => $attr) { if ($attr['required'] && empty($this->{$field}) && isset($defaults[$field])) { $this->{$field} = $defaults[$field]; echo "Setting default value " . $this->className() . ":" . $this->id . " {$field}=" . $defaults[$field] . "\n"; } } if ($this->isModified()) { $this->save(); } }