コード例 #1
0
ファイル: BaseController.php プロジェクト: sbadi/shareatrip
 public function setAllNotificationsAsRead()
 {
     if (!is_null(SessionUtils::getUserLogged())) {
         $notificationDAO = new NotificationDAO();
         $notificationDAO->setAllNotificationsAsRead();
         $this->view->setArg('unreadNotification', 0);
     }
 }
コード例 #2
0
 function add($friend)
 {
     global $db, $current_user;
     if (!is_numeric($friend)) {
         die;
     }
     if ($current_user->user_id == 0) {
         echo "<span class='success' style='border:solid1px#269900;padding:2px2px2px2px'>Please <a href=" . my_base_url . my_pligg_base . "/login.php?return=/user.php?login=god&amp;view=addfriend>login</a></span><br/>";
         return;
     }
     $friend_status = $this->get_friend_status($friend);
     if (!$friend_status) {
         //echo "INSERT INTO " . table_friends . " (friend_from, friend_to) values ($current_user->user_id, $friend);";
         $db->query("INSERT IGNORE INTO " . table_friends . " (friend_from, friend_to) values (" . $current_user->user_id . ", " . $friend . ");");
         $notificationDAO = new NotificationDAO();
         $notificationDAO->friend($friend, "followed you");
         $friend_status = $this->get_friend_status($friend);
         if (!$friend_status) {
             die("there was an error");
         }
     }
 }
コード例 #3
0
 public function denyFriendshipModel($notificationId, $userForm)
 {
     $formObjRaw = new FormDTO(DENY_FRIENDSHIP_FORM, $userForm);
     $formObjRaw->setSubElementId($notificationId);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $friendDAO = new FriendsDAO();
         $friendId = $friendDAO->deleteFriend($formDataObj[DENY_FRIENDSHIP_FORM . FRIENDID]);
         $notificationDAO = new NotificationDAO();
         $notificationDAO->deleteNotificationByNotificationId($notificationId);
         $responseDTO = new ResponseDTO(DENY_REGISTRATION_FORM);
         $responseDTO->setResponseSucc($notificationId);
         return $notificationId;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
コード例 #4
0
ファイル: DataModelUtils.php プロジェクト: sbadi/shareatrip
 public static function notifyAction($object, $context)
 {
     $notificationDAO = new NotificationDAO();
     $timestamp = date(DATE_FORMAT);
     $userLoggedFriendList = SessionUtils::getUserLoggedFriendsList();
     if ($context === REGISTRATION_FORM) {
         $user = explode(SEPARATOR, $object);
         $message = DataModelUtils::getNotificationMessage($object, $context);
         $notificationDTO = new NotifyDTO(NULL, $user[0], 1, $message, 0, $timestamp, $context, $user[0] . SEPARATOR . $user[1]);
         $notificationDAO->saveNewNotification($notificationDTO);
     } else {
         if ($context === ADD_FRIEND_FORM) {
             $userLogged = SessionUtils::getUserLogged();
             $friend = explode(SEPARATOR, $object);
             $message = DataModelUtils::getNotificationMessage($object, $context);
             $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friend[0], $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]);
             $notificationDAO->saveNewNotification($notificationDTO);
         } else {
             if ($context === CONFIRM_FRIENDSHIP_FORM) {
                 $userLogged = SessionUtils::getUserLogged();
                 $friend = explode(SEPARATOR, $object);
                 $message = DataModelUtils::getNotificationMessage($object, $context, TOMYSELF);
                 $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $userLogged->getUserId(), $message, 1, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]);
                 $result = $notificationDAO->saveNewNotification($notificationDTO);
                 $message = DataModelUtils::getNotificationMessage($object, $context, TOMINENEWFRIEND);
                 $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friend[0], $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]);
                 $result = $notificationDAO->saveNewNotification($notificationDTO);
                 $userLoggedFriendList = SessionUtils::getUserLoggedFriendsList();
                 SessionUtils::prepareNotificationToFriends($object, $context, $userLoggedFriendList, $timestamp, TOMYFRIENDSLIST);
                 $friendsDAO = new FriendsDAO();
                 $myfriendFriendList = $friendsDAO->getNewFriendsFriendList($userLogged->getUserId(), $friend[0]);
                 SessionUtils::prepareNotificationToFriends($object, $context, $myfriendFriendList, $timestamp, TOMINENEWFRIENDFRIENDLIST);
                 $message = '<a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '"><label>' . $userLogged->getUsername() . '</label></a> ha stretto amicizia con <a href="' . URL . PROFILE_CONTROLLER . INDEX . $friend[0] . '"><label>' . $friend[1] . '</label></a>';
                 $adminNotificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), 1, $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]);
                 $notificationDAO->saveNewNotification($adminNotificationDTO);
             } else {
                 $userLoggedFriendList = SessionUtils::getUserLoggedFriendsList();
                 SessionUtils::prepareNotificationToFriends($object, $context, $userLoggedFriendList, $timestamp);
             }
         }
     }
 }
