/** * 課題詳細を確認(ここではViewでダウンロードリンクを発行できるように) * * @throws NotFoundException * @param string $id * @return void */ public function teacher_view($id = null) { if (!$this->Report->exists($id)) { throw new NotFoundException(__('不正なアクセス')); } // 通知を更新 $updateRM = new ReadManagementsController(); $updateRM->updateWithRM($id, 'Report', $this->Auth->user('id')); $options = array('conditions' => array('Report.' . $this->Report->primaryKey => $id)); $this->set('report', $this->Report->find('first', $options)); }
/** * 記事の情報表示 * * @param unknown $id * @throws NotFoundException */ private function __view($id = null) { if (!$id) { throw new NotFoundException(__('Invalid post')); } $post = $this->Post->findById($id); /* * 前画面へ戻るリンク */ $this->set('referer', $this->referer()); // 2階層分のデータを結合する // $this->Post->Behaviors->attach('Containable'); /* * 重要:モデルをViewへ引っ張ってくる場合は以下な感じにするのだ! */ $this->Post->contain(array('Comment.User.username', 'User.username', 'File')); // 通知を更新 $updateRM = new ReadManagementsController(); $updateRM->updateWithRM($id, 'Post', $this->Auth->user('id')); if (!$post) { throw new NotFoundException(__('無効なポスト')); } $this->set('post', $post); if ($this->request->is('post')) { $data = $this->request->data; if ($data['File']['0']['remove'] == 1) { // remove は1だとTrue if (!empty($data['File']['0']['id'])) { $this->loadModel('Attachment'); $this->Attachment->delete($data['File']['0']['id']); $this->Session->setFlash(__('削除しました。')); return $this->redirect(array('action' => 'view', $id)); } else { $this->Session->setFlash(__('削除できませんでした。')); } } else { $this->Session->setFlash(__('ファイルを選択してください。')); } } }