Exemple #1
0
 public function testUserRequestCreation()
 {
     $factoryMock = $this->getMock('Magento\\Backend\\Model\\Config\\Factory', [], [], '', false);
     $responseMock = $this->getMock('Magento\\Framework\\App\\Console\\Response', [], [], '', false);
     $configMock = $this->getMock('Magento\\Backend\\Model\\Config', [], [], '', false);
     $key = 'key';
     $value = 'value';
     $request = [$key => $value];
     $model = new UserConfig($factoryMock, $responseMock, $request);
     $factoryMock->expects($this->once())->method('create')->will($this->returnValue($configMock));
     $configMock->expects($this->once())->method('setDataByPath')->with($key, $value);
     $configMock->expects($this->once())->method('save');
     $model->launch();
 }
 public function __construct()
 {
     parent::__construct();
     $top = new Navigation($this->getDisplayTitle(), PluginEngine::getURL($this, array('view' => 'tiles'), "presenting/overview"));
     $top->setImage(Icon::create($this->getPluginURL() . "/assets/topicon.svg"));
     $overview = new Navigation($this->getDisplayTitle(), PluginEngine::getURL($this, array(), "presenting/overview"));
     $top->addSubNavigation("presenting", $overview);
     $overview->addSubNavigation("overview", new AutoNavigation(_('Übersicht'), PluginEngine::getURL($this, array(), "presenting/overview")));
     $overview->addSubNavigation("all", new AutoNavigation(_('Alle Plugins'), PluginEngine::getURL($this, array(), "presenting/all")));
     $overview->addSubNavigation("tools", new AutoNavigation(_('Tools'), PluginEngine::getURL($this, array(), "tools/sidebar_graphics_generator")));
     if ($GLOBALS['perm']->have_perm("autor")) {
         $top->addSubNavigation("myplugins", new Navigation(_("Meine Plugins"), PluginEngine::getURL($this, array(), "myplugins/overview")));
     }
     if ($GLOBALS['perm']->have_perm("user")) {
         $last_visit = UserConfig::get($GLOBALS['user']->id)->getValue("last_pluginmarket_visit");
         if ($last_visit) {
             $badge_number = MarketPlugin::countBySql("publiclyvisible = 1 AND approved = 1 AND published > ?", array($last_visit));
             if ($badge_number > 0) {
                 $top->setBadgeNumber($badge_number);
             }
         }
     }
     if ($GLOBALS['perm']->have_perm("root")) {
         $approving = new Navigation(_("Qualitätssicherung"), PluginEngine::getURL($this, array(), "approving/overview"));
         $top->addSubNavigation("approving", $approving);
     }
     Navigation::addItem("/pluginmarket", $top);
     $loginlink = new Navigation($this->getDisplayTitle(), PluginEngine::getURL($this, array(), "presenting/overview"));
     $loginlink->setDescription(_("Laden Sie hier Plugins für Ihr Stud.IP herunter"));
     Navigation::addItem("/login/pluginmarket", $loginlink);
     NotificationCenter::addObserver($this, "triggerFollowingStudips", "PluginReleaseDidUpdateCode");
 }
Exemple #3
0
 /**
  * Display a user's calendar settings
  */
 public function index_action()
 {
     $calendar_user_control_data = (array) UserConfig::get($GLOBALS['user']->id)->getValue('CALENDAR_SETTINGS');
     foreach ($calendar_user_control_data as $key => $value) {
         $this->{$key} = $value;
     }
 }
Exemple #4
0
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     PageLayout::setHelpKeyword('Basis.Terminkalender');
     $this->settings = UserConfig::get($GLOBALS['user']->id)->getValue('CALENDAR_SETTINGS');
     if (!is_array($this->settings)) {
         $this->settings = Calendar::getDefaultUserSettings();
     }
     URLHelper::bindLinkParam('atime', $this->atime);
     $this->atime = Request::int('atime', time());
     $this->category = Request::int('category');
     $this->last_view = Request::option('last_view', $this->settings['view']);
     $this->action = $action;
     $this->restrictions = $this->category ? array('STUDIP_CATEGORY' => $this->category) : null;
     if ($this->category) {
         URLHelper::bindLinkParam('category', $this->category);
     }
     $self = Request::option('self');
     //   var_dump($_SESSION['SessSemName'], $self); exit;
     if (!$self && $_SESSION['SessSemName']['class'] == 'sem') {
         $this->range_id = Request::option('cid');
         Navigation::activateItem('/course/calendar');
     } else {
         $this->range_id = Request::option('range_id', $GLOBALS['user']->id);
         Navigation::activateItem('/calendar/calendar');
         URLHelper::bindLinkParam('range_id', $this->range_id);
     }
     URLHelper::bindLinkParam('last_view', $this->last_view);
 }
