Example #1
0
 public function run()
 {
     $email = $_POST["email"];
     $loginRegister = isset($_POST["loginRegister"]) && $_POST["loginRegister"] ? true : null;
     $res = Citoyen::login($email, $_POST["pwd"], $loginRegister);
     if (isset($_POST["app"])) {
         $res = array_merge($res, Citoyen::applicationRegistered($_POST["app"], $email));
     }
     Rest::json($res);
     Yii::app()->end();
 }
Example #2
0
 public function run()
 {
     $email = $_POST["email"];
     if (Yii::app()->request->isAjaxRequest) {
         //if exists login else create the new user
         $res = Citoyen::register($email, $_POST["pwd"]);
         //   if($res['result'])
         if (Yii::app()->mongodb->citoyens->findOne(array("email" => $email))) {
             $res .= "email found, ";
             $newInfos = array();
             if (isset($_POST['cp'])) {
                 $newInfos['cp'] = $_POST['cp'];
             }
             if (isset($_POST['name'])) {
                 $newInfos['name'] = $_POST['name'];
             }
             if (isset($_POST['tags'])) {
                 $newInfos['tags'] = explode(",", $_POST['tags']);
             }
             if (isset($_POST['geo'])) {
                 $newInfos['geo'] = $_POST['geo'];
             }
             //specific application routines
             if (isset($_POST["app"])) {
                 $appKey = $_POST["app"];
                 //when registration is done for an application it must be registered
                 $newInfos['applications'] = array($appKey => array("usertype" => isset($_POST['type']) ? $_POST['type'] : $_POST['app']));
                 $app = Yii::app()->mongodb->applications->findOne(array("key" => $appKey));
                 //check for application specifics defined in DBs application entry
                 if (isset($app["registration"]) && $app["registration"] == "mustBeConfirmed") {
                     $newInfos['applications'][$appKey]["registrationConfirmed"] = false;
                 }
             }
             Yii::app()->mongodb->citoyens->update(array("email" => $email), array('$set' => $newInfos));
             $res .= "proc end";
         }
     } else {
         $res = array('result' => false, 'msg' => 'something somewhere went terribly wrong');
     }
     Rest::json($res);
     Yii::app()->end();
 }
Example #3
0
 public function run()
 {
     //check if invited user exists
     if (isset($_POST["email"]) && preg_match('#^[\\w.-]+@[\\w.-]+\\.[a-zA-Z]{2,6}$#', $_POST["email"])) {
         if ($user = Yii::app()->mongodb->citoyens->findOne(array("email" => $_POST["email"]))) {
             $res = array('userAllreadyExists' => true);
             if (Yii::app()->session["userId"]) {
                 $res["link2Users_Call"] = Citoyen::link2Users((string) Yii::app()->session["userId"], (string) $user["_id"]);
             } else {
                 $res["invitedButNotLinked"] = "noUserLogguedin";
             }
         } else {
             $res = Citoyen::inviteUser($_POST["email"]);
         }
     } else {
         $res = array("result" => false, "msg" => "bad or no email");
     }
     Rest::json($res);
     Yii::app()->end();
 }
Example #4
0
                    <h2>Entreprises</h2>
                    <ul>
                        <?php 
$pa = Yii::app()->mongodb->groups->find(array("type" => PHType::TYPE_ENTREPRISE));
foreach ($pa as $e) {
    ?>
                            <li class="group"><a href="<?php 
    echo Yii::app()->createUrl('index.php/entreprise/view/id/' . $e["_id"]);
    ?>
"><?php 
    echo $e["name"];
    ?>
</a>
                            <?php 
    echo Citoyen::isAdminUser() ? '<a href="#' . $e["_id"] . '" class="updateBtn pull-right"><span class="icon-pencil"></span></a>' : "";
    echo Citoyen::isAdminUser() ? '<a href="#' . $e["_id"] . '" class="delBtn pull-right"><span class="icon-cancel"></span></a>' : "";
    ?>
                            </li>
                            <?php 
}
?>
                    </ul>
                </div>
                
                <div class='col-md-6'>
                    <h2>Applications</h2>
                    <ul>
                        <?php 
