コード例 #1
0
 public function run($id)
 {
     $controller = $this->getController();
     //get The job Id
     if (empty($id)) {
         throw new CTKException(Yii::t("job", "The job posting id is mandatory to retrieve the job posting !"));
     }
     if (empty($_POST["mode"])) {
         $mode = "view";
     } else {
         $mode = $_POST["mode"];
     }
     if ($mode == "insert") {
         $job = array();
         $controller->title = Yii::t("job", "New Job Offer");
         $controller->subTitle = Yii::t("job", "Fill the form");
     } else {
         $job = Job::getById($id);
         $controller->title = $job["title"];
         $controller->subTitle = isset($job["description"]) ? $job["description"] : (isset($job["type"]) ? "Type " . $job["type"] : "");
     }
     $tags = json_encode(Tags::getActiveTags());
     $organizations = Authorisation::listUserOrganizationAdmin(Yii::app()->session["userId"]);
     $controller->pageTitle = Yii::t("job", "Job Posting");
     Rest::json(array("result" => true, "content" => $controller->renderPartial("jobSV", array("job" => $job, "tags" => $tags, "organizations" => $organizations, "mode" => $mode), true)));
 }
コード例 #2
0
 public function run()
 {
     //récupère seulement les citoyens qui ont un nom et une position géo
     $users = PHDB::find(PHType::TYPE_CITOYEN);
     Rest::json($users);
     Yii::app()->end();
 }
コード例 #3
0
 public function run($name)
 {
     if ($name) {
         $list = Lists::getListByName($name);
     }
     Rest::json(array("result" => true, "list" => $list));
 }
コード例 #4
0
 public function run($type, $id, $contentKey = null, $user)
 {
     if (isset($_FILES['avatar'])) {
         $type = trim($type);
         $folder = str_replace(DIRECTORY_SEPARATOR, "/", DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $id . DIRECTORY_SEPARATOR);
         $pathImage = $this->processImage($_FILES['avatar'], $id, $type);
         if ($pathImage) {
             $params = array();
             $params["id"] = $id;
             $params["type"] = $type;
             $params['folder'] = $folder;
             $params['moduleId'] = Yii::app()->controller->module->id;
             $params['name'] = $pathImage["name"];
             $params['doctype'] = "image";
             $params['size'] = $pathImage["size"][0] * $pathImage["size"][1] / 1000;
             $params['author'] = $user;
             $params['category'] = array();
             $params['contentKey'] = $contentKey;
             $result = Document::save($params);
             //Profile to check
             $urlBdd = str_replace(DIRECTORY_SEPARATOR, "/", DIRECTORY_SEPARATOR . "upload" . DIRECTORY_SEPARATOR . Yii::app()->controller->module->id . $folder . $pathImage["name"]);
             Document::setImagePath($id, $type, $urlBdd, $contentKey);
             $newImage = Document::getById($result["id"]);
         }
         $res = array('result' => true, 'msg' => 'The picture was uploaded', 'imagePath' => $urlBdd, "id" => $result["id"], "image" => $newImage);
         Rest::json($res);
         Yii::app()->end();
     }
 }
コード例 #5
0
 public function run()
 {
     $whereGeo = array();
     //$this->getGeoQuery($_POST);
     $where = array('geo' => array('$exists' => true));
     $where = array_merge($where, $whereGeo);
     $events = PHDB::find(PHType::TYPE_EVENTS, $where);
     foreach ($events as $event) {
         //dans le cas où un événement n'a pas de position geo,
         //on lui ajoute grace au CP
         //il sera visible sur la carte au prochain rechargement
         if (!isset($event["geo"])) {
             $cp = $event["location"]["address"]["addressLocality"];
             $queryCity = array("cp" => strval(intval($cp)), "geo" => array('$exists' => true));
             $city = Yii::app()->mongodb->cities->findOne($queryCity);
             //->limit(1)
             if ($city != null) {
                 $newPos = array('geo' => array("@type" => "GeoCoordinates", "longitude" => floatval($city['geo']['coordinates'][0]), "latitude" => floatval($city['geo']['coordinates'][1])), 'geoPosition' => $city['geo']);
                 Yii::app()->mongodb->events->update(array("_id" => $event["_id"]), array('$set' => $newPos));
             }
         }
     }
     $events["origine"] = "ShowLocalEvents";
     Rest::json($events);
     Yii::app()->end();
 }
コード例 #6
0
 public function actionClearInitDataPeopleAll()
 {
     //inject Data brute d'une liste de Person avec Id
     $import = Admin::initMultipleModuleData($this->module->id, "personNetworkingAll", true, true, true);
     Rest::json($import);
     Yii::app()->end();
 }
