return;
}
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(
+ _('API method not found.'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
if (empty($this->user)) {
$this->clientError(_('No such user.'), 404, $this->format);
return;
if (!$result) {
common_log_db_error($profile, 'UPDATE', __FILE__);
- $this->serverError(_('Couldn\'t save profile.'));
+ $this->serverError(_('Could not save profile.'));
return;
}
return;
}
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(
+ _('API method not found.'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
// Workaround for PHP returning empty $_POST and $_FILES when POST
// length > post_max_size in php.ini
}
if (empty($this->user)) {
- $this->clientError(_('No such user!'), 404, $this->format);
+ $this->clientError(_('No such user.'), 404, $this->format);
return;
}
+ $design = $this->user->getDesign();
+
+ // XXX: This is kinda gross, but before we can add a background
+ // img we have to make sure there's a Design because design ID
+ // is part of the img filename.
+
+ if (empty($design)) {
+
+ $this->user->query('BEGIN');
+
+ // save new design
+ $design = new Design();
+ $id = $design->insert();
+
+ if (empty($id)) {
+ common_log_db_error($id, 'INSERT', __FILE__);
+ $this->clientError(_('Unable to save your design settings.'));
+ return;
+ }
+
+ $original = clone($this->user);
+ $this->user->design_id = $id;
+ $result = $this->user->update($original);
+
+ if (empty($result)) {
+ common_log_db_error($original, 'UPDATE', __FILE__);
+ $this->clientError(_('Unable to save your design settings.'));
+ $this->user->query('ROLLBACK');
+ return;
+ }
+
+ $this->user->query('COMMIT');
+ }
+
+ // Okay, now get the image and add it to the design
+
try {
$imagefile = ImageFile::fromUpload('image');
} catch (Exception $e) {
return;
}
- $design = $this->user->getDesign();
-
$filename = Design::filename(
$design->id,
image_type_to_extension($imagefile->type),
}
$original = clone($design);
-
$design->backgroundimage = $filename;
-
- $design->setDisposition(true, false, !empty($this->tile));
+ $design->setDisposition(true, false, ($this->tile == 'true'));
$result = $design->update($original);
if ($result === false) {
common_log_db_error($design, 'UPDATE', __FILE__);
- $this->showForm(_('Couldn\'t update your design.'));
+ $this->showForm(_('Could not update your design.'));
return;
}
return;
}
- $twitter_user = $this->twitterUserArray($this->user->getProfile(), true);
+ $twitter_user = $this->twitterUserArray($profile, true);
if ($this->format == 'xml') {
$this->initDocument('xml');
return;
}
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(
+ _('API method not found.'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
$design = $this->user->getDesign();
if (!empty($design)) {
if ($result === false) {
common_log_db_error($design, 'UPDATE', __FILE__);
- $this->clientError(_('Couldn\'t update your design.'));
+ $this->clientError(_('Could not update your design.'));
return;
}
if (empty($id)) {
common_log_db_error($id, 'INSERT', __FILE__);
- $this->clientError(_('Unable to save your design settings!'));
+ $this->clientError(_('Unable to save your design settings.'));
return;
}
if (empty($result)) {
common_log_db_error($original, 'UPDATE', __FILE__);
- $this->clientError(_('Unable to save your design settings!'));
+ $this->clientError(_('Unable to save your design settings.'));
$this->user->query('ROLLBACK');
return;
}
return;
}
- $twitter_user = $this->twitterUserArray($this->user->getProfile(), true);
+ $twitter_user = $this->twitterUserArray($profile, true);
if ($this->format == 'xml') {
$this->initDocument('xml');
}
if (empty($this->user)) {
- $this->clientError(_('No such user!'), 404, $this->format);
+ $this->clientError(_('No such user.'), 404, $this->format);
return;
}
common_broadcast_profile($profile);
- $twitter_user = $this->twitterUserArray($this->user->getProfile(), true);
+ $twitter_user = $this->twitterUserArray($profile, true);
if ($this->format == 'xml') {
$this->initDocument('xml');