protected function atompubPrepare()
 {
     $subscriberId = $this->trimmed('subscriber');
     $this->_subscriber = Profile::getKV('id', $subscriberId);
     if (!$this->_subscriber instanceof Profile) {
         // TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
         // TRANS: %d is the non-existing profile ID number.
         throw new ClientException(sprintf(_('No such profile id: %d.'), $subscriberId), 404);
     }
     $subscribedId = $this->trimmed('subscribed');
     $this->_subscribed = Profile::getKV('id', $subscribedId);
     if (!$this->_subscribed instanceof Profile) {
         // TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
         // TRANS: %d is the non-existing profile ID number.
         throw new ClientException(sprintf(_('No such profile id: %d.'), $subscribedId), 404);
     }
     $this->_subscription = Subscription::pkeyGet(array('subscriber' => $subscriberId, 'subscribed' => $subscribedId));
     if (!$this->_subscription instanceof Subscription) {
         // TRANS: Client exception thrown when trying to display a subscription for a non-subscribed profile ID.
         // TRANS: %1$d is the non-existing subscriber ID number, $2$d is the ID of the profile that was not subscribed to.
         $msg = sprintf(_('Profile %1$d not subscribed to profile %2$d.'), $subscriberId, $subscribedId);
         throw new ClientException($msg, 404);
     }
     return true;
 }
 /**
  * Prepare to run
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Client error displayed when trying to perform an action while not logged in.
         $this->clientError(_('You must be logged in to unsubscribe from a list.'));
     }
     // Only allow POST requests
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         // TRANS: Client error displayed when trying to use another method than POST.
         $this->clientError(_('This action only accepts POST requests.'));
     }
     // CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
     }
     $tagger_arg = $this->trimmed('tagger');
     $tag_arg = $this->trimmed('tag');
     $id = intval($this->arg('id'));
     if ($id) {
         $this->peopletag = Profile_list::getKV('id', $id);
     } else {
         // TRANS: Client error displayed when trying to perform an action without providing an ID.
         $this->clientError(_('No ID given.'), 404);
     }
     if (!$this->peopletag || $this->peopletag->private) {
         // TRANS: Client error displayed trying to reference a non-existing list.
         $this->clientError(_('No such list.'), 404);
     }
     $this->tagger = Profile::getKV('id', $this->peopletag->tagger);
     return true;
 }
Exemplo n.º 3
0
function silencespammer($filter, $user, $minimum, $percent)
{
    printfnq("Testing user %s\n", $user->nickname);
    $profile = Profile::getKV('id', $user->id);
    if ($profile->isSilenced()) {
        printfnq("Already silenced %s\n", $user->nickname);
        return;
    }
    $cnt = $profile->noticeCount();
    if ($cnt < $minimum) {
        printfnq("Only %d notices posted (minimum %d); skipping\n", $cnt, $minimum);
        return;
    }
    $ss = new Spam_score();
    $ss->query(sprintf("SELECT count(*) as spam_count " . "FROM notice join spam_score on notice.id = spam_score.notice_id " . "WHERE notice.profile_id = %d AND spam_score.is_spam = 1", $profile->id));
    while ($ss->fetch()) {
        $spam_count = $ss->spam_count;
    }
    $spam_percent = $spam_count * 100.0 / $cnt;
    if ($spam_percent > $percent) {
        printfnq("Silencing user %s (%d/%d = %0.2f%% spam)\n", $user->nickname, $spam_count, $cnt, $spam_percent);
        try {
            $profile->silence();
        } catch (Exception $e) {
            printfnq("Error: %s", $e->getMessage());
        }
    }
}
Exemplo n.º 4
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Client exception thrown when trying to view group private messages without being logged in.
         throw new ClientException(_m('Only logged-in users can view private messages.'), 403);
     }
     $id = $this->trimmed('id');
     $this->gm = Group_message::getKV('id', $id);
     if (empty($this->gm)) {
         // TRANS: Client exception thrown when trying to view a non-existing group private message.
         throw new ClientException(_m('No such message.'), 404);
     }
     $this->group = User_group::getKV('id', $this->gm->to_group);
     if (empty($this->group)) {
         // TRANS: Server exception thrown when trying to view group private messages for a non-exsting group.
         throw new ServerException(_m('Group not found.'));
     }
     if (!$this->user->isMember($this->group)) {
         // TRANS: Client exception thrown when trying to view a group private message without being a group member.
         throw new ClientException(_m('Cannot read message.'), 403);
     }
     $this->sender = Profile::getKV('id', $this->gm->from_profile);
     if (empty($this->sender)) {
         // TRANS: Server exception thrown when trying to view a group private message without a sender.
         throw new ServerException(_m('No sender found.'));
     }
     return true;
 }
Exemplo n.º 5
0
 /**
  * Check pre-requisites and instantiate attributes
  *
  * @param Array $args array of arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     // CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
     }
     // Only for logged-in users
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     // Profile to subscribe to
     $tagged_id = $this->arg('tagged');
     $this->tagged = Profile::getKV('id', $tagged_id);
     if (empty($this->tagged)) {
         // TRANS: Client error displayed trying to perform an action related to a non-existing profile.
         $this->clientError(_('No such profile.'));
     }
     $id = $this->arg('peopletag_id');
     $this->peopletag = Profile_list::getKV('id', $id);
     if (empty($this->peopletag)) {
         // TRANS: Client error displayed trying to reference a non-existing list.
         $this->clientError(_('No such list.'));
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  * constructor
  *
  * Also initializes the owner attribute.
  *
  * @param Notice $notice The notice we'll display
  */
 function __construct($peopletag, $current, $out = null)
 {
     parent::__construct($out);
     $this->peopletag = $peopletag;
     $this->current = $current;
     $this->profile = Profile::getKV('id', $this->peopletag->tagger);
 }
 function show()
 {
     $links = array();
     $you = false;
     $cur = common_current_user();
     foreach ($this->getProfiles() as $id) {
         if ($cur && $cur->id == $id) {
             $you = true;
             // TRANS: Reference to the logged in user in favourite list.
             array_unshift($links, _m('FAVELIST', 'You'));
         } else {
             $profile = Profile::getKV('id', $id);
             if ($profile instanceof Profile) {
                 $links[] = sprintf('<a class="h-card" href="%s">%s</a>', htmlspecialchars($profile->getUrl()), htmlspecialchars($profile->getBestName()));
             }
         }
     }
     if ($links) {
         $count = count($links);
         $msg = $this->getListMessage($count, $you);
         $out = sprintf($msg, $this->magicList($links));
         $this->showStart();
         $this->out->raw($out);
         $this->showEnd();
         return $count;
     } else {
         return 0;
     }
 }
