This commit is contained in:
Romain Neutron
2012-04-25 17:38:49 +02:00
parent 68527a48f2
commit dd994a9bd6
31 changed files with 182 additions and 125 deletions

View File

@@ -39,5 +39,6 @@ return call_user_func(
$app->error(function($e){
return new \Symfony\Component\HttpFoundation\Response($e->getMessage(), 403);
});
return $app;
});

View File

@@ -88,6 +88,7 @@ class Tools implements ControllerProviderInterface
'metadatasFirst' => $metadatasFirst,
'metadatasSecond' => $metadatasSecond
);
return new Response($app['Core']->getTwig()->render($template, $var));
});
@@ -115,6 +116,7 @@ class Tools implements ControllerProviderInterface
}
$json = $app['Core']->getSerializer()->serialize($return, 'json');
return new Response($json, 200, array('content-type' => 'application/json'));
});
@@ -143,6 +145,7 @@ class Tools implements ControllerProviderInterface
}
$json = $app['Core']->getSerializer()->serialize($return, 'json');
return new Response($json, 200, array('content-type' => 'application/json'));
});
@@ -251,6 +254,7 @@ class Tools implements ControllerProviderInterface
, 'fileName' => $fileName
, 'errorMessage' => $errorMessage
);
return new Response($app['Core']->getTwig()->render($template, $var));
}
});
@@ -276,6 +280,7 @@ class Tools implements ControllerProviderInterface
}
$json = $app['Core']->getSerializer()->serialize($return, 'json');
return new Response($json, 201, array('content-type' => 'application/json'));
});
@@ -307,6 +312,7 @@ class Tools implements ControllerProviderInterface
}
$json = $app['Core']->getSerializer()->serialize($return, 'json');
return new Response($json, 201, array('content-type' => 'application/json'));
});

View File

@@ -195,6 +195,7 @@ class API_OAuth2_Adapter extends OAuth2
$application = API_OAuth2_Application::load_from_client_id($this->appbox, $client_id);
if ($client_secret === NULL)
return true;
$crypted = $this->crypt_secret($client_secret, $application->get_nonce());
@@ -640,11 +641,13 @@ class API_OAuth2_Adapter extends OAuth2
if ($token_param === FALSE) // Access token was not provided
return $exit_not_present ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_BAD_REQUEST, $realm, OAUTH2_ERROR_INVALID_REQUEST, 'The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed.', NULL, $scope) : FALSE;
// Get the stored token data (from the implementing subclass)
$token = $this->getAccessToken($token_param);
if ($token === NULL)
return $exit_invalid ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_INVALID_TOKEN, 'The access token provided is invalid.', NULL, $scope) : FALSE;
if (isset($token['revoked']) && $token['revoked'])
@@ -656,11 +659,13 @@ class API_OAuth2_Adapter extends OAuth2
{
// Check token expiration (I'm leaving this check separated, later we'll fill in better error messages)
if (isset($token["expires"]) && time() > $token["expires"])
return $exit_expired ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_EXPIRED_TOKEN, 'The access token provided has expired.', NULL, $scope) : FALSE;
}
// Check scope, if provided
// If token doesn't have a scope, it's NULL/empty, or it's insufficient, then throw an error
if ($scope && ( ! isset($token["scope"]) || ! $token["scope"] || ! $this->checkScope($scope, $token["scope"])))
return $exit_scope ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_FORBIDDEN, $realm, OAUTH2_ERROR_INSUFFICIENT_SCOPE, 'The request requires higher privileges than provided by the access token.', NULL, $scope) : FALSE;
//save token's linked ses_id

View File

