Exemplo n.º 1
0
 public static function updateJob($jobId, $job, $userId)
 {
     if (!Authorisation::isJobAdmin($jobId, $userId)) {
         throw new CTKException(Yii::t("job", "Can not update the job : you are not authorized to update that job offer !"));
     }
     foreach ($job as $jobFieldName => $jobFieldValue) {
         if (!Job::checkFieldBeforeUpdate($jobFieldName, $jobFieldValue)) {
             throw new CTKException(Yii::t("job", "Can not insert the job : unknown field ") . $jobFieldName);
         }
         //address
         if ($jobFieldName == "jobLocation.address") {
             if (!empty($jobFieldValue["postalCode"]) && !empty($jobFieldValue["codeInsee"])) {
                 $insee = $jobFieldValue["codeInsee"];
                 $address = SIG::getAdressSchemaLikeByCodeInsee($insee);
                 $job["jobLocation"] = array("address" => $address);
                 $job["geo"] = getGeoPositionByInseeCode($insee);
             } else {
                 throw new CTKException(Yii::t("job", "Error updating the Organization : address is not well formated !"));
             }
             unset($job[$jobFieldName]);
         } else {
             $job[$jobFieldName] = $jobFieldValue;
         }
     }
     //Manage tags : save any inexistant tag to DB
     if (isset($job["tags"])) {
         $job["tags"] = Tags::filterAndSaveNewTags($job["tags"]);
     }
     //update the job
     PHDB::update(Job::COLLECTION, array("_id" => new MongoId($jobId)), array('$set' => $job));
     return array("result" => true, "msg" => Yii::t("job", "Your job offer has been updated with success"), "id" => $jobId);
 }
 public function run()
 {
     $whereGeo = SIG::getGeoQuery($_POST, 'geo');
     $where = array();
     //'cp' => array( '$exists' => true ));
     $where = array_merge($where, $whereGeo);
     $citoyens = PHDB::find(PHType::TYPE_CITOYEN, $where);
     $citoyens["origine"] = "ShowMyNetwork";
     Rest::json($citoyens);
     Yii::app()->end();
 }
 public function run()
 {
     $errorMessage = array(array("value" => "", "text" => Yii::t("openData", "Unknown Postal Code")));
     $cities = array();
     $postalCode = isset($_POST["postalCode"]) ? $_POST["postalCode"] : null;
     try {
         $cities = SIG::getCitiesByPostalCode($postalCode);
     } catch (CTKException $e) {
         $cities = array("unknownId" => array("name" => Yii::t("openData", "Unknown Postal Code"), "insee" => ""));
     }
     Rest::json($cities);
     Yii::app()->end();
 }
 public function run()
 {
     $where = array('_id' => new MongoId(Yii::app()->session["userId"]));
     $user = PHDB::find(PHType::TYPE_CITOYEN, $where);
     //si l'utilisateur connecté n'a pas enregistré sa position geo
     //on prend la position de son CP
     foreach ($user as $me) {
         if (!isset($me["geo"]) && isset($me["cp"])) {
             $res = array(Yii::app()->session["userId"] => SIG::getGeoPositionByCp($me["cp"]));
             Rest::json($res);
             Yii::app()->end();
         }
     }
     Rest::json($user);
     Yii::app()->end();
 }
Exemplo n.º 5
0
<?php 
SIG::clientScripts();
?>

<div class="apiForm createNews">
					
	<div id="mapCanvasNewsStream" class="mapCanvas1">
		<br/>Chargement de la carte ...
	</div>	
	
	<div style="width:300px; float:left;">
		<b>Tags</b> : <input type="text" name="tagsStreamNews" id="tagsSaveNews" value="<?php 
echo $this->module->id;
?>
 Tags" /><br/>
		<b>Nature :</b>
		<select id="natureStreamNews">
			<?php 
$natures = array("free_msg", "help", "idea", "proposition", "rumor", "true_information", "question");
foreach ($natures as $value) {
    echo '<option value="' . $value . '">' . $value . '</option>';
}
?>
		
		</select></br>
		
