示例#1
0
文件: Note.php 项目: ajaboa/crmpuan
 public function defaultAttributes()
 {
     $attr = parent::defaultAttributes();
     $category = NotesModule::getDefaultNoteCategory(GO::user()->id);
     $attr['category_id'] = $category->id;
     return $attr;
 }
示例#2
0
 /**
  * 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));
     }
 }