Exemplo n.º 8
0
 /**
  * Prepare to run
  */
 function prepare($args)
 {
     parent::prepare($args);
     $cur = common_current_user();
     if (empty($cur)) {
         // TRANS: Client error displayed trying to approve group membership while not logged in.
         $this->clientError(_('Must be logged in.'), 403);
     }
     if ($this->arg('profile_id')) {
         $this->profile = Profile::getKV('id', $this->arg('profile_id'));
     } else {
         // TRANS: Client error displayed trying to approve subscriptionswithout specifying a profile to approve.
         $this->clientError(_('Must specify a profile.'));
     }
     $this->request = Subscription_queue::pkeyGet(array('subscriber' => $this->profile->id, 'subscribed' => $cur->id));
     if (empty($this->request)) {
         // TRANS: Client error displayed trying to approve subscription for a non-existing request.
         // TRANS: %s is a user nickname.
         $this->clientError(sprintf(_('%s is not in the moderation queue for your subscriptions.'), $this->profile->nickname), 403);
     }
     $this->approve = (bool) $this->arg('approve');
     $this->cancel = (bool) $this->arg('cancel');
     if (!$this->approve && !$this->cancel) {
         // TRANS: Client error displayed trying to approve/deny subscription.
         $this->clientError(_('Internal error: received neither cancel nor abort.'));
     }
     if ($this->approve && $this->cancel) {
         // TRANS: Client error displayed trying to approve/deny  subscription
         $this->clientError(_('Internal error: received both cancel and abort.'));
     }
     return true;
 }
 protected function doPreparation()
 {
     $profile_id = $this->int('unsubscribeto');
     $this->target = Profile::getKV('id', $profile_id);
     if (!$this->target instanceof Profile) {
         throw new NoProfileException($profile_id);
     }
 }
