/** * Post notifications to users * @return null */ function post_notifications() { $notifs = get_notifications(); echo '[ ' . date('r') . ' ] Updating DB '; foreach ($notifs as $notif) { if (dbFetchCell('select 1 from notifications where checksum = ?', array($notif['checksum'])) != 1 && dbInsert('notifications', $notif) > 0) { echo '.'; } } echo ' Done'; echo PHP_EOL; }
case 'only_updates': $response = get_only_updates(); break; case 'open_tickets': $response = get_open_tickets($conn); break; case 'unresolved_alarms': $response = get_unresolved_alarms($conn); break; case 'sensor_status': $response = get_sensor_status($conn); break; case 'system_eps': $response = get_system_eps($conn); break; case 'monitored_devices': $response = get_monitored_devices($conn); break; case 'events_trend': $response = get_events_trend($conn); break; case 'notifications': $response = get_notifications($conn); break; default: $response['error'] = TRUE; $response['output'] = _('Wrong Option Chosen'); } echo json_encode($response); } $db->close();
/** * Get all the users who need to receive a notification of a new post (those subscribed to * the forum or the thread) * * @param integer $forum_id the id of the forum * @param integer $thread_id the id of the thread * @param integer $post_id the id of the post * @return bool * * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version May 2008, dokeos 1.8.5 * @since May 2008, dokeos 1.8.5 */ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0) { $_course = api_get_course_info(); // The content of the mail $thread_link = api_get_path(WEB_CODE_PATH) . 'forum/viewthread.php?' . api_get_cidreq() . '&forum=' . $forum_id . '&thread=' . $thread_id; // Users who subscribed to the forum if ($forum_id != 0) { $users_to_be_notified_by_forum = get_notifications('forum', $forum_id); } else { return false; } $current_thread = get_thread_information($thread_id); $current_forum = get_forum_information($current_thread['forum_id']); $subject = get_lang('NewForumPost') . ' - ' . $_course['official_code'] . ' - ' . $current_forum['forum_title'] . ' - ' . $current_thread['thread_title']; // User who subscribed to the thread if ($thread_id != 0) { $users_to_be_notified_by_thread = get_notifications('thread', $thread_id); } // Merging the two $users_to_be_notified = array_merge($users_to_be_notified_by_forum, $users_to_be_notified_by_thread); $sender_id = api_get_user_id(); if (is_array($users_to_be_notified)) { foreach ($users_to_be_notified as $value) { $user_info = api_get_user_info($value['user_id']); $email_body = get_lang('Dear') . ' ' . api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS) . ", <br />\n\r"; $email_body .= get_lang('NewForumPost') . ": " . $current_forum['forum_title'] . ' - ' . $current_thread['thread_title'] . " <br />\n"; $email_body .= get_lang('Course') . ': ' . $_course['name'] . ' - [' . $_course['official_code'] . "] <br />\n"; $email_body .= get_lang('YouWantedToStayInformed') . "<br />\n"; $email_body .= get_lang('ThreadCanBeFoundHere') . ': <br /> <a href="' . $thread_link . '">' . $thread_link . "</a>\n"; MessageManager::send_message_simple($value['user_id'], $subject, $email_body, $sender_id); } } }
$t->is($notifications[0]['body'], 'notify10'); $t->is($notifications[1]['body'], 'notify9'); $t->is($notifications[2]['body'], 'notify8'); $t->is($notifications[3]['body'], 'notify7'); $t->is($notifications[4]['body'], 'notify6'); $conn->rollback(); //============================================================================== $t->diag('opNotificationCenter::setRead()'); $conn->beginTransaction(); opNotificationCenter::notify($member1, $member2, 'hogehoge1'); opNotificationCenter::notify($member1, $member2, 'hogehoge2'); $notifications = get_notifications($member2); $t->is($notifications[0]['unread'], true); $t->is($notifications[1]['unread'], true); opNotificationCenter::setRead($member2, $notifications[0]['id']); $notifications = get_notifications($member2); $t->is($notifications[0]['unread'], false); $t->is($notifications[1]['unread'], true); $conn->rollback(); //============================================================================== $t->diag('opNotificationCenter::getNotifications()'); $t->info('empty value'); $conn->beginTransaction(); $notifications = opNotificationCenter::getNotifications($member2); $t->ok(is_array($notifications)); $t->is(count($notifications), 0); $conn->rollback(); $t->info('check format'); $conn->beginTransaction(); opNotificationCenter::notify($member1, $member2, 'hogehoge'); $notifications = opNotificationCenter::getNotifications($member2);
<?php }?> <?php if (userdata('id')=='1'){?> <li><a href="<?php echo base_url('admin/settings'); ?>"><i class="icon-settings"></i><span>Settings</span></a></li> <?php }?> </ul> </div> </div> <div class="header-right"> <ul class="header-menu nav navbar-nav"> <!-- BEGIN NOTIFICATION DROPDOWN --> <?php $res_notification=get_notifications(); $total_notification=count($res_notification); ?> <li class="dropdown" id="notifications-header"> <a href="#" data-toggle="dropdown" data-hover="dropdown" data-close-others="true"> <i class="icon-bell"></i> <?php if($total_notification > 0){?> <span class="badge badge-danger badge-header"><?php echo $total_notification;?></span> <?php }?> </a> <ul class="dropdown-menu"> <li class="dropdown-header clearfix"> <?php if($total_notification > 0){?> <p class="pull-left"><?php echo $total_notification;?> Pending Notifications</p> <?php }else{?>
<?php include_once "../includes/head_tags.php"; require_once "../includes/notifications.inc"; ?> <title>Secure Your Images - ToyApp</title> </head> <body class="auth-user"> <?php include_once "../includes/header.inc"; ?> <div id="dash-board"> <ul class="dash-options"> <a href="repo.php"><li>Your Repo</li></a> <a href="secure_share.php"><li>SecureShare Image</li></a> <a href="secure_reconstruct.php"><li>SecureReconstruct Image</li></a> <a href="../logout.php"><li>Logout</li></a> </ul> <div id="dash-notifications"> <div class="noti-head">Notifications</div> <div class="noti-container"> <?php $uinfo = get_user_info(); echo get_notifications($uinfo['uid']); ?> </div> </div> </div> <div id="footer"> </div> </body>