コード例 #1
0
ファイル: ForumBulkMail.php プロジェクト: ratbird/hope
 /**
  * Overwrites the parent method. This method combines messages with the same
  * content and prepares them for sending them as a mail with multiple 
  * recepients instead of one mail for each recipient.
  * The actual sending task is done bulkSend().
  * 
  * @global object $user
  * 
  * @param string $rec_user_id  user_id of recipient
  * @param string $snd_user_id  user_id of sender
  * @param string $message      the message
  * @param string $subject      subject for the message
  * @param string $message_id   the message_id in the database
  */
 function sendingEmail($rec_user_id, $snd_user_id, $message, $subject, $message_id)
 {
     global $user;
     $db4 = new DB_Seminar("SELECT user_id, Email FROM auth_user_md5 WHERE user_id = '{$rec_user_id}';");
     $db4->next_record();
     if ($to = $db4->f("Email")) {
         $rec_fullname = 'Sie';
         setTempLanguage($db4->f("user_id"));
         if (empty($this->bulk_mail[md5($message)][getenv('LANG')])) {
             $title = "[Stud.IP - " . $GLOBALS['UNI_NAME_CLEAN'] . "] " . stripslashes(kill_format(str_replace(array("\r", "\n"), '', $subject)));
             if ($snd_user_id != "____%system%____") {
                 $snd_fullname = get_fullname($snd_user_id);
                 $db4->query("SELECT Email FROM auth_user_md5 WHERE user_id = '{$user->id}'");
                 $db4->next_record();
                 $reply_to = $db4->f("Email");
             }
             $template = $GLOBALS['template_factory']->open('mail/text');
             $template->set_attribute('message', kill_format(stripslashes($message)));
             $template->set_attribute('rec_fullname', $rec_fullname);
             $mailmessage = $template->render();
             $template = $GLOBALS['template_factory']->open('mail/html');
             $template->set_attribute('lang', getUserLanguagePath($rec_user_id));
             $template->set_attribute('message', stripslashes($message));
             $template->set_attribute('rec_fullname', $rec_fullname);
             $mailhtml = $template->render();
             $this->bulk_mail[md5($message)][getenv('LANG')] = array('text' => $mailmessage, 'html' => $mailhtml, 'title' => $title, 'reply_to' => $reply_to, 'message_id' => $message_id, 'users' => array());
         }
         $this->bulk_mail[md5($message)][getenv('LANG')]['users'][$db4->f('user_id')] = $to;
         restoreLanguage();
     }
 }