$me = Yii::app()->mongodb->citoyens->findOne(array("_id" => new MongoId(Yii::app()->session["userId"])));
if (isset($me["applications"])) {
    foreach ($me["applications"] as $k => $v) {
Example #5
0
 public function run()
 {
     $res = Citoyen::communect($_POST["email"], $_POST["cp"]);
     Rest::json($res);
     Yii::app()->end();
 }
Example #6
0
 public static function inviteUser($invitedEmail)
 {
     //check email is valid
     if (preg_match('#^[\\w.-]+@[\\w.-]+\\.[a-zA-Z]{2,6}$#', $invitedEmail)) {
         $res = Citoyen::createUser($invitedEmail);
         //link both users together
         if (Yii::app()->session["userId"]) {
             $res["link2Users_Call"] = Citoyen::link2Users((string) Yii::app()->session["userId"], (string) $res["id"]);
         }
     } else {
         $res = array("result" => false, "msg" => "submited email is not valid");
     }
     return $res;
 }
Example #7
0
 public function run()
 {
     $email = $_POST["email"];
     if (Yii::app()->request->isAjaxRequest) {
         //if exists login else create the new user
         $pwd = isset($_POST["pwd"]) ? $_POST["pwd"] : null;
         if ($user = PHDB::findOne(PHType::TYPE_CITOYEN, array("email" => $email))) {
             $res = array('result' => false, 'msg' => 'Email non valid');
         } else {
             $res = Citoyen::register($email, $pwd);
         }
         $newInfos = array();
         if ($user = PHDB::findOne(PHType::TYPE_CITOYEN, array("email" => $email))) {
             $pos = array();
             //udate the new app specific fields
             if (isset($_POST["position"])) {
                 $positionObj = array();
                 if (is_array($_POST["position"])) {
                     for ($i = 0; $i < count($_POST["position"]); $i++) {
                         if ($_POST["position"][$i] != "") {
                             array_push($positionObj, $_POST["position"][$i]);
                         }
                     }
                 } else {
                     $positionObj = $_POST["position"];
                 }
                 $newInfos["positions"] = $positionObj;
             }
             if (isset($_POST['supervisor'])) {
                 $newInfos['supervisor'] = $_POST['supervisor'];
             }
             if (isset($_POST['cp'])) {
                 $newInfos['cp'] = $_POST['cp'];
             }
             if (isset($_POST['tel'])) {
                 $newInfos['phoneNumber'] = $_POST['tel'];
             }
             if (isset($_POST['url'])) {
                 $newInfos['url'] = $_POST['url'];
             }
             if (isset($_POST['skype'])) {
                 $newInfos['skype'] = $_POST['skype'];
             }
             if (isset($_POST['birth'])) {
                 $newInfos['birth'] = $_POST['birth'];
             }
             if (isset($_POST['name'])) {
                 $newInfos['name'] = $_POST['name'];
                 Yii::app()->session["user"] = array("name" => $_POST['name']);
             }
             if (isset($_POST['city'])) {
                 $newInfos['city'] = $_POST['city'];
             }
             if (isset($_POST['imagePath'])) {
                 $newInfos['imagePath'] = $_POST['imagePath'];
             }
             if (isset($_POST['cp'])) {
                 $newInfos["cp"] = $_POST['cp'];
                 $newInfos["address"] = array("@type" => "PostalAddress", "postalCode" => $_POST['cp']);
             }
             if (isset($_POST['country'])) {
                 $newInfos["address"]["addressLocality"] = $_POST['country'];
             }
             if (isset($_POST['tags'])) {
                 if ($_POST['tags'] != "") {
                     $tabTags = explode(",", $_POST['tags']);
                     $newInfos["tags"] = $tabTags;
                     $tagsList = PHDB::findOne(PHType::TYPE_LISTS, array("name" => "tags"), array('list'));
                     foreach (explode(",", $_POST['tags']) as $tag) {
                         if (!in_array($tag, $tagsList['list'])) {
                             PHDB::update(PHType::TYPE_LISTS, array("name" => "tags"), array('$push' => array("list" => $tag)));
                         }
                     }
                     $newInfos["tags"] = explode(",", $_POST['tags']);
                 } else {
                     $newInfos["tags"] = $_POST['tags'];
                 }
             }
             if (isset($_FILES['avatar'])) {
                 $pathImage = $this->processImage($_FILES['avatar'], $user["_id"]["{$id}"]);
                 if ($pathImage) {
                     $newInfos["imagePath"] = $pathImage;
                 }
             }
             //specific application routines
             if (isset($_POST["app"])) {
                 $appKey = $_POST["app"];
                 //when registration is done for an application it must be registered
                 $newInfos['applications'] = array($appKey => array("usertype" => isset($_POST['type']) ? $_POST['type'] : $_POST['app']));
                 $app = PHDB::findOne(PHType::TYPE_APPLICATIONS, array("key" => $appKey));
                 //check for application specifics defined in DBs application entry
                 if (isset($app["registration"])) {
                     if ($app["registration"] == "mustBeConfirmed") {
                         $newInfos['applications'][$appKey]["registrationConfirmed"] = false;
                     } else {
                         if ($app["registration"] == "mailValidation") {
                             Yii::app()->session["userId"] = $user["_id"];
                             Yii::app()->session["userEmail"] = null;
                             //send validation mail
                             //TODO : make emails as cron jobs
                             $title = $app["name"];
                             $logo = isset($app["logo"]) ? $this->module->assetsUrl . $app["logo"] : Yii::app()->getRequest()->getBaseUrl(true) . '/images/logo/logo144.png';
                             Mail::send(array("tpl" => 'validation', "subject" => 'Confirmer votre compte ' . $title, "from" => Yii::app()->params['adminEmail'], "to" => $email, "tplParams" => array("user" => $user["_id"], "title" => $title, "logo" => $logo)));
                         }
                     }
                 }
             }
             //Social Network info
             $socialNetwork = array();
             if (isset($_POST["twitterAccount"])) {
                 $socialNetwork["twitterAccount"] = $_POST["twitterAccount"];
             }
             if (isset($_POST["facebookAccount"])) {
                 $socialNetwork["facebookAccount"] = $_POST["facebookAccount"];
             }
             if (isset($_POST["gplusAccount"])) {
                 $socialNetwork["gplusAccount"] = $_POST["gplusAccount"];
             }
             if (isset($_POST["gitHubAccount"])) {
                 $socialNetwork["gitHubAccount"] = $_POST["gitHubAccount"];
             }
             if (isset($_POST["linkedInAccount"])) {
                 $socialNetwork["linkedInAccount"] = $_POST["linkedInAccount"];
             }
             if (isset($_POST["skypeAccount"])) {
                 $socialNetwork["skypeAccount"] = $_POST["skypeAccount"];
             }
             $newInfos["socialNetwork"] = $socialNetwork;
             $res = PHDB::update(PHType::TYPE_CITOYEN, array("email" => $email), array('$set' => $newInfos));
             //$res = array('result' => true , 'msg'=>'update profile succesfully');
         }
     } else {
         $res = array('result' => false, 'msg' => 'something somewhere went terribly wrong');
     }
     Rest::json($res);
     Yii::app()->end();
 }
Example #8
0
	      
	      var currIndex = $(this).index('.acc-btn'),
	          targetHeight = $('.acc-content-inner').eq(currIndex).outerHeight();
	   
	      $('.acc-btn h1').removeClass('selected');
	      $(this).find('h1').addClass('selected');
	      
	      $('.acc-content').stop().animate({ height: 0 }, animTime);
	      $('.acc-content').eq(currIndex).stop().animate({ height: targetHeight }, animTime);

	      setTimeout(function(){ clickPolice = false; }, animTime);
	    }
	    
	  });
	  <?php 
