示例#1
0
 public static function GetNewsByRSSId($rss_id, $as_objects = false)
 {
     if ($user_id = StudipNews::GetUserIDFromRssID($rss_id)) {
         return StudipNews::GetNewsByRange($user_id, true, $as_objects);
     } else {
         return array();
     }
 }
 function toString ($args = NULL) {
     $js_only = $this->config->getValue("Main", "jsonly");
     if (!$js_only)
         $out = "<script type=\"text/javascript\">\n<!--\n";
     $out .= "var newsticker_max = 0;\n\n";
     $out .= "function textlist() {\n\tnewsticker_max = textlist.arguments.length;\n\t";
     $out .= "for (i = 0; i < newsticker_max; i++)\n\t\tthis[i] = textlist.arguments[i];\n}\n\n";
     $out .= "newsticker_tl = new textlist(";
     
     $topics = array();
     foreach(StudipNews::GetNewsByRange($this->config->range_id, true) as $news_content){
         $topics[] = "'" . addslashes($news_content["topic"]) . "'";
     }
     if (!count($topics))
         $topics[] = "'" . $this->config->getValue("Main", "nodatatext") . "'";
     if ($this->config->getValue("Main", "endtext"))
         $topics[] = "'" . $this->config->getValue("Main", "endtext") . "'";
     
     $out .= implode(", ", $topics) . ");\n\n";
     
     $out .= "var newsticker_x = 0; newsticker_pos = 0;\n";
     $out .= "var newsticker_l = newsticker_tl[0].length;\n\n";
     $out .= "function newsticker() {\n\t";
     $out .= "document.tickform.tickfield.value = newsticker_tl[newsticker_x].substring(0, newsticker_pos) + \"_\";\n";
     $out .= "\tif (newsticker_pos++ == newsticker_l) {\n";
     $out .= "\t\tnewsticker_pos = 0;\n\t\tsetTimeout(\"newsticker()\", ";
     
     $out .= $this->config->getValue("Main", "pause");
     
     $out .= ");\n\t\tif (++newsticker_x == newsticker_max)\n\t\t\tnewsticker_x = 0;\n"; 
     $out .= "\t\tnewsticker_l = newsticker_tl[newsticker_x].length;\n\t}\n";
     $out .= "\telse\n\t\tsetTimeout(\"newsticker()\", ";
     
     $out .= ceil(1000 / $this->config->getValue("Main", "frequency"));
     
     $out .= ");\n}\n";
     if (!$js_only) {
         $out .= "//-->\n</script>\n";
         $out .= "<form name=\"tickform\">\t\n<textarea name=\"tickfield\" rows=\"";
     
         $out .= $this->config->getValue("Main", "rows") . "\" cols=\"";
         $out .= $this->config->getValue("Main", "length") . "\" style=\"";
         $out .= $this->config->getValue("Main", "style") . "\" wrap=\"virtual\">";
         $out .= $this->config->getValue("Main", "starttext");
         $out .= "</textarea>\n</form>\n";
     
         if ($this->config->getValue("Main", "automaticstart"))
             $out .= "<script type=\"text/javascript\">\n\tnewsticker();\n</script>\n";
     }
     
     return $out;
 }
