/** * Prepare the action * * Reads and validates arguments and instantiates the attributes. * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $nickname_arg = $this->arg('nickname'); $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); common_redirect(common_local_url('showgroup', $args), 301); } if (!$nickname) { // TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname. $this->clientError(_('No nickname.'), 404); } $local = Local_group::getKV('nickname', $nickname); if (!$local) { // TRANS: Client error displayed when requesting a group RSS feed for group that does not exist. $this->clientError(_('No such group.'), 404); } $this->group = User_group::getKV('id', $local->group_id); if (!$this->group) { // TRANS: Client error displayed when requesting a group RSS feed for an object that is not a group. $this->clientError(_('No such group.'), 404); } $this->notices = $this->getNotices($this->limit); return true; }
function updateGroupUrls() { printfnq("Updating group URLs...\n"); $group = new User_group(); if ($group->find()) { while ($group->fetch()) { try { printfv("Updating group {$group->nickname}..."); $orig = User_group::getKV('id', $group->id); if (!empty($group->original_logo)) { $group->original_logo = Avatar::url(basename($group->original_logo)); $group->homepage_logo = Avatar::url(basename($group->homepage_logo)); $group->stream_logo = Avatar::url(basename($group->stream_logo)); $group->mini_logo = Avatar::url(basename($group->mini_logo)); } // XXX: this is a hack to see if a group is local or not $localUri = common_local_url('groupbyid', array('id' => $group->id)); if ($group->getUri() != $localUri) { $group->mainpage = common_local_url('showgroup', array('nickname' => $group->nickname)); } $group->update($orig); printfv("DONE."); } catch (Exception $e) { echo "Can't update avatars for group " . $group->nickname . ": " . $e->getMessage(); } } } }
protected function prepare(array $args = array()) { parent::prepare($args); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $nickname_arg = $this->arg('nickname'); $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); if ($this->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('groupqueue', $args), 301); } if (!$nickname) { // TRANS: Client error displayed when trying to view group members without providing a group nickname. $this->clientError(_('No nickname.'), 404); } $local = Local_group::getKV('nickname', $nickname); if (!$local) { // TRANS: Client error displayed when trying to view group members for a non-existing group. $this->clientError(_('No such group.'), 404); } $this->group = User_group::getKV('id', $local->group_id); if (!$this->group) { // TRANS: Client error displayed when trying to view group members for an object that is not a group. $this->clientError(_('No such group.'), 404); } $cur = common_current_user(); if (!$cur || !$cur->isAdmin($this->group)) { // TRANS: Client error displayed when trying to approve group applicants without being a group administrator. $this->clientError(_('Only the group admin may approve users.')); } return true; }
function prepare($args) { parent::prepare($args); $nickname_arg = $this->arg('nickname'); if (empty($nickname_arg)) { // TRANS: Client error displayed when requesting Friends of a Friend feed without providing a group nickname. $this->clientError(_('No such group.'), 404); } $this->nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $this->nickname) { common_redirect(common_local_url('foafgroup', array('nickname' => $this->nickname)), 301); return false; } $local = Local_group::getKV('nickname', $this->nickname); if (!$local) { // TRANS: Client error displayed when requesting Friends of a Friend feed for a non-local group. $this->clientError(_('No such group.'), 404); } $this->group = User_group::getKV('id', $local->group_id); if (!$this->group) { // TRANS: Client error displayed when requesting Friends of a Friend feed for a nickname that is not a group. $this->clientError(_('No such group.'), 404); } common_set_returnto($this->selfUrl()); return true; }
protected function prepare(array $args = array()) { parent::prepare($args); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $nickname_arg = $this->arg('nickname'); $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); if ($this->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('blockedfromgroup', $args), 301); } if (!$nickname) { // TRANS: Client error displayed when requesting a list of blocked users for a group without providing a group nickname. $this->clientError(_('No nickname.'), 404); } $local = Local_group::getKV('nickname', $nickname); if (!$local) { // TRANS: Client error displayed when requesting a list of blocked users for a non-local group. $this->clientError(_('No such group.'), 404); } $this->group = User_group::getKV('id', $local->group_id); if (!$this->group) { // TRANS: Client error displayed when requesting a list of blocked users for a non-existing group. $this->clientError(_('No such group.'), 404); } return true; }
/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { parent::prepare($argarray); $cur = common_current_user(); if (empty($cur)) { // TRANS: Client exception thrown when trying to view group inbox while not logged in. throw new ClientException(_m('Only for logged-in users.'), 403); } $nicknameArg = $this->trimmed('nickname'); $nickname = common_canonical_nickname($nicknameArg); if ($nickname != $nicknameArg) { $url = common_local_url('groupinbox', array('nickname' => $nickname)); common_redirect($url); } $localGroup = Local_group::getKV('nickname', $nickname); if (empty($localGroup)) { // TRANS: Client exception thrown when trying to view group inbox for non-existing group. throw new ClientException(_m('No such group.'), 404); } $this->group = User_group::getKV('id', $localGroup->group_id); if (empty($this->group)) { // TRANS: Client exception thrown when trying to view group inbox for non-existing group. throw new ClientException(_m('No such group.'), 404); } if (!$cur->isMember($this->group)) { // TRANS: Client exception thrown when trying to view group inbox while not a member. throw new ClientException(_m('Only for members.'), 403); } $this->page = $this->trimmed('page'); if (!$this->page) { $this->page = 1; } $this->gm = Group_message::forGroup($this->group, ($this->page - 1) * MESSAGES_PER_PAGE, MESSAGES_PER_PAGE + 1); return true; }
/** * 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; }
/** * Prepare to run */ function prepare($args) { parent::prepare($args); if (!common_logged_in()) { // TRANS: Client error displayed when trying to leave a group while not logged in. $this->clientError(_('You must be logged in to leave a group.')); } $nickname_arg = $this->trimmed('nickname'); $id = intval($this->arg('id')); if ($id) { $this->group = User_group::getKV('id', $id); } else { if ($nickname_arg) { $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); common_redirect(common_local_url('leavegroup', $args), 301); } $local = Local_group::getKV('nickname', $nickname); if (!$local) { // TRANS: Client error displayed when trying to leave a non-local group. $this->clientError(_('No such group.'), 404); } $this->group = User_group::getKV('id', $local->group_id); } else { // TRANS: Client error displayed when trying to leave a group without providing a group name or group ID. $this->clientError(_('No nickname or ID.'), 404); } } if (!$this->group) { // TRANS: Client error displayed when trying to leave a non-existing group. $this->clientError(_('No such group.'), 404); } $cur = common_current_user(); if (empty($cur)) { // TRANS: Client error displayed when trying to leave a group while not logged in. $this->clientError(_('Must be logged in.'), 403); } if ($this->arg('profile_id')) { if ($cur->isAdmin($this->group)) { $this->profile = Profile::getKV('id', $this->arg('profile_id')); } else { // TRANS: Client error displayed when trying to approve or cancel a group join request without // TRANS: being a group administrator. $this->clientError(_('Only group admin can approve or cancel join requests.'), 403); } } else { $this->profile = $cur->getProfile(); } $this->request = Group_join_queue::pkeyGet(array('profile_id' => $this->profile->id, 'group_id' => $this->group->id)); if (empty($this->request)) { // TRANS: Client error displayed when trying to approve a non-existing group join request. // TRANS: %s is a user nickname. $this->clientError(sprintf(_('%s is not in the moderation queue for this group.'), $this->profile->nickname), 403); } return true; }
public function getProfile() { $group = User_group::getKV('id', $this->group_id); if (!$group instanceof User_group) { return null; // TODO: Throw exception when other code is ready } return $group->getProfile(); }
function getGroup() { $group = User_group::getKV('id', $this->group_id); if (empty($group)) { // TRANS: Exception thrown providing an invalid group ID. // TRANS: %s is the invalid group ID. throw new Exception(sprintf(_("Group ID %s is invalid."), $this->group_id)); } return $group; }
/** * 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; }
function prepare($args) { parent::prepare($args); $id = $this->arg('id'); if (!$id) { // TRANS: Client error displayed referring to a group's permalink without providing a group ID. $this->clientError(_('No ID.')); } common_debug("Got ID {$id}"); $this->group = User_group::getKV('id', $id); if (!$this->group) { // TRANS: Client error displayed referring to a group's permalink for a non-existing group ID. $this->clientError(_('No such group.'), 404); } return true; }
/** * 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; }
/** * Prepare to run */ protected function prepare(array $args = array()) { parent::prepare($args); if (!common_logged_in()) { // TRANS: Client error displayed when trying to join a group while not logged in. $this->clientError(_('You must be logged in to join a group.')); } $nickname_arg = $this->trimmed('nickname'); $id = intval($this->arg('id')); if ($id) { $this->group = User_group::getKV('id', $id); } else { if ($nickname_arg) { $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); common_redirect(common_local_url('leavegroup', $args), 301); } $local = Local_group::getKV('nickname', $nickname); if (!$local) { // TRANS: Client error displayed when trying to join a non-local group. $this->clientError(_('No such group.'), 404); } $this->group = User_group::getKV('id', $local->group_id); } else { // TRANS: Client error displayed when trying to join a group without providing a group name or group ID. $this->clientError(_('No nickname or ID.'), 404); } } if (!$this->group) { // TRANS: Client error displayed when trying to join a non-existing group. $this->clientError(_('No such group.'), 404); } if ($this->scoped->isMember($this->group)) { // TRANS: Client error displayed when trying to join a group while already a member. $this->clientError(_('You are already a member of that group.'), 403); } if (Group_block::isBlocked($this->group, $this->scoped)) { // TRANS: Client error displayed when trying to join a group while being blocked form joining it. $this->clientError(_('You have been blocked from that group by the admin.'), 403); } return true; }
/** * 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; }
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; }
/** * Prepare to run * * @fixme merge common setup code with other group actions * @fixme allow group admins to delete their own groups */ function prepare($args) { parent::prepare($args); if (!common_logged_in()) { // TRANS: Client error when trying to delete group while not logged in. $this->clientError(_('You must be logged in to delete a group.')); } $nickname_arg = $this->trimmed('nickname'); $id = intval($this->arg('id')); if ($id) { $this->group = User_group::getKV('id', $id); } else { if ($nickname_arg) { $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); common_redirect(common_local_url('leavegroup', $args), 301); } $local = Local_group::getKV('nickname', $nickname); if (!$local) { // TRANS: Client error when trying to delete a non-local group. $this->clientError(_('No such group.'), 404); } $this->group = User_group::getKV('id', $local->group_id); } else { // TRANS: Client error when trying to delete a group without providing a nickname or ID for the group. $this->clientError(_('No nickname or ID.'), 404); } } if (!$this->group) { // TRANS: Client error when trying to delete a non-existing group. $this->clientError(_('No such group.'), 404); } $cur = common_current_user(); if (!$cur->hasRight(Right::DELETEGROUP)) { // TRANS: Client error when trying to delete a group without having the rights to delete it. $this->clientError(_('You are not allowed to delete this group.'), 403); } return true; }
protected function prepare(array $args = array()) { parent::prepare($args); $id = $this->trimmed('id'); if (!$id) { // TRANS: Client error. $this->clientError(_m('No ID.')); } $this->group = User_group::getKV('id', $id); if (!$this->group instanceof User_group) { // TRANS: Client error. $this->clientError(_m('No such group.')); } $this->target = $this->group; $remote_group = Ostatus_profile::getKV('group_id', $id); if ($remote_group instanceof Ostatus_profile) { // TRANS: Client error. $this->clientError(_m('Cannot accept remote posts for a remote group.')); } return true; }
/** * Prepare to run */ protected function prepare(array $args = array()) { parent::prepare($args); if (!common_logged_in()) { // TRANS: Client error displayed trying to edit a group while not logged in. $this->clientError(_('You must be logged in to create a group.')); } $nickname_arg = $this->trimmed('nickname'); $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); common_redirect(common_local_url('editgroup', $args), 301); } if (!$nickname) { // TRANS: Client error displayed trying to edit a group while not proving a nickname for the group to edit. $this->clientError(_('No nickname.'), 404); } $groupid = $this->trimmed('groupid'); if ($groupid) { $this->group = User_group::getKV('id', $groupid); } else { $local = Local_group::getKV('nickname', $nickname); if ($local) { $this->group = User_group::getKV('id', $local->group_id); } } if (!$this->group) { // TRANS: Client error displayed trying to edit a non-existing group. $this->clientError(_('No such group.'), 404); } $cur = common_current_user(); if (!$cur->isAdmin($this->group)) { // TRANS: Client error displayed trying to edit a group while not being a group admin. $this->clientError(_('You must be an admin to edit the group.'), 403); } return true; }
protected function prepare(array $args = array()) { parent::prepare($args); $nickname_arg = $this->arg('nickname'); $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); if ($this->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('showgroup', $args), 301); } if (!$nickname) { // TRANS: Client error displayed if no nickname argument was given requesting a group page. $this->clientError(_('No nickname.'), 404); } $local = Local_group::getKV('nickname', $nickname); if (!$local) { $alias = Group_alias::getKV('alias', $nickname); if ($alias) { $args = array('id' => $alias->group_id); if ($this->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('groupbyid', $args), 301); } else { common_log(LOG_NOTICE, "Couldn't find local group for nickname '{$nickname}'"); // TRANS: Client error displayed if no remote group with a given name was found requesting group page. $this->clientError(_('No such group.'), 404); } } $this->group = User_group::getKV('id', $local->group_id); if (!$this->group instanceof User_group) { // TRANS: Client error displayed if no local group with a given name was found requesting group page. $this->clientError(_('No such group.'), 404); } }
/** * 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 send a private group message while not logged in. throw new ClientException(_m('Must be logged in.'), 403); } if (!$this->user->hasRight(Right::NEWMESSAGE)) { // TRANS: Exception thrown when user %s is not allowed to send a private group message. throw new Exception(sprintf(_m('User %s is not allowed to send private messages.'), $this->user->nickname)); } $nicknameArg = $this->trimmed('nickname'); $nickname = common_canonical_nickname($nicknameArg); if ($nickname != $nicknameArg) { $url = common_local_url('newgroupmessage', array('nickname' => $nickname)); common_redirect($url, 301); } $localGroup = Local_group::getKV('nickname', $nickname); if (empty($localGroup)) { // TRANS: Client exception thrown when trying to send a private group message to a non-existing group. throw new ClientException(_m('No such group.'), 404); } $this->group = User_group::getKV('id', $localGroup->group_id); if (empty($this->group)) { // TRANS: Client exception thrown when trying to send a private group message to a non-existing group. throw new ClientException(_m('No such group.'), 404); } // This throws an exception on error Group_privacy_settings::ensurePost($this->user, $this->group); // If we're posted to, check session token and get text if ($this->isPost()) { $this->checkSessionToken(); $this->text = $this->trimmed('content'); } return true; }
/** * Filters a list of recipient ID URIs to just those for local delivery. * @param Profile local profile of sender * @param array in/out &$attention_uris set of URIs, will be pruned on output * @return array of group IDs */ public static function filterAttention(Profile $sender, array $attention) { common_log(LOG_DEBUG, "Original reply recipients: " . implode(', ', array_keys($attention))); $groups = array(); $replies = array(); foreach ($attention as $recipient => $type) { // Is the recipient a local user? $user = User::getKV('uri', $recipient); if ($user instanceof User) { // @todo FIXME: Sender verification, spam etc? $replies[] = $recipient; continue; } // Is the recipient a local group? // TODO: $group = User_group::getKV('uri', $recipient); $id = OStatusPlugin::localGroupFromUrl($recipient); if ($id) { $group = User_group::getKV('id', $id); if ($group instanceof User_group) { // Deliver to all members of this local group if allowed. if ($sender->isMember($group)) { $groups[] = $group->id; } else { common_log(LOG_DEBUG, sprintf('Skipping reply to local group %s as sender %d is not a member', $group->getNickname(), $sender->id)); } continue; } else { common_log(LOG_DEBUG, "Skipping reply to bogus group {$recipient}"); } } // Is the recipient a remote user or group? try { $oprofile = self::ensureProfileURI($recipient); if ($oprofile->isGroup()) { // Deliver to local members of this remote group. // @todo FIXME: Sender verification? $groups[] = $oprofile->group_id; } else { // may be canonicalized or something $replies[] = $oprofile->getUri(); } continue; } catch (Exception $e) { // Neither a recognizable local nor remote user! common_log(LOG_DEBUG, "Skipping reply to unrecognized profile {$recipient}: " . $e->getMessage()); } } common_log(LOG_DEBUG, "Local reply recipients: " . implode(', ', $replies)); common_log(LOG_DEBUG, "Local group recipients: " . implode(', ', $groups)); return array($groups, $replies); }
/** * add a new favorite * * @return void */ function addMembership() { // XXX: Refactor this; all the same for atompub if (empty($this->auth_user) || $this->auth_user->id != $this->_profile->id) { // TRANS: Client exception thrown when trying subscribe someone else to a group. throw new ClientException(_("Cannot add someone else's" . " membership."), 403); } $xml = file_get_contents('php://input'); $dom = DOMDocument::loadXML($xml); if ($dom->documentElement->namespaceURI != Activity::ATOM || $dom->documentElement->localName != 'entry') { // TRANS: Client error displayed when not using an Atom entry. throw new ClientException(_('Atom post must be an Atom entry.')); return; } $activity = new Activity($dom->documentElement); $membership = null; if (Event::handle('StartAtomPubNewActivity', array(&$activity))) { if ($activity->verb != ActivityVerb::JOIN) { // TRANS: Client error displayed when not using the join verb. throw new ClientException(_('Can only handle join activities.')); } $groupObj = $activity->objects[0]; if ($groupObj->type != ActivityObject::GROUP) { // TRANS: Client exception thrown when trying to join something which is not a group throw new ClientException(_('Can only join groups.')); } $group = User_group::getKV('uri', $groupObj->id); if (empty($group)) { // XXX: import from listed URL or something // TRANS: Client exception thrown when trying to subscribe to a non-existing group. throw new ClientException(_('Unknown group.')); } $old = Group_member::pkeyGet(array('profile_id' => $this->auth_user->id, 'group_id' => $group->id)); if (!empty($old)) { // TRANS: Client exception thrown when trying to subscribe to an already subscribed group. throw new ClientException(_('Already a member.')); } $profile = $this->auth_user->getProfile(); if (Group_block::isBlocked($group, $profile)) { // XXX: import from listed URL or something // TRANS: Client exception thrown when trying to subscribe to group while blocked from that group. throw new ClientException(_('Blocked by admin.')); } $this->auth_user->joinGroup($group); Event::handle('EndAtomPubNewActivity', array($activity, $membership)); } if (!empty($membership)) { $act = $membership->asActivity(); header('Content-Type: application/atom+xml; charset=utf-8'); header('Content-Location: ' . $act->selfLink); $this->startXML(); $this->raw($act->asString(true, true, true)); $this->endXML(); } }
protected function filterAttention(array $attn) { $groups = array(); // TODO: context->attention $replies = array(); // TODO: context->attention foreach ($attn as $recipient => $type) { // Is the recipient a local user? $user = User::getKV('uri', $recipient); if ($user instanceof User) { // TODO: @fixme sender verification, spam etc? $replies[] = $recipient; continue; } // Is the recipient a remote group? $oprofile = Ostatus_profile::ensureProfileURI($recipient); if ($oprofile) { if (!$oprofile->isGroup()) { // may be canonicalized or something $replies[] = $oprofile->uri; } continue; } // Is the recipient a local group? // TODO: @fixme uri on user_group isn't reliable yet // $group = User_group::getKV('uri', $recipient); $id = OStatusPlugin::localGroupFromUrl($recipient); if ($id) { $group = User_group::getKV('id', $id); if ($group) { // Deliver to all members of this local group if allowed. $profile = $sender->localProfile(); if ($profile->isMember($group)) { $groups[] = $group->id; } else { common_log(LOG_INFO, "Skipping reply to local group {$group->nickname} as sender {$profile->id} is not a member"); } continue; } else { common_log(LOG_INFO, "Skipping reply to bogus group {$recipient}"); } } } return array($groups, $replies); }
/** * Correct group mentions * * We get the correct group ids in a $_POST var called "post_to_groups", formatted as a string with ids separated by colon, e.g. 4:5 * * @return boolean hook flag */ public function onEndFindMentions($sender, $text, &$mentions) { // get the correct group profiles if (isset($_POST['post_to_groups'])) { $correct_group_mentions = explode(':', $_POST['post_to_groups']); foreach ($correct_group_mentions as $group_id) { $correct_groups[] = User_group::getKV('id', $group_id); } // loop through the groups guessed by gnu social's common_find_mentions() and correct them foreach ($mentions as $mention_array_id => $mention) { foreach ($correct_groups as $correct_groups_array_id => $correct_group) { if ($mention['mentioned'][0]->nickname == $correct_group->nickname && !isset($mentions[$mention_array_id]['corrected'])) { $user_group_profile = Profile::getKV('id', $correct_group->profile_id); $mentions[$mention_array_id]['mentioned'][0] = $user_group_profile; $mentions[$mention_array_id]['url'] = $correct_group->permalink(); $mentions[$mention_array_id]['title'] = $correct_group->getFancyName(); $mentions[$mention_array_id]['corrected'] = true; // now we've used this unset($correct_groups[$correct_groups_array_id]); } } } } return true; }
/** * Handle the request * * Make a new notice for the update, save it, and show it * * @return void */ protected function handle() { parent::handle(); // Workaround for PHP returning empty $_POST and $_FILES when POST // length > post_max_size in php.ini if (empty($_FILES) && empty($_POST) && $_SERVER['CONTENT_LENGTH'] > 0) { // TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit. // TRANS: %s is the number of bytes of the CONTENT_LENGTH. $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH'])); $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); } if (empty($this->status)) { // TRANS: Client error displayed when the parameter "status" is missing. $this->clientError(_('Client must provide a \'status\' parameter with a value.')); } if (is_null($this->scoped)) { // TRANS: Client error displayed when updating a status for a non-existing user. $this->clientError(_('No such user.'), 404); } /* Do not call shortenlinks until the whole notice has been build */ // Check for commands $inter = new CommandInterpreter(); $cmd = $inter->handle_command($this->auth_user, $this->status); if ($cmd) { if ($this->supported($cmd)) { $cmd->execute(new Channel()); } // Cmd not supported? Twitter just returns your latest status. // And, it returns your last status whether the cmd was successful // or not! $this->notice = $this->auth_user->getCurrentNotice(); } else { $reply_to = null; if (!empty($this->in_reply_to_status_id)) { // Check whether notice actually exists $reply = Notice::getKV($this->in_reply_to_status_id); if ($reply) { $reply_to = $this->in_reply_to_status_id; } else { // TRANS: Client error displayed when replying to a non-existing notice. $this->clientError(_('Parent notice not found.'), 404); } } $upload = null; try { $upload = MediaFile::fromUpload('media', $this->scoped); } catch (NoUploadedMediaException $e) { // There was no uploaded media for us today. } if (isset($upload)) { $this->status .= ' ' . $upload->shortUrl(); /* Do not call shortenlinks until the whole notice has been build */ } // in Qvitter we shorten _before_ posting, so disble shortening here $status_shortened = $this->status; if (Notice::contentTooLong($status_shortened)) { if ($upload instanceof MediaFile) { $upload->delete(); } // TRANS: Client error displayed exceeding the maximum notice length. // TRANS: %d is the maximum lenth for a notice. $msg = _m('Maximum notice size is %d character, including attachment URL.', 'Maximum notice size is %d characters, including attachment URL.', Notice::maxContent()); /* Use HTTP 413 error code (Request Entity Too Large) * instead of basic 400 for better understanding */ $this->clientError(sprintf($msg, Notice::maxContent()), 413); } $content = html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'); $options = array('reply_to' => $reply_to); // ------------------------------------------------------------- // -------- Qvitter's post-to-the-right-group stuff! ----------- // ------------------------------------------------------------- // guess the groups by the content first, if we don't have group id:s as meta data $profile = Profile::getKV('id', $this->scoped->id); $guessed_groups = User_group::groupsFromText($content, $profile); // if the user has specified any group id:s, correct the guesswork if (strlen($this->post_to_groups) > 0) { // get the groups that the user wants to post to $group_ids = explode(':', $this->post_to_groups); $correct_groups = array(); foreach ($group_ids as $group_id) { $correct_groups[] = User_group::getKV('id', $group_id); } // correct the guesses $corrected_group_ids = array(); foreach ($guessed_groups as $guessed_group) { $id_to_keep = $guessed_group->id; foreach ($correct_groups as $k => $correct_group) { if ($correct_group->nickname == $guessed_group->nickname) { $id_to_keep = $correct_group->id; unset($correct_groups[$k]); break; } } $corrected_group_ids[$id_to_keep] = true; } // but we still want to post to all of the groups that the user specified by id // even if we couldn't use it to correct a bad guess foreach ($correct_groups as $correct_group) { $corrected_group_ids[$correct_group->id] = true; } $options['groups'] = array_keys($corrected_group_ids); } else { $guessed_ids = array(); foreach ($guessed_groups as $guessed_group) { $guessed_ids[$guessed_group->id] = true; } $options['groups'] = array_keys($guessed_ids); } // ------------------------------------------------------------- // ------ End of Qvitter's post-to-the-right-group stuff! ------ // ------------------------------------------------------------- if ($this->scoped->shareLocation()) { $locOptions = Notice::locationOptions($this->lat, $this->lon, null, null, $this->scoped); $options = array_merge($options, $locOptions); } try { $this->notice = Notice::saveNew($this->scoped->id, $content, $this->source, $options); } catch (Exception $e) { $this->clientError($e->getMessage(), $e->getCode()); } if (isset($upload)) { $upload->attachToNotice($this->notice); } } $this->showNotice(); }
function showQvitter() { $logged_in_user_nickname = ''; $logged_in_user_obj = false; $logged_in_user = common_current_user(); if ($logged_in_user) { $logged_in_user_nickname = $logged_in_user->nickname; $logged_in_user_obj = ApiAction::twitterUserArray($logged_in_user->getProfile()); } $registrationsclosed = false; if (common_config('site', 'closed') == 1 || common_config('site', 'inviteonly') == 1) { $registrationsclosed = true; } // check if the client's ip address is blocked for registration if (is_array(QvitterPlugin::settings("blocked_ips"))) { $client_ip_is_blocked = in_array($_SERVER['REMOTE_ADDR'], QvitterPlugin::settings("blocked_ips")); } $sitetitle = common_config('site', 'name'); $siterootdomain = common_config('site', 'server'); $qvitterpath = Plugin::staticPath('Qvitter', ''); $apiroot = common_path('api/', StatusNet::isHTTPS()); $attachmentroot = common_path('attachment/', StatusNet::isHTTPS()); $instanceurl = common_path('', StatusNet::isHTTPS()); // user's browser's language setting $user_browser_language = 'en'; // use english if we can't find the browser language if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $user_browser_language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); } common_set_returnto(''); // forget this // if this is a profile we add a link header for LRDD Discovery (see WebfingerPlugin.php) if (substr_count($_SERVER['REQUEST_URI'], '/') == 1) { $nickname = substr($_SERVER['REQUEST_URI'], 1); if (preg_match("/^[a-zA-Z0-9]+\$/", $nickname) == 1) { $acct = 'acct:' . $nickname . '@' . common_config('site', 'server'); $url = common_local_url('webfinger') . '?resource=' . $acct; foreach (array(Discovery::JRD_MIMETYPE, Discovery::XRD_MIMETYPE) as $type) { header('Link: <' . $url . '>; rel="' . Discovery::LRDD_REL . '"; type="' . $type . '"'); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php print $sitetitle; ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0"> <link rel="stylesheet" type="text/css" href="<?php print $qvitterpath; ?> css/qvitter.css?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/css/qvitter.css')); ?> " /> <link rel="stylesheet" type="text/css" href="<?php print $qvitterpath; ?> css/jquery.minicolors.css" /> <link rel="shortcut icon" type="image/x-icon" href="<?php print $qvitterpath; print QvitterPlugin::settings("favicon"); ?> "> <?php // if qvitter is a webapp and this is a users url we add feeds if (substr_count($_SERVER['REQUEST_URI'], '/') == 1) { $nickname = substr($_SERVER['REQUEST_URI'], 1); if (preg_match("/^[a-zA-Z0-9]+\$/", $nickname) == 1) { $user = User::getKV('nickname', $nickname); if (!isset($user->id)) { //error_log("QVITTER: Could not get user id for user with nickname: $nickname – REQUEST_URI: ".$_SERVER['REQUEST_URI']); } else { print '<link title="Notice feed for ' . $nickname . ' (Activity Streams JSON)" type="application/stream+json" href="' . $instanceurl . 'api/statuses/user_timeline/' . $user->id . '.as" rel="alternate">' . "\n"; print ' <link title="Notice feed for ' . $nickname . ' (RSS 1.0)" type="application/rdf+xml" href="' . $instanceurl . $nickname . '/rss" rel="alternate">' . "\n"; print ' <link title="Notice feed for ' . $nickname . ' (RSS 2.0)" type="application/rss+xml" href="' . $instanceurl . 'api/statuses/user_timeline/' . $user->id . '.rss" rel="alternate">' . "\n"; print ' <link title="Notice feed for ' . $nickname . ' (Atom)" type="application/atom+xml" href="' . $instanceurl . 'api/statuses/user_timeline/' . $user->id . '.atom" rel="alternate">' . "\n"; print ' <link title="FOAF for ' . $nickname . '" type="application/rdf+xml" href="' . $instanceurl . $nickname . '/foaf" rel="meta">' . "\n"; print ' <link href="' . $instanceurl . $nickname . '/microsummary" rel="microsummary">' . "\n"; // maybe openid if (array_key_exists('OpenID', StatusNet::getActivePlugins())) { print ' <link rel="openid2.provider" href="' . common_local_url('openidserver') . '"/>' . "\n"; print ' <link rel="openid2.local_id" href="' . $user->getProfile()->profileurl . '"/>' . "\n"; print ' <link rel="openid2.server" href="' . common_local_url('openidserver') . '"/>' . "\n"; print ' <link rel="openid2.delegate" href="' . $user->getProfile()->profileurl . '"/>' . "\n"; } } } } elseif (substr($_SERVER['REQUEST_URI'], 0, 7) == '/group/') { $group_id_or_name = substr($_SERVER['REQUEST_URI'], 7); if (stristr($group_id_or_name, '/id')) { $group_id_or_name = substr($group_id_or_name, 0, strpos($group_id_or_name, '/id')); $group = User_group::getKV('id', $group_id_or_name); if ($group instanceof User_group) { $group_name = $group->nickname; $group_id = $group_id_or_name; } } else { $group = Local_group::getKV('nickname', $group_id_or_name); if ($group instanceof Local_group) { $group_id = $group->group_id; $group_name = $group_id_or_name; } } if (preg_match("/^[a-zA-Z0-9]+\$/", $group_id_or_name) == 1 && isset($group_name) && isset($group_id)) { ?> <link rel="alternate" href="<?php echo htmlspecialchars(common_local_url('ApiTimelineGroup', array('id' => $group_id, 'format' => 'as'))); ?> " type="application/stream+json" title="Notice feed for '<?php echo htmlspecialchars($group_name); ?> ' group (Activity Streams JSON)" /> <link rel="alternate" href="<?php echo htmlspecialchars(common_local_url('grouprss', array('nickname' => $group_name))); ?> " type="application/rdf+xml" title="Notice feed for '<?php echo htmlspecialchars($group_name); ?> ' group (RSS 1.0)" /> <link rel="alternate" href="<?php echo htmlspecialchars(common_local_url('ApiTimelineGroup', array('id' => $group_id, 'format' => 'rss'))); ?> " type="application/rss+xml" title="Notice feed for '<?php echo htmlspecialchars($group_name); ?> ' group (RSS 2.0)" /> <link rel="alternate" href="<?php echo htmlspecialchars(common_local_url('ApiTimelineGroup', array('id' => $group_id, 'format' => 'atom'))); ?> " type="application/atom+xml" title="Notice feed for '<?php echo htmlspecialchars($group_name); ?> ' group (Atom)" /> <link rel="meta" href="<?php echo htmlspecialchars(common_local_url('foafgroup', array('nickname' => $group_name))); ?> " type="application/rdf+xml" title="FOAF for '<?php echo htmlspecialchars($group_name); ?> ' group" /> <?php } } // oembed discovery for local notices if (substr($_SERVER['REQUEST_URI'], 0, 8) == '/notice/' && $this->arg('notice') && array_key_exists('Oembed', StatusNet::getActivePlugins())) { $notice = Notice::getKV('id', $this->arg('notice')); if ($notice instanceof Notice) { if ($notice->isLocal()) { try { $notice_url = $notice->getUrl(); print '<link title="oEmbed" href="' . common_local_url('apiqvitteroembednotice', array('id' => $notice->id, 'format' => 'json')) . '?url=' . urlencode($notice_url) . '" type="application/json+oembed" rel="alternate">'; print '<link title="oEmbed" href="' . common_local_url('apiqvitteroembednotice', array('id' => $notice->id, 'format' => 'xml')) . '?url=' . urlencode($notice_url) . '" type="application/xml+oembed" rel="alternate">'; } catch (Exception $e) { // } } } } ?> <script> /* @licstart The following is the entire license notice for the JavaScript code in this page. Copyright (C) 2015 Hannes Mannerheim and other contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. @licend The above is the entire license notice for the JavaScript code in this page. */ window.usersLanguageCode = <?php print json_encode($user_browser_language); ?> ; window.usersLanguageNameInEnglish = <?php print json_encode(Locale::getDisplayLanguage($user_browser_language, 'en')); ?> ; window.englishLanguageData = <?php print file_get_contents(QVITTERDIR . '/locale/en.json'); ?> ; window.defaultAvatarStreamSize = <?php print json_encode(Avatar::defaultImage(AVATAR_STREAM_SIZE)); ?> ; window.defaultAvatarProfileSize = <?php print json_encode(Avatar::defaultImage(AVATAR_PROFILE_SIZE)); ?> ; window.textLimit = <?php print json_encode((int) common_config('site', 'textlimit')); ?> ; window.registrationsClosed = <?php print json_encode($registrationsclosed); ?> ; window.thisSiteThinksItIsHttpButIsActuallyHttps = <?php // this is due to a crazy setup at quitter.se, sorry about that $siteSSL = common_config('site', 'ssl'); if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' && $siteSSL == 'never') { $this_site_thinks_it_is_http_but_is_actually_https = true; print 'true'; } else { $this_site_thinks_it_is_http_but_is_actually_https = false; print 'false'; } ?> ; window.siteTitle = <?php print json_encode($sitetitle); ?> ; window.loggedIn = <?php $logged_in_user_json = json_encode($logged_in_user_obj); $logged_in_user_json = str_replace('http:\\/\\/quitter.se\\/', 'https:\\/\\/quitter.se\\/', $logged_in_user_json); print $logged_in_user_json; ?> ; window.timeBetweenPolling = <?php print QvitterPlugin::settings("timebetweenpolling"); ?> ; window.apiRoot = <?php $api_root = common_path("api/", StatusNet::isHTTPS()); if ($this_site_thinks_it_is_http_but_is_actually_https) { $api_root = str_replace('http://', 'https://', $api_root); } print '\'' . $api_root . '\''; ?> ; window.fullUrlToThisQvitterApp = '<?php print $qvitterpath; ?> '; window.siteRootDomain = '<?php print $siterootdomain; ?> '; window.siteInstanceURL = '<?php print $instanceurl; ?> '; window.defaultLinkColor = '<?php print QvitterPlugin::settings("defaultlinkcolor"); ?> '; window.defaultBackgroundColor = '<?php print QvitterPlugin::settings("defaultbackgroundcolor"); ?> '; window.siteBackground = '<?php print QvitterPlugin::settings("sitebackground"); ?> '; window.enableWelcomeText = <?php print json_encode(QvitterPlugin::settings("enablewelcometext")); ?> ; window.customWelcomeText = <?php print json_encode(QvitterPlugin::settings("customwelcometext")); ?> ; window.urlShortenerAPIURL = '<?php print QvitterPlugin::settings("urlshortenerapiurl"); ?> '; window.urlShortenerSignature = '<?php print QvitterPlugin::settings("urlshortenersignature"); ?> '; window.commonSessionToken = '<?php print common_session_token(); ?> '; window.siteMaxThumbnailSize = <?php print common_config('thumbnail', 'maxsize'); ?> ; window.siteAttachmentURLBase = '<?php print $attachmentroot; ?> '; window.siteEmail = '<?php print common_config('site', 'email'); ?> '; window.siteLicenseTitle = '<?php print common_config('license', 'title'); ?> '; window.siteLicenseURL = '<?php print common_config('license', 'url'); ?> '; window.customTermsOfUse = <?php print json_encode(QvitterPlugin::settings("customtermsofuse")); ?> ; window.siteLocalOnlyDefaultPath = <?php print common_config('public', 'localonly') ? 'true' : 'false'; ?> ; <?php // Get all topics in Qvitter's namespace in Profile_prefs if ($logged_in_user) { try { $qvitter_profile_prefs = Profile_prefs::getNamespace(Profile::current(), 'qvitter'); } catch (Exception $e) { $qvitter_profile_prefs = array(); } if (count($qvitter_profile_prefs) > 0) { $topic_data = new stdClass(); foreach ($qvitter_profile_prefs as $pref) { $topic_data->{$pref->topic} = $pref->data; } print 'window.qvitterProfilePrefs = ' . json_encode($topic_data) . ';'; } else { print 'window.qvitterProfilePrefs = false;'; } } ?> // available language files and their last update time window.availableLanguages = {<?php // scan all files in the locale directory and create a json object with their change date added $available_languages = array_diff(scandir(QVITTERDIR . '/locale'), array('..', '.')); foreach ($available_languages as $lankey => $lan) { $lancode = substr($lan, 0, strpos($lan, '.')); // for the paranthesis containing language region to work with rtl in ltr enviroment and vice versa, we add a // special rtl or ltr html char after the paranthesis // this list is incomplete, but if any rtl language gets a regional translation, it will probably be arabic $rtl_or_ltr_special_char = '‎'; $base_lancode = substr($lancode, 0, strpos($lancode, '_')); if ($base_lancode == 'ar' || $base_lancode == 'fa' || $base_lancode == 'he') { $rtl_or_ltr_special_char = '‏'; } // also make an array with all language names, to use for generating menu $languagecodesandnames[$lancode]['english_name'] = Locale::getDisplayLanguage($lancode, 'en'); $languagecodesandnames[$lancode]['name'] = Locale::getDisplayLanguage($lancode, $lancode); if (Locale::getDisplayRegion($lancode, $lancode)) { $languagecodesandnames[$lancode]['name'] .= ' (' . Locale::getDisplayRegion($lancode, $lancode) . ')' . $rtl_or_ltr_special_char; } // ahorita meme only on quitter.es if ($lancode == 'es_ahorita') { if ($siterootdomain == 'quitter.es') { $languagecodesandnames[$lancode]['name'] = 'español (ahorita)'; } else { unset($available_languages[$lankey]); unset($languagecodesandnames[$lancode]); continue; } } print "\n" . ' "' . $lancode . '": "' . $lan . '?changed=' . date('YmdHis', filemtime(QVITTERDIR . '/locale/' . $lan)) . '",'; } ?> }; </script> <?php // event for other plugins to use to add head elements to qvitter Event::handle('QvitterEndShowHeadElements', array($this)); ?> </head> <body style="background-color:<?php print QvitterPlugin::settings("defaultbackgroundcolor"); ?> "> <?php // add an accessibility toggle link to switch to standard UI, if we're logged in if ($logged_in_user) { print '<a id="accessibility-toggle-link" href="#"></a>'; } ?> <input id="upload-image-input" class="upload-image-input" type="file" name="upload-image-input"> <div class="topbar"> <a href="<?php // if we're logged in, the logo links to the home stream // if logged out it links to the site's public stream if ($logged_in_user) { print $instanceurl . $logged_in_user_nickname . '/all'; } else { print $instanceurl . 'main/public'; } ?> "><div id="logo"></div></a><?php // menu for logged in users if ($logged_in_user) { ?> <a id="settingslink"> <div class="dropdown-toggle"> <div class="nav-session" style="background-image:url('<?php print htmlspecialchars($logged_in_user_obj['profile_image_url_profile_size']); ?> ')"></div> </div> </a><?php } ?> <div id="top-compose" class="hidden"></div> <ul class="quitter-settings dropdown-menu"> <li class="dropdown-caret right"> <span class="caret-outer"></span> <span class="caret-inner"></span> </li> <li class="fullwidth"><a id="logout"></a></li> <li class="fullwidth dropdown-divider"></li> <li class="fullwidth"><a id="edit-profile-header-link"></a></li> <li class="fullwidth"><a id="settings" href="<?php print $instanceurl; ?> settings/profile" donthijack></a></li> <li class="fullwidth"><a id="faq-link"></a></li> <li class="fullwidth"><a id="shortcuts-link"></a></li> <?php if (common_config('invite', 'enabled') && !common_config('site', 'closed')) { ?> <li class="fullwidth"><a id="invite-link" href="<?php print $instanceurl; ?> main/invite"></a></li> <?php } ?> <li class="fullwidth"><a id="classic-link"></a></li> <li class="fullwidth language dropdown-divider"></li> <?php // languages foreach ($languagecodesandnames as $lancode => $lan) { print '<li class="language"><a class="language-link" title="' . $lan['english_name'] . '" data-lang-code="' . $lancode . '">' . $lan['name'] . '</a></li>'; } ?> <li class="fullwidth language dropdown-divider"></li> <li class="fullwidth"><a href="https://git.gnu.io/h2p/Qvitter/tree/master/locale" target="_blank" id="add-edit-language-link"></a></li> </ul> <div class="global-nav"> <div class="global-nav-inner"> <div class="container"> <div id="search"> <input type="text" spellcheck="false" autocomplete="off" name="q" placeholder="Sök" id="search-query" class="search-input"> <span class="search-icon"> <button class="icon nav-search" type="submit" tabindex="-1"> <span> Sök </span> </button> </span> </div> <ul class="language-dropdown"> <li class="dropdown"> <a class="dropdown-toggle"> <small></small> <span class="current-language"></span> <b class="caret"></b> </a> <ul class="dropdown-menu"> <li class="dropdown-caret right"> <span class="caret-outer"></span> <span class="caret-inner"></span> </li> <?php // languages foreach ($languagecodesandnames as $lancode => $lan) { print '<li><a class="language-link" title="' . $lan['english_name'] . '" data-lang-code="' . $lancode . '">' . $lan['name'] . '</a></li>'; } ?> </ul> </li> </ul> </div> </div> </div> </div> <div id="no-js-error">Please enable javascript to use this site.<script>var element = document.getElementById('no-js-error'); element.parentNode.removeChild(element);</script></div> <div id="page-container"> <?php $site_notice = common_config('site', 'notice'); if (!empty($site_notice)) { print '<div id="site-notice">' . common_config('site', 'notice') . '</div>'; } // welcome text, login and register container if logged out if ($logged_in_user === null) { ?> <div class="front-welcome-text <?php if ($registrationsclosed) { print 'registrations-closed'; } ?> "></div> <div id="login-register-container"> <div id="login-content"> <form id="form_login" class="form_settings" action="<?php print common_local_url('qvitterlogin'); ?> " method="post"> <div id="username-container"> <input id="nickname" name="nickname" type="text" value="<?php print $logged_in_user_nickname; ?> " tabindex="1" /> </div> <table class="password-signin"><tbody><tr> <td class="flex-table-primary"> <div class="placeholding-input"> <input id="password" name="password" type="password" tabindex="2" value="" /> </div> </td> <td class="flex-table-secondary"> <button class="submit" type="submit" id="submit-login" tabindex="4"></button> </td> </tr></tbody></table> <div id="remember-forgot"> <input type="checkbox" id="rememberme" name="rememberme" value="yes" tabindex="3" checked="checked"> <span id="rememberme_label"></span> · <a id="forgot-password" href="<?php print $instanceurl; ?> main/recoverpassword" ></a> <input type="hidden" id="token" name="token" value="<?php print common_session_token(); ?> "> <?php if (array_key_exists('OpenID', StatusNet::getActivePlugins())) { print '<a href="' . $instanceurl . 'main/openid" id="openid-login" title="OpenID" donthijack>OpenID</a>'; } ?> </div> </form> </div> <?php if ($registrationsclosed === false && $client_ip_is_blocked === false) { ?> <div class="front-signup"> <h2></h2> <div class="signup-input-container"><input placeholder="" type="text" name="user[name]" autocomplete="off" class="text-input" id="signup-user-name"></div> <div class="signup-input-container"><input placeholder="" type="text" name="user[email]" autocomplete="off" id="signup-user-email"></div> <div class="signup-input-container"><input placeholder="" type="password" name="user[user_password]" class="text-input" id="signup-user-password"></div> <button id="signup-btn-step1" class="signup-btn" type="submit"></button> </div> <div id="other-servers-link"></div><?php } ?> <div id="qvitter-notice-logged-out"><?php print common_config('site', 'qvitternoticeloggedout'); ?> </div> </div><?php } // box containing the logged in users queet count and compose form if ($logged_in_user) { ?> <div id="user-container" style="display:none;"> <div id="user-header" style="background-image:url('<?php print htmlspecialchars($logged_in_user_obj['cover_photo']); ?> ')"> <div id="mini-edit-profile-button"></div> <div class="profile-header-inner-overlay"></div> <div id="user-avatar-container"><img id="user-avatar" src="<?php print htmlspecialchars($logged_in_user_obj['profile_image_url_profile_size']); ?> " /></div> <div id="user-name"><?php print htmlspecialchars($logged_in_user_obj['name']); ?> </div> <div id="user-screen-name"><?php print htmlspecialchars($logged_in_user_obj['screen_name']); ?> </div> </div> <ul id="user-body"> <li><a href="<?php print $instanceurl . $logged_in_user->nickname; ?> " id="user-queets"><span class="label"></span><strong><?php print $logged_in_user_obj['statuses_count']; ?> </strong></a></li> <li><a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /subscriptions" id="user-following"><span class="label"></span><strong><?php print $logged_in_user_obj['friends_count']; ?> </strong></a></li> <li><a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /groups" id="user-groups"><span class="label"></span><strong><?php print $logged_in_user_obj['groups_count']; ?> </strong></a></li> </ul> <div id="user-footer"> <div id="user-footer-inner"> <div id="queet-box" class="queet-box queet-box-syntax" data-start-text=""></div> <div class="syntax-middle"></div> <div class="syntax-two" contenteditable="true"></div> <div class="mentions-suggestions"></div> <div class="queet-toolbar"> <div class="queet-box-extras"> <button class="upload-image"></button> <button class="shorten disabled">URL</button> </div> <div class="queet-button"> <span class="queet-counter"></span> <button></button> </div> </div> </div> </div> <div id="main-menu" class="menu-container"><?php if ($logged_in_user) { ?> <a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /all" class="stream-selection friends-timeline"><i class="chev-right"></i></a> <a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /notifications" class="stream-selection notifications"><span id="unseen-notifications"></span><i class="chev-right"></i></a> <a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /replies" class="stream-selection mentions"><i class="chev-right"></i></a> <a href="<?php print $instanceurl . $logged_in_user->nickname; ?> " class="stream-selection my-timeline"><i class="chev-right"></i></a> <a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /favorites" class="stream-selection favorites"><i class="chev-right"></i></a> <a href="<?php print $instanceurl; ?> main/public" class="stream-selection public-timeline"><i class="chev-right"></i></a> <a href="<?php print $instanceurl; ?> main/all" class="stream-selection public-and-external-timeline"><i class="chev-right"></i></a> <?php } ?> </div> <div class="menu-container" id="bookmark-container"></div> <div class="menu-container" id="history-container"></div> <div id="clear-history"></div> <div id="qvitter-notice"><?php print common_config('site', 'qvitternotice'); ?> </div> </div><?php } ?> <div id="feed"> <div id="feed-header"> <div id="feed-header-inner"> <h2></h2> <div class="reload-stream"></div> </div> </div> <div id="new-queets-bar-container" class="hidden"><div id="new-queets-bar"></div></div> <div id="feed-body"></div> </div> <div id="hidden-html"><?php // adds temporary support for microformats and linkbacks on the notice page if (substr($_SERVER['REQUEST_URI'], 0, 8) == '/notice/' && $this->arg('notice')) { echo '<ol class="notices xoxo">'; if ($notice instanceof Notice) { $widget = new NoticeListItem($notice, $this); $widget->show(); $this->flush(); } echo '</ol>'; } Event::handle('QvitterHiddenHtml', array($this)); ?> </div> <div id="footer"><div id="footer-spinner-container"></div></div> </div> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/jquery-2.1.4.min.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/jquery-2.1.4.min.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/jquery-ui.min.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/jquery-ui.min.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/jquery.minicolors.min.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/jquery.minicolors.min.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/jquery.jWindowCrop.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/jquery.jWindowCrop.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/load-image.min.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/load-image.min.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/xregexp-all-3.0.0-pre.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/xregexp-all-3.0.0-pre.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/lz-string.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/lz-string.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/bowser.min.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/bowser.min.js')); ?> "></script> <script charset="utf-8" type="text/javascript" src="<?php print $qvitterpath; ?> js/dom-functions.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/dom-functions.js')); ?> "></script> <script charset="utf-8" type="text/javascript" src="<?php print $qvitterpath; ?> js/misc-functions.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/misc-functions.js')); ?> "></script> <script charset="utf-8" type="text/javascript" src="<?php print $qvitterpath; ?> js/ajax-functions.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/ajax-functions.js')); ?> "></script> <script charset="utf-8" type="text/javascript" src="<?php print $qvitterpath; ?> js/stream-router.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/stream-router.js')); ?> "></script> <script charset="utf-8" type="text/javascript" src="<?php print $qvitterpath; ?> js/qvitter.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/qvitter.js')); ?> "></script> <?php // event for other plugins to add scripts to qvitter Event::handle('QvitterEndShowScripts', array($this)); // we might have custom javascript in the config file that we want to add if (QvitterPlugin::settings('js')) { print '<script type="text/javascript">' . QvitterPlugin::settings('js') . '</script>'; } ?> <div id="dynamic-styles"> <style> a, a:visited, a:active, ul.stats li:hover a, ul.stats li:hover a strong, #user-body a:hover div strong, #user-body a:hover div div, .permalink-link:hover, .stream-item.expanded > .queet .stream-item-expand, .stream-item-footer .with-icn .requeet-text a b:hover, .queet-text span.attachment.more, .stream-item-header .created-at a:hover, .stream-item-header a.account-group:hover .name, .queet:hover .stream-item-expand, .show-full-conversation:hover, #new-queets-bar, .menu-container div, .cm-mention, .cm-tag, .cm-group, .cm-url, .cm-email, div.syntax-middle span, #user-body strong, ul.stats, .stream-item:not(.temp-post) ul.queet-actions li .icon:not(.is-mine):hover:before, .show-full-conversation, #user-body #user-queets:hover .label, #user-body #user-groups:hover .label, #user-body #user-following:hover .label, ul.stats a strong, .queet-box-extras button, #openid-login:hover:after, .post-to-group { color:/*COLORSTART*/<?php print QvitterPlugin::settings("defaultlinkcolor"); ?> /*COLOREND*/; } #unseen-notifications, .stream-item.notification.not-seen > .queet::before, #top-compose, #logo, .queet-toolbar button, #user-header, .profile-header-inner, .topbar, .menu-container, .member-button.member, .external-follow-button.following, .qvitter-follow-button.following, .save-profile-button, .crop-and-save-button, .topbar .global-nav.show-logo:before, .topbar .global-nav.pulse-logo:before, .dropdown-menu li:not(.dropdown-caret) a:hover { background-color:/*BACKGROUNDCOLORSTART*/<?php print QvitterPlugin::settings("defaultlinkcolor"); ?> /*BACKGROUNDCOLOREND*/; } .queet-box-syntax[contenteditable="true"]:focus, .stream-item.selected-by-keyboard::before { border-color:/*BORDERCOLORSTART*/#999999/*BORDERCOLOREND*/; } #user-footer-inner, .inline-reply-queetbox, #popup-faq #faq-container p.indent { background-color:/*LIGHTERBACKGROUNDCOLORSTART*/rgb(205,230,239)/*LIGHTERBACKGROUNDCOLOREND*/; } #user-footer-inner, .queet-box, .queet-box-syntax[contenteditable="true"], .inline-reply-queetbox, span.inline-reply-caret, .stream-item.expanded .stream-item.first-visible-after-parent, #popup-faq #faq-container p.indent, .post-to-group, .quoted-notice:hover, .oembed-item:hover, .stream-item:hover:not(.expanded) .quoted-notice:hover, .stream-item:hover:not(.expanded) .oembed-item:hover { border-color:/*LIGHTERBORDERCOLORSTART*/rgb(155,206,224)/*LIGHTERBORDERCOLOREND*/; } span.inline-reply-caret .caret-inner { border-bottom-color:/*LIGHTERBORDERBOTTOMCOLORSTART*/rgb(205,230,239)/*LIGHTERBORDERBOTTOMCOLOREND*/; } .modal-close .icon, .chev-right, .close-right, button.icon.nav-search, .member-button .join-text i, .external-member-button .join-text i, .external-follow-button .follow-text i, .qvitter-follow-button .follow-text i, #logo, .upload-cover-photo, .upload-avatar, .upload-background-image, button.shorten i, .reload-stream, .topbar .global-nav:before, .stream-item.notification.repeat .dogear, .stream-item.notification.like .dogear, .ostatus-link, .close-edit-profile-window { background-image: url("<?php print QvitterPlugin::settings("sprite"); ?> "); background-size: 500px 1329px; } @media (max-width: 910px) { #search-query, .menu-container a, .menu-container a.current, .stream-selection.friends-timeline:after, .stream-selection.notifications:after, .stream-selection.my-timeline:after, .stream-selection.public-timeline:after { background-image: url("<?php print QvitterPlugin::settings("sprite"); ?> "); background-size: 500px 1329px; } } </style> </div> </body> </html> <?php }
/** * Send notifications via email etc to group administrators about * this exciting new pending moderation queue item! */ public function notify() { $joiner = Profile::getKV('id', $this->profile_id); $group = User_group::getKV('id', $this->group_id); mail_notify_group_join_pending($group, $joiner); }
/** * Record this notice to the given group inboxes for delivery. * Overrides the regular parsing of !group markup. * * @param string $group_ids * @fixme might prefer URIs as identifiers, as for replies? * best with generalizations on user_group to support * remote groups better. */ function saveKnownGroups(array $group_ids) { $groups = array(); foreach (array_unique($group_ids) as $id) { $group = User_group::getKV('id', $id); if ($group instanceof User_group) { common_log(LOG_DEBUG, "Local delivery to group id {$id}, {$group->nickname}"); $result = $this->addToGroupInbox($group); if (!$result) { common_log_db_error($gi, 'INSERT', __FILE__); } if (common_config('group', 'addtag')) { // we automatically add a tag for every group name, too $tag = Notice_tag::pkeyGet(array('tag' => common_canonical_tag($group->nickname), 'notice_id' => $this->id)); if (is_null($tag)) { $this->saveTag($group->nickname); } } $groups[] = clone $group; } else { common_log(LOG_ERR, "Local delivery to group id {$id} skipped, doesn't exist"); } } return $groups; }
Removes a local user from a local group. -i --id ID of user to remove -n --nickname nickname of the user to remove -g --group nickname or alias of group -G --group-id ID of group END_OF_HELP; require_once INSTALLDIR . '/scripts/commandline.inc'; try { $user = getUser(); $lgroup = null; if (have_option('G', 'group-id')) { $gid = get_option_value('G', 'group-id'); $lgroup = Local_group::getKV('group_id', $gid); } else { if (have_option('g', 'group')) { $gnick = get_option_value('g', 'group'); $lgroup = Local_group::getKV('nickname', $gnick); } } if (!$lgroup instanceof Local_group) { throw new Exception("No such local group: {$gnick}"); } $group = User_group::getKV('id', $lgroup->group_id); $user->leaveGroup($group); print "OK\n"; } catch (Exception $e) { print $e->getMessage() . "\n"; exit(1); }