/** * Creates a note */ protected function actionCreate($category_id = 0) { $model = new Note(); if (GO::request()->isPost()) { $note = GO::request()->post['note']; if (isset($note['currentPassword'])) { //if the note was encrypted and no new password was supplied the current //pasword is sent. $note['userInputPassword1'] = $note['userInputPassword2'] = $note['currentPassword']; } $model->setAttributes($note); if ($model->save()) { if (GO::modules()->files) { $f = new \GO\Files\Controller\FolderController(); $response = array(); //never used in processAttachements? $f->processAttachments($response, $model, $note); } } echo $this->render('submit', array('note' => $model)); } else { if (empty($category_id)) { $defaultCategory = GO\Notes\NotesModule::getDefaultNoteCategory(GO::user()->id); $model->category_id = $defaultCategory->id; } else { $model->category_id = $category_id; } echo $this->render('form', array('note' => $model)); } }
/** * 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(); } }