/**
  * Executes the cronjob.
  *
  * @param mixed $last_result What the last execution of this cronjob
  *                           returned.
  * @param Array $parameters Parameters for this cronjob instance which
  *                          were defined during scheduling.
  *                          Only valid parameter at the moment is
  *                          "verbose" which toggles verbose output while
  *                          purging the cache.
  */
 public function execute($last_result, $parameters = array())
 {
     global $user;
     $cli_user = $user;
     $notification = new ModulesNotification();
     $query = "SELECT DISTINCT user_id FROM seminar_user su WHERE notification <> 0";
     if (get_config('DEPUTIES_ENABLE')) {
         $query .= " UNION SELECT DISTINCT user_id FROM deputies WHERE notification <> 0";
     }
     $rs = DBManager::get()->query($query);
     while ($r = $rs->fetch()) {
         $user = new Seminar_User($r["user_id"]);
         if ($user->locked) {
             continue;
         }
         setTempLanguage('', $user->preferred_language);
         $to = $user->email;
         $title = "[" . $GLOBALS['UNI_NAME_CLEAN'] . "] " . _("Tägliche Benachrichtigung");
         $mailmessage = $notification->getAllNotifications($user->id);
         $ok = false;
         if ($mailmessage) {
             if ($user->cfg->getValue('MAIL_AS_HTML')) {
                 $smail = new StudipMail();
                 $ok = $smail->setSubject($title)->addRecipient($to)->setBodyHtml($mailmessage['html'])->setBodyText($mailmessage['text'])->send();
             } else {
                 $ok = StudipMail::sendMessage($to, $title, $mailmessage['text']);
             }
         }
         UserConfig::set($user->id, null);
         if ($ok !== false && $parameters['verbose']) {
             echo $user->username . ':' . $ok . "\n";
         }
     }
     $user = $cli_user;
 }
示例#2
0
文件: ForumAbo.php 项目: ratbird/hope
 /**
  * send out the notification messages for the passed topic. The contents
  * and a link directly to the topic are added to the messages.
  * 
  * @param string $topic_id
  */
 static function notify($topic_id)
 {
     // send message to all abo-users
     $db = DBManager::get();
     $messaging = new ForumBulkMail();
     // $messaging = new Messaging();
     // get all parent topic-ids, to find out which users to notify
     $path = ForumEntry::getPathToPosting($topic_id);
     // fetch all users to notify, exlcude current user
     $stmt = $db->prepare("SELECT DISTINCT user_id\n            FROM forum_abo_users\n            WHERE topic_id IN (:topic_ids)\n                AND user_id != :user_id");
     $stmt->bindParam(':topic_ids', array_keys($path), StudipPDO::PARAM_ARRAY);
     $stmt->bindParam(':user_id', $GLOBALS['user']->id);
     $stmt->execute();
     // get details for topic
     $topic = ForumEntry::getConstraints($topic_id);
     $template_factory = new Flexi_TemplateFactory(dirname(__FILE__) . '/../views');
     $template = $template_factory->open('index/_mail_notification');
     // notify users
     while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $user_id = $data['user_id'];
         // create subject and content
         setTempLanguage(get_userid($user_id));
         // check if user wants an email for all or selected messages only
         $force_email = false;
         if ($messaging->user_wants_email($user_id)) {
             $force_email = true;
         }
         $parent_id = ForumEntry::getParentTopicId($topic['topic_id']);
         setTempLanguage($data['user_id']);
         $notification = sprintf(_("%s hat einen Beitrag geschrieben"), $topic['anonymous'] ? _('Anonym') : $topic['author']);
         restoreLanguage();
         PersonalNotifications::add($user_id, UrlHelper::getUrl('plugins.php/coreforum/index/index/' . $topic['topic_id'] . '#' . $topic['topic_id'], array('cid' => $topic['seminar_id']), true), $notification, "forumposting_" . $topic['topic_id'], Icon::create('forum', 'clickable')->asImagePath(40));
         if ($force_email) {
             $title = implode(' >> ', ForumEntry::getFlatPathToPosting($topic_id));
             $subject = addslashes(_('[Forum]') . ' ' . ($title ?: _('Neuer Beitrag')));
             $htmlMessage = $template->render(compact('user_id', 'topic', 'path'));
             $textMessage = trim(kill_format($htmlMessage));
             $userWantsHtml = UserConfig::get($user_id)->getValue('MAIL_AS_HTML');
             StudipMail::sendMessage(User::find($user_id)->email, $subject, addslashes($textMessage), $userWantsHtml ? $htmlMessage : null);
         }
         restoreLanguage();
     }
     $messaging->bulkSend();
 }