Exemple #5
0
 /**
  * Liefert die vorhandenen Nachrichten eines Ordners des
  * autorisierten Nutzers zurück.
  *
  * @get /user/:user_id/:box/:folder_id
  */
 public function showFolder($user_id, $box, $folder_id)
 {
     $settings = \UserConfig::get($user_id)->MESSAGING_SETTINGS ?: array();
     $type = substr($box, 0, -3);
     if ($folder_id != 0 && (!isset($settings['folder'][$type][$folder_id]) || $settings['folder'][$type][$folder_id] === 'dummy')) {
         $this->notFound();
     }
     // only your messages!
     if ($user_id !== self::currentUser()) {
         $this->error(401);
     }
     // get all messages in the user's folder
     $ids = self::folder($user_id, $box === 'inbox' ? 'rec' : 'snd', $folder_id);
     $total = count($ids);
     $ids = array_slice($ids, $this->offset, $this->limit, true);
     $messages = array();
     if (sizeof($ids)) {
         foreach (\Message::findMany($ids) as $msg) {
             $url = $this->urlf('/message/%s', array($msg->id));
             $messages[$url] = $this->messageToJSON($msg);
         }
     }
     $this->etag(md5(serialize($messages)));
     return $this->paginated($messages, $total, compact('user_id', 'box', 'folder_id'));
 }
Exemple #6
0
 /**
  * Sends the collected messages from sendingMail as e-mail.
  */
 function bulkSend()
 {
     // if nothing to do, return
     if (empty($this->bulk_mail)) {
         return;
     }
     // send a mail, for each language one
     foreach ($this->bulk_mail as $lang_data) {
         foreach ($lang_data as $data) {
             $mail = new StudipMail();
             $mail->setSubject($data['title']);
             foreach ($data['users'] as $user_id => $to) {
                 $mail->addRecipient($to, get_fullname($user_id), 'Bcc');
             }
             $mail->setReplyToEmail('')->setBodyText($data['text']);
             if (strlen($data['reply_to'])) {
                 $mail->setSenderEmail($data['reply_to'])->setSenderName($snd_fullname);
             }
             $user_cfg = UserConfig::get($user_id);
             if ($user_cfg->getValue('MAIL_AS_HTML')) {
                 $mail->setBodyHtml($mailhtml);
             }
             if ($GLOBALS["ENABLE_EMAIL_ATTACHMENTS"]) {
                 foreach (get_message_attachments($data['message_id']) as $attachment) {
                     $mail->addStudipAttachment($attachment['dokument_id']);
                 }
             }
             $mail->send();
         }
     }
 }
Exemple #7
0
 public function initItem()
 {
     global $user, $neux;
     parent::initItem();
     $my_messaging_settings = UserConfig::get($user->id)->MESSAGING_SETTINGS;
     $lastVisitedTimestamp = isset($my_messaging_settings['last_box_visit']) ? (int) $my_messaging_settings['last_box_visit'] : 0;
     $query = "SELECT SUM(mkdate > :time AND readed = 0) AS num_new,\n                         SUM(readed = 0) AS num_unread,\n                         SUM(readed = 1) AS num_read\n                  FROM message_user\n                  WHERE snd_rec = 'rec' AND user_id = :user_id AND deleted = 0";
     $statement = DBManager::get()->prepare($query);
     $statement->bindValue(':time', $lastVisitedTimestamp);
     $statement->bindValue(':user_id', $GLOBALS['user']->id);
     $statement->execute();
     list($neux, $neum, $altm) = $statement->fetch(PDO::FETCH_NUM);
     $this->setBadgeNumber($neum);
     if ($neux > 0) {
         $tip = sprintf(ngettext('Sie haben %d neue ungelesene Nachricht', 'Sie haben %d neue ungelesene Nachrichten', $neux), $neux);
     } else {
         if ($neum > 1) {
             $tip = sprintf(ngettext('Sie haben %d ungelesene Nachricht', 'Sie haben %d ungelesene Nachrichten', $neum), $neum);
         } else {
             if ($altm > 1) {
                 $tip = sprintf(ngettext('Sie haben %d alte empfangene Nachricht', 'Sie haben %d alte empfangene Nachrichten', $altm), $altm);
             } else {
                 $tip = _('Sie haben keine alten empfangenen Nachrichten');
             }
         }
     }
     $this->setImage(Icon::create('mail', 'navigation', ["title" => $tip]));
 }
