*
* @return boolean success flag
*/
- function prepare($args)
+ protected function prepare(array $args=array())
{
parent::prepare($args);
*
* @return void
*/
- function handle($args)
+ protected function handle()
{
- parent::handle($args);
+ parent::handle();
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
$this->clientError(
return;
}
- if (empty($this->auth_user)) {
+ if (is_null($this->scoped)) {
// TRANS: Client error displayed when updating a status for a non-existing user.
$this->clientError(_('No such user.'), 404, $this->format);
return;
$upload = null;
try {
- $upload = MediaFile::fromUpload('media', $this->auth_user->getProfile());
+ $upload = MediaFile::fromUpload('media', $this->scoped);
} catch (Exception $e) {
$this->clientError($e->getMessage(), $e->getCode(), $this->format);
return;
$options = array('reply_to' => $reply_to);
- if ($this->auth_user->shareLocation()) {
+ if ($this->scoped->shareLocation()) {
$locOptions = Notice::locationOptions($this->lat,
$this->lon,
null,
null,
- $this->auth_user->getProfile());
+ $this->scoped);
$options = array_merge($options, $locOptions);
}
try {
$this->notice = Notice::saveNew(
- $this->auth_user->id,
+ $this->scoped->id,
$content,
$this->source,
$options
}
}
- if ($user->shareLocation()) {
+ if ($this->scoped->shareLocation()) {
// use browser data if checked; otherwise profile data
if ($this->arg('notice_data-geo')) {
$locOptions = Notice::locationOptions($this->trimmed('lat'),
// TRANS: Checkbox label in form for profile settings.
$this->checkbox('sharelocation', _('Share my current location when posting notices'),
($this->arg('sharelocation')) ?
- $this->arg('sharelocation') : $user->shareLocation());
+ $this->arg('sharelocation') : $this->scoped->shareLocation());
$this->elementEnd('li');
}
Event::handle('EndProfileFormData', array($this));
// XXX: identical to Notice::getLocation.
- function getLocation()
+ public function getLocation()
{
$location = null;
return $location;
}
+ public function shareLocation()
+ {
+ $cfg = common_config('location', 'share');
+
+ if ($cfg == 'always') {
+ return true;
+ } else if ($cfg == 'never') {
+ return false;
+ } else { // user
+ $share = common_config('location', 'sharedefault');
+
+ // Check if user has a personal setting for this
+ $prefs = User_location_prefs::getKV('user_id', $this->id);
+
+ if (!empty($prefs)) {
+ $share = $prefs->share_location;
+ $prefs->free();
+ }
+
+ return $share;
+ }
+ }
+
function hasRole($name)
{
$has_role = false;
throw new Exception(_('Not implemented since inbox change.'));
}
- function shareLocation()
- {
- $cfg = common_config('location', 'share');
-
- if ($cfg == 'always') {
- return true;
- } else if ($cfg == 'never') {
- return false;
- } else { // user
- $share = common_config('location', 'sharedefault');
-
- // Check if user has a personal setting for this
- $prefs = User_location_prefs::getKV('user_id', $this->id);
-
- if (!empty($prefs)) {
- $share = $prefs->share_location;
- $prefs->free();
- }
-
- return $share;
- }
- }
-
public static function siteOwner()
{
$owner = self::cacheGet('user:site_owner');
*
* @return boolean false if user doesn't exist
*/
- function prepare($args)
+ protected function prepare(array $args=array())
{
StatusNet::setApi(true); // reduce exception reports to aid in debugging
parent::prepare($args);
*
* @return void
*/
- function handle($args)
+ protected function handle()
{
header('Access-Control-Allow-Origin: *');
- parent::handle($args);
+ parent::handle();
}
/**
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Actions extending this class will require auth
* @return boolean success flag
*
*/
- function prepare($args)
+ protected function prepare(array $args=array())
{
parent::prepare($args);
$toWidget->show();
$this->out->elementEnd('div');
- if ($this->user->shareLocation()) {
+ if ($this->profile->shareLocation()) {
$this->out->hidden('notice_data-lat', empty($this->lat) ? (empty($this->profile->lat) ? null : $this->profile->lat) : $this->lat, 'lat');
$this->out->hidden('notice_data-lon', empty($this->lon) ? (empty($this->profile->lon) ? null : $this->profile->lon) : $this->lon, 'lon');
$this->out->hidden('notice_data-location_id', empty($this->location_id) ? (empty($this->profile->location_id) ? null : $this->profile->location_id) : $this->location_id, 'location_id');
}
$this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
- if ($this->user->shareLocation()) {
+ if ($this->profile->shareLocation()) {
$this->out->hidden('notice_data-lat', empty($this->lat) ? (empty($this->profile->lat) ? null : $this->profile->lat) : $this->lat, 'lat');
$this->out->hidden('notice_data-lon', empty($this->lon) ? (empty($this->profile->lon) ? null : $this->profile->lon) : $this->lon, 'lon');
$this->out->hidden('notice_data-location_id', empty($this->location_id) ? (empty($this->profile->location_id) ? null : $this->profile->location_id) : $this->location_id, 'location_id');
Event::handle('EndShowNoticeFormData', array($this));
}
}
-}
\ No newline at end of file
+}