/**
  * 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);
     $controller->title = isset($organization["name"]) ? $organization["name"] : "";
     $controller->subTitle = isset($organization["shortDescripion"]) ? $organization["shortDescripion"] : "";
     $controller->pageTitle = $controller->title . " - " . $controller->subTitle;
     $params = array("organization" => $organization);
     $params["events"] = $events;
     //Same content Key base as the dashboard
     $contentKeyBase = Yii::app()->controller->id . ".dashboard";
     $params["contentKeyBase"] = $contentKeyBase;
     $limit = array(Document::IMG_PROFIL => 1, Document::IMG_MEDIA => 5);
     $images = Document::getListDocumentsURLByContentKey($id, $contentKeyBase, Document::DOC_TYPE_IMAGE, $limit);
     $params["images"] = $images;
     $documents = Document::getWhere(array("type" => Organization::COLLECTION, "id" => $id));
     $params["documents"] = $documents;
     $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);
     }
     if (isset($organization["links"]) && isset($organization["links"]["members"])) {
         $equipe = array();
         $ca = array();
         $bureau = array();
         foreach ($organization["links"]["members"] as $key => $value) {
             if ($value["type"] == PHType::TYPE_CITOYEN && isset($value["roles"])) {
                 $person = Person::getById($key);
                 if (!empty($person)) {
                     if (in_array("Bureau", $value["roles"])) {
                         $bureau[$key] = $person;
                     }
                     if (in_array("Conseil d'administration", $value["roles"])) {
                         $ca[$key] = $person;
                     }
                     if (in_array("Equipe", $value["roles"])) {
                         $equipe[$key] = $person;
                     }
                 }
             }
         }
         if (count($equipe) > 0) {
             $params["equipe"] = $equipe;
         }
         if (count($ca) > 0) {
             $params["ca"] = $ca;
         }
         if (count($bureau) > 0) {
             $params["bureau"] = $bureau;
         }
     }
     foreach ($events as $key => $value) {
         $newEvent = Event::getById($key);
         array_push($contextMap["events"], $newEvent);
     }
     foreach ($people as $key => $value) {
         $newCitoyen = Person::getById($key);
         array_push($contextMap["people"], $newCitoyen);
     }
     $params["contextMap"] = $contextMap;
     $params["countries"] = OpenData::getCountriesList();
     $lists = Lists::get(array("organisationTypes"));
     $params["organizationTypes"] = $lists["organisationTypes"];
     $controller->title = isset($organization["name"]) ? $organization["name"] : "";
     $controller->render("dashboard1", $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);
 }
示例#3
0
 /**
  * List all the event the userId is adminOf
  * A user can be admin of an event if :
  * 1/ He is attendee + admin of the event
  * 2/ He is admin of an organization organizing an event
  * 3/ He is admin of an organization that can edit it members (canEditMembers flag) 
  *      and the organizations members is organizing the event
  * @param String $userId The userId to get the authorisation of
  * @return array List of EventId (String) the user is admin of
  */
 public static function listEventsIamAdminOf($userId)
 {
     $eventList = array();
     //event i'am admin
     $where = array("links.attendees." . $userId . ".isAdmin" => true);
     $eventList = PHDB::find(PHType::TYPE_EVENTS, $where);
     //events of organization i'am admin
     $listOrganizationAdmin = Authorisation::listUserOrganizationAdmin($userId);
     foreach ($listOrganizationAdmin as $organizationId => $organization) {
         $eventOrganization = Organization::listEventsPublicAgenda($organizationId);
         foreach ($eventOrganization as $eventId => $eventValue) {
             $eventList[$eventId] = $eventValue;
         }
     }
     foreach ($eventList as $key => $value) {
         $profil = Document::getLastImageByKey($key, PHType::TYPE_EVENTS, Document::IMG_PROFIL);
         if ($profil != "") {
             $value['imagePath'] = $profil;
         }
     }
     return $eventList;
 }
 public function actionListOrganizationEvent()
 {
     $id = "54eed904a1aa1958b70041ef";
     var_dump(Organization::listEventsPublicAgenda($id));
 }
 /**
  * Dashboard Organization
  */
 public function run($id)
 {
     $controller = $this->getController();
     //get The organization Id
     if (empty($id)) {
         throw new CTKException(Yii::t("organisation", "The organization id is mandatory to retrieve the organization !"));
     }
     $organization = Organization::getPublicData($id);
     $params = array("organization" => $organization);
     $controller->title = isset($organization["name"]) ? $organization["name"] : "";
     $controller->subTitle = isset($organization["shortDescripion"]) ? $organization["shortDescripion"] : "";
     $controller->pageTitle = ucfirst($controller->module->id) . " - Informations publiques de " . $controller->title;
     //Same content Key base as the dashboard
     $contentKeyBase = Yii::app()->controller->id . ".dashboard";
     $params["contentKeyBase"] = $contentKeyBase;
     if (isset($organization["links"]) && isset($organization["links"]["members"])) {
         $memberData;
         $subOrganizationIds = array();
         $members = array("citoyens" => array(), "organizations" => array());
         foreach ($organization["links"]["members"] as $key => $member) {
             if ($member['type'] == Organization::COLLECTION) {
                 array_push($subOrganizationIds, $key);
                 $memberData = Organization::getPublicData($key);
                 array_push($members[Organization::COLLECTION], $memberData);
             } elseif ($member['type'] == PHType::TYPE_CITOYEN) {
                 $memberData = Person::getPublicData($key);
                 array_push($members[PHType::TYPE_CITOYEN], $memberData);
             }
         }
         if (count($subOrganizationIds) != 0) {
             $randomOrganizationId = array_rand($subOrganizationIds);
             $randomOrganization = Organization::getById($subOrganizationIds[$randomOrganizationId]);
             //Load the images
             $limit = array(Document::IMG_PROFIL => 1, Document::IMG_LOGO => 1);
             $images = Document::getListDocumentsURLByContentKey((string) $randomOrganization["_id"], $contentKeyBase, Document::DOC_TYPE_IMAGE, $limit);
             $randomOrganization["images"] = $images;
             $params["randomOrganization"] = $randomOrganization;
         }
         $params["members"] = $members;
     }
     $limit = array(Document::IMG_PROFIL => 1, Document::IMG_MEDIA => 5);
     $images = Document::getListDocumentsURLByContentKey($id, $contentKeyBase, Document::DOC_TYPE_IMAGE, $limit);
     $params["images"] = $images;
     $events = Organization::listEventsPublicAgenda($id);
     $params["events"] = $events;
     $lists = Lists::get(array("organisationTypes"));
     $params["organizationTypes"] = $lists["organisationTypes"];
     $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);
     }
     foreach ($events as $key => $value) {
         $newEvent = Event::getById($key);
         array_push($contextMap["events"], $newEvent);
     }
     foreach ($people as $key => $value) {
         $newCitoyen = Person::getById($key);
         array_push($contextMap["people"], $newCitoyen);
     }
     $params["contextMap"] = $contextMap;
     $controller->render("dashboardMember", $params);
 }