Exemple #8
0
 public static function createUdpApplication($config)
 {
     AutoLoad::addRoot(dirname(dirname($config)));
     SysLog::init(UserConfig::getConfig('log'));
     return new YaafUdpServ();
     // return $class;
     //进行路由解析等
 }
 public function __construct()
 {
     parent::__construct();
     if (!is_null(UserConfig::$email_module)) {
         throw new EmailModuleException("You can assign only one email module");
     }
     UserConfig::$email_module = $this;
 }
 /**
  * @param User $model
  * Add new email alerts and delete older
  */
 private function saveEmailAlerts(User $model)
 {
     if (isset($_POST['User'])) {
         UserConfig::model()->deleteAll("userId=" . $model->use_id . " AND configType ='" . UserConfig::TYPE_EMAIL_ALERT . "' AND configKey='" . UserConfig::KEY_EMAIL_ALERT_DEAL_STATUS . "'");
         if (isset($_POST['User']['emailAlertForDealStatus'])) {
             $emailAlerts = $_POST['User']['emailAlertForDealStatus'];
             foreach ($emailAlerts as $k => $v) {
                 if ($v == 1) {
                     $userConfig = new UserConfig();
                     $userConfig->unsetAttributes();
                     $userConfig->userId = $model->use_id;
                     $userConfig->configType = UserConfig::TYPE_EMAIL_ALERT;
                     $userConfig->configKey = UserConfig::KEY_EMAIL_ALERT_DEAL_STATUS;
                     $userConfig->configValue = $k;
                     $userConfig->save();
                 }
             }
         }
     }
 }
Exemple #11
0
 function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     Navigation::activateItem("/pluginmarket/presenting");
     if ($GLOBALS['perm']->have_perm("user")) {
         $config = UserConfig::get($GLOBALS['user']->id);
         $this->last_pluginmarket_visit = $config->getValue("last_pluginmarket_visit") ?: time();
         $_SESSION['last_pluginmarket_visit'] = time();
         $config->store("last_pluginmarket_visit", $_SESSION['last_pluginmarket_visit']);
     }
     PageLayout::addScript($this->plugin->getPluginURL() . "/assets/studiptable.js");
     PageLayout::addScript($this->plugin->getPluginURL() . "/assets/pluginmarket.js");
     $tags_statement = DBManager::get()->prepare("\n            SELECT pluginmarket_tags.tag, COUNT(*) AS number\n            FROM pluginmarket_tags\n                INNER JOIN pluginmarket_plugins ON (pluginmarket_plugins.plugin_id = pluginmarket_tags.plugin_id)\n            WHERE pluginmarket_tags. proposal = '0'\n                AND pluginmarket_plugins.approved = 1\n                AND pluginmarket_plugins.publiclyvisible = 1\n            GROUP BY pluginmarket_tags.tag\n            ORDER BY number DESC, RAND()\n            LIMIT 25\n        ");
     $tags_statement->execute();
     $this->tags = $tags_statement->fetchAll(PDO::FETCH_ASSOC);
     // Set view
     $_SESSION['pluginmarket']['view'] = Request::get('view') ?: $_SESSION['pluginmarket']['view'];
     if (!isset($_SESSION['pluginmarket']['view'])) {
         $_SESSION['pluginmarket']['view'] = 'tiles';
     }
     // Sidebar
     $sidebar = Sidebar::Get();
     // Create search widget
     $searchWidget = new SearchWidget($this->url_for('presenting/all'));
     $searchWidget->addNeedle(_('Suche'), 'search', true);
     $sidebar->addWidget($searchWidget);
     // Create cloud
     $tagWidget = new LinkCloudWidget();
     $tagWidget->setTitle(_("Beliebte Tags"));
     foreach ($this->tags as $tag) {
         $tagWidget->addLink($tag['tag'], $this->url_for('presenting/all', array('tag' => $tag['tag'])), $tag['number']);
     }
     $sidebar->addWidget($tagWidget);
     // Create view widget
     if ($action != 'details') {
         $viewWidget = new ViewsWidget();
         $viewWidget->addLink(_('Kacheln'), URLHelper::getLink('', array('view' => 'tiles')))->setActive($_SESSION['pluginmarket']['view'] == 'tiles');
         $viewWidget->addLink(_('Liste'), $this->url_for('presenting/all', array('view' => 'list')))->setActive($_SESSION['pluginmarket']['view'] == 'list');
         $sidebar->addWidget($viewWidget);
     }
     // Create versionfilter widget
     $versionWidget = new OptionsWidget();
     $versionWidget->setTitle(_('Stud.IP Version'));
     // Create options for all studip versions
     $_SESSION['pluginmarket']['version'] = Request::submitted('version') ? Request::get('version') : $_SESSION['pluginmarket']['version'];
     $options[] = "<option value='" . URLHelper::getLink('', array('version' => 0)) . "'>" . _('Alle Versionen') . "</option>";
     foreach (array_reverse(PluginMarket::getStudipReleases()) as $version) {
         $options[] = "<option value='" . URLHelper::getLink('', array('version' => $version)) . "' " . ($_SESSION['pluginmarket']['version'] == $version ? "SELECTED" : "") . ">{$version}</option>";
     }
     $versionWidget->addElement(new WidgetElement('<select style="width: 100%" onchange="location = this.options[this.selectedIndex].value;">' . join("", $options) . '</select>'));
     // Add checkbox to ignore older releases (use invese logic to be applied on startup)
     $sidebar->addWidget($versionWidget, 'comments');
 }