if (Citoyen::isAdminUser()) {
    ?>
	  $(document).on('touchstart click', '.delBtn', function(event){
		  event.preventDefault();
		  toggleSpinner();
		  $( "."+this.hash.substr(1) ).remove();
		  $.ajax({
	    	  type: "POST",
	    	  url: baseUrl+"/index.php/data/delete",
	    	  data: {"id":this.hash.substr(1)},
	    	  success: function(data){
	    			  $("#flashInfo .modal-body").html(data.msg);
	    			  toggleSpinner();
	    		  	  $("#flashInfo").modal('show');
	    	  },
	    	  dataType: "json"
Example #9
0
    	<?php 
if (!isset(Yii::app()->session["userId"])) {
    ?>
        <div class="pull-left homestead blueDark center" style="width:45%;border:1px color red;">
        	<span class="icon-vcard blue" style="font-size:300%"></span><br/><br/>
        	<h1> Adhérer </h1>
        	<div>
        	C'est se communecter, être connecté à sa commune ( mail, code postal).
        	<br/>Ainsi vous adhérez au projet et donnez plus de poids à votre communauté locale.
        	</div>
        	<br/>
        	<a class=" btn-warning btn-large homestead" href="#loginForm"  role="button" data-toggle="modal"> Je souhaite adhérer </a>
        </div>
        <?php 
} else {
    if (!($userCp = Citoyen::isCommunected())) {
        ?>
        <div class="pull-left homestead blueDark center" style="width:45%;border:1px color red;">
        	<span class="icon-vcard blue" style="font-size:300%"></span><br/><br/>
        	<h1> Inscrit <span style="text-decoration:line-through">communecté </span></h1>
        	<div>
        	se communecter, c'est être connecté à sa commune, avec un simple code postal
        	</div>
        	<br/>
        	<a class=" btn-warning btn-large homestead" href="#participer"  role="button" data-toggle="modal"> Communectez vous </a>
        </div>
        <?php 
    } else {
        ?>
        	<div class="pull-left homestead blueDark center" style="width:45%;border:1px color red;">
        	<span class="icon-vcard blue" style="font-size:300%"></span><br/><br/>
Example #10
0
 public function run()
 {
     $res = Citoyen::getPeopleBy($_POST);
     Rest::json($res);
     Yii::app()->end();
 }