function ossn_messages_page($pages) { if (!ossn_isLoggedin()) { ossn_error_page(); } $OssnMessages = new OssnMessages(); $page = $pages[0]; if (empty($page)) { $page = 'messages'; } switch ($page) { case 'message': $username = $pages[1]; if (!empty($username)) { $user = ossn_user_by_username($username); if (empty($user->guid)) { ossn_error_page(); } $title = ossn_print('ossn:message:between', array($user->fullname)); $OssnMessages->markViewed($user->guid, ossn_loggedin_user()->guid); $params['data'] = $OssnMessages->get(ossn_loggedin_user()->guid, $user->guid); $params['user'] = $user; $params['recent'] = $OssnMessages->recentChat(ossn_loggedin_user()->guid); $contents = array('content' => ossn_plugin_view('messages/pages/view', $params)); $content = ossn_set_page_layout('media', $contents); echo ossn_view_page($title, $content); } else { ossn_error_page(); } break; case 'all': $params['recent'] = $OssnMessages->recentChat(ossn_loggedin_user()->guid); $active = $params['recent'][0]; if (isset($active->message_to) && $active->message_to == ossn_loggedin_user()->guid) { $getuser = $active->message_from; } if (isset($active->message_from) && $active->message_from == ossn_loggedin_user()->guid) { $getuser = $active->message_to; } if (isset($getuser)) { $user = ossn_user_by_guid($getuser); $OssnMessages->markViewed($getuser, ossn_loggedin_user()->guid); $params['data'] = $OssnMessages->get(ossn_loggedin_user()->guid, $getuser); $params['user'] = $user; } $contents = array('content' => ossn_plugin_view('messages/pages/messages', $params)); if (!isset($getuser)) { $contents = array('content' => ossn_plugin_view('messages/pages/messages-none')); } $title = ossn_print('messages'); $content = ossn_set_page_layout('media', $contents); echo ossn_view_page($title, $content); break; case 'getnew': $username = $pages[1]; $guid = ossn_user_by_username($username)->guid; $messages = $OssnMessages->getNew($guid, ossn_loggedin_user()->guid); if ($messages) { foreach ($messages as $message) { $user = ossn_user_by_guid($message->message_from); $message = $message->message; $params['user'] = $user; $params['message'] = $message; echo ossn_plugin_view('messages/templates/message-send', $params); } $OssnMessages->markViewed($guid, ossn_loggedin_user()->guid); echo '<script>Ossn.playSound();</script>'; } break; case 'getrecent': $params['recent'] = $OssnMessages->recentChat(ossn_loggedin_user()->guid); echo ossn_plugin_view('messages/templates/message-with', $params); break; default: ossn_error_page(); break; } }
/** * Notification Page * * @return mixed data; * @access public */ function ossn_notification_page($pages) { $page = $pages[0]; if (empty($page)) { ossn_error_page(); } header('Content-Type: application/json'); switch ($page) { case 'notification': $get = new OssnNotifications(); $notifications['notifications'] = $get->get(ossn_loggedin_user()->guid, true); $notifications['seeall'] = ossn_site_url("notifications/all"); if (!empty($notifications['notifications'])) { $data = ossn_view('components/OssnNotifications/pages/notification/notification', $notifications); echo json_encode(array('type' => 1, 'data' => $data)); } else { echo json_encode(array('type' => 0, 'data' => '<div class="ossn-no-notification">Nothing to show</div>')); } break; case 'friends': $friends['friends'] = ossn_loggedin_user()->getFriendRequests(); $friends_count = count($friends['friends']); if ($friends_count > 0 && !empty($friends['friends'])) { $data = ossn_view('components/OssnNotifications/pages/notification/friends', $friends); echo json_encode(array('type' => 1, 'data' => $data)); } else { echo json_encode(array('type' => 0, 'data' => '<div class="ossn-no-notification">Nothing to show</div>')); } break; case 'messages': $OssnMessages = new OssnMessages(); $params['recent'] = $OssnMessages->recentChat(ossn_loggedin_user()->guid); $data = ossn_view('components/OssnMessages/templates/message-with-notifi', $params); if (!empty($params['recent'])) { echo json_encode(array('type' => 1, 'data' => $data)); } else { echo json_encode(array('type' => 0, 'data' => '<div class="ossn-no-notification">Nothing to show</div>')); } break; case 'read': if (!empty($pages[1])) { $notification = new OssnNotifications(); $guid = $notification->getbyGUID($pages[1]); if ($guid->owner_guid == ossn_loggedin_user()->guid) { $notification->setViewed($pages[1]); $url = urldecode(input('notification')); header("Location: {$url}"); } else { redirect(); } } else { redirect(); } break; case 'count': if (!ossn_isLoggedIn()) { ossn_error_page(); } $notification = new OssnNotifications(); $messages = new OssnMessages(); $count_notif = $notification->countNotification(ossn_loggedin_user()->guid); $count_messages = $messages->countUNREAD(ossn_loggedin_user()->guid); if (!$count_notif) { $count_notif = 0; } $friends = ossn_loggedin_user()->getFriendRequests(); $friends_c = 0; if (count($friends) > 0 && !empty($friends)) { $friends_c = count($friends); } echo json_encode(array('notifications' => $count_notif, 'messages' => $count_messages, 'friends' => $friends_c)); break; default: ossn_error_page(); break; } }
/** * Delete user messages * * @param string $callback Name of callback * @param string $type Callback type * @param array $params Arrays or Objects * * @return void * @access private */ function ossn_user_messages_delete($callback, $type, $params) { $messages = new OssnMessages(); if (isset($params['entity']->guid)) { $messages->deleteUser($params['entity']->guid); } }
<?php /** * OpenSource-SocialNetwork * * @package (Informatikon.com).ossn * @author OSSN Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://opensource-socialnetwork.com/licence * @link http://www.opensource-socialnetwork.com/licence */ //declear empty variables; $friends_c = ''; //init classes $notification = new OssnNotifications(); $messages = new OssnMessages(); $count_notif = $notification->countNotification(ossn_loggedin_user()->guid); $count_messages = $messages->countUNREAD(ossn_loggedin_user()->guid); $friends = ossn_loggedin_user()->getFriendRequests(); if (count($friends) > 0 && !empty($friends)) { $friends_c = count($friends); } ?> <li id="ossn-notif-friends"> <a onClick="Ossn.NotificationFriendsShow(this);" class="ossn-notifications-friends" href="javascript::;"> <span> <?php if ($friends_c > 0) { ?> <div class="ossn-icon ossn-icons-topbar-friends-new ossn-icons-topbar"></div> <span class="ossn-notification-container"><?php
<?php /** * Open Source Social Network * * @package Open Source Social Network * @author Open Social Website Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://www.opensource-socialnetwork.org/licence * @link http://www.opensource-socialnetwork.org/licence */ $send = new OssnMessages(); $message = input('message'); $to = input('to'); if ($send->send(ossn_loggedin_user()->guid, $to, $message)) { $user = ossn_user_by_guid(ossn_loggedin_user()->guid); $message = input('message'); $params['user'] = $user; $params['message'] = $message; echo ossn_view('components/OssnMessages/templates/message-send', $params); } else { echo 0; }
/** * Notification Page * * @return mixed data; * @access public */ function ossn_notification_page($pages) { $page = $pages[0]; if (empty($page)) { ossn_error_page(); } header('Content-Type: application/json'); switch ($page) { case 'notification': $get = new OssnNotifications(); //removed true as second arg of get() as second arg is introduced in v2.0 $notifications['notifications'] = $get->get(ossn_loggedin_user()->guid); $notifications['seeall'] = ossn_site_url("notifications/all"); $clearall = ossn_plugin_view('output/url', array('action' => true, 'href' => ossn_site_url('action/notification/mark/allread'), 'class' => 'ossn-notification-mark-read', 'text' => ossn_print('ossn:notifications:mark:as:read'))); if (!empty($notifications['notifications'])) { $data = ossn_plugin_view('notifications/pages/notification/notification', $notifications); echo json_encode(array('type' => 1, 'data' => $data, 'extra' => $clearall)); } else { echo json_encode(array('type' => 0, 'data' => '<div class="ossn-no-notification">' . ossn_print('ossn:notification:no:notification') . '</div>')); } break; case 'friends': $friends['friends'] = ossn_loggedin_user()->getFriendRequests(); $friends_count = count($friends['friends']); if ($friends_count > 0 && !empty($friends['friends'])) { $data = ossn_plugin_view('notifications/pages/notification/friends', $friends); echo json_encode(array('type' => 1, 'data' => $data)); } else { echo json_encode(array('type' => 0, 'data' => '<div class="ossn-no-notification">' . ossn_print('ossn:notification:no:notification') . '</div>')); } break; case 'messages': $OssnMessages = new OssnMessages(); $params['recent'] = $OssnMessages->recentChat(ossn_loggedin_user()->guid); $data = ossn_plugin_view('messages/templates/message-with-notifi', $params); if (!empty($params['recent'])) { echo json_encode(array('type' => 1, 'data' => $data)); } else { echo json_encode(array('type' => 0, 'data' => '<div class="ossn-no-notification">' . ossn_print('ossn:notification:no:notification') . '</div>')); } break; case 'read': if (!empty($pages[1])) { $notification = new OssnNotifications(); $guid = $notification->getbyGUID($pages[1]); if ($guid->owner_guid == ossn_loggedin_user()->guid) { $notification->setViewed($pages[1]); $url = urldecode(input('notification')); header("Location: {$url}"); } else { redirect(); } } else { redirect(); } break; case 'count': if (!ossn_isLoggedIn()) { ossn_error_page(); } $notification = new OssnNotifications(); $messages = new OssnMessages(); $count_notif = $notification->countNotification(ossn_loggedin_user()->guid); $count_messages = $messages->countUNREAD(ossn_loggedin_user()->guid); if (!$count_notif) { $count_notif = 0; } $friends = ossn_loggedin_user()->getFriendRequests(); $friends_c = 0; if (count($friends) > 0 && !empty($friends)) { $friends_c = count($friends); } echo json_encode(array('notifications' => $count_notif, 'messages' => $count_messages, 'friends' => $friends_c)); break; default: ossn_error_page(); break; } }