Beispiel #1
0
 public static function insertJob($job)
 {
     foreach ($job as $jobFieldName => $jobFieldValue) {
         if (!Job::checkFieldBeforeUpdate($jobFieldName, $jobFieldValue)) {
             throw new CTKException(Yii::t("job", "Can not insert the job : unknown field ") . $jobFieldName);
         }
     }
     //Manage tags : save any inexistant tag to DB
     if (isset($job["tags"])) {
         $job["tags"] = Tags::filterAndSaveNewTags($job["tags"]);
     }
     //Manage address
     if (isset($job["jobLocation.address"])) {
         if (!empty($job["jobLocation.address"]["postalCode"]) && !empty($job["jobLocation.address"]["codeInsee"])) {
             $insee = $job["jobLocation.address"]["codeInsee"];
             $address = SIG::getAdressSchemaLikeByCodeInsee($insee);
             $job["jobLocation.address"] = $address;
             $job["geo"] = SIG::getGeoPositionByInseeCode($insee);
         }
     }
     //Insert the job
     $result = PHDB::updateWithOptions(Job::COLLECTION, array("_id" => new MongoId()), array('$set' => $job), array("upsert" => true));
     //Trick for windows : the upserted does not have the same return value
     if (isset($result["upserted"])) {
         if (is_array($result["upserted"])) {
             $newJobId = (string) $result["upserted"][0]["_id"];
         } else {
             $newJobId = (string) $result["upserted"];
         }
         $job = Job::getById($newJobId);
     } else {
         throw new CTKException(Yii::t("job", "Problem inserting the new job offer"));
     }
     return array("result" => true, "msg" => Yii::t("job", "Your job offer has been added with succes"), "id" => $newJobId, "job" => $job);
 }
Beispiel #2
0
 public static function addWorkLog($project, $userEmail, $controller, $action)
 {
     if (stripos($_SERVER['SERVER_NAME'], "127.0.0.1") >= 0 || stripos($_SERVER['SERVER_NAME'], "localhost:8080") >= 0) {
         $lastUpdate = PHDB::findOne("cornerDev", array("project" => $project, "person" => $userEmail, "controller" => $controller, "action" => $action, "type" => self::ACTION_WORKLOG, "date" => date("d/m/y")));
         $timespend = 0;
         if ($lastUpdate) {
             $timespend = time() - $lastUpdate["lastUpdate"];
             //if($timespend > ) //seesion closer , maybe should be a button
             $timespend = ($timespend + $lastUpdate["timespend"] * 60) / 60;
         }
         $entry = array("project" => $project, "person" => $userEmail, "controller" => $controller, "action" => $action, "date" => date("d/m/y"), "timespend" => $timespend, "lastUpdate" => time());
         PHDB::updateWithOptions("cornerDev", array("project" => $project, "person" => $userEmail, "controller" => $controller, "action" => $action, "date" => date("d/m/y"), "type" => self::ACTION_WORKLOG), array('$set' => $entry), array("upsert" => true));
         PHDB::insert("cornerLog", array("project" => $project, "person" => $userEmail, "controller" => $controller, "action" => $action, "timestamp" => time(), "type" => self::ACTION_WORKLOG));
     }
 }