示例#3
0
文件: single.php 项目: ratbird/hope
 public function share_action($range_id = null)
 {
     $this->range_id = $range_id ?: $this->range_id;
     $this->calendar = new SingleCalendar($this->range_id);
     $this->short_id = null;
     if ($this->calendar->havePermission(Calendar::PERMISSION_OWN)) {
         if (Request::submitted('delete_id')) {
             CSRFProtection::verifySecurityToken();
             IcalExport::deleteKey($GLOBALS['user']->id);
             PageLayout::postMessage(MessageBox::success(_('Die Adresse, unter der Ihre Termine abrufbar sind, wurde gelöscht')));
         }
         if (Request::submitted('new_id')) {
             CSRFProtection::verifySecurityToken();
             $this->short_id = IcalExport::setKey($GLOBALS['user']->id);
             PageLayout::postMessage(MessageBox::success(_('Eine Adresse, unter der Ihre Termine abrufbar sind, wurde erstellt.')));
         } else {
             $this->short_id = IcalExport::getKeyByUser($GLOBALS['user']->id);
         }
         if (Request::submitted('submit_email')) {
             $email_reg_exp = '/^([-.0-9=?A-Z_a-z{|}~])+@([-.0-9=?A-Z_a-z{|}~])+\\.[a-zA-Z]{2,6}$/i';
             if (preg_match($email_reg_exp, Request::get('email')) !== 0) {
                 $subject = '[' . get_config('UNI_NAME_CLEAN') . ']' . _('Exportadresse für Ihre Termine');
                 $text .= _("Diese Email wurde vom Stud.IP-System verschickt. Sie können\n            auf diese Nachricht nicht antworten.") . "\n\n";
                 $text .= _('Über diese Adresse erreichen Sie den Export für Ihre Termine:') . "\n\n";
                 $text .= $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'dispatch.php/ical/index/' . IcalExport::getKeyByUser($GLOBALS['user']->id);
                 StudipMail::sendMessage(Request::get('email'), $subject, $text);
                 PageLayout::postMessage(MessageBox::success(_('Die Adresse wurde verschickt!')));
             } else {
                 PageLayout::postMessage(MessageBox::error(_('Bitte geben Sie eine gültige Email-Adresse an.')));
             }
             $this->short_id = IcalExport::getKeyByUser($GLOBALS['user']->id);
         }
     }
     PageLayout::setTitle($this->getTitle($this->calendar, _('Kalender teilen oder einbetten')));
     $this->createSidebar('share', $this->calendar);
     $this->createSidebarFilter();
 }
 /**
  * This sends an email to the user to recognize him/her that he/she was 
  * mentioned in a blubber.
  * @param type $posting 
  */
 public function mention($posting)
 {
     $url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . "plugins.php/blubber/streams/thread/" . $posting['root_id'] . ($posting['context_type'] === "course" ? '?cid=' . $posting['Seminar_id'] : "");
     $message = sprintf(_("%s hat Sie in einem Blubber erwähnt. Zum Beantworten klicken auf Sie auf folgenen Link:\n\n%s\n"), get_fullname(), $url);
     StudipMail::sendMessage($this['mail_identifier'], _("Sie wurden erwähnt."), $message);
 }