示例#3
0
 public function perform($unconsumed)
 {
     if ($unconsumed !== 'read_all') {
         return;
     }
     $global_news = StudipNews::GetNewsByRange('studip', true);
     foreach ($global_news as $news) {
         object_add_view($news['news_id']);
         object_set_visit($news['news_id'], 'news');
     }
     if (Request::isXhr()) {
         echo json_encode(true);
     } else {
         PageLayout::postMessage(MessageBox::success(_('Alle Ankündigungen wurden als gelesen markiert.')));
         header('Location: ' . URLHelper::getLink('dispatch.php/start'));
     }
 }
    function getContent ($args = NULL, $raw = FALSE)
    {
        $content = array();
        $error_message = "";

        // stimmt die übergebene range_id?
        $query = "SELECT 1 FROM Institute WHERE Institut_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($this->config->range_id));
        if (!$statement->fetchColumn()) {
            $error_message = $GLOBALS['EXTERN_ERROR_MESSAGE'];
        }

        $local_fullname_sql = $GLOBALS['_fullname_sql'];
        if (!$nameformat = $this->config->getValue('Main', 'nameformat')) {
            $nameformat = 'no_title';
        }
        if ($nameformat == 'last') $local_fullname_sql['last'] = ' Nachname ';

        $news =& StudipNews::GetNewsByRange($this->config->range_id);
        if (!count($news)) {
            $content['NEWS']['NO-NEWS']['NO-NEWS_TEXT'] = $this->config->getValue('Main', "nodatatext");
        }

        $studip_link = URLHelper::getLink('dispatch.php/institute/overview?again=yes&cid='. $this->config->range_id);
        $content['__GLOBAL__']['STUDIP-LINK'] = $studip_link;

        $dateform = $this->config->getValue("Main", "dateformat");
        $show_date_author = $this->config->getValue("Main", "showdateauthor");
        $i = 1;
        $j = 1;
        foreach ($news as $news_id => $news_detail) {
            //aktuelle News ausgeben
            if (($news_detail['date'] + $news_detail['expire']) >= time())
                {
                list($news_content, $admin_msg) = explode("<admin_msg>", $news_detail['body']);
                if ($news_detail['chdate_uid']){
                    $admin_msg = StudipNews::GetAdminMsg($news_detail['chdate_uid'],$news_detail['chdate']);
                }
                if ($admin_msg) {
                    $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_ADMIN-MESSAGE'] = preg_replace('# \(?(.*)\)?#', '$1', $admin_msg);
                }

                if (!$news_content) {
                    $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_BODY'] = _("Keine Beschreibung vorhanden.");
                } else {
                    $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_BODY'] =  ExternModule::ExtFormatReady($news_content);
                }

                $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_DATE'] = strftime($dateform, $news_detail['date']);
                $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_TOPIC'] = ExternModule::ExtHtmlReady($news_detail['topic']);
                $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_NO'] = $i;

                $query = "SELECT Nachname, Vorname, title_front, title_rear,
                                 {$local_fullname_sql[$nameformat]} AS fullname, username,
                                 aum.user_id
                          FROM auth_user_md5 AS aum
                          LEFT JOIN user_info AS ui USING (user_id)
                          WHERE aum.user_id = ?";
                $statement = DBManager::get()->prepare($query);
                $statement->execute(array($news_detail['user_id']));
                $temp = $statement->fetch(PDO::FETCH_ASSOC);
                if ($temp) {
                    $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['FULLNAME'] = ExternModule::ExtHtmlReady($temp['fullname']);
                    $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['FIRSTNAME'] = ExternModule::ExtHtmlReady($temp['Vorname']);
                    $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['LASTNAME'] = ExternModule::ExtHtmlReady($temp['Nachname']);
                    $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['TITLEFRONT'] = ExternModule::ExtHtmlReady($temp['title_front']);
                    $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['TITLEREAR'] = ExternModule::ExtHtmlReady($temp['title_rear']);
                    $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['USERNAME'] = $temp['username'];
                    $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['PERSONDETAIL-HREF'] = $this->elements['LinkInternTemplate']->createUrl(array('link_args' => 'username='******'username']));

                    if (GetAllStatusgruppen($this->config->range_id, $temp['user_id'], true)) {
                        $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['PERSONDETAIL-LINK']['LINK_PERSONDETAIL-HREF'] = $this->elements['LinkInternTemplate']->createUrl(array('link_args' => 'username='******'username']));
                        $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['PERSONDETAIL-LINK']['LINK_FULLNAME'] = ExternModule::ExtHtmlReady($temp['fullname']);
                        $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['PERSONDETAIL-LINK']['LINK_FIRSTNAME'] = ExternModule::ExtHtmlReady($temp['Vorname']);
                        $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['PERSONDETAIL-LINK']['LINK_LASTNAME'] = ExternModule::ExtHtmlReady($temp['Nachname']);
                        $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['PERSONDETAIL-LINK']['LINK_TITLEFRONT'] = ExternModule::ExtHtmlReady($temp['title_front']);
                        $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['PERSONDETAIL-LINK']['LINK_TITLEREAR'] = ExternModule::ExtHtmlReady($temp['title_rear']);
                    }
                }
                $i++;
            }
            //archivierte News ausgeben
            elseif(($news_detail['date'] + $news_detail['expire']) < time())
            {
                list($news_content, $admin_msg) = explode("<admin_msg>", $news_detail['body']);
                if ($news_detail['chdate_uid']){
                    $admin_msg = StudipNews::GetAdminMsg($news_detail['chdate_uid'],$news_detail['chdate']);
                }
                if ($admin_msg) {
                    $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_NEWS_ADMIN-MESSAGE'] = preg_replace('# \(?(.*)\)?#', '$1', $admin_msg);
                }

                if (!$news_content) {
                    $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_NEWS_BODY'] = _("Keine Beschreibung vorhanden.");
                } else {
                    $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_NEWS_BODY'] =  ExternModule::ExtFormatReady($news_content);
                }

                $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_NEWS_DATE'] = strftime($dateform, $news_detail['date']);
                $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_NEWS_TOPIC'] = ExternModule::ExtHtmlReady($news_detail['topic']);
                $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_NEWS_NO'] = $j;

                $query = "SELECT Nachname, Vorname, title_front, title_rear,
                                 {$local_fullname_sql[$nameformat]} AS fullname, username,
                                 aum.user_id
                          FROM auth_user_md5 AS aum
                          LEFT JOIN user_info AS ui USING (user_id)
                          WHERE aum.user_id = ?";
                $statement = DBManager::get()->prepare($query);
                $statement->execute(array($news_detail['user_id']));
                $temp = $statement->fetch(PDO::FETCH_ASSOC);
                if ($temp) {
                    $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_FULLNAME'] = ExternModule::ExtHtmlReady($temp['fullname']);
                    $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_FIRSTNAME'] = ExternModule::ExtHtmlReady($temp['Vorname']);
                    $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_LASTNAME'] = ExternModule::ExtHtmlReady($temp['Nachname']);
                    $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_TITLEFRONT'] = ExternModule::ExtHtmlReady($temp['title_front']);
                    $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_TITLEREAR'] = ExternModule::ExtHtmlReady($temp['title_rear']);
                    $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_USERNAME'] = $temp['username'];
                    $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_PERSONDETAIL-HREF'] = $this->elements['LinkInternTemplate']->createUrl(array('link_args' => 'username='******'username']));

                    if (GetAllStatusgruppen($this->config->range_id, $temp['user_id'], true)) {
                        $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_PERSONDETAIL-LINK']['ARCHIV_LINK_PERSONDETAIL-HREF'] = $this->elements['LinkInternTemplate']->createUrl(array('link_args' => 'username='******'username']));
                        $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_PERSONDETAIL-LINK']['ARCHIV_LINK_FULLNAME'] = ExternModule::ExtHtmlReady($temp['fullname']);
                        $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_PERSONDETAIL-LINK']['ARCHIV_LINK_FIRSTNAME'] = ExternModule::ExtHtmlReady($temp['Vorname']);
                        $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_PERSONDETAIL-LINK']['ARCHIV_LINK_LASTNAME'] = ExternModule::ExtHtmlReady($temp['Nachname']);
                        $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_PERSONDETAIL-LINK']['ARCHIV_LINK_TITLEFRONT'] = ExternModule::ExtHtmlReady($temp['title_front']);
                        $content['NEWS']['ALL-ARCHIV-NEWS']['SINGLE-ARCHIVE-NEWS'][$j]['ARCHIV_PERSONDETAIL-LINK']['ARCHIV_LINK_TITLEREAR'] = ExternModule::ExtHtmlReady($temp['title_rear']);
                    }
                }
                $j++;
            }
        }
        $content['__GLOBAL__']['NEWS-COUNT'] = $i  - 1;
        $content['__GLOBAL__']['ARCHIV-NEWS-COUNT'] = $j -1;
        return $content;
    }