Exemplo n.º 10
0
 function showFeedForm($mirror)
 {
     $profile = Profile::getKV('id', $mirror->subscribed);
     if ($profile) {
         $form = new EditMirrorForm($this, $profile);
         $form->show();
     }
 }
Exemplo n.º 11
0
 function prepare($args)
 {
     parent::prepare($args);
     $args = $this->returnToArgs();
     $this->profile = Profile::getKV('nickname', $args[1]['nickname']);
     //die(print_r($this->profile));
     gnusocial_profile_merge($this->profile);
     return true;
 }
Exemplo n.º 12
0
 function handle($data)
 {
     assert(is_array($data));
     assert(is_string($data['salmonuri']));
     assert(is_string($data['entry']));
     $actor = Profile::getKV($data['actor']);
     Salmon::post($data['salmonuri'], $data['entry'], $actor->getUser());
     // @fixme detect failure and attempt to resend
     return true;
 }
 protected function atompubPrepare()
 {
     $this->_profile = Profile::getKV('id', $this->trimmed('profile'));
     if (!$this->_profile instanceof Profile) {
         // TRANS: Client exception.
         throw new ClientException(_('No such profile.'), 404);
     }
     $this->_memberships = Group_member::byMember($this->_profile->id, $this->offset, $this->limit);
     return true;
 }
Exemplo n.º 14
0
 function getMember()
 {
     $member = Profile::getKV('id', $this->profile_id);
     if (empty($member)) {
         // TRANS: Exception thrown providing an invalid profile ID.
         // TRANS: %s is the invalid profile ID.
         throw new Exception(sprintf(_("Profile ID %s is invalid."), $this->profile_id));
     }
     return $member;
 }
Exemplo n.º 15
0
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $args = $this->returnToArgs();
     $this->photoid = $args[1]['photoid'];
     $this->photo = GNUsocialPhoto::getKV('id', $this->photoid);
     $this->notice = Notice::getKV('id', $this->photo->notice_id);
     $this->user = Profile::getKV('id', $this->notice->profile_id);
     $this->conv = $this->notice->getConversation();
     return true;
 }
Exemplo n.º 16
0
 function handle($data)
 {
     assert(is_array($data));
     assert(is_string($data['salmonuri']));
     assert(is_string($data['entry']));
     $actor = Profile::getKV($data['actor']);
     $target = array_key_exists('target', $data) ? Profile::getKV($data['target']) : null;
     Salmon::post($data['salmonuri'], $data['entry'], $actor, $target);
     // @fixme detect failure and attempt to resend
     return true;
 }
Exemplo n.º 17
0
 protected function validateProfile($id)
 {
     $id = intval($id);
     $profile = Profile::getKV('id', $id);
     if ($profile && $profile->id != $this->user->id) {
         return $profile;
     }
     // TRANS: Error message returned to user when setting up feed mirroring,
     // TRANS: but we were unable to resolve the given URL to a working feed.
     $this->clientError(_m('Invalid profile for mirroring.'));
 }
 protected function atompubPrepare()
 {
     $subscriber = $this->trimmed('subscriber');
     $this->_profile = Profile::getKV('id', $subscriber);
     if (!$this->_profile instanceof Profile) {
         // TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
         // TRANS: %d is the non-existing profile ID number.
         throw new ClientException(sprintf(_('No such profile id: %d.'), $subscriber), 404);
     }
     $this->_subscriptions = Subscription::bySubscriber($this->_profile->id, $this->offset, $this->limit);
     return true;
 }
