Esempio n. 1
0
 /**
  * SystemPlugins may call UpdateInformation::setInformation to set information
  * to be sent via ajax to the main request. Core-functionality-data should be
  * collected and set here.
  * @return array: array(array('js_function' => $data), ...)
  */
 protected function coreInformation()
 {
     $data = array();
     if (PersonalNotifications::isActivated()) {
         $notifications = PersonalNotifications::getMyNotifications();
         if ($notifications && count($notifications)) {
             $ret = array();
             foreach ($notifications as $notification) {
                 $info = $notification->toArray();
                 $info['html'] = $notification->getLiElement();
                 $ret[] = $info;
             }
             $data['PersonalNotifications.newNotifications'] = $ret;
         } else {
             $data['PersonalNotifications.newNotifications'] = array();
         }
     }
     $page_info = Request::getArray("page_info");
     if (stripos(Request::get("page"), "dispatch.php/messages") !== false) {
         $messages = Message::findNew($GLOBALS["user"]->id, $page_info['Messages']['received'], $page_info['Messages']['since'], $page_info['Messages']['tag']);
         $template_factory = $this->get_template_factory();
         foreach ($messages as $message) {
             $data['Messages.newMessages']['messages'][$message->getId()] = $template_factory->open("messages/_message_row.php")->render(compact("message") + array('controller' => $this));
         }
     }
     if (count($page_info['Questionnaire']['questionnaire_ids']) > 0) {
         foreach ($page_info['Questionnaire']['questionnaire_ids'] as $questionnaire_id) {
             $questionnaire = new Questionnaire($questionnaire_id);
             if ($questionnaire->latestAnswerTimestamp() > $page_info['Questionnaire']['last_update']) {
                 $template = $this->get_template_factory()->open("questionnaire/evaluate");
                 $template->set_layout(null);
                 $template->set_attribute("questionnaire", $questionnaire);
                 $data['Questionnaire.updateQuestionnaireResults'][$questionnaire->getId()] = array('html' => $template->render());
             }
         }
     }
     return $data;
 }