@@ -1156,6 +1156,7 @@ class API_V1_adapter extends API_V1_Abstract
* @todo ajouter une option pour avoir les values serialisées
* dans un cas multi
*/
return array(
'meta_id' => $value->getId()
, 'meta_structure_id' => $field->get_meta_struct_id()

View File

@@ -115,6 +115,7 @@ class API_V1_result
protected function parse_response_type()
{
if (trim($this->request->get('callback')) !== '')
return $this->response_type = self::FORMAT_JSONP;
$accept = $this->request->getAcceptableContentTypes();

View File

@@ -224,6 +224,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
foreach ($this->get_fields() as $meta_struct_id => $field)
{
if ($field->get_name() == $fieldname)
return $field;
}

View File

@@ -448,6 +448,7 @@ class databox extends base
$stmt->closeCursor();
if ($row)
return self::get_instance((int) $row['sbas_id']);
try
@@ -701,6 +702,7 @@ class databox extends base
}
}
if ($n > $limit)
return true;
return false;
@@ -1217,6 +1219,7 @@ class databox extends base
public function get_structure()
{
if ($this->structure)
return $this->structure;
$this->structure = $this->retrieve_structure();
@@ -1257,6 +1260,7 @@ class databox extends base
public function get_cterms()
{
if ($this->cterms)
return $this->cterms;
$sql = "SELECT value FROM pref WHERE prop='cterms'";
@@ -1423,6 +1427,7 @@ class databox extends base
public function get_cgus()
{
if ($this->cgus)
return $this->cgus;
$this->load_cgus();

View File

@@ -1696,6 +1696,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if ( ! $subdefs)
{
$Core['monolog']->addInfo(sprintf('Nothing to do for %s', $this->get_type()));
return;
}

View File

@@ -646,6 +646,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
);
if ( ! isset($res['results']) || ! is_array($res['results']))
return array();
$rs = $res['results'];
$res = array_shift($rs);

View File

@@ -264,6 +264,7 @@ class system_file extends SplFileObject
if (in_array($this->get_mime(), $raws))
return true;
return false;
}
@@ -292,8 +293,10 @@ class system_file extends SplFileObject
}
if ($lowercase)
return mb_strtolower($extension);
else
return $extension;
}
@@ -486,6 +489,7 @@ class system_file extends SplFileObject
$this->technical_datas = array();
if ( ! is_executable($registry->get('GV_mplayer')))
return $this;
$cmd = $registry->get('GV_mplayer')
@@ -708,6 +712,7 @@ class system_file extends SplFileObject
public function read_uuid()
{
if ($this->uuid)
return $this->uuid;
$datas = exiftool::extract_metadatas($this, exiftool::EXTRACT_XML_RDF);
@@ -746,6 +751,7 @@ class system_file extends SplFileObject
public function is_new_in_base($sbas_id)
{
if ( ! $this->uuid)
return true;
$connbas = connection::getPDOConnection($sbas_id);
@@ -817,6 +823,7 @@ class system_file extends SplFileObject
{
$value = $base64_encoded ? base64_decode($v->nodeValue) : $v->nodeValue;
if (uuid::is_valid($value))
return $value;
}
}
@@ -921,6 +928,7 @@ class system_file extends SplFileObject
public function get_phrasea_tech_field($field)
{
if (isset($this->phrasea_tech_field[$field]))
return $this->phrasea_tech_field[$field];
return null;
}
@@ -1255,6 +1263,7 @@ class system_file extends SplFileObject
for ($i = strlen($mac); $i;)
{
if (strpos($macchars, $mac[ -- $i]) !== false)
return(iconv('MACINTOSH', 'UTF-8', $mac));
}
@@ -1265,6 +1274,7 @@ class system_file extends SplFileObject
for ($i = strlen($s); $i;)
{
if (strpos($macchars, $s[ -- $i]) !== false)
return(iconv('MACINTOSH', 'UTF-8', $s));
}

View File

@@ -50,6 +50,7 @@ class task_Scheduler
{
file_put_contents($logdir . "scheduler_l.log", $message . "\n", FILE_APPEND);
}
return $this;
}

View File

@@ -115,6 +115,7 @@ abstract class task_abstract
$stmt->closeCursor();
if(!$row)
throw new Exception('Unknown task id');
return $row['status'];
}
@@ -446,6 +447,7 @@ $this->log(sprintf("task %d <- %s", $this->get_task_id(), $status));
}
fclose($fd);
}
return $pid;
}
@@ -604,6 +606,7 @@ $this->log(sprintf("task %d <- %s", $this->get_task_id(), $status));
$this->delete();
else
$this->set_status($this->return_value);
return $this;
}

