mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
fix desktop application creation issue
This commit is contained in:
@@ -282,7 +282,15 @@ return call_user_func(function()
|
|||||||
$app->post($route, function() use ($app)
|
$app->post($route, function() use ($app)
|
||||||
{
|
{
|
||||||
$submit = false;
|
$submit = false;
|
||||||
$post = new \API_OAuth2_Form_DevApp($app['request']);
|
if ($app['request']->get("type") == "desktop")
|
||||||
|
{
|
||||||
|
$post = new \API_OAuth2_Form_DevAppDesktop($app['request']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$post = new \API_OAuth2_Form_DevAppInternet($app['request']);
|
||||||
|
}
|
||||||
|
|
||||||
$violations = $app['validator']->validate($post);
|
$violations = $app['validator']->validate($post);
|
||||||
|
|
||||||
if ($violations->count() == 0)
|
if ($violations->count() == 0)
|
||||||
@@ -303,7 +311,8 @@ return call_user_func(function()
|
|||||||
|
|
||||||
$var = array(
|
$var = array(
|
||||||
"violations" => $violations,
|
"violations" => $violations,
|
||||||
"form" => $post
|
"form" => $post,
|
||||||
|
"request" => $request
|
||||||
);
|
);
|
||||||
|
|
||||||
return $app['response']('api/auth/application_dev_new.twig', $var);
|
return $app['response']('api/auth/application_dev_new.twig', $var);
|
||||||
|
170
lib/classes/API/OAuth2/Form/DevAppDesktop.class.php
Normal file
170
lib/classes/API/OAuth2/Form/DevAppDesktop.class.php
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package OAuth2 Connector
|
||||||
|
*
|
||||||
|
* @see http://oauth.net/2/
|
||||||
|
* @uses http://code.google.com/p/oauth2-php/
|
||||||
|
*
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Validator\Constraints;
|
||||||
|
|
||||||
|
class API_OAuth2_Form_DevAppDesktop
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $website;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
public function __construct(Request $request)
|
||||||
|
{
|
||||||
|
$this->name = $request->get('name', null);
|
||||||
|
$this->description = $request->get('description', null);
|
||||||
|
$this->website = $request->get('website', null);
|
||||||
|
$this->callback = $request->get('callback', null);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $callback
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $callback
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
public function setDescription($description)
|
||||||
|
{
|
||||||
|
$this->description = $description;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getWebsite()
|
||||||
|
{
|
||||||
|
return $this->website;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $callback
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
public function setWebsite($website)
|
||||||
|
{
|
||||||
|
$this->website = $website;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCallback()
|
||||||
|
{
|
||||||
|
return $this->callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $callback
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
public function setCallback($callback)
|
||||||
|
{
|
||||||
|
$this->callback = $callback;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param ClassMetadata $metadata
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
static public function loadValidatorMetadata(ClassMetadata $metadata)
|
||||||
|
{
|
||||||
|
$blank = array('message' => _('Cette valeur ne peut être vide'));
|
||||||
|
$url = array('message' => _('Url non valide'));
|
||||||
|
|
||||||
|
$metadata->addPropertyConstraint('name', new Constraints\NotBlank($blank));
|
||||||
|
$metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank));
|
||||||
|
$metadata->addPropertyConstraint('website', new Constraints\NotBlank($blank));
|
||||||
|
$metadata->addPropertyConstraint('website', new Constraints\Url($url));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
170
lib/classes/API/OAuth2/Form/DevAppInternet.class.php
Normal file
170
lib/classes/API/OAuth2/Form/DevAppInternet.class.php
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package OAuth2 Connector
|
||||||
|
*
|
||||||
|
* @see http://oauth.net/2/
|
||||||
|
* @uses http://code.google.com/p/oauth2-php/
|
||||||
|
*
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Validator\Constraints;
|
||||||
|
|
||||||
|
class API_OAuth2_Form_DevAppInternet
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $website;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
public function __construct(Request $request)
|
||||||
|
{
|
||||||
|
$this->name = $request->get('name', null);
|
||||||
|
$this->description = $request->get('description', null);
|
||||||
|
$this->website = $request->get('website', null);
|
||||||
|
$this->callback = $request->get('callback', null);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $callback
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $callback
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
public function setDescription($description)
|
||||||
|
{
|
||||||
|
$this->description = $description;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getWebsite()
|
||||||
|
{
|
||||||
|
return $this->website;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $callback
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
public function setWebsite($website)
|
||||||
|
{
|
||||||
|
$this->website = $website;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCallback()
|
||||||
|
{
|
||||||
|
return $this->callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $callback
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
public function setCallback($callback)
|
||||||
|
{
|
||||||
|
$this->callback = $callback;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param ClassMetadata $metadata
|
||||||
|
* @return API_OAuth2_Form_DevApp
|
||||||
|
*/
|
||||||
|
static public function loadValidatorMetadata(ClassMetadata $metadata)
|
||||||
|
{
|
||||||
|
$blank = array('message' => _('Cette valeur ne peut être vide'));
|
||||||
|
$url = array('message' => _('Url non valide'));
|
||||||
|
|
||||||
|
$metadata->addPropertyConstraint('name', new Constraints\NotBlank($blank));
|
||||||
|
$metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank));
|
||||||
|
$metadata->addPropertyConstraint('website', new Constraints\NotBlank($blank));
|
||||||
|
$metadata->addPropertyConstraint('website', new Constraints\Url($url));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -59,14 +59,16 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><label for="type">{% trans 'Type d\'application' %}</label></td>
|
<td><label for="type">{% trans 'Type d\'application' %}</label></td>
|
||||||
<td>{% trans 'Application web' %}
|
<td>{% trans 'Application web' %}
|
||||||
<input type="radio" name="type" value="web" checked="checked"/>
|
<input type="radio" name="type" value="web" {{ request.get("type") == "web" ? "checked='checked'" : "" }}/>
|
||||||
{% trans 'Application desktop' %}
|
{% trans 'Application desktop' %}
|
||||||
<input type="radio" name="type" value="desktop"/></td>
|
<input type="radio" name="type" value="desktop" {{ request.get("type") == "desktop" ? "checked='checked'" : "" }}/></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% if request.get("type") == "web" %}
|
||||||
<tr class="callback" style="height:25px;">
|
<tr class="callback" style="height:25px;">
|
||||||
<td><label for="callback">{% trans 'URL de callback' %} <br/></label></td>
|
<td><label for="callback">{% trans 'URL de callback' %} <br/></label></td>
|
||||||
<td>{{ _self.input("callback", callback|default("http://"), violations) }}</td>
|
<td>{{ _self.input("callback", callback|default("http://"), violations) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><button class="app_submit" type="button">{% trans 'boutton::valider' %}</button</td>
|
<td><button class="app_submit" type="button">{% trans 'boutton::valider' %}</button</td>
|
||||||
|
Reference in New Issue
Block a user