Exemple #12
0
 protected function _getIncludes()
 {
     $config = array();
     $config['js']['core'] = json_decode($this->getModule('FS')->read(self::INCLUDES_PATH), TRUE);
     $core_css = $this->getModule('FS')->readDir("system/ui/core/interface", TRUE, array('file_type' => 'css', 'path_type' => FS::FILESYSTEM_PATH));
     if ($this->isSession()) {
         $user_config = new UserConfig();
         $ui = $user_config->getConfig('ui', TRUE);
         foreach (array('interface', 'icons') as $value) {
             $this->set_session_value($value, $ui[$value]);
         }
         $user_css = $this->getModule('FS')->readDir("system/ui/" . $this->session['interface'] . "/interface", TRUE, array('file_type' => 'css', 'path_type' => FS::FILESYSTEM_PATH));
         $user_js = [];
         //$this->getModule('FS')->readDir("system/ui/".$this->session['interface']."/interface", TRUE, array('file_type' => 'js', 'path_type' => FS::FILESYSTEM_PATH));
     } else {
         $user_css = $this->getModule('FS')->readDir("system/ui/flatos/interface", TRUE, array('file_type' => 'css', 'path_type' => FS::FILESYSTEM_PATH));
         $user_js = $this->getModule('FS')->readDir("system/ui/flatos/interface", TRUE, array('file_type' => 'js', 'path_type' => FS::FILESYSTEM_PATH));
     }
     $config['css']['core'] = $core_css;
     $config['css']['user'] = $user_css;
     $config['js']['user'] = $user_js;
     return $config;
 }
Exemple #13
0
 function __construct($user = null)
 {
     if ($user instanceof User) {
         $this->user = $user;
     } else {
         $this->user = User::find($user);
     }
     if (!isset($this->user)) {
         $this->user = new User();
         $this->user->user_id = 'nobody';
     }
     $this->cfg = UserConfig::get($this->user->user_id);
     $this->last_online_time = $this->get_last_action();
 }
Exemple #14
0
 /**
  * Show the user configuration for one parameter
  *
  * @param   string $user_id
  * @param   string $field
  *
  * @return  array()
  */
 public static function showUserConfiguration($user_id, $field)
 {
     $uconfig = UserConfig::get($user_id);
     $config = Config::get();
     $data = $config->getMetadata($field);
     if (!count($data)) {
         $data['field'] = $field;
         $data['type'] = 'string';
         $data['description'] = 'missing in table `config`';
     }
     $data['value'] = $uconfig->{$field};
     $data['fullname'] = User::find($user_id)->getFullname();
     return $data;
 }
 public static function set($key, $value)
 {
     if (!User::isLoggedIn()) {
         throw new Exception("User is not logged in.");
     }
     $id = User::getUserID();
     self::$userConfig = null;
     if (is_null($value) || is_string($value) && strlen(trim($value)) == 0) {
         // Just remove the row and let the defaults take over
         return Db::execute("delete from zz_users_config where id = :id and locker = :key", array(":id" => $id, ":key" => $key));
     }
     $value = json_encode($value);
     return Db::execute("insert into zz_users_config (id, locker, content) values (:id, :key, :value)\n                                on duplicate key update content = :value", array(":id" => $id, ":key" => $key, ":value" => $value));
 }
 function down()
 {
     DBManager::get()->execute("ALTER TABLE `event_data` CHANGE `author_id` `autor_id` VARCHAR(32) NOT NULL");
     DBManager::get()->execute("ALTER TABLE `calendar_event` DROP `mkdate`");
     $replace = array('list' => 'showlist', 'day' => 'showday', 'week' => 'showweek', 'month' => 'showmonth', 'year' => 'showyear');
     $default_settings = array('view' => 'week', 'start' => '9', 'end' => '20', 'step_day' => '900', 'step_week' => '1800', 'type_week' => 'LONG', 'delete' => '0', 'step_week_group' => '3600', 'step_day_group' => '3600');
     $res = DBManager::get()->query("SELECT user_id FROM `user_config` WHERE field = 'CALENDAR_SETTINGS'");
     foreach ($res as $row) {
         $config = UserConfig::get($row['user_id']);
         $settings = $config->getValue('CALENDAR_SETTINGS');
         if (isset($settings['view'])) {
             $default_settings['view'] = $replace[$settings['view']];
             $config->store('CALENDAR_SETTINGS', $default_settings);
         }
     }
 }