Exemplo n.º 19
0
 function prepare($args)
 {
     parent::prepare($args);
     $args = $this->returnToArgs();
     $username = $args[1]['nickname'];
     $this->albumid = $args[1]['albumid'];
     if (common_valid_profile_tag($username) == 0) {
         $this->user = null;
     } else {
         $this->user = Profile::getKV('nickname', $username);
     }
     return true;
 }
Exemplo n.º 20
0
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->_profile = Profile::getKV('id', $this->trimmed('profile'));
     if (!$this->_profile instanceof Profile) {
         // TRANS: Client exception thrown when requesting a favorite feed for a non-existing profile.
         throw new ClientException(_('No such profile.'), 404);
     }
     $offset = ($this->page - 1) * $this->count;
     $limit = $this->count + 1;
     $this->_faves = Fave::byProfile($this->_profile->id, $offset, $limit);
     return true;
 }
 static function cleanup($profile_list)
 {
     $subs = new self();
     $subs->profile_tag_id = $profile_list->id;
     $subs->find();
     while ($subs->fetch()) {
         $profile = Profile::getKV('id', $subs->profile_id);
         Event::handle('StartUnsubscribePeopletag', array($profile_list, $profile));
         // Delete anyway
         $subs->delete();
         Event::handle('StartUnsubscribePeopletag', array($profile_list, $profile));
     }
 }
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  *
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     if ($this->format !== 'json') {
         $this->clientError('This method currently only serves JSON.', 415);
     }
     $profileurl = urldecode($this->arg('profileurl'));
     // TODO: Make this more ... unique!
     $this->profile = Profile::getKV('profileurl', $profileurl);
     if (!$this->profile instanceof Profile) {
         // TRANS: Client error displayed when requesting profile information for a non-existing profile.
         $this->clientError(_('Profile not found.'), 404);
     }
     return true;
 }
Exemplo n.º 23
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     $token = $this->trimmed('token');
     if (empty($token) || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token. Try again, please.'));
     }
     $id = $this->trimmed('blockto');
     if (empty($id)) {
         // TRANS: Client error displayed trying to block a user from a group while not specifying a to be blocked user profile.
         $this->clientError(_('No profile specified.'));
     }
     $this->profile = Profile::getKV('id', $id);
     if (empty($this->profile)) {
         // TRANS: Client error displayed trying to block a user from a group while specifying a non-existing profile.
         $this->clientError(_('No profile with that ID.'));
     }
     $group_id = $this->trimmed('blockgroup');
     if (empty($group_id)) {
         // TRANS: Client error displayed trying to block a user from a group while not specifying a group to block a profile from.
         $this->clientError(_('No group specified.'));
     }
     $this->group = User_group::getKV('id', $group_id);
     if (empty($this->group)) {
         // TRANS: Client error displayed trying to block a user from a group while specifying a non-existing group.
         $this->clientError(_('No such group.'));
     }
     $user = common_current_user();
     if (!$user->isAdmin($this->group)) {
         // TRANS: Client error displayed trying to block a user from a group while not being an admin user.
         $this->clientError(_('Only an admin can block group members.'), 401);
     }
     if (Group_block::isBlocked($this->group, $this->profile)) {
         // TRANS: Client error displayed trying to block a user from a group while user is already blocked from the given group.
         $this->clientError(_('User is already blocked from group.'));
     }
     // XXX: could have proactive blocks, but we don't have UI for it.
     if (!$this->profile->isMember($this->group)) {
         // TRANS: Client error displayed trying to block a user from a group while user is not a member of given group.
         $this->clientError(_('User is not a member of group.'));
     }
     return true;
 }