コード例 #5
0
ファイル: SessionUtils.php プロジェクト: sbadi/shareatrip
 public static function prepareNotificationToFriends($object, $context, $friendList, $timestamp, $direction = NULL, $userId = NULL)
 {
     $userLogged = SessionUtils::getUserLogged();
     $notificationDao = new NotificationDAO();
     if ($context !== CONFIRM_FRIENDSHIP_FORM) {
         $message = DataModelUtils::getNotificationMessage($object, $context, $direction);
         $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), 1, $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $object);
         $result = $notificationDao->saveNewNotification($notificationDTO);
     }
     if ($friendList != null) {
         foreach ($friendList as $key => $friendDTO) {
             $message = DataModelUtils::getNotificationMessage($object, $context, $direction);
             if ($context === CONFIRM_FRIENDSHIP_FORM) {
                 $friend = explode(SEPARATOR, $object);
                 if ($direction === TOMYFRIENDSLIST) {
                     if ($friend[0] !== $friendDTO->getFriendId()->getUserId()) {
                         $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friendDTO->getFriendId()->getUserId(), $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $object);
                         $result = $notificationDao->saveNewNotification($notificationDTO);
                     }
                 } else {
                     if ($direction === TOMINENEWFRIENDFRIENDLIST) {
                         if ($friendDTO->getFriendId()->getUserId() !== $userLogged->getUserId()) {
                             $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friendDTO->getFriendId()->getUserId(), $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $object);
                             $result = $notificationDao->saveNewNotification($notificationDTO);
                         }
                     }
                 }
             } else {
                 $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friendDTO->getFriendId()->getUserId(), $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $object);
                 $result = $notificationDao->saveNewNotification($notificationDTO);
             }
         }
     }
 }
コード例 #6
0
            }
        } else {
            //if rollback, I should change the default checked radio button
            //find userid
            $target_user = $db->get_row("SELECT user_id FROM colfusion_users WHERE user_login = '******'");
            $target_user_id = $target_user->user_id;
            //echo $target_user_id;
            $sql_update = "UPDATE wiki_history ";
            $sql_update .= "SET checked = true ";
            $sql_update .= "WHERE sid = {$link_id} and field = 'tags' and timestamp = '{$modified_date}' and user_id = {$target_user_id} ";
            $db->query($sql_update);
        }
    }
}
//added by Jason
$notificationDAO = new NotificationDAO();
$notificationDAO->addEditNTFtoDB($link_id);
//echo $str."<br/>";
/*
error_reporting(E_ALL ^ E_DEPRECATED);
$con = mysql_connect($servername,$username,$password);
if (!$con){
    die('Could not connect: ' . mysql_error());
    //echo 'fail to connect';
} else {
    mysql_select_db($database,$con);
    $sql_select = " SELECT content
                    FROM description
                    WHERE id=(SELECT MAX(id)
                              FROM description)";
    if (!mysql_query($sql_select,$con)) {
コード例 #7
0
function addEditNTFtoDB()
{
    $notificationDAO = new NotificationDAO();
    $link_id = $_GET["link_id"];
    echo $notificationDAO->addEditNTFtoDB($link_id);
}
コード例 #8
0
<?php

require_once realpath(dirname(__FILE__)) . '/../config.php';
require_once realpath(dirname(__FILE__)) . '/../DAL/RelationshipDAO.php';
require_once realpath(dirname(__FILE__)) . '/../DAL/Neo4JDAO.php';
require_once realpath(dirname(__FILE__)) . '/../DAL/NotificationDAO.php';
if (!$current_user->authenticated) {
    die('Please login to use this function.');
}
$relId = $_POST['relId'];
$userId = $current_user->user_id;
$relationshipDAO = new RelationshipDAO();
$notificationDAO = new NotificationDAO();
$notificationDAO->addNTFtoDB($relId, "removeRelationship");
$jsonResult = new stdClass();
try {
    $relationshipDAO->deleteRelationship($relId, $userId);
    $n4jDao = new Neo4JDAO();
    $n4jDao->deleteRelationshipByRelId($relId);
    $jsonResult->isSuccessful = true;
} catch (Exception $e) {
    $jsonResult->isSuccessful = false;
}
echo json_encode($jsonResult);