示例#1
0
 public function getAll($userId)
 {
     $sp = "sp_notification_getAllByUserId";
     $params = new SDMDBParameters();
     $params->add($userId);
     // 		var_dump($params);
     $result = $this->handler->execute_stored_procedure($sp, $params, 'array');
     // 				var_dump($result);
     $ret = false;
     if ($result && $result['response']['system']['errorNo'] == 0) {
         if (isset($result['response']['resultSet'])) {
             if (isset($result['response']['resultSet'])) {
                 $dataRows = $result['response']['resultSet'];
                 $notifications = array();
                 foreach ($dataRows as $dataRow) {
                     $notification = new Notification();
                     $notification->setId($dataRow['notification_id']);
                     $notification->setStatus($dataRow['status']);
                     $notification->setProirity($dataRow['proirity']);
                     $notification->setUserId($dataRow['user_id']);
                     $notification->setType($dataRow['type']);
                     $notification->setMsg($dataRow['message']);
                     $notification->setEventDt($dataRow['event_dt']);
                     $notification->setLastUpate($dataRow['last_update']);
                     $notification->setObserveeId($dataRow['observee_id']);
                     array_push($notifications, $notification);
                 }
                 $ret = $notifications;
             } else {
                 throw new SSSException(ErrorFactory::ERR_DB_INVALID_RESULT);
             }
         } else {
             $ret = false;
         }
     } else {
         throw new SSSException(ErrorFactory::ERR_DB_EXECUTE);
     }
     return $ret;
 }
 public function submitPanic($userId)
 {
     $notifiMod = new NotificationModel();
     $studMod = new StudentModel();
     $student = null;
     try {
         $student = $studMod->getStudent($userId);
         // 			var_dump($student);
         $date = new \DateTime();
         $notification = new Notification();
         $notification->setEventDt($date->format(DATETIME_FORMAT));
         $notification->setProirity(1);
         $notification->setType("Panic");
         $notification->setStatus("P");
         $notification->setUserId($userId);
         $notification->setMsg($student->getName() . " call help");
         $notifiMod->addNotification($notification);
         $result['result'] = "success";
     } catch (SSSException $e) {
         $result = ErrorFactory::getError($e->getCode());
     }
     return $result;
 }