Can now edit/change application icon
This commit is contained in:
parent
7694955cd6
commit
adfca01808
@ -183,15 +183,12 @@ class EditApplicationAction extends OwnerDesignAction
|
||||
_('Description is too long (max %d chars).'),
|
||||
Oauth_application::maxDescription()));
|
||||
return;
|
||||
} elseif (empty($source_url)) {
|
||||
$this->showForm(_('Source URL is required.'));
|
||||
} elseif (mb_strlen($source_url) > 255) {
|
||||
$this->showForm(_('Source URL is too long.'));
|
||||
return;
|
||||
} elseif ((strlen($source_url) > 0)
|
||||
&& !Validate::uri(
|
||||
$source_url,
|
||||
array('allowed_schemes' => array('http', 'https'))
|
||||
)
|
||||
)
|
||||
} elseif ((mb_strlen($source_url) > 0)
|
||||
&& !Validate::uri($source_url,
|
||||
array('allowed_schemes' => array('http', 'https'))))
|
||||
{
|
||||
$this->showForm(_('Source URL is not valid.'));
|
||||
return;
|
||||
@ -204,24 +201,19 @@ class EditApplicationAction extends OwnerDesignAction
|
||||
} elseif (empty($homepage)) {
|
||||
$this->showForm(_('Organization homepage is required.'));
|
||||
return;
|
||||
} elseif ((strlen($homepage) > 0)
|
||||
&& !Validate::uri(
|
||||
$homepage,
|
||||
array('allowed_schemes' => array('http', 'https'))
|
||||
)
|
||||
)
|
||||
} elseif ((mb_strlen($homepage) > 0)
|
||||
&& !Validate::uri($homepage,
|
||||
array('allowed_schemes' => array('http', 'https'))))
|
||||
{
|
||||
$this->showForm(_('Homepage is not a valid URL.'));
|
||||
return;
|
||||
} elseif (empty($callback_url)) {
|
||||
$this->showForm(_('Callback is required.'));
|
||||
} elseif (mb_strlen($callback_url) > 255) {
|
||||
$this->showForm(_('Callback is too long.'));
|
||||
return;
|
||||
} elseif (strlen($callback_url) > 0
|
||||
&& !Validate::uri(
|
||||
$source_url,
|
||||
} elseif (mb_strlen($callback_url) > 0
|
||||
&& !Validate::uri($source_url,
|
||||
array('allowed_schemes' => array('http', 'https'))
|
||||
)
|
||||
)
|
||||
))
|
||||
{
|
||||
$this->showForm(_('Callback URL is not valid.'));
|
||||
return;
|
||||
@ -244,8 +236,6 @@ class EditApplicationAction extends OwnerDesignAction
|
||||
$this->app->callback_url = $callback_url;
|
||||
$this->app->type = $type;
|
||||
|
||||
$result = $this->app->update($orig);
|
||||
|
||||
common_debug("access_type = $access_type");
|
||||
|
||||
if ($access_type == 'r') {
|
||||
@ -254,11 +244,15 @@ class EditApplicationAction extends OwnerDesignAction
|
||||
$this->app->access_type = 3;
|
||||
}
|
||||
|
||||
$result = $this->app->update($orig);
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($this->app, 'UPDATE', __FILE__);
|
||||
$this->serverError(_('Could not update application.'));
|
||||
}
|
||||
|
||||
$this->app->uploadLogo();
|
||||
|
||||
common_redirect(common_local_url('apps',
|
||||
array('nickname' => $cur->nickname)), 303);
|
||||
}
|
||||
|
@ -200,8 +200,8 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
{
|
||||
$this->showForm(_('Homepage is not a valid URL.'));
|
||||
return;
|
||||
} elseif (empty($callback_url)) {
|
||||
$this->showForm(_('Callback is required.'));
|
||||
} elseif (mb_strlen($callback_url) > 255) {
|
||||
$this->showForm(_('Callback is too long.'));
|
||||
return;
|
||||
} elseif (strlen($callback_url) > 0
|
||||
&& !Validate::uri(
|
||||
@ -266,7 +266,7 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
$app->query('ROLLBACK');
|
||||
}
|
||||
|
||||
$this->uploadLogo($app);
|
||||
$this->app->uploadLogo();
|
||||
|
||||
$app->query('COMMIT');
|
||||
|
||||
@ -275,40 +275,5 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an image upload
|
||||
*
|
||||
* Does all the magic for handling an image upload, and crops the
|
||||
* image by default.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function uploadLogo($app)
|
||||
{
|
||||
if ($_FILES['app_icon']['error'] ==
|
||||
UPLOAD_ERR_OK) {
|
||||
|
||||
try {
|
||||
$imagefile = ImageFile::fromUpload('app_icon');
|
||||
} catch (Exception $e) {
|
||||
common_debug("damn that sucks");
|
||||
$this->showForm($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = Avatar::filename($app->id,
|
||||
image_type_to_extension($imagefile->type),
|
||||
null,
|
||||
'oauth-app-icon-'.common_timestamp());
|
||||
|
||||
$filepath = Avatar::path($filename);
|
||||
|
||||
move_uploaded_file($imagefile->filepath, $filepath);
|
||||
|
||||
$app->setOriginal($filename);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -102,4 +102,39 @@ class Oauth_application extends Memcached_DataObject
|
||||
return empty($result) ? null : $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an image upload
|
||||
*
|
||||
* Does all the magic for handling an image upload, and crops the
|
||||
* image by default.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function uploadLogo()
|
||||
{
|
||||
if ($_FILES['app_icon']['error'] ==
|
||||
UPLOAD_ERR_OK) {
|
||||
|
||||
try {
|
||||
$imagefile = ImageFile::fromUpload('app_icon');
|
||||
} catch (Exception $e) {
|
||||
common_debug("damn that sucks");
|
||||
$this->showForm($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = Avatar::filename($this->id,
|
||||
image_type_to_extension($imagefile->type),
|
||||
null,
|
||||
'oauth-app-icon-'.common_timestamp());
|
||||
|
||||
$filepath = Avatar::path($filename);
|
||||
|
||||
move_uploaded_file($imagefile->filepath, $filepath);
|
||||
|
||||
$this->setOriginal($filename);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user