コード例 #7
0
 public function run()
 {
     $events = array();
     $organization = Organization::getPublicData($id);
     if (isset($organization["links"]["events"])) {
         foreach ($organization["links"]["events"] as $key => $value) {
             $event = Event::getPublicData($key);
             $events[$key] = $event;
         }
     }
     foreach ($organization["links"]["members"] as $newId => $e) {
         if ($e["type"] == Organization::COLLECTION) {
             $member = Organization::getPublicData($newId);
         } else {
             $member = Person::getPublicData($newId);
         }
         if (isset($member["links"]["events"])) {
             foreach ($member["links"]["events"] as $key => $value) {
                 $event = Event::getPublicData($key);
                 $events[$key] = $event;
             }
         }
     }
     Rest::json($events);
 }
コード例 #8
0
 public function run($eventId)
 {
     if (isset(Yii::app()->session["userId"])) {
         Event::delete($eventId, Yii::app()->session["userId"]);
     }
     Rest::json(array('result' => true, "msg" => Yii::t("event", "Event removed")));
 }
コード例 #9
0
 /**
  * Save a job
  * @return an array with result and message json encoded
  */
 public function run()
 {
     $controller = $this->getController();
     //insert a new job
     if (empty($_POST["pk"])) {
         foreach ($_POST as $fieldName => $fieldValue) {
             $collectionName = $controller->getCollectionFieldName($fieldName);
             $job[$collectionName] = $fieldValue;
         }
         $res = Job::insertJob($job);
         if ($res["result"]) {
             return Rest::json(array("msg" => "insertion ok ", "id" => $res["id"], "job" => $res["job"]));
         }
         //update an existing job
     } else {
         $jobId = $_POST["pk"];
         if (!empty($_POST["name"]) && !empty($_POST["value"])) {
             $jobFieldName = $_POST["name"];
             $jobFieldValue = $_POST["value"];
             $collectionName = $controller->getCollectionFieldName($jobFieldName);
             Job::updateJobField($jobId, $collectionName, $jobFieldValue, Yii::app()->session["userId"]);
         } else {
             return Rest::json(array("result" => false, "msg" => Yii::t("common", "Uncorrect request")));
         }
     }
     return Rest::json(array("result" => true, "msg" => Yii::t("job", "Your job offer has been updated with success"), $jobFieldName => $jobFieldValue));
 }
コード例 #10
0
 /**
  * Update an information field for an organization
  */
 public function run()
 {
     $organizationId = "";
     $res = array("result" => false, "msg" => Yii::t("common", "Something went wrong!"));
     if (!empty($_POST["pk"])) {
         $organizationId = $_POST["pk"];
     } else {
         if (!empty($_POST["id"])) {
             $organizationId = $_POST["id"];
         }
     }
     if ($organizationId != "") {
         if (!empty($_POST["name"]) && !empty($_POST["value"])) {
             $organizationFieldName = $_POST["name"];
             $organizationFieldValue = $_POST["value"];
             try {
                 Organization::updateOrganizationField($organizationId, $organizationFieldName, $organizationFieldValue, Yii::app()->session["userId"]);
                 $res = array("result" => true, "msg" => Yii::t("organisation", "The organization has been updated"), $organizationFieldName => $organizationFieldValue);
             } catch (CTKException $e) {
                 $res = array("result" => false, "msg" => $e->getMessage(), $organizationFieldName => $organizationFieldValue);
             }
         }
     }
     Rest::json($res);
 }