コード例 #2
0
 function getAllTreeLevelContent(&$tree, $start_item_id, $max_level, $level = 0)
 {
     if (($num_kids = $tree->getNumKids($start_item_id)) && $level <= $max_level) {
         $level++;
         if ($this->config->getValue('SelectSubjectAreas', 'selectallsubjectareas')) {
             $kids = $tree->getKids($start_item_id);
         } else {
             if (is_array($this->config->getValue('SelectSubjectAreas', 'subjectareasselected'))) {
                 if ($this->config->getValue('SelectSubjectAreas', 'reverseselection')) {
                     $kids = array_diff($tree->getKids($start_item_id), $this->config->getValue('SelectSubjectAreas', 'subjectareasselected'));
                 } else {
                     $kids = array_intersect($tree->getKids($start_item_id), $this->config->getValue('SelectSubjectAreas', 'subjectareasselected'));
                 }
             } else {
                 return false;
             }
         }
         $count = 0;
         foreach ($kids as $kid) {
             $num_entries = $tree->getNumEntries($kid, true);
             if (!($this->config->getValue('Main', 'disableemptylevels') && $num_entries == 0)) {
                 /*
                 if ($tree->isModuleItem($kid) && $studienmodulmanagement = PluginEngine::getPlugin('StudienmodulManagement')) {
                     $info = 'An dieser Stelle nicht verwendet';
                 } else {
                 */
                 if (trim($tree->tree_data[$kid]['info'])) {
                     $info = kill_format(trim($tree->tree_data[$kid]['info']));
                 } else {
                     $info = '';
                     $content[$count]['SUBLEVEL' . $level]['SUBLEVEL_NO_INFO_' . $level] = true;
                 }
                 //  }
                 $level_content = array('SUBLEVEL_NAME_' . $level => ExternModule::ExtHtmlReady($tree->tree_data[$kid]['name']), 'SUBLEVEL_COURSE_COUNT_' . $level => $num_entries, 'SUBLEVEL_NO_' . $level => $count + 1, 'SUBLEVEL_INFO_' . $level => $info);
                 $content['SUBLEVEL_' . $level][$count]['SUBLEVEL_RESULT_' . $level] = $this->elements['TemplateResult']->toString(array('content' => $this->getContentResult($kid), 'subpart' => 'RESULT'));
                 if ($this->config->getValue('LinkInternShowCourses', 'config') && $tree->getNumEntries($kid, false)) {
                     $content['SUBLEVEL_' . $level][$count]['LINK_TO_COURSES_' . $level] = $level_content;
                     $content['SUBLEVEL_' . $level][$count]['LINK_TO_COURSES_' . $level]['SUBLEVEL-HREF_SHOW_COURSES_' . $level] = $this->getLinkToSelf(array('start_item_id' => $kid, 'show_result' => '1', 'withkids' => '1', 'do_search' => '0'), true, 'LinkInternShowCourses');
                     $content['SUBLEVEL_' . $level][$count]['NO_LINK_TO_COURSES_' . $level]['SUBLEVEL-HREF_' . $level] = $this->getLinkToSelf(array('start_item_id' => $kid, 'show_result' => '1', 'withkids' => '1', 'do_search' => '0'), true, 'LinkInternTree');
                     $content['SUBLEVEL_' . $level][$count]['NO_LINK_TO_COURSES_' . $level] = false;
                 } else {
                     $content['SUBLEVEL_' . $level][$count]['NO_LINK_TO_COURSES_' . $level] = $level_content;
                     $content['SUBLEVEL_' . $level][$count]['NO_LINK_TO_COURSES_' . $level]['SUBLEVEL-HREF_' . $level] = $this->getLinkToSelf(array('start_item_id' => $kid, 'show_result' => '1', 'withkids' => '1', 'do_search' => '0'), true, 'LinkInternTree');
                     $content['SUBLEVEL_' . $level][$count]['LINK_TO_COURSES_' . $level] = false;
                 }
                 if ($sublevel = $this->getAllTreeLevelContent($tree, $kid, $max_level, $level)) {
                     $content['SUBLEVEL_' . $level][$count]['SUBLEVELS_' . ($level + 1)] = $sublevel;
                 }
                 $count++;
             }
         }
         return $content;
     }
     return false;
 }
コード例 #3
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();
 }
コード例 #4
0
ファイル: messaging.inc.php プロジェクト: ratbird/hope
 /**
  *
  * @param $rec_user_id
  * @param $snd_user_id
  * @param $message
  * @param $subject
  * @param $message_id
  */
 function sendingEmail($rec_user_id, $snd_user_id, $message, $subject, $message_id)
 {
     $receiver = User::find($rec_user_id);
     $to = $receiver->Email;
     // do not try to send mails to users without a mail address
     if (!$to) {
         return;
     }
     $rec_fullname = $receiver->getFullName();
     setTempLanguage($rec_user_id);
     $title = "[Stud.IP - " . $GLOBALS['UNI_NAME_CLEAN'] . "] " . kill_format(str_replace(array("\r", "\n"), '', $subject));
     if ($snd_user_id != "____%system%____") {
         $sender = User::find($snd_user_id);
         $snd_fullname = $sender->getFullName();
         $reply_to = $sender->Email;
     }
     $template = $GLOBALS['template_factory']->open('mail/text');
     $template->set_attribute('message', kill_format($message));
     $template->set_attribute('rec_fullname', $rec_fullname);
     $mailmessage = $template->render();
     $template = $GLOBALS['template_factory']->open('mail/html');
     $template->set_attribute('lang', getUserLanguagePath($rec_user_id));
     $template->set_attribute('message', $message);
     $template->set_attribute('rec_fullname', $rec_fullname);
     $mailhtml = $template->render();
     restoreLanguage();
     // Now, let us send the message
     $mail = new StudipMail();
     $mail->setSubject($title)->addRecipient($to, $rec_fullname)->setReplyToEmail('')->setBodyText($mailmessage);
     if (strlen($reply_to)) {
         $mail->setSenderEmail($reply_to)->setSenderName($snd_fullname);
     }
     $user_cfg = UserConfig::get($rec_user_id);
     if ($user_cfg->getValue('MAIL_AS_HTML')) {
         $mail->setBodyHtml($mailhtml);
     }
     if ($GLOBALS['ENABLE_EMAIL_ATTACHMENTS']) {
         foreach (get_message_attachments($message_id) as $attachment) {
             $mail->addStudipAttachment($attachment['dokument_id']);
         }
     }
     if (!get_config("MAILQUEUE_ENABLE")) {
         $mail->send();
     } else {
         MailQueueEntry::add($mail, $message_id, $rec_user_id);
     }
 }
