Пример #1
0
 public function togglestudy()
 {
     try {
         if (!Check::digits($rid = $_SESSION['user']['researcher_id'])) {
             throw new Exception('invalid researcher id!');
         }
         if (!Check::digits($study_id = $_POST['study_id'], $empty = false)) {
             throw new Exception('invalid study id!');
         }
         $r = new Research();
         $visible = $_REQUEST['visible'] ? 1 : 0;
         if ($r->upd(array('researcher_id' => $rid, 'study_id' => $study_id), array('visible' => $visible)) === false) {
             throw new Exception($r->err());
         }
         return 'home.tpl';
     } catch (Exception $e) {
         $this->err($e);
         View::assign('error', $this->error);
         return 'error.tpl';
     }
 }