Exemple #1
0
	public function sendRecoverMail(){
		global $config;
		$user = DAO::getOne("User", "mail = '".$_POST['email']."'");
		
		if ($user == null){
			return $this->_showMessage("Impossible de trouver un utilisateur correspondant à cet email : ".$_POST['email'], 'warning');
		}

		$token = new Token();
		$t = md5(uniqid(rand(), true));
		$token->setToken($t);
		$token->setUser($user);
		DAO::insert($token);
	
		$this->sendMail("<a href='".$config['siteUrl']."Support/resetPassword/".$t."'>Cliquez ici pour réintialiser votre mot de passe et en choisir un nouveau</a>", $user->getMail());
		
		return $this->_showMessage("Un mail vous a  été envoyé avec un lien permettant de réintialiser votre mot de passe...", 'success');
	}
Exemple #2
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();
			
		}
	}
Exemple #3
0
	public function signin_with_hybridauth($provider) {
		global $config;
		$authConfig=ROOT."configHybrid.php";
		include ROOT."./../vendor/hybridauth/hybridauth/hybridauth/Hybrid/Auth.php";

		$hybridauth=new Hybrid_Auth($authConfig);
		$adapter=$hybridauth->authenticate($provider[0]);
		$user_profile=$adapter->getUserProfile();

		$dbProvider=DAO::getOne("AuthProvider", array (
				"name" => $provider[0]
		));
		if ($dbProvider!=NULL) {
			$user=DAO::getOne("User", array (
					"login" => $user_profile->displayName,"idAuthProvider" => $dbProvider->getId()
			));
			if ($user===null) {
				$user=new User();
				$user->setLogin($user_profile->displayName);
				$user->setMail($user_profile->email);
				$user->setGroupe(DAO::getOne("Groupe", "id=2"));
				$user->setAuthProvider($dbProvider);
				$user->setKey($user_profile->identifier);
				DAO::insert($user);
			}
			$_SESSION["user"]=$user;
			setcookie("autoConnect", $provider[0], time()+3600, "/");
			if (array_key_exists("action", $_SESSION)) {
				Startup::runAction($_SESSION["action"], false, false);
				unset($_SESSION["action"]);
			} else {
				echo '<h3>Connecté à '.$dbProvider->getName().'</h3>';
				echo '<h4>'.$user->getLogin().'</h4>';
				echo '<div class="row"><div class="col-xs-6 col-md-3"><img style="width: 230px;height:230px;border-radius: 6px;" src="'.$user_profile->photoURL.'&s=460" alt="avatar" width="230" height="230"></div></div>';
			}
			echo "<div id='divInfoUser'></div>";
			echo Jquery::get("Indexx/getInfoUser/", "#divInfoUser");
			header("Location: ".$config['siteUrl']."/Indexx");
		}
	}
 /**
  * Met à jour à partir d'un post une instance de $className<br>
  * L'affectation des membres de l'objet par le contenu du POST se fait par appel de la méthode setValuesToObject()
  * @see _DefaultController::setValuesToObject()
  */
 public function update()
 {
     if (RequestUtils::isPost()) {
         $className = $this->model;
         $object = new $className();
         $this->setValuesToObject($object);
         if ($_POST["id"]) {
             try {
                 DAO::update($object);
                 $msg = new DisplayedMessage($this->model . " `{$object->toString()}` mis à jour");
                 if (isset($object->getMail())) {
                     $_SESSION["password"] = $object->getPassword();
                     $_SESSION["login"] = $object->getLogin();
                 }
             } catch (Exception $e) {
                 $msg = new DisplayedMessage("Impossible de modifier l'instance de " . $this->model, "danger");
             }
         } else {
             try {
                 DAO::insert($object);
                 $msg = new DisplayedMessage("Instance de " . $this->model . " `{$object->toString()}` ajoutée");
             } catch (Exception $e) {
                 $msg = new DisplayedMessage("Impossible d'ajouter l'instance de " . $this->model, "danger");
             }
         }
         $this->forward(get_class($this), "index", $msg);
     }
 }
	public function updateNotForward(){
			$className=$this->model;
			$object=new $className();
			$this->setValuesToObject($object);
			if($_POST["id"]){
				try{
					DAO::update($object);
					$msg=new DisplayedMessage($this->model." `{$object->toString()}` mis à jour");
				}catch(Exception $e){
					$msg=new DisplayedMessage("Impossible de modifier l'instance de ".$this->model,"danger");
				}
			}else{
				try{
					DAO::insert($object);
					$msg=new DisplayedMessage("Instance de ".$this->model." `{$object->toString()}` ajoutée");
				}catch(Exception $e){
					$msg=new DisplayedMessage("Impossible d'ajouter l'instance de ".$this->model,"danger");
				}
			}
			return $msg;
	} 
Exemple #6
0
 /**
  * Met à jour le membre $member de $instance annoté par un ManyToMany
  * @param Object $instance
  * @param String $member
  */
 public static function insertOrUpdateManyToMany($instance, $member)
 {
     $parser = new ManyToManyParser($instance, $member);
     if ($parser->init()) {
         $myField = $parser->getMyFkField();
         $field = $parser->getFkField();
         $sql = "INSERT INTO `" . $parser->getJoinTable() . "`(`" . $myField . "`,`" . $field . "`) VALUES (:" . $myField . ",:" . $field . ");";
         $memberAccessor = "get" . ucfirst($member);
         $memberValues = $instance->{$memberAccessor}();
         $myKey = $parser->getMyPk();
         $myAccessorId = "get" . ucfirst($myKey);
         $accessorId = "get" . ucfirst($parser->getPk());
         $id = $instance->{$myAccessorId}();
         if (!is_null($memberValues)) {
             DAO::$db->execute("DELETE FROM `" . $parser->getJoinTable() . "` WHERE `" . $myField . "`='" . $id . "'");
             $statement = DAO::$db->prepareStatement($sql);
             foreach ($memberValues as $k => $targetInstance) {
                 $foreignId = $targetInstance->{$accessorId}();
                 $foreignInstances = DAO::getAll($parser->getTargetEntity(), "`" . $parser->getPk() . "`" . "='" . $foreignId . "'");
                 if (!OrmUtils::exists($targetInstance, $parser->getPk(), $foreignInstances)) {
                     DAO::insert($targetInstance, false);
                     $foreignId = $targetInstance->{$accessorId}();
                     \Logger::log("InsertMany", "Insertion d'une instance de " . get_class($instance));
                 }
                 DAO::$db->bindValueFromStatement($statement, $myField, $id);
                 DAO::$db->bindValueFromStatement($statement, $field, $foreignId);
                 $result = $statement->execute();
                 \Logger::log("InsertMany", "Insertion des valeurs dans la table association '" . $parser->getJoinTable() . "'");
             }
         }
     }
 }