exit(1);
}
-require_once INSTALLDIR . '/lib/apiauth.php';
-
/**
* API analog to the group edit page
*
*/
class ApiGroupProfileUpdateAction extends ApiAuthAction
{
+ protected $needPost = true;
/**
* Take arguments for running
*
* @return boolean success flag
*
*/
- function prepare($args)
+ protected function prepare($args)
{
parent::prepare($args);
*
* See which request params have been set, and update the profile
*
- * @param array $args $_REQUEST data (unused)
- *
* @return void
*/
- function handle($args)
+ protected function handle()
{
- parent::handle($args);
-
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->clientError(
- // TRANS: Client error message. POST is a HTTP command. It should not be translated.
- _('This method requires a POST.'),
- 400, $this->format
- );
- return;
- }
+ parent::handle();
if (!in_array($this->format, array('xml', 'json'))) {
- $this->clientError(
- // TRANS: Client error displayed when coming across a non-supported API method.
- _('API method not found.'),
- 404,
- $this->format
- );
- return;
+ // TRANS: Client error displayed when coming across a non-supported API method.
+ $this->clientError(_('API method not found.'), 404);
}
if (empty($this->user)) {
// TRANS: Client error displayed when not providing a user or an invalid user.
- $this->clientError(_('No such user.'), 404, $this->format);
- return;
+ $this->clientError(_('No such user.'), 404);
}
if (empty($this->group)) {
// TRANS: Client error displayed when not providing a group or an invalid group.
- $this->clientError(_('Group not found.'), 404, $this->format);
- return false;
+ $this->clientError(_('Group not found.'), 404);
}
if (!$this->user->isAdmin($this->group)) {
// TRANS: Client error displayed when trying to edit a group without being an admin.
$this->clientError(_('You must be an admin to edit the group.'), 403);
- return false;
}
$this->group->query('BEGIN');
}
} catch (ApiValidationException $ave) {
- $this->clientError(
- $ave->getMessage(),
- 403,
- $this->format
- );
- return;
+ $this->clientError($ave->getMessage(), 403);
}
$result = $this->group->update($orig);
}
} catch (ApiValidationException $ave) {
- $this->clientError(
- $ave->getMessage(),
- 403,
- $this->format
- );
- return;
+ $this->clientError($ave->getMessage(), 403);
}
$result = $this->group->setAliases($aliases);
if (!empty($this->nickname) && ($this->nickname != $orig->nickname)) {
common_log(LOG_INFO, "Saving local group info.");
- $local = Local_group::staticGet('group_id', $this->group->id);
+ $local = Local_group::getKV('group_id', $this->group->id);
$local->setNickname($this->nickname);
}
break;
default:
// TRANS: Client error displayed when coming across a non-supported API method.
- $this->clientError(_('API method not found.'), 404, $this->format);
- break;
+ $this->clientError(_('API method not found.'), 404);
}
}
function nicknameExists($nickname)
{
- $group = Local_group::staticGet('nickname', $nickname);
+ $group = Local_group::getKV('nickname', $nickname);
if (!empty($group) &&
$group->group_id != $this->group->id) {
return true;
}
- $alias = Group_alias::staticGet('alias', $nickname);
+ $alias = Group_alias::getKV('alias', $nickname);
if (!empty($alias) &&
$alias->group_id != $this->group->id) {
function validateHomepage()
{
if (!is_null($this->homepage)
- && (strlen($this->homepage) > 0)
- && !Validate::uri(
- $this->homepage,
- array('allowed_schemes' => array('http', 'https')
- )
- )
- ) {
+ && (strlen($this->homepage) > 0)
+ && !common_valid_http_url($this->homepage)) {
throw new ApiValidationException(
// TRANS: API validation exception thrown when homepage URL does not validate.
_('Homepage is not a valid URL.')