Exemple #17
0
function check_terms($userid, $_language_path) {

    if (Request::get('i_accept_the_terms') == "yes") {
        UserConfig::get($userid)->store('TERMS_ACCEPTED', 1);
        return;
    }

    if ($GLOBALS['auth']->auth['uid'] != 'nobody' && !empty($GLOBALS['user']) && !$GLOBALS['user']->cfg->getValue('TERMS_ACCEPTED'))
    {
?>

<table align="center" border="0" cellpadding="1" cellspacing="0">
    <tr>
        <td class="table_header_bold">
            <?= Icon::create('door-enter', 'info_alt')->asImg() ?>
            <b><?=_("Nutzungsbedingungen")?></b>
        </td>
    </tr>
    <tr>
        <td class="blank">
        <p><br><?=_("Stud.IP ist ein Open Source Projekt und steht unter der Gnu General Public License (GPL). Das System befindet sich in der ständigen Weiterentwicklung.")?></p>
        <p><?=_("Um den vollen Funktionsumfang von Stud.IP nutzen zu können, müssen Sie sich am System anmelden.")?><br>
        <?=_("Das hat viele Vorzüge:")?></p>
        <ul>
            <li><?=_("Zugriff auf Ihre Daten von jedem internetfähigen Rechner weltweit,")?></li>
            <li><?=_("Anzeige neuer Mitteilungen oder Dateien seit Ihrem letzten Besuch,")?></li>
            <li><?=_("Ein eigenes Profil im System,")?></li>
            <li><?=_("die Möglichkeit anderen Personen Nachrichten zu schicken oder mit ihnen zu chatten,")?></li>
            <li><?=_("und vieles mehr.")?></li>
        </ul>
        <p><?=_("Mit der Anmeldung werden die nachfolgenden Nutzungsbedingungen akzeptiert:")?></p>
        <? include("locale/$_language_path/LC_HELP/pages/nutzung.html"); ?>
        <p align="center">
        <a href="<?= URLHelper::getLink(Request::url(), array('i_accept_the_terms' => 'yes')) ?>"><b><?=_("Ich erkenne die Nutzungsbedingungen an")?></b></a>
        </p>
        <br>
        </td>
    </tr>
</table>

<?php
    include ('lib/include/html_end.inc.php');
    die;
    }
}
Exemple #18
0
 /**
  * Sets up the controller
  *
  * @param String $action Which action shall be invoked
  * @param Array $args Arguments passed to the action method
  */
 public function before_filter(&$action, &$args)
 {
     // Abwärtskompatibilität, erst ab 1.1 bekannt
     if (!isset($GLOBALS['ALLOW_CHANGE_NAME'])) {
         $GLOBALS['ALLOW_CHANGE_NAME'] = TRUE;
     }
     parent::before_filter($action, $args);
     // Ensure user is logged in
     $GLOBALS['auth']->login_if($action !== 'logout' && $GLOBALS['auth']->auth['uid'] === 'nobody');
     // extract username
     $username = Request::username('username', $GLOBALS['user']->username);
     $user = User::findByUsername($username);
     if (!$GLOBALS['perm']->have_profile_perm('user', $user->user_id)) {
         $username = $GLOBALS['user']->username;
     } else {
         $username = $user->username;
         URLHelper::addLinkParam('username', $username);
     }
     $this->about = new about($username, null);
     $this->about->get_user_details();
     if (!$this->about->check) {
         $this->reportErrorWithDetails(_('Zugriff verweigert.'), array(_("Wahrscheinlich ist Ihre Session abgelaufen. Bitte " . "nutzen Sie in diesem Fall den untenstehenden Link, " . "um zurück zur Anmeldung zu gelangen.\n\n" . "Eine andere Ursache kann der Versuch des Zugriffs " . "auf Userdaten, die Sie nicht bearbeiten dürfen, sein. " . "Nutzen Sie den untenstehenden Link, um zurück auf " . "die Startseite zu gelangen."), sprintf(_('%s Hier%s geht es wieder zur Anmeldung beziehungsweise Startseite.'), '<a href="index.php">', '</a>')));
         $this->render_nothing();
         return;
     }
     $this->user = User::findByUsername($username);
     $this->restricted = $GLOBALS['perm']->get_profile_perm($this->user->user_id) !== 'user' && $username !== $GLOBALS['user']->username;
     $this->config = UserConfig::get($this->user->user_id);
     $this->validator = new email_validation_class();
     # Klasse zum Ueberpruefen der Eingaben
     $this->validator->timeout = 10;
     // Default auth plugin to standard
     if (!$this->user->auth_plugin) {
         $this->user->auth_plugin = 'standard';
     }
     PageLayout::addSqueezePackage('settings');
     // Show info message if user is not on his own profile
     if ($username != $GLOBALS['user']->username) {
         $message = sprintf(_('Daten von: %s %s (%s), Status: %s'), htmlReady($this->user->Vorname), htmlReady($this->user->Nachname), $username, $this->user->perms);
         $this->reportInfo($message);
     }
     Sidebar::get()->setImage('sidebar/person-sidebar.png');
     $this->set_layout($GLOBALS['template_factory']->open('layouts/base'));
 }
