/** * Get an event from an id and return filter data in order to return only public data * @param type $id * @return event structure */ public static function getPublicData($id) { //Public datas $publicData = array(); //TODO SBAR = filter data to retrieve only publi data $event = Event::getById($id); if (empty($event)) { throw new CTKException("The event id is unknown ! Check your URL"); } return $event; }
function editEvent() { global $lang; $page_lang = scandir('inc/lang/' . $_SESSION['lang']); foreach ($page_lang as $file) { if ($file != '.' && $file != '..') { $parts = explode(".", $file); $page = $parts[0]; if ($page == 'content') { $page_file = $file; } } } include_once 'inc/lang/' . $_SESSION['lang'] . '/' . $page_file; if ($_SESSION['access']->events > 1) { $results = array(); if (isset($_POST['saveChanges'])) { $_POST['id'] = $_POST['editId']; unset($_POST['editId']); // User has posted the content edit form: save the content changes if (!($event = Event::getById((int) $_POST['id']))) { header("Location: index.php?action=listEvent&error=eventNotFound"); return; } $event = new Event(); $event->storeFormValues($_POST); $event->update(); header("Location: index.php?action=listEvent&success=changesSaved"); } elseif (isset($_POST['cancel'])) { // User has cancelled their edits: return to the events list header("Location: index.php?action=listEvent"); } else { if (!($event = Event::getById((int) $_GET['editId']))) { header("Location: index.php?action=listEvent&error=eventNotFound"); return; } // User has not submitted the event edit form: display the form $results['event'] = Event::getById((int) $_GET['editId']); require "inc/layout/editEvent.php"; } } else { require "inc/layout/noAccess.php"; } }
/** * 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); }
// changement du statut de l'option $configurationManager = new Configuration(); $conf = $configurationManager->getAll(); $configurationManager->put('optionFeedIsVerbose', $_['optionFeedIsVerbose'] == "0" ? 0 : 1); break; case 'articleDisplayMode': if ($myUser == false) { $response_array['status'] = 'noconnect'; $response_array['texte'] = _t('YOU_MUST_BE_CONNECTED_ACTION'); header('Content-type: application/json'); echo json_encode($response_array); exit; } // chargement du content de l'article souhaité $newEvent = new Event(); $event = $newEvent->getById($_['event_id']); if ($_['articleDisplayMode'] == 'content') { //error_log(print_r($_SESSION['events'],true)); $content = $event->getContent(); } else { $content = $event->getDescription(); } echo $content; break; default: require_once "SimplePie.class.php"; Plugin::callHook("action_post_case", array(&$_, $myUser)); //exit('0'); break; //Installation d'un nouveau plugin //Installation d'un nouveau plugin
public static function removeEventLinks($eventId) { $events = Event::getById($eventId); foreach ($events["links"] as $type => $item) { foreach ($item as $id => $itemInfo) { if ($type == "organizer") { $res = PHDB::update(Organization::COLLECTION, array("_id" => new MongoId($id)), array('$unset' => array("links.events." . $eventId => ""))); } else { $res = PHDB::update(Person::COLLECTION, array("_id" => new MongoId($id)), array('$unset' => array("links.events." . $eventId => ""))); } } } return $res; }
public function run($id, $type) { $controller = $this->getController(); $itemType = Person::COLLECTION; if ($type == "organization") { $itemType = Organization::COLLECTION; } else { if ($type == "event") { $itemType = Event::COLLECTION; } else { if ($type == "project") { $itemType = Project::COLLECTION; } } } $item = PHDB::findOne($itemType, array("_id" => new MongoId($id))); $viewerMap = array($type => $item); $viewerMap[Organization::COLLECTION] = array(); $viewerMap[Event::COLLECTION] = array(); $viewerMap[Person::COLLECTION] = array(); $viewerMap[Project::COLLECTION] = array(); if (isset($item) && isset($item["links"])) { foreach ($item["links"] as $key => $value) { foreach ($value as $k => $v) { if (strcmp($key, "memberOf") == 0 || strcmp($key, "organizer") == 0) { $obj = Organization::getById($k); array_push($viewerMap[Organization::COLLECTION], $obj); } else { if (strcmp($key, "knows") == 0 || strcmp($key, "attendees") == 0 || strcmp($key, "contributors") == 0) { $obj = Person::getById($k); array_push($viewerMap[Person::COLLECTION], $obj); } else { if (strcmp($key, "events") == 0) { $obj = Event::getById($k); array_push($viewerMap[Event::COLLECTION], $obj); } else { if (strcmp($key, "projects") == 0) { $obj = Project::getById($k); array_push($viewerMap[Project::COLLECTION], $obj); } else { if (strcmp($key, "members") == 0) { if (isset($v["type"])) { if (strcmp($v["type"], Organization::COLLECTION) == 0) { $obj = Organization::getById($k); array_push($viewerMap[Organization::COLLECTION], $obj); } else { if (strcmp($v["type"], Person::COLLECTION) == 0) { $obj = Person::getById($k); array_push($viewerMap[Person::COLLECTION], $obj); } } } } } } } } } } } $params = array('viewerMap' => $viewerMap); $params["typeMap"] = $type; $controller->renderPartial("viewer", $params); }
/** * 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); }
function eventmanager_plugin_page($_) { if (isset($_['module']) && $_['module'] == 'eventmanager') { $eventManager = new Event(); $currentEvent = new Event(); $currentEvent->setYear('*'); $currentEvent->setMonth('*'); $currentEvent->setDay('*'); $currentEvent->setHour('*'); $currentEvent->setMinut('*'); $currentEvent = isset($_['id']) ? $eventManager->getById($_['id']) : $currentEvent; ?> <div class="span12"> <h1>Événements</h1> <form action="action.php?action=eventmanager_save_event" method="POST"> <fieldset> <legend>Gestion des événements</legend> <p>Ce module vous permet de créer un événement en fonction d'une date que le client (yana windows ou yana for android) ou le serveur (yana-server sur le rapsberry PI) pourra retranscrire. <br/>Pour le client, l'événement peut être une action parole (prononce une phrase), une commande (une commande est lancée sur le poste qui execute yana client), ou encore un son à jouer (le son doit être un .wav situé dans le repertoire son de yana-windows) <br/><br/>Pour le serveur, l'événement peut être une commande (lancée sur le rapsberry PI), ou un changement d'état GPIO.</p> <div class="row"> <div class="flatBloc blue-color"> <h3><i class="fa fa-clock-o"></i> Événement : heure/date</h3> <div class="span2"> <label for="eventMinut">Minute</label> <select class="input-medium" name="eventMinut" id="eventMinut"> <option <?php if ($currentEvent->getMinut() == '*') { echo 'selected="selected"'; } ?> value="*">Toutes</option> <?php for ($i = 0; $i < 60; $i++) { ?> <option <?php if ($currentEvent->getMinut() == '' . $i) { echo 'selected="selected"'; } ?> ><?php echo $i; ?> </option> <?php } ?> </select> </div> <div class="span2"> <label for="eventHour">Heure</label> <select class="input-medium" name="eventHour" id="eventHour"> <option <?php if ($currentEvent->getHour() == '*') { echo 'selected="selected"'; } ?> value="*">Toutes</option> <?php for ($i = 0; $i < 24; $i++) { ?> <option <?php if ($currentEvent->getHour() == '' . $i) { echo 'selected="selected"'; } ?> ><?php echo $i; ?> </option> <?php } ?> </select> </div> <div class="span2"> <label for="eventDay">Jour</label> <select class="input-medium" name="eventDay" id="eventDay"> <option <?php if ($currentEvent->getDay() == '*') { echo 'selected="selected"'; } ?> value="*">Tous</option> <?php for ($i = 1; $i < 32; $i++) { ?> <option <?php if ($currentEvent->getDay() == '' . $i) { echo 'selected="selected"'; } ?> ><?php echo $i; ?> </option> <?php } ?> </select> </div> <div class="span2"> <label for="eventMonth">Mois</label> <select class="input-medium" name="eventMonth" id="eventMonth"> <option <?php if ($currentEvent->getMonth() == '*') { echo 'selected="selected"'; } ?> value="*">Tous</option> <?php for ($i = 1; $i < 13; $i++) { ?> <option <?php if ($currentEvent->getMonth() == '' . $i) { echo 'selected="selected"'; } ?> ><?php echo $i; ?> </option> <?php } ?> </select> </div> <div class="span3"> <label for="eventYear">Année (taper * pour toutes)</label> <input class="input-medium" type="text" value="<?php echo $currentEvent->getYear(); ?> " name="eventYear" id="eventYear" placeholder="1988" /> </div> <div class="clear"></div> </div> </div> <div class="row"> <div class="flatBloc green-color"> <h3><i class="fa fa-bomb"></i> Action résultante</h3> <div class="span4"> <label for="eventName">Nom</label> <input class="input-xlarge" type="text" id="eventName" value="<?php echo $currentEvent->getName(); ?> " name="eventName" placeholder="ex : Signale un anniversaire"/> </div> <div class="span2"> <?php $recipients = $currentEvent->getRecipients(); $content = $currentEvent->getContent(); $action = $content; ?> <label for="eventTarget">Cible</label> <select class="input-medium" name="eventTarget" id="eventTarget" onready="setActionTypeList('<?php echo $action['type']; ?> ');" onchange="setActionTypeList('<?php echo $action['type']; ?> ');"> <option <?php echo $recipients[0] == 'client' ? 'selected="selected"' : ''; ?> value="client">Client</option> <option <?php echo $recipients[0] == 'server' ? 'selected="selected"' : ''; ?> value="server">Serveur</option> </select> </div> <div class="span2"> <label for="eventType">Action</label> <select class="input-medium" id="eventType" name="eventType" value="<?php echo $action['type']; ?> "></select> </div> <div class="span2"> <label for="eventState">État</label> <select class="input-medium" id="eventState" name="eventState"> <option value="1" <?php echo $currentEvent->getState() == '1' ? 'selected="selected"' : ''; ?> >Actif</option> <option value="0" <?php echo $currentEvent->getState() == '0' ? 'selected="selected"' : ''; ?> >Inactif</option> </select> </div> <div class="span4"> <label for="eventContent">Contenu</label> <textarea class="span10" name="eventContent" id="eventContent"><?php switch ($action['type']) { case 'talk': echo $action['sentence']; break; case 'sound': echo $action['file']; break; case 'command': echo $action['program']; break; case 'gpio': echo $action['gpios']; break; } ?> </textarea> <input type="hidden" name="eventId" value="<?php echo $currentEvent->getId(); ?> " > </div> <div class="clear"></div> </div> </div> <div class="clear"></div> <br/><button type="submit" class="btn">Enregistrer</button> </fieldset> </form> <table class="table table-striped table-bordered table-hover"> <thead> <tr> <th>Nom</th> <th>Heure Date</th> <th>Type</th> <th>Contenu</th> <th>Dernier lancement</th> <th>Cibles</th> <th>Etat</th> <th></th> </tr> </thead> <?php $eventManager = new Event(); $events = $eventManager->populate(); foreach ($events as $event) { $action = $event->getContent(); $recipients = $event->getRecipients(); //$action = $action[0]; ?> <tr> <td><?php echo $event->getName(); ?> </td> <td><?php echo $event->getHour() . ':' . $event->getMinut() . ' ' . $event->getDay() . '/' . $event->getMonth() . '/' . $event->getYear(); ?> </td> <td><?php echo $action['type']; ?> </td> <td><?php switch ($action['type']) { case 'talk': echo $action['sentence']; break; case 'sound': echo $action['file']; break; case 'command': echo $action['program']; break; case 'gpio': echo $action['gpios']; break; } ?> </td> <td><?php echo $event->getRepeat(); ?> </td> <td><?php echo implode(',', $recipients); ?> </td> <td><?php echo $event->getState() == '1' ? 'Actif' : 'Inactif'; ?> </td> <td> <a class="btn" href="index.php?module=eventmanager&id=<?php echo $event->getId(); ?> "><i class="fa fa-pencil"></i></a> <a class="btn" href="action.php?action=eventmanager_delete_event&id=<?php echo $event->getId(); ?> "><i class="fa fa-times"></i></a></td> </tr> <?php } ?> </table> <strong>Important: </strong>Pour profiter du gestionnaire d'événements de yana <code>coté serveur</code>, vous devez ajouter une tâche planifiée sur le raspberry PI, pour cela tapez : <code>sudo crontab -e</code> puis ajoutez la ligne <?php $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://"; $url = $protocol . str_replace('//', '/', 'localhost/' . str_replace('index.php', '', $_SERVER['PHP_SELF']) . '/action.php?action=GET_EVENT&checker=server'); echo '<code>*/1 * * * * wget ' . $url . ' -O /dev/null 2>&1</code>'; ?> puis sauvegardez (<code>ctrl</code>+<code>x</code> puis <code>O</code> puis <code>Entrée</code>) <br/><br/> <br/><br/> </div> <?php } }
public static function eventEndDate($toValidate, $objectId) { $event = Event::getById($objectId); return self::endDate($toValidate, $event); }