repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Connection/ConnectionPoolManager.php
ConnectionPoolManager.add
public function add(Connection $connection) { $key = md5(serialize($connection->getParams())); if (isset($this->connections[$key]) && $connection !== $this->connections[$key]) { throw new \InvalidArgumentException('Expects a non registered connection.'); } $this->connections[$key] = $connection; }
php
public function add(Connection $connection) { $key = md5(serialize($connection->getParams())); if (isset($this->connections[$key]) && $connection !== $this->connections[$key]) { throw new \InvalidArgumentException('Expects a non registered connection.'); } $this->connections[$key] = $connection; }
[ "public", "function", "add", "(", "Connection", "$", "connection", ")", "{", "$", "key", "=", "md5", "(", "serialize", "(", "$", "connection", "->", "getParams", "(", ")", ")", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "connections", "[",...
Add a connection to the pool @param Connection $connection
[ "Add", "a", "connection", "to", "the", "pool" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Connection/ConnectionPoolManager.php#L63-L70
alchemy-fr/Phraseanet
lib/classes/patch/390alpha9a.php
patch_390alpha9a.apply
public function apply(base $appbox, Application $app) { $this->updateRegistry($app); $this->updateDoctrineUsers($app); $this->updateDataboxPrefs($appbox); }
php
public function apply(base $appbox, Application $app) { $this->updateRegistry($app); $this->updateDoctrineUsers($app); $this->updateDataboxPrefs($appbox); }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "$", "this", "->", "updateRegistry", "(", "$", "app", ")", ";", "$", "this", "->", "updateDoctrineUsers", "(", "$", "app", ")", ";", "$", "this", "->...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/390alpha9a.php#L49-L54
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Converter/ApiApplicationConverter.php
ApiApplicationConverter.convert
public function convert($id) { if (null === $application = $this->repository->find((int) $id)) { throw new NotFoundHttpException(sprintf('Application %s not found.', $id)); } return $application; }
php
public function convert($id) { if (null === $application = $this->repository->find((int) $id)) { throw new NotFoundHttpException(sprintf('Application %s not found.', $id)); } return $application; }
[ "public", "function", "convert", "(", "$", "id", ")", "{", "if", "(", "null", "===", "$", "application", "=", "$", "this", "->", "repository", "->", "find", "(", "(", "int", ")", "$", "id", ")", ")", "{", "throw", "new", "NotFoundHttpException", "(",...
{@inheritdoc} @return ApiApplication
[ "{", "@inheritdoc", "}" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Converter/ApiApplicationConverter.php#L32-L39
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.has_hd_grant
public function has_hd_grant(RecordReferenceInterface $record) { $this->load_hd_grant(); if (array_key_exists($record->getId(), $this->_rights_records_document)) { return true; } return false; }
php
public function has_hd_grant(RecordReferenceInterface $record) { $this->load_hd_grant(); if (array_key_exists($record->getId(), $this->_rights_records_document)) { return true; } return false; }
[ "public", "function", "has_hd_grant", "(", "RecordReferenceInterface", "$", "record", ")", "{", "$", "this", "->", "load_hd_grant", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "record", "->", "getId", "(", ")", ",", "$", "this", "->", "_rights_...
Check if a hd grant has been received for a record @param RecordReferenceInterface $record @return bool
[ "Check", "if", "a", "hd", "grant", "has", "been", "received", "for", "a", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L212-L222
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.has_preview_grant
public function has_preview_grant(RecordReferenceInterface $record) { $this->load_hd_grant(); if (array_key_exists($record->getId(), $this->_rights_records_preview)) { return true; } return false; }
php
public function has_preview_grant(RecordReferenceInterface $record) { $this->load_hd_grant(); if (array_key_exists($record->getId(), $this->_rights_records_preview)) { return true; } return false; }
[ "public", "function", "has_preview_grant", "(", "RecordReferenceInterface", "$", "record", ")", "{", "$", "this", "->", "load_hd_grant", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "record", "->", "getId", "(", ")", ",", "$", "this", "->", "_ri...
Check if a hd grant has been received for a record @param RecordReferenceInterface $record @return bool
[ "Check", "if", "a", "hd", "grant", "has", "been", "received", "for", "a", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L277-L286
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.apply_model
public function apply_model(User $template_user, Array $base_ids) { if (count($base_ids) == 0) { return $this; } $sbas_ids = []; foreach ($base_ids as $base_id) { $sbas_ids[] = phrasea::sbasFromBas($this->app, $base_id); } $sbas_ids = array_unique($sbas_ids); $sbas_to_acces = []; $rights_to_give = []; foreach ($this->app->getAclForUser($template_user)->get_granted_sbas() as $databox) { $sbas_id = $databox->get_sbas_id(); if (!in_array($sbas_id, $sbas_ids)) continue; if (!$this->has_access_to_sbas($sbas_id)) { $sbas_to_acces[] = $sbas_id; } foreach (self::$sbas_rights as $right) { if ($this->app->getAclForUser($template_user)->has_right_on_sbas($sbas_id, $right)) { $rights_to_give[$sbas_id][$right] = true; } } } $this->give_access_to_sbas($sbas_to_acces); foreach ($rights_to_give as $sbas_id => $rights) { $this->update_rights_to_sbas($sbas_id, $rights); } $bas_rights = $this->get_bas_rights(); $bas_to_acces = $masks_to_give = $rights_to_give = []; // todo ? wtf simplify this sb manipulation, now it is 32 bits /** * map masks (and+xor) of template to masks to apply to user on base * (and_and, and_or, xor_and, xor_or) */ $sbmap = [ '00' => ['aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'], '01' => ['aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'], '10' => ['aa' => '1', 'ao' => '1', 'xa' => '0', 'xo' => '0'], '11' => ['aa' => '1', 'ao' => '1', 'xa' => '1', 'xo' => '1'] ]; foreach ($this->app->getAclForUser($template_user)->get_granted_base() as $collection) { $base_id = $collection->get_base_id(); if (!in_array($base_id, $base_ids)) { continue; } if (!$this->has_access_to_base($base_id)) { $bas_to_acces[] = $base_id; } foreach ($bas_rights as $right) { if ($this->app->getAclForUser($template_user)->has_right_on_base($base_id, $right)) { $rights_to_give[$base_id][$right] = '1'; } } $mask_and = $this->app->getAclForUser($template_user)->get_mask_and($base_id); $mask_xor = $this->app->getAclForUser($template_user)->get_mask_xor($base_id); /** * apply sb is substractive */ $mand = substr( str_repeat('0', 32) . decbin($mask_and) , -32 ); $mxor = substr( str_repeat('0', 32) . decbin($mask_xor) , -32 ); $m = ['aa' => '', 'ao' => '', 'xa' => '', 'xo' => '']; for ($i = 0; $i < 32; $i++) { $ax = $mand[$i] . $mxor[$i]; foreach ($m as $k => $v) { $m[$k] .= $sbmap[$ax][$k]; } } $masks_to_give[$base_id] = [ 'aa' => $m['aa'], 'ao' => $m['ao'], 'xa' => $m['xa'], 'xo' => $m['xo'] ]; } $this->give_access_to_base($bas_to_acces); foreach ($masks_to_give as $base_id => $mask) { $this->set_masks_on_base($base_id, $mask['aa'], $mask['ao'], $mask['xa'], $mask['xo']); } foreach ($rights_to_give as $base_id => $rights) { $this->update_rights_to_base($base_id, $rights); } $this->apply_template_time_limits($template_user, $base_ids); $this->user->setLastAppliedTemplate($template_user); return $this; }
php
public function apply_model(User $template_user, Array $base_ids) { if (count($base_ids) == 0) { return $this; } $sbas_ids = []; foreach ($base_ids as $base_id) { $sbas_ids[] = phrasea::sbasFromBas($this->app, $base_id); } $sbas_ids = array_unique($sbas_ids); $sbas_to_acces = []; $rights_to_give = []; foreach ($this->app->getAclForUser($template_user)->get_granted_sbas() as $databox) { $sbas_id = $databox->get_sbas_id(); if (!in_array($sbas_id, $sbas_ids)) continue; if (!$this->has_access_to_sbas($sbas_id)) { $sbas_to_acces[] = $sbas_id; } foreach (self::$sbas_rights as $right) { if ($this->app->getAclForUser($template_user)->has_right_on_sbas($sbas_id, $right)) { $rights_to_give[$sbas_id][$right] = true; } } } $this->give_access_to_sbas($sbas_to_acces); foreach ($rights_to_give as $sbas_id => $rights) { $this->update_rights_to_sbas($sbas_id, $rights); } $bas_rights = $this->get_bas_rights(); $bas_to_acces = $masks_to_give = $rights_to_give = []; // todo ? wtf simplify this sb manipulation, now it is 32 bits /** * map masks (and+xor) of template to masks to apply to user on base * (and_and, and_or, xor_and, xor_or) */ $sbmap = [ '00' => ['aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'], '01' => ['aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'], '10' => ['aa' => '1', 'ao' => '1', 'xa' => '0', 'xo' => '0'], '11' => ['aa' => '1', 'ao' => '1', 'xa' => '1', 'xo' => '1'] ]; foreach ($this->app->getAclForUser($template_user)->get_granted_base() as $collection) { $base_id = $collection->get_base_id(); if (!in_array($base_id, $base_ids)) { continue; } if (!$this->has_access_to_base($base_id)) { $bas_to_acces[] = $base_id; } foreach ($bas_rights as $right) { if ($this->app->getAclForUser($template_user)->has_right_on_base($base_id, $right)) { $rights_to_give[$base_id][$right] = '1'; } } $mask_and = $this->app->getAclForUser($template_user)->get_mask_and($base_id); $mask_xor = $this->app->getAclForUser($template_user)->get_mask_xor($base_id); /** * apply sb is substractive */ $mand = substr( str_repeat('0', 32) . decbin($mask_and) , -32 ); $mxor = substr( str_repeat('0', 32) . decbin($mask_xor) , -32 ); $m = ['aa' => '', 'ao' => '', 'xa' => '', 'xo' => '']; for ($i = 0; $i < 32; $i++) { $ax = $mand[$i] . $mxor[$i]; foreach ($m as $k => $v) { $m[$k] .= $sbmap[$ax][$k]; } } $masks_to_give[$base_id] = [ 'aa' => $m['aa'], 'ao' => $m['ao'], 'xa' => $m['xa'], 'xo' => $m['xo'] ]; } $this->give_access_to_base($bas_to_acces); foreach ($masks_to_give as $base_id => $mask) { $this->set_masks_on_base($base_id, $mask['aa'], $mask['ao'], $mask['xa'], $mask['xo']); } foreach ($rights_to_give as $base_id => $rights) { $this->update_rights_to_base($base_id, $rights); } $this->apply_template_time_limits($template_user, $base_ids); $this->user->setLastAppliedTemplate($template_user); return $this; }
[ "public", "function", "apply_model", "(", "User", "$", "template_user", ",", "Array", "$", "base_ids", ")", "{", "if", "(", "count", "(", "$", "base_ids", ")", "==", "0", ")", "{", "return", "$", "this", ";", "}", "$", "sbas_ids", "=", "[", "]", ";...
Apply a template on user @param User $template_user @param array $base_ids @return ACL
[ "Apply", "a", "template", "on", "user" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L349-L471
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.is_restricted_download
public function is_restricted_download($base_id) { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) { return false; } return $this->_rights_bas[$base_id][self::RESTRICT_DWNLD]; }
php
public function is_restricted_download($base_id) { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) { return false; } return $this->_rights_bas[$base_id][self::RESTRICT_DWNLD]; }
[ "public", "function", "is_restricted_download", "(", "$", "base_id", ")", "{", "$", "this", "->", "load_rights_bas", "(", ")", ";", "if", "(", "!", "$", "this", "->", "has_access_to_base", "(", "$", "base_id", ")", ")", "{", "return", "false", ";", "}", ...
Return true if user is restricted in download on the collection @param int $base_id @return boolean
[ "Return", "true", "if", "user", "is", "restricted", "in", "download", "on", "the", "collection" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L582-L591
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.remaining_download
public function remaining_download($base_id) { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) { return false; } return (int) $this->_rights_bas[$base_id]['remain_dwnld']; }
php
public function remaining_download($base_id) { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) { return false; } return (int) $this->_rights_bas[$base_id]['remain_dwnld']; }
[ "public", "function", "remaining_download", "(", "$", "base_id", ")", "{", "$", "this", "->", "load_rights_bas", "(", ")", ";", "if", "(", "!", "$", "this", "->", "has_access_to_base", "(", "$", "base_id", ")", ")", "{", "return", "false", ";", "}", "r...
Return the number of remaining downloads on the collection @param int $base_id @return int
[ "Return", "the", "number", "of", "remaining", "downloads", "on", "the", "collection" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L599-L608
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.remove_remaining
public function remove_remaining($base_id, $n = 1) { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) { return false; } $this->_rights_bas[$base_id]['remain_dwnld'] = max(0, $this->_rights_bas[$base_id]['remain_dwnld'] - (int) $n); return $this; }
php
public function remove_remaining($base_id, $n = 1) { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) { return false; } $this->_rights_bas[$base_id]['remain_dwnld'] = max(0, $this->_rights_bas[$base_id]['remain_dwnld'] - (int) $n); return $this; }
[ "public", "function", "remove_remaining", "(", "$", "base_id", ",", "$", "n", "=", "1", ")", "{", "$", "this", "->", "load_rights_bas", "(", ")", ";", "if", "(", "!", "$", "this", "->", "has_access_to_base", "(", "$", "base_id", ")", ")", "{", "retur...
Remove n download from the remainings @param int $base_id @param int $n @return ACL todo : wtf direct cache modification, where is sql ?
[ "Remove", "n", "download", "from", "the", "remainings" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L619-L630
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.has_right
public function has_right($right) { $this->load_global_rights(); if (!isset($this->_global_rights[$right])) { throw new Exception('This right does not exists'); } return $this->_global_rights[$right]; }
php
public function has_right($right) { $this->load_global_rights(); if (!isset($this->_global_rights[$right])) { throw new Exception('This right does not exists'); } return $this->_global_rights[$right]; }
[ "public", "function", "has_right", "(", "$", "right", ")", "{", "$", "this", "->", "load_global_rights", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_global_rights", "[", "$", "right", "]", ")", ")", "{", "throw", "new", "Excepti...
Check if the user has the right, on at least one collection @param string $right @return bool @throws Exception
[ "Check", "if", "the", "user", "has", "the", "right", "on", "at", "least", "one", "collection" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L639-L648
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.has_right_on_sbas
public function has_right_on_sbas($sbas_id, $right) { $this->load_rights_sbas(); if (!isset($this->_rights_sbas[$sbas_id])) { return false; } if (!isset($this->_rights_sbas[$sbas_id][$right])) { throw new Exception('This right does not exists'); } if ($this->_rights_sbas[$sbas_id][$right] === true) { return true; } return false; }
php
public function has_right_on_sbas($sbas_id, $right) { $this->load_rights_sbas(); if (!isset($this->_rights_sbas[$sbas_id])) { return false; } if (!isset($this->_rights_sbas[$sbas_id][$right])) { throw new Exception('This right does not exists'); } if ($this->_rights_sbas[$sbas_id][$right] === true) { return true; } return false; }
[ "public", "function", "has_right_on_sbas", "(", "$", "sbas_id", ",", "$", "right", ")", "{", "$", "this", "->", "load_rights_sbas", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_rights_sbas", "[", "$", "sbas_id", "]", ")", ")", "{...
Check if the user has the required right on a database @param int $sbas_id @param string $right @return bool @throws Exception
[ "Check", "if", "the", "user", "has", "the", "required", "right", "on", "a", "database" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L658-L675
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.get_mask_and
public function get_mask_and($base_id) { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) { return false; } return $this->_rights_bas[$base_id]['mask_and']; }
php
public function get_mask_and($base_id) { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) { return false; } return $this->_rights_bas[$base_id]['mask_and']; }
[ "public", "function", "get_mask_and", "(", "$", "base_id", ")", "{", "$", "this", "->", "load_rights_bas", "(", ")", ";", "if", "(", "!", "$", "this", "->", "has_access_to_base", "(", "$", "base_id", ")", ")", "{", "return", "false", ";", "}", "return"...
Retrieve mask AND for user on specified base_id @param int $base_id @return int
[ "Retrieve", "mask", "AND", "for", "user", "on", "specified", "base_id" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L683-L691
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.get_mask_xor
public function get_mask_xor($base_id) { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) { return false; } return $this->_rights_bas[$base_id]['mask_xor']; }
php
public function get_mask_xor($base_id) { $this->load_rights_bas(); if (!$this->has_access_to_base($base_id)) { return false; } return $this->_rights_bas[$base_id]['mask_xor']; }
[ "public", "function", "get_mask_xor", "(", "$", "base_id", ")", "{", "$", "this", "->", "load_rights_bas", "(", ")", ";", "if", "(", "!", "$", "this", "->", "has_access_to_base", "(", "$", "base_id", ")", ")", "{", "return", "false", ";", "}", "return"...
Retrieve mask XOR for user on specified base_id @param int $base_id @return int
[ "Retrieve", "mask", "XOR", "for", "user", "on", "specified", "base_id" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L699-L707
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.has_access_to_base
public function has_access_to_base($base_id) { $this->load_rights_bas(); return (isset($this->_rights_bas[$base_id]) && $this->_rights_bas[$base_id][self::ACTIF] === true); }
php
public function has_access_to_base($base_id) { $this->load_rights_bas(); return (isset($this->_rights_bas[$base_id]) && $this->_rights_bas[$base_id][self::ACTIF] === true); }
[ "public", "function", "has_access_to_base", "(", "$", "base_id", ")", "{", "$", "this", "->", "load_rights_bas", "(", ")", ";", "return", "(", "isset", "(", "$", "this", "->", "_rights_bas", "[", "$", "base_id", "]", ")", "&&", "$", "this", "->", "_rig...
Return true if access to base_id is granted @param int $base_id @return boolean
[ "Return", "true", "if", "access", "to", "base_id", "is", "granted" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L715-L721
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.get_granted_base
public function get_granted_base(Array $rights = [], array $sbas_ids = null) { $this->load_rights_bas(); $ret = []; foreach ($this->app->getDataboxes() as $databox) { if ($sbas_ids && !in_array($databox->get_sbas_id(), $sbas_ids)) { continue; } foreach ($databox->get_collections() as $collection) { $continue = false; if (!array_key_exists($collection->get_base_id(), $this->_rights_bas)) { continue; } $base_id = $collection->get_base_id(); foreach ($rights as $right) { if (!$this->has_right_on_base($base_id, $right)) { $continue = true; break; } } if ($continue || $this->is_limited($base_id)) { continue; } $ret[$base_id] = $collection; } } return $ret; }
php
public function get_granted_base(Array $rights = [], array $sbas_ids = null) { $this->load_rights_bas(); $ret = []; foreach ($this->app->getDataboxes() as $databox) { if ($sbas_ids && !in_array($databox->get_sbas_id(), $sbas_ids)) { continue; } foreach ($databox->get_collections() as $collection) { $continue = false; if (!array_key_exists($collection->get_base_id(), $this->_rights_bas)) { continue; } $base_id = $collection->get_base_id(); foreach ($rights as $right) { if (!$this->has_right_on_base($base_id, $right)) { $continue = true; break; } } if ($continue || $this->is_limited($base_id)) { continue; } $ret[$base_id] = $collection; } } return $ret; }
[ "public", "function", "get_granted_base", "(", "Array", "$", "rights", "=", "[", "]", ",", "array", "$", "sbas_ids", "=", "null", ")", "{", "$", "this", "->", "load_rights_bas", "(", ")", ";", "$", "ret", "=", "[", "]", ";", "foreach", "(", "$", "t...
Return an array of base_id which are granted, with optionnal filter by rights @param array $rights @param array|null $sbas_ids Optionnal sbas_id to restrict the query on @return collection[] An array of collection
[ "Return", "an", "array", "of", "base_id", "which", "are", "granted", "with", "optionnal", "filter", "by", "rights" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L744-L778
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.get_granted_sbas
public function get_granted_sbas($rights = []) { if (is_string($rights)) { $rights = [$rights]; } assert(is_array($rights)); $this->load_rights_sbas(); $ret = []; foreach ($this->_rights_sbas as $sbas_id => $datas) { $continue = false; foreach ($rights as $right) { if (!$this->has_right_on_sbas($sbas_id, $right)) { $continue = true; break; } } if ($continue) { continue; } try { $ret[$sbas_id] = $this->app->findDataboxById((int) $sbas_id); } catch (\Exception $e) { // no-op } } return $ret; }
php
public function get_granted_sbas($rights = []) { if (is_string($rights)) { $rights = [$rights]; } assert(is_array($rights)); $this->load_rights_sbas(); $ret = []; foreach ($this->_rights_sbas as $sbas_id => $datas) { $continue = false; foreach ($rights as $right) { if (!$this->has_right_on_sbas($sbas_id, $right)) { $continue = true; break; } } if ($continue) { continue; } try { $ret[$sbas_id] = $this->app->findDataboxById((int) $sbas_id); } catch (\Exception $e) { // no-op } } return $ret; }
[ "public", "function", "get_granted_sbas", "(", "$", "rights", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "rights", ")", ")", "{", "$", "rights", "=", "[", "$", "rights", "]", ";", "}", "assert", "(", "is_array", "(", "$", "rights", ...
Return an array of databox (key=sbas_id) which are granted, with optionnal filter by rights @param Array $rights @return \databox[]
[ "Return", "an", "array", "of", "databox", "(", "key", "=", "sbas_id", ")", "which", "are", "granted", "with", "optionnal", "filter", "by", "rights" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L822-L855
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.load_hd_grant
protected function load_hd_grant() { if ($this->_rights_records_preview) { return $this; } try { $tmp_rights = $this->get_data_from_cache(self::CACHE_RIGHTS_RECORDS); $this->_rights_records_preview = $tmp_rights['preview']; $this->_rights_records_document = $tmp_rights['document']; return $this; } catch (\Exception $e) { } $sql = "SELECT sbas_id, record_id, preview, document FROM records_rights WHERE usr_id = :usr_id"; $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute([':usr_id' => $this->user->getId()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); unset($stmt); $this->_rights_records_preview = []; $this->_rights_records_document = []; foreach ($rs as $row) { $currentid = $row["sbas_id"] . "_" . $row["record_id"]; if ($row['document'] == '1') $this->_rights_records_document[$currentid] = $currentid; $this->_rights_records_preview[$currentid] = $currentid; } $datas = [ 'preview' => $this->_rights_records_preview, 'document' => $this->_rights_records_document ]; $this->set_data_to_cache($datas, self::CACHE_RIGHTS_RECORDS); return $this; }
php
protected function load_hd_grant() { if ($this->_rights_records_preview) { return $this; } try { $tmp_rights = $this->get_data_from_cache(self::CACHE_RIGHTS_RECORDS); $this->_rights_records_preview = $tmp_rights['preview']; $this->_rights_records_document = $tmp_rights['document']; return $this; } catch (\Exception $e) { } $sql = "SELECT sbas_id, record_id, preview, document FROM records_rights WHERE usr_id = :usr_id"; $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute([':usr_id' => $this->user->getId()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); unset($stmt); $this->_rights_records_preview = []; $this->_rights_records_document = []; foreach ($rs as $row) { $currentid = $row["sbas_id"] . "_" . $row["record_id"]; if ($row['document'] == '1') $this->_rights_records_document[$currentid] = $currentid; $this->_rights_records_preview[$currentid] = $currentid; } $datas = [ 'preview' => $this->_rights_records_preview, 'document' => $this->_rights_records_document ]; $this->set_data_to_cache($datas, self::CACHE_RIGHTS_RECORDS); return $this; }
[ "protected", "function", "load_hd_grant", "(", ")", "{", "if", "(", "$", "this", "->", "_rights_records_preview", ")", "{", "return", "$", "this", ";", "}", "try", "{", "$", "tmp_rights", "=", "$", "this", "->", "get_data_from_cache", "(", "self", "::", ...
Load if needed the elements which have a HD grant @return Array
[ "Load", "if", "needed", "the", "elements", "which", "have", "a", "HD", "grant" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L888-L930
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.load_rights_sbas
protected function load_rights_sbas() { if ($this->_rights_sbas && $this->_global_rights) { return $this; } try { $global_rights = $this->get_data_from_cache(self::CACHE_GLOBAL_RIGHTS); if (!is_array($global_rights)) { throw new Exception('global rights were not properly retrieved'); } $sbas_rights = $this->get_data_from_cache(self::CACHE_RIGHTS_SBAS); if (!is_array($sbas_rights)) { throw new Exception('sbas rights were not properly retrieved'); } $this->_global_rights = $global_rights; $this->_rights_sbas = $sbas_rights; return $this; } catch (\Exception $e) { // no-op } $sql = "SELECT sbasusr.* FROM sbasusr INNER JOIN sbas USING(sbas_id) WHERE usr_id= :usr_id"; $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute([':usr_id' => $this->user->getId()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->_rights_sbas = []; foreach(self::$sbas_rights as $b) { $this->_global_rights[$b] = false; } foreach ($rs as $row) { $sbid = $row['sbas_id']; $this->_rights_sbas[$sbid] = []; foreach (self::$sbas_rights as $b) { $this->_global_rights[$b] = ($this->_rights_sbas[$sbid][$b] = ($row[$b] == '1')) || $this->_global_rights[$b]; } } $this->set_data_to_cache($this->_rights_sbas, self::CACHE_RIGHTS_SBAS); $this->set_data_to_cache($this->_global_rights, self::CACHE_GLOBAL_RIGHTS); return $this; }
php
protected function load_rights_sbas() { if ($this->_rights_sbas && $this->_global_rights) { return $this; } try { $global_rights = $this->get_data_from_cache(self::CACHE_GLOBAL_RIGHTS); if (!is_array($global_rights)) { throw new Exception('global rights were not properly retrieved'); } $sbas_rights = $this->get_data_from_cache(self::CACHE_RIGHTS_SBAS); if (!is_array($sbas_rights)) { throw new Exception('sbas rights were not properly retrieved'); } $this->_global_rights = $global_rights; $this->_rights_sbas = $sbas_rights; return $this; } catch (\Exception $e) { // no-op } $sql = "SELECT sbasusr.* FROM sbasusr INNER JOIN sbas USING(sbas_id) WHERE usr_id= :usr_id"; $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute([':usr_id' => $this->user->getId()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->_rights_sbas = []; foreach(self::$sbas_rights as $b) { $this->_global_rights[$b] = false; } foreach ($rs as $row) { $sbid = $row['sbas_id']; $this->_rights_sbas[$sbid] = []; foreach (self::$sbas_rights as $b) { $this->_global_rights[$b] = ($this->_rights_sbas[$sbid][$b] = ($row[$b] == '1')) || $this->_global_rights[$b]; } } $this->set_data_to_cache($this->_rights_sbas, self::CACHE_RIGHTS_SBAS); $this->set_data_to_cache($this->_global_rights, self::CACHE_GLOBAL_RIGHTS); return $this; }
[ "protected", "function", "load_rights_sbas", "(", ")", "{", "if", "(", "$", "this", "->", "_rights_sbas", "&&", "$", "this", "->", "_global_rights", ")", "{", "return", "$", "this", ";", "}", "try", "{", "$", "global_rights", "=", "$", "this", "->", "g...
Loads rights of specified user for all sbas @return ACL
[ "Loads", "rights", "of", "specified", "user", "for", "all", "sbas" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L937-L986
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.load_rights_bas
protected function load_rights_bas() { if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited)) { return $this; } try { $data = $this->get_data_from_cache(self::CACHE_GLOBAL_RIGHTS); if (!is_array($data)) { throw new Exception('Unable to retrieve global rights'); } $this->_global_rights = $data; $data = $this->get_data_from_cache(self::CACHE_RIGHTS_BAS); if (!is_array($data)) { throw new Exception('Unable to retrieve base rights'); } $this->_rights_bas = $data; $data = $this->get_data_from_cache(self::CACHE_LIMITS_BAS); if (!is_array($data)) { throw new Exception('Unable to retrieve limits rights'); } $this->_limited = $data; return $this; } catch (\Exception $e) { // no-op } $sql = "SELECT u.* FROM basusr u, bas b, sbas s\n" . " WHERE usr_id= :usr_id\n" . " AND b.base_id = u.base_id\n" . " AND s.sbas_id = b.sbas_id"; $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute([':usr_id' => $this->user->getId()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->_rights_bas = $this->_limited = []; foreach(self::$bas_rights as $b) { $this->_global_rights[$b] = false; } foreach ($rs as $row) { $bid = $row['base_id']; foreach(self::$bas_rights as $b) { $this->_global_rights[$b] = ($this->_rights_bas[$bid][$b] = ($row[$b] == '1')) || $this->_global_rights[$b]; } $this->_rights_bas[$bid]['remain_dwnld'] = (int) $row['remain_dwnld']; $this->_rights_bas[$bid]['mask_and'] = (int) $row['mask_and']; $this->_rights_bas[$bid]['mask_xor'] = (int) $row['mask_xor']; $row['limited_from'] = $row['limited_from'] == '0000-00-00 00:00:00' ? '' : trim($row['limited_from']); $row['limited_to'] = $row['limited_to'] == '0000-00-00 00:00:00' ? '' : trim($row['limited_to']); if ($row['time_limited'] == '1' && ($row['limited_from'] !== '' || $row['limited_to'] !== '')) { $this->_limited[$bid] = [ 'dmin' => $row['limited_from'] ? new DateTime($row['limited_from']) : null, 'dmax' => $row['limited_to'] ? new DateTime($row['limited_to']) : null ]; } } $this->set_data_to_cache($this->_global_rights, self::CACHE_GLOBAL_RIGHTS); $this->set_data_to_cache($this->_rights_bas, self::CACHE_RIGHTS_BAS); $this->set_data_to_cache($this->_limited, self::CACHE_LIMITS_BAS); return $this; }
php
protected function load_rights_bas() { if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited)) { return $this; } try { $data = $this->get_data_from_cache(self::CACHE_GLOBAL_RIGHTS); if (!is_array($data)) { throw new Exception('Unable to retrieve global rights'); } $this->_global_rights = $data; $data = $this->get_data_from_cache(self::CACHE_RIGHTS_BAS); if (!is_array($data)) { throw new Exception('Unable to retrieve base rights'); } $this->_rights_bas = $data; $data = $this->get_data_from_cache(self::CACHE_LIMITS_BAS); if (!is_array($data)) { throw new Exception('Unable to retrieve limits rights'); } $this->_limited = $data; return $this; } catch (\Exception $e) { // no-op } $sql = "SELECT u.* FROM basusr u, bas b, sbas s\n" . " WHERE usr_id= :usr_id\n" . " AND b.base_id = u.base_id\n" . " AND s.sbas_id = b.sbas_id"; $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute([':usr_id' => $this->user->getId()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->_rights_bas = $this->_limited = []; foreach(self::$bas_rights as $b) { $this->_global_rights[$b] = false; } foreach ($rs as $row) { $bid = $row['base_id']; foreach(self::$bas_rights as $b) { $this->_global_rights[$b] = ($this->_rights_bas[$bid][$b] = ($row[$b] == '1')) || $this->_global_rights[$b]; } $this->_rights_bas[$bid]['remain_dwnld'] = (int) $row['remain_dwnld']; $this->_rights_bas[$bid]['mask_and'] = (int) $row['mask_and']; $this->_rights_bas[$bid]['mask_xor'] = (int) $row['mask_xor']; $row['limited_from'] = $row['limited_from'] == '0000-00-00 00:00:00' ? '' : trim($row['limited_from']); $row['limited_to'] = $row['limited_to'] == '0000-00-00 00:00:00' ? '' : trim($row['limited_to']); if ($row['time_limited'] == '1' && ($row['limited_from'] !== '' || $row['limited_to'] !== '')) { $this->_limited[$bid] = [ 'dmin' => $row['limited_from'] ? new DateTime($row['limited_from']) : null, 'dmax' => $row['limited_to'] ? new DateTime($row['limited_to']) : null ]; } } $this->set_data_to_cache($this->_global_rights, self::CACHE_GLOBAL_RIGHTS); $this->set_data_to_cache($this->_rights_bas, self::CACHE_RIGHTS_BAS); $this->set_data_to_cache($this->_limited, self::CACHE_LIMITS_BAS); return $this; }
[ "protected", "function", "load_rights_bas", "(", ")", "{", "if", "(", "$", "this", "->", "_rights_bas", "&&", "$", "this", "->", "_global_rights", "&&", "is_array", "(", "$", "this", "->", "_limited", ")", ")", "{", "return", "$", "this", ";", "}", "tr...
Loads rights of specified user for all bas @return ACL
[ "Loads", "rights", "of", "specified", "user", "for", "all", "bas" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L993-L1065
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.load_global_rights
protected function load_global_rights() { $this->load_rights_bas(); $this->load_rights_sbas(); $this->_global_rights[self::TASKMANAGER] = $this->is_admin(); return $this; }
php
protected function load_global_rights() { $this->load_rights_bas(); $this->load_rights_sbas(); $this->_global_rights[self::TASKMANAGER] = $this->is_admin(); return $this; }
[ "protected", "function", "load_global_rights", "(", ")", "{", "$", "this", "->", "load_rights_bas", "(", ")", ";", "$", "this", "->", "load_rights_sbas", "(", ")", ";", "$", "this", "->", "_global_rights", "[", "self", "::", "TASKMANAGER", "]", "=", "$", ...
Loads global rights for user @return ACL
[ "Loads", "global", "rights", "for", "user" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L1072-L1079
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.has_access_to_module
public function has_access_to_module($module_name) { switch ($module_name) { case 'admin': return ( ($this->has_right(self::BAS_MODIFY_STRUCT) || $this->has_right(self::COLL_MODIFY_STRUCT) || $this->has_right(self::BAS_MANAGE) || $this->has_right(self::COLL_MANAGE) || $this->has_right(self::CANADMIN) || $this->is_admin()) ); break; case 'thesaurus': return ($this->has_right(self::BAS_MODIF_TH) === true ); break; case 'upload': return ($this->has_right(self::CANADDRECORD) === true); break; case 'report': return ($this->has_right(self::CANREPORT) === true); break; default: break; } return true; }
php
public function has_access_to_module($module_name) { switch ($module_name) { case 'admin': return ( ($this->has_right(self::BAS_MODIFY_STRUCT) || $this->has_right(self::COLL_MODIFY_STRUCT) || $this->has_right(self::BAS_MANAGE) || $this->has_right(self::COLL_MANAGE) || $this->has_right(self::CANADMIN) || $this->is_admin()) ); break; case 'thesaurus': return ($this->has_right(self::BAS_MODIF_TH) === true ); break; case 'upload': return ($this->has_right(self::CANADDRECORD) === true); break; case 'report': return ($this->has_right(self::CANREPORT) === true); break; default: break; } return true; }
[ "public", "function", "has_access_to_module", "(", "$", "module_name", ")", "{", "switch", "(", "$", "module_name", ")", "{", "case", "'admin'", ":", "return", "(", "(", "$", "this", "->", "has_right", "(", "self", "::", "BAS_MODIFY_STRUCT", ")", "||", "$"...
Return whether or not the acces to the specified module is OK @param String $module_name @return boolean
[ "Return", "whether", "or", "not", "the", "acces", "to", "the", "specified", "module", "is", "OK" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L1087-L1113
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.update_rights_to_base
public function update_rights_to_base($base_id, $rights) { if (!$this->has_access_to_base($base_id) && (!isset($rights[self::ACTIF]) || $rights[self::ACTIF] == true)) { $this->give_access_to_base([$base_id]); } $conn = $this->app->getApplicationBox()->get_connection(); $sql_args = []; foreach ($rights as $right => $v) { if(is_bool($v)) { $v = $v ? 1 : 0; } $sql_args[] = " " . $conn->quoteIdentifier($right) . "=" . $conn->quote($v) . "\n"; } if (count($sql_args) == 0) { return $this; } $sql = "UPDATE basusr SET\n" . implode(',', $sql_args) . " WHERE base_id = :base_id AND usr_id = :usr_id"; $stmt = $conn->prepare($sql); $stmt->execute([':base_id' => $base_id, ':usr_id' => $this->user->getId()]); $stmt->closeCursor(); $this->delete_data_from_cache(self::CACHE_RIGHTS_BAS); $this->app['dispatcher']->dispatch( AclEvents::RIGHTS_TO_BASE_CHANGED, new RightsToBaseChangedEvent( $this, [ 'base_id' => $base_id, 'rights' => $rights ] ) ); return $this; }
php
public function update_rights_to_base($base_id, $rights) { if (!$this->has_access_to_base($base_id) && (!isset($rights[self::ACTIF]) || $rights[self::ACTIF] == true)) { $this->give_access_to_base([$base_id]); } $conn = $this->app->getApplicationBox()->get_connection(); $sql_args = []; foreach ($rights as $right => $v) { if(is_bool($v)) { $v = $v ? 1 : 0; } $sql_args[] = " " . $conn->quoteIdentifier($right) . "=" . $conn->quote($v) . "\n"; } if (count($sql_args) == 0) { return $this; } $sql = "UPDATE basusr SET\n" . implode(',', $sql_args) . " WHERE base_id = :base_id AND usr_id = :usr_id"; $stmt = $conn->prepare($sql); $stmt->execute([':base_id' => $base_id, ':usr_id' => $this->user->getId()]); $stmt->closeCursor(); $this->delete_data_from_cache(self::CACHE_RIGHTS_BAS); $this->app['dispatcher']->dispatch( AclEvents::RIGHTS_TO_BASE_CHANGED, new RightsToBaseChangedEvent( $this, [ 'base_id' => $base_id, 'rights' => $rights ] ) ); return $this; }
[ "public", "function", "update_rights_to_base", "(", "$", "base_id", ",", "$", "rights", ")", "{", "if", "(", "!", "$", "this", "->", "has_access_to_base", "(", "$", "base_id", ")", "&&", "(", "!", "isset", "(", "$", "rights", "[", "self", "::", "ACTIF"...
@todo Create special toggle 'actif' / not a right like others => nested loops when updating right to actif on an inactif account @param <type> $base_id @param <type> $rights @return ACL
[ "@todo", "Create", "special", "toggle", "actif", "/", "not", "a", "right", "like", "others", "=", ">", "nested", "loops", "when", "updating", "right", "to", "actif", "on", "an", "inactif", "account" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L1261-L1303
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.get_limits
public function get_limits($base_id) { $this->load_rights_bas(); if (!isset($this->_limited[$base_id])) { return null; } return $this->_limited[$base_id]; }
php
public function get_limits($base_id) { $this->load_rights_bas(); if (!isset($this->_limited[$base_id])) { return null; } return $this->_limited[$base_id]; }
[ "public", "function", "get_limits", "(", "$", "base_id", ")", "{", "$", "this", "->", "load_rights_bas", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_limited", "[", "$", "base_id", "]", ")", ")", "{", "return", "null", ";", "}"...
returns date limits ['dmin'=>x, 'dmax'=>y] with x,y : NullableDateTime @param $base_id @return array|null
[ "returns", "date", "limits", "[", "dmin", "=", ">", "x", "dmax", "=", ">", "y", "]", "with", "x", "y", ":", "NullableDateTime" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L1668-L1676
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.getOrderMasterCollectionsBaseIds
public function getOrderMasterCollectionsBaseIds() { $sql = "SELECT base_id FROM basusr WHERE order_master='1' AND usr_id= :usr_id"; $result = $this->app->getApplicationBox() ->get_connection() ->executeQuery($sql, [':usr_id' => $this->user->getId()]) ->fetchAll(\PDO::FETCH_ASSOC); $baseIds = []; foreach ($result as $item) { $baseIds[] = $item['base_id']; } return $baseIds; }
php
public function getOrderMasterCollectionsBaseIds() { $sql = "SELECT base_id FROM basusr WHERE order_master='1' AND usr_id= :usr_id"; $result = $this->app->getApplicationBox() ->get_connection() ->executeQuery($sql, [':usr_id' => $this->user->getId()]) ->fetchAll(\PDO::FETCH_ASSOC); $baseIds = []; foreach ($result as $item) { $baseIds[] = $item['base_id']; } return $baseIds; }
[ "public", "function", "getOrderMasterCollectionsBaseIds", "(", ")", "{", "$", "sql", "=", "\"SELECT base_id FROM basusr WHERE order_master='1' AND usr_id= :usr_id\"", ";", "$", "result", "=", "$", "this", "->", "app", "->", "getApplicationBox", "(", ")", "->", "get_conn...
Returns base ids on which user is 'order master' @return array
[ "Returns", "base", "ids", "on", "which", "user", "is", "order", "master" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L1726-L1742
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.get_order_master_collections
public function get_order_master_collections() { $baseIds = $this->getOrderMasterCollectionsBaseIds(); $collectionReferences = $this->app['repo.collection-references']->findHavingOrderMaster($baseIds); $groups = new CollectionReferenceCollection($collectionReferences); $collections = []; foreach ($groups->groupByDataboxIdAndCollectionId() as $databoxId => $group) { foreach ($group as $collectionId => $index) { $collections[$index] = \collection::getByCollectionId($this->app, $databoxId, $collectionId); } } ksort($collections); return $collections; }
php
public function get_order_master_collections() { $baseIds = $this->getOrderMasterCollectionsBaseIds(); $collectionReferences = $this->app['repo.collection-references']->findHavingOrderMaster($baseIds); $groups = new CollectionReferenceCollection($collectionReferences); $collections = []; foreach ($groups->groupByDataboxIdAndCollectionId() as $databoxId => $group) { foreach ($group as $collectionId => $index) { $collections[$index] = \collection::getByCollectionId($this->app, $databoxId, $collectionId); } } ksort($collections); return $collections; }
[ "public", "function", "get_order_master_collections", "(", ")", "{", "$", "baseIds", "=", "$", "this", "->", "getOrderMasterCollectionsBaseIds", "(", ")", ";", "$", "collectionReferences", "=", "$", "this", "->", "app", "[", "'repo.collection-references'", "]", "-...
Returns an array of collections on which the user is 'order master' @return collection[]
[ "Returns", "an", "array", "of", "collections", "on", "which", "the", "user", "is", "order", "master" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L1749-L1767
alchemy-fr/Phraseanet
lib/classes/ACL.php
ACL.set_order_master
public function set_order_master(\collection $collection, $bool) { $sql = "UPDATE basusr SET order_master = :master WHERE usr_id = :usr_id AND base_id = :base_id"; $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute([ ':master' => $bool ? 1 : 0, ':usr_id' => $this->user->getId(), ':base_id' => $collection->get_base_id() ]); $stmt->closeCursor(); return $this; }
php
public function set_order_master(\collection $collection, $bool) { $sql = "UPDATE basusr SET order_master = :master WHERE usr_id = :usr_id AND base_id = :base_id"; $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute([ ':master' => $bool ? 1 : 0, ':usr_id' => $this->user->getId(), ':base_id' => $collection->get_base_id() ]); $stmt->closeCursor(); return $this; }
[ "public", "function", "set_order_master", "(", "\\", "collection", "$", "collection", ",", "$", "bool", ")", "{", "$", "sql", "=", "\"UPDATE basusr SET order_master = :master WHERE usr_id = :usr_id AND base_id = :base_id\"", ";", "$", "stmt", "=", "$", "this", "->", "...
Sets the user as "order_master" on a collection @param \collection $collection The collection to apply @param Boolean $bool Wheter the user is order master or not @return ACL
[ "Sets", "the", "user", "as", "order_master", "on", "a", "collection" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/ACL.php#L1777-L1790
alchemy-fr/Phraseanet
lib/classes/patch/371alpha1a.php
patch_371alpha1a.apply
public function apply(base $databox, Application $app) { foreach ($databox->get_meta_structure() as $databox_field) { $databox_field->save(); } return true; }
php
public function apply(base $databox, Application $app) { foreach ($databox->get_meta_structure() as $databox_field) { $databox_field->save(); } return true; }
[ "public", "function", "apply", "(", "base", "$", "databox", ",", "Application", "$", "app", ")", "{", "foreach", "(", "$", "databox", "->", "get_meta_structure", "(", ")", "as", "$", "databox_field", ")", "{", "$", "databox_field", "->", "save", "(", ")"...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/371alpha1a.php#L49-L56
alchemy-fr/Phraseanet
lib/classes/patch/320alpha4b.php
patch_320alpha4b.apply
public function apply(base $appbox, Application $app) { try { $sql = 'ALTER TABLE `ssel` ADD `migrated` INT NOT NULL DEFAULT "0"'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); } catch (\Exception $e) { } $sql = 'SELECT ssel_id, usr_id, name, descript, pub_date, updater, pub_restrict, homelink FROM ssel WHERE (public = "1" OR homelink="1") AND migrated = 0'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $date_ref = new DateTime(); $n = 0; $app['orm.em']->getEventManager()->removeEventSubscriber(new TimestampableListener()); foreach ($rs as $row) { if (null === $user = $this->loadUser($app['orm.em'], $row['usr_id'])) { continue; } $feed = $this->get_feed($app, $appbox, $user, $row['pub_restrict'], $row['homelink']); if (! $feed instanceof Feed) { continue; } $publishers = $feed->getPublishers(); $entry = new FeedEntry(); $entry->setAuthorEmail((string) $user->getEmail()); $entry->setAuthorName((string) $user->getDisplayName()); $entry->setFeed($feed); $entry->setPublisher($publishers->first()); $entry->setTitle($row['name']); $entry->setSubtitle($row['descript']); $feed->addEntry($entry); $date_create = new DateTime($row['pub_date']); if ($date_create < $date_ref) { $date_ref = $date_create; } $entry->setCreatedOn($date_create); if ($row['updater'] != '0000-00-00 00:00:00') { $date_update = new DateTime($row['updater']); $entry->setUpdatedOn($date_update); } $sql = 'SELECT sselcont_id, ssel_id, base_id, record_id FROM sselcont WHERE ssel_id = :ssel_id ORDER BY ord ASC'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute([':ssel_id' => $row['ssel_id']]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($rs as $row) { try { $record = new record_adapter($app, phrasea::sbasFromBas($app, $row['base_id']), $row['record_id']); $item = new FeedItem(); $item->setEntry($entry); $entry->addItem($item); $item->setRecordId($record->getRecordId()); $item->setSbasId($record->getDataboxId()); $app['orm.em']->persist($item); } catch (NotFoundHttpException $e) { } } $app['orm.em']->persist($entry); $sql = 'UPDATE ssel SET deleted = "1", migrated="1" WHERE ssel_id = :ssel_id'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute([':ssel_id' => $row['ssel_id']]); $stmt->closeCursor(); $app['orm.em']->persist($feed); $n++; if ($n % 1000 == 0) { $app['orm.em']->flush(); $app['orm.em']->clear(); } } $this->set_feed_dates($date_ref); $app['orm.em']->flush(); $app['orm.em']->clear(); $app['orm.em']->getEventManager()->removeEventSubscriber(new TimestampableListener()); return true; }
php
public function apply(base $appbox, Application $app) { try { $sql = 'ALTER TABLE `ssel` ADD `migrated` INT NOT NULL DEFAULT "0"'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); } catch (\Exception $e) { } $sql = 'SELECT ssel_id, usr_id, name, descript, pub_date, updater, pub_restrict, homelink FROM ssel WHERE (public = "1" OR homelink="1") AND migrated = 0'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $date_ref = new DateTime(); $n = 0; $app['orm.em']->getEventManager()->removeEventSubscriber(new TimestampableListener()); foreach ($rs as $row) { if (null === $user = $this->loadUser($app['orm.em'], $row['usr_id'])) { continue; } $feed = $this->get_feed($app, $appbox, $user, $row['pub_restrict'], $row['homelink']); if (! $feed instanceof Feed) { continue; } $publishers = $feed->getPublishers(); $entry = new FeedEntry(); $entry->setAuthorEmail((string) $user->getEmail()); $entry->setAuthorName((string) $user->getDisplayName()); $entry->setFeed($feed); $entry->setPublisher($publishers->first()); $entry->setTitle($row['name']); $entry->setSubtitle($row['descript']); $feed->addEntry($entry); $date_create = new DateTime($row['pub_date']); if ($date_create < $date_ref) { $date_ref = $date_create; } $entry->setCreatedOn($date_create); if ($row['updater'] != '0000-00-00 00:00:00') { $date_update = new DateTime($row['updater']); $entry->setUpdatedOn($date_update); } $sql = 'SELECT sselcont_id, ssel_id, base_id, record_id FROM sselcont WHERE ssel_id = :ssel_id ORDER BY ord ASC'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute([':ssel_id' => $row['ssel_id']]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($rs as $row) { try { $record = new record_adapter($app, phrasea::sbasFromBas($app, $row['base_id']), $row['record_id']); $item = new FeedItem(); $item->setEntry($entry); $entry->addItem($item); $item->setRecordId($record->getRecordId()); $item->setSbasId($record->getDataboxId()); $app['orm.em']->persist($item); } catch (NotFoundHttpException $e) { } } $app['orm.em']->persist($entry); $sql = 'UPDATE ssel SET deleted = "1", migrated="1" WHERE ssel_id = :ssel_id'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute([':ssel_id' => $row['ssel_id']]); $stmt->closeCursor(); $app['orm.em']->persist($feed); $n++; if ($n % 1000 == 0) { $app['orm.em']->flush(); $app['orm.em']->clear(); } } $this->set_feed_dates($date_ref); $app['orm.em']->flush(); $app['orm.em']->clear(); $app['orm.em']->getEventManager()->removeEventSubscriber(new TimestampableListener()); return true; }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "try", "{", "$", "sql", "=", "'ALTER TABLE `ssel` ADD `migrated` INT NOT NULL DEFAULT \"0\"'", ";", "$", "stmt", "=", "$", "appbox", "->", "get_connection", "(",...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/320alpha4b.php#L64-L165
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Authentication/Phrasea/FailureHandledNativeAuthentication.php
FailureHandledNativeAuthentication.getUsrId
public function getUsrId($username, $password, Request $request) { // check failures and throws a RequireCaptchaException is needed $this->failure->checkFailures($username, $request); $usr_id = $this->auth->getUsrId($username, $password, $request); if (null === $usr_id) { $this->failure->saveFailure($username, $request); // check failures $this->failure->checkFailures($username, $request); } return $usr_id; }
php
public function getUsrId($username, $password, Request $request) { // check failures and throws a RequireCaptchaException is needed $this->failure->checkFailures($username, $request); $usr_id = $this->auth->getUsrId($username, $password, $request); if (null === $usr_id) { $this->failure->saveFailure($username, $request); // check failures $this->failure->checkFailures($username, $request); } return $usr_id; }
[ "public", "function", "getUsrId", "(", "$", "username", ",", "$", "password", ",", "Request", "$", "request", ")", "{", "// check failures and throws a RequireCaptchaException is needed", "$", "this", "->", "failure", "->", "checkFailures", "(", "$", "username", ","...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Authentication/Phrasea/FailureHandledNativeAuthentication.php#L30-L44
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Provider/OrderServiceProvider.php
OrderServiceProvider.register
public function register(Application $app) { $app['events.order_subscriber'] = $app->share(function (Application $app) { $notifierRegistry = new ValidationNotifierRegistry(); $notifierRegistry->registerNotifier(Order::NOTIFY_MAIL, new MailNotifier($app)); $notifierRegistry->registerNotifier(Order::NOTIFY_WEBHOOK, new WebhookNotifier( new LazyLocator($app, 'manipulator.webhook-event') )); return new OrderSubscriber($app, $notifierRegistry); }); }
php
public function register(Application $app) { $app['events.order_subscriber'] = $app->share(function (Application $app) { $notifierRegistry = new ValidationNotifierRegistry(); $notifierRegistry->registerNotifier(Order::NOTIFY_MAIL, new MailNotifier($app)); $notifierRegistry->registerNotifier(Order::NOTIFY_WEBHOOK, new WebhookNotifier( new LazyLocator($app, 'manipulator.webhook-event') )); return new OrderSubscriber($app, $notifierRegistry); }); }
[ "public", "function", "register", "(", "Application", "$", "app", ")", "{", "$", "app", "[", "'events.order_subscriber'", "]", "=", "$", "app", "->", "share", "(", "function", "(", "Application", "$", "app", ")", "{", "$", "notifierRegistry", "=", "new", ...
Registers services on the given app. This method should only be used to configure services and parameters. It should not get services.
[ "Registers", "services", "on", "the", "given", "app", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Provider/OrderServiceProvider.php#L32-L44
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Prod/ShareController.php
ShareController.shareRecord
public function shareRecord($base_id, $record_id) { $record = new \record_adapter($this->app, \phrasea::sbasFromBas($this->app, $base_id), $record_id); //get list of subdefs $subdefs = $record->get_subdefs(); $databoxSubdefs = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType()); $acl = $this->getAclForUser(); $subdefList = []; $defaultKey = null; foreach ($subdefs as $subdef) { $subdefName = $subdef->get_name(); if ($subdefName == 'document') { if (!$acl->has_right_on_base($record->getBaseId(), \ACL::CANDWNLDHD)) { continue; } $label = $this->app->trans('prod::tools: document'); } elseif ($databoxSubdefs->hasSubdef($subdefName)) { if (!$acl->has_access_to_subdef($record, $subdefName)) { continue; } $label = $databoxSubdefs->getSubdef($subdefName)->get_label($this->app['locale']); } else { // this subdef does no exists anymore in databox structure ? continue; // don't publish it } $value = $subdef->get_name(); $preview = $record->get_subdef($value); $defaultKey = $value; // will set a default option if neither preview,thumbnail or document is present if (($previewLink = $preview->get_permalink()) !== null) { $permalinkUrl = $previewLink->get_url()->__toString(); $permaviewUrl = $previewLink->get_page(); $previewWidth = $preview->get_width(); $previewHeight = $preview->get_height(); $embedUrl = $this->app->url('alchemy_embed_view', ['url' => (string)$permalinkUrl]); $previewData = [ 'label' => $label, 'permalinkUrl' => $permalinkUrl, 'permaviewUrl' => $permaviewUrl, 'embedUrl' => $embedUrl, 'width' => $previewWidth, 'height' => $previewHeight ]; $subdefList[$value] = $previewData; } } // candidates as best default selected option foreach (["preview", "thumbnail", "document"] as $k) { if (array_key_exists($k, $subdefList)) { $defaultKey = $k; break; } } // if no subdef was sharable, subdefList is empty and defaultKey is null // the twig MUST handle that $outputVars = [ 'isAvailable' => !empty($subdefList), 'subdefList' => $subdefList, 'defaultKey' => $defaultKey ]; return $this->renderResponse('prod/Share/record.html.twig', $outputVars); }
php
public function shareRecord($base_id, $record_id) { $record = new \record_adapter($this->app, \phrasea::sbasFromBas($this->app, $base_id), $record_id); //get list of subdefs $subdefs = $record->get_subdefs(); $databoxSubdefs = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType()); $acl = $this->getAclForUser(); $subdefList = []; $defaultKey = null; foreach ($subdefs as $subdef) { $subdefName = $subdef->get_name(); if ($subdefName == 'document') { if (!$acl->has_right_on_base($record->getBaseId(), \ACL::CANDWNLDHD)) { continue; } $label = $this->app->trans('prod::tools: document'); } elseif ($databoxSubdefs->hasSubdef($subdefName)) { if (!$acl->has_access_to_subdef($record, $subdefName)) { continue; } $label = $databoxSubdefs->getSubdef($subdefName)->get_label($this->app['locale']); } else { // this subdef does no exists anymore in databox structure ? continue; // don't publish it } $value = $subdef->get_name(); $preview = $record->get_subdef($value); $defaultKey = $value; // will set a default option if neither preview,thumbnail or document is present if (($previewLink = $preview->get_permalink()) !== null) { $permalinkUrl = $previewLink->get_url()->__toString(); $permaviewUrl = $previewLink->get_page(); $previewWidth = $preview->get_width(); $previewHeight = $preview->get_height(); $embedUrl = $this->app->url('alchemy_embed_view', ['url' => (string)$permalinkUrl]); $previewData = [ 'label' => $label, 'permalinkUrl' => $permalinkUrl, 'permaviewUrl' => $permaviewUrl, 'embedUrl' => $embedUrl, 'width' => $previewWidth, 'height' => $previewHeight ]; $subdefList[$value] = $previewData; } } // candidates as best default selected option foreach (["preview", "thumbnail", "document"] as $k) { if (array_key_exists($k, $subdefList)) { $defaultKey = $k; break; } } // if no subdef was sharable, subdefList is empty and defaultKey is null // the twig MUST handle that $outputVars = [ 'isAvailable' => !empty($subdefList), 'subdefList' => $subdefList, 'defaultKey' => $defaultKey ]; return $this->renderResponse('prod/Share/record.html.twig', $outputVars); }
[ "public", "function", "shareRecord", "(", "$", "base_id", ",", "$", "record_id", ")", "{", "$", "record", "=", "new", "\\", "record_adapter", "(", "$", "this", "->", "app", ",", "\\", "phrasea", "::", "sbasFromBas", "(", "$", "this", "->", "app", ",", ...
Share a record @param integer $base_id @param integer $record_id @return Response
[ "Share", "a", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Prod/ShareController.php#L24-L92
alchemy-fr/Phraseanet
lib/classes/patch/380alpha9a.php
patch_380alpha9a.apply
public function apply(base $databox, Application $app) { $sxe = $databox->get_sxml_structure(); if ($sxe !== false) { foreach ($sxe->statbits->bit as $sb) { $bit = (int) ($sb["n"]); if ($bit < 4 && $bit > 31) { continue; } $name = (string) $sb; $labelOff = (string) $sb['labelOff']; $labelOn = (string) $sb['labelOn']; $this->status[$bit]["labeloff"] = $labelOff ? : 'no-' . $name; $this->status[$bit]["labelon"] = $labelOn ? : 'ok-' . $name; } } $dom = new \DOMDocument(); $dom->loadXML($sxe->asXML()); $databox->saveStructure($dom); return true; }
php
public function apply(base $databox, Application $app) { $sxe = $databox->get_sxml_structure(); if ($sxe !== false) { foreach ($sxe->statbits->bit as $sb) { $bit = (int) ($sb["n"]); if ($bit < 4 && $bit > 31) { continue; } $name = (string) $sb; $labelOff = (string) $sb['labelOff']; $labelOn = (string) $sb['labelOn']; $this->status[$bit]["labeloff"] = $labelOff ? : 'no-' . $name; $this->status[$bit]["labelon"] = $labelOn ? : 'ok-' . $name; } } $dom = new \DOMDocument(); $dom->loadXML($sxe->asXML()); $databox->saveStructure($dom); return true; }
[ "public", "function", "apply", "(", "base", "$", "databox", ",", "Application", "$", "app", ")", "{", "$", "sxe", "=", "$", "databox", "->", "get_sxml_structure", "(", ")", ";", "if", "(", "$", "sxe", "!==", "false", ")", "{", "foreach", "(", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/380alpha9a.php#L49-L75
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Report/ReportService.php
ReportService.getGranted
public function getGranted() { $databoxes = []; /** @var \collection $collection */ foreach ($this->acl->get_granted_base([\ACL::CANREPORT]) as $collection) { $sbas_id = $collection->get_sbas_id(); if (!isset($databoxes[$sbas_id])) { $databoxes[$sbas_id] = [ 'id' => $sbas_id, 'name' => $collection->get_databox()->get_viewname(), 'collections' => [] ]; } $databoxes[$sbas_id]['collections'][$collection->get_base_id()] = [ 'id' => $collection->get_base_id(), 'coll_id' => $collection->get_coll_id(), 'name' => $collection->get_name() ]; } return ['databoxes' => $databoxes]; }
php
public function getGranted() { $databoxes = []; /** @var \collection $collection */ foreach ($this->acl->get_granted_base([\ACL::CANREPORT]) as $collection) { $sbas_id = $collection->get_sbas_id(); if (!isset($databoxes[$sbas_id])) { $databoxes[$sbas_id] = [ 'id' => $sbas_id, 'name' => $collection->get_databox()->get_viewname(), 'collections' => [] ]; } $databoxes[$sbas_id]['collections'][$collection->get_base_id()] = [ 'id' => $collection->get_base_id(), 'coll_id' => $collection->get_coll_id(), 'name' => $collection->get_name() ]; } return ['databoxes' => $databoxes]; }
[ "public", "function", "getGranted", "(", ")", "{", "$", "databoxes", "=", "[", "]", ";", "/** @var \\collection $collection */", "foreach", "(", "$", "this", "->", "acl", "->", "get_granted_base", "(", "[", "\\", "ACL", "::", "CANREPORT", "]", ")", "as", "...
return bases allowed for reporting, grouped by databox @return array
[ "return", "bases", "allowed", "for", "reporting", "grouped", "by", "databox" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Report/ReportService.php#L38-L60
alchemy-fr/Phraseanet
lib/classes/caption/field.php
caption_field.get_serialized_values
public function get_serialized_values($custom_separator = false, $highlight = false) { if (0 === count($this->values)) { return null; } if ($this->is_multi()) { $separator = $custom_separator !== false ? $custom_separator : $this->databox_field->get_separator(); return $this->serialize_value($this->values, $separator, $highlight); } /** @var caption_Field_Value $value */ $value = current($this->values); if ($highlight) { return $value->highlight_thesaurus(); } return $value->getValue(); }
php
public function get_serialized_values($custom_separator = false, $highlight = false) { if (0 === count($this->values)) { return null; } if ($this->is_multi()) { $separator = $custom_separator !== false ? $custom_separator : $this->databox_field->get_separator(); return $this->serialize_value($this->values, $separator, $highlight); } /** @var caption_Field_Value $value */ $value = current($this->values); if ($highlight) { return $value->highlight_thesaurus(); } return $value->getValue(); }
[ "public", "function", "get_serialized_values", "(", "$", "custom_separator", "=", "false", ",", "$", "highlight", "=", "false", ")", "{", "if", "(", "0", "===", "count", "(", "$", "this", "->", "values", ")", ")", "{", "return", "null", ";", "}", "if",...
@param string|bool $custom_separator @param bool $highlight @return string
[ "@param", "string|bool", "$custom_separator", "@param", "bool", "$highlight" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/caption/field.php#L195-L216
alchemy-fr/Phraseanet
lib/classes/caption/field.php
caption_field.get_cache_key
public function get_cache_key($option = null) { return 'caption_field_' . $this->databox_field->get_id() . '_' . $this->record->getId() . ($option ? '_' . $option : ''); }
php
public function get_cache_key($option = null) { return 'caption_field_' . $this->databox_field->get_id() . '_' . $this->record->getId() . ($option ? '_' . $option : ''); }
[ "public", "function", "get_cache_key", "(", "$", "option", "=", "null", ")", "{", "return", "'caption_field_'", ".", "$", "this", "->", "databox_field", "->", "get_id", "(", ")", ".", "'_'", ".", "$", "this", "->", "record", "->", "getId", "(", ")", "....
Part of the cache_cacheableInterface @param string $option @return string
[ "Part", "of", "the", "cache_cacheableInterface" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/caption/field.php#L376-L379
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php
FeedRepository.getAllForUser
public function getAllForUser(\ACL $userACL, array $restrictions = []) { $base_ids = array_keys($userACL->get_granted_base()); $qb = $this ->createQueryBuilder('f'); $qb->where($qb->expr()->isNull('f.baseId')) ->orWhere($qb->expr()->eq('f.public', $qb->expr()->literal(true))); if (count($restrictions) > 0 && count($base_ids) > 0) { $base_ids = array_intersect($base_ids, $restrictions); } if (empty($base_ids) && count($restrictions) > 0) { $base_ids = $restrictions; } if (count($base_ids) > 0) { $qb->orWhere($qb->expr()->in('f.baseId', $base_ids)); } $qb->orderBy('f.updatedOn', 'DESC'); return $qb->getQuery()->getResult(); }
php
public function getAllForUser(\ACL $userACL, array $restrictions = []) { $base_ids = array_keys($userACL->get_granted_base()); $qb = $this ->createQueryBuilder('f'); $qb->where($qb->expr()->isNull('f.baseId')) ->orWhere($qb->expr()->eq('f.public', $qb->expr()->literal(true))); if (count($restrictions) > 0 && count($base_ids) > 0) { $base_ids = array_intersect($base_ids, $restrictions); } if (empty($base_ids) && count($restrictions) > 0) { $base_ids = $restrictions; } if (count($base_ids) > 0) { $qb->orWhere($qb->expr()->in('f.baseId', $base_ids)); } $qb->orderBy('f.updatedOn', 'DESC'); return $qb->getQuery()->getResult(); }
[ "public", "function", "getAllForUser", "(", "\\", "ACL", "$", "userACL", ",", "array", "$", "restrictions", "=", "[", "]", ")", "{", "$", "base_ids", "=", "array_keys", "(", "$", "userACL", "->", "get_granted_base", "(", ")", ")", ";", "$", "qb", "=", ...
Returns all the feeds a user can access. @param \ACL $userACL @param array $restrictions @return Feed[]
[ "Returns", "all", "the", "feeds", "a", "user", "can", "access", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php#L33-L58
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php
FeedRepository.findByIds
public function findByIds(array $feedIds) { $qb = $this->createQueryBuilder('f'); if (!empty($feedIds)) { $qb->Where($qb->expr()->in('f.id', $feedIds)); } $qb->orderBy('f.updatedOn', 'DESC'); return $qb->getQuery()->getResult(); }
php
public function findByIds(array $feedIds) { $qb = $this->createQueryBuilder('f'); if (!empty($feedIds)) { $qb->Where($qb->expr()->in('f.id', $feedIds)); } $qb->orderBy('f.updatedOn', 'DESC'); return $qb->getQuery()->getResult(); }
[ "public", "function", "findByIds", "(", "array", "$", "feedIds", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'f'", ")", ";", "if", "(", "!", "empty", "(", "$", "feedIds", ")", ")", "{", "$", "qb", "->", "Where", "(", ...
Returns all the feeds from a given array containing their id. @param array $feedIds @return Feed[]
[ "Returns", "all", "the", "feeds", "from", "a", "given", "array", "containing", "their", "id", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php#L66-L77
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php
FeedRepository.filterUserAccessibleByIds
public function filterUserAccessibleByIds(\ACL $userACL, array $feedIds = []) { $qb = $this->createQueryBuilder('f'); // is public feed? $orx = $qb->expr()->orX( $qb->expr()->isNull('f.baseId'), $qb->expr()->eq('f.public', $qb->expr()->literal(true)) ); // is granted base? $grantedBases = array_keys($userACL->get_granted_base()); if ($grantedBases) { $orx->add($qb->expr()->in('f.baseId', $grantedBases)); } if ($feedIds) { $qb->where($qb->expr()->in('f.id', $feedIds), $orx); } $qb->orderBy('f.updatedOn', 'DESC'); return $qb->getQuery()->getResult(); }
php
public function filterUserAccessibleByIds(\ACL $userACL, array $feedIds = []) { $qb = $this->createQueryBuilder('f'); // is public feed? $orx = $qb->expr()->orX( $qb->expr()->isNull('f.baseId'), $qb->expr()->eq('f.public', $qb->expr()->literal(true)) ); // is granted base? $grantedBases = array_keys($userACL->get_granted_base()); if ($grantedBases) { $orx->add($qb->expr()->in('f.baseId', $grantedBases)); } if ($feedIds) { $qb->where($qb->expr()->in('f.id', $feedIds), $orx); } $qb->orderBy('f.updatedOn', 'DESC'); return $qb->getQuery()->getResult(); }
[ "public", "function", "filterUserAccessibleByIds", "(", "\\", "ACL", "$", "userACL", ",", "array", "$", "feedIds", "=", "[", "]", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'f'", ")", ";", "// is public feed?", "$", "orx", "...
Returns all the feeds from a given array containing their id. @param \ACL $userACL @param array $feedIds Ids to restrict feeds, all accessible otherwise @return Feed[]
[ "Returns", "all", "the", "feeds", "from", "a", "given", "array", "containing", "their", "id", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php#L87-L110
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Http/H264PseudoStreaming/H264Factory.php
H264Factory.createMode
public function createMode($throwException = false, $forceMode = false) { if (false === $this->enabled && true !== $forceMode) { return new NullMode(); } switch ($this->type) { case 'apache': case 'apache2': return new Apache($this->mapping); case 'nginx': return new Nginx($this->mapping); default: $this->logger->error('Invalid h264 pseudo streaming configuration.'); if ($throwException) { throw new InvalidArgumentException(sprintf('Invalid h264 pseudo streaming configuration width type "%s"', $this->type)); } return new NullMode(); } }
php
public function createMode($throwException = false, $forceMode = false) { if (false === $this->enabled && true !== $forceMode) { return new NullMode(); } switch ($this->type) { case 'apache': case 'apache2': return new Apache($this->mapping); case 'nginx': return new Nginx($this->mapping); default: $this->logger->error('Invalid h264 pseudo streaming configuration.'); if ($throwException) { throw new InvalidArgumentException(sprintf('Invalid h264 pseudo streaming configuration width type "%s"', $this->type)); } return new NullMode(); } }
[ "public", "function", "createMode", "(", "$", "throwException", "=", "false", ",", "$", "forceMode", "=", "false", ")", "{", "if", "(", "false", "===", "$", "this", "->", "enabled", "&&", "true", "!==", "$", "forceMode", ")", "{", "return", "new", "Nul...
Returns a new instance of H264Interface. @return H264Interface @throws InvalidArgumentException if mode type is unknown
[ "Returns", "a", "new", "instance", "of", "H264Interface", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/H264Factory.php#L48-L68
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php
MailInfoUserRegistered.getMessage
public function getMessage() { if (!$this->registeredUser) { throw new LogicException('You must set a user before calling getMessage'); } return $this->app->trans('admin::register: un utilisateur a fait une demande d\'inscription') . "\n\n" . sprintf('%s %s',$this->registeredUser->getFirstName(), $this->registeredUser->getLastName()) . "\n\n" . sprintf('%s %s',$this->registeredUser->getJob(), $this->registeredUser->getCompany()); }
php
public function getMessage() { if (!$this->registeredUser) { throw new LogicException('You must set a user before calling getMessage'); } return $this->app->trans('admin::register: un utilisateur a fait une demande d\'inscription') . "\n\n" . sprintf('%s %s',$this->registeredUser->getFirstName(), $this->registeredUser->getLastName()) . "\n\n" . sprintf('%s %s',$this->registeredUser->getJob(), $this->registeredUser->getCompany()); }
[ "public", "function", "getMessage", "(", ")", "{", "if", "(", "!", "$", "this", "->", "registeredUser", ")", "{", "throw", "new", "LogicException", "(", "'You must set a user before calling getMessage'", ")", ";", "}", "return", "$", "this", "->", "app", "->",...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php#L43-L52
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.delete
public function delete(User $user, $flush = true) { $this->cleanProperties($user); $this->cleanRights($user); $this->objectManager->persist($user); if ($flush) { $this->objectManager->flush(); $this->objectManager->clear(ApiLog::class); } }
php
public function delete(User $user, $flush = true) { $this->cleanProperties($user); $this->cleanRights($user); $this->objectManager->persist($user); if ($flush) { $this->objectManager->flush(); $this->objectManager->clear(ApiLog::class); } }
[ "public", "function", "delete", "(", "User", "$", "user", ",", "$", "flush", "=", "true", ")", "{", "$", "this", "->", "cleanProperties", "(", "$", "user", ")", ";", "$", "this", "->", "cleanRights", "(", "$", "user", ")", ";", "$", "this", "->", ...
Deletes an user. @param User $user @param bool $flush
[ "Deletes", "an", "user", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L50-L61
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.update
public function update(User $user, $flush = true) { $this->objectManager->persist($user); if ($flush) { $this->objectManager->flush(); } }
php
public function update(User $user, $flush = true) { $this->objectManager->persist($user); if ($flush) { $this->objectManager->flush(); } }
[ "public", "function", "update", "(", "User", "$", "user", ",", "$", "flush", "=", "true", ")", "{", "$", "this", "->", "objectManager", "->", "persist", "(", "$", "user", ")", ";", "if", "(", "$", "flush", ")", "{", "$", "this", "->", "objectManage...
Updates an user. @param User $user @param bool $flush
[ "Updates", "an", "user", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L69-L76
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.cleanSettings
private function cleanSettings(User $user) { foreach ($user->getNotificationSettings() as $userNotificationSetting) { $this->objectManager->remove($userNotificationSetting); } $user->getNotificationSettings()->clear(); foreach ($user->getSettings() as $userSetting) { $this->objectManager->remove($userSetting); } $user->getSettings()->clear(); }
php
private function cleanSettings(User $user) { foreach ($user->getNotificationSettings() as $userNotificationSetting) { $this->objectManager->remove($userNotificationSetting); } $user->getNotificationSettings()->clear(); foreach ($user->getSettings() as $userSetting) { $this->objectManager->remove($userSetting); } $user->getSettings()->clear(); }
[ "private", "function", "cleanSettings", "(", "User", "$", "user", ")", "{", "foreach", "(", "$", "user", "->", "getNotificationSettings", "(", ")", "as", "$", "userNotificationSetting", ")", "{", "$", "this", "->", "objectManager", "->", "remove", "(", "$", ...
Removes user settings. @param User $user
[ "Removes", "user", "settings", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L93-L106
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.cleanQueries
private function cleanQueries(User $user) { foreach ($user->getQueries() as $userQuery) { $this->objectManager->remove($userQuery); } $user->getQueries()->clear(); }
php
private function cleanQueries(User $user) { foreach ($user->getQueries() as $userQuery) { $this->objectManager->remove($userQuery); } $user->getQueries()->clear(); }
[ "private", "function", "cleanQueries", "(", "User", "$", "user", ")", "{", "foreach", "(", "$", "user", "->", "getQueries", "(", ")", "as", "$", "userQuery", ")", "{", "$", "this", "->", "objectManager", "->", "remove", "(", "$", "userQuery", ")", ";",...
Removes user queries. @param User $user
[ "Removes", "user", "queries", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L123-L130
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.cleanFtpCredentials
private function cleanFtpCredentials(User $user) { if (null !== $credential = $user->getFtpCredential()) { $this->objectManager->remove($credential); } }
php
private function cleanFtpCredentials(User $user) { if (null !== $credential = $user->getFtpCredential()) { $this->objectManager->remove($credential); } }
[ "private", "function", "cleanFtpCredentials", "(", "User", "$", "user", ")", "{", "if", "(", "null", "!==", "$", "credential", "=", "$", "user", "->", "getFtpCredential", "(", ")", ")", "{", "$", "this", "->", "objectManager", "->", "remove", "(", "$", ...
Removes user ftp credentials. @param User $user
[ "Removes", "user", "ftp", "credentials", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L137-L142
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.cleanFtpExports
private function cleanFtpExports(User $user) { $elements = $this->objectManager->getRepository('Phraseanet:FtpExport') ->findBy(['user' => $user]); foreach ($elements as $element) { $this->objectManager->remove($element); } }
php
private function cleanFtpExports(User $user) { $elements = $this->objectManager->getRepository('Phraseanet:FtpExport') ->findBy(['user' => $user]); foreach ($elements as $element) { $this->objectManager->remove($element); } }
[ "private", "function", "cleanFtpExports", "(", "User", "$", "user", ")", "{", "$", "elements", "=", "$", "this", "->", "objectManager", "->", "getRepository", "(", "'Phraseanet:FtpExport'", ")", "->", "findBy", "(", "[", "'user'", "=>", "$", "user", "]", "...
Removes user ftp export. @param User $user
[ "Removes", "user", "ftp", "export", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L149-L157
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.cleanOrders
private function cleanOrders(User $user) { $orders = $this->objectManager->getRepository('Phraseanet:Order') ->findBy(['user' => $user]); foreach ($orders as $order) { $this->objectManager->remove($order); } }
php
private function cleanOrders(User $user) { $orders = $this->objectManager->getRepository('Phraseanet:Order') ->findBy(['user' => $user]); foreach ($orders as $order) { $this->objectManager->remove($order); } }
[ "private", "function", "cleanOrders", "(", "User", "$", "user", ")", "{", "$", "orders", "=", "$", "this", "->", "objectManager", "->", "getRepository", "(", "'Phraseanet:Order'", ")", "->", "findBy", "(", "[", "'user'", "=>", "$", "user", "]", ")", ";",...
Removes user orders. @param User $user
[ "Removes", "user", "orders", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L164-L172
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.cleanUserSessions
private function cleanUserSessions(User $user) { $sessions = $this->objectManager->getRepository('Phraseanet:Session') ->findByUser(['user' => $user]); foreach ($sessions as $session) { $this->objectManager->remove($session); } }
php
private function cleanUserSessions(User $user) { $sessions = $this->objectManager->getRepository('Phraseanet:Session') ->findByUser(['user' => $user]); foreach ($sessions as $session) { $this->objectManager->remove($session); } }
[ "private", "function", "cleanUserSessions", "(", "User", "$", "user", ")", "{", "$", "sessions", "=", "$", "this", "->", "objectManager", "->", "getRepository", "(", "'Phraseanet:Session'", ")", "->", "findByUser", "(", "[", "'user'", "=>", "$", "user", "]",...
Removes user orders. @param User $user
[ "Removes", "user", "orders", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L179-L187
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.cleanAuthProvider
private function cleanAuthProvider(User $user) { $providers = $this->objectManager->getRepository('Phraseanet:UsrAuthProvider') ->findBy(['user' => $user]); foreach ($providers as $provider) { $this->objectManager->remove($provider); } }
php
private function cleanAuthProvider(User $user) { $providers = $this->objectManager->getRepository('Phraseanet:UsrAuthProvider') ->findBy(['user' => $user]); foreach ($providers as $provider) { $this->objectManager->remove($provider); } }
[ "private", "function", "cleanAuthProvider", "(", "User", "$", "user", ")", "{", "$", "providers", "=", "$", "this", "->", "objectManager", "->", "getRepository", "(", "'Phraseanet:UsrAuthProvider'", ")", "->", "findBy", "(", "[", "'user'", "=>", "$", "user", ...
Removes user providers. @param User $user
[ "Removes", "user", "providers", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L194-L202
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.cleanProperties
private function cleanProperties(User $user) { $sql = 'DELETE FROM `edit_presets` WHERE usr_id = :usr_id'; $stmt = $this->appboxConnection->prepare($sql); $stmt->execute([':usr_id' => $user->getId()]); $stmt->closeCursor(); $this->cleanSettings($user); $this->cleanTokens($user); $this->cleanQueries($user); $this->cleanFtpCredentials($user); $this->cleanOrders($user); $this->cleanFtpExports($user); $this->cleanAuthProvider($user); $this->cleanUserSessions($user); $this->cleanOauthApplication($user); }
php
private function cleanProperties(User $user) { $sql = 'DELETE FROM `edit_presets` WHERE usr_id = :usr_id'; $stmt = $this->appboxConnection->prepare($sql); $stmt->execute([':usr_id' => $user->getId()]); $stmt->closeCursor(); $this->cleanSettings($user); $this->cleanTokens($user); $this->cleanQueries($user); $this->cleanFtpCredentials($user); $this->cleanOrders($user); $this->cleanFtpExports($user); $this->cleanAuthProvider($user); $this->cleanUserSessions($user); $this->cleanOauthApplication($user); }
[ "private", "function", "cleanProperties", "(", "User", "$", "user", ")", "{", "$", "sql", "=", "'DELETE FROM `edit_presets` WHERE usr_id = :usr_id'", ";", "$", "stmt", "=", "$", "this", "->", "appboxConnection", "->", "prepare", "(", "$", "sql", ")", ";", "$",...
Removes all user's properties. @param User $user
[ "Removes", "all", "user", "s", "properties", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L209-L225
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manager/UserManager.php
UserManager.cleanRights
private function cleanRights(User $user) { foreach ([ 'DELETE FROM `basusr` WHERE usr_id = :usr_id', 'DELETE FROM `sbasusr` WHERE usr_id = :usr_id', ] as $sql) { $stmt = $this->appboxConnection->prepare($sql); $stmt->execute([':usr_id' => $user->getId()]); $stmt->closeCursor(); } }
php
private function cleanRights(User $user) { foreach ([ 'DELETE FROM `basusr` WHERE usr_id = :usr_id', 'DELETE FROM `sbasusr` WHERE usr_id = :usr_id', ] as $sql) { $stmt = $this->appboxConnection->prepare($sql); $stmt->execute([':usr_id' => $user->getId()]); $stmt->closeCursor(); } }
[ "private", "function", "cleanRights", "(", "User", "$", "user", ")", "{", "foreach", "(", "[", "'DELETE FROM `basusr` WHERE usr_id = :usr_id'", ",", "'DELETE FROM `sbasusr` WHERE usr_id = :usr_id'", ",", "]", "as", "$", "sql", ")", "{", "$", "stmt", "=", "$", "thi...
Removes all user's rights. @param User $user
[ "Removes", "all", "user", "s", "rights", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manager/UserManager.php#L232-L242
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/AccessRestriction.php
AccessRestriction.isDataboxAvailable
public function isDataboxAvailable(\databox $databox) { if (!$this->isRestricted()) { return true; } return in_array($databox->get_sbas_id(), $this->availableDataboxes, true); }
php
public function isDataboxAvailable(\databox $databox) { if (!$this->isRestricted()) { return true; } return in_array($databox->get_sbas_id(), $this->availableDataboxes, true); }
[ "public", "function", "isDataboxAvailable", "(", "\\", "databox", "$", "databox", ")", "{", "if", "(", "!", "$", "this", "->", "isRestricted", "(", ")", ")", "{", "return", "true", ";", "}", "return", "in_array", "(", "$", "databox", "->", "get_sbas_id",...
Returns true if a databox is available given a configuration. @param \databox $databox @return bool
[ "Returns", "true", "if", "a", "databox", "is", "available", "given", "a", "configuration", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/AccessRestriction.php#L79-L86
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/AccessRestriction.php
AccessRestriction.isCollectionAvailable
public function isCollectionAvailable(\collection $collection) { if (!$this->isRestricted()) { return true; } $availableCollections = isset($this->availableCollections[$collection->get_sbas_id()]) ? $this->availableCollections[$collection->get_sbas_id()] : []; return in_array($collection->get_base_id(), $availableCollections, true); }
php
public function isCollectionAvailable(\collection $collection) { if (!$this->isRestricted()) { return true; } $availableCollections = isset($this->availableCollections[$collection->get_sbas_id()]) ? $this->availableCollections[$collection->get_sbas_id()] : []; return in_array($collection->get_base_id(), $availableCollections, true); }
[ "public", "function", "isCollectionAvailable", "(", "\\", "collection", "$", "collection", ")", "{", "if", "(", "!", "$", "this", "->", "isRestricted", "(", ")", ")", "{", "return", "true", ";", "}", "$", "availableCollections", "=", "isset", "(", "$", "...
Returns true if a collection is available given a configuration. @param \collection $collection @return bool
[ "Returns", "true", "if", "a", "collection", "is", "available", "given", "a", "configuration", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/AccessRestriction.php#L114-L124
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Cache/RedisCache.php
RedisCache.doSave
protected function doSave($id, $data, $lifeTime = 0) { if (0 === $lifeTime) { return $this->_redis->set($id, $data); } else { return $this->_redis->setex($id, $lifeTime, $data); } }
php
protected function doSave($id, $data, $lifeTime = 0) { if (0 === $lifeTime) { return $this->_redis->set($id, $data); } else { return $this->_redis->setex($id, $lifeTime, $data); } }
[ "protected", "function", "doSave", "(", "$", "id", ",", "$", "data", ",", "$", "lifeTime", "=", "0", ")", "{", "if", "(", "0", "===", "$", "lifeTime", ")", "{", "return", "$", "this", "->", "_redis", "->", "set", "(", "$", "id", ",", "$", "data...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Cache/RedisCache.php#L62-L69
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Cache/RedisCache.php
RedisCache.doGetStats
protected function doGetStats() { $stats = $this->_redis->info(); return [ Cache::STATS_HITS => false, Cache::STATS_MISSES => false, Cache::STATS_UPTIME => $stats['uptime_in_seconds'], Cache::STATS_MEMORY_USAGE => $stats['used_memory'], Cache::STATS_MEMORY_AVAILIABLE => false, ]; }
php
protected function doGetStats() { $stats = $this->_redis->info(); return [ Cache::STATS_HITS => false, Cache::STATS_MISSES => false, Cache::STATS_UPTIME => $stats['uptime_in_seconds'], Cache::STATS_MEMORY_USAGE => $stats['used_memory'], Cache::STATS_MEMORY_AVAILIABLE => false, ]; }
[ "protected", "function", "doGetStats", "(", ")", "{", "$", "stats", "=", "$", "this", "->", "_redis", "->", "info", "(", ")", ";", "return", "[", "Cache", "::", "STATS_HITS", "=>", "false", ",", "Cache", "::", "STATS_MISSES", "=>", "false", ",", "Cache...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Cache/RedisCache.php#L90-L101
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/Result.php
Result.createResponse
public function createResponse() { $response = $this->format(); $response->headers->set('content-type', $this->getContentType()); $response->setStatusCode($this->getStatusCode()); $response->setCharset('UTF-8'); return $response; }
php
public function createResponse() { $response = $this->format(); $response->headers->set('content-type', $this->getContentType()); $response->setStatusCode($this->getStatusCode()); $response->setCharset('UTF-8'); return $response; }
[ "public", "function", "createResponse", "(", ")", "{", "$", "response", "=", "$", "this", "->", "format", "(", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'content-type'", ",", "$", "this", "->", "getContentType", "(", ")", ")", ";",...
Creates a Symfony Response @return Response
[ "Creates", "a", "Symfony", "Response" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/Result.php#L91-L99
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/Result.php
Result.createError
public static function createError(Request $request, $code, $message) { $errorDetails = $message; switch ($code) { case 400: $errorType = self::ERROR_BAD_REQUEST; $errorMessage = 'Parameter is invalid or missing'; break; case 401: $errorType = self::ERROR_UNAUTHORIZED; $errorMessage = 'The OAuth token was provided but was invalid.'; break; case 403: $errorType = self::ERROR_FORBIDDEN; $errorMessage = 'Access to the requested resource is forbidden'; break; case 404: $errorType = self::ERROR_NOTFOUND; $errorMessage = 'Requested resource is not found'; break; case 405: $errorType = self::ERROR_METHODNOTALLOWED; $errorMessage = 'Attempting to use POST with a GET-only endpoint, or vice-versa'; break; case 406: $errorType = self::ERROR_UNACCEPTABLE; $errorMessage = 'Request content type is not acceptable'; break; case 422: $errorType = self::ERROR_UNPROCESSABLEENTITY; $errorMessage = 'Request content is unprocessable'; break; case 500: $errorType = self::ERROR_INTERNALSERVERERROR; $errorMessage = 'Internal Server Error'; break; case 503: $errorType = self::ERROR_MAINTENANCE; $errorMessage = 'Server is offline for maintenance, try again soon.'; break; default: throw new \InvalidArgumentException('Unable to generate a response.'); } return new static($request, null, $code, $errorType, $errorMessage, $errorDetails); }
php
public static function createError(Request $request, $code, $message) { $errorDetails = $message; switch ($code) { case 400: $errorType = self::ERROR_BAD_REQUEST; $errorMessage = 'Parameter is invalid or missing'; break; case 401: $errorType = self::ERROR_UNAUTHORIZED; $errorMessage = 'The OAuth token was provided but was invalid.'; break; case 403: $errorType = self::ERROR_FORBIDDEN; $errorMessage = 'Access to the requested resource is forbidden'; break; case 404: $errorType = self::ERROR_NOTFOUND; $errorMessage = 'Requested resource is not found'; break; case 405: $errorType = self::ERROR_METHODNOTALLOWED; $errorMessage = 'Attempting to use POST with a GET-only endpoint, or vice-versa'; break; case 406: $errorType = self::ERROR_UNACCEPTABLE; $errorMessage = 'Request content type is not acceptable'; break; case 422: $errorType = self::ERROR_UNPROCESSABLEENTITY; $errorMessage = 'Request content is unprocessable'; break; case 500: $errorType = self::ERROR_INTERNALSERVERERROR; $errorMessage = 'Internal Server Error'; break; case 503: $errorType = self::ERROR_MAINTENANCE; $errorMessage = 'Server is offline for maintenance, try again soon.'; break; default: throw new \InvalidArgumentException('Unable to generate a response.'); } return new static($request, null, $code, $errorType, $errorMessage, $errorDetails); }
[ "public", "static", "function", "createError", "(", "Request", "$", "request", ",", "$", "code", ",", "$", "message", ")", "{", "$", "errorDetails", "=", "$", "message", ";", "switch", "(", "$", "code", ")", "{", "case", "400", ":", "$", "errorType", ...
@param Request $request @param $code @param $message @return Result @throws \InvalidArgumentException
[ "@param", "Request", "$request", "@param", "$code", "@param", "$message" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/Result.php#L121-L167
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/Result.php
Result.setData
private function setData(array $data = null) { if (null === $data || count($data) === 0) { $data = new \stdClass(); } $this->data = $data; return $this; }
php
private function setData(array $data = null) { if (null === $data || count($data) === 0) { $data = new \stdClass(); } $this->data = $data; return $this; }
[ "private", "function", "setData", "(", "array", "$", "data", "=", "null", ")", "{", "if", "(", "null", "===", "$", "data", "||", "count", "(", "$", "data", ")", "===", "0", ")", "{", "$", "data", "=", "new", "\\", "stdClass", "(", ")", ";", "}"...
Sets data to the response. If no datas provided, a stdClass if set, so the serialized datas will be objects @param array $datas @return Result
[ "Sets", "data", "to", "the", "response", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/Result.php#L200-L209
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/Result.php
Result.format
private function format() { $request_uri = sprintf('%s %s', $this->request->getMethod(), $this->request->getBasePath().$this->request->getPathInfo()); $ret = [ 'meta' => [ 'api_version' => $this->getVersion(), 'request' => $request_uri, 'response_time' => $this->responseTime, 'http_code' => $this->code, 'error_type' => $this->errorType, 'error_message' => $this->errorMessage, 'error_details' => $this->errorDetails, 'charset' => 'UTF-8', ], 'response' => $this->data, ]; switch ($this->responseType) { case self::FORMAT_JSON: default: return new JsonResponse($ret); case self::FORMAT_YAML: if ($ret['response'] instanceof \stdClass) { $ret['response'] = []; } $dumper = new Dumper(); return new Response($dumper->dump($ret, 8)); case self::FORMAT_JSONP: $response = new JsonResponse($ret); $response->setCallback(trim($this->request->get('callback'))); return $response; break; } }
php
private function format() { $request_uri = sprintf('%s %s', $this->request->getMethod(), $this->request->getBasePath().$this->request->getPathInfo()); $ret = [ 'meta' => [ 'api_version' => $this->getVersion(), 'request' => $request_uri, 'response_time' => $this->responseTime, 'http_code' => $this->code, 'error_type' => $this->errorType, 'error_message' => $this->errorMessage, 'error_details' => $this->errorDetails, 'charset' => 'UTF-8', ], 'response' => $this->data, ]; switch ($this->responseType) { case self::FORMAT_JSON: default: return new JsonResponse($ret); case self::FORMAT_YAML: if ($ret['response'] instanceof \stdClass) { $ret['response'] = []; } $dumper = new Dumper(); return new Response($dumper->dump($ret, 8)); case self::FORMAT_JSONP: $response = new JsonResponse($ret); $response->setCallback(trim($this->request->get('callback'))); return $response; break; } }
[ "private", "function", "format", "(", ")", "{", "$", "request_uri", "=", "sprintf", "(", "'%s %s'", ",", "$", "this", "->", "request", "->", "getMethod", "(", ")", ",", "$", "this", "->", "request", "->", "getBasePath", "(", ")", ".", "$", "this", "-...
Formats the data and return serialized string @return Response
[ "Formats", "the", "data", "and", "return", "serialized", "string" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/Result.php#L216-L253
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php
RegistrationManipulator.createRegistration
public function createRegistration(User $user, \collection $collection) { $registration = new Registration(); $registration->setUser($user); $registration->setCollection($collection); $this->em->persist($registration); $this->em->flush(); return $registration; }
php
public function createRegistration(User $user, \collection $collection) { $registration = new Registration(); $registration->setUser($user); $registration->setCollection($collection); $this->em->persist($registration); $this->em->flush(); return $registration; }
[ "public", "function", "createRegistration", "(", "User", "$", "user", ",", "\\", "collection", "$", "collection", ")", "{", "$", "registration", "=", "new", "Registration", "(", ")", ";", "$", "registration", "->", "setUser", "(", "$", "user", ")", ";", ...
Creates a new registration. @param User $user @param \collection $collection @return Registration
[ "Creates", "a", "new", "registration", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php#L46-L55
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php
RegistrationManipulator.rejectRegistration
public function rejectRegistration(Registration $registration) { $registration->setPending(false); $registration->setRejected(true); $this->em->persist($registration); $this->em->flush(); }
php
public function rejectRegistration(Registration $registration) { $registration->setPending(false); $registration->setRejected(true); $this->em->persist($registration); $this->em->flush(); }
[ "public", "function", "rejectRegistration", "(", "Registration", "$", "registration", ")", "{", "$", "registration", "->", "setPending", "(", "false", ")", ";", "$", "registration", "->", "setRejected", "(", "true", ")", ";", "$", "this", "->", "em", "->", ...
Rejects a registration. @param Registration $registration
[ "Rejects", "a", "registration", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php#L62-L68
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php
RegistrationManipulator.acceptRegistration
public function acceptRegistration(Registration $registration, $grantHd = false, $grantWatermark = false) { $user = $registration->getUser(); $collection = $registration->getCollection($this->app); $this->aclProvider->get($user)->give_access_to_sbas([$collection->get_sbas_id()]); $this->aclProvider->get($user)->give_access_to_base([$collection->get_base_id()]); $this->aclProvider->get($user)->update_rights_to_base( $collection->get_base_id(), [ \ACL::CANPUTINALBUM => true, \ACL::CANDWNLDHD => (bool)$grantHd, \ACL::NOWATERMARK => (bool)$grantWatermark, \ACL::CANDWNLDPREVIEW => true, \ACL::ACTIF => true ] ); $this->em->remove($registration); $this->em->flush(); }
php
public function acceptRegistration(Registration $registration, $grantHd = false, $grantWatermark = false) { $user = $registration->getUser(); $collection = $registration->getCollection($this->app); $this->aclProvider->get($user)->give_access_to_sbas([$collection->get_sbas_id()]); $this->aclProvider->get($user)->give_access_to_base([$collection->get_base_id()]); $this->aclProvider->get($user)->update_rights_to_base( $collection->get_base_id(), [ \ACL::CANPUTINALBUM => true, \ACL::CANDWNLDHD => (bool)$grantHd, \ACL::NOWATERMARK => (bool)$grantWatermark, \ACL::CANDWNLDPREVIEW => true, \ACL::ACTIF => true ] ); $this->em->remove($registration); $this->em->flush(); }
[ "public", "function", "acceptRegistration", "(", "Registration", "$", "registration", ",", "$", "grantHd", "=", "false", ",", "$", "grantWatermark", "=", "false", ")", "{", "$", "user", "=", "$", "registration", "->", "getUser", "(", ")", ";", "$", "collec...
Accepts a registration. @param Registration $registration @param bool $grantHd @param bool $grantWatermark
[ "Accepts", "a", "registration", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php#L77-L96
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php
RegistrationManipulator.deleteUserRegistrations
public function deleteUserRegistrations(User $user, array $collections) { $qb = $this->repository->createQueryBuilder('d'); $qb->delete('Phraseanet:Registration', 'd'); $qb->where($qb->expr()->eq('d.user', ':user')); $qb->setParameter(':user', $user->getId()); if (count($collections) > 0) { $qb->andWhere('d.baseId IN (:bases)'); $qb->setParameter(':bases', array_map(function ($collection) { return $collection->get_base_id(); }, $collections)); } return $qb->getQuery()->execute(); }
php
public function deleteUserRegistrations(User $user, array $collections) { $qb = $this->repository->createQueryBuilder('d'); $qb->delete('Phraseanet:Registration', 'd'); $qb->where($qb->expr()->eq('d.user', ':user')); $qb->setParameter(':user', $user->getId()); if (count($collections) > 0) { $qb->andWhere('d.baseId IN (:bases)'); $qb->setParameter(':bases', array_map(function ($collection) { return $collection->get_base_id(); }, $collections)); } return $qb->getQuery()->execute(); }
[ "public", "function", "deleteUserRegistrations", "(", "User", "$", "user", ",", "array", "$", "collections", ")", "{", "$", "qb", "=", "$", "this", "->", "repository", "->", "createQueryBuilder", "(", "'d'", ")", ";", "$", "qb", "->", "delete", "(", "'Ph...
Deletes registration for given user. @param User $user @param \collection[] $collections @return mixed
[ "Deletes", "registration", "for", "given", "user", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php#L106-L121
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php
RegistrationManipulator.deleteOldRegistrations
public function deleteOldRegistrations() { $qb = $this->repository->createQueryBuilder('d'); $qb->delete('Phraseanet:Registration', 'd'); $qb->where($qb->expr()->lt('d.created', ':date')); $qb->setParameter(':date', new \DateTime('-1 month')); $qb->getQuery()->execute(); }
php
public function deleteOldRegistrations() { $qb = $this->repository->createQueryBuilder('d'); $qb->delete('Phraseanet:Registration', 'd'); $qb->where($qb->expr()->lt('d.created', ':date')); $qb->setParameter(':date', new \DateTime('-1 month')); $qb->getQuery()->execute(); }
[ "public", "function", "deleteOldRegistrations", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "repository", "->", "createQueryBuilder", "(", "'d'", ")", ";", "$", "qb", "->", "delete", "(", "'Phraseanet:Registration'", ",", "'d'", ")", ";", "$", "qb", ...
Deletes old registrations.
[ "Deletes", "old", "registrations", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php#L126-L133
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php
RegistrationManipulator.deleteRegistrationsOnCollection
public function deleteRegistrationsOnCollection(\collection $collection) { $qb = $this->repository->createQueryBuilder('d'); $qb->delete('Phraseanet:Registration', 'd'); $qb->where($qb->expr()->eq('d.baseId', ':base')); $qb->setParameter(':base', $collection->get_base_id()); $qb->getQuery()->execute(); }
php
public function deleteRegistrationsOnCollection(\collection $collection) { $qb = $this->repository->createQueryBuilder('d'); $qb->delete('Phraseanet:Registration', 'd'); $qb->where($qb->expr()->eq('d.baseId', ':base')); $qb->setParameter(':base', $collection->get_base_id()); $qb->getQuery()->execute(); }
[ "public", "function", "deleteRegistrationsOnCollection", "(", "\\", "collection", "$", "collection", ")", "{", "$", "qb", "=", "$", "this", "->", "repository", "->", "createQueryBuilder", "(", "'d'", ")", ";", "$", "qb", "->", "delete", "(", "'Phraseanet:Regis...
Deletes registrations on given collection. @param $baseId
[ "Deletes", "registrations", "on", "given", "collection", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/RegistrationManipulator.php#L140-L147
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Utilities/RedisSessionHandler.php
RedisSessionHandler.write
public function write($sessionId, $data) { return $this->redis->setex($this->prefix.$sessionId, $this->lifetime, $data); }
php
public function write($sessionId, $data) { return $this->redis->setex($this->prefix.$sessionId, $this->lifetime, $data); }
[ "public", "function", "write", "(", "$", "sessionId", ",", "$", "data", ")", "{", "return", "$", "this", "->", "redis", "->", "setex", "(", "$", "this", "->", "prefix", ".", "$", "sessionId", ",", "$", "this", "->", "lifetime", ",", "$", "data", ")...
{@inheritDoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Utilities/RedisSessionHandler.php#L73-L76
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php
MailInfoValidationDone.getSubject
public function getSubject() { if (!$this->user) { throw new LogicException('You must set an user before calling getSubject'); } if (!$this->title) { throw new LogicException('You must set an title before calling getSubject'); } return $this->app->trans('push::mail:: Rapport de validation de %user% pour %title%', [ '%user%' => $this->user->getDisplayName(), '%title%' => $this->title, ]); }
php
public function getSubject() { if (!$this->user) { throw new LogicException('You must set an user before calling getSubject'); } if (!$this->title) { throw new LogicException('You must set an title before calling getSubject'); } return $this->app->trans('push::mail:: Rapport de validation de %user% pour %title%', [ '%user%' => $this->user->getDisplayName(), '%title%' => $this->title, ]); }
[ "public", "function", "getSubject", "(", ")", "{", "if", "(", "!", "$", "this", "->", "user", ")", "{", "throw", "new", "LogicException", "(", "'You must set an user before calling getSubject'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "title", ")...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php#L47-L60
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php
MailInfoValidationDone.getMessage
public function getMessage() { if (!$this->user) { throw new LogicException('You must set an user before calling getMessage'); } return $this->app->trans('%user% has just sent its validation report, you can now see it', [ '%user%' => $this->user->getDisplayName(), ]); }
php
public function getMessage() { if (!$this->user) { throw new LogicException('You must set an user before calling getMessage'); } return $this->app->trans('%user% has just sent its validation report, you can now see it', [ '%user%' => $this->user->getDisplayName(), ]); }
[ "public", "function", "getMessage", "(", ")", "{", "if", "(", "!", "$", "this", "->", "user", ")", "{", "throw", "new", "LogicException", "(", "'You must set an user before calling getMessage'", ")", ";", "}", "return", "$", "this", "->", "app", "->", "trans...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php#L65-L74
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php
FtpPullEditor.getFormProperties
protected function getFormProperties() { return [ 'proxy' => static::FORM_TYPE_STRING, 'proxyport' => static::FORM_TYPE_STRING, 'passive' => static::FORM_TYPE_BOOLEAN, 'ssl' => static::FORM_TYPE_BOOLEAN, 'password' => static::FORM_TYPE_STRING, 'user' => static::FORM_TYPE_STRING, 'ftppath' => static::FORM_TYPE_STRING, 'localpath' => static::FORM_TYPE_STRING, 'port' => static::FORM_TYPE_INTEGER, 'host' => static::FORM_TYPE_STRING, ]; }
php
protected function getFormProperties() { return [ 'proxy' => static::FORM_TYPE_STRING, 'proxyport' => static::FORM_TYPE_STRING, 'passive' => static::FORM_TYPE_BOOLEAN, 'ssl' => static::FORM_TYPE_BOOLEAN, 'password' => static::FORM_TYPE_STRING, 'user' => static::FORM_TYPE_STRING, 'ftppath' => static::FORM_TYPE_STRING, 'localpath' => static::FORM_TYPE_STRING, 'port' => static::FORM_TYPE_INTEGER, 'host' => static::FORM_TYPE_STRING, ]; }
[ "protected", "function", "getFormProperties", "(", ")", "{", "return", "[", "'proxy'", "=>", "static", "::", "FORM_TYPE_STRING", ",", "'proxyport'", "=>", "static", "::", "FORM_TYPE_STRING", ",", "'passive'", "=>", "static", "::", "FORM_TYPE_BOOLEAN", ",", "'ssl'"...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php#L59-L73
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php
LinkGeneratorCollection.generate
public function generate(FeedInterface $feed, User $user, $format, $page = null, $renew = false) { if (null === $generator = $this->findGenerator($feed)) { throw new InvalidArgumentException(sprintf('Unable to find a valid generator for %s', get_class($feed))); } return $generator->generate($feed, $user, $format, $page); }
php
public function generate(FeedInterface $feed, User $user, $format, $page = null, $renew = false) { if (null === $generator = $this->findGenerator($feed)) { throw new InvalidArgumentException(sprintf('Unable to find a valid generator for %s', get_class($feed))); } return $generator->generate($feed, $user, $format, $page); }
[ "public", "function", "generate", "(", "FeedInterface", "$", "feed", ",", "User", "$", "user", ",", "$", "format", ",", "$", "page", "=", "null", ",", "$", "renew", "=", "false", ")", "{", "if", "(", "null", "===", "$", "generator", "=", "$", "this...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php#L36-L43
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php
LinkGeneratorCollection.generatePublic
public function generatePublic(FeedInterface $feed, $format, $page = null) { if (null === $generator = $this->findGenerator($feed)) { throw new InvalidArgumentException(sprintf('Unable to find a valid generator for %s', get_class($feed))); } return $generator->generatePublic($feed, $format, $page); }
php
public function generatePublic(FeedInterface $feed, $format, $page = null) { if (null === $generator = $this->findGenerator($feed)) { throw new InvalidArgumentException(sprintf('Unable to find a valid generator for %s', get_class($feed))); } return $generator->generatePublic($feed, $format, $page); }
[ "public", "function", "generatePublic", "(", "FeedInterface", "$", "feed", ",", "$", "format", ",", "$", "page", "=", "null", ")", "{", "if", "(", "null", "===", "$", "generator", "=", "$", "this", "->", "findGenerator", "(", "$", "feed", ")", ")", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php#L48-L55
alchemy-fr/Phraseanet
lib/classes/media/subdef.php
media_subdef.remove_file
public function remove_file() { if ($this->is_physically_present() && is_writable($this->getRealPath())) { unlink($this->getRealPath()); $this->delete_data_from_cache(); $permalink = $this->get_permalink(); if ($permalink instanceof media_Permalink_Adapter) { $permalink->delete_data_from_cache(); } $this->markPhysicallyUnavailable(); } return $this; }
php
public function remove_file() { if ($this->is_physically_present() && is_writable($this->getRealPath())) { unlink($this->getRealPath()); $this->delete_data_from_cache(); $permalink = $this->get_permalink(); if ($permalink instanceof media_Permalink_Adapter) { $permalink->delete_data_from_cache(); } $this->markPhysicallyUnavailable(); } return $this; }
[ "public", "function", "remove_file", "(", ")", "{", "if", "(", "$", "this", "->", "is_physically_present", "(", ")", "&&", "is_writable", "(", "$", "this", "->", "getRealPath", "(", ")", ")", ")", "{", "unlink", "(", "$", "this", "->", "getRealPath", "...
Removes the file associated to a subdef @return \media_subdef
[ "Removes", "the", "file", "associated", "to", "a", "subdef" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/media/subdef.php#L251-L268
alchemy-fr/Phraseanet
lib/classes/media/subdef.php
media_subdef.delete
public function delete() { $this->remove_file(); $connection = $this->getDataboxConnection(); $connection->executeUpdate( 'DELETE FROM permalinks WHERE subdef_id = :subdef_id', ['subdef_id' => $this->subdef_id] ); self::getMediaSubdefRepository($this->app, $this->record->getDataboxId())->delete($this); $this->delete_data_from_cache(); $this->record->delete_data_from_cache(record_adapter::CACHE_SUBDEFS); }
php
public function delete() { $this->remove_file(); $connection = $this->getDataboxConnection(); $connection->executeUpdate( 'DELETE FROM permalinks WHERE subdef_id = :subdef_id', ['subdef_id' => $this->subdef_id] ); self::getMediaSubdefRepository($this->app, $this->record->getDataboxId())->delete($this); $this->delete_data_from_cache(); $this->record->delete_data_from_cache(record_adapter::CACHE_SUBDEFS); }
[ "public", "function", "delete", "(", ")", "{", "$", "this", "->", "remove_file", "(", ")", ";", "$", "connection", "=", "$", "this", "->", "getDataboxConnection", "(", ")", ";", "$", "connection", "->", "executeUpdate", "(", "'DELETE FROM permalinks WHERE subd...
delete this subdef @throws \Doctrine\DBAL\DBALException
[ "delete", "this", "subdef" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/media/subdef.php#L275-L289
alchemy-fr/Phraseanet
lib/classes/media/subdef.php
media_subdef.markPhysicallyUnavailable
protected function markPhysicallyUnavailable() { $this->is_physically_present = false; $this->mime = 'image/png'; $this->width = 256; $this->height = 256; $this->file = $this->getSubstituteFilename(); $this->etag = null; $this->path = $this->app['root.path'] . '/www/assets/common/images/icons/substitution/'; $this->url = Url::factory('/assets/common/images/icons/substitution/' . $this->file); if (!file_exists($this->getRealPath())) { $this->path = $this->app['root.path'] . '/www/assets/common/images/icons/'; $this->file = 'substitution.png'; $this->url = Url::factory('/assets/common/images/icons/' . $this->file); } }
php
protected function markPhysicallyUnavailable() { $this->is_physically_present = false; $this->mime = 'image/png'; $this->width = 256; $this->height = 256; $this->file = $this->getSubstituteFilename(); $this->etag = null; $this->path = $this->app['root.path'] . '/www/assets/common/images/icons/substitution/'; $this->url = Url::factory('/assets/common/images/icons/substitution/' . $this->file); if (!file_exists($this->getRealPath())) { $this->path = $this->app['root.path'] . '/www/assets/common/images/icons/'; $this->file = 'substitution.png'; $this->url = Url::factory('/assets/common/images/icons/' . $this->file); } }
[ "protected", "function", "markPhysicallyUnavailable", "(", ")", "{", "$", "this", "->", "is_physically_present", "=", "false", ";", "$", "this", "->", "mime", "=", "'image/png'", ";", "$", "this", "->", "width", "=", "256", ";", "$", "this", "->", "height"...
Find a substitution file for a subdef @return void
[ "Find", "a", "substitution", "file", "for", "a", "subdef" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/media/subdef.php#L307-L325
alchemy-fr/Phraseanet
lib/classes/media/subdef.php
media_subdef.getDataboxSubdef
public function getDataboxSubdef() { return $this->record ->getDatabox() ->get_subdef_structure() ->get_subdef($this->record->getType(), $this->get_name()); }
php
public function getDataboxSubdef() { return $this->record ->getDatabox() ->get_subdef_structure() ->get_subdef($this->record->getType(), $this->get_name()); }
[ "public", "function", "getDataboxSubdef", "(", ")", "{", "return", "$", "this", "->", "record", "->", "getDatabox", "(", ")", "->", "get_subdef_structure", "(", ")", "->", "get_subdef", "(", "$", "this", "->", "record", "->", "getType", "(", ")", ",", "$...
Return the databox subdef corresponding to the subdef @return \databox_subdef
[ "Return", "the", "databox", "subdef", "corresponding", "to", "the", "subdef" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/media/subdef.php#L524-L530
alchemy-fr/Phraseanet
lib/classes/media/subdef.php
media_subdef.rotate
public function rotate($angle, Alchemyst $alchemyst, MediaVorus $mediavorus) { if (!$this->is_physically_present()) { throw new \Alchemy\Phrasea\Exception\RuntimeException('You can not rotate a substitution'); } $specs = new \MediaAlchemyst\Specification\Image(); $specs->setRotationAngle($angle); try { $alchemyst->turnInto($this->getRealPath(), $this->getRealPath(), $specs); } catch (\MediaAlchemyst\Exception\ExceptionInterface $e) { return $this; } $media = $mediavorus->guess($this->getRealPath()); $this->width = $media->getWidth(); $this->height = $media->getHeight(); return $this->save(); }
php
public function rotate($angle, Alchemyst $alchemyst, MediaVorus $mediavorus) { if (!$this->is_physically_present()) { throw new \Alchemy\Phrasea\Exception\RuntimeException('You can not rotate a substitution'); } $specs = new \MediaAlchemyst\Specification\Image(); $specs->setRotationAngle($angle); try { $alchemyst->turnInto($this->getRealPath(), $this->getRealPath(), $specs); } catch (\MediaAlchemyst\Exception\ExceptionInterface $e) { return $this; } $media = $mediavorus->guess($this->getRealPath()); $this->width = $media->getWidth(); $this->height = $media->getHeight(); return $this->save(); }
[ "public", "function", "rotate", "(", "$", "angle", ",", "Alchemyst", "$", "alchemyst", ",", "MediaVorus", "$", "mediavorus", ")", "{", "if", "(", "!", "$", "this", "->", "is_physically_present", "(", ")", ")", "{", "throw", "new", "\\", "Alchemy", "\\", ...
@param int $angle @param Alchemyst $alchemyst @param MediaVorus $mediavorus @return media_subdef
[ "@param", "int", "$angle", "@param", "Alchemyst", "$alchemyst", "@param", "MediaVorus", "$mediavorus" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/media/subdef.php#L556-L577
alchemy-fr/Phraseanet
lib/classes/media/subdef.php
media_subdef.readTechnicalDatas
public function readTechnicalDatas(MediaVorus $mediavorus) { if (!$this->is_physically_present()) { return []; } $media = $mediavorus->guess($this->getRealPath()); $datas = []; $techDatas = self::getTechnicalFieldsList(); foreach ($techDatas as $tc_name => $techData) { if (array_key_exists('method', $techData)) { if (method_exists($media, $techData['method'])) { $result = call_user_func([$media, $techData['method']]); if (null !== $result) { $datas[$tc_name] = $result; } } } } $datas[self::TC_DATA_MIMETYPE] = $media->getFile()->getMimeType(); $datas[self::TC_DATA_FILESIZE] = $media->getFile()->getSize(); unset($media); return $datas; }
php
public function readTechnicalDatas(MediaVorus $mediavorus) { if (!$this->is_physically_present()) { return []; } $media = $mediavorus->guess($this->getRealPath()); $datas = []; $techDatas = self::getTechnicalFieldsList(); foreach ($techDatas as $tc_name => $techData) { if (array_key_exists('method', $techData)) { if (method_exists($media, $techData['method'])) { $result = call_user_func([$media, $techData['method']]); if (null !== $result) { $datas[$tc_name] = $result; } } } } $datas[self::TC_DATA_MIMETYPE] = $media->getFile()->getMimeType(); $datas[self::TC_DATA_FILESIZE] = $media->getFile()->getSize(); unset($media); return $datas; }
[ "public", "function", "readTechnicalDatas", "(", "MediaVorus", "$", "mediavorus", ")", "{", "if", "(", "!", "$", "this", "->", "is_physically_present", "(", ")", ")", "{", "return", "[", "]", ";", "}", "$", "media", "=", "$", "mediavorus", "->", "guess",...
Read the technical datas of the file. Returns an empty array for non physical present files @return array An array of technical datas Key/values
[ "Read", "the", "technical", "datas", "of", "the", "file", ".", "Returns", "an", "empty", "array", "for", "non", "physical", "present", "files" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/media/subdef.php#L585-L615
alchemy-fr/Phraseanet
lib/classes/media/subdef.php
media_subdef.getTechnicalFieldsList
public static function getTechnicalFieldsList() { if (empty(self::$technicalFieldsList)) { self::$technicalFieldsList = [ self::TC_DATA_WIDTH => ['method' => 'getWidth', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_HEIGHT => ['method' => 'getHeight', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_FOCALLENGTH => ['method' => 'getFocalLength', 'type' => 'float', 'analyzable' => false], self::TC_DATA_CHANNELS => ['method' => 'getChannels', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_COLORDEPTH => ['method' => 'getColorDepth', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_CAMERAMODEL => ['method' => 'getCameraModel', 'type' => 'string', 'analyzable' => false], self::TC_DATA_FLASHFIRED => ['method' => 'getFlashFired', 'type' => 'boolean', 'analyzable' => false], self::TC_DATA_APERTURE => ['method' => 'getAperture', 'type' => 'float', 'analyzable' => false], self::TC_DATA_SHUTTERSPEED => ['method' => 'getShutterSpeed', 'type' => 'float', 'analyzable' => false], self::TC_DATA_HYPERFOCALDISTANCE => ['method' => 'getHyperfocalDistance', 'type' => 'float', 'analyzable' => false], self::TC_DATA_ISO => ['method' => 'getISO', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_LIGHTVALUE => ['method' => 'getLightValue', 'type' => 'float', 'analyzable' => false], self::TC_DATA_COLORSPACE => ['method' => 'getColorSpace', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_DURATION => ['method' => 'getDuration', 'type' => 'float', 'analyzable' => false], self::TC_DATA_FRAMERATE => ['method' => 'getFrameRate', 'type' => 'float', 'analyzable' => false], self::TC_DATA_AUDIOSAMPLERATE => ['method' => 'getAudioSampleRate', 'type' => 'float', 'analyzable' => false], self::TC_DATA_VIDEOCODEC => ['method' => 'getVideoCodec', 'type' => 'string', 'analyzable' => false], self::TC_DATA_AUDIOCODEC => ['method' => 'getAudioCodec', 'type' => 'string', 'analyzable' => false], self::TC_DATA_ORIENTATION => ['method' => 'getOrientation', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_LONGITUDE => ['method' => 'getLongitude', 'type' => 'float', 'analyzable' => false], self::TC_DATA_LONGITUDE_REF => ['method' => 'getLongitudeRef'], self::TC_DATA_LATITUDE => ['method' => 'getLatitude', 'type' => 'float', 'analyzable' => false], self::TC_DATA_LATITUDE_REF => ['method' => 'getLatitudeRef'], self::TC_DATA_MIMETYPE => ['type' => 'string', 'analyzable' => false], self::TC_DATA_FILESIZE => ['type' => 'long', 'analyzable' => false], ]; } return self::$technicalFieldsList; }
php
public static function getTechnicalFieldsList() { if (empty(self::$technicalFieldsList)) { self::$technicalFieldsList = [ self::TC_DATA_WIDTH => ['method' => 'getWidth', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_HEIGHT => ['method' => 'getHeight', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_FOCALLENGTH => ['method' => 'getFocalLength', 'type' => 'float', 'analyzable' => false], self::TC_DATA_CHANNELS => ['method' => 'getChannels', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_COLORDEPTH => ['method' => 'getColorDepth', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_CAMERAMODEL => ['method' => 'getCameraModel', 'type' => 'string', 'analyzable' => false], self::TC_DATA_FLASHFIRED => ['method' => 'getFlashFired', 'type' => 'boolean', 'analyzable' => false], self::TC_DATA_APERTURE => ['method' => 'getAperture', 'type' => 'float', 'analyzable' => false], self::TC_DATA_SHUTTERSPEED => ['method' => 'getShutterSpeed', 'type' => 'float', 'analyzable' => false], self::TC_DATA_HYPERFOCALDISTANCE => ['method' => 'getHyperfocalDistance', 'type' => 'float', 'analyzable' => false], self::TC_DATA_ISO => ['method' => 'getISO', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_LIGHTVALUE => ['method' => 'getLightValue', 'type' => 'float', 'analyzable' => false], self::TC_DATA_COLORSPACE => ['method' => 'getColorSpace', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_DURATION => ['method' => 'getDuration', 'type' => 'float', 'analyzable' => false], self::TC_DATA_FRAMERATE => ['method' => 'getFrameRate', 'type' => 'float', 'analyzable' => false], self::TC_DATA_AUDIOSAMPLERATE => ['method' => 'getAudioSampleRate', 'type' => 'float', 'analyzable' => false], self::TC_DATA_VIDEOCODEC => ['method' => 'getVideoCodec', 'type' => 'string', 'analyzable' => false], self::TC_DATA_AUDIOCODEC => ['method' => 'getAudioCodec', 'type' => 'string', 'analyzable' => false], self::TC_DATA_ORIENTATION => ['method' => 'getOrientation', 'type' => 'integer', 'analyzable' => false], self::TC_DATA_LONGITUDE => ['method' => 'getLongitude', 'type' => 'float', 'analyzable' => false], self::TC_DATA_LONGITUDE_REF => ['method' => 'getLongitudeRef'], self::TC_DATA_LATITUDE => ['method' => 'getLatitude', 'type' => 'float', 'analyzable' => false], self::TC_DATA_LATITUDE_REF => ['method' => 'getLatitudeRef'], self::TC_DATA_MIMETYPE => ['type' => 'string', 'analyzable' => false], self::TC_DATA_FILESIZE => ['type' => 'long', 'analyzable' => false], ]; } return self::$technicalFieldsList; }
[ "public", "static", "function", "getTechnicalFieldsList", "(", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "technicalFieldsList", ")", ")", "{", "self", "::", "$", "technicalFieldsList", "=", "[", "self", "::", "TC_DATA_WIDTH", "=>", "[", "'method'...
Return list of technical data and their attributes @return array
[ "Return", "list", "of", "technical", "data", "and", "their", "attributes" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/media/subdef.php#L817-L851
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/RegistrationManager.php
RegistrationManager.isRegistrationEnabled
public function isRegistrationEnabled() { foreach ($this->appbox->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { if ($collection->isRegistrationEnabled()) { return true; } } } return false; }
php
public function isRegistrationEnabled() { foreach ($this->appbox->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { if ($collection->isRegistrationEnabled()) { return true; } } } return false; }
[ "public", "function", "isRegistrationEnabled", "(", ")", "{", "foreach", "(", "$", "this", "->", "appbox", "->", "get_databoxes", "(", ")", "as", "$", "databox", ")", "{", "foreach", "(", "$", "databox", "->", "get_collections", "(", ")", "as", "$", "col...
Tells whether registration is enabled or not. @return boolean
[ "Tells", "whether", "registration", "is", "enabled", "or", "not", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/RegistrationManager.php#L36-L47
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/RegistrationManager.php
RegistrationManager.getRegistrationSummary
public function getRegistrationSummary(User $user = null) { $data = $userData = []; // Gets user data if (null !== $user) { $userData = $this->repository->getRegistrationsSummaryForUser($user); } foreach ($this->appbox->get_databoxes() as $databox) { $data[$databox->get_sbas_id()] = [ // Registrations on databox by type 'registrations' => [ 'by-type' => [ 'inactive' => [], 'accepted' => [], 'in-time' => [], 'out-dated' => [], 'pending' => [], 'rejected' => [], ] ], // Registration configuration on databox and collections that belong to the databox 'config' => [ 'db-name' => $databox->get_dbname(), 'cgu' => $databox->get_cgus(), 'can-register' => $databox->isRegistrationEnabled(), // Configuration on collection 'collections' => [], ] ]; foreach ($databox->get_collections() as $collection) { // Sets collection info $data[$databox->get_sbas_id()]['config']['collections'][$collection->get_base_id()] = $this->getCollectionSummary($collection, $userData); // Sets registration by type if (null !== $registration = $this->getUserCollectionRegistration($collection, $userData)) { $data[$databox->get_sbas_id()]['registrations']['by-type'][$registration['type']][] = $registration; } } } return $data; }
php
public function getRegistrationSummary(User $user = null) { $data = $userData = []; // Gets user data if (null !== $user) { $userData = $this->repository->getRegistrationsSummaryForUser($user); } foreach ($this->appbox->get_databoxes() as $databox) { $data[$databox->get_sbas_id()] = [ // Registrations on databox by type 'registrations' => [ 'by-type' => [ 'inactive' => [], 'accepted' => [], 'in-time' => [], 'out-dated' => [], 'pending' => [], 'rejected' => [], ] ], // Registration configuration on databox and collections that belong to the databox 'config' => [ 'db-name' => $databox->get_dbname(), 'cgu' => $databox->get_cgus(), 'can-register' => $databox->isRegistrationEnabled(), // Configuration on collection 'collections' => [], ] ]; foreach ($databox->get_collections() as $collection) { // Sets collection info $data[$databox->get_sbas_id()]['config']['collections'][$collection->get_base_id()] = $this->getCollectionSummary($collection, $userData); // Sets registration by type if (null !== $registration = $this->getUserCollectionRegistration($collection, $userData)) { $data[$databox->get_sbas_id()]['registrations']['by-type'][$registration['type']][] = $registration; } } } return $data; }
[ "public", "function", "getRegistrationSummary", "(", "User", "$", "user", "=", "null", ")", "{", "$", "data", "=", "$", "userData", "=", "[", "]", ";", "// Gets user data", "if", "(", "null", "!==", "$", "user", ")", "{", "$", "userData", "=", "$", "...
Gets information about registration configuration and registration status if a user id is provided. @param null|user $user @return array
[ "Gets", "information", "about", "registration", "configuration", "and", "registration", "status", "if", "a", "user", "id", "is", "provided", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/RegistrationManager.php#L56-L99
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/RegistrationManager.php
RegistrationManager.userHasRequestedARegistrationOnCollection
private function userHasRequestedARegistrationOnCollection(\collection $collection, $userData) { if (null === $userRegistration = igorw\get_in($userData, [$collection->get_sbas_id(), $collection->get_base_id()])) { return false; } return !is_null($userRegistration['active']); }
php
private function userHasRequestedARegistrationOnCollection(\collection $collection, $userData) { if (null === $userRegistration = igorw\get_in($userData, [$collection->get_sbas_id(), $collection->get_base_id()])) { return false; } return !is_null($userRegistration['active']); }
[ "private", "function", "userHasRequestedARegistrationOnCollection", "(", "\\", "collection", "$", "collection", ",", "$", "userData", ")", "{", "if", "(", "null", "===", "$", "userRegistration", "=", "igorw", "\\", "get_in", "(", "$", "userData", ",", "[", "$"...
Tells whether user has ever requested a registration on collection or not. @param \collection $collection @param $userData @return boolean
[ "Tells", "whether", "user", "has", "ever", "requested", "a", "registration", "on", "collection", "or", "not", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/RegistrationManager.php#L109-L116
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Configuration/RegistrationManager.php
RegistrationManager.getUserCollectionRegistration
private function getUserCollectionRegistration(\collection $collection, $userData) { if (false === $this->userHasRequestedARegistrationOnCollection($collection, $userData)) { return null; } $userRegistration = igorw\get_in($userData, [$collection->get_sbas_id(), $collection->get_base_id()]); // sets collection name $userRegistration['coll-name'] = $collection->get_label($this->locale); // sets default type $userRegistration['type'] = 'active'; // gets registration entity $registration = $userRegistration['registration']; // set registration type & return user registration $registrationStillExists = !is_null($registration); $registrationNoMoreExists = !$registrationStillExists; $isPending = $registrationStillExists && $registration->isPending() && !$registration->isRejected(); $isRejected = $registrationStillExists && $registration->isRejected(); $isDone = ($registrationNoMoreExists) || (!$isPending && !$isRejected); $isActive = (Boolean) $userRegistration['active']; $isTimeLimited = (Boolean) $userRegistration['time-limited']; $isNotTimeLimited = !$isTimeLimited; $isOnTime = (Boolean) $userRegistration['in-time']; $isOutDated = !$isOnTime; if (!$isActive) { $userRegistration['type'] = 'inactive'; return $userRegistration; } if ($isDone) { $userRegistration['type'] = 'accepted'; return $userRegistration; } if ($isRejected) { $userRegistration['type'] = 'rejected'; return $userRegistration; } if ($isTimeLimited && $isOnTime && $isPending) { $userRegistration['type'] = 'in-time'; return $userRegistration; } if ($isTimeLimited && $isOutDated && $isPending) { $userRegistration['type'] = 'out-dated'; return $userRegistration; } if ($isNotTimeLimited && $isPending) { $userRegistration['type'] = 'pending'; return $userRegistration; } return $userRegistration; }
php
private function getUserCollectionRegistration(\collection $collection, $userData) { if (false === $this->userHasRequestedARegistrationOnCollection($collection, $userData)) { return null; } $userRegistration = igorw\get_in($userData, [$collection->get_sbas_id(), $collection->get_base_id()]); // sets collection name $userRegistration['coll-name'] = $collection->get_label($this->locale); // sets default type $userRegistration['type'] = 'active'; // gets registration entity $registration = $userRegistration['registration']; // set registration type & return user registration $registrationStillExists = !is_null($registration); $registrationNoMoreExists = !$registrationStillExists; $isPending = $registrationStillExists && $registration->isPending() && !$registration->isRejected(); $isRejected = $registrationStillExists && $registration->isRejected(); $isDone = ($registrationNoMoreExists) || (!$isPending && !$isRejected); $isActive = (Boolean) $userRegistration['active']; $isTimeLimited = (Boolean) $userRegistration['time-limited']; $isNotTimeLimited = !$isTimeLimited; $isOnTime = (Boolean) $userRegistration['in-time']; $isOutDated = !$isOnTime; if (!$isActive) { $userRegistration['type'] = 'inactive'; return $userRegistration; } if ($isDone) { $userRegistration['type'] = 'accepted'; return $userRegistration; } if ($isRejected) { $userRegistration['type'] = 'rejected'; return $userRegistration; } if ($isTimeLimited && $isOnTime && $isPending) { $userRegistration['type'] = 'in-time'; return $userRegistration; } if ($isTimeLimited && $isOutDated && $isPending) { $userRegistration['type'] = 'out-dated'; return $userRegistration; } if ($isNotTimeLimited && $isPending) { $userRegistration['type'] = 'pending'; return $userRegistration; } return $userRegistration; }
[ "private", "function", "getUserCollectionRegistration", "(", "\\", "collection", "$", "collection", ",", "$", "userData", ")", "{", "if", "(", "false", "===", "$", "this", "->", "userHasRequestedARegistrationOnCollection", "(", "$", "collection", ",", "$", "userDa...
Returns a user registration for given collection or null if no registration were requested. @param \collection $collection @param $userData @return null|array
[ "Returns", "a", "user", "registration", "for", "given", "collection", "or", "null", "if", "no", "registration", "were", "requested", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/RegistrationManager.php#L126-L191
alchemy-fr/Phraseanet
lib/classes/Bridge/Api/Youtube.php
Bridge_Api_Youtube.handle_exception
public function handle_exception(Exception $e) { if ($e instanceof Zend_Gdata_App_HttpException) { $response = $e->getResponse(); $http_code = $response->getStatus(); if ($http_code == 401) { $e = new Bridge_Exception_ActionAuthNeedReconnect(); return; } $message = $code = ""; switch ($response->getStatus()) { case 400: $message = $this->translator->trans("Erreur la requête a été mal formée ou contenait des données valides."); break; case 401: $message = $this->translator->trans("Erreur lors de l'authentification au service Youtube, Veuillez vous déconnecter, puis vous reconnecter."); break; case 403: $message = $this->translator->trans("Erreur lors de l'envoi de la requête. Erreur d'authentification."); break; case 404: $message = $this->translator->trans("Erreur la ressource que vous tentez de modifier n'existe pas."); break; case 500: $message = $this->translator->trans("Erreur YouTube a rencontré une erreur lors du traitement de la requête."); break; case 501: $message = $this->translator->trans("Erreur vous avez essayé d'exécuter une requête non prise en charge par Youtube"); break; case 503: $message = $this->translator->trans("Erreur le service Youtube n'est pas accessible pour le moment. Veuillez réessayer plus tard."); break; } if ($error = $this->parse_xml_error($response->getBody())) { $code = $error['code']; if ($code == "too_many_recent_calls") { $this->block_api(10 * 60 * 60); $e = new Bridge_Exception_ApiDisabled($this->get_api_manager()); return; } $reason = ''; switch ($code) { case "required": $reason = $this->translator->trans("A required field is missing or has an empty value"); break; case "deprecated": $reason = $this->translator->trans("A value has been deprecated and is no longer valid"); break; case "invalid_format": $reason = $this->translator->trans("A value does not match an expected format"); break; case "invalid_character": $reason = $this->translator->trans("A field value contains an invalid character"); break; case "too_long": $reason = $this->translator->trans("A value exceeds the maximum allowable length"); break; case "too_many_recent_calls": $reason = $this->translator->trans("The Youtube servers have received too many calls from the same caller in a short amount of time."); break; case "too_many_entries": $reason = $this->translator->trans("You are attempting to exceed the storage limit on your account and must delete existing entries before inserting new entries"); break; case "InvalidToken"; $reason = $this->translator->trans("The authentication token specified in the Authorization header is invalid"); break; case "TokenExpired"; $reason = $this->translator->trans("The authentication token specified in the Authorization header has expired."); break; case "disabled_in_maintenance_mode": $reason = $this->translator->trans("Current operations cannot be executed because the site is temporarily in maintenance mode. Wait a few minutes and try your request again"); break; } $message .= '<br/>' . $reason . '<br/>Youtube said : ' . $error['message']; } if ($error == false && $response->getStatus() == 404) { $message = $this->translator->trans("Service youtube introuvable."); } $e = new Exception($message); } return; }
php
public function handle_exception(Exception $e) { if ($e instanceof Zend_Gdata_App_HttpException) { $response = $e->getResponse(); $http_code = $response->getStatus(); if ($http_code == 401) { $e = new Bridge_Exception_ActionAuthNeedReconnect(); return; } $message = $code = ""; switch ($response->getStatus()) { case 400: $message = $this->translator->trans("Erreur la requête a été mal formée ou contenait des données valides."); break; case 401: $message = $this->translator->trans("Erreur lors de l'authentification au service Youtube, Veuillez vous déconnecter, puis vous reconnecter."); break; case 403: $message = $this->translator->trans("Erreur lors de l'envoi de la requête. Erreur d'authentification."); break; case 404: $message = $this->translator->trans("Erreur la ressource que vous tentez de modifier n'existe pas."); break; case 500: $message = $this->translator->trans("Erreur YouTube a rencontré une erreur lors du traitement de la requête."); break; case 501: $message = $this->translator->trans("Erreur vous avez essayé d'exécuter une requête non prise en charge par Youtube"); break; case 503: $message = $this->translator->trans("Erreur le service Youtube n'est pas accessible pour le moment. Veuillez réessayer plus tard."); break; } if ($error = $this->parse_xml_error($response->getBody())) { $code = $error['code']; if ($code == "too_many_recent_calls") { $this->block_api(10 * 60 * 60); $e = new Bridge_Exception_ApiDisabled($this->get_api_manager()); return; } $reason = ''; switch ($code) { case "required": $reason = $this->translator->trans("A required field is missing or has an empty value"); break; case "deprecated": $reason = $this->translator->trans("A value has been deprecated and is no longer valid"); break; case "invalid_format": $reason = $this->translator->trans("A value does not match an expected format"); break; case "invalid_character": $reason = $this->translator->trans("A field value contains an invalid character"); break; case "too_long": $reason = $this->translator->trans("A value exceeds the maximum allowable length"); break; case "too_many_recent_calls": $reason = $this->translator->trans("The Youtube servers have received too many calls from the same caller in a short amount of time."); break; case "too_many_entries": $reason = $this->translator->trans("You are attempting to exceed the storage limit on your account and must delete existing entries before inserting new entries"); break; case "InvalidToken"; $reason = $this->translator->trans("The authentication token specified in the Authorization header is invalid"); break; case "TokenExpired"; $reason = $this->translator->trans("The authentication token specified in the Authorization header has expired."); break; case "disabled_in_maintenance_mode": $reason = $this->translator->trans("Current operations cannot be executed because the site is temporarily in maintenance mode. Wait a few minutes and try your request again"); break; } $message .= '<br/>' . $reason . '<br/>Youtube said : ' . $error['message']; } if ($error == false && $response->getStatus() == 404) { $message = $this->translator->trans("Service youtube introuvable."); } $e = new Exception($message); } return; }
[ "public", "function", "handle_exception", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "e", "instanceof", "Zend_Gdata_App_HttpException", ")", "{", "$", "response", "=", "$", "e", "->", "getResponse", "(", ")", ";", "$", "http_code", "=", "$", "...
Set The exception to Bridge_Exception_ActionAuthNeedReconnect if exception is instance of Zend_Gdata_App_HttpException and Http code 401 @param Exception $e @return Void
[ "Set", "The", "exception", "to", "Bridge_Exception_ActionAuthNeedReconnect", "if", "exception", "is", "instance", "of", "Zend_Gdata_App_HttpException", "and", "Http", "code", "401" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Bridge/Api/Youtube.php#L510-L601
alchemy-fr/Phraseanet
lib/classes/Bridge/Api/Youtube.php
Bridge_Api_Youtube.get_category_list
public function get_category_list() { $cat = []; $url_cat = sprintf('%s?hl=%s', self::CATEGORY_URL, $this->get_locale()); if (false === $cxml = simplexml_load_file($url_cat)) { throw new Bridge_Exception_ApiConnectorRequestFailed('Failed to retrive youtube categories'); } $cxml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); $categories = $cxml->xpath('//atom:category'); foreach ($categories as $c) { $cat[(string) $c['term']] = (string) $c['label']; } return $cat; }
php
public function get_category_list() { $cat = []; $url_cat = sprintf('%s?hl=%s', self::CATEGORY_URL, $this->get_locale()); if (false === $cxml = simplexml_load_file($url_cat)) { throw new Bridge_Exception_ApiConnectorRequestFailed('Failed to retrive youtube categories'); } $cxml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); $categories = $cxml->xpath('//atom:category'); foreach ($categories as $c) { $cat[(string) $c['term']] = (string) $c['label']; } return $cat; }
[ "public", "function", "get_category_list", "(", ")", "{", "$", "cat", "=", "[", "]", ";", "$", "url_cat", "=", "sprintf", "(", "'%s?hl=%s'", ",", "self", "::", "CATEGORY_URL", ",", "$", "this", "->", "get_locale", "(", ")", ")", ";", "if", "(", "fals...
get available youtube categories as an array @return array
[ "get", "available", "youtube", "categories", "as", "an", "array" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Bridge/Api/Youtube.php#L703-L720
alchemy-fr/Phraseanet
lib/classes/Bridge/Api/Youtube.php
Bridge_Api_Youtube.get_update_datas
public function get_update_datas(Request $request) { $datas = [ 'title' => $request->get('modif_title'), 'description' => $request->get('modif_description'), 'category' => $request->get('modif_category'), 'tags' => $request->get('modif_tags'), 'privacy' => $request->get('modif_privacy'), ]; return $datas; }
php
public function get_update_datas(Request $request) { $datas = [ 'title' => $request->get('modif_title'), 'description' => $request->get('modif_description'), 'category' => $request->get('modif_category'), 'tags' => $request->get('modif_tags'), 'privacy' => $request->get('modif_privacy'), ]; return $datas; }
[ "public", "function", "get_update_datas", "(", "Request", "$", "request", ")", "{", "$", "datas", "=", "[", "'title'", "=>", "$", "request", "->", "get", "(", "'modif_title'", ")", ",", "'description'", "=>", "$", "request", "->", "get", "(", "'modif_descr...
Returns datas needed for an uploaded record @param Request $request @return array
[ "Returns", "datas", "needed", "for", "an", "uploaded", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Bridge/Api/Youtube.php#L953-L964
alchemy-fr/Phraseanet
lib/classes/Bridge/Api/Youtube.php
Bridge_Api_Youtube.get_upload_datas
public function get_upload_datas(Request $request, record_adapter $record) { $key = $record->getId(); $datas = [ 'title' => $request->get('title_' . $key), 'description' => $request->get('description_' . $key), 'category' => $request->get('category_' . $key), 'tags' => $request->get('tags_' . $key), 'privacy' => $request->get('privacy_' . $key), ]; return $datas; }
php
public function get_upload_datas(Request $request, record_adapter $record) { $key = $record->getId(); $datas = [ 'title' => $request->get('title_' . $key), 'description' => $request->get('description_' . $key), 'category' => $request->get('category_' . $key), 'tags' => $request->get('tags_' . $key), 'privacy' => $request->get('privacy_' . $key), ]; return $datas; }
[ "public", "function", "get_upload_datas", "(", "Request", "$", "request", ",", "record_adapter", "$", "record", ")", "{", "$", "key", "=", "$", "record", "->", "getId", "(", ")", ";", "$", "datas", "=", "[", "'title'", "=>", "$", "request", "->", "get"...
Returns datas needed for an uploaded record @param Request $request @param record_adapter $record @return array
[ "Returns", "datas", "needed", "for", "an", "uploaded", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Bridge/Api/Youtube.php#L974-L986
alchemy-fr/Phraseanet
lib/classes/patch/380alpha17a.php
patch_380alpha17a.apply
public function apply(base $appbox, Application $app) { $auth = $app['conf']->get('authentication'); if (isset($auth['captcha']) && isset($auth['captcha']['trials-before-failure'])) { $auth['captcha']['trials-before-display'] = $auth['captcha']['trials-before-failure']; unset($auth['captcha']['trials-before-failure']); } if (isset($auth['auto-create']) && isset($auth['auto-create']['enabled'])) { unset($auth['auto-create']['enabled']); } $app['conf']->set('authentication', $auth); return true; }
php
public function apply(base $appbox, Application $app) { $auth = $app['conf']->get('authentication'); if (isset($auth['captcha']) && isset($auth['captcha']['trials-before-failure'])) { $auth['captcha']['trials-before-display'] = $auth['captcha']['trials-before-failure']; unset($auth['captcha']['trials-before-failure']); } if (isset($auth['auto-create']) && isset($auth['auto-create']['enabled'])) { unset($auth['auto-create']['enabled']); } $app['conf']->set('authentication', $auth); return true; }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "$", "auth", "=", "$", "app", "[", "'conf'", "]", "->", "get", "(", "'authentication'", ")", ";", "if", "(", "isset", "(", "$", "auth", "[", "'capt...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/380alpha17a.php#L49-L65
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php
XSendFileFactory.create
public static function create(Application $app) { $conf = $app['conf']->get('xsendfile'); $mapping = []; if (isset($conf['mapping'])) { $mapping = $conf['mapping']; } return new self($app['monolog'], $conf['enabled'], $conf['type'], $mapping); }
php
public static function create(Application $app) { $conf = $app['conf']->get('xsendfile'); $mapping = []; if (isset($conf['mapping'])) { $mapping = $conf['mapping']; } return new self($app['monolog'], $conf['enabled'], $conf['type'], $mapping); }
[ "public", "static", "function", "create", "(", "Application", "$", "app", ")", "{", "$", "conf", "=", "$", "app", "[", "'conf'", "]", "->", "get", "(", "'xsendfile'", ")", ";", "$", "mapping", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "co...
Creates a new instance of XSendFile Factory according to the application configuration. @param Application $app @return XSendFileFactory
[ "Creates", "a", "new", "instance", "of", "XSendFile", "Factory", "according", "to", "the", "application", "configuration", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php#L49-L60
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php
XSendFileFactory.getMode
public function getMode($throwException = false, $forceMode = false) { if (false === $this->enabled && true !== $forceMode) { return new NullMode(); } switch ($this->type) { case 'nginx': case 'sendfile': case 'xaccel': case 'xaccelredirect': case 'x-accel': case 'x-accel-redirect': if (2 >= count($this->mapping)) { $this->logger->error('Invalid xsendfile mapping configuration.'); if ($throwException) { throw new RuntimeException('Mapping is not set up.'); } } return new NginxMode($this->mapping); case 'apache': case 'apache2': case 'xsendfile': return new ApacheMode($this->mapping); default: $this->logger->error('Invalid xsendfile type configuration.'); if ($throwException) { throw new InvalidArgumentException(sprintf( 'Invalid xsendfile type value "%s"', $this->type )); } return new NullMode(); } }
php
public function getMode($throwException = false, $forceMode = false) { if (false === $this->enabled && true !== $forceMode) { return new NullMode(); } switch ($this->type) { case 'nginx': case 'sendfile': case 'xaccel': case 'xaccelredirect': case 'x-accel': case 'x-accel-redirect': if (2 >= count($this->mapping)) { $this->logger->error('Invalid xsendfile mapping configuration.'); if ($throwException) { throw new RuntimeException('Mapping is not set up.'); } } return new NginxMode($this->mapping); case 'apache': case 'apache2': case 'xsendfile': return new ApacheMode($this->mapping); default: $this->logger->error('Invalid xsendfile type configuration.'); if ($throwException) { throw new InvalidArgumentException(sprintf( 'Invalid xsendfile type value "%s"', $this->type )); } return new NullMode(); } }
[ "public", "function", "getMode", "(", "$", "throwException", "=", "false", ",", "$", "forceMode", "=", "false", ")", "{", "if", "(", "false", "===", "$", "this", "->", "enabled", "&&", "true", "!==", "$", "forceMode", ")", "{", "return", "new", "NullMo...
Returns a new instance of ModeInterface. @return ModeInterface @throws InvalidArgumentException if mode type is unknown
[ "Returns", "a", "new", "instance", "of", "ModeInterface", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php#L69-L105
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Notifier.php
Notifier.notify
public function notify($message) { try { $command = $this->createCommand($message); $this->socket->send($command); $result = false; $limit = microtime(true) + $this->timeout; while (microtime(true) < $limit && false === $result = $this->socket->recv(\ZMQ::MODE_NOBLOCK)) { usleep(1000); } if (false === $result) { $this->logger->error(sprintf('Unable to notify the task manager with message "%s" within timeout of %d seconds', $message, $this->timeout)); throw new RuntimeException('Unable to retrieve information.'); } $data = @json_decode($result, true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Invalid task manager response : invalid JSON.'); } if (!isset($data['reply']) || !isset($data['request']) || $command !== $data['request']) { throw new RuntimeException('Invalid task manager response : missing fields.'); } return $data['reply']; } catch (\ZMQSocketException $e) { $this->logger->error(sprintf('Unable to notify the task manager with message "%s" within timeout of %d seconds', $message, $this->timeout), ['exception' => $e]); throw new RuntimeException('Unable to retrieve information.', $e->getCode(), $e); } }
php
public function notify($message) { try { $command = $this->createCommand($message); $this->socket->send($command); $result = false; $limit = microtime(true) + $this->timeout; while (microtime(true) < $limit && false === $result = $this->socket->recv(\ZMQ::MODE_NOBLOCK)) { usleep(1000); } if (false === $result) { $this->logger->error(sprintf('Unable to notify the task manager with message "%s" within timeout of %d seconds', $message, $this->timeout)); throw new RuntimeException('Unable to retrieve information.'); } $data = @json_decode($result, true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Invalid task manager response : invalid JSON.'); } if (!isset($data['reply']) || !isset($data['request']) || $command !== $data['request']) { throw new RuntimeException('Invalid task manager response : missing fields.'); } return $data['reply']; } catch (\ZMQSocketException $e) { $this->logger->error(sprintf('Unable to notify the task manager with message "%s" within timeout of %d seconds', $message, $this->timeout), ['exception' => $e]); throw new RuntimeException('Unable to retrieve information.', $e->getCode(), $e); } }
[ "public", "function", "notify", "(", "$", "message", ")", "{", "try", "{", "$", "command", "=", "$", "this", "->", "createCommand", "(", "$", "message", ")", ";", "$", "this", "->", "socket", "->", "send", "(", "$", "command", ")", ";", "$", "resul...
Notifies the task manager given a message constant, see MESSAGE_* constants. @param string $message @return mixed|null The return value of the task manager. @throws RuntimeException in case notification did not occur within the timeout.
[ "Notifies", "the", "task", "manager", "given", "a", "message", "constant", "see", "MESSAGE_", "*", "constants", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Notifier.php#L53-L84
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Notifier.php
Notifier.create
public static function create(LoggerInterface $logger, array $options = []) { $context = new \ZMQContext(); $socket = $context->getSocket(\ZMQ::SOCKET_REQ); $socket->setSockOpt(\ZMQ::SOCKOPT_LINGER, $options['linger']); $socket->connect(sprintf( '%s://%s:%s', $options['protocol'], $options['host'], $options['port'] )); return new static($socket, $logger); }
php
public static function create(LoggerInterface $logger, array $options = []) { $context = new \ZMQContext(); $socket = $context->getSocket(\ZMQ::SOCKET_REQ); $socket->setSockOpt(\ZMQ::SOCKOPT_LINGER, $options['linger']); $socket->connect(sprintf( '%s://%s:%s', $options['protocol'], $options['host'], $options['port'] )); return new static($socket, $logger); }
[ "public", "static", "function", "create", "(", "LoggerInterface", "$", "logger", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "context", "=", "new", "\\", "ZMQContext", "(", ")", ";", "$", "socket", "=", "$", "context", "->", "getSocket"...
Creates a Notifier. @param array $options @return Notifier
[ "Creates", "a", "Notifier", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Notifier.php#L107-L117
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Command/Setup/CrossDomainGenerator.php
CrossDomainGenerator.doExecute
protected function doExecute(InputInterface $input, OutputInterface $output) { if ($this->container['phraseanet.configuration-tester']->isInstalled()) { $configuration = $this->container['phraseanet.configuration']['crossdomain']; } else { $default = Yaml::parse($this->container['root.path'].'/lib/conf.d/configuration.yml'); $configuration = $default['crossdomain']; } $dumper = new CrossDomainDumper(); $xml = $dumper->dump($configuration); $output->writeln("Generating crossdomain.xml"); $this->container['filesystem']->dumpFile($this->container['root.path'].'/www/crossdomain.xml', $xml); return ; }
php
protected function doExecute(InputInterface $input, OutputInterface $output) { if ($this->container['phraseanet.configuration-tester']->isInstalled()) { $configuration = $this->container['phraseanet.configuration']['crossdomain']; } else { $default = Yaml::parse($this->container['root.path'].'/lib/conf.d/configuration.yml'); $configuration = $default['crossdomain']; } $dumper = new CrossDomainDumper(); $xml = $dumper->dump($configuration); $output->writeln("Generating crossdomain.xml"); $this->container['filesystem']->dumpFile($this->container['root.path'].'/www/crossdomain.xml', $xml); return ; }
[ "protected", "function", "doExecute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "if", "(", "$", "this", "->", "container", "[", "'phraseanet.configuration-tester'", "]", "->", "isInstalled", "(", ")", ")", "{", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Command/Setup/CrossDomainGenerator.php#L32-L48
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Http/H264PseudoStreaming/Apache.php
Apache.getVirtualHostConfiguration
public function getVirtualHostConfiguration() { $output = "\n"; foreach ($this->mapping as $entry) { $output .= " Alias ".$entry['mount-point']." \"".$entry['directory']."\"\n"; $output .= "\n"; $output .= " <Location ".$entry['mount-point'].">\n"; $output .= " AuthTokenSecret \"".$entry['passphrase']."\"\n"; $output .= " AuthTokenPrefix ".$entry['mount-point']."\n"; $output .= " AuthTokenTimeout 3600\n"; $output .= " AuthTokenLimitByIp off\n"; $output .= " </Location>\n"; $output .= "\n"; } return $output; }
php
public function getVirtualHostConfiguration() { $output = "\n"; foreach ($this->mapping as $entry) { $output .= " Alias ".$entry['mount-point']." \"".$entry['directory']."\"\n"; $output .= "\n"; $output .= " <Location ".$entry['mount-point'].">\n"; $output .= " AuthTokenSecret \"".$entry['passphrase']."\"\n"; $output .= " AuthTokenPrefix ".$entry['mount-point']."\n"; $output .= " AuthTokenTimeout 3600\n"; $output .= " AuthTokenLimitByIp off\n"; $output .= " </Location>\n"; $output .= "\n"; } return $output; }
[ "public", "function", "getVirtualHostConfiguration", "(", ")", "{", "$", "output", "=", "\"\\n\"", ";", "foreach", "(", "$", "this", "->", "mapping", "as", "$", "entry", ")", "{", "$", "output", ".=", "\" Alias \"", ".", "$", "entry", "[", "'mount-point...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Http/H264PseudoStreaming/Apache.php#L82-L98
alchemy-fr/Phraseanet
lib/classes/p4string.php
p4string.MakeString
public static function MakeString($s, $context = 'html', $quoted = '') { switch (mb_strtolower($context . '_' . $quoted)) { case 'js_': // old method $s = str_replace(["\\", "\"", "'", "\r", "\n"], ["\\\\", "\\\"", "\\'", "\\r", "\\n"], $s); break; case 'js_"': $s = str_replace(["\\", "\"", "\r", "\n"], ["\\\\", "\\\"", "\\r", "\\n"], $s); break; case 'js_\'': $s = str_replace(["\\", "'", "\r", "\n"], ["\\\\", "\\'", "\\r", "\\n"], $s); break; case 'dquot_"': $s = str_replace(["\\", "\"", "\r", "\n"], ["\\\\", "\\\"", "\\r", "\\n"], $s); break; case 'squot_"': $s = str_replace(["\\", "'", "\r", "\n"], ["\\\\", "\\'", "\\r", "\\n"], $s); break; case 'html_': // old method case 'html_\'': case 'html_"': $s = str_replace(["&", "<", ">", "\n"], ["&amp;", "&lt;", "&gt;", "<br/>\n"], $s); break; case 'htmlprop_': $s = str_replace(["\"", "'", "<", ">"], ["&quot;", "&#39;", "&lt;", "&gt;"], $s); break; case 'htmlprop_\'': $s = str_replace(["'", "<", ">"], ["&#39;", "&lt;", "&gt;"], $s); break; case 'htmlprop_"': $s = str_replace(["\"", "<", ">"], ["&quot;", "&lt;", "&gt;"], $s); break; case 'form_': case 'form_\'': // <input type... value='$phpvar'...> case 'form_"': $s = str_replace(["&", "\"", "'", "<", ">"], ["&amp;", "&quot;", "&#39;", "&lt;", "&gt;"], $s); break; case 'none_"': default: break; } return($s); }
php
public static function MakeString($s, $context = 'html', $quoted = '') { switch (mb_strtolower($context . '_' . $quoted)) { case 'js_': // old method $s = str_replace(["\\", "\"", "'", "\r", "\n"], ["\\\\", "\\\"", "\\'", "\\r", "\\n"], $s); break; case 'js_"': $s = str_replace(["\\", "\"", "\r", "\n"], ["\\\\", "\\\"", "\\r", "\\n"], $s); break; case 'js_\'': $s = str_replace(["\\", "'", "\r", "\n"], ["\\\\", "\\'", "\\r", "\\n"], $s); break; case 'dquot_"': $s = str_replace(["\\", "\"", "\r", "\n"], ["\\\\", "\\\"", "\\r", "\\n"], $s); break; case 'squot_"': $s = str_replace(["\\", "'", "\r", "\n"], ["\\\\", "\\'", "\\r", "\\n"], $s); break; case 'html_': // old method case 'html_\'': case 'html_"': $s = str_replace(["&", "<", ">", "\n"], ["&amp;", "&lt;", "&gt;", "<br/>\n"], $s); break; case 'htmlprop_': $s = str_replace(["\"", "'", "<", ">"], ["&quot;", "&#39;", "&lt;", "&gt;"], $s); break; case 'htmlprop_\'': $s = str_replace(["'", "<", ">"], ["&#39;", "&lt;", "&gt;"], $s); break; case 'htmlprop_"': $s = str_replace(["\"", "<", ">"], ["&quot;", "&lt;", "&gt;"], $s); break; case 'form_': case 'form_\'': // <input type... value='$phpvar'...> case 'form_"': $s = str_replace(["&", "\"", "'", "<", ">"], ["&amp;", "&quot;", "&#39;", "&lt;", "&gt;"], $s); break; case 'none_"': default: break; } return($s); }
[ "public", "static", "function", "MakeString", "(", "$", "s", ",", "$", "context", "=", "'html'", ",", "$", "quoted", "=", "''", ")", "{", "switch", "(", "mb_strtolower", "(", "$", "context", ".", "'_'", ".", "$", "quoted", ")", ")", "{", "case", "'...
deprecated @param string $s @param string $context @param string $quoted
[ "deprecated" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/p4string.php#L47-L95
alchemy-fr/Phraseanet
lib/classes/module/report/nav.php
module_report_nav.buildTabUserWhat
public function buildTabUserWhat($bid, $rid, $tab = false) { $this->initialize(); $sbas_id = phrasea::sbasFromBas($this->app, $bid); try { $record = new record_adapter($this->app, $sbas_id, $rid); } catch (\Exception_Record_AdapterNotFound $e) { return $this->report; } $this->setDisplay($tab); $this->champ = [ 'photo', 'record_id', 'date', 'type', 'titre', 'taille' ]; $document = $record->get_subdef('document'); $this->title = $this->app->trans('report:: Information sur l\'enregistrement numero %number%', ['%number%' => (int) $rid]); $x = $record->get_thumbnail(); $this->result[] = [ 'photo' => "<img style='width:" . $x->get_width() . "px;height:" . $x->get_height() . "px;' src='" . (string) $x->get_url() . "'>" , 'record_id' => $record->getRecordId() , 'date' => $this->app['date-formatter']->getPrettyString($document->get_creation_date()) , 'type' => $document->get_mime() , 'titre' => $record->get_title() , 'taille' => $document->get_size() ]; $this->setDisplayNav(); $this->setReport(); return $this->report; }
php
public function buildTabUserWhat($bid, $rid, $tab = false) { $this->initialize(); $sbas_id = phrasea::sbasFromBas($this->app, $bid); try { $record = new record_adapter($this->app, $sbas_id, $rid); } catch (\Exception_Record_AdapterNotFound $e) { return $this->report; } $this->setDisplay($tab); $this->champ = [ 'photo', 'record_id', 'date', 'type', 'titre', 'taille' ]; $document = $record->get_subdef('document'); $this->title = $this->app->trans('report:: Information sur l\'enregistrement numero %number%', ['%number%' => (int) $rid]); $x = $record->get_thumbnail(); $this->result[] = [ 'photo' => "<img style='width:" . $x->get_width() . "px;height:" . $x->get_height() . "px;' src='" . (string) $x->get_url() . "'>" , 'record_id' => $record->getRecordId() , 'date' => $this->app['date-formatter']->getPrettyString($document->get_creation_date()) , 'type' => $document->get_mime() , 'titre' => $record->get_title() , 'taille' => $document->get_size() ]; $this->setDisplayNav(); $this->setReport(); return $this->report; }
[ "public", "function", "buildTabUserWhat", "(", "$", "bid", ",", "$", "rid", ",", "$", "tab", "=", "false", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "$", "sbas_id", "=", "phrasea", "::", "sbasFromBas", "(", "$", "this", "->", "app", ...
Return basic information about a record @param integer $bid base id @param integer $rid record id @param array $tab config for the html table @return array
[ "Return", "basic", "information", "about", "a", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report/nav.php#L490-L530
alchemy-fr/Phraseanet
lib/classes/patch/380alpha13a.php
patch_380alpha13a.apply
public function apply(base $appbox, Application $app) { $sql = 'SELECT `key`, `value` FROM `registry` WHERE `key` = "GV_X_Accel_Redirect" OR `key` = "GV_X_Accel_Redirect_mount_point" OR `key` = "GV_modxsendfile"'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); $registry = [ 'GV_X_Accel_Redirect' => null, 'GV_X_Accel_Redirect_mount_point' => null, 'GV_modxsendfile' => null, ]; foreach ($rows as $row) { $registry[$row['key']] = $row['value']; } $xsendfilePath = $registry['GV_X_Accel_Redirect']; $xsendfileMountPoint = $registry['GV_X_Accel_Redirect_mount_point']; $config = $app['configuration.store']->setDefault('xsendfile')->getConfig(); $config['xsendfile']['enabled'] = (Boolean) $registry['GV_modxsendfile']; $config['xsendfile']['type'] = $config['xsendfile']['enabled'] ? 'nginx' : ''; if (null !== $xsendfilePath && null !== $xsendfileMountPoint) { $config['xsendfile']['mapping'] = [[ 'directory' => $xsendfilePath, 'mount-point' => $xsendfileMountPoint, ]]; } $app['configuration.store']->setConfig($config); $toRemove = ['GV_X_Accel_Redirect', 'GV_X_Accel_Redirect_mount_point', 'GV_modxsendfile']; $sql = 'DELETE FROM registry WHERE `key` = :k'; $stmt = $appbox->get_connection()->prepare($sql); foreach ($toRemove as $registryKey) { $stmt->execute([ ':k' => $registryKey ]); } $stmt->closeCursor(); return true; }
php
public function apply(base $appbox, Application $app) { $sql = 'SELECT `key`, `value` FROM `registry` WHERE `key` = "GV_X_Accel_Redirect" OR `key` = "GV_X_Accel_Redirect_mount_point" OR `key` = "GV_modxsendfile"'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); $registry = [ 'GV_X_Accel_Redirect' => null, 'GV_X_Accel_Redirect_mount_point' => null, 'GV_modxsendfile' => null, ]; foreach ($rows as $row) { $registry[$row['key']] = $row['value']; } $xsendfilePath = $registry['GV_X_Accel_Redirect']; $xsendfileMountPoint = $registry['GV_X_Accel_Redirect_mount_point']; $config = $app['configuration.store']->setDefault('xsendfile')->getConfig(); $config['xsendfile']['enabled'] = (Boolean) $registry['GV_modxsendfile']; $config['xsendfile']['type'] = $config['xsendfile']['enabled'] ? 'nginx' : ''; if (null !== $xsendfilePath && null !== $xsendfileMountPoint) { $config['xsendfile']['mapping'] = [[ 'directory' => $xsendfilePath, 'mount-point' => $xsendfileMountPoint, ]]; } $app['configuration.store']->setConfig($config); $toRemove = ['GV_X_Accel_Redirect', 'GV_X_Accel_Redirect_mount_point', 'GV_modxsendfile']; $sql = 'DELETE FROM registry WHERE `key` = :k'; $stmt = $appbox->get_connection()->prepare($sql); foreach ($toRemove as $registryKey) { $stmt->execute([ ':k' => $registryKey ]); } $stmt->closeCursor(); return true; }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "$", "sql", "=", "'SELECT `key`, `value` FROM `registry`\n WHERE `key` = \"GV_X_Accel_Redirect\"\n OR `key` = \"GV_X_Accel_Redirect_mount_point\"\n ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/380alpha13a.php#L49-L99
alchemy-fr/Phraseanet
lib/classes/module/report/dashboard.php
module_report_dashboard.getListeBase
public function getListeBase($separator) { $all_coll = $this->getAllColl(); $liste = ''; foreach ($all_coll as $sbas => $info) { $liste .= phrasea::sbas_labels($sbas, $this->app) . ' ' . $separator . ' '; } return $liste; }
php
public function getListeBase($separator) { $all_coll = $this->getAllColl(); $liste = ''; foreach ($all_coll as $sbas => $info) { $liste .= phrasea::sbas_labels($sbas, $this->app) . ' ' . $separator . ' '; } return $liste; }
[ "public", "function", "getListeBase", "(", "$", "separator", ")", "{", "$", "all_coll", "=", "$", "this", "->", "getAllColl", "(", ")", ";", "$", "liste", "=", "''", ";", "foreach", "(", "$", "all_coll", "as", "$", "sbas", "=>", "$", "info", ")", "...
La liste des base authorisee sous forme de string @param string $separator @return string
[ "La", "liste", "des", "base", "authorisee", "sous", "forme", "de", "string" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report/dashboard.php#L296-L305
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Admin/DataboxesController.php
DataboxesController.getDatabases
public function getDatabases(Request $request) { $acl = $this->getAclForUser(); $sbasIds = array_merge( array_keys($acl->get_granted_sbas([\ACL::BAS_MANAGE])), array_keys($acl->get_granted_sbas([\ACL::BAS_MODIFY_STRUCT])) ); $sbas = []; foreach ($sbasIds as $sbasId) { $sbas[$sbasId] = [ 'version' => 'unknown', 'image' => '/assets/common/images/icons/db-remove.png', 'server_info' => '', 'name' => $this->app->trans('Unreachable server') ]; try { $databox = $this->findDataboxById($sbasId); /** @var \PDO $pdoConnection */ $pdoConnection = $databox->get_connection()->getWrappedConnection(); $sbas[$sbasId] = [ 'version' => $databox->get_version(), 'image' => '/assets/common/images/icons/foldph20close_0.gif', 'server_info' => $pdoConnection->getAttribute(\PDO::ATTR_SERVER_VERSION), 'name' => \phrasea::sbas_labels($sbasId, $this->app) ]; } catch (\Exception $e) { } } switch ($errorMsg = $request->query->get('error')) { case 'scheduler-started' : $errorMsg = $this->app->trans('Veuillez arreter le planificateur avant la mise a jour'); break; case 'already-started' : $errorMsg = $this->app->trans('The upgrade is already started'); break; case 'unknow' : $errorMsg = $this->app->trans('An error occured'); break; case 'bad-email' : $errorMsg = $this->app->trans('Please fix the database before starting'); break; case 'special-chars' : $errorMsg = $this->app->trans('Database name can not contains special characters'); break; case 'base-failed' : $errorMsg = $this->app->trans('Base could not be created'); break; case 'database-failed' : $errorMsg = $this->app->trans('Database does not exists or can not be accessed'); break; case 'no-empty' : $errorMsg = $this->app->trans('Database can not be empty'); break; case 'mount-failed' : $errorMsg = $this->app->trans('Database could not be mounted'); break; case 'innodb-support' : $errorMsg = $this->app->trans('Database server does not support InnoDB storage engine'); break; } return $this->render('admin/databases.html.twig', [ 'files' => new \DirectoryIterator($this->app['root.path'] . '/lib/conf.d/data_templates'), 'sbas' => $sbas, 'error_msg' => $errorMsg, 'advices' => $request->query->get('advices', []), 'reloadTree' => (Boolean) $request->query->get('reload-tree'), ]); }
php
public function getDatabases(Request $request) { $acl = $this->getAclForUser(); $sbasIds = array_merge( array_keys($acl->get_granted_sbas([\ACL::BAS_MANAGE])), array_keys($acl->get_granted_sbas([\ACL::BAS_MODIFY_STRUCT])) ); $sbas = []; foreach ($sbasIds as $sbasId) { $sbas[$sbasId] = [ 'version' => 'unknown', 'image' => '/assets/common/images/icons/db-remove.png', 'server_info' => '', 'name' => $this->app->trans('Unreachable server') ]; try { $databox = $this->findDataboxById($sbasId); /** @var \PDO $pdoConnection */ $pdoConnection = $databox->get_connection()->getWrappedConnection(); $sbas[$sbasId] = [ 'version' => $databox->get_version(), 'image' => '/assets/common/images/icons/foldph20close_0.gif', 'server_info' => $pdoConnection->getAttribute(\PDO::ATTR_SERVER_VERSION), 'name' => \phrasea::sbas_labels($sbasId, $this->app) ]; } catch (\Exception $e) { } } switch ($errorMsg = $request->query->get('error')) { case 'scheduler-started' : $errorMsg = $this->app->trans('Veuillez arreter le planificateur avant la mise a jour'); break; case 'already-started' : $errorMsg = $this->app->trans('The upgrade is already started'); break; case 'unknow' : $errorMsg = $this->app->trans('An error occured'); break; case 'bad-email' : $errorMsg = $this->app->trans('Please fix the database before starting'); break; case 'special-chars' : $errorMsg = $this->app->trans('Database name can not contains special characters'); break; case 'base-failed' : $errorMsg = $this->app->trans('Base could not be created'); break; case 'database-failed' : $errorMsg = $this->app->trans('Database does not exists or can not be accessed'); break; case 'no-empty' : $errorMsg = $this->app->trans('Database can not be empty'); break; case 'mount-failed' : $errorMsg = $this->app->trans('Database could not be mounted'); break; case 'innodb-support' : $errorMsg = $this->app->trans('Database server does not support InnoDB storage engine'); break; } return $this->render('admin/databases.html.twig', [ 'files' => new \DirectoryIterator($this->app['root.path'] . '/lib/conf.d/data_templates'), 'sbas' => $sbas, 'error_msg' => $errorMsg, 'advices' => $request->query->get('advices', []), 'reloadTree' => (Boolean) $request->query->get('reload-tree'), ]); }
[ "public", "function", "getDatabases", "(", "Request", "$", "request", ")", "{", "$", "acl", "=", "$", "this", "->", "getAclForUser", "(", ")", ";", "$", "sbasIds", "=", "array_merge", "(", "array_keys", "(", "$", "acl", "->", "get_granted_sbas", "(", "["...
Get Databases control panel @param Request $request @return Response
[ "Get", "Databases", "control", "panel" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Admin/DataboxesController.php#L30-L103
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Admin/DataboxesController.php
DataboxesController.createDatabase
public function createDatabase(Request $request) { $dbName = $request->request->get('new_dbname', ''); /** @var DataboxService $databoxService */ $databoxService = $this->app['databox.service']; $dataTemplate = $request->request->get('new_data_template'); try { $connectionSettings = $this->buildSettingsFromRequest($request); $databox = $databoxService->createDatabox( $dbName, $dataTemplate, $this->getAuthenticatedUser(), $connectionSettings ); return $this->app->redirectPath('admin_database', [ 'databox_id' => $databox->get_sbas_id(), 'success' => 1, 'reload-tree' => 1 ]); } catch (\InvalidArgumentException $exception) { return $this->handleInvalidArgument($exception); } catch (DBALException $e) { return $this->app->redirectPath('admin_databases', ['success' => 0, 'error' => 'database-failed']); } catch (\Exception $e) { return $this->app->redirectPath('admin_databases', [ 'success' => 0, 'error' => 'base-failed' ]); } }
php
public function createDatabase(Request $request) { $dbName = $request->request->get('new_dbname', ''); /** @var DataboxService $databoxService */ $databoxService = $this->app['databox.service']; $dataTemplate = $request->request->get('new_data_template'); try { $connectionSettings = $this->buildSettingsFromRequest($request); $databox = $databoxService->createDatabox( $dbName, $dataTemplate, $this->getAuthenticatedUser(), $connectionSettings ); return $this->app->redirectPath('admin_database', [ 'databox_id' => $databox->get_sbas_id(), 'success' => 1, 'reload-tree' => 1 ]); } catch (\InvalidArgumentException $exception) { return $this->handleInvalidArgument($exception); } catch (DBALException $e) { return $this->app->redirectPath('admin_databases', ['success' => 0, 'error' => 'database-failed']); } catch (\Exception $e) { return $this->app->redirectPath('admin_databases', [ 'success' => 0, 'error' => 'base-failed' ]); } }
[ "public", "function", "createDatabase", "(", "Request", "$", "request", ")", "{", "$", "dbName", "=", "$", "request", "->", "request", "->", "get", "(", "'new_dbname'", ",", "''", ")", ";", "/** @var DataboxService $databoxService */", "$", "databoxService", "="...
Create a new databox @param Request $request The current HTTP request @return RedirectResponse
[ "Create", "a", "new", "databox" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Admin/DataboxesController.php#L111-L146
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Admin/DataboxesController.php
DataboxesController.databaseMount
public function databaseMount(Request $request) { $dbName = trim($request->request->get('new_dbname', '')); /** @var DataboxService $databoxService */ $databoxService = $this->app['databox.service']; try { $connectionSettings = $this->buildSettingsFromRequest($request); \phrasea::clear_sbas_params($this->app); $databox = $databoxService->mountDatabox($dbName, $this->app->getAuthenticatedUser(), $connectionSettings); return $this->app->redirectPath('admin_database', [ 'databox_id' => $databox->get_sbas_id(), 'success' => 1, 'reload-tree' => 1, ]); } catch (\InvalidArgumentException $exception) { return $this->handleInvalidArgument($exception); } catch (\Exception $exception) { return $this->app->redirectPath('admin_databases', [ 'success' => 0, // 'error' => 'mount-failed' 'error' => $exception->getMessage() ]); } }
php
public function databaseMount(Request $request) { $dbName = trim($request->request->get('new_dbname', '')); /** @var DataboxService $databoxService */ $databoxService = $this->app['databox.service']; try { $connectionSettings = $this->buildSettingsFromRequest($request); \phrasea::clear_sbas_params($this->app); $databox = $databoxService->mountDatabox($dbName, $this->app->getAuthenticatedUser(), $connectionSettings); return $this->app->redirectPath('admin_database', [ 'databox_id' => $databox->get_sbas_id(), 'success' => 1, 'reload-tree' => 1, ]); } catch (\InvalidArgumentException $exception) { return $this->handleInvalidArgument($exception); } catch (\Exception $exception) { return $this->app->redirectPath('admin_databases', [ 'success' => 0, // 'error' => 'mount-failed' 'error' => $exception->getMessage() ]); } }
[ "public", "function", "databaseMount", "(", "Request", "$", "request", ")", "{", "$", "dbName", "=", "trim", "(", "$", "request", "->", "request", "->", "get", "(", "'new_dbname'", ",", "''", ")", ")", ";", "/** @var DataboxService $databoxService */", "$", ...
Mount a databox @param Request $request The current HTTP request @return RedirectResponse
[ "Mount", "a", "databox" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Admin/DataboxesController.php#L154-L184