Exemple #19
0
 public function getGlobals()
 {
     $result = array();
     if (User::isLoggedIn()) {
         $u = User::getUserInfo();
         $config = UserConfig::getAll();
         foreach ($config as $key => $val) {
             $this->addGlobal($result, $key, $val);
         }
         $this->addGlobal($result, 'sessionusername', $u['username']);
         $this->addGlobal($result, 'sessionuserid', $u['id']);
         $this->addGlobal($result, 'sessionadmin', (bool) $u['admin']);
         $this->addGlobal($result, 'sessionmoderator', (bool) $u['moderator']);
     }
     global $mdb;
     $killsLastHour = new RedisTtlCounter('killsLastHour', 3600);
     $this->addGlobal($result, 'killsLastHour', $killsLastHour->count(), 0);
     return $result;
 }
 public function getGlobals()
 {
     global $showAds;
     $result = array();
     if (isset($_SESSION["loggedin"])) {
         $u = User::getUserInfo();
         $config = UserConfig::getAll();
         foreach ($config as $key => $val) {
             $this->addGlobal($result, $key, $val);
         }
         $this->addGlobal($result, "sessionusername", $u["username"]);
         $this->addGlobal($result, "sessionuserid", $u["id"]);
         $this->addGlobal($result, "sessionadmin", (bool) $u["admin"]);
         $this->addGlobal($result, "sessionmoderator", (bool) $u["moderator"]);
     }
     $this->addGlobal($result, "killsLastHour", Storage::retrieve("KillsLastHour", 0));
     $this->addGlobal($result, "showAds", $showAds);
     return $result;
 }
Exemple #21
0
 public function getDailyRegistrations()
 {
     $db = UserConfig::getDB();
     $dailyregs = array();
     if ($stmt = $db->prepare('SELECT regdate, count(*) AS reqs FROM (SELECT CAST(regtime AS DATE) AS regdate, id AS regs FROM ' . UserConfig::$mysql_prefix . 'users u LEFT JOIN ' . UserConfig::$mysql_prefix . 'googlefriendconnect g ON u.id = g.user_id WHERE g.google_id IS NOT NULL GROUP BY id) agg group by agg.regdate')) {
         if (!$stmt->execute()) {
             throw new Exception("Can't execute statement: " . $stmt->error);
         }
         if (!$stmt->bind_result($regdate, $regs)) {
             throw new Exception("Can't bind result: " . $stmt->error);
         }
         while ($stmt->fetch() === TRUE) {
             $dailyregs[] = array('regdate' => $regdate, 'regs' => $regs);
         }
         $stmt->close();
     } else {
         throw new Exception("Can't prepare statement: " . $db->error);
     }
     return $dailyregs;
 }
Exemple #22
0
 /**
  * Returns the formatted list of skip links
  *
  * @return string the formatted list of skip links
  */
 public static function getHTML()
 {
     $html = '';
     if (UserConfig::get($GLOBALS['user']->id)->getValue('SKIPLINKS_ENABLE') && $GLOBALS['auth']->is_authenticated() && sizeof(self::$links)) {
         Navigation::addItem('/skiplinks', new Navigation(''));
         uasort(self::$links, create_function('$a, $b', 'return $a["position"] > $b["position"];'));
         $i = 1;
         $position = 0;
         $overwriteable = false;
         foreach (self::$links as $link) {
             $navigation = new Navigation($link['name'], $link['url']);
             $path = '/skiplinks/' . $i++;
             Navigation::addItem($path, $navigation);
             $position = $link['position'];
             $overwriteable = $link['overwriteable'];
         }
         $navigation = Navigation::getItem('/skiplinks');
         $html = $GLOBALS['template_factory']->render('skiplinks', compact('navigation'));
     }
     return $html;
 }