Exemplo n.º 24
0
 function handle($args)
 {
     parent::handle($args);
     if (!common_logged_in()) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         common_redirect(common_local_url('subscriptions', array('nickname' => $this->scoped->nickname)));
     }
     /* Use a session token for CSRF protection. */
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token. ' . 'Try again, please.'));
     }
     $other_id = $this->arg('unsubscribeto');
     if (!$other_id) {
         // TRANS: Client error displayed when trying to unsubscribe without providing a profile ID.
         $this->clientError(_('No profile ID in request.'));
     }
     $other = Profile::getKV('id', $other_id);
     if (!$other instanceof Profile) {
         // TRANS: Client error displayed when trying to unsubscribe while providing a non-existing profile ID.
         $this->clientError(_('No profile with that ID.'));
     }
     try {
         Subscription::cancel($this->scoped, $other);
     } catch (Exception $e) {
         $this->clientError($e->getMessage());
     }
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Page title for page to unsubscribe.
         $this->element('title', null, _('Unsubscribed'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $subscribe = new SubscribeForm($this, $other);
         $subscribe->show();
         $this->elementEnd('body');
         $this->endHTML();
     } else {
         common_redirect(common_local_url('subscriptions', array('nickname' => $this->scoped->nickname)), 303);
     }
 }
Exemplo n.º 25
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     $token = $this->trimmed('token');
     if (empty($token) || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token. Try again, please.'));
     }
     $id = $this->trimmed('profileid');
     if (empty($id)) {
         // TRANS: Client error displayed when not providing a profile ID on the Make Admin page.
         $this->clientError(_('No profile specified.'));
     }
     $this->profile = Profile::getKV('id', $id);
     if (empty($this->profile)) {
         // TRANS: Client error displayed when specifying an invalid profile ID on the Make Admin page.
         $this->clientError(_('No profile with that ID.'));
     }
     $group_id = $this->trimmed('groupid');
     if (empty($group_id)) {
         // TRANS: Client error displayed when not providing a group ID on the Make Admin page.
         $this->clientError(_('No group specified.'));
     }
     $this->group = User_group::getKV('id', $group_id);
     if (empty($this->group)) {
         // TRANS: Client error displayed when providing an invalid group ID on the Make Admin page.
         $this->clientError(_('No such group.'));
     }
     $user = common_current_user();
     if (!$user->isAdmin($this->group) && !$user->hasRight(Right::MAKEGROUPADMIN)) {
         // TRANS: Client error displayed when trying to make another user admin on the Make Admin page while not an admin.
         $this->clientError(_('Only an admin can make another user an admin.'), 401);
     }
     if ($this->profile->isAdmin($this->group)) {
         // TRANS: Client error displayed when trying to make another user admin on the Make Admin page who already is admin.
         // TRANS: %1$s is the user that is already admin, %2$s is the group user is already admin for.
         $this->clientError(sprintf(_('%1$s is already an admin for group "%2$s".'), $this->profile->getBestName(), $this->group->getBestName()), 401);
     }
     return true;
 }
Exemplo n.º 26
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     $token = $this->trimmed('token');
     if (empty($token) || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token. Try again, please.'));
     }
     $id = $this->trimmed('unblockto');
     if (empty($id)) {
         // TRANS: Client error displayed when trying to unblock a user from a group without providing a profile.
         $this->clientError(_('No profile specified.'));
     }
     $this->profile = Profile::getKV('id', $id);
     if (empty($this->profile)) {
         // TRANS: Client error displayed when trying to unblock a user from a group without providing an existing profile.
         $this->clientError(_('No profile with that ID.'));
     }
     $group_id = $this->trimmed('unblockgroup');
     if (empty($group_id)) {
         // TRANS: Client error displayed when trying to unblock a user from a group without providing a group.
         $this->clientError(_('No group specified.'));
     }
     $this->group = User_group::getKV('id', $group_id);
     if (empty($this->group)) {
         // TRANS: Client error displayed when trying to unblock a user from a non-existing group.
         $this->clientError(_('No such group.'));
     }
     $user = common_current_user();
     if (!$user->isAdmin($this->group)) {
         // TRANS: Client error displayed when trying to unblock a user from a group without being an administrator for the group.
         $this->clientError(_('Only an admin can unblock group members.'), 401);
     }
     if (!Group_block::isBlocked($this->group, $this->profile)) {
         // TRANS: Client error displayed when trying to unblock a non-blocked user from a group.
         $this->clientError(_('User is not blocked from group.'));
     }
     return true;
 }
 /**
  * Handle the data
  *
  * @param array $data associative array of user & bookmark info from DeliciousBackupImporter::importBookmark()
  *
  * @return boolean success value
  */
 function handle($data)
 {
     $profile = Profile::getKV('id', $data['profile_id']);
     try {
         $saved = Bookmark::saveNew($profile, $data['title'], $data['url'], $data['tags'], $data['description'], array('created' => $data['created'], 'distribute' => false));
     } catch (ClientException $ce) {
         // Most likely a duplicate -- continue on with the rest!
         common_log(LOG_ERR, "Error importing delicious bookmark to {$data['url']}: " . $ce->getMessage());
         return true;
     } catch (Exception $ex) {
         if (preg_match("/DB Error: already exists/", $ex->getMessage())) {
             common_log(LOG_ERR, "Error importing delicious bookmark to {$data['url']}: " . $ce->getMessage());
             return true;
         } else {
             throw $ex;
         }
     }
     return true;
 }
