Example #1
0
 /**
  * Current user is going to follow (add as buddy) the given user, who could
  * also be an external contact.
  */
 public function follow_user_action()
 {
     if (!$GLOBALS['perm']->have_perm("autor")) {
         throw new AccessDeniedException();
     }
     if (Request::get("external_contact")) {
         $user = BlubberExternalContact::find(Request::option("user_id"));
     } else {
         $user = new BlubberUser(Request::option("user_id"));
     }
     if (!$user->isNew()) {
         if (is_a($user, "BlubberExternalContact")) {
             $statement = DBManager::get()->prepare("INSERT IGNORE INTO blubber_follower " . "SET studip_user_id = :user_id, " . "external_contact_id = :contact_id, " . "left_follows_right = '1' " . "");
             $success = $statement->execute(array('user_id' => $GLOBALS['user']->id, 'contact_id' => $user->getId()));
             if ($success) {
                 NotificationCenter::postNotification('BlubberExternalContactDidAdd', $user);
             }
         } else {
             Contact::import(array('owner_id' => User::findCurrent()->id, 'user_id' => $user->id))->store();
         }
     }
     $this->render_json(array('success' => 1, 'message' => (string) MessageBox::success(_("Kontakt hinzugefĆ¼gt"))));
 }
Example #2
0
 /**
  * Returns all known users that have been sharing this thread.
  * @return array of \BlubberContact
  */
 public function getSharingUsers()
 {
     if ($this['context_type'] !== "public") {
         return array();
     }
     $get_shares = DBManager::get()->prepare("SELECT * FROM blubber_reshares WHERE topic_id = ? " . "");
     $get_shares->execute(array($this['root_id']));
     $shares = $get_shares->fetchAll(PDO::FETCH_ASSOC);
     $users = array();
     foreach ($shares as $share) {
         $users[] = $share['external_contact'] ? BlubberExternalContact::find($share['user_id']) : BlubberUser::find($share['user_id']);
     }
     return $users;
 }