function aggregatePoints()
{
    $db = UserConfig::getDB();
    if ($db->query('CREATE TEMPORARY TABLE activity_points (
	     activity_id int(2) UNSIGNED NOT NULL,
	     points int(4) UNSIGNED NOT NULL)') === TRUE) {
        $query = 'INSERT INTO activity_points VALUES';
        $pairs = array();
        foreach (UserConfig::$activities as $id => $activity) {
            $pairs[] = "({$id}, " . $activity[1] . ')';
        }
        $query .= ' ' . implode(', ', $pairs);
        if ($db->query($query) === TRUE) {
            if ($db->query('CREATE TEMPORARY TABLE user_activity_points
					SELECT u.id AS user_id, SUM(p.points) AS points
					FROM ' . UserConfig::$mysql_prefix . 'users u
					INNER JOIN ' . UserConfig::$mysql_prefix . 'activity a ON u.id = a.user_id
					INNER JOIN activity_points p ON a.activity_id = p.activity_id
					GROUP BY u.id')) {
                if ($stmt = $db->prepare('UPDATE ' . UserConfig::$mysql_prefix . 'users u
						INNER JOIN user_activity_points up ON u.id = up.user_id
						SET u.points = up.points')) {
                    if (!$stmt->execute()) {
                        throw new Exception("Can't execute statement: " . $stmt->error);
                    }
                    $stmt->close();
                } else {
                    throw new Exception("Can't prepare statement: " . $db->error);
                }
            } else {
                throw new Exception("Can't prepare statement: " . $db->error);
            }
        } else {
            throw new Exception("Can't prepare statement: " . $db->error);
        }
    } else {
        throw new Exception("Can't prepare statement: " . $db->error);
    }
}
Exemple #24
0
 public static function getUserTrackerData()
 {
     $entities = array("character", "corporation", "alliance", "faction", "ship", "item", "system", "region");
     $entlist = array();
     foreach ($entities as $ent) {
         Db::execute("update zz_users_config set locker = 'tracker_{$ent}' where locker = '{$ent}'");
         $result = UserConfig::get("tracker_{$ent}");
         $part = array();
         if ($result != null) {
             foreach ($result as $row) {
                 switch ($ent) {
                     case "system":
                         $row["solarSystemID"] = $row["id"];
                         $row["solarSystemName"] = $row["name"];
                         $sunType = Db::queryField("SELECT sunTypeID FROM ccp_systems WHERE solarSystemID = :id", "sunTypeID", array(":id" => $row["id"]));
                         $row["sunTypeID"] = $sunType;
                         break;
                     case "item":
                         $row["typeID"] = $row["id"];
                         $row["shipName"] = $row["name"];
                         break;
                     case "ship":
                         $row["shipTypeID"] = $row["id"];
                         $row["{$ent}Name"] = $row["name"];
                         break;
                     default:
                         $row["{$ent}ID"] = $row["id"];
                         $row["{$ent}Name"] = $row["name"];
                         break;
                 }
                 $part[] = $row;
             }
         }
         $entlist[$ent] = $part;
     }
     return $entlist;
 }
Exemple #25
0
 /**
  * returns schedule for a given user and semester
  *
  * @get /user/:user_id/schedule/:semester_id
  * @get /user/:user_id/schedule
  */
 public function getSchedule($user_id, $semester_id = NULL)
 {
     if ($user_id !== $GLOBALS['user']->id) {
         $this->error(401);
     }
     $semdata = new \SemesterData();
     $current_semester = isset($semester_id) ? $semdata->getSemesterData($semester_id) : $semdata->getCurrentSemesterData();
     if (!$current_semester) {
         $this->notFound('No such semester.');
     }
     $schedule_settings = \UserConfig::get($user_id)->SCHEDULE_SETTINGS;
     $days = $schedule_settings['glb_days'];
     $entries = \CalendarScheduleModel::getEntries($user_id, $current_semester, $schedule_settings['glb_start_time'], $schedule_settings['glb_end_time'], $days, $visible = false);
     $json = array();
     foreach ($entries as $number_of_day => $schedule_of_day) {
         $entries = array();
         foreach ($schedule_of_day->entries as $entry) {
             $entries[$entry['id']] = self::entryToJson($entry);
         }
         $json[$number_of_day + 1] = $entries;
     }
     $this->etag(md5(serialize($json)));
     return $json;
 }
Exemple #26
0
 public function overview_action()
 {
     if (Navigation::hasItem("/lernmarktplatz/overview")) {
         Navigation::activateItem("/lernmarktplatz/overview");
     }
     $tag_matrix_entries_number = 9;
     $tag_subtags_number = 6;
     if (Request::get("disable_maininfo")) {
         UserConfig::get($GLOBALS['user']->id)->store("LERNMARKTPLATZ_DISABLE_MAININFO", 1);
         $this->redirect("market/overview");
     }
     if (Request::get("tags")) {
         $tags = $this->tag_history = explode(",", Request::get("tags"));
         $this->without_tags = array();
         $tag_to_search_for = array_pop($tags);
         foreach (LernmarktplatzTag::findBest($tag_matrix_entries_number, true) as $related_tag) {
             if ($related_tag['tag_hash'] !== $this->tag_history[0]) {
                 $this->without_tags[] = $related_tag['tag_hash'];
             }
         }
         //array_shift($this->tag_history);
         foreach ($tags as $tag) {
             foreach (LernmarktplatzTag::findRelated($tag, $this->without_tags, $tag_subtags_number, true) as $related_tag) {
                 $this->without_tags[] = $related_tag['tag_hash'];
             }
         }
         $this->more_tags = LernmarktplatzTag::findRelated($tag_to_search_for, $this->without_tags, $tag_subtags_number);
         $this->materialien = LernmarktplatzMaterial::findByTagHash($tag_to_search_for);
     } elseif (Request::get("search")) {
         $this->materialien = LernmarktplatzMaterial::findByText(Request::get("search"));
     } elseif (Request::get("tag")) {
         $this->materialien = LernmarktplatzMaterial::findByTag(Request::get("tag"));
     } else {
         $this->best_nine_tags = LernmarktplatzTag::findBest($tag_matrix_entries_number);
     }
 }
Exemple #27
0
 /**
  * Sets the background-color of the notification-number to blue, so it does
  * not annoy the user anymore. But he/she is still able to see the notificaion-list.
  * Just sets a unix-timestamp in the user-config NOTIFICATIONS_SEEN_LAST_DATE.
  */
 public function notifications_seen_action()
 {
     UserConfig::get($GLOBALS['user']->id)->store('NOTIFICATIONS_SEEN_LAST_DATE', time());
     $this->render_text(time());
 }
Exemple #28
0
    $type = $map[$key]['column'];
    $detail = Info::getInfoDetails("{$type}ID", $id);
    if (isset($detail['valid']) && $detail['valid'] == false) {
        $app->notFound();
    }
} catch (Exception $ex) {
    $app->render('error.html', array('message' => "There was an error fetching information for the {$key} you specified."));
    return;
}
$pageName = isset($detail[$map[$key]['column'] . 'Name']) ? $detail[$map[$key]['column'] . 'Name'] : '???';
if ($pageName == '???' && !$mdb->exists('information', ['id' => $id])) {
    return $app->render('404.html', array('message' => 'This entity is not in our database.'), 404);
    die;
}
$columnName = $map[$key]['column'] . 'ID';
$mixedKills = $pageType == 'overview' && $map[$key]['mixed'] && UserConfig::get('mixKillsWithLosses', true);
$mixed = $pageType == 'overview' ? Kills::getKills($parameters) : array();
$kills = $pageType == 'kills' ? Kills::getKills($parameters) : array();
$losses = $pageType == 'losses' ? Kills::getKills($parameters) : array();
if ($pageType != 'solo' || $key == 'faction') {
    $soloKills = array();
    //$soloCount = 0;
} else {
    $soloParams = $parameters;
    if (!isset($parameters['kills']) || !isset($parameters['losses'])) {
        $soloParams['mixed'] = true;
    }
    $soloKills = Kills::getKills($soloParams);
}
//$soloPages = ceil($soloCount / $limit);
$solo = Kills::mergeKillArrays($soloKills, array(), $limit, $columnName, $id);
Exemple #29
0
 public function enableForUser($user)
 {
     if (!$this->enabled) {
         return;
     }
     // if feature is forced, return true
     if ($this->enabled_for_all) {
         return;
     }
     // now, let's see if user has it enabled
     $db = UserConfig::getDB();
     $userid = $user->getID();
     if ($stmt = $db->prepare('REPLACE INTO ' . UserConfig::$mysql_prefix . 'user_features (user_id, feature_id) VALUES (?, ?)')) {
         if (!$stmt->bind_param('ii', $userid, $this->id)) {
             throw new Exception("Can't bind parameter" . $stmt->error);
         }
         if (!$stmt->execute()) {
             throw new Exception("Can't execute statement: " . $stmt->error);
         }
         $stmt->close();
     } else {
         throw new Exception("Can't prepare statement: " . $db->error);
     }
 }
Exemple #30
-1
        }
    }
    $ddcombine = Util::getPost("ddcombine");
    if (isset($ddcombine)) {
        UserConfig::set("ddcombine", $ddcombine);
    }
    $ddmonthyear = Util::getPost("ddmonthYear");
    if (isset($ddmonthyear)) {
        UserConfig::set("ddmonthyear", $ddmonthyear);
    }
    $useSummaryAccordion = Util::getPost("useSummaryAccordion");
    if (isset($useSummaryAccordion)) {
        UserConfig::set("useSummaryAccordion", $useSummaryAccordion);
    }
}
$data["entities"] = Account::getUserTrackerData();
$data["themes"] = Util::bootstrapThemes();
$data["viewthemes"] = Util::themesAvailable();
$data["apiKeys"] = Api::getKeys($userID);
$data["apiChars"] = Api::getCharacters($userID);
$charKeys = Api::getCharacterKeys($userID);
$charKeys = Info::addInfo($charKeys);
$data["apiCharKeys"] = $charKeys;
$data["userInfo"] = User::getUserInfo();
$data["currentTheme"] = UserConfig::get("theme", "default");
$data["timeago"] = UserConfig::get("timeago");
$data["ddcombine"] = UserConfig::get("ddcombine");
$data["ddmonthyear"] = UserConfig::get("ddmonthyear");
$data["useSummaryAccordion"] = UserConfig::get("useSummaryAccordion");
$data["sessions"] = User::getSessions($userID);
$app->render("account.html", array("data" => $data, "message" => $error, "key" => $key, "reqid" => $reqid));