示例#5
0
/**
 *
 * @param unknown_type $range_id
 * @param unknown_type $type
 */
function show_rss_news($range_id, $type)
{
    $item_url_fmt = '%1$s&contentbox_open=%2$s#%2$s';
    switch ($type) {
        case 'user':
            $studip_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'dispatch.php/profile?again=yes&username='******' (Stud.IP - ' . $GLOBALS['UNI_NAME_CLEAN'] . ')';
            $description = _('Persönliche Neuigkeiten') . ' ' . $title;
            break;
        case 'sem':
            $studip_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'dispatch.php/course/overview?cid=' . $range_id;
            $sem_obj = Seminar::GetInstance($range_id);
            if ($sem_obj->read_level > 0) {
                $studip_url .= '&again=yes';
            }
            $title = $sem_obj->getName() . ' (Stud.IP - ' . $GLOBALS['UNI_NAME_CLEAN'] . ')';
            $description = _('Neuigkeiten der Veranstaltung') . ' ' . $title;
            break;
        case 'inst':
            $studip_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'dispatch.php/institute/overview?auswahl=' . $range_id;
            $object_name = get_object_name($range_id, $type);
            if (!get_config('ENABLE_FREE_ACCESS')) {
                $studip_url .= "&again=yes";
            }
            $title = $object_name['name'] . ' (Stud.IP - ' . $GLOBALS['UNI_NAME_CLEAN'] . ')';
            $description = _('Neuigkeiten der Einrichtung') . ' ' . $title;
            break;
        case 'global':
            $studip_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'dispatch.php/start?again=yes';
            $title = 'Stud.IP - ' . $GLOBALS['UNI_NAME_CLEAN'];
            $description = _('Allgemeine Neuigkeiten') . ' ' . $title;
            break;
    }
    $items = StudipNews::GetNewsByRange($range_id, true);
    $last_changed = 0;
    foreach ($items as &$item) {
        if ($last_changed < $item['chdate']) {
            $last_changed = $item['chdate'];
        }
        if ($item['date'] < $item['chdate']) {
            $item['date'] = $item['chdate'];
        }
        list($body, $admin_msg) = explode('<admin_msg>', $item['body']);
        $item['body'] = $body;
    }
    header('Content-type: application/rss+xml; charset=utf-8');
    $template = $GLOBALS['template_factory']->open('news/rss-feed');
    $template->items = $items;
    $template->title = $title;
    $template->studip_url = $studip_url;
    $template->description = $description;
    $template->last_changed = $last_changed;
    $template->item_url_fmt = $item_url_fmt;
    echo $template->render();
    return true;
}
 private function getContentNews () {
     $news =& StudipNews::GetNewsByRange($this->user_id, TRUE);
     if (!count($news)) {
         $content['NEWS']['NO-NEWS']['NEWS_NO-NEWS-TEXT'] = $this->config->getValue('Main', 'nodatatext');
     } else {
         $i = 0;
         foreach ($news as $news_id => $news_detail) {
             list($news_content, $admin_msg) = explode("<admin_msg>", $news_detail['body']);
             if ($admin_msg) {
                 $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_ADMIN-MESSAGE'] = preg_replace('# \(.*?\)#', '', $admin_msg);
                 $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_BODY'] = ExternModule::ExtFormatReady($news_content);
             } else {
                 $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_BODY'] = ExternModule::ExtFormatReady($news_detail['body']);
             }
             $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_DATE'] = strftime($dateform, $news_detail['date']);
             $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_TOPIC'] = ExternModule::ExtHtmlReady($news_detail['topic']);
             $content['NEWS']['ALL-NEWS']['SINGLE-NEWS'][$i]['NEWS_NO'] = $i + 1;
             $i++;
         }
     }
     return $content;
 }