<!-- 	Activer / Désactiver la reception des messages postés pour CP ou DEPARTEMENT ?

		<input type="checkbox" class="radioScope" name="scopeNewsStream" id="chkBoxCp" value="cp" checked> Mon code postal<br>
		<input type="checkbox" class="radioScope" name="scopeNewsStream" id="chkBoxDep" value="departement" checked>Mon département<br>
Exemplo n.º 6
0
 /**
  * Update a project field value
  * @param String $projectId The person Id to update
  * @param String $projectFieldName The name of the field to update
  * @param String $projectFieldValue 
  * @param String $isAdmin or $isModerate (including after)
  * @return boolean True if the update has been done correctly. Can throw CTKException on error.
  */
 public static function updateProjectField($projectId, $projectFieldName, $projectFieldValue, $userId)
 {
     if (!Authorisation::canEditItem($userId, self::COLLECTION, $projectId)) {
         throw new CTKException(Yii::t("project", "Can not update this project : you are not authorized to update that project !"));
     }
     $dataFieldName = self::getCollectionFieldNameAndValidate($projectFieldName, $projectFieldValue, $projectId);
     //Specific case :
     //Tags
     if ($dataFieldName == "tags") {
         $projectFieldValue = Tags::filterAndSaveNewTags($projectFieldValue);
     }
     //address
     if ($dataFieldName == "address") {
         if (!empty($projectFieldValue["postalCode"]) && !empty($projectFieldValue["codeInsee"])) {
             $insee = $projectFieldValue["codeInsee"];
             $address = SIG::getAdressSchemaLikeByCodeInsee($insee);
             $set = array("address" => $address, "geo" => SIG::getGeoPositionByInseeCode($insee));
         } else {
             throw new CTKException("Error updating the Project : address is not well formated !");
         }
         //Start Date - End Date
     } else {
         if ($dataFieldName == "startDate" || $dataFieldName == "endDate") {
             date_default_timezone_set('UTC');
             $dt = DateTime::createFromFormat('Y-m-d H:i', $projectFieldValue);
             if (empty($dt)) {
                 $dt = DateTime::createFromFormat('Y-m-d', $projectFieldValue);
             }
             $newMongoDate = new MongoDate($dt->getTimestamp());
             $set = array($dataFieldName => $newMongoDate);
         } else {
             $set = array($dataFieldName => $projectFieldValue);
         }
     }
     //update the project
     PHDB::update(self::COLLECTION, array("_id" => new MongoId($projectId)), array('$set' => $set));
     return array("result" => true, "msg" => "Votre projet a été modifié avec succes", "id" => $projectId);
 }
Exemplo n.º 7
0
 /**
  * Update an organization field value
  * @param String $organisationId The organization Id to update
  * @param String $organizationFieldName The name of the field to update
  * @param String $organizationFieldValue 
  * @param String $userId 
  * @return boolean True if the update has been done correctly. Can throw CTKException on error.
  */
 public static function updateOrganizationField($organizationId, $organizationFieldName, $organizationFieldValue, $userId)
 {
     if (!Authorisation::isOrganizationAdmin($userId, $organizationId)) {
         throw new CTKException(Yii::t("organisation", "Can not update this organization : you are not authorized to update that organization !"));
     }
     $dataFieldName = Organization::getCollectionFieldNameAndValidate($organizationFieldName, $organizationFieldValue);
     //Specific case :
     //Tags
     if ($dataFieldName == "tags") {
         $organizationFieldValue = Tags::filterAndSaveNewTags($organizationFieldValue);
     }
     //address
     if ($dataFieldName == "address") {
         if (!empty($organizationFieldValue["postalCode"]) && !empty($organizationFieldValue["codeInsee"])) {
             $insee = $organizationFieldValue["codeInsee"];
             $address = SIG::getAdressSchemaLikeByCodeInsee($insee);
             $set = array("address" => $address, "geo" => SIG::getGeoPositionByInseeCode($insee));
         } else {
             throw new CTKException("Error updating the Organization : address is not well formated !");
         }
     } else {
         $set = array($dataFieldName => $organizationFieldValue);
     }
     //update the organization
     PHDB::update(Organization::COLLECTION, array("_id" => new MongoId($organizationId)), array('$set' => $set));
     return true;
 }
