Exemple #1
0
    if ($path_info == '/notify_feed/feed.atom') {
        $type = 'ATOM1.0';
    } else {
        header('HTTP/1.0 404 Not Found');
        exit;
    }
}
if (!isset($_SERVER["PHP_AUTH_USER"]) or !OCP\User::checkPassword($uid = $_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])) {
    header('WWW-Authenticate: Basic realm="ownCloud Login"');
    header('HTTP/1.0 401 Unauthorized');
    exit;
}
$lang = OC_Preferences::getValue($uid, 'core', 'lang', OC_L10N::findLanguage());
$l = OC_L10N::get('notify', $lang);
//TODO: use different feed creator library (like Zend_Feed) and switch html flag to true
$notifications = OC_Notify::getNotifications($uid, 50, $lang, false);
$baseAddress = (isset($_SERVER["HTTPS"]) ? 'https://' : 'http://') . $_SERVER["SERVER_NAME"];
$rssURI = $baseAddress . $baseuri . 'feed.rss';
$atomURI = $baseAddress . $baseuri . 'feed.atom';
$feed = new UniversalFeedCreator();
$feed->title = $l->t('ownCloud notifications');
$feed->description = $l->t('ownCloud notification stream of the user "%s".', array($uid));
$feed->link = $baseAddress . OC::$WEBROOT;
$feed->syndicationURL = $baseAddress . $_SERVER["PHP_SELF"];
$feed->image = new FeedImage();
$feed->image->title = 'ownCloud';
$feed->image->url = $baseAddress . OCP\Util::imagePath('core', 'logo-inverted.png');
$feed->image->link = $feed->link;
foreach ($notifications as $notification) {
    $item = new FeedItem();
    $item->title = strip_tags($notification["summary"]);
Exemple #2
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled("notify");
// FIXME CSRF !!
if ($_SERVER["REQUEST_METHOD"] != 'POST') {
    OCP\JSON::error(array("message" => 'POST required for this action!'));
    exit;
}
try {
    $num = OC_Notify::deleteByUser();
    OCP\JSON::success(array("num" => $num));
} catch (Exception $e) {
    OCP\JSON::error(array("message" => $e->getMessage()));
}
exit;
Exemple #3
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled("notify");
// FIXME CSRF !!
if (isset($_POST["id"])) {
    $id = (int) $_POST["id"];
} else {
    OCP\JSON::error();
}
if (isset($_POST["read"])) {
    $read = (bool) $_POST["read"];
}
try {
    $num = OC_Notify::markReadById(null, $id, $read);
    OCP\JSON::success(array("unread" => OC_Notify::getUnreadNumber(), "num" => $num));
} catch (Exception $e) {
    OCP\JSON::error(array("message" => $e->getMessage()));
}
exit;
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled("notify");
if (isset($_POST["count"])) {
    $count = (int) $_POST["count"];
} else {
    //$count = 10;
    //FIXME
    $count = null;
}
OCP\JSON::encodedPrint(OC_Notify::getNotifications(null, $count));
Exemple #5
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled("notify");
// FIXME CSRF !!
if (isset($_POST["id"])) {
    $id = (int) $_POST["id"];
} else {
    OCP\JSON::error(array("message" => 'Missing id argument'));
    exit;
}
try {
    $num = OC_Notify::deleteById(null, $id);
    OCP\JSON::success(array("num" => $num));
} catch (Exception $e) {
    OCP\JSON::error(array("message" => $e->getMessage()));
}
exit;
Exemple #6
0
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
 * redirect to the notification's href
 */
try {
    OCP\App::checkAppEnabled("notify");
    OCP\User::checkLoggedIn();
    $id = (int) $_GET["id"];
    $uid = OCP\User::getUser();
    $notification = OC_Notify::getNotificationById((int) $id);
    if ($notification && $notification["uid"] == $uid) {
        OC_Notify::markReadById($uid, $id, true);
        if ($notification["app"] == "notify") {
            switch ($notification["class"]) {
                case "sharedCalendar":
                case "sharedEvent":
                    $href = OCP\Util::linkTo("calendar", "index.php");
                    break;
                case "sharedAbook":
                    $href = OCP\Util::linkTo("contacts", "index.php");
                    break;
                case "sharedFile":
                    $href = OCP\Util::linkTo("files", "index.php", array("dir" => "/Shared" . rtrim(dirname($notification["params"]["name"]), "/")));
                    break;
                case "sharedFolder":
                    $href = OCP\Util::linkTo("files", "index.php", array("dir" => "/Shared" . $notification["params"]["name"]));
                    break;
Exemple #7
0
 /**
  * @brief check if the given class is in the given user's blacklist
  * @param string $uid user
  * @param string $class class id
  * @return true if the class is blocked by the user, otherwise false
  */
 private static function isBlacklisted($uid, $class)
 {
     if (!isset(self::$isBlockedStmt)) {
         self::$isBlockedStmt = OCP\DB::prepare("SELECT COUNT(*) FROM *PREFIX*notification_blacklist WHERE uid = ? AND class = ?");
     }
     return (bool) self::$isBlockedStmt->execute(array($uid, $class))->fetchOne();
 }
Exemple #8
0
<?php

OCP\Util::addScript('notify', 'personalSettings');
OCP\Util::addStyle('notify', 'personalSettings');
$tmpl = new OCP\Template('notify', 'personalSettings');
$notificationClasses = OC_Notify::getClasses();
$classes = array();
foreach ($notificationClasses as $c) {
    //$l = OC_L10N::get($c['appid'], null); //TODO: put this into notify.php
    $appInfo = OCP\App::getAppInfo($c['appid']);
    $classes[$c['id']] = array('blocked' => $c['blocked'], 'summary' => $c['summary'], 'name' => $c['name'], 'appName' => $appInfo['name'], 'appid' => $c['appid']);
}
$tmpl->assign('classes', $classes);
return $tmpl->fetchPage();
Exemple #9
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled("notify");
// FIXME CSRF !!
if (isset($_POST["read"])) {
    $read = (strtolower($_POST["read"]) != "false" and (bool) $_POST["read"]);
} else {
    OCP\JSON::error(array("message" => "Missing argument"));
    exit;
}
try {
    $num = OC_Notify::deleteByRead(null, $read);
    OCP\JSON::success(array("num" => $num));
} catch (Exception $e) {
    OCP\JSON::error(array("message" => $e->getMessage()));
}
exit;
Exemple #10
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled("notify");
OCP\JSON::encodedPrint(OC_Notify::getUnreadNumber());
Exemple #11
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled("notify");
// FIXME CSRF !!
if ($_SERVER["REQUEST_METHOD"] != 'POST') {
    OCP\JSON::error(array("message" => 'POST required for this action!'));
    exit;
}
try {
    $num = OC_Notify::markReadByUser();
    OCP\JSON::success(array("num" => $num));
} catch (Exception $e) {
    OCP\JSON::error(array("message" => $e->getMessage()));
}
exit;