Пример #1
0
 /**
  *
  */
 private function add()
 {
     UserHelper::breakOnMissingUserId();
     $notification = new Notifier();
     $notification->notify($_SESSION['user']->userid, $_POST['userid'], 'confirmfriend', 'index.php?m=confirmfriend&action=' . $_POST['userid']);
     $relations = new Db\Table\Relationships();
     $res = $relations->insert(["sender" => $_SESSION['user']->userid, "receiver" => $_POST['userid'], "status" => 1]);
     if ($res) {
         $view = new View($res !== false);
         $view->sendResponse();
     }
 }
Пример #2
0
 /**
  * @param array $data
  * @return bool|mixed
  */
 public function post(array $data)
 {
     if (isset($data['wall_owner_id']) && isset($data['wall_owner_type']) && !empty($data['wall_owner_id']) && !empty($data['wall_owner_type'])) {
         $walls = new Walls();
         $wallid = $walls->getWallId($data['wall_owner_id'], $data['wall_owner_type']);
         $notification = new Notifier();
         $notification->notify($data['wall_owner_id'], $_SESSION['user']->userid, 'wall_post', 'index.php?m=wall_post&action=' . $data['wall_owner_id']);
     } else {
         $wallid = $_POST['wallid'];
     }
     $res = $this->insert(["userid" => $data['userid'], "wall_id" => $wallid, "privacy" => $data['privacy'], "content" => $data['content'], "time" => new \Zend_Db_Expr("UTC_TIMESTAMP()"), "type" => $data['type']]);
     if ($res !== null) {
         return $this->getPostData($res);
     } else {
         return false;
     }
 }
Пример #3
0
 /**
  * @return array
  */
 public function getNotifications()
 {
     $result = [];
     $query = $this->getAdapter()->select()->from(["n" => $this->_name])->joinLeft(["u" => $this->_dbprefix . "users"], "n.ref_userid=u.userid", ["name", "username"])->joinLeft(["pi" => $this->_dbprefix . "gallery_images"], "pi.id = u.profileImage", ['filename AS pimg', 'albumid AS palbumid'])->where("n.userid=?", $_SESSION['user']->userid)->order("n.unread DESC")->limit(5);
     $res = $this->getAdapter()->fetchAll($query);
     $resCount = count($res);
     for ($i = 0; $i < $resCount; $i++) {
         $d = Notifier::getNotificationData($res[$i]["type"]);
         $res[$i]["message"] = \sprintf($d, $res[$i]["name"]);
         $res[$i]["target"] = Url::convertUrl($res[$i]["target"]);
         if ($res[$i]["unread"] == 1) {
             $result["new"]++;
         }
     }
     $result["all"] = $res;
     return $result;
 }
Пример #4
0
 /**
  * @param $cid
  * @param $users
  * @param bool $invitation
  * @param bool $notify
  * @return bool
  */
 public function addUsersToConversation($cid, $users, $invitation = false, $notify = true)
 {
     if (is_array($users) && !empty($users)) {
         foreach ($users as $user) {
             $this->insert(["userid" => intval($user), "conversation_id" => intval($cid)]);
             if ($notify) {
                 Notifier::notify($user, $_SESSION['user']->userid, "addConversation", "index.php?m=messages&action=" . $cid);
             }
         }
     } else {
         $this->insert(["userid" => intval($users), "conversation_id" => intval($cid)]);
         if ($notify) {
             if ($invitation) {
                 Notifier::notify($_POST['userid'], $_SESSION['user']->userid, "addConversation", "index.php?m=messages&action=" . $cid);
             } else {
                 Notifier::notify($_POST['userid'], $_SESSION['user']->userid, "message", "index.php?m=messages&action=" . $cid);
             }
         }
     }
     return true;
 }
Пример #5
0
 /**
  * @param bool $notify
  */
 public static function add($notify = false)
 {
     UserHelper::breakOnMissingUserId();
     $relations = new Relationships();
     $res = $relations->insert(["sender" => $_SESSION['user']->userid, "receiver" => $_POST['userid'], "status" => 1]);
     if ($res) {
         if ($notify) {
             Notifier::notify($_POST['userid'], $_SESSION['user']->userid, "addfriend", "index.php?m=profile&action=" . $_SESSION['user']->username);
         }
         $view = new View($res !== false);
         $view->sendResponse();
     }
 }
Пример #6
0
 /**
  * @param $eventid
  * @param $users
  * @param int $status
  * @param bool $invitation
  * @return bool
  */
 public function addGuests($eventid, $users, $status = 0, $invitation = false)
 {
     if (is_array($users) && !empty($users)) {
         foreach ($users as $user) {
             $this->insert(["userid" => intval($user), "eventid" => intval($eventid), "status" => $status]);
             Notifier::notify($user, $_SESSION['user']->userid, "eventInvitation", "index.php?m=events&action=" . $eventid);
         }
     } else {
         $this->insert(["userid" => intval($users), "eventid" => intval($eventid), "status" => $status]);
         if ($invitation) {
             Notifier::notify($users, $_SESSION['user']->userid, "eventInvitation", "index.php?m=events&action=" . $eventid);
         }
     }
     return true;
 }