/** * View all users connections * @param int $user * @return void */ private function viewAll($user) { if ($this->registry->getObject('authenticate')->isLoggedIn()) { require_once FRAMEWORK_PATH . 'models/relationships.php'; $relationships = new Relationships($this->registry); $all = $relationships->getByUser($user, false, 0); $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'friends/all.tpl.php', 'footer.tpl.php'); $this->registry->getObject('template')->getPage()->addTag('all', array('SQL', $all)); require_once FRAMEWORK_PATH . 'models/profile.php'; $p = new Profile($this->registry, $user); $name = $p->getName(); $this->registry->getObject('template')->getPage()->addTag('connecting_name', $name); } else { $this->registry->errorPage('Please login', 'Please login to view a users connections'); } }
/** * Set common template tags for all profile aspects * @param int $user the user id * @return void */ private function commonTemplateTags($user) { // get a random sample of 6 friends. require_once FRAMEWORK_PATH . 'models/relationships.php'; $relationships = new Relationships($this->registry); $cache = $relationships->getByUser($user, true, 6); $this->registry->getObject('template')->getPage()->addTag('profile_friends_sample', array('SQL', $cache)); // get the name and photo of the user require_once FRAMEWORK_PATH . 'models/profile.php'; $profile = new Profile($this->registry, $user); $name = $profile->getName(); $photo = $profile->getPhoto(); $uid = $profile->getID(); $this->registry->getObject('template')->getPage()->addTag('profile_name', $name); $this->registry->getObject('template')->getPage()->addTag('profile_photo', $photo); $this->registry->getObject('template')->getPage()->addTag('profile_user_id', $uid); // clear the profile $profile = ""; }
/** * Compose a new message, and process new message submissions * @parm int $reply message ID this message is in reply to [optional] only used to pre-populate subject and recipient * @return void */ private function newMessage($reply = 0) { $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'messages/create.tpl.php', 'footer.tpl.php'); require_once FRAMEWORK_PATH . 'models/relationships.php'; $relationships = new Relationships($this->registry); if (isset($_POST) && count($_POST) > 0) { $network = $relationships->getNetwork($this->registry->getObject('authenticate')->getUser()->getUserID()); $recipient = intval($_POST['recipient']); if (in_array($recipient, $network)) { // this additional check may not be something we require for private messages? require_once FRAMEWORK_PATH . 'models/message.php'; $message = new Message($this->registry, 0); $message->setSender($this->registry->getObject('authenticate')->getUser()->getUserID()); $message->setRecipient($recipient); $message->setSubject($this->registry->getObject('db')->sanitizeData($_POST['subject'])); $message->setMessage($this->registry->getObject('db')->sanitizeData($_POST['message'])); $message->save(); // email notification to the recipient perhaps?? // confirm, and redirect $url = $this->registry->getObject('url')->buildURL(array('messages'), '', false); $this->registry->redirectUser($url, 'Message sent', 'The message has been sent'); } else { $this->registry->errorPage('Invalid recipient', 'Sorry, you can only send messages to your recipients'); } } else { $cache = $relationships->getByUser($this->registry->getObject('authenticate')->getUser()->getUserID()); $this->registry->getObject('template')->getPage()->addTag('recipients', array('SQL', $cache)); if ($reply > 0) { require_once FRAMEWORK_PATH . 'models/message.php'; $message = new Message($this->registry, $reply); if ($message->getRecipient() == $this->registry->getObject('authenticate')->getUser()->getUserID()) { $this->registry->getObject('template')->getPage()->addAdditionalParsingData('recipients', 'ID', $message->getSender(), 'opt', "selected='selected'"); $this->registry->getObject('template')->getPage()->addTag('subject', 'Re: ' . $message->getSubject()); } else { $this->registry->getObject('template')->getPage()->addTag('subject', ''); } } else { $this->registry->getObject('template')->getPage()->addTag('subject', ''); } } }