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(); }
/** * Returns the type of an objectID * @access public * @param string $objectID The objectID * @return string INSTANCEOF_x, else NO */ function getType($objectID) { $evalDB = new EvaluationDB(); return $evalDB->getType($objectID); }
function getNumberOfVotesText($eval, $voted) { $stopdate = $eval->getRealStopdate(); $number = EvaluationDB::getNumberOfVotes($eval->getObjectID()); $html = ""; /* Get number of participants ------------------------------------------- */ if ($stopdate < time() && $stopdate > 0) { if ($number != 1) { $html .= sprintf(_("Es haben insgesamt <b>%s</b> Personen teilgenommen"), $number); } else { $html .= $voted ? sprintf(_("Sie waren die einzige Person die teilgenommen hat")) : sprintf(_("Es hat insgesamt <b>eine</b> Person teilgenommen")); } } else { if ($number != 1) { $html .= sprintf(_("Es haben bisher <b>%s</b> Personen teilgenommen"), $number); } else { $html .= $voted ? sprintf(_("Sie waren bisher der/die einzige Person die teilgenommen hat")) : sprintf(_("Es hat bisher <b>eine</b> Person teilgenommen")); } } /* ---------------------------------------------------------------------- */ if ($voted && $number > 1) { $html .= _(", Sie ebenfalls"); } $html .= ".\n"; return $html; }
} } /* Create objects ---------------------------------------------------------- */ $db = new EvaluationDB(); $lib = new EvalShow(); /* ------------------------------------------------------------ end: objects */ #error_reporting( E_ALL & ~E_NOTICE ); /* Set variables ----------------------------------------------------------- */ $rangeID = Request::option('rangeID', $SessSemName[1]); if (empty($rangeID)) { $rangeID = $user->id; } $evalID = Request::option('evalID'); $tree = new EvaluationTreeShowUser($evalID); $eval = $tree->tree->eval; $evalDB = new EvaluationDB(); $isPreview = Request::option('isPreview') ? YES : NO; $votedEarlier = $eval->hasVoted($auth->auth["uid"]) && $isPreview == NO; $votedNow = Request::submitted('voteButton') && $votedEarlier == NO; if ($eval->isAnonymous()) { $userID = StudipObject::createNewID(); } else { $userID = $auth->auth["uid"]; } /* ---------------------------------------------------------- end: variables */ $br = new HTMpty("br"); /* Surrounding Form -------------------------------------------------------- */ $form = new HTM("form"); $form->attr("action", URLHelper::getLink(Request::url())); $form->attr("method", "post"); $form->html(CSRFProtection::tokenTag());
/** * Exports the evaluation * @access public */ function export() { if (empty($this->filehandle)) { return $this->throwError(1, _("ExportManager::Konnte temporäre Datei nicht öffnen.")); } if (!$this->eval->isAnonymous()) { $this->users = EvaluationDB::getUserVoted($this->eval->getObjectID()); } else { $questions = $this->eval->getSpecialChildobjects($this->eval, INSTANCEOF_EVALQUESTION); $questionIDs = array(); foreach ($questions as $question) { array_push($questionIDs, $question->getObjectID()); } $this->users = EvaluationDB::getUserVoted($this->eval->getObjectID(), null, $questionIDs); } if (empty($this->users)) { return $this->throwError(1, _("ExportManager::Es haben noch keine Benutzer abgestimmt oder angegebene Evaluation existiert nicht.")); } }
function createDomainLinks($search) { global $user; $db = new EvaluationObjectDB(); $evalDB = new EvaluationDB(); $globalperm = $db->getGlobalPerm(); // search results $results = $evalDB->search_range($search); if ($globalperm == "root") { $results["studip"] = array("type" => "system", "name" => _("Systemweite Evaluationen")); } else { $results[$user->id] = array("type" => "user", "name" => _("Profil")); } if ($globalperm == "dozent" || $globalperm == "autor" || $search) { $showsearchresults = 1; } if ($globalperm == "admin") { $range_types = array("user" => _("Benutzer"), "sem" => _("Veranstaltung"), "inst" => _("Einrichtung"), "fak" => _("Fakultät")); } elseif ($globalperm == "root") { $range_types = array("user" => _("Benutzer"), "sem" => _("Veranstaltung"), "inst" => _("Einrichtung"), "fak" => _("Fakultät"), "system" => _("System")); } // display search_results if ($results) { foreach ($results as $k => $v) { while (list($type_key, $type_value) = each($range_types)) { if ($v["type"] == $type_key) { $ranges["{$type_key}"][] = array("id" => $k, "name" => $v["name"]); } } reset($range_types); } $table = new HTML("table"); $table->addAttr("class", "default"); $table->addAttr("border", "0"); $table->addAttr("align", "center"); $table->addAttr("cellspacing", "0"); $table->addAttr("cellpadding", "0"); $table->addAttr("width", "100%"); while (list($type_key, $type_value) = each($range_types)) { // Überschriften $tr = new HTML("tr"); // Typ $td = new HTML("td"); $td->addAttr("colspan", "1"); $td->addAttr("class", "table_header"); $td->addAttr("height", "22"); $td->addAttr("width", "50%"); $td->addAttr("style", "vertical-align:bottom;"); $b = new HTML("b"); $b->addHTMLContent(" "); $b->addContent($type_value . ":"); $td->addContent($b); $tr->addContent($td); // Typ $td = new HTML("td"); $td->addAttr("class", "table_header"); $td->addAttr("height", "22"); $td->addAttr("align", "center"); $td->addAttr("style", "vertical-align:bottom;"); $b = new HTML("b"); $b->addContent(" "); $td->addContent($b); $tr->addContent($td); // Typ $td = new HTML("td"); $td->addAttr("class", "table_header"); $td->addAttr("height", "22"); $td->addAttr("align", "center"); $td->addAttr("style", "vertical-align:bottom;"); $b = new HTML("b"); $b->addContent(" "); $td->addContent($b); $tr->addContent($td); $table->addContent($tr); $counter = 0; if ($ranges["{$type_key}"]) { foreach ($ranges["{$type_key}"] as $range) { if ($counter == 0) { $displayclass = "content_body"; } elseif ($counter % 2 == 0) { $displayclass = "table_row_even"; } else { $displayclass = "table_row_odd"; } $tr = new HTML("tr"); // name $td = new HTML("td"); $td->addHTMLContent(" "); $td->addContent($range["name"]); $tr->addContent($td); // if the rangeID is a username, convert it to the userID $new_rangeID = get_userid($range['id']) ? get_userid($range['id']) : $range['id']; // link $td = new HTML("td"); $td->addAttr("align", "center"); $link = new HTML("a"); $link->addAttr("href", URLHelper::getLink(EVAL_FILE_ADMIN . "?rangeID=" . $range['id'])); $link->addContent(_("Diesen Bereich anzeigen.")); $td->addContent($link); $tr->addContent($td); // copy $td = new HTML("td"); $td->addAttr("align", "center"); $td->addContent(" "); $tr->addContent($td); $table->addContent($tr); $counter++; } } elseif ($globalperm == "root" || $globalperm == "admin") { $tr = new HTML("tr"); $td = new HTML("td"); $td->addAttr("class", "content_body"); $td->addAttr("colspan", "4"); $td->addHTMLContent(" "); $td->addContent(_("Es wurden keine Ergebnisse aus diesem Bereich gefunden.")); $tr->addContent($td); $table->addContent($tr); } reset($ranges); } } return $table->createContent(); }
/** * 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; }