コード例 #11
0
ファイル: SaveAction.php プロジェクト: Koulio/pixelhumain
 public function run()
 {
     $res = array();
     if (Yii::app()->session["userId"]) {
         $email = $_POST["email"];
         $name = $_POST['name'];
         //if exists login else create the new user
         if (PHDB::findOne(PHType::TYPE_CITOYEN, array("email" => $email))) {
             //udate the new app specific fields
             $newInfos = array();
             $newInfos['email'] = (string) $email;
             $newInfos['name'] = (string) $name;
             if (isset($_POST['survey'])) {
                 $newInfos['survey'] = $_POST['survey'];
             }
             if (isset($_POST['message'])) {
                 $newInfos['message'] = (string) $_POST['message'];
             }
             if (isset($_POST['type'])) {
                 $newInfos['type'] = $_POST['type'];
             }
             if (isset($_POST['tags']) && !empty($_POST['tags'])) {
                 $newInfos['tags'] = explode(",", $_POST['tags']);
             }
             if (isset($_POST['cp'])) {
                 $newInfos['cp'] = explode(",", $_POST['cp']);
             }
             if (isset($_POST['urls'])) {
                 $newInfos['urls'] = $_POST['urls'];
             }
             $newInfos['created'] = time();
             //specific application routines
             if (isset($_POST["app"])) {
                 $appKey = $_POST["app"];
                 if ($app = PHDB::findOne(PHType::TYPE_APPLICATIONS, array("key" => $appKey))) {
                     //when registration is done for an application it must be registered
                     $newInfos['applications'] = array($appKey => array("usertype" => isset($_POST['type']) ? $_POST['type'] : $_POST['app']));
                     //check for application specifics defined in DBs application entry
                     if (isset($app["moderation"])) {
                         $newInfos['applications'][$appKey][SurveyType::STATUS_CLEARED] = false;
                         //TODO : set a Notification for admin moderation
                     }
                     $res['applicationExist'] = true;
                 } else {
                     $res['applicationExist'] = false;
                 }
             }
             PHDB::update(PHType::TYPE_PROJECTS, array("name" => $name), array('$set' => $newInfos), array('upsert' => true));
             $res['result'] = true;
             $res['msg'] = $this->id . "Saved";
         } else {
             $res = array('result' => false, 'msg' => "user doen't exist");
         }
     } else {
         $res = array('result' => false, 'msg' => 'something somewhere went terribly wrong');
     }
     Rest::json($res);
     Yii::app()->end();
 }
コード例 #12
0
 public function run()
 {
     //TODO $res = Citoyen::addNode( "applications.".$_POST['app'].".isAdmin" ,true , $_POST['id']  );
     //TODO update application sadmin array
     $res = array('result' => true);
     Rest::json($res);
     Yii::app()->end();
 }
コード例 #13
0
 public function run()
 {
     //affiche les villes de plus de 100 000 habitants
     $query = array('habitants' => array('$gt' => 100000));
     $cities = iterator_to_array(Yii::app()->mongodb->cities->find($query));
     Rest::json($cities);
     Yii::app()->end();
 }
コード例 #14
0
 public function run($cp)
 {
     $city = Yii::app()->mongodb->cities->findOne(array("cp" => $cp));
     if ($city != null) {
         Rest::json(array('lat' => $city['geo']['latitude'], 'lng' => $city['geo']['longitude']));
     }
     Yii::app()->end();
 }
コード例 #15
0
 public function run()
 {
     $email = Yii::app()->session["userEmail"];
     $user = Yii::app()->mongodb->citoyens->findOne(array("email" => $email));
     $city = Yii::app()->mongodb->cities->findOne(array("cp" => $user['cp']));
     Rest::json(array('user' => $user, 'city' => $city));
     Yii::app()->end();
 }
コード例 #16
0
 public function run()
 {
     //récupère seulement les citoyens qui ont un code postal (et une position geo)
     $where = array('cp' => array('$exists' => true), 'geo' => array('$exists' => true), 'geo.latitude' => array('$gt' => floatval($_POST['latMinScope']), '$lt' => floatval($_POST['latMaxScope'])), 'geo.longitude' => array('$gt' => floatval($_POST['lngMinScope']), '$lt' => floatval($_POST['lngMaxScope'])));
     $users = PHDB::find(PHType::TYPE_CITOYEN, $where);
     $users["origine"] = "getCommunected";
     Rest::json($users);
     Yii::app()->end();
 }
コード例 #17
0
 public function run($email, $app)
 {
     //TODO : add a test adminUser
     //isAppAdminUser
     $user = Yii::app()->mongodb->citoyens->findAndModify(array("email" => $email), array('$set' => array("applications." . $app . ".registrationConfirmed" => true)));
     $user = Yii::app()->mongodb->citoyens->findOne(array("email" => $email));
     Rest::json($user);
     Yii::app()->end();
 }
コード例 #18
0
 /**
  * Delete an entry from the job table using the id
  */
 public function run($id)
 {
     //get The job Id
     if (empty($id)) {
         throw new CTKException(Yii::t("job", "The job posting id is mandatory to retrieve the job posting !"));
     }
     $res = Job::removeJob($id, Yii::app()->session["userId"]);
     Rest::json($res);
 }