コード例 #5
0
 function getSemPath()
 {
     if ($parents = $this->tree->getParents($this->start_item_id)) {
         for ($i = count($parents) - 1; $i >= 0; --$i) {
             $ret .= "&nbsp;&gt;&nbsp;<a href=\"" . URLHelper::getLink($this->getSelf("start_item_id={$parents[$i]}", false)) . "\">" . htmlReady($this->tree->tree_data[$parents[$i]]["name"]) . "</a>";
         }
     }
     if ($this->start_item_id == "root") {
         $ret = "&nbsp;&gt;&nbsp;<a href=\"" . URLHelper::getLink($this->getSelf("start_item_id=root", false)) . "\">" . htmlReady($this->tree->root_name) . "</a>";
     } else {
         $ret .= "&nbsp;&gt;&nbsp;<a href=\"" . URLHelper::getLink($this->getSelf("start_item_id={$this->start_item_id}", false)) . "\">" . htmlReady($this->tree->tree_data[$this->start_item_id]["name"]) . "</a>";
     }
     $ret .= "&nbsp;<a href=\"#\" " . tooltip(kill_format($this->getTooltip($this->start_item_id)), false, true) . ">";
     $ret .= Icon::create('info-circle', 'inactive')->asImg();
     $ret .= "</a>";
     return $ret;
 }
コード例 #6
0
ファイル: ForumEntry.php プロジェクト: ratbird/hope
 /**
  * calls Stud.IP's kill_format and additionally removes any found smiley-tag
  *
  * @param string $text the text to parse
  * @return string the text without format-tags and without smileys
  */
 static function killFormat($text)
 {
     $text = kill_format($text);
     // find stuff which is enclosed between to colons
     preg_match('/:.*:/U', $text, $matches);
     // remove the match if it is a smiley
     foreach ($matches as $match) {
         if (Smiley::getByName($match) || Smiley::getByShort($match)) {
             $text = str_replace($match, '', $text);
         }
     }
     return $text;
 }
コード例 #7
0
ファイル: new.php プロジェクト: ratbird/hope
            // load metadata of plugin
            $plugin = $sem_class->getModule($key);
            $info = $plugin->getMetadata();
            ?>
            <label>
                <input name="groupplugin[<?php 
echo $key;
?>
]" type="checkbox" <?php 
echo $this->flash['request']['groupplugin'][$key] ? 'checked="checked"' : '';
?>
> <?php 
echo htmlReady($name);
?>
                <?php 
echo isset($info['description']) ? tooltipIcon(kill_format($info['description'])) : "";
?>
            </label><br>
        <? endif ?>
    <? endforeach; ?>
  </td>
</tr>

<tr>
  <td style='text-align:right;'></td>
</tr>

<tr>
  <td style='text-align:right;'><label for="groupaccess"><?php 
echo _("Zugang:");
?>
コード例 #8
0
 function getInfoIcon($item_id)
 {
     if (is_object($this->studienmodulmanagement) && $this->tree->isModuleItem($item_id)) {
         $nav = $this->studienmodulmanagement->getModuleInfoNavigation($item_id, SemesterData::GetSemesterIdByIndex($this->tree->sem_number[0]));
         if ($nav->isVisible(true)) {
             $ret = '<a class="module-info" href="' . URLHelper::getLink($nav->getURL()) . '">';
             $ret .= $nav->getImage()->asImg($nav->getLinkAttributes());
             $ret .= '<span>' . htmlready($nav->getTitle()) . '</span>';
             $ret .= '</a>';
         }
     } else {
         if ($item_id == "root") {
             $info = $this->root_content ? $this->root_content : _("Keine weitere Info vorhanden");
         } else {
             $info = $this->tree->getValue($item_id, 'info') ? $this->tree->getValue($item_id, 'info') : _("Keine weitere Info vorhanden");
         }
         $ret = tooltipicon(kill_format($info));
     }
     return $ret;
 }