Example #1
0
 /**
  * Marks a personal notification as read by the user so it won't be displayed
  * in the list in the header.
  * @param string $id : hash-id of the notification
  */
 public function mark_notification_read_action($id)
 {
     PersonalNotifications::markAsRead($id);
     if (Request::isXhr()) {
         $this->render_nothing();
     } else {
         $notification = new PersonalNotifications($id);
         if ($notification->url) {
             $this->redirect(URLHelper::getUrl(TransformInternalLinks($notification->url)));
         } else {
             $this->render_nothing();
         }
     }
 }
Example #2
0
 /**
  * Stud.IP markup for hyperlinks (intern, extern).
  * Has lower priority than [code], [img], etc
  */
 protected static function markupLinks($markup, $matches)
 {
     if ($markup->isInsideOf('htmlAnchor') || $markup->isInsideOf('htmlImg')) {
         return $matches[0];
     }
     $url = $matches[2];
     $title = $matches[1] ?: $url;
     $intern = isLinkIntern($url);
     $url = TransformInternalLinks($url);
     $linkmarkup = clone $markup;
     $linkmarkup->removeMarkup('links');
     $linkmarkup->removeMarkup('wiki-links');
     return sprintf('<a class="%s" href="%s"%s>%s</a>', $intern ? 'link-intern' : 'link-extern', $url, $intern ? '' : ' target="_blank"', $linkmarkup->format($title));
 }
Example #3
0
/**
 * Return a normalized, internal URL.
 *
 * @params string $url  An internal URL.
 * @returns string      Normalized internal URL.
 */
function transformInternalIdnaLink($url)
{
    return \idna_link(\TransformInternalLinks($url));
}
Example #4
0
function isLinkIntern($url)
{
    $pum = @parse_url(TransformInternalLinks($url));
    return in_array($pum['scheme'], array('https', 'http', NULL), true) && in_array($pum['host'], array($_SERVER['SERVER_NAME'], NULL), true) && in_array($pum['port'], array($_SERVER['SERVER_PORT'], NULL), true) && strpos($pum['path'], $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP']) === 0;
}