コード例 #19
0
 public function run()
 {
     $controller = $this->getController();
     //$res = array( "result" => false , "content" => Yii::t("common", "Something went wrong!") );
     if (isset($_POST["id"])) {
         $project = isset($_POST["id"]) ? PHDB::findOne(PHType::TYPE_PROJECTS, array("_id" => new MongoId($_POST["id"]))) : null;
         if ($project) {
             if (preg_match('#^[\\w.-]+@[\\w.-]+\\.[a-zA-Z]{2,6}$#', $_POST['email'])) {
                 if ($_POST['type'] == "citoyens") {
                     $member = PHDB::findOne(PHType::TYPE_CITOYEN, array("email" => $_POST['email']));
                     $memberType = PHType::TYPE_CITOYEN;
                 } else {
                     $member = PHDB::findOne(Organization::COLLECTION, array("email" => $_POST['email']));
                     $memberType = Organization::COLLECTION;
                 }
                 if (!$member) {
                     if ($_POST['type'] == "citoyens") {
                         $member = array('name' => $_POST['name'], 'email' => $_POST['email'], 'invitedBy' => Yii::app()->session["userId"], 'tobeactivated' => true, 'created' => time());
                         $memberId = Person::createAndInvite($member);
                         $isAdmin = isset($_POST["contributorIsAdmin"]) ? $_POST["contributorIsAdmin"] : false;
                         if ($isAdmin == "1") {
                             $isAdmin = true;
                         } else {
                             $isAdmin = false;
                         }
                     } else {
                         $member = array('name' => $_POST['name'], 'email' => $_POST['email'], 'invitedBy' => Yii::app()->session["userId"], 'tobeactivated' => true, 'created' => time(), 'type' => $_POST["organizationType"]);
                         $memberId = Organization::createAndInvite($member);
                         $isAdmin = false;
                     }
                     $member["id"] = $memberId["id"];
                     Link::connect($memberId["id"], $memberType, $_POST["id"], PHType::TYPE_PROJECTS, Yii::app()->session["userId"], "projects", $isAdmin);
                     Link::connect($_POST["id"], PHType::TYPE_PROJECTS, $memberId["id"], $memberType, Yii::app()->session["userId"], "contributors", $isAdmin);
                     $res = array("result" => true, "msg" => Yii::t("common", "Your data has been saved"), "member" => $member, "reload" => true);
                 } else {
                     if (isset($project['links']["contributors"]) && isset($project['links']["contributors"][(string) $member["_id"]])) {
                         $res = array("result" => false, "content" => "member allready exists");
                     } else {
                         $isAdmin = isset($_POST["contributorIsAdmin"]) ? $_POST["contributorIsAdmin"] : false;
                         if ($isAdmin == "1") {
                             $isAdmin = true;
                         } else {
                             $isAdmin = false;
                         }
                         Link::connect($member["_id"], $memberType, $_POST["id"], PHType::TYPE_PROJECTS, Yii::app()->session["userId"], "projects", $isAdmin);
                         Link::connect($_POST["id"], PHType::TYPE_PROJECTS, $member["_id"], $memberType, Yii::app()->session["userId"], "contributors", $isAdmin);
                         $res = array("result" => true, "msg" => Yii::t("common", "Your data has been saved"), "member" => $member, "reload" => true);
                     }
                 }
             } else {
                 $res = array("result" => false, "content" => "email must be valid");
             }
         }
     }
     Rest::json($res);
 }
コード例 #20
0
 public function run()
 {
     $whereGeo = $this->getGeoQuery($_POST, 'geo');
     $where = array('type' => "company");
     $where = array_merge($where, $whereGeo);
     $companies = PHDB::find(Organization::COLLECTION, $where);
     $companies["origine"] = "ShowLocalCompanies";
     Rest::json($companies);
     Yii::app()->end();
 }
コード例 #21
0
 public function run($memberId, $memberType, $memberOfId, $memberOfType, $role)
 {
     $res = array("result" => false, "msg" => Yii::t("common", "Something went wrong!"));
     try {
         $res = Link::removeRole($memberOfId, Organization::COLLECTION, $memberId, $memberType, $role, Yii::app()->session['userId']);
     } catch (CTKException $e) {
         $res = array("result" => false, "msg" => $e->getMessage());
     }
     return Rest::json($res);
 }
コード例 #22
0
 public function run()
 {
     $res = array();
     if (Yii::app()->session["userId"]) {
         $res = ActivityStream::removeNotificationsByUser();
     } else {
         $res = array('result' => false, 'msg' => 'something somewhere went terribly wrong');
     }
     Rest::json($res);
     Yii::app()->end();
 }