示例#7
0
 static function loadRange($range_id)
 {
     $news = \StudipNews::GetNewsByRange($range_id);
     $news = array_map('self::adjust', $news);
     return $news;
 }
示例#8
0
 /**
  * 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;
 }
示例#9
0
文件: news.php 项目: ratbird/hope
 /**
  * Widget controller to produce the formally known show_votes()
  *
  * @param String $range_id range id of the news to get displayed
  * @return array() Array of votes
  */
 function display_action($range_id)
 {
     if (!$range_id) {
         $this->set_status(400);
         return $this->render_nothing();
     }
     if (!StudipNews::haveRangePermission('view', $range_id, $GLOBALS['user']->id)) {
         $this->set_status(401);
         return $this->render_nothing();
     }
     // Check if user wrote a comment
     if (Request::submitted('accept') && trim(Request::get('comment_content')) && Request::isPost()) {
         CSRFProtection::verifySecurityToken();
         StudipComment::create(array('object_id' => Request::get('comsubmit'), 'user_id' => $GLOBALS['user']->id, 'content' => trim(Request::get('comment_content'))));
     }
     // Check if user wants to remove a announcement
     if ($news_id = Request::get('remove_news')) {
         $news = new StudipNews($news_id);
         $range = Request::get('news_range');
         if ($news->havePermission('unassign', $range)) {
             if (Request::get('confirm')) {
                 $news->deleteRange($range);
                 $news->store();
             } else {
                 $this->question = createQuestion(_('Ankündigung wirklich aus diesem Bereich entfernen?'), array('remove_news' => $news_id, 'news_range' => $range, 'confirm' => true));
             }
         }
     }
     // Check if user wants to delete an announcement
     if ($news_id = Request::get('delete_news')) {
         $news = new StudipNews($news_id);
         if ($news->havePermission('delete')) {
             if (Request::get('confirm')) {
                 $news->delete();
             } else {
                 $this->question = createQuestion(_('Ankündigung wirklich löschen?'), array('delete_news' => $news_id, 'confirm' => true));
             }
         }
     }
     $this->perm = StudipNews::haveRangePermission('edit', $range_id);
     $this->show_all_news = Request::get('nshow_all') && $this->perm;
     $news = StudipNews::GetNewsByRange($range_id, !$this->show_all_news);
     if ($this->show_all_news) {
         URLHelper::addLinkParam('nshow_all', 1);
     }
     $this->news = StudipNews::GetNewsByRange($range_id, !$this->show_all_news, true);
     $this->count_all_news = $this->show_all_news ? count($this->news) : count(StudipNews::GetNewsByRange($range_id, false));
     $this->rss_id = get_config('NEWS_RSS_EXPORT_ENABLE') ? StudipNews::GetRssIdFromRangeId($range_id) : false;
     $this->range = $range_id;
     $this->nobody = !$GLOBALS['user']->id || $GLOBALS['user']->id == 'nobody';
     $this->visit();
 }