Exemplo n.º 28
0
 static function newAlbum($profile_id, $album_name, $album_description)
 {
     //TODO: Should use foreign key instead...
     if (!Profile::getKV('id', $profile_id)) {
         //Is this a bit extreme?
         throw new ServerException(_m('No such user exists with id ' . $profile_id . ', couldn\'t create album.'));
     }
     $album = new GNUsocialPhotoAlbum();
     $album->profile_id = $profile_id;
     $album->album_name = $album_name;
     $album->album_description = $album_description;
     $album->album_id = $album->insert();
     if (!$album->album_id) {
         common_log_db_error($album, 'INSERT', __FILE__);
         throw new ServerException(_m('Error creating new album.'));
     }
     common_log(LOG_INFO, 'album_id : ' . $album->album_id);
     return $album;
 }
 protected function atompubPrepare()
 {
     $this->_profile = Profile::getKV('id', $this->trimmed('profile'));
     if (!$this->_profile instanceof Profile) {
         // TRANS: Client exception.
         throw new ClientException(_('No such profile.'), 404);
     }
     $this->_group = User_group::getKV('id', $this->trimmed('group'));
     if (!$this->_group instanceof User_group) {
         // TRANS: Client exception thrown when referencing a non-existing group.
         throw new ClientException(_('No such group.'), 404);
     }
     $kv = array('group_id' => $groupId, 'profile_id' => $this->_profile->id);
     $this->_membership = Group_member::pkeyGet($kv);
     if (!$this->_membership instanceof Group_member) {
         // TRANS: Client exception thrown when trying to show membership of a non-subscribed group
         throw new ClientException(_('Not a member.'), 404);
     }
     return true;
 }
Exemplo n.º 30
0
 /**
  * Constructor
  *
  * @param List    $list    the list for the feed
  * @param User    $cur     the current authenticated user, if any
  * @param boolean $indent  flag to turn indenting on or off
  *
  * @return void
  */
 function __construct($list, $cur = null, $indent = true)
 {
     parent::__construct($cur, $indent);
     $this->list = $list;
     $this->tagger = Profile::getKV('id', $list->tagger);
     // TRANS: Title in atom list notice feed. %1$s is a list name, %2$s is a tagger's nickname.
     $title = sprintf(_('Timeline for people in list %1$s by %2$s'), $list->tag, $this->tagger->nickname);
     $this->setTitle($title);
     $sitename = common_config('site', 'name');
     $subtitle = sprintf(_('Updates from %1$s\'s list %2$s on %3$s!'), $this->tagger->nickname, $list->tag, $sitename);
     $this->setSubtitle($subtitle);
     $avatar = $this->tagger->avatarUrl(AVATAR_PROFILE_SIZE);
     $this->setLogo($avatar);
     $this->setUpdated('now');
     $self = common_local_url('ApiTimelineList', array('user' => $this->tagger->nickname, 'id' => $list->tag, 'format' => 'atom'));
     $this->setId($self);
     $this->setSelfLink($self);
     $ao = ActivityObject::fromPeopletag($this->list);
     $this->addAuthorRaw($ao->asString('author'));
     $this->addLink($this->list->getUri());
 }