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