public function display_action($range_id) { // Bind some params URLHelper::bindLinkParam('show_expired', $null1); URLHelper::bindLinkParam('preview', $null2); URLHelper::bindLinkParam('revealNames', $null3); URLHelper::bindLinkParam('sort', $null4); // Bind range_id $this->range_id = $range_id; $this->nobody = !$GLOBALS['user']->id || $GLOBALS['user']->id == 'nobody'; /* * Insert vote */ if ($vote = Request::get('vote')) { $vote = new StudipVote($vote); if (!$this->nobody && $vote && $vote->isRunning() && (!$vote->userVoted() || $vote->changeable)) { try { $vote->insertVote(Request::getArray('vote_answers'), $GLOBALS['user']->id); } catch (Exception $exc) { $GLOBALS['vote_message'][$vote->id] = MessageBox::error($exc->getMessage()); } } } // Check if we need administration icons $this->admin = $range_id == $GLOBALS['user']->id || $GLOBALS['perm']->have_studip_perm('tutor', $range_id); // Load evaluations if (!$this->nobody) { $eval_db = new EvaluationDB(); $this->evaluations = StudipEvaluation::findMany($eval_db->getEvaluationIDs($range_id, EVAL_STATE_ACTIVE)); } else { $this->evaluations = array(); } $show_votes[] = 'active'; // Check if we got expired if (Request::get('show_expired')) { $show_votes[] = 'stopvis'; if ($this->admin) { $this->evaluations = array_merge($this->evaluations, StudipEvaluation::findMany($eval_db->getEvaluationIDs($range_id, EVAL_STATE_STOPPED))); $show_votes[] = 'stopinvis'; } } $this->votes = StudipVote::findBySQL('range_id = ? AND state IN (?) ORDER BY mkdate desc', array($range_id, $show_votes)); $this->visit(); }
/** * Builds an array containing all available elements that are part of a * user's homepage together with their visibility. It isn't sufficient to * just load the visibility settings from database, because if the user * has added some data (e.g. CV) but not yet assigned a special visibility * to that field, it wouldn't show up. * * @return array An array containing all available homepage elements * together with their visibility settings in the form * $name => $visibility. */ public function get_homepage_elements() { global $NOT_HIDEABLE_FIELDS; $query = "SELECT user_info.*, auth_user_md5.*\n FROM auth_user_md5\n LEFT JOIN user_info USING (user_id)\n WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->auth_user['user_id'])); $my_data = $statement->fetch(PDO::FETCH_ASSOC); $homepage_visibility = get_local_visibility_by_id($this->auth_user['user_id'], 'homepage'); if (is_array(json_decode($homepage_visibility, true))) { $homepage_visibility = json_decode($homepage_visibility, true); } else { $homepage_visibility = array(); } // News $news = StudipNews::GetNewsByRange($this->auth_user['user_id'], true); // Non-private dates. if (Config::get()->CALENDAR_ENABLE) { $dates = CalendarEvent::countBySql('range_id = ?', array($this->auth_user['user_id'])); } // Votes if (Config::get()->VOTE_ENABLE) { //$voteDB = new VoteDB(); $activeVotes = Questionnaire::countBySQL("user_id = ? AND visible = '1'", array($this->auth_user['user_id'])); $stoppedVotes = Questionnaire::countBySQL("user_id = ? AND visible = '0'", array($this->auth_user['user_id'])); } // Evaluations $evalDB = new EvaluationDB(); $activeEvals = $evalDB->getEvaluationIDs($this->auth_user['user_id'], EVAL_STATE_ACTIVE); // Literature $lit_list = StudipLitList::GetListsByRange($this->auth_user['user_id']); // Free datafields $data_fields = DataFieldEntry::getDataFieldEntries($this->auth_user['user_id'], 'user'); // Homepage plugins //$homepageplugins = PluginEngine::getPlugins('HomepagePlugin'); // Deactivate plugin visibility settings because they aren't working now. $homepageplugins = array(); $user_domains = count(UserDomain::getUserDomains()); // Now join all available elements with visibility settings. $homepage_elements = array(); if (Avatar::getAvatar($this->auth_user['user_id'])->is_customized() && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['picture']) { $homepage_elements["picture"] = array("name" => _("Eigenes Bild"), "visibility" => $homepage_visibility["picture"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Allgemeine Daten'); } if ($my_data["motto"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['motto']) { $homepage_elements["motto"] = array("name" => _("Motto"), "visibility" => $homepage_visibility["motto"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } if (Config::get()->ENABLE_SKYPE_INFO) { if ($GLOBALS['user']->cfg->getValue('SKYPE_NAME') && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['skype_name']) { $homepage_elements["skype_name"] = array("name" => _("Skype Name"), "visibility" => $homepage_visibility["skype_name"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); if ($GLOBALS['user']->cfg->getValue('SKYPE_ONLINE_STATUS')) { $homepage_elements["skype_online_status"] = array("name" => _("Skype Online Status"), "visibility" => $homepage_visibility["skype_online_status"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } } } if ($my_data["privatnr"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['Private Daten_phone']) { $homepage_elements["private_phone"] = array("name" => _("Private Telefonnummer"), "visibility" => $homepage_visibility["private_phone"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } if ($my_data["privatcell"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['private_cell']) { $homepage_elements["private_cell"] = array("name" => _("Private Handynummer"), "visibility" => $homepage_visibility["private_cell"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } if ($my_data["privadr"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['privadr']) { $homepage_elements["privadr"] = array("name" => _("Private Adresse"), "visibility" => $homepage_visibility["privadr"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } if ($my_data["Home"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['homepage']) { $homepage_elements["homepage"] = array("name" => _("Homepage-Adresse"), "visibility" => $homepage_visibility["homepage"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten'); } if ($news && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['news']) { $homepage_elements["news"] = array("name" => _("Ankündigungen"), "visibility" => $homepage_visibility["news"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Allgemeine Daten'); } if (Config::get()->CALENDAR_ENABLE && $dates && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['dates']) { $homepage_elements["termine"] = array("name" => _("Termine"), "visibility" => $homepage_visibility["termine"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Allgemeine Daten'); } if (Config::get()->VOTE_ENABLE && ($activeVotes || $stoppedVotes || $activeEvals) && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['votes']) { $homepage_elements["votes"] = array("name" => _("Fragebögen"), "visibility" => $homepage_visibility["votes"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Allgemeine Daten'); } $query = "SELECT 1\n FROM user_inst\n LEFT JOIN Institute USING (Institut_id)\n WHERE user_id = ? AND inst_perms = 'user'"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->auth_user['user_id'])); if ($statement->fetchColumn() && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['studying']) { $homepage_elements["studying"] = array("name" => _("Wo ich studiere"), "visibility" => $homepage_visibility["studying"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Studien-/Einrichtungsdaten'); } if ($lit_list && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['literature']) { $homepage_elements["literature"] = array("name" => _("Literaturlisten"), "visibility" => $homepage_visibility["literature"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Allgemeine Daten'); } if ($my_data["lebenslauf"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['lebenslauf']) { $homepage_elements["lebenslauf"] = array("name" => _("Lebenslauf"), "visibility" => $homepage_visibility["lebenslauf"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten'); } if ($my_data["hobby"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['hobby']) { $homepage_elements["hobby"] = array("name" => _("Hobbies"), "visibility" => $homepage_visibility["hobby"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } if ($my_data["publi"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['publi']) { $homepage_elements["publi"] = array("name" => _("Publikationen"), "visibility" => $homepage_visibility["publi"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten'); } if ($my_data["schwerp"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['schwerp']) { $homepage_elements["schwerp"] = array("name" => _("Arbeitsschwerpunkte"), "visibility" => $homepage_visibility["schwerp"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten'); } if ($data_fields) { foreach ($data_fields as $key => $field) { if ($field->getValue() && $field->isEditable($this->auth_user['perms']) && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']][$key]) { $homepage_elements[$key] = array('name' => $field->getName(), 'visibility' => $homepage_visibility[$key] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'extern' => true, 'category' => 'Zusätzliche Datenfelder'); } } } $query = "SELECT kategorie_id, name\n FROM kategorien\n WHERE range_id = ?\n ORDER BY priority"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->auth_user['user_id'])); while ($category = $statement->fetch(PDO::FETCH_ASSOC)) { $homepage_elements["kat_" . $category["kategorie_id"]] = array("name" => $category["name"], "visibility" => $homepage_visibility["kat_" . $category["kategorie_id"]] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Eigene Kategorien'); } if ($homepageplugins) { foreach ($homepageplugins as $plugin) { $homepage_elements['plugin_' . $plugin->getPluginId()] = array("name" => $plugin->getPluginName(), "visibility" => $homepage_visibility["plugin_" . $plugin->getPluginId()] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Plugins'); } } return $homepage_elements; }