示例#1
0
 public function dologinAction()
 {
     Db::connect();
     $bean = R::dispense('user');
     // the redbean model
     $required = ['Name' => 'name', 'Email' => 'email', 'User_Name' => ['rmnl', 'az_lower'], 'Password' => 'password_hash'];
     \RedBeanFVM\RedBeanFVM::registerAutoloader();
     // for future use
     $fvm = \RedBeanFVM\RedBeanFVM::getInstance();
     $fvm->generate_model($bean, $required);
     //the magic
     R::store($bean);
     $val = new validation();
     $val->addSource($_POST)->addRule('email', 'email', true, 1, 255, true)->addRule('password', 'string', true, 10, 150, false);
     $val->run();
     if (count($val->errors)) {
         Debug::r($val->errors);
         foreach ($val->errors as $error) {
             Notification::setMessage($error, Notification::TYPE_ERROR);
         }
         $this->redirect(Request::createUrl('login', 'login'));
     } else {
         Notification::setMessage("Welcome back !", Notification::TYPE_SUCCESS);
         Debug::r($val->sanitized);
         session::set('user', ['sanil']);
         $this->redirect(Request::createUrl('index', 'index'));
     }
 }
示例#2
0
 /**
  * Creates a by $type parameter specified message
  *
  * @param string $type
  * @param string $message
  *
  * @return Notification
  */
 private function createMessageObject(string $type, string $message) : Notification
 {
     $msg = new Notification();
     $msg->setType($type);
     $msg->setMessage($message);
     $this->handler->add($msg);
     return $msg;
 }
示例#3
0
 /**
  * @Route("/sendEventsCurlPost", name="send_events_curl_post")
  * @Method("POST")
  */
 public function sendEventsCurlAction(Request $request)
 {
     //$events =  $request->request->get('event_check_list');
     $em = $this->getDoctrine()->getManager();
     $qb = $em->createQueryBuilder();
     $qb->select('m');
     $qb->from('AppBundle:Event', 'm');
     //$qb->where($qb->expr()->in('m.id', $events));
     //ArrayCollection
     $result = $qb->getQuery()->getResult();
     $events = array();
     //$serializer = $this->container->get('jms_serializer');
     //
     $Devices = $em->getRepository('AppBundle:Device')->findAll();
     $devicesTokens = "";
     foreach ($Devices as $key => $value) {
         $devicesTokens = $devicesTokens . ',' . $Devices[$key]->getDeviceToken();
     }
     $devicesTokens = substr($devicesTokens, 1);
     foreach ($result as $key => $value) {
         //$events [$key] =json_encode(array_values((array) $value),JSON_FORCE_OBJECT);
         $events[$key] = $value;
         //$events [$key] =json_encode($serializer->serialize($value, 'json'),JSON_FORCE_OBJECT);
     }
     $devicesTokens = str_replace(',', '","', $devicesTokens);
     $notification = new Notification();
     $notification->setTitle($request->request->get('title'));
     $notification->setMessage($request->request->get('message'));
     $notification->setDate();
     $em = $this->getDoctrine()->getManager();
     $em->persist($notification);
     $em->flush();
     $cmd = '  curl -u 485d490dd0720a823c518fb6d39d73623ddff1f0487764a4: -H "Content-Type: application/json" -H "X-Ionic-Application-Id: 9cea62b6" https://push.ionic.io/api/v1/push -d \'{"tokens": ["' . $devicesTokens . '"],"production": false, "notification":{  "alert":"' . $request->request->get('message') . '", "title": "' . $request->request->get('title') . '","android": {"payload":""}, "ios": {"payload": ""}}}\' ';
     exec($cmd);
     //          echo $cmd;
     //          die;
     $notifications = $em->getRepository('AppBundle:Notification')->find($notification->getId());
     $serializer = $this->container->get('serializer');
     $reports = $serializer->serialize($notifications, 'json');
     return new Response($reports);
 }
示例#4
0
	public function update(){
		if(RequestUtils::isPost()){
			parent::updateNotForward();

			$ticket = DAO::getOne("Ticket",$_POST['idTicket']);
			$messages = DAO::getAll("Message", 'idTicket = '.$_POST['idTicket']);

			$users = array();
			foreach ($messages as $message) {
				$user = $message->getUser()->getId();
				if (!in_array($user, $users) && $user != Auth::getUser()->getId() ) {
					array_push($users, $message->getUser()->getId());
				}
				$message->setUser(DAO::getAll("User", "id=".$message->getUser()->getId())[0]);
			}
			
			$message = DAO::getOne("Message", "idUser="******" ORDER BY date DESC");

			foreach ($users as $user) {
				if (DAO::getOne("Notification", 'idUser = '******' AND idTicket = '.$ticket->getId()) == null) {
					$user = DAO::getOne("User", $user);
					$notif = new Notification();
					$notif->setUser($user);
					$notif->setTicket($ticket);
					$notif->setMessage($message);
					DAO::insert($notif);
				}
			}


			$this->loadView("ticket/vMessage",array("messages"=>$messages, "ticket" => $ticket));
			Jquery::execute("CKEDITOR.replace('contenu');");
			Jquery::executeOn('.submitMessage', "click", "
			for ( instance in CKEDITOR.instances )
        		CKEDITOR.instances[instance].updateElement();
			");
			Jquery::postFormOn("click",".submitMessage","messages/update","frm",".contentMessages");
			echo Jquery::compile();
			
		}
	}