View File

@@ -68,6 +68,7 @@ class task_manager
public function get_tasks($refresh = false)
{
if ($this->tasks && !$refresh)
return $this->tasks;
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";

View File

@@ -172,6 +172,7 @@ class task_period_archive extends task_abstract
<?php echo $form ?>.copy_spe.checked = <?php echo p4field::isyes($sxml->copy_spe) ? "true" : "false" ?>;
</script>
<?php
return("");
}
else // ... so we NEVER come here
@@ -204,6 +205,7 @@ class task_period_archive extends task_abstract
}
</script>
<?php
return;
}
@@ -514,6 +516,7 @@ class task_period_archive extends task_abstract
}
}
$this->return_value = $ret;
return($ret);
}
@@ -589,6 +592,7 @@ class task_period_archive extends task_abstract
$stmt->closeCursor();
if($row && $row['status'] == 'tostop')
return('NORECSTODO');
sleep(2);
$cold -= 2;
@@ -736,8 +740,10 @@ class task_period_archive extends task_abstract
{
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
if($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile))
return;
elseif($magicmethod == 'UNLOCK' && !file_exists($path . '/' . $magicfile))
return;
}
@@ -843,8 +849,10 @@ class task_period_archive extends task_abstract
{
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
if($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile))
return;
elseif($magicmethod == 'UNLOCK' && !file_exists($path . '/' . $magicfile))
return;
}
}
@@ -935,6 +943,7 @@ class task_period_archive extends task_abstract
$iloop = 0;
if($depth == 0 && ($node->getAttribute('temperature') == 'hot' || $node->getAttribute('cid') == '-1'))
return;
$xpath = new DOMXPath($dom); // useful
@@ -1093,6 +1102,7 @@ class task_period_archive extends task_abstract
$ret = false;
if($depth == 0 && $node->getAttribute('temperature') == 'hot') // if root of hotfolder if hot, die...
return($ret);
$nodesToDel = array();
@@ -1174,6 +1184,7 @@ class task_period_archive extends task_abstract
$iloop = 0;
if($node->getAttribute('temperature') == 'hot')
return;
$nodesToDel = array();
@@ -1250,6 +1261,7 @@ class task_period_archive extends task_abstract
$iloop = 0;
if($node->getAttribute('temperature') == 'hot')
return;
$ret = 0;
@@ -1313,6 +1325,7 @@ class task_period_archive extends task_abstract
$ret = false;
if($depth == 0 && $node->getAttribute('temperature') == 'hot') // if root of hotfolder if hot, die...
return($ret);
//printf("%s : \n", __LINE__);
@@ -1696,6 +1709,7 @@ class task_period_archive extends task_abstract
{
$match = $node->getAttribute('match');
if($match == '*')
return;
$file = $node->getAttribute('name');

View File

@@ -183,6 +183,7 @@ class task_period_cindexer extends task_abstract
parent.calccmd();
</script>
<?php
return("");
}
else // ... so we NEVER come here
@@ -251,6 +252,7 @@ class task_period_cindexer extends task_abstract
}
</script>
<?php
return;
}

View File

@@ -563,6 +563,7 @@
if(thumbnail.length === 0)
{
console.error('No image selected');
return;
}

View File

@@ -66,6 +66,7 @@ foreach(array('l' => 'log', 'o' => 'stdout', 'e' => 'stderr') as $k => $v)
if($parm['act'] == 'CLR')
{
file_put_contents($logfile, '');
return phrasea::redirect(sprintf("/admin/showlogtask.php?fil=%s&log=%s&id=%s"
, urlencode($parm['fil'])
, urlencode($parm['log'])

View File

@@ -254,6 +254,7 @@ foreach($tasks as $t)
beforeShow:function()
{
if(!retPing)
return;
if(retPing.scheduler && retPing.scheduler.pid)
{
@@ -321,6 +322,7 @@ foreach($tasks as $t)
var tid = $($(this)[0].target).parent().attr('id').split('_').pop();
if(!retPing || !retPing.tasks[tid])
return;
if(retPing.tasks[tid].pid)