/** * */ 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(); } }
/** * @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; } }
/** * @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; }
/** * @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(); } }
/** * @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; }