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))); }
/** * From an array of tags (String), the new tags will be saved * Filter the array and return all the valid tags * @param array of tags (String) * @return all the valid tags */ public static function filterAndSaveNewTags($tags) { $res = array(); $existingTags = Tags::getActiveTags(); if (!empty($tags)) { foreach ($tags as $tag) { if (!in_array($tag, $existingTags)) { //TODO : Add here how to define if a tag is valid or not PHDB::update(PHType::TYPE_LISTS, array("name" => "tags"), array('$push' => array("list" => $tag))); } array_push($res, $tag); } } return $res; }
/** * */ public function run($id) { $controller = $this->getController(); $params = array(); //get The organization Id if (empty($id)) { throw new CTKException(Yii::t("organisation", "The Parent organization doesn't exist !")); } $params["parentOrganization"] = Organization::getPublicData($id); $lists = Lists::get(array("organisationTypes", "typeIntervention", "public")); if (!isset($lists["organisationTypes"]) || !isset($lists["typeIntervention"]) || !isset($lists["public"])) { throw new CTKException(Yii::t("organisation", Yii::t("organisation", "Missing List data in 'lists' collection, must have organisationTypes, typeIntervention, public"))); } $params["types"] = $lists["organisationTypes"]; $params["listTypeIntervention"] = $lists["typeIntervention"]; $params["listPublic"] = $lists["public"]; $params["tags"] = Tags::getActiveTags(); $controller->layout = "//layouts/mainSimple"; $controller->render("join", $params); }
public function run($type = null, $id = null) { $controller = $this->getController(); $organization = null; if (isset($id)) { $organization = Organization::getById($id); //make sure conected user is the owner if ($organization["email"] != Yii::app()->session["userEmail"] || isset($organization["ph:owner"]) && $organization["ph:owner"] != Yii::app()->session["userEmail"]) { $organization = null; } } $types = PHDB::findOne(PHType::TYPE_LISTS, array("name" => "organisationTypes"), array('list')); $tags = Tags::getActiveTags(); $detect = new Mobile_Detect(); $isMobile = $detect->isMobile(); $params = array("organization" => $organization, 'type' => $type, 'types' => $types['list'], 'tags' => json_encode($tags)); if ($isMobile) { $controller->layout = "//layouts/mainSimple"; $controller->render("addOrganizationMobile", $params); } else { $controller->renderPartial("addOrganizationSV", $params); } }
/** * Dashboard Organization */ public function run($id) { $controller = $this->getController(); if (empty($id)) { throw new CTKException(Yii::t("organisation", "The organization id is mandatory to retrieve the organization !")); } $organization = Organization::getPublicData($id); $events = Organization::listEventsPublicAgenda($id); $members = array("citoyens" => array(), "organizations" => array()); $controller->title = isset($organization["name"]) ? $organization["name"] : ""; $controller->subTitle = isset($organization["shortDescripion"]) ? $organization["shortDescripion"] : ""; $controller->pageTitle = "Organization " . $controller->title . " - " . $controller->subTitle; if (isset($organization["_id"]) && isset(Yii::app()->session["userId"]) && Link::isLinked((string) $organization["_id"], Organization::COLLECTION, Yii::app()->session["userId"])) { $controller->toolbarMBZ = array("<li id='linkBtns'><a href='javascript:;' class='removeMemberBtn text-red tooltips' data-name='" . $organization["name"] . "' data-memberof-id='" . $organization["_id"] . "' data-member-type='" . Person::COLLECTION . "' data-member-id='" . Yii::app()->session["userId"] . "' data-placement='top' data-original-title='Remove from my Organizations' ><i class='disconnectBtnIcon fa fa-unlink'></i>NOT MEMBER</a></li>"); } else { $controller->toolbarMBZ = array("<li id='linkBtns'><a href='javascript:;' class='connectBtn tooltips ' id='addMeAsMemberInfo' data-placement='top' data-original-title='I'm member of this organization' ><i class=' connectBtnIcon fa fa-link '></i>I'M MEMBER</a></li>"); } $contentKeyBase = Yii::app()->controller->id . "." . Yii::app()->controller->action->id; $limit = array(Document::IMG_PROFIL => 1, Document::IMG_MEDIA => 5); $images = Document::getListDocumentsURLByContentKey($id, $contentKeyBase, Document::DOC_TYPE_IMAGE, $limit); $params = array("organization" => $organization); $params["contentKeyBase"] = $contentKeyBase; $params["images"] = $images; $params["events"] = $events; $contextMap = array(); $contextMap["organization"] = $organization; $contextMap["events"] = array(); $contextMap["organizations"] = array(); $contextMap["people"] = array(); $organizations = Organization::getMembersByOrganizationId($id, Organization::COLLECTION); $people = Organization::getMembersByOrganizationId($id, Person::COLLECTION); foreach ($organizations as $key => $value) { $newOrga = Organization::getById($key); array_push($contextMap["organizations"], $newOrga); array_push($members["organizations"], $newOrga); } foreach ($events as $key => $value) { $newEvent = Event::getById($key); array_push($contextMap["events"], $newEvent); } foreach ($people as $key => $value) { $newCitoyen = Person::getById($key); $profil = Document::getLastImageByKey($key, Person::COLLECTION, Document::IMG_PROFIL); if ($profil != "") { $newCitoyen["imagePath"] = $profil; } array_push($contextMap["people"], $newCitoyen); array_push($members["citoyens"], $newCitoyen); } $params["members"] = $members; $params["contextMap"] = $contextMap; //list $params["tags"] = Tags::getActiveTags(); $lists = Lists::get(array("public", "typeIntervention", "organisationTypes")); $params["public"] = $lists["public"]; $params["organizationTypes"] = $lists["organisationTypes"]; $params["typeIntervention"] = $lists["typeIntervention"]; $params["countries"] = OpenData::getCountriesList(); //Plaquette de présentation $listPlaquette = Document::listDocumentByCategory($id, Organization::COLLECTION, Document::CATEGORY_PLAQUETTE, array('created' => 1)); $params["plaquette"] = reset($listPlaquette); $controller->title = isset($organization["name"]) ? $organization["name"] : ""; $controller->render("dashboard", $params); }
public function run($id) { $controller = $this->getController(); $project = Project::getPublicData($id); $controller->sidebar1 = array(array('label' => "ACCUEIL", "key" => "home", "iconClass" => "fa fa-home", "href" => "communecter/project/dashboard/id/" . $id)); $controller->title = isset($project["name"]) ? $project["name"] : ""; if (isset($project["_id"]) && isset(Yii::app()->session["userId"]) && Link::isLinked($project["_id"], Project::COLLECTION, Yii::app()->session['userId'])) { $htmlFollowBtn = "<li id='linkBtns'><a href='javascript:;' class='disconnectBtn text-red tooltips' data-name='" . $project["name"] . "' data-id='" . $project["_id"] . "' data-type='" . Project::COLLECTION . "' data-member-id='" . Yii::app()->session["userId"] . "' data-ownerlink='" . Link::person2projects . "' data-targetlink='" . Link::project2person . "' data-placement='top' data-original-title='No more Attendee' ><i class='disconnectBtnIcon fa fa-unlink'></i>UNCONTRIBUTE</a></li>"; } else { $htmlFollowBtn = "<li id='linkBtns'><a href='javascript:;' class='connectBtn tooltips ' id='addKnowsRelation' data-placement='top' data-ownerlink='" . Link::person2projects . "' data-targetlink='" . Link::project2person . "' data-original-title='I know this person' ><i class=' connectBtnIcon fa fa-link '></i>CONTRIBUTE</a></li>"; } $controller->toolbarMBZ = array("<a href='" . Yii::app()->createUrl("/" . $controller->module->id . "/news/index/type/projects/id/" . $id) . "'><i class='fa fa-rss fa-2x'></i>TIMELINE</a>", "<a href='" . Yii::app()->createUrl("/" . $controller->module->id . "/discuss/index/type/projects/id/" . $id) . "'><i class='fa fa-comments-o fa-2x'></i>DISCUSS</a>", $htmlFollowBtn); $controller->subTitle = isset($project["description"]) ? $project["description"] : ""; $controller->pageTitle = "Communecter - Informations sur le projet " . $controller->title; $organizations = array(); $people = array(); //$admins = array(); $contributors = array(); $properties = array(); $contentKeyBase = $controller->id . "." . $controller->action->id; $images = Document::getListDocumentsURLByContentKey($id, $contentKeyBase, Document::DOC_TYPE_IMAGE); if (!empty($project)) { $params = array(); if (isset($project["links"])) { foreach ($project["links"]["contributors"] as $id => $e) { if ($e["type"] == Organization::COLLECTION) { $organization = Organization::getPublicData($id); if (!empty($organization)) { array_push($organizations, $organization); $organization["type"] = "organization"; array_push($contributors, $organization); } } else { if ($e["type"] == PHType::TYPE_CITOYEN) { $citoyen = Person::getPublicData($id); if (!empty($citoyen)) { array_push($people, $citoyen); $citoyen["type"] = "citoyen"; array_push($contributors, $citoyen); } } } /*if(isset($e["isAdmin"]) && $e["isAdmin"]==true){ array_push($admins, $e); }*/ } } if (isset($project["properties"])) { $properties = $project["properties"]; } } $lists = Lists::get(array("organisationTypes")); $params["countries"] = OpenData::getCountriesList(); $params["tags"] = Tags::getActiveTags(); $params["organizationTypes"] = $lists["organisationTypes"]; $params["images"] = $images; $params["contentKeyBase"] = $contentKeyBase; $params["contributors"] = $contributors; $params["project"] = $project; $params["organizations"] = $organizations; $params["people"] = $people; $params["properties"] = $properties; //$params["admins"] = $admins; $controller->render("dashboard", $params); }
public function run($id = null) { $controller = $this->getController(); //get The person Id if (empty($id)) { if (empty(Yii::app()->session["userId"])) { $controller->redirect(Yii::app()->homeUrl); } else { $id = Yii::app()->session["userId"]; } } $person = Person::getPublicData($id); $contentKeyBase = Yii::app()->controller->id . "." . Yii::app()->controller->action->id; $limit = array(Document::IMG_PROFIL => 1, Document::IMG_MEDIA => 5); $images = Document::getListDocumentsURLByContentKey($id, $contentKeyBase, Document::DOC_TYPE_IMAGE, $limit); $params = array("person" => $person); $params['images'] = $images; $params["contentKeyBase"] = $contentKeyBase; $controller->sidebar1 = array(array('label' => "ACCUEIL", "key" => "home", "iconClass" => "fa fa-home", "href" => "communecter/person/dashboard/id/" . $id)); $controller->title = (isset($person["name"]) ? $person["name"] : "") . "'s Dashboard"; $controller->subTitle = isset($person["description"]) ? $person["description"] : ""; $controller->pageTitle = ucfirst($controller->module->id) . " - Informations publiques de " . $controller->title; //$controller->pageTitle = "Citoyens ".$controller->title." - ".$controller->subTitle; if (isset($person["_id"]) && isset(Yii::app()->session["userId"]) && $person["_id"] != Yii::app()->session["userId"]) { if (isset($person["_id"]) && isset(Yii::app()->session["userId"]) && Link::isConnected(Yii::app()->session['userId'], PHType::TYPE_CITOYEN, (string) $person["_id"], PHType::TYPE_CITOYEN)) { $controller->toolbarMBZ = array("<li id='linkBtns'><a href='javascript:;' class='disconnectBtn text-red tooltips' data-name='" . $person["name"] . "' data-id='" . $person["_id"] . "' data-type='" . Person::COLLECTION . "' data-ownerlink='" . link::person2person . "' data-placement='top' data-original-title='Remove from my contact' ><i class='disconnectBtnIcon fa fa-unlink'></i>UNFOLLOW</a></li>"); } else { $controller->toolbarMBZ = array("<li id='linkBtns'><a href='javascript:;' class='connectBtn tooltips ' id='addKnowsRelation' data-ownerlink='" . link::person2person . "' data-placement='top' data-original-title='I know this person' ><i class=' connectBtnIcon fa fa-link '></i>FOLLOW</a></li>"); } } //Get Projects $projects = array(); if (isset($person["links"]["projects"])) { foreach ($person["links"]["projects"] as $key => $value) { $project = Project::getPublicData($key); array_push($projects, $project); } } //Get the Events $events = Authorisation::listEventsIamAdminOf($id); $eventsAttending = Event::listEventAttending($id); foreach ($eventsAttending as $key => $value) { $eventId = (string) $value["_id"]; if (!isset($events[$eventId])) { $events[$eventId] = $value; } } //TODO - SBAR : Pour le dashboard person, affiche t-on les événements des associations dont je suis memebre ? //Get the organization where i am member of; $organizations = array(); if (isset($person["links"]) && isset($person["links"]["memberOf"])) { foreach ($person["links"]["memberOf"] as $key => $member) { $organization; if ($member['type'] == Organization::COLLECTION) { $organization = Organization::getPublicData($key); $profil = Document::getLastImageByKey($key, Organization::COLLECTION, Document::IMG_PROFIL); if ($profil != "") { $organization["imagePath"] = $profil; } array_push($organizations, $organization); } if (isset($organization["links"]["events"])) { foreach ($organization["links"]["events"] as $keyEv => $valueEv) { $event = Event::getPublicData($keyEv); $events[$keyEv] = $event; } } } //$randomOrganizationId = array_rand($subOrganizationIds); //$randomOrganization = Organization::getById( $subOrganizationIds[$randomOrganizationId] ); //$params["randomOrganization"] = $randomOrganization; } $people = array(); if (isset($person["links"]) && isset($person["links"]["knows"])) { foreach ($person["links"]["knows"] as $key => $member) { $citoyen; if ($member['type'] == PHType::TYPE_CITOYEN) { $citoyen = Person::getPublicData($key); $profil = Document::getLastImageByKey($key, Person::COLLECTION, Document::IMG_PROFIL); if ($profil != "") { $citoyen["imagePath"] = $profil; } array_push($people, $citoyen); } } } $params["countries"] = OpenData::getCountriesList(); $params["listCodeOrga"] = Lists::get(array("organisationTypes")); $params["tags"] = Tags::getActiveTags(); $params["organizations"] = $organizations; $params["projects"] = $projects; $params["events"] = $events; $params["people"] = $people; $controller->render("dashboard", $params); }