コード例 #23
0
 public function run()
 {
     if (isset($_POST['email']) && isset($_POST['msg']) && isset($_POST['cp']) && isset($_POST['name']) && isset($_POST['firstname'])) {
         $app = isset($_POST['app']) ? $_POST['app'] : null;
         $res = MessageVitrine::createMessage($_POST['email'], $_POST['name'], $_POST['firstname'], $_POST['msg'], $_POST['cp'], $app);
     } else {
         $res = array('result' => false, 'msg' => 'something somewhere went terribly wrong');
     }
     Rest::json($res);
     Yii::app()->end();
 }
コード例 #24
0
 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();
 }
コード例 #25
0
ファイル: LoginAction.php プロジェクト: Koulio/pixelhumain
 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();
 }
コード例 #26
0
 public function run($contributorId, $contributorType, $projectId)
 {
     $res = array("result" => false, "msg" => Yii::t("common", "Something went wrong!"));
     try {
         Link::disconnect($contributorId, $contributorType, $projectId, PHType::TYPE_PROJECTS, Yii::app()->session['userId'], "projects");
         Link::disconnect($projectId, PHType::TYPE_PROJECTS, $contributorId, $contributorType, Yii::app()->session['userId'], "contributors");
         $res = array("result" => true, "msg" => Yii::t("project", "Contributor successfully removed"));
     } catch (CTKException $e) {
         $res = array("result" => false, "msg" => $e->getMessage());
     }
     return Rest::json($res);
 }
コード例 #27
0
 /**
  * Save a new organization with the minimal information
  * @return an array with result and message json encoded
  */
 public function run()
 {
     $controller = $this->getController();
     // Retrieve data from form
     $newOrganization = Organization::newOrganizationFromPost($_POST);
     try {
         //Save the organization
         Rest::json(Organization::insert($newOrganization, Yii::app()->session["userId"]));
     } catch (CTKException $e) {
         return Rest::json(array("result" => false, "msg" => $e->getMessage()));
     }
 }
コード例 #28
0
 public function run()
 {
     $result = $this->createPartners();
     //créé des citoyens Partenaires et PixelActif
     //$result = $this->importFromJson();			//importe les cities depuis fichier .json vers dbb
     //$result = $this->updateGeoPositionCitoyens();
     //$result = $this->updateGeoPositionCities();
     //$result = $this->updateGeoPositionGroups();
     //$result = "Par sécurité, l'execution de ce script est désactivé. Merci de choisir une action avant d'executer ce script";
     Rest::json($result);
     Yii::app()->end();
 }
コード例 #29
0
 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();
 }
コード例 #30
0
 public function run($filter = null)
 {
     $query = array("name" => new MongoRegex("/" . $_POST['name'] . "/i"));
     $res = array();
     if (strcmp($filter, Person::COLLECTION) != 0) {
         $allCitoyen = PHDB::find(PHType::TYPE_CITOYEN, $query, array("name"));
         foreach ($allCitoyen as $key => $value) {
             $profil = Document::getLastImageByKey($key, Person::COLLECTION, Document::IMG_PROFIL);
             if ($profil != "") {
                 $value["imagePath"] = $profil;
             }
             $allCitoyen[$key] = $value;
         }
         $res["citoyen"] = $allCitoyen;
     }
     if (strcmp($filter, Organization::COLLECTION) != 0) {
         $allOrganizations = PHDB::find(Organization::COLLECTION, $query, array("name", "type"));
         foreach ($allOrganizations as $key => $value) {
             $profil = Document::getLastImageByKey($key, Organization::COLLECTION, Document::IMG_PROFIL);
             if ($profil != "") {
                 $value["imagePath"] = $profil;
             }
             $allOrganizations[$key] = $value;
         }
         $res["organization"] = $allOrganizations;
     }
     if (strcmp($filter, Event::COLLECTION) != 0) {
         $allEvents = PHDB::find(PHType::TYPE_EVENTS, $query, array("name"));
         foreach ($allEvents as $key => $value) {
             $profil = Document::getLastImageByKey($key, Event::COLLECTION, Document::IMG_PROFIL);
             if ($profil != "") {
                 $value["imagePath"] = $profil;
             }
             $allEvents[$key] = $value;
         }
         $res["event"] = $allEvents;
     }
     if (strcmp($filter, Project::COLLECTION) != 0) {
         $allProject = PHDB::find(Project::COLLECTION, $query, array("name"));
         foreach ($allProject as $key => $value) {
             $profil = Document::getLastImageByKey($key, Project::COLLECTION, Document::IMG_PROFIL);
             if ($profil != "") {
                 $value["imagePath"] = $profil;
             }
             $allProject[$key] = $value;
         }
         $res["project"] = $allProject;
     }
     Rest::json($res);
     Yii::app()->end();
 }