示例#5
0
 /**
  * Change an existing user password
  *
  * @param string $password
  * @return bool change successful?
  */
 function changePassword($password)
 {
     global $perm;
     $this->user_data['auth_user_md5.password'] = self::getPwdHasher()->HashPassword($password);
     $this->storeToDatabase();
     $this->msg .= "msg§" . _("Das Passwort wurde neu gesetzt.") . "§";
     // include language-specific subject and mailbody
     $user_language = getUserLanguagePath($this->user_data['auth_user_md5.user_id']);
     $Zeit = date("H:i:s, d.m.Y", time());
     include "locale/{$user_language}/LC_MAILS/password_mail.inc.php";
     // send mail
     StudipMail::sendMessage($this->user_data['auth_user_md5.Email'], $subject, $mailbody);
     return TRUE;
 }
示例#6
0
function edit_email($user, $email, $force = False)
{
    $msg = '';
    $query = "SELECT email, username, auth_plugin\n              FROM auth_user_md5\n              WHERE user_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($user->user_id));
    $row = $statement->fetch(PDO::FETCH_ASSOC);
    $email_cur = $row['email'];
    $username = $row['username'];
    $auth_plugin = $row['auth_plugin'];
    if ($email_cur == $email && !$force) {
        return array(True, $msg);
    }
    if (StudipAuthAbstract::CheckField("auth_user_md5.Email", $auth_plugin) || LockRules::check($user->user_id, 'email')) {
        return array(False, $msg);
    }
    if (!$GLOBALS['ALLOW_CHANGE_EMAIL']) {
        return array(False, $msg);
    }
    $validator = new email_validation_class();
    ## Klasse zum Ueberpruefen der Eingaben
    $validator->timeout = 10;
    $REMOTE_ADDR = $_SERVER["REMOTE_ADDR"];
    $Zeit = date("H:i:s, d.m.Y", time());
    // accept only registered domains if set
    $email_restriction = trim(get_config('EMAIL_DOMAIN_RESTRICTION'));
    if (!$validator->ValidateEmailAddress($email, $email_restriction)) {
        if ($email_restriction) {
            $email_restriction_msg_part = '';
            $email_restriction_parts = explode(',', $email_restriction);
            for ($email_restriction_count = 0; $email_restriction_count < count($email_restriction_parts); $email_restriction_count++) {
                if ($email_restriction_count == count($email_restriction_parts) - 1) {
                    $email_restriction_msg_part .= '@' . trim($email_restriction_parts[$email_restriction_count]) . '<br>';
                } else {
                    if (($email_restriction_count + 1) % 3) {
                        $email_restriction_msg_part .= '@' . trim($email_restriction_parts[$email_restriction_count]) . ', ';
                    } else {
                        $email_restriction_msg_part .= '@' . trim($email_restriction_parts[$email_restriction_count]) . ',<br>';
                    }
                }
            }
            $msg .= 'error§' . sprintf(_("Die E-Mail-Adresse fehlt, ist falsch geschrieben oder gehört nicht zu folgenden Domains:%s"), '<br>' . $email_restriction_msg_part);
        } else {
            $msg .= "error§" . _("Die E-Mail-Adresse fehlt oder ist falsch geschrieben!") . "§";
        }
        return array(False, $msg);
        // E-Mail syntaktisch nicht korrekt oder fehlend
    }
    if (!$validator->ValidateEmailHost($email)) {
        // Mailserver nicht erreichbar, ablehnen
        $msg .= "error§" . _("Der Mailserver ist nicht erreichbar. Bitte überprüfen Sie, ob Sie E-Mails mit der angegebenen Adresse verschicken können!") . "§";
        return array(False, $msg);
    } else {
        // Server ereichbar
        if (!$validator->ValidateEmailBox($email)) {
            // aber user unbekannt. Mail an abuse!
            StudipMail::sendAbuseMessage("edit_about", "Emailbox unbekannt\n\nUser: "******"\nEmail: {$email}\n\nIP: {$REMOTE_ADDR}\nZeit: {$Zeit}\n");
            $msg .= "error§" . _("Die angegebene E-Mail-Adresse ist nicht erreichbar. Bitte überprüfen Sie Ihre Angaben!") . "§";
            return array(False, $msg);
        }
    }
    $query = "SELECT Vorname, Nachname\n              FROM auth_user_md5\n              WHERE Email = ? AND user_id != ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($email, $user->user_id));
    $row = $statement->fetch(PDO::FETCH_ASSOC);
    if ($row) {
        $msg .= "error§" . sprintf(_("Die angegebene E-Mail-Adresse wird bereits von einem anderen Benutzer (%s %s) verwendet. Bitte geben Sie eine andere E-Mail-Adresse an."), htmlReady($row['Vorname']), htmlReady($row['Nachname'])) . "§";
        return array(False, $msg);
    }
    // This already moved to the controller
    //    $query = "UPDATE auth_user_md5 SET Email = ? WHERE user_id = ?";
    //    $statement = DBManager::get()->prepare($query);
    //    $statement->execute(array($email, $uid));
    if (StudipAuthAbstract::CheckField("auth_user_md5.validation_key", $auth_plugin)) {
        $msg .= "msg§" . _("Ihre E-Mail-Adresse wurde geändert!") . "§";
        return array(True, $msg);
    } else {
        // auth_plugin does not map validation_key (what if...?)
        // generate 10 char activation key
        $key = '';
        mt_srand((double) microtime() * 1000000);
        for ($i = 1; $i <= 10; $i++) {
            $temp = mt_rand() % 36;
            if ($temp < 10) {
                $temp += 48;
            } else {
                $temp += 87;
            }
            // a = chr(97), z = chr(122)
            $key .= chr($temp);
        }
        $user->validation_key = $key;
        $activatation_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'activate_email.php?uid=' . $user->user_id . '&key=' . $user->validation_key;
        // include language-specific subject and mailbody with fallback to german
        $lang = $GLOBALS['_language_path'];
        // workaround
        if ($lang == '') {
            $lang = 'de';
        }
        include_once "locale/{$lang}/LC_MAILS/change_self_mail.inc.php";
        $mail = StudipMail::sendMessage($email, $subject, $mailbody);
        if (!$mail) {
            return array(True, $msg);
        }
        $query = "UPDATE auth_user_md5 SET validation_key = ? WHERE user_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($user->validation_key, $user->user_id));
        $msg .= "info§<b>" . sprintf(_('An Ihre neue E-Mail-Adresse <b>%s</b> wurde ein Aktivierungslink geschickt, dem Sie folgen müssen bevor Sie sich das nächste mal einloggen können.'), $email) . '</b>§';
        log_event("USER_NEWPWD", $user->user_id);
        // logging
    }
    return array(True, $msg);
}
示例#7
0
    function setPassword () {

        // Can we reach the email?
        if (!$this->checkMail($this->user_data['auth_user_md5.Email'])) {
            return FALSE;
        }

        $password = $this->generate_password(6);
        $this->user_data['auth_user_md5.password'] = self::getPwdHasher()->HashPassword($password);

        if (!$this->storeToDatabase()) {
            $this->msg .= "error§" . _("Die Änderung konnte nicht in die Datenbank geschrieben werden.") . "§";
            return FALSE;
        }

        $this->msg .= "msg§" . sprintf(_("Passwort von Benutzer \"%s\" neu gesetzt."), $this->user_data['auth_user_md5.username']) . "§";

        // include language-specific subject and mailbody
        $user_language = getUserLanguagePath($this->user_data['auth_user_md5.user_id']);
        include("locale/$user_language/LC_MAILS/password_mail.inc.php");

        // send mail
        StudipMail::sendMessage($this->user_data['auth_user_md5.Email'], $subject, $mailbody);

        log_event("USER_NEWPWD",$this->user_data['auth_user_md5.user_id']);
        return TRUE;

    }