Exemplo n.º 8
0
 /**
  * Update a person field value
  * @param String $personId The person Id to update
  * @param String $personFieldName The name of the field to update
  * @param String $personFieldValue 
  * @param String $userId 
  * @return boolean True if the update has been done correctly. Can throw CTKException on error.
  */
 public static function updatePersonField($personId, $personFieldName, $personFieldValue, $userId)
 {
     if ($personId != $userId) {
         throw new CTKException("Can not update the person : you are not authorized to update that person !");
     }
     $dataFieldName = Person::getCollectionFieldNameAndValidate($personFieldName, $personFieldValue);
     //Specific case :
     //Tags
     if ($dataFieldName == "tags") {
         $personFieldValue = Tags::filterAndSaveNewTags($personFieldValue);
     }
     //address
     if ($dataFieldName == "address") {
         if (!empty($personFieldValue["postalCode"]) && !empty($personFieldValue["codeInsee"])) {
             $insee = $personFieldValue["codeInsee"];
             $address = SIG::getAdressSchemaLikeByCodeInsee($insee);
             $set = array("address" => $address, "geo" => SIG::getGeoPositionByInseeCode($insee));
         } else {
             throw new CTKException("Error updating the Person : address is not well formated !");
         }
     } else {
         if ($dataFieldName == "birthDate") {
             date_default_timezone_set('UTC');
             $dt = DateTime::createFromFormat('Y-m-d H:i', $personFieldValue);
             if (empty($dt)) {
                 $dt = DateTime::createFromFormat('Y-m-d', $personFieldValue);
             }
             $newMongoDate = new MongoDate($dt->getTimestamp());
             $set = array($dataFieldName => $newMongoDate);
         } else {
             $set = array($dataFieldName => $personFieldValue);
         }
     }
     //update the person
     PHDB::update(self::COLLECTION, array("_id" => new MongoId($personId)), array('$set' => $set));
     return true;
 }
Exemplo n.º 9
0
Arquivo: sig.php Projeto: prggmr/xpspl
 /**
  * Compare if the given ``$sig`` is identical to this.
  *
  * @param  object  $sig  SIG to compare.
  *
  * @return  boolean
  */
 public function compare(SIG $sig)
 {
     return $sig->get_index() === $this->_index;
 }
Exemplo n.º 10
0
 public static function updateEventField($eventId, $eventFieldName, $eventFieldValue, $userId)
 {
     if (!Authorisation::isEventAdmin($eventId, $userId)) {
         throw new CTKException("Can not update the event : you are not authorized to update that event!");
     }
     $dataFieldName = self::getCollectionFieldNameAndValidate($eventFieldName, $eventFieldValue, $eventId);
     //address
     if ($eventFieldName == "address") {
         if (!empty($eventFieldValue["postalCode"]) && !empty($eventFieldValue["codeInsee"])) {
             $insee = $eventFieldValue["codeInsee"];
             $address = SIG::getAdressSchemaLikeByCodeInsee($insee);
             $set = array("address" => $address, "geo" => SIG::getGeoPositionByInseeCode($insee));
         } else {
             throw new CTKException("Error updating the Event : address is not well formated !");
         }
         //Date format
     } else {
         if ($dataFieldName == "startDate" || $dataFieldName == "endDate") {
             date_default_timezone_set('UTC');
             $dt = DateTime::createFromFormat('Y-m-d H:i', $eventFieldValue);
             if (empty($dt)) {
                 $dt = DateTime::createFromFormat('Y-m-d', $eventFieldValue);
             }
             $newMongoDate = new MongoDate($dt->getTimestamp());
             $set = array($dataFieldName => $newMongoDate);
         } else {
             $set = array($dataFieldName => $eventFieldValue);
         }
     }
     $res = Event::updateEvent($eventId, $set, $userId);
     return $res;
 }