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/Controller/Api/V1Controller.php
V1Controller.searchPublicationsAction
public function searchPublicationsAction(Request $request) { $user = $this->getAuthenticatedUser(); /** @var FeedRepository $feedsRepository */ $feedsRepository = $this->app['repo.feeds']; $coll = $feedsRepository->getAllForUser($this->getAclForUser($user)); $data = array_map(function ($feed) use ($user) { return $this->listPublication($feed, $user); }, $coll); return Result::create($request, ["feeds" => $data])->createResponse(); }
php
public function searchPublicationsAction(Request $request) { $user = $this->getAuthenticatedUser(); /** @var FeedRepository $feedsRepository */ $feedsRepository = $this->app['repo.feeds']; $coll = $feedsRepository->getAllForUser($this->getAclForUser($user)); $data = array_map(function ($feed) use ($user) { return $this->listPublication($feed, $user); }, $coll); return Result::create($request, ["feeds" => $data])->createResponse(); }
[ "public", "function", "searchPublicationsAction", "(", "Request", "$", "request", ")", "{", "$", "user", "=", "$", "this", "->", "getAuthenticatedUser", "(", ")", ";", "/** @var FeedRepository $feedsRepository */", "$", "feedsRepository", "=", "$", "this", "->", "...
List all available feeds @param Request $request @return Response
[ "List", "all", "available", "feeds" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2268-L2280
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.listPublication
private function listPublication(Feed $feed, User $user = null) { return [ 'id' => $feed->getId(), 'title' => $feed->getTitle(), 'subtitle' => $feed->getSubtitle(), 'total_entries' => $feed->getCountTotalEntries(), 'icon' => $feed->getIconUrl(), 'public' => $feed->isPublic(), 'readonly' => !$feed->isPublisher($user), 'deletable' => $feed->isOwner($user), 'created_on' => $feed->getCreatedOn()->format(DATE_ATOM), 'updated_on' => $feed->getUpdatedOn()->format(DATE_ATOM), ]; }
php
private function listPublication(Feed $feed, User $user = null) { return [ 'id' => $feed->getId(), 'title' => $feed->getTitle(), 'subtitle' => $feed->getSubtitle(), 'total_entries' => $feed->getCountTotalEntries(), 'icon' => $feed->getIconUrl(), 'public' => $feed->isPublic(), 'readonly' => !$feed->isPublisher($user), 'deletable' => $feed->isOwner($user), 'created_on' => $feed->getCreatedOn()->format(DATE_ATOM), 'updated_on' => $feed->getUpdatedOn()->format(DATE_ATOM), ]; }
[ "private", "function", "listPublication", "(", "Feed", "$", "feed", ",", "User", "$", "user", "=", "null", ")", "{", "return", "[", "'id'", "=>", "$", "feed", "->", "getId", "(", ")", ",", "'title'", "=>", "$", "feed", "->", "getTitle", "(", ")", "...
Retrieve detailed information about one feed @param Feed $feed @param User $user @return array
[ "Retrieve", "detailed", "information", "about", "one", "feed" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2290-L2304
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.listPublicationsEntries
private function listPublicationsEntries(Request $request, FeedInterface $feed, $offset_start = 0, $how_many = 5) { return array_map(function ($entry) use ($request) { return $this->listPublicationEntry($request, $entry); }, $feed->getEntries()->slice($offset_start, $how_many)); }
php
private function listPublicationsEntries(Request $request, FeedInterface $feed, $offset_start = 0, $how_many = 5) { return array_map(function ($entry) use ($request) { return $this->listPublicationEntry($request, $entry); }, $feed->getEntries()->slice($offset_start, $how_many)); }
[ "private", "function", "listPublicationsEntries", "(", "Request", "$", "request", ",", "FeedInterface", "$", "feed", ",", "$", "offset_start", "=", "0", ",", "$", "how_many", "=", "5", ")", "{", "return", "array_map", "(", "function", "(", "$", "entry", ")...
Retrieve all entries of one feed @param Request $request @param FeedInterface $feed @param int $offset_start @param int $how_many @return array
[ "Retrieve", "all", "entries", "of", "one", "feed" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2337-L2342
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.listPublicationEntry
private function listPublicationEntry(Request $request, FeedEntry $entry) { $items = array_map(function ($item) use ($request) { return $this->listPublicationEntryItem($request, $item); }, iterator_to_array($entry->getItems())); return [ 'id' => $entry->getId(), 'author_email' => $entry->getAuthorEmail(), 'author_name' => $entry->getAuthorName(), 'created_on' => $entry->getCreatedOn()->format(DATE_ATOM), 'updated_on' => $entry->getUpdatedOn()->format(DATE_ATOM), 'title' => $entry->getTitle(), 'subtitle' => $entry->getSubtitle(), 'items' => $items, 'feed_id' => $entry->getFeed()->getId(), 'feed_title' => $entry->getFeed()->getTitle(), 'feed_url' => '/feeds/' . $entry->getFeed()->getId() . '/content/', 'url' => '/feeds/entry/' . $entry->getId() . '/', ]; }
php
private function listPublicationEntry(Request $request, FeedEntry $entry) { $items = array_map(function ($item) use ($request) { return $this->listPublicationEntryItem($request, $item); }, iterator_to_array($entry->getItems())); return [ 'id' => $entry->getId(), 'author_email' => $entry->getAuthorEmail(), 'author_name' => $entry->getAuthorName(), 'created_on' => $entry->getCreatedOn()->format(DATE_ATOM), 'updated_on' => $entry->getUpdatedOn()->format(DATE_ATOM), 'title' => $entry->getTitle(), 'subtitle' => $entry->getSubtitle(), 'items' => $items, 'feed_id' => $entry->getFeed()->getId(), 'feed_title' => $entry->getFeed()->getTitle(), 'feed_url' => '/feeds/' . $entry->getFeed()->getId() . '/content/', 'url' => '/feeds/entry/' . $entry->getId() . '/', ]; }
[ "private", "function", "listPublicationEntry", "(", "Request", "$", "request", ",", "FeedEntry", "$", "entry", ")", "{", "$", "items", "=", "array_map", "(", "function", "(", "$", "item", ")", "use", "(", "$", "request", ")", "{", "return", "$", "this", ...
Retrieve detailed information about one feed entry @param Request $request @param FeedEntry $entry @return array
[ "Retrieve", "detailed", "information", "about", "one", "feed", "entry" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2351-L2371
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.listPublicationEntryItem
private function listPublicationEntryItem(Request $request, FeedItem $item) { return [ 'item_id' => $item->getId(), 'record' => $this->listRecord($request, $item->getRecord($this->app)), ]; }
php
private function listPublicationEntryItem(Request $request, FeedItem $item) { return [ 'item_id' => $item->getId(), 'record' => $this->listRecord($request, $item->getRecord($this->app)), ]; }
[ "private", "function", "listPublicationEntryItem", "(", "Request", "$", "request", ",", "FeedItem", "$", "item", ")", "{", "return", "[", "'item_id'", "=>", "$", "item", "->", "getId", "(", ")", ",", "'record'", "=>", "$", "this", "->", "listRecord", "(", ...
Retrieve detailed information about one feed entry item @param Request $request @param FeedItem $item @return array
[ "Retrieve", "detailed", "information", "about", "one", "feed", "entry", "item" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2380-L2386
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.getPublicationAction
public function getPublicationAction(Request $request, $feed_id) { $user = $this->getAuthenticatedUser(); /** @var FeedRepository $repository */ $repository = $this->app['repo.feeds']; /** @var Feed $feed */ $feed = $repository->find($feed_id); if (!$feed->isAccessible($user, $this->app)) { return Result::create($request, [])->createResponse(); } $offset_start = (int) $request->get('offset_start', 0); $per_page = (int) $request->get('per_page', 5); $per_page = (($per_page >= 1) && ($per_page <= 100)) ? $per_page : 100; $data = [ 'feed' => $this->listPublication($feed, $user), 'offset_start' => $offset_start, 'per_page' => $per_page, 'entries' => $this->listPublicationsEntries($request, $feed, $offset_start, $per_page), ]; return Result::create($request, $data)->createResponse(); }
php
public function getPublicationAction(Request $request, $feed_id) { $user = $this->getAuthenticatedUser(); /** @var FeedRepository $repository */ $repository = $this->app['repo.feeds']; /** @var Feed $feed */ $feed = $repository->find($feed_id); if (!$feed->isAccessible($user, $this->app)) { return Result::create($request, [])->createResponse(); } $offset_start = (int) $request->get('offset_start', 0); $per_page = (int) $request->get('per_page', 5); $per_page = (($per_page >= 1) && ($per_page <= 100)) ? $per_page : 100; $data = [ 'feed' => $this->listPublication($feed, $user), 'offset_start' => $offset_start, 'per_page' => $per_page, 'entries' => $this->listPublicationsEntries($request, $feed, $offset_start, $per_page), ]; return Result::create($request, $data)->createResponse(); }
[ "public", "function", "getPublicationAction", "(", "Request", "$", "request", ",", "$", "feed_id", ")", "{", "$", "user", "=", "$", "this", "->", "getAuthenticatedUser", "(", ")", ";", "/** @var FeedRepository $repository */", "$", "repository", "=", "$", "this"...
Retrieve one feed @param Request $request @param int $feed_id @return Response
[ "Retrieve", "one", "feed" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2412-L2437
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.getStoryEmbedAction
public function getStoryEmbedAction(Request $request, $databox_id, $record_id) { $record = $this->findDataboxById($databox_id)->get_record($record_id); $devices = $request->get('devices', []); $mimes = $request->get('mimes', []); $ret = array_values(array_filter(array_map(function ($media) use ($request, $record) { return $this->listEmbeddableMedia($request, $record, $media); }, $record->get_embedable_medias($devices, $mimes)))); return Result::create($request, ["embed" => $ret])->createResponse(); }
php
public function getStoryEmbedAction(Request $request, $databox_id, $record_id) { $record = $this->findDataboxById($databox_id)->get_record($record_id); $devices = $request->get('devices', []); $mimes = $request->get('mimes', []); $ret = array_values(array_filter(array_map(function ($media) use ($request, $record) { return $this->listEmbeddableMedia($request, $record, $media); }, $record->get_embedable_medias($devices, $mimes)))); return Result::create($request, ["embed" => $ret])->createResponse(); }
[ "public", "function", "getStoryEmbedAction", "(", "Request", "$", "request", ",", "$", "databox_id", ",", "$", "record_id", ")", "{", "$", "record", "=", "$", "this", "->", "findDataboxById", "(", "$", "databox_id", ")", "->", "get_record", "(", "$", "reco...
Get a Response containing the story embed files @param Request $request @param int $databox_id @param int $record_id @return Response
[ "Get", "a", "Response", "containing", "the", "story", "embed", "files" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2448-L2460
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.getStoryAction
public function getStoryAction(Request $request, $databox_id, $record_id) { try { $story = $this->findDataboxById($databox_id)->get_record($record_id); return Result::create($request, ['story' => $this->listStory($request, $story)])->createResponse(); } catch (NotFoundHttpException $e) { return Result::createError($request, 404, $this->app->trans('Story Not Found'))->createResponse(); } catch (\Exception $e) { return $this->getBadRequestAction($request, $this->app->trans('An error occurred')); } }
php
public function getStoryAction(Request $request, $databox_id, $record_id) { try { $story = $this->findDataboxById($databox_id)->get_record($record_id); return Result::create($request, ['story' => $this->listStory($request, $story)])->createResponse(); } catch (NotFoundHttpException $e) { return Result::createError($request, 404, $this->app->trans('Story Not Found'))->createResponse(); } catch (\Exception $e) { return $this->getBadRequestAction($request, $this->app->trans('An error occurred')); } }
[ "public", "function", "getStoryAction", "(", "Request", "$", "request", ",", "$", "databox_id", ",", "$", "record_id", ")", "{", "try", "{", "$", "story", "=", "$", "this", "->", "findDataboxById", "(", "$", "databox_id", ")", "->", "get_record", "(", "$...
Return detailed information about one story @param Request $request @param int $databox_id @param int $record_id @return Response
[ "Return", "detailed", "information", "about", "one", "story" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2471-L2482
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.getCurrentUserStructureAction
public function getCurrentUserStructureAction(Request $request) { $ret = [ "meta_fields" => $this->listUserAuthorizedMetadataFields($this->getAuthenticatedUser()), "aggregable_fields" => $this->buildUserFieldList(ElasticsearchOptions::getAggregableTechnicalFields(), ['choices']), "technical_fields" => $this->buildUserFieldList(media_subdef::getTechnicalFieldsList()), ]; return Result::create($request, $ret)->createResponse(); }
php
public function getCurrentUserStructureAction(Request $request) { $ret = [ "meta_fields" => $this->listUserAuthorizedMetadataFields($this->getAuthenticatedUser()), "aggregable_fields" => $this->buildUserFieldList(ElasticsearchOptions::getAggregableTechnicalFields(), ['choices']), "technical_fields" => $this->buildUserFieldList(media_subdef::getTechnicalFieldsList()), ]; return Result::create($request, $ret)->createResponse(); }
[ "public", "function", "getCurrentUserStructureAction", "(", "Request", "$", "request", ")", "{", "$", "ret", "=", "[", "\"meta_fields\"", "=>", "$", "this", "->", "listUserAuthorizedMetadataFields", "(", "$", "this", "->", "getAuthenticatedUser", "(", ")", ")", ...
Returns all documentary fields available for user @param Request $request @return Response
[ "Returns", "all", "documentary", "fields", "available", "for", "user" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2714-L2723
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.getCurrentUserSubdefsAction
public function getCurrentUserSubdefsAction(Request $request) { $ret = [ "subdefs" => $this->listUserAuthorizedSubdefs($this->getAuthenticatedUser()), ]; return Result::create($request, $ret)->createResponse(); }
php
public function getCurrentUserSubdefsAction(Request $request) { $ret = [ "subdefs" => $this->listUserAuthorizedSubdefs($this->getAuthenticatedUser()), ]; return Result::create($request, $ret)->createResponse(); }
[ "public", "function", "getCurrentUserSubdefsAction", "(", "Request", "$", "request", ")", "{", "$", "ret", "=", "[", "\"subdefs\"", "=>", "$", "this", "->", "listUserAuthorizedSubdefs", "(", "$", "this", "->", "getAuthenticatedUser", "(", ")", ")", ",", "]", ...
Returns all sub-definitions available for the user @param Request $request @return Response
[ "Returns", "all", "sub", "-", "definitions", "available", "for", "the", "user" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2730-L2737
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.getCurrentUserCollectionsAction
public function getCurrentUserCollectionsAction(Request $request) { $ret = [ "collections" => $this->listUserAuthorizedCollections($this->getAuthenticatedUser()), ]; return Result::create($request, $ret)->createResponse(); }
php
public function getCurrentUserCollectionsAction(Request $request) { $ret = [ "collections" => $this->listUserAuthorizedCollections($this->getAuthenticatedUser()), ]; return Result::create($request, $ret)->createResponse(); }
[ "public", "function", "getCurrentUserCollectionsAction", "(", "Request", "$", "request", ")", "{", "$", "ret", "=", "[", "\"collections\"", "=>", "$", "this", "->", "listUserAuthorizedCollections", "(", "$", "this", "->", "getAuthenticatedUser", "(", ")", ")", "...
Returns all collections available for the user @param Request $request @return Response
[ "Returns", "all", "collections", "available", "for", "the", "user" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2744-L2750
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.listUserAuthorizedMetadataFields
private function listUserAuthorizedMetadataFields(User $user) { $acl = $this->getAclForUser($user); $ret = []; foreach ($acl->get_granted_sbas() as $databox) { $databoxId = $databox->get_sbas_id(); foreach ($databox->get_meta_structure() as $databox_field) { $data = [ 'name' => $databox_field->get_name(), 'id' => $databox_field->get_id(), 'databox_id' => $databoxId, 'multivalue' => $databox_field->is_multi(), 'indexable' => $databox_field->is_indexable(), 'readonly' => $databox_field->is_readonly(), 'business' => $databox_field->isBusiness(), 'source' => $databox_field->get_tag()->getTagname(), 'labels' => [ 'fr' => $databox_field->get_label('fr'), 'en' => $databox_field->get_label('en'), 'de' => $databox_field->get_label('de'), 'nl' => $databox_field->get_label('nl'), ], ]; $ret[] = $data; } if ($acl->can_see_business_fields($databox) === false) { $ret = array_values($this->removeBusinessFields($ret)); } } return $ret; }
php
private function listUserAuthorizedMetadataFields(User $user) { $acl = $this->getAclForUser($user); $ret = []; foreach ($acl->get_granted_sbas() as $databox) { $databoxId = $databox->get_sbas_id(); foreach ($databox->get_meta_structure() as $databox_field) { $data = [ 'name' => $databox_field->get_name(), 'id' => $databox_field->get_id(), 'databox_id' => $databoxId, 'multivalue' => $databox_field->is_multi(), 'indexable' => $databox_field->is_indexable(), 'readonly' => $databox_field->is_readonly(), 'business' => $databox_field->isBusiness(), 'source' => $databox_field->get_tag()->getTagname(), 'labels' => [ 'fr' => $databox_field->get_label('fr'), 'en' => $databox_field->get_label('en'), 'de' => $databox_field->get_label('de'), 'nl' => $databox_field->get_label('nl'), ], ]; $ret[] = $data; } if ($acl->can_see_business_fields($databox) === false) { $ret = array_values($this->removeBusinessFields($ret)); } } return $ret; }
[ "private", "function", "listUserAuthorizedMetadataFields", "(", "User", "$", "user", ")", "{", "$", "acl", "=", "$", "this", "->", "getAclForUser", "(", "$", "user", ")", ";", "$", "ret", "=", "[", "]", ";", "foreach", "(", "$", "acl", "->", "get_grant...
Returns list of Metadata Fields from the databoxes on which the user has rights @param User $user @return array
[ "Returns", "list", "of", "Metadata", "Fields", "from", "the", "databoxes", "on", "which", "the", "user", "has", "rights" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2757-L2790
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.buildUserFieldList
private function buildUserFieldList(array $fields, array $excludes = []) { $ret = []; foreach ($fields as $key => $field) { $data['name'] = $key; foreach ($field as $k => $i) { if (in_array($k, $excludes)) { continue; } $data[$k] = $i; } $ret[] = $data; } return $ret; }
php
private function buildUserFieldList(array $fields, array $excludes = []) { $ret = []; foreach ($fields as $key => $field) { $data['name'] = $key; foreach ($field as $k => $i) { if (in_array($k, $excludes)) { continue; } $data[$k] = $i; } $ret[] = $data; } return $ret; }
[ "private", "function", "buildUserFieldList", "(", "array", "$", "fields", ",", "array", "$", "excludes", "=", "[", "]", ")", "{", "$", "ret", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "key", "=>", "$", "field", ")", "{", "$", ...
Build the aggregable/technical fields array @param array $fields @param array $excludes @return array
[ "Build", "the", "aggregable", "/", "technical", "fields", "array" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2798-L2817
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.listUserAuthorizedSubdefs
private function listUserAuthorizedSubdefs(User $user) { $acl = $this->getAclForUser($user); $ret = []; foreach ($acl->get_granted_sbas() as $databox) { $databoxId = $databox->get_sbas_id(); $subdefs = $databox->get_subdef_structure(); foreach ($subdefs as $subGroup) { foreach ($subGroup->getIterator() as $sub) { $opt = []; $data = [ 'name' => $sub->get_name(), 'databox_id' => $databoxId, 'class' => $sub->get_class(), 'preset' => $sub->get_preset(), 'downloadable' => $sub->isDownloadable(), 'devices' => $sub->getDevices(), 'labels' => [ 'fr' => $sub->get_label('fr'), 'en' => $sub->get_label('en'), 'de' => $sub->get_label('de'), 'nl' => $sub->get_label('nl'), ], ]; $options = $sub->getOptions(); foreach ($options as $option) { $opt[$option->getName()] = $option->getValue(); } $data['options'] = $opt; $ret[$subGroup->getName()][$sub->get_name()] = $data; } } } return $ret; }
php
private function listUserAuthorizedSubdefs(User $user) { $acl = $this->getAclForUser($user); $ret = []; foreach ($acl->get_granted_sbas() as $databox) { $databoxId = $databox->get_sbas_id(); $subdefs = $databox->get_subdef_structure(); foreach ($subdefs as $subGroup) { foreach ($subGroup->getIterator() as $sub) { $opt = []; $data = [ 'name' => $sub->get_name(), 'databox_id' => $databoxId, 'class' => $sub->get_class(), 'preset' => $sub->get_preset(), 'downloadable' => $sub->isDownloadable(), 'devices' => $sub->getDevices(), 'labels' => [ 'fr' => $sub->get_label('fr'), 'en' => $sub->get_label('en'), 'de' => $sub->get_label('de'), 'nl' => $sub->get_label('nl'), ], ]; $options = $sub->getOptions(); foreach ($options as $option) { $opt[$option->getName()] = $option->getValue(); } $data['options'] = $opt; $ret[$subGroup->getName()][$sub->get_name()] = $data; } } } return $ret; }
[ "private", "function", "listUserAuthorizedSubdefs", "(", "User", "$", "user", ")", "{", "$", "acl", "=", "$", "this", "->", "getAclForUser", "(", "$", "user", ")", ";", "$", "ret", "=", "[", "]", ";", "foreach", "(", "$", "acl", "->", "get_granted_sbas...
Returns list of sub-definitions from the databoxes on which the user has rights @param User $user @return array
[ "Returns", "list", "of", "sub", "-", "definitions", "from", "the", "databoxes", "on", "which", "the", "user", "has", "rights" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2824-L2860
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
V1Controller.listUserAuthorizedCollections
private function listUserAuthorizedCollections(User $user) { $acl = $this->getAclForUser($user); $rights = $acl->get_bas_rights(); $bases = $acl->get_granted_base(); $grants = []; $statusMapper = new RestrictedStatusExtractor($acl, $this->getApplicationBox()); foreach ($bases as $base) { $baseGrants = []; foreach ($rights as $right) { if (!$acl->has_right_on_base($base->get_base_id(), $right)) { continue; } $baseGrants[] = $right; } $grants[] = [ 'databox_id' => $base->get_sbas_id(), 'base_id' => $base->get_base_id(), 'collection_id' => $base->get_coll_id(), 'name' => $base->get_name(), 'logo' => $base->get_binary_minilogos() ? base64_encode($base->get_binary_minilogos()) : '', 'labels' => [ 'fr' => $base->get_label('fr'), 'en' => $base->get_label('en'), 'de' => $base->get_label('de'), 'nl' => $base->get_label('nl'), ], 'rights' => $baseGrants, 'statuses' => $statusMapper->getRestrictedStatuses($base->get_base_id()) ]; } return $grants; }
php
private function listUserAuthorizedCollections(User $user) { $acl = $this->getAclForUser($user); $rights = $acl->get_bas_rights(); $bases = $acl->get_granted_base(); $grants = []; $statusMapper = new RestrictedStatusExtractor($acl, $this->getApplicationBox()); foreach ($bases as $base) { $baseGrants = []; foreach ($rights as $right) { if (!$acl->has_right_on_base($base->get_base_id(), $right)) { continue; } $baseGrants[] = $right; } $grants[] = [ 'databox_id' => $base->get_sbas_id(), 'base_id' => $base->get_base_id(), 'collection_id' => $base->get_coll_id(), 'name' => $base->get_name(), 'logo' => $base->get_binary_minilogos() ? base64_encode($base->get_binary_minilogos()) : '', 'labels' => [ 'fr' => $base->get_label('fr'), 'en' => $base->get_label('en'), 'de' => $base->get_label('de'), 'nl' => $base->get_label('nl'), ], 'rights' => $baseGrants, 'statuses' => $statusMapper->getRestrictedStatuses($base->get_base_id()) ]; } return $grants; }
[ "private", "function", "listUserAuthorizedCollections", "(", "User", "$", "user", ")", "{", "$", "acl", "=", "$", "this", "->", "getAclForUser", "(", "$", "user", ")", ";", "$", "rights", "=", "$", "acl", "->", "get_bas_rights", "(", ")", ";", "$", "ba...
Returns list of collection from the databoxes on which the user has rights @param User $user @return array
[ "Returns", "list", "of", "collection", "from", "the", "databoxes", "on", "which", "the", "user", "has", "rights" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php#L2867-L2906
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Command/Upgrade/Step35.php
Step35.execute
public function execute(InputInterface $input, OutputInterface $output) { foreach ($this->app->getDataboxes() as $databox) { foreach ($databox->get_meta_structure()->get_elements() as $databox_field) { if ($databox_field->is_on_error()) { throw new \Exception(sprintf("Databox description field %s is on error, please fix it before continue</error>", $databox_field->get_name())); } } $this->ensureMigrateColumn($databox); do { $rs = $this->getEmptyOriginalNameRecords($databox); $databox->get_connection()->beginTransaction(); foreach ($rs as $record) { $this->setOriginalName($databox, $record); } $databox->get_connection()->commit(); } while (count($rs) > 0); do { $rs = $this->getRecordsToMigrate($databox); $databox->get_connection()->beginTransaction(); $sql = 'UPDATE record SET migrate35=1 WHERE record_id = :record_id'; $stmt = $databox->get_connection()->prepare($sql); foreach ($rs as $row) { $stmt->execute([':record_id' => $row['record_id']]); try { $record = new \record_adapter($this->app, $databox->get_sbas_id(), $row['record_id']); } catch (\Exception $e) { $this->app['monolog']->addError(sprintf("Unable to load record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $record->get_sbas_id(), $e->getMessage())); continue; } try { $this->updateMetadatas($record, $row['xml']); } catch (\Exception $e) { $this->app['monolog']->addError(sprintf("Error while upgrading metadatas for record %d on databox %d : %s", $record->getRecordId(), $record->getDataboxId(), $e->getMessage())); } try { $record->setStatus($row['status']); } catch (\Exception $e) { $this->app['monolog']->addError(sprintf("Error while upgrading status for record %d on databox %d : %s", $record->getRecordId(), $record->getDataboxId(), $e->getMessage())); } unset($record); } $stmt->closeCursor(); $databox->get_connection()->commit(); } while (count($rs) > 0); } foreach ($this->app->getDataboxes() as $databox) { $this->ensureDropMigrateColumn($databox); } }
php
public function execute(InputInterface $input, OutputInterface $output) { foreach ($this->app->getDataboxes() as $databox) { foreach ($databox->get_meta_structure()->get_elements() as $databox_field) { if ($databox_field->is_on_error()) { throw new \Exception(sprintf("Databox description field %s is on error, please fix it before continue</error>", $databox_field->get_name())); } } $this->ensureMigrateColumn($databox); do { $rs = $this->getEmptyOriginalNameRecords($databox); $databox->get_connection()->beginTransaction(); foreach ($rs as $record) { $this->setOriginalName($databox, $record); } $databox->get_connection()->commit(); } while (count($rs) > 0); do { $rs = $this->getRecordsToMigrate($databox); $databox->get_connection()->beginTransaction(); $sql = 'UPDATE record SET migrate35=1 WHERE record_id = :record_id'; $stmt = $databox->get_connection()->prepare($sql); foreach ($rs as $row) { $stmt->execute([':record_id' => $row['record_id']]); try { $record = new \record_adapter($this->app, $databox->get_sbas_id(), $row['record_id']); } catch (\Exception $e) { $this->app['monolog']->addError(sprintf("Unable to load record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $record->get_sbas_id(), $e->getMessage())); continue; } try { $this->updateMetadatas($record, $row['xml']); } catch (\Exception $e) { $this->app['monolog']->addError(sprintf("Error while upgrading metadatas for record %d on databox %d : %s", $record->getRecordId(), $record->getDataboxId(), $e->getMessage())); } try { $record->setStatus($row['status']); } catch (\Exception $e) { $this->app['monolog']->addError(sprintf("Error while upgrading status for record %d on databox %d : %s", $record->getRecordId(), $record->getDataboxId(), $e->getMessage())); } unset($record); } $stmt->closeCursor(); $databox->get_connection()->commit(); } while (count($rs) > 0); } foreach ($this->app->getDataboxes() as $databox) { $this->ensureDropMigrateColumn($databox); } }
[ "public", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "foreach", "(", "$", "this", "->", "app", "->", "getDataboxes", "(", ")", "as", "$", "databox", ")", "{", "foreach", "(", "$", "databox...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php#L38-L102
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Command/Upgrade/Step35.php
Step35.getTimeEstimation
public function getTimeEstimation() { $time = 0; foreach ($this->app->getDataboxes() as $databox) { $sql = 'select record_id FROM record'; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute(); $time += $stmt->rowCount(); $stmt->closeCursor(); } $time = $time / self::AVERAGE_PER_SECOND; return $time; }
php
public function getTimeEstimation() { $time = 0; foreach ($this->app->getDataboxes() as $databox) { $sql = 'select record_id FROM record'; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute(); $time += $stmt->rowCount(); $stmt->closeCursor(); } $time = $time / self::AVERAGE_PER_SECOND; return $time; }
[ "public", "function", "getTimeEstimation", "(", ")", "{", "$", "time", "=", "0", ";", "foreach", "(", "$", "this", "->", "app", "->", "getDataboxes", "(", ")", "as", "$", "databox", ")", "{", "$", "sql", "=", "'select record_id\n F...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php#L107-L124
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Command/Upgrade/Step35.php
Step35.updateMetadatas
protected function updateMetadatas(\record_adapter $record, $xml) { $metas = $record->getDatabox()->get_meta_structure(); $datas = $metadatas = []; if (false !== $sxe = simplexml_load_string($xml)) { $fields = $sxe->xpath('/record/description'); if ($fields && is_array($fields)) { foreach ($fields[0] as $fieldname => $value) { $fieldname = trim($fieldname); $value = trim($value); if (null === $databox_field = $metas->get_element_by_name($fieldname)) { continue; } if ($databox_field->is_multi()) { $new_value = \caption_field::get_multi_values($value, $databox_field->get_separator()); if (isset($datas[$databox_field->get_id()])) { $value = array_unique(array_merge($datas[$databox_field->get_id()], $new_value)); } else { $value = $new_value; } } else { $new_value = $value; if (isset($datas[$databox_field->get_id()])) { $value = $datas[$databox_field->get_id()] . ' ' . $new_value; } else { $value = $new_value; } } $datas[$databox_field->get_id()] = $value; } } } foreach ($datas as $meta_struct_id => $values) { if (is_array($values)) { foreach ($values as $value) { $metadatas[] = [ 'meta_struct_id' => $meta_struct_id , 'meta_id' => null , 'value' => $value ]; } } else { $metadatas[] = [ 'meta_struct_id' => $meta_struct_id , 'meta_id' => null , 'value' => $values ]; } } $record->set_metadatas($metadatas, true); }
php
protected function updateMetadatas(\record_adapter $record, $xml) { $metas = $record->getDatabox()->get_meta_structure(); $datas = $metadatas = []; if (false !== $sxe = simplexml_load_string($xml)) { $fields = $sxe->xpath('/record/description'); if ($fields && is_array($fields)) { foreach ($fields[0] as $fieldname => $value) { $fieldname = trim($fieldname); $value = trim($value); if (null === $databox_field = $metas->get_element_by_name($fieldname)) { continue; } if ($databox_field->is_multi()) { $new_value = \caption_field::get_multi_values($value, $databox_field->get_separator()); if (isset($datas[$databox_field->get_id()])) { $value = array_unique(array_merge($datas[$databox_field->get_id()], $new_value)); } else { $value = $new_value; } } else { $new_value = $value; if (isset($datas[$databox_field->get_id()])) { $value = $datas[$databox_field->get_id()] . ' ' . $new_value; } else { $value = $new_value; } } $datas[$databox_field->get_id()] = $value; } } } foreach ($datas as $meta_struct_id => $values) { if (is_array($values)) { foreach ($values as $value) { $metadatas[] = [ 'meta_struct_id' => $meta_struct_id , 'meta_id' => null , 'value' => $value ]; } } else { $metadatas[] = [ 'meta_struct_id' => $meta_struct_id , 'meta_id' => null , 'value' => $values ]; } } $record->set_metadatas($metadatas, true); }
[ "protected", "function", "updateMetadatas", "(", "\\", "record_adapter", "$", "record", ",", "$", "xml", ")", "{", "$", "metas", "=", "$", "record", "->", "getDatabox", "(", ")", "->", "get_meta_structure", "(", ")", ";", "$", "datas", "=", "$", "metadat...
Update the metadatas of a record @param \record_adapter $record @param string $xml
[ "Update", "the", "metadatas", "of", "a", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php#L132-L190
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Command/Upgrade/Step35.php
Step35.setOriginalName
protected function setOriginalName(\databox $databox, array $record) { static $stmt; if (!isset($stmt[$databox->get_sbas_id()])) { $sql = 'UPDATE record SET originalname = :originalname WHERE record_id = :record_id'; $stmt[$databox->get_sbas_id()] = $databox->get_connection()->prepare($sql); } $original = ''; if (false !== $sxe = simplexml_load_string($record['xml'])) { foreach ($sxe->doc->attributes() as $key => $value) { if (trim($key) != 'originalname') { continue; } $original = basename(trim($value)); break; } } $stmt[$databox->get_sbas_id()]->execute([':originalname' => $original, ':record_id' => $record['record_id']]); }
php
protected function setOriginalName(\databox $databox, array $record) { static $stmt; if (!isset($stmt[$databox->get_sbas_id()])) { $sql = 'UPDATE record SET originalname = :originalname WHERE record_id = :record_id'; $stmt[$databox->get_sbas_id()] = $databox->get_connection()->prepare($sql); } $original = ''; if (false !== $sxe = simplexml_load_string($record['xml'])) { foreach ($sxe->doc->attributes() as $key => $value) { if (trim($key) != 'originalname') { continue; } $original = basename(trim($value)); break; } } $stmt[$databox->get_sbas_id()]->execute([':originalname' => $original, ':record_id' => $record['record_id']]); }
[ "protected", "function", "setOriginalName", "(", "\\", "databox", "$", "databox", ",", "array", "$", "record", ")", "{", "static", "$", "stmt", ";", "if", "(", "!", "isset", "(", "$", "stmt", "[", "$", "databox", "->", "get_sbas_id", "(", ")", "]", "...
Update the original name of a record @staticvar \PDO_statement $stmt @param \databox $databox @param array $record
[ "Update", "the", "original", "name", "of", "a", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php#L199-L221
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Command/Upgrade/Step35.php
Step35.ensureDropMigrateColumn
protected function ensureDropMigrateColumn(\databox $databox) { $sql = 'ALTER TABLE `record` DROP `migrate35` '; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); }
php
protected function ensureDropMigrateColumn(\databox $databox) { $sql = 'ALTER TABLE `record` DROP `migrate35` '; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); }
[ "protected", "function", "ensureDropMigrateColumn", "(", "\\", "databox", "$", "databox", ")", "{", "$", "sql", "=", "'ALTER TABLE `record` DROP `migrate35` '", ";", "$", "stmt", "=", "$", "databox", "->", "get_connection", "(", ")", "->", "prepare", "(", "$", ...
Removes the migration column @param \databox $databox
[ "Removes", "the", "migration", "column" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php#L268-L274
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Command/Upgrade/Step35.php
Step35.ensureMigrateColumn
protected function ensureMigrateColumn(\databox $databox) { try { $sql = 'ALTER TABLE `record` ADD `migrate35` TINYINT( 1 ) UNSIGNED NOT NULL , ADD INDEX ( `migrate35` ) '; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); } catch (\Exception $e) { } }
php
protected function ensureMigrateColumn(\databox $databox) { try { $sql = 'ALTER TABLE `record` ADD `migrate35` TINYINT( 1 ) UNSIGNED NOT NULL , ADD INDEX ( `migrate35` ) '; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); } catch (\Exception $e) { } }
[ "protected", "function", "ensureMigrateColumn", "(", "\\", "databox", "$", "databox", ")", "{", "try", "{", "$", "sql", "=", "'ALTER TABLE `record`\n ADD `migrate35` TINYINT( 1 ) UNSIGNED NOT NULL ,\n ADD INDEX ( `migrate35` ) '", ";", "$", "...
Add a migration column to the table @param \databox $databox
[ "Add", "a", "migration", "column", "to", "the", "table" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php#L281-L293
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsersController.php
ConnectedUsersController.getModuleNameFromId
public function getModuleNameFromId($appId) { if (null === $this->moduleNames) { $translator = $this->translator; $this->moduleNames = [ '0' => $translator->trans('admin::monitor: module inconnu'), '1' => $translator->trans('admin::monitor: module production'), '2' => $translator->trans('admin::monitor: module client'), '3' => $translator->trans('admin::monitor: module admin'), '4' => $translator->trans('admin::monitor: module report'), '5' => $translator->trans('admin::monitor: module thesaurus'), '6' => $translator->trans('admin::monitor: module comparateur'), '7' => $translator->trans('admin::monitor: module validation'), '8' => $translator->trans('admin::monitor: module upload'), ]; } return isset($this->moduleNames[$appId]) ? $this->moduleNames[$appId] : null; }
php
public function getModuleNameFromId($appId) { if (null === $this->moduleNames) { $translator = $this->translator; $this->moduleNames = [ '0' => $translator->trans('admin::monitor: module inconnu'), '1' => $translator->trans('admin::monitor: module production'), '2' => $translator->trans('admin::monitor: module client'), '3' => $translator->trans('admin::monitor: module admin'), '4' => $translator->trans('admin::monitor: module report'), '5' => $translator->trans('admin::monitor: module thesaurus'), '6' => $translator->trans('admin::monitor: module comparateur'), '7' => $translator->trans('admin::monitor: module validation'), '8' => $translator->trans('admin::monitor: module upload'), ]; } return isset($this->moduleNames[$appId]) ? $this->moduleNames[$appId] : null; }
[ "public", "function", "getModuleNameFromId", "(", "$", "appId", ")", "{", "if", "(", "null", "===", "$", "this", "->", "moduleNames", ")", "{", "$", "translator", "=", "$", "this", "->", "translator", ";", "$", "this", "->", "moduleNames", "=", "[", "'...
Return module name according to its ID @param integer $appId @return string
[ "Return", "module", "name", "according", "to", "its", "ID" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsersController.php#L109-L127
alchemy-fr/Phraseanet
lib/classes/cache/databox.php
cache_databox.refresh
public static function refresh(Application $app, $sbas_id) { if (self::$refreshing) { return; } self::$refreshing = true; $databox = $app->findDataboxById((int) $sbas_id); $date = new \DateTime('-3 seconds'); $last_update = null; try { $last_update = $app->getApplicationBox()->get_data_from_cache('memcached_update_' . $sbas_id); } catch (\Exception $e) { } if ($last_update) $last_update = new \DateTime($last_update); else $last_update = new \DateTime('-10 years'); if ($date <= $last_update) { self::$refreshing = false; return; } $connsbas = $databox->get_connection(); $sql = 'SELECT type, value FROM memcached WHERE site_id = :site_id'; $stmt = $connsbas->prepare($sql); $stmt->execute([':site_id' => $app['conf']->get('servername')]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($rs as $row) { switch ($row['type']) { case 'record': $key = 'record_' . $sbas_id . '_' . $row['value']; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SUBDEFS; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_GROUPING; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_MIME; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_ORIGINAL_NAME; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SHA256; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_TECHNICAL_DATA; $databox->delete_data_from_cache($key); $sql = 'DELETE FROM memcached WHERE site_id = :site_id AND type="record" AND value = :value'; $params = [ ':site_id' => $app['conf']->get('servername') , ':value' => $row['value'] ]; $stmt = $connsbas->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); $record = new \record_adapter($app, $sbas_id, $row['value']); $record->get_caption()->delete_data_from_cache(); foreach ($record->get_subdefs() as $subdef) { $subdef->delete_data_from_cache(); } break; case 'structure': $app->getApplicationBox()->delete_data_from_cache(\appbox::CACHE_LIST_BASES); $sql = 'DELETE FROM memcached WHERE site_id = :site_id AND type="structure" AND value = :value'; $params = [ ':site_id' => $app['conf']->get('servername') , ':value' => $row['value'] ]; $stmt = $connsbas->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); break; } } $date = new \DateTime(); $now = $date->format(DATE_ISO8601); $app->getApplicationBox()->set_data_to_cache($now, 'memcached_update_' . $sbas_id); $conn = $app->getApplicationBox()->get_connection(); $sql = 'UPDATE sitepreff SET memcached_update = :date'; $stmt = $conn->prepare($sql); $stmt->execute([':date' => $now]); $stmt->closeCursor(); self::$refreshing = false; return; }
php
public static function refresh(Application $app, $sbas_id) { if (self::$refreshing) { return; } self::$refreshing = true; $databox = $app->findDataboxById((int) $sbas_id); $date = new \DateTime('-3 seconds'); $last_update = null; try { $last_update = $app->getApplicationBox()->get_data_from_cache('memcached_update_' . $sbas_id); } catch (\Exception $e) { } if ($last_update) $last_update = new \DateTime($last_update); else $last_update = new \DateTime('-10 years'); if ($date <= $last_update) { self::$refreshing = false; return; } $connsbas = $databox->get_connection(); $sql = 'SELECT type, value FROM memcached WHERE site_id = :site_id'; $stmt = $connsbas->prepare($sql); $stmt->execute([':site_id' => $app['conf']->get('servername')]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($rs as $row) { switch ($row['type']) { case 'record': $key = 'record_' . $sbas_id . '_' . $row['value']; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SUBDEFS; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_GROUPING; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_MIME; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_ORIGINAL_NAME; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SHA256; $databox->delete_data_from_cache($key); $key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_TECHNICAL_DATA; $databox->delete_data_from_cache($key); $sql = 'DELETE FROM memcached WHERE site_id = :site_id AND type="record" AND value = :value'; $params = [ ':site_id' => $app['conf']->get('servername') , ':value' => $row['value'] ]; $stmt = $connsbas->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); $record = new \record_adapter($app, $sbas_id, $row['value']); $record->get_caption()->delete_data_from_cache(); foreach ($record->get_subdefs() as $subdef) { $subdef->delete_data_from_cache(); } break; case 'structure': $app->getApplicationBox()->delete_data_from_cache(\appbox::CACHE_LIST_BASES); $sql = 'DELETE FROM memcached WHERE site_id = :site_id AND type="structure" AND value = :value'; $params = [ ':site_id' => $app['conf']->get('servername') , ':value' => $row['value'] ]; $stmt = $connsbas->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); break; } } $date = new \DateTime(); $now = $date->format(DATE_ISO8601); $app->getApplicationBox()->set_data_to_cache($now, 'memcached_update_' . $sbas_id); $conn = $app->getApplicationBox()->get_connection(); $sql = 'UPDATE sitepreff SET memcached_update = :date'; $stmt = $conn->prepare($sql); $stmt->execute([':date' => $now]); $stmt->closeCursor(); self::$refreshing = false; return; }
[ "public", "static", "function", "refresh", "(", "Application", "$", "app", ",", "$", "sbas_id", ")", "{", "if", "(", "self", "::", "$", "refreshing", ")", "{", "return", ";", "}", "self", "::", "$", "refreshing", "=", "true", ";", "$", "databox", "="...
@param Application $app @param int $sbas_id @return cache_databox
[ "@param", "Application", "$app", "@param", "int", "$sbas_id" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/cache/databox.php#L24-L132
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Report/Controller/ApiReportController.php
ApiReportController.rootAction
public function rootAction(Request $request) { $ret = [ 'granted' => $this->reportService->getGranted() ]; $result = Result::create($request, $ret); return $result->createResponse(); }
php
public function rootAction(Request $request) { $ret = [ 'granted' => $this->reportService->getGranted() ]; $result = Result::create($request, $ret); return $result->createResponse(); }
[ "public", "function", "rootAction", "(", "Request", "$", "request", ")", "{", "$", "ret", "=", "[", "'granted'", "=>", "$", "this", "->", "reportService", "->", "getGranted", "(", ")", "]", ";", "$", "result", "=", "Result", "::", "create", "(", "$", ...
route api/report @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "route", "api", "/", "report" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Report/Controller/ApiReportController.php#L54-L63
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Report/Controller/ApiReportController.php
ApiReportController.connectionsAction
public function connectionsAction(Request $request, $sbasId) { /** @var ReportConnections $report */ $report = $this->reportFactory->createReport( ReportFactory::CONNECTIONS, $sbasId, [ 'dmin' => $request->get('dmin'), 'dmax' => $request->get('dmax'), 'group' => $request->get('group'), 'anonymize' => $this->anonymousReport, ] ); $result = Result::create($request, $report->getContent()); return $result->createResponse(); }
php
public function connectionsAction(Request $request, $sbasId) { /** @var ReportConnections $report */ $report = $this->reportFactory->createReport( ReportFactory::CONNECTIONS, $sbasId, [ 'dmin' => $request->get('dmin'), 'dmax' => $request->get('dmax'), 'group' => $request->get('group'), 'anonymize' => $this->anonymousReport, ] ); $result = Result::create($request, $report->getContent()); return $result->createResponse(); }
[ "public", "function", "connectionsAction", "(", "Request", "$", "request", ",", "$", "sbasId", ")", "{", "/** @var ReportConnections $report */", "$", "report", "=", "$", "this", "->", "reportFactory", "->", "createReport", "(", "ReportFactory", "::", "CONNECTIONS",...
route api/report/connections @param Request $request @param $sbasId @return \Symfony\Component\HttpFoundation\Response
[ "route", "api", "/", "report", "/", "connections" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Report/Controller/ApiReportController.php#L72-L89
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Report/Controller/ApiReportController.php
ApiReportController.downloadsAction
public function downloadsAction(Request $request, $sbasId) { /** @var ReportDownloads $report */ $report = $this->reportFactory->createReport( ReportFactory::DOWNLOADS, $sbasId, [ 'dmin' => $request->get('dmin'), 'dmax' => $request->get('dmax'), 'group' => $request->get('group'), 'bases' => $request->get('base'), 'anonymize' => $this->anonymousReport, ] ); $result = Result::create($request, $report->getContent()); return $result->createResponse(); }
php
public function downloadsAction(Request $request, $sbasId) { /** @var ReportDownloads $report */ $report = $this->reportFactory->createReport( ReportFactory::DOWNLOADS, $sbasId, [ 'dmin' => $request->get('dmin'), 'dmax' => $request->get('dmax'), 'group' => $request->get('group'), 'bases' => $request->get('base'), 'anonymize' => $this->anonymousReport, ] ); $result = Result::create($request, $report->getContent()); return $result->createResponse(); }
[ "public", "function", "downloadsAction", "(", "Request", "$", "request", ",", "$", "sbasId", ")", "{", "/** @var ReportDownloads $report */", "$", "report", "=", "$", "this", "->", "reportFactory", "->", "createReport", "(", "ReportFactory", "::", "DOWNLOADS", ","...
route api/report/downloads @param Request $request @param $sbasId @return \Symfony\Component\HttpFoundation\Response
[ "route", "api", "/", "report", "/", "downloads" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Report/Controller/ApiReportController.php#L98-L116
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Report/Controller/ApiReportController.php
ApiReportController.recordsAction
public function recordsAction(Request $request, $sbasId) { /** @var ReportRecords $report */ $report = $this->reportFactory->createReport( ReportFactory::RECORDS, $sbasId, [ 'dmin' => $request->get('dmin'), 'dmax' => $request->get('dmax'), 'group' => $request->get('group'), 'base' => $request->get('base'), 'meta' => $request->get('meta'), ] ); $result = Result::create($request, $report->getContent()); return $result->createResponse(); }
php
public function recordsAction(Request $request, $sbasId) { /** @var ReportRecords $report */ $report = $this->reportFactory->createReport( ReportFactory::RECORDS, $sbasId, [ 'dmin' => $request->get('dmin'), 'dmax' => $request->get('dmax'), 'group' => $request->get('group'), 'base' => $request->get('base'), 'meta' => $request->get('meta'), ] ); $result = Result::create($request, $report->getContent()); return $result->createResponse(); }
[ "public", "function", "recordsAction", "(", "Request", "$", "request", ",", "$", "sbasId", ")", "{", "/** @var ReportRecords $report */", "$", "report", "=", "$", "this", "->", "reportFactory", "->", "createReport", "(", "ReportFactory", "::", "RECORDS", ",", "$...
route api/report/records @param Request $request @param $sbasId @return \Symfony\Component\HttpFoundation\Response
[ "route", "api", "/", "report", "/", "records" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Report/Controller/ApiReportController.php#L125-L143
alchemy-fr/Phraseanet
lib/classes/patch/380alpha11a.php
patch_380alpha11a.apply
public function apply(base $appbox, Application $app) { try { $sql = 'SELECT usr_id, user_agent, ip, platform, browser, app, browser_version, screen, token, nonce, lastaccess, created_on FROM cache'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); } catch (DBALException $e) { // this may fail on oldest versions return false; } foreach ($rs as $row) { if (null === $user = $this->loadUser($app['orm.em'], $row['usr_id'])) { continue; } $created = $updated = null; if ('0000-00-00 00:00:00' !== $row['created_on']) { $created = \DateTime::createFromFormat('Y-m-d H:i:s', $row['created_on']); } if ('0000-00-00 00:00:00' !== $row['lastaccess']) { $updated = \DateTime::createFromFormat('Y-m-d H:i:s', $row['lastaccess']); } $session = new Session(); $session ->setUser($user) ->setUserAgent($row['user_agent']) ->setUpdated($updated) ->setToken($row['token']) ->setPlatform($row['platform']) ->setNonce($row['nonce']) ->setIpAddress($row['ip']) ->setCreated($created) ->setBrowserVersion($row['browser_version']) ->setBrowserName($row['browser']); $sizes = explode ('x', $row['screen']); if (2 === count($sizes)) { $session ->setScreenWidth($sizes[0]) ->setScreenHeight($sizes[1]); } if (false !== $apps = @unserialize($row['app'])) { foreach ($apps as $appli) { $module = new SessionModule(); $module ->setModuleId($appli) ->setCreated($created) ->setSession($session) ->setUpdated($updated); $session->addModule($module); $app['orm.em']->persist($module); } } $app['orm.em']->persist($session); } $app['orm.em']->flush(); return true; }
php
public function apply(base $appbox, Application $app) { try { $sql = 'SELECT usr_id, user_agent, ip, platform, browser, app, browser_version, screen, token, nonce, lastaccess, created_on FROM cache'; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); } catch (DBALException $e) { // this may fail on oldest versions return false; } foreach ($rs as $row) { if (null === $user = $this->loadUser($app['orm.em'], $row['usr_id'])) { continue; } $created = $updated = null; if ('0000-00-00 00:00:00' !== $row['created_on']) { $created = \DateTime::createFromFormat('Y-m-d H:i:s', $row['created_on']); } if ('0000-00-00 00:00:00' !== $row['lastaccess']) { $updated = \DateTime::createFromFormat('Y-m-d H:i:s', $row['lastaccess']); } $session = new Session(); $session ->setUser($user) ->setUserAgent($row['user_agent']) ->setUpdated($updated) ->setToken($row['token']) ->setPlatform($row['platform']) ->setNonce($row['nonce']) ->setIpAddress($row['ip']) ->setCreated($created) ->setBrowserVersion($row['browser_version']) ->setBrowserName($row['browser']); $sizes = explode ('x', $row['screen']); if (2 === count($sizes)) { $session ->setScreenWidth($sizes[0]) ->setScreenHeight($sizes[1]); } if (false !== $apps = @unserialize($row['app'])) { foreach ($apps as $appli) { $module = new SessionModule(); $module ->setModuleId($appli) ->setCreated($created) ->setSession($session) ->setUpdated($updated); $session->addModule($module); $app['orm.em']->persist($module); } } $app['orm.em']->persist($session); } $app['orm.em']->flush(); return true; }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "try", "{", "$", "sql", "=", "'SELECT usr_id, user_agent, ip, platform, browser, app,\n browser_version, screen, token, nonce, lastaccess, created_on\n ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/380alpha11a.php#L60-L130
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php
RecordMoverJob.doJob
protected function doJob(JobData $data) { $app = $data->getApplication(); $settings = simplexml_load_string($data->getTask()->getSettings()); $logsql = (Boolean) $settings->logsql; $tasks = array(); foreach($settings->tasks->task as $task) { $tasks[] = $task; } $data = $this->getData($app, $tasks, $logsql); foreach ($data as $record) { $this->processData($app, $record, $logsql); } }
php
protected function doJob(JobData $data) { $app = $data->getApplication(); $settings = simplexml_load_string($data->getTask()->getSettings()); $logsql = (Boolean) $settings->logsql; $tasks = array(); foreach($settings->tasks->task as $task) { $tasks[] = $task; } $data = $this->getData($app, $tasks, $logsql); foreach ($data as $record) { $this->processData($app, $record, $logsql); } }
[ "protected", "function", "doJob", "(", "JobData", "$", "data", ")", "{", "$", "app", "=", "$", "data", "->", "getApplication", "(", ")", ";", "$", "settings", "=", "simplexml_load_string", "(", "$", "data", "->", "getTask", "(", ")", "->", "getSettings",...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php#L57-L73
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Repositories/ValidationParticipantRepository.php
ValidationParticipantRepository.findNotConfirmedAndNotRemindedParticipantsByExpireDate
public function findNotConfirmedAndNotRemindedParticipantsByExpireDate(\DateTime $expireDate) { $dql = ' SELECT p, s FROM Phraseanet:ValidationParticipant p JOIN p.session s JOIN s.basket b WHERE p.is_confirmed = 0 AND p.reminded IS NULL AND s.expires < :date AND s.expires > CURRENT_TIMESTAMP()'; return $this->_em->createQuery($dql) ->setParameter('date', $expireDate, Type::DATETIME) ->getResult(); }
php
public function findNotConfirmedAndNotRemindedParticipantsByExpireDate(\DateTime $expireDate) { $dql = ' SELECT p, s FROM Phraseanet:ValidationParticipant p JOIN p.session s JOIN s.basket b WHERE p.is_confirmed = 0 AND p.reminded IS NULL AND s.expires < :date AND s.expires > CURRENT_TIMESTAMP()'; return $this->_em->createQuery($dql) ->setParameter('date', $expireDate, Type::DATETIME) ->getResult(); }
[ "public", "function", "findNotConfirmedAndNotRemindedParticipantsByExpireDate", "(", "\\", "DateTime", "$", "expireDate", ")", "{", "$", "dql", "=", "'\n SELECT p, s\n FROM Phraseanet:ValidationParticipant p\n JOIN p.session s\n JOIN s.basket b\n...
Retrieve all not reminded participants where the validation has not expired @param $expireDate The expiration Date @return ValidationParticipant[]
[ "Retrieve", "all", "not", "reminded", "participants", "where", "the", "validation", "has", "not", "expired" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Repositories/ValidationParticipantRepository.php#L27-L41
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.checkClientCredentials
protected function checkClientCredentials($clientId, $clientSecret = null) { if (null === $application = $this->app['repo.api-applications']->findByClientId($clientId)) { return false; } if (null === $clientSecret) { return true; } return $application->getClientSecret() === $clientSecret; }
php
protected function checkClientCredentials($clientId, $clientSecret = null) { if (null === $application = $this->app['repo.api-applications']->findByClientId($clientId)) { return false; } if (null === $clientSecret) { return true; } return $application->getClientSecret() === $clientSecret; }
[ "protected", "function", "checkClientCredentials", "(", "$", "clientId", ",", "$", "clientSecret", "=", "null", ")", "{", "if", "(", "null", "===", "$", "application", "=", "$", "this", "->", "app", "[", "'repo.api-applications'", "]", "->", "findByClientId", ...
Implements OAuth2::checkClientCredentials(). @param string $clientId @param string $clientSecret @return bool
[ "Implements", "OAuth2", "::", "checkClientCredentials", "()", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L142-L153
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.getRedirectUri
protected function getRedirectUri($clientId) { if (null === $application = $this->app['repo.api-applications']->findByClientId($clientId)) { throw new BadRequestHttpException(sprintf('Application with client id %s could not be found', $clientId)); } return $application->getRedirectUri(); }
php
protected function getRedirectUri($clientId) { if (null === $application = $this->app['repo.api-applications']->findByClientId($clientId)) { throw new BadRequestHttpException(sprintf('Application with client id %s could not be found', $clientId)); } return $application->getRedirectUri(); }
[ "protected", "function", "getRedirectUri", "(", "$", "clientId", ")", "{", "if", "(", "null", "===", "$", "application", "=", "$", "this", "->", "app", "[", "'repo.api-applications'", "]", "->", "findByClientId", "(", "$", "clientId", ")", ")", "{", "throw...
Implements OAuth2::getRedirectUri(). @param string $clientId @return string @throws RuntimeException
[ "Implements", "OAuth2", "::", "getRedirectUri", "()", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L163-L170
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.getAccessToken
protected function getAccessToken($oauthToken) { if (null === $token = $this->app['repo.api-oauth-tokens']->find($oauthToken)) { return null; } return [ 'scope' => $token->getScope(), 'expires' => $token->getExpires(), 'client_id' => $token->getAccount()->getApplication()->getClientId(), 'session_id' => $token->getSessionId(), 'revoked' => (int) $token->getAccount()->isRevoked(), 'usr_id' => $token->getAccount()->getUser()->getId(), 'oauth_token' => $token->getOauthToken(), ]; }
php
protected function getAccessToken($oauthToken) { if (null === $token = $this->app['repo.api-oauth-tokens']->find($oauthToken)) { return null; } return [ 'scope' => $token->getScope(), 'expires' => $token->getExpires(), 'client_id' => $token->getAccount()->getApplication()->getClientId(), 'session_id' => $token->getSessionId(), 'revoked' => (int) $token->getAccount()->isRevoked(), 'usr_id' => $token->getAccount()->getUser()->getId(), 'oauth_token' => $token->getOauthToken(), ]; }
[ "protected", "function", "getAccessToken", "(", "$", "oauthToken", ")", "{", "if", "(", "null", "===", "$", "token", "=", "$", "this", "->", "app", "[", "'repo.api-oauth-tokens'", "]", "->", "find", "(", "$", "oauthToken", ")", ")", "{", "return", "null"...
Implements OAuth2::getAccessToken(). @param string $oauthToken @return array
[ "Implements", "OAuth2", "::", "getAccessToken", "()", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L178-L193
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.setAccessToken
protected function setAccessToken($oauthToken, $accountId, $expires = null, $scope = null) { if (null === $account = $this->app['repo.api-accounts']->find($accountId)) { throw new RuntimeException(sprintf('Account with id %s is not valid', $accountId)); } $token = $this->app['manipulator.api-oauth-token']->create($account, $expires, $scope); $this->app['manipulator.api-oauth-token']->setOauthToken($token, $oauthToken); return $this; }
php
protected function setAccessToken($oauthToken, $accountId, $expires = null, $scope = null) { if (null === $account = $this->app['repo.api-accounts']->find($accountId)) { throw new RuntimeException(sprintf('Account with id %s is not valid', $accountId)); } $token = $this->app['manipulator.api-oauth-token']->create($account, $expires, $scope); $this->app['manipulator.api-oauth-token']->setOauthToken($token, $oauthToken); return $this; }
[ "protected", "function", "setAccessToken", "(", "$", "oauthToken", ",", "$", "accountId", ",", "$", "expires", "=", "null", ",", "$", "scope", "=", "null", ")", "{", "if", "(", "null", "===", "$", "account", "=", "$", "this", "->", "app", "[", "'repo...
Implements OAuth2::setAccessToken(). @param $oauthToken @param $accountId @param $expires @param null $scope @return $this @throws RuntimeException
[ "Implements", "OAuth2", "::", "setAccessToken", "()", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L205-L214
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.getAuthCode
protected function getAuthCode($code) { if (null === $code = $this->app['repo.api-oauth-codes']->find($code)) { return null; } return [ 'redirect_uri' => $code->getRedirectUri(), 'client_id' => $code->getAccount()->getApplication()->getClientId(), 'expires' => $code->getExpires(), 'account_id' => $code->getAccount()->getId(), ]; }
php
protected function getAuthCode($code) { if (null === $code = $this->app['repo.api-oauth-codes']->find($code)) { return null; } return [ 'redirect_uri' => $code->getRedirectUri(), 'client_id' => $code->getAccount()->getApplication()->getClientId(), 'expires' => $code->getExpires(), 'account_id' => $code->getAccount()->getId(), ]; }
[ "protected", "function", "getAuthCode", "(", "$", "code", ")", "{", "if", "(", "null", "===", "$", "code", "=", "$", "this", "->", "app", "[", "'repo.api-oauth-codes'", "]", "->", "find", "(", "$", "code", ")", ")", "{", "return", "null", ";", "}", ...
Overrides OAuth2::getAuthCode(). @param $code @return array|null
[ "Overrides", "OAuth2", "::", "getAuthCode", "()", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L246-L258
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.setAuthCode
protected function setAuthCode($oauthCode, $accountId, $redirectUri, $expires = null, $scope = null) { if (null === $account = $this->app['repo.api-accounts']->find($accountId)) { throw new RuntimeException(sprintf('Account with id %s is not valid', $accountId)); } $code = $this->app['manipulator.api-oauth-code']->create($account, $redirectUri, $expires, $scope); $this->app['manipulator.api-oauth-code']->setCode($code, $oauthCode); return $this; }
php
protected function setAuthCode($oauthCode, $accountId, $redirectUri, $expires = null, $scope = null) { if (null === $account = $this->app['repo.api-accounts']->find($accountId)) { throw new RuntimeException(sprintf('Account with id %s is not valid', $accountId)); } $code = $this->app['manipulator.api-oauth-code']->create($account, $redirectUri, $expires, $scope); $this->app['manipulator.api-oauth-code']->setCode($code, $oauthCode); return $this; }
[ "protected", "function", "setAuthCode", "(", "$", "oauthCode", ",", "$", "accountId", ",", "$", "redirectUri", ",", "$", "expires", "=", "null", ",", "$", "scope", "=", "null", ")", "{", "if", "(", "null", "===", "$", "account", "=", "$", "this", "->...
Overrides OAuth2::setAuthCode(). @param $oauthCode @param $accountId @param $redirectUri @param $expires @param null $scope @return $this|void @throws RuntimeException
[ "Overrides", "OAuth2", "::", "setAuthCode", "()", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L272-L281
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.setRefreshToken
protected function setRefreshToken($refreshToken, $accountId, $expires, $scope = null) { if (null === $account = $this->app['repo.api-accounts']->find($accountId)) { throw new RuntimeException(sprintf('Account with id %s is not valid', $accountId)); } $token = $this->app['manipulator.api-oauth-refresh-token']->create($account, $expires, $scope); $this->app['manipulator.api-oauth-refresh-token']->setRefreshToken($token, $refreshToken); return $this; }
php
protected function setRefreshToken($refreshToken, $accountId, $expires, $scope = null) { if (null === $account = $this->app['repo.api-accounts']->find($accountId)) { throw new RuntimeException(sprintf('Account with id %s is not valid', $accountId)); } $token = $this->app['manipulator.api-oauth-refresh-token']->create($account, $expires, $scope); $this->app['manipulator.api-oauth-refresh-token']->setRefreshToken($token, $refreshToken); return $this; }
[ "protected", "function", "setRefreshToken", "(", "$", "refreshToken", ",", "$", "accountId", ",", "$", "expires", ",", "$", "scope", "=", "null", ")", "{", "if", "(", "null", "===", "$", "account", "=", "$", "this", "->", "app", "[", "'repo.api-accounts'...
Overrides OAuth2::setRefreshToken(). @param $refreshToken @param $accountId @param $expires @param null $scope @return $this|void @throws RuntimeException
[ "Overrides", "OAuth2", "::", "setRefreshToken", "()", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L294-L303
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.getRefreshToken
protected function getRefreshToken($refreshToken) { if (null === $token = $this->app['repo.api-oauth-refresh-token']->find($refreshToken)) { return null; } return [ 'token' => $token->getRefreshToken(), 'expires' => $token->getExpires(), 'client_id' => $token->getAccount()->getApplication()->getClientId() ]; }
php
protected function getRefreshToken($refreshToken) { if (null === $token = $this->app['repo.api-oauth-refresh-token']->find($refreshToken)) { return null; } return [ 'token' => $token->getRefreshToken(), 'expires' => $token->getExpires(), 'client_id' => $token->getAccount()->getApplication()->getClientId() ]; }
[ "protected", "function", "getRefreshToken", "(", "$", "refreshToken", ")", "{", "if", "(", "null", "===", "$", "token", "=", "$", "this", "->", "app", "[", "'repo.api-oauth-refresh-token'", "]", "->", "find", "(", "$", "refreshToken", ")", ")", "{", "retur...
Overrides OAuth2::getRefreshToken(). @param $refreshToken @return array|null
[ "Overrides", "OAuth2", "::", "getRefreshToken", "()", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L312-L323
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.unsetRefreshToken
protected function unsetRefreshToken($refreshToken) { if (null !== $token = $this->app['repo.api-oauth-refresh-token']->find($refreshToken)) { $this->app['manipulator.api-oauth-refresh-token']->delete($token); } return $this; }
php
protected function unsetRefreshToken($refreshToken) { if (null !== $token = $this->app['repo.api-oauth-refresh-token']->find($refreshToken)) { $this->app['manipulator.api-oauth-refresh-token']->delete($token); } return $this; }
[ "protected", "function", "unsetRefreshToken", "(", "$", "refreshToken", ")", "{", "if", "(", "null", "!==", "$", "token", "=", "$", "this", "->", "app", "[", "'repo.api-oauth-refresh-token'", "]", "->", "find", "(", "$", "refreshToken", ")", ")", "{", "$",...
Overrides OAuth2::unsetRefreshToken(). @param $refreshToken @return $this|void
[ "Overrides", "OAuth2", "::", "unsetRefreshToken", "()", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L332-L339
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.updateAccount
public function updateAccount(User $user) { if ($this->client === null) { throw new LogicException("Client property must be set before update an account"); } if (null === $account = $this->app['repo.api-accounts']->findByUserAndApplication($user, $this->client)) { $account = $this->app['manipulator.api-account']->create($this->client, $user, $this->getVariable('api_version', V2::VERSION)); } return $account; }
php
public function updateAccount(User $user) { if ($this->client === null) { throw new LogicException("Client property must be set before update an account"); } if (null === $account = $this->app['repo.api-accounts']->findByUserAndApplication($user, $this->client)) { $account = $this->app['manipulator.api-account']->create($this->client, $user, $this->getVariable('api_version', V2::VERSION)); } return $account; }
[ "public", "function", "updateAccount", "(", "User", "$", "user", ")", "{", "if", "(", "$", "this", "->", "client", "===", "null", ")", "{", "throw", "new", "LogicException", "(", "\"Client property must be set before update an account\"", ")", ";", "}", "if", ...
@param User $user @return mixed @throws LogicException
[ "@param", "User", "$user" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L478-L489
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.finishNativeClientAuthorization
public function finishNativeClientAuthorization($is_authorized, $params = []) { $result = []; $params += ['scope' => null, 'state' => null,]; if ($params['state'] !== null) { $result["query"]["state"] = $params['state'] ; } if ($is_authorized === false) { $result["error"] = OAUTH2_ERROR_USER_DENIED; } else { if ($params['response_type'] === OAUTH2_AUTH_RESPONSE_TYPE_AUTH_CODE) { $result["code"] = $this->createAuthCode($params['account_id'], $params['redirect_uri'], $params['scope']); } if ($params['response_type'] === OAUTH2_AUTH_RESPONSE_TYPE_ACCESS_TOKEN) { $result["error"] = OAUTH2_ERROR_UNSUPPORTED_RESPONSE_TYPE; } } return $result; }
php
public function finishNativeClientAuthorization($is_authorized, $params = []) { $result = []; $params += ['scope' => null, 'state' => null,]; if ($params['state'] !== null) { $result["query"]["state"] = $params['state'] ; } if ($is_authorized === false) { $result["error"] = OAUTH2_ERROR_USER_DENIED; } else { if ($params['response_type'] === OAUTH2_AUTH_RESPONSE_TYPE_AUTH_CODE) { $result["code"] = $this->createAuthCode($params['account_id'], $params['redirect_uri'], $params['scope']); } if ($params['response_type'] === OAUTH2_AUTH_RESPONSE_TYPE_ACCESS_TOKEN) { $result["error"] = OAUTH2_ERROR_UNSUPPORTED_RESPONSE_TYPE; } } return $result; }
[ "public", "function", "finishNativeClientAuthorization", "(", "$", "is_authorized", ",", "$", "params", "=", "[", "]", ")", "{", "$", "result", "=", "[", "]", ";", "$", "params", "+=", "[", "'scope'", "=>", "null", ",", "'state'", "=>", "null", ",", "]...
@param $is_authorized @param array $params @return array
[ "@param", "$is_authorized", "@param", "array", "$params" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L497-L519
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.checkUserCredentials
protected function checkUserCredentials($clientId, $username, $password) { try { if (null === $client = $this->app['repo.api-applications']->findByClientId($clientId)) { return false; } $this->setClient($client); $usrId = $this->app['auth.native']->getUsrId($username, $password, Request::createFromGlobals()); if (!$usrId) { return false; } if (null === $user = $this->app['repo.users']->find($usrId)) { return false; } $account = $this->updateAccount($user); return [ 'redirect_uri' => $this->client->getRedirectUri(), 'client_id' => $this->client->getClientId(), 'account_id' => $account->getId(), ]; } catch (AccountLockedException $e) { return false; } catch (RequireCaptchaException $e) { return false; } catch (\Exception $e) { return false; } }
php
protected function checkUserCredentials($clientId, $username, $password) { try { if (null === $client = $this->app['repo.api-applications']->findByClientId($clientId)) { return false; } $this->setClient($client); $usrId = $this->app['auth.native']->getUsrId($username, $password, Request::createFromGlobals()); if (!$usrId) { return false; } if (null === $user = $this->app['repo.users']->find($usrId)) { return false; } $account = $this->updateAccount($user); return [ 'redirect_uri' => $this->client->getRedirectUri(), 'client_id' => $this->client->getClientId(), 'account_id' => $account->getId(), ]; } catch (AccountLockedException $e) { return false; } catch (RequireCaptchaException $e) { return false; } catch (\Exception $e) { return false; } }
[ "protected", "function", "checkUserCredentials", "(", "$", "clientId", ",", "$", "username", ",", "$", "password", ")", "{", "try", "{", "if", "(", "null", "===", "$", "client", "=", "$", "this", "->", "app", "[", "'repo.api-applications'", "]", "->", "f...
@param $clientId @param $username @param $password @return array|boolean
[ "@param", "$clientId", "@param", "$username", "@param", "$password" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L782-L814
alchemy-fr/Phraseanet
lib/classes/API/OAuth2/Adapter.php
API_OAuth2_Adapter.useTokenHeaderChoice
private function useTokenHeaderChoice($apiTokenHeader) { if ($apiTokenHeader === true) { return Oauth2::TOKEN_ONLY_IN_HEADER; } elseif ($apiTokenHeader === false) { return Oauth2::TOKEN_ONLY_IN_GETPOST; } else { return Oauth2::TOKEN_AUTO_FIND; } }
php
private function useTokenHeaderChoice($apiTokenHeader) { if ($apiTokenHeader === true) { return Oauth2::TOKEN_ONLY_IN_HEADER; } elseif ($apiTokenHeader === false) { return Oauth2::TOKEN_ONLY_IN_GETPOST; } else { return Oauth2::TOKEN_AUTO_FIND; } }
[ "private", "function", "useTokenHeaderChoice", "(", "$", "apiTokenHeader", ")", "{", "if", "(", "$", "apiTokenHeader", "===", "true", ")", "{", "return", "Oauth2", "::", "TOKEN_ONLY_IN_HEADER", ";", "}", "elseif", "(", "$", "apiTokenHeader", "===", "false", ")...
Get the correct constante to call on Oauth2 @param $apiTokenHeader @return string
[ "Get", "the", "correct", "constante", "to", "call", "on", "Oauth2" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/API/OAuth2/Adapter.php#L822-L831
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Core/Provider/AccountServiceProvider.php
AccountServiceProvider.register
public function register(Application $app) { $app['accounts.service'] = $app->share(function () use ($app) { return new AccountService( $app['authentication'], $app['auth.password-encoder'], $app['dispatcher'], $app['orm.em'], $app['model.user-manager'], $app['manipulator.user'], $app['repo.users'] ); }); }
php
public function register(Application $app) { $app['accounts.service'] = $app->share(function () use ($app) { return new AccountService( $app['authentication'], $app['auth.password-encoder'], $app['dispatcher'], $app['orm.em'], $app['model.user-manager'], $app['manipulator.user'], $app['repo.users'] ); }); }
[ "public", "function", "register", "(", "Application", "$", "app", ")", "{", "$", "app", "[", "'accounts.service'", "]", "=", "$", "app", "->", "share", "(", "function", "(", ")", "use", "(", "$", "app", ")", "{", "return", "new", "AccountService", "(",...
Registers services on the given app. This method should only be used to configure services and parameters. It should not get services. @param Application $app An Application instance
[ "Registers", "services", "on", "the", "given", "app", "." ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Provider/AccountServiceProvider.php#L20-L33
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/User/UserNotificationController.php
UserNotificationController.readNotifications
public function readNotifications(Request $request) { if (!$request->isXmlHttpRequest()) { $this->app->abort(400); } try { $this->getEventsManager()->read( explode('_', (string) $request->request->get('notifications')), $this->getAuthenticatedUser()->getId() ); return $this->app->json(['success' => true, 'message' => '']); } catch (\Exception $e) { return $this->app->json(['success' => false, 'message' => $e->getMessage()]); } }
php
public function readNotifications(Request $request) { if (!$request->isXmlHttpRequest()) { $this->app->abort(400); } try { $this->getEventsManager()->read( explode('_', (string) $request->request->get('notifications')), $this->getAuthenticatedUser()->getId() ); return $this->app->json(['success' => true, 'message' => '']); } catch (\Exception $e) { return $this->app->json(['success' => false, 'message' => $e->getMessage()]); } }
[ "public", "function", "readNotifications", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "this", "->", "app", "->", "abort", "(", "400", ")", ";", "}", "try", "{", "$", ...
Set notifications as read @param Request $request @return JsonResponse
[ "Set", "notifications", "as", "read" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/User/UserNotificationController.php#L24-L40
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/User/UserNotificationController.php
UserNotificationController.listNotifications
public function listNotifications(Request $request) { if (!$request->isXmlHttpRequest()) { $this->app->abort(400); } $page = (int) $request->query->get('page', 0); return $this->app->json($this->getEventsManager()->get_notifications_as_array(($page < 0 ? 0 : $page))); }
php
public function listNotifications(Request $request) { if (!$request->isXmlHttpRequest()) { $this->app->abort(400); } $page = (int) $request->query->get('page', 0); return $this->app->json($this->getEventsManager()->get_notifications_as_array(($page < 0 ? 0 : $page))); }
[ "public", "function", "listNotifications", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "this", "->", "app", "->", "abort", "(", "400", ")", ";", "}", "$", "page", "=", ...
Get all notifications @param Request $request @return JsonResponse
[ "Get", "all", "notifications" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/User/UserNotificationController.php#L48-L57
alchemy-fr/Phraseanet
lib/classes/set/selection.php
set_selection.grep_authorized
public function grep_authorized(array $rights = [], array $sbas_rights = []) { $to_remove = []; foreach ($this->get_elements() as $id => $record) { $base_id = $record->getBaseId(); $sbas_id = $record->getDataboxId(); $record_id = $record->getRecordId(); if (! $rights) { if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_hd_grant($record)) { continue; } if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_preview_grant($record)) { continue; } if ( ! $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_access_to_base($base_id)) { $to_remove[] = $id; continue; } } else { foreach ($rights as $right) { if ( ! $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($base_id, $right)) { $to_remove[] = $id; continue; } } foreach ($sbas_rights as $right) { if ( ! $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_sbas($sbas_id, $right)) { $to_remove[] = $id; continue; } } } try { $connsbas = $record->getDatabox()->get_connection(); $sql = 'SELECT record_id FROM record WHERE ((status ^ ' . $this->app->getAclForUser($this->app->getAuthenticatedUser())->get_mask_xor($base_id) . ') & ' . $this->app->getAclForUser($this->app->getAuthenticatedUser())->get_mask_and($base_id) . ')=0 AND record_id = :record_id'; $stmt = $connsbas->prepare($sql); $stmt->execute([':record_id' => $record_id]); $num_rows = $stmt->rowCount(); $stmt->closeCursor(); if ($num_rows == 0) { $to_remove[] = $id; } } catch (\Exception $e) { } } foreach ($to_remove as $id) { $this->offsetUnset($id); } return $this; }
php
public function grep_authorized(array $rights = [], array $sbas_rights = []) { $to_remove = []; foreach ($this->get_elements() as $id => $record) { $base_id = $record->getBaseId(); $sbas_id = $record->getDataboxId(); $record_id = $record->getRecordId(); if (! $rights) { if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_hd_grant($record)) { continue; } if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_preview_grant($record)) { continue; } if ( ! $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_access_to_base($base_id)) { $to_remove[] = $id; continue; } } else { foreach ($rights as $right) { if ( ! $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($base_id, $right)) { $to_remove[] = $id; continue; } } foreach ($sbas_rights as $right) { if ( ! $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_sbas($sbas_id, $right)) { $to_remove[] = $id; continue; } } } try { $connsbas = $record->getDatabox()->get_connection(); $sql = 'SELECT record_id FROM record WHERE ((status ^ ' . $this->app->getAclForUser($this->app->getAuthenticatedUser())->get_mask_xor($base_id) . ') & ' . $this->app->getAclForUser($this->app->getAuthenticatedUser())->get_mask_and($base_id) . ')=0 AND record_id = :record_id'; $stmt = $connsbas->prepare($sql); $stmt->execute([':record_id' => $record_id]); $num_rows = $stmt->rowCount(); $stmt->closeCursor(); if ($num_rows == 0) { $to_remove[] = $id; } } catch (\Exception $e) { } } foreach ($to_remove as $id) { $this->offsetUnset($id); } return $this; }
[ "public", "function", "grep_authorized", "(", "array", "$", "rights", "=", "[", "]", ",", "array", "$", "sbas_rights", "=", "[", "]", ")", "{", "$", "to_remove", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "get_elements", "(", ")", "as", ...
@param array $rights @param array $sbas_rights @return set_selection
[ "@param", "array", "$rights", "@param", "array", "$sbas_rights" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/set/selection.php#L46-L107
alchemy-fr/Phraseanet
lib/classes/set/selection.php
set_selection.load_list
public function load_list(array $lst, $flatten_groupings = false) { foreach ($lst as $basrec) { $basrec = explode('_', $basrec); if (count($basrec) == 2) { try { $record = new record_adapter($this->app, (int) $basrec[0], (int) $basrec[1], $this->get_count()); } catch (\Exception $e) { continue; } if ($record->isStory() && $flatten_groupings === true) { foreach ($record->getChildren() as $rec) { $this->add_element($rec); } } else { $this->add_element($record); } } } return $this; }
php
public function load_list(array $lst, $flatten_groupings = false) { foreach ($lst as $basrec) { $basrec = explode('_', $basrec); if (count($basrec) == 2) { try { $record = new record_adapter($this->app, (int) $basrec[0], (int) $basrec[1], $this->get_count()); } catch (\Exception $e) { continue; } if ($record->isStory() && $flatten_groupings === true) { foreach ($record->getChildren() as $rec) { $this->add_element($rec); } } else { $this->add_element($record); } } } return $this; }
[ "public", "function", "load_list", "(", "array", "$", "lst", ",", "$", "flatten_groupings", "=", "false", ")", "{", "foreach", "(", "$", "lst", "as", "$", "basrec", ")", "{", "$", "basrec", "=", "explode", "(", "'_'", ",", "$", "basrec", ")", ";", ...
@param array $lst @param Boolean $flatten_groupings @return set_selection
[ "@param", "array", "$lst", "@param", "Boolean", "$flatten_groupings" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/set/selection.php#L115-L136
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php
AbstractMail.renderHTML
public function renderHTML() { return $this->app['twig']->render('email-template.html.twig', [ 'phraseanetURL' => $this->getPhraseanetURL(), 'phraseanetTitle' => $this->getPhraseanetTitle(), 'logoUrl' => $this->getLogoUrl(), 'logoText' => $this->getLogoText(), 'subject' => $this->getSubject(), 'senderName' => $this->getEmitter() ? $this->getEmitter()->getName() : null, 'senderMail' => $this->getEmitter() ? $this->getEmitter()->getEmail() : null, 'messageText' => $this->getMessage(), 'expiration' => $this->getExpiration(), 'buttonUrl' => $this->getButtonURL(), 'buttonText' => $this->getButtonText(), 'mailSkin' => $this->getMailSkin(), ]); }
php
public function renderHTML() { return $this->app['twig']->render('email-template.html.twig', [ 'phraseanetURL' => $this->getPhraseanetURL(), 'phraseanetTitle' => $this->getPhraseanetTitle(), 'logoUrl' => $this->getLogoUrl(), 'logoText' => $this->getLogoText(), 'subject' => $this->getSubject(), 'senderName' => $this->getEmitter() ? $this->getEmitter()->getName() : null, 'senderMail' => $this->getEmitter() ? $this->getEmitter()->getEmail() : null, 'messageText' => $this->getMessage(), 'expiration' => $this->getExpiration(), 'buttonUrl' => $this->getButtonURL(), 'buttonText' => $this->getButtonText(), 'mailSkin' => $this->getMailSkin(), ]); }
[ "public", "function", "renderHTML", "(", ")", "{", "return", "$", "this", "->", "app", "[", "'twig'", "]", "->", "render", "(", "'email-template.html.twig'", ",", "[", "'phraseanetURL'", "=>", "$", "this", "->", "getPhraseanetURL", "(", ")", ",", "'phraseane...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php#L50-L66
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php
AbstractMail.create
public static function create(Application $app, ReceiverInterface $receiver, EmitterInterface $emitter = null, $message = null) { return new static($app, $receiver, $emitter, $message); }
php
public static function create(Application $app, ReceiverInterface $receiver, EmitterInterface $emitter = null, $message = null) { return new static($app, $receiver, $emitter, $message); }
[ "public", "static", "function", "create", "(", "Application", "$", "app", ",", "ReceiverInterface", "$", "receiver", ",", "EmitterInterface", "$", "emitter", "=", "null", ",", "$", "message", "=", "null", ")", "{", "return", "new", "static", "(", "$", "app...
Creates an Email @param Application $app @param ReceiverInterface $receiver @param EmitterInterface $emitter @param string $message @return static
[ "Creates", "an", "Email" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php#L210-L213
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/IndexerJob.php
IndexerJob.doJob
protected function doJob(JobData $data) { $app = $data->getApplication(); /** @var Indexer $indexer */ $indexer = $app['elasticsearch.indexer']; foreach($app->getDataboxes() as $databox) { if($app->getApplicationBox()->is_databox_indexable($databox)) { $indexer->indexScheduledRecords($databox); } } }
php
protected function doJob(JobData $data) { $app = $data->getApplication(); /** @var Indexer $indexer */ $indexer = $app['elasticsearch.indexer']; foreach($app->getDataboxes() as $databox) { if($app->getApplicationBox()->is_databox_indexable($databox)) { $indexer->indexScheduledRecords($databox); } } }
[ "protected", "function", "doJob", "(", "JobData", "$", "data", ")", "{", "$", "app", "=", "$", "data", "->", "getApplication", "(", ")", ";", "/** @var Indexer $indexer */", "$", "indexer", "=", "$", "app", "[", "'elasticsearch.indexer'", "]", ";", "foreach"...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/IndexerJob.php#L52-L64
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/ControllerProvider/Prod/Download.php
Download.connect
public function connect(Application $app) { $controllers = $this->createCollection($app); $controllers->before(new OAuthListener(['exit_not_present' => false])); $this->getFirewall($app)->addMandatoryAuthentication($controllers); $controllers->post('/', 'controller.prod.download:checkDownload') ->bind('check_download'); return $controllers; }
php
public function connect(Application $app) { $controllers = $this->createCollection($app); $controllers->before(new OAuthListener(['exit_not_present' => false])); $this->getFirewall($app)->addMandatoryAuthentication($controllers); $controllers->post('/', 'controller.prod.download:checkDownload') ->bind('check_download'); return $controllers; }
[ "public", "function", "connect", "(", "Application", "$", "app", ")", "{", "$", "controllers", "=", "$", "this", "->", "createCollection", "(", "$", "app", ")", ";", "$", "controllers", "->", "before", "(", "new", "OAuthListener", "(", "[", "'exit_not_pres...
{@inheritDoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/ControllerProvider/Prod/Download.php#L42-L52
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Border/MetadataBag.php
MetadataBag.toMetadataArray
public function toMetadataArray(\databox_descriptionStructure $metadatasStructure) { $metas = []; $unicode = new \unicode(); foreach ($metadatasStructure as $databox_field) { if ('' === $databox_field->get_tag()->getTagname()) { // skipping fields without sources continue; } if ($this->containsKey($databox_field->get_tag()->getTagname())) { if ($databox_field->is_multi()) { $values = $this->get($databox_field->get_tag()->getTagname())->getValue()->asArray(); $tmp = []; foreach ($values as $value) { foreach (\caption_field::get_multi_values($value, $databox_field->get_separator()) as $v) { $tmp[] = $v; } } $values = array_unique($tmp); foreach ($values as $value) { $value = $unicode->substituteCtrlCharacters($value, ' '); $value = $unicode->toUTF8($value); if ($databox_field->get_type() == 'date') { $value = $unicode->parseDate($value); } $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null ]; } } else { $value = $this->get($databox_field->get_tag()->getTagname())->getValue()->asString(); $value = $unicode->substituteCtrlCharacters($value, ' '); $value = $unicode->toUTF8($value); if ($databox_field->get_type() == 'date') { $value = $unicode->parseDate($value); } $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null ]; } } } unset($unicode); return $metas; }
php
public function toMetadataArray(\databox_descriptionStructure $metadatasStructure) { $metas = []; $unicode = new \unicode(); foreach ($metadatasStructure as $databox_field) { if ('' === $databox_field->get_tag()->getTagname()) { // skipping fields without sources continue; } if ($this->containsKey($databox_field->get_tag()->getTagname())) { if ($databox_field->is_multi()) { $values = $this->get($databox_field->get_tag()->getTagname())->getValue()->asArray(); $tmp = []; foreach ($values as $value) { foreach (\caption_field::get_multi_values($value, $databox_field->get_separator()) as $v) { $tmp[] = $v; } } $values = array_unique($tmp); foreach ($values as $value) { $value = $unicode->substituteCtrlCharacters($value, ' '); $value = $unicode->toUTF8($value); if ($databox_field->get_type() == 'date') { $value = $unicode->parseDate($value); } $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null ]; } } else { $value = $this->get($databox_field->get_tag()->getTagname())->getValue()->asString(); $value = $unicode->substituteCtrlCharacters($value, ' '); $value = $unicode->toUTF8($value); if ($databox_field->get_type() == 'date') { $value = $unicode->parseDate($value); } $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null ]; } } } unset($unicode); return $metas; }
[ "public", "function", "toMetadataArray", "(", "\\", "databox_descriptionStructure", "$", "metadatasStructure", ")", "{", "$", "metas", "=", "[", "]", ";", "$", "unicode", "=", "new", "\\", "unicode", "(", ")", ";", "foreach", "(", "$", "metadatasStructure", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/MetadataBag.php#L27-L90
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/ControllerProvider/User/Notifications.php
Notifications.connect
public function connect(Application $app) { $controllers = $this->createAuthenticatedCollection($app); $firewall = $this->getFirewall($app); $controllers->before(function () use ($firewall) { $firewall->requireNotGuest(); }); $controllers->get('/', 'controller.user.notifications:listNotifications') ->bind('get_notifications'); $controllers->post('/read/', 'controller.user.notifications:readNotifications') ->bind('set_notifications_readed'); return $controllers; }
php
public function connect(Application $app) { $controllers = $this->createAuthenticatedCollection($app); $firewall = $this->getFirewall($app); $controllers->before(function () use ($firewall) { $firewall->requireNotGuest(); }); $controllers->get('/', 'controller.user.notifications:listNotifications') ->bind('get_notifications'); $controllers->post('/read/', 'controller.user.notifications:readNotifications') ->bind('set_notifications_readed'); return $controllers; }
[ "public", "function", "connect", "(", "Application", "$", "app", ")", "{", "$", "controllers", "=", "$", "this", "->", "createAuthenticatedCollection", "(", "$", "app", ")", ";", "$", "firewall", "=", "$", "this", "->", "getFirewall", "(", "$", "app", ")...
{@inheritDoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/ControllerProvider/User/Notifications.php#L40-L56
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Model/Entities/UsrList.php
UsrList.has
public function has(User $user) { return $this->entries->exists( function ($key, $entry) use ($user) { return $entry->getUser()->getId() === $user->getId(); } ); }
php
public function has(User $user) { return $this->entries->exists( function ($key, $entry) use ($user) { return $entry->getUser()->getId() === $user->getId(); } ); }
[ "public", "function", "has", "(", "User", "$", "user", ")", "{", "return", "$", "this", "->", "entries", "->", "exists", "(", "function", "(", "$", "key", ",", "$", "entry", ")", "use", "(", "$", "user", ")", "{", "return", "$", "entry", "->", "g...
Return true if one of the entry is related to the given user @param User $user @return boolean
[ "Return", "true", "if", "one", "of", "the", "entry", "is", "related", "to", "the", "given", "user" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/UsrList.php#L244-L251
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/TaskManager/Job/AbstractJob.php
AbstractJob.doRun
final protected function doRun(JobDataInterface $data) { if (!$data instanceof JobData) { throw new InvalidArgumentException(sprintf('Phraseanet jobs require Phraseanet JobData, got %s.', get_class($data))); } $this->setPauseDuration($data->getTask()->getPeriod()); $this->doJob($data); }
php
final protected function doRun(JobDataInterface $data) { if (!$data instanceof JobData) { throw new InvalidArgumentException(sprintf('Phraseanet jobs require Phraseanet JobData, got %s.', get_class($data))); } $this->setPauseDuration($data->getTask()->getPeriod()); $this->doJob($data); }
[ "final", "protected", "function", "doRun", "(", "JobDataInterface", "$", "data", ")", "{", "if", "(", "!", "$", "data", "instanceof", "JobData", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Phraseanet jobs require Phraseanet JobData, ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/Job/AbstractJob.php#L60-L68
alchemy-fr/Phraseanet
lib/classes/patch/380alpha15a.php
patch_380alpha15a.apply
public function apply(base $appbox, Application $app) { $app['conf']->remove(['binaries', 'composite_binary']); $app['conf']->remove(['binaries', 'convert_binary']); return true; }
php
public function apply(base $appbox, Application $app) { $app['conf']->remove(['binaries', 'composite_binary']); $app['conf']->remove(['binaries', 'convert_binary']); return true; }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "$", "app", "[", "'conf'", "]", "->", "remove", "(", "[", "'binaries'", ",", "'composite_binary'", "]", ")", ";", "$", "app", "[", "'conf'", "]", "->...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/380alpha15a.php#L49-L55
alchemy-fr/Phraseanet
lib/classes/patch/410alpha14a.php
patch_410alpha14a.apply
public function apply(base $databox, Application $app) { $sql = "UPDATE metadatas_structure SET type = 'string' where type = 'text' OR type = '' "; $databox->get_connection()->executeQuery($sql); return true; }
php
public function apply(base $databox, Application $app) { $sql = "UPDATE metadatas_structure SET type = 'string' where type = 'text' OR type = '' "; $databox->get_connection()->executeQuery($sql); return true; }
[ "public", "function", "apply", "(", "base", "$", "databox", ",", "Application", "$", "app", ")", "{", "$", "sql", "=", "\"UPDATE metadatas_structure SET type = 'string' where type = 'text' OR type = '' \"", ";", "$", "databox", "->", "get_connection", "(", ")", "->", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/410alpha14a.php#L57-L63
alchemy-fr/Phraseanet
lib/classes/patch/370alpha1a.php
patch_370alpha1a.apply
public function apply(base $databox, Application $app) { $conn = $databox->get_connection(); $sql = 'SELECT value FROM pref WHERE prop = "structure"'; $stmt = $conn->prepare($sql); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); if (! $result) { throw new \RuntimeException('Unable to find structure'); } $DOMDocument = new DOMDocument(); $DOMDocument->loadXML($result['value']); $XPath = new DOMXPath($DOMDocument); foreach ($XPath->query('/record/subdefs/subdefgroup/subdef/delay') as $delay) { $delay->nodeValue = min(500, max(50, (int) $delay->nodeValue * 400)); } foreach ($XPath->query('/record/subdefs/subdefgroup/subdef/acodc') as $acodec) { if ($acodec->nodeValue == 'faac') { $acodec->nodeValue = 'libvo_aacenc'; } } $sql = 'UPDATE pref SET value = :structure WHERE prop = "structure"'; $stmt = $conn->prepare($sql); $stmt->execute([':structure' => $DOMDocument->saveXML()]); $stmt->closeCursor(); return true; }
php
public function apply(base $databox, Application $app) { $conn = $databox->get_connection(); $sql = 'SELECT value FROM pref WHERE prop = "structure"'; $stmt = $conn->prepare($sql); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); if (! $result) { throw new \RuntimeException('Unable to find structure'); } $DOMDocument = new DOMDocument(); $DOMDocument->loadXML($result['value']); $XPath = new DOMXPath($DOMDocument); foreach ($XPath->query('/record/subdefs/subdefgroup/subdef/delay') as $delay) { $delay->nodeValue = min(500, max(50, (int) $delay->nodeValue * 400)); } foreach ($XPath->query('/record/subdefs/subdefgroup/subdef/acodc') as $acodec) { if ($acodec->nodeValue == 'faac') { $acodec->nodeValue = 'libvo_aacenc'; } } $sql = 'UPDATE pref SET value = :structure WHERE prop = "structure"'; $stmt = $conn->prepare($sql); $stmt->execute([':structure' => $DOMDocument->saveXML()]); $stmt->closeCursor(); return true; }
[ "public", "function", "apply", "(", "base", "$", "databox", ",", "Application", "$", "app", ")", "{", "$", "conn", "=", "$", "databox", "->", "get_connection", "(", ")", ";", "$", "sql", "=", "'SELECT value FROM pref WHERE prop = \"structure\"'", ";", "$", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/370alpha1a.php#L49-L84
alchemy-fr/Phraseanet
lib/classes/patch/390alpha18a.php
patch_390alpha18a.apply
public function apply(base $appbox, Application $app) { $app['orm.em']->getConnection()->executeUpdate(' DELETE lf FROM LazaretFiles lf INNER JOIN LazaretSessions ls ON (ls.id = lf.lazaret_session_id) LEFT JOIN Users u ON (ls.user_id = u.id) WHERE u.id IS NULL' ); $app['orm.em']->getConnection()->executeUpdate(' DELETE ls FROM LazaretSessions AS ls LEFT JOIN Users u ON (ls.user_id = u.id) WHERE u.id IS NULL' ); $app['orm.em']->getConnection()->executeUpdate(' DELETE fi FROM FeedItems AS fi INNER JOIN FeedEntries fe ON (fe.id = fi.entry_id) LEFT JOIN Users u ON (fe.publisher_id = u.id) WHERE u.id IS NULL' ); $app['orm.em']->getConnection()->executeUpdate(' DELETE fe FROM FeedEntries AS fe LEFT JOIN Users u ON (fe.publisher_id = u.id) WHERE u.id IS NULL' ); $app['orm.em']->getConnection()->executeUpdate( 'DELETE se FROM Sessions AS se LEFT JOIN Users u ON (se.user_id = u.id) WHERE u.id IS NULL' ); return true; }
php
public function apply(base $appbox, Application $app) { $app['orm.em']->getConnection()->executeUpdate(' DELETE lf FROM LazaretFiles lf INNER JOIN LazaretSessions ls ON (ls.id = lf.lazaret_session_id) LEFT JOIN Users u ON (ls.user_id = u.id) WHERE u.id IS NULL' ); $app['orm.em']->getConnection()->executeUpdate(' DELETE ls FROM LazaretSessions AS ls LEFT JOIN Users u ON (ls.user_id = u.id) WHERE u.id IS NULL' ); $app['orm.em']->getConnection()->executeUpdate(' DELETE fi FROM FeedItems AS fi INNER JOIN FeedEntries fe ON (fe.id = fi.entry_id) LEFT JOIN Users u ON (fe.publisher_id = u.id) WHERE u.id IS NULL' ); $app['orm.em']->getConnection()->executeUpdate(' DELETE fe FROM FeedEntries AS fe LEFT JOIN Users u ON (fe.publisher_id = u.id) WHERE u.id IS NULL' ); $app['orm.em']->getConnection()->executeUpdate( 'DELETE se FROM Sessions AS se LEFT JOIN Users u ON (se.user_id = u.id) WHERE u.id IS NULL' ); return true; }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "$", "app", "[", "'orm.em'", "]", "->", "getConnection", "(", ")", "->", "executeUpdate", "(", "'\n DELETE lf FROM LazaretFiles lf\n INNER JOIN...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/390alpha18a.php#L57-L92
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php
PhraseanetExtension.getCaptionFieldLabel
public function getCaptionFieldLabel(RecordInterface $record, $fieldName) { if ($record) { /** @var \appbox $appbox */ $appbox = $this->app['phraseanet.appbox']; $databox = $appbox->get_databox($record->getDataboxId()); foreach ($databox->get_meta_structure() as $meta) { /** @var \databox_field $meta */ if ($meta->get_name() === $fieldName) { return $meta->get_label($this->app['locale']); } } } return ''; }
php
public function getCaptionFieldLabel(RecordInterface $record, $fieldName) { if ($record) { /** @var \appbox $appbox */ $appbox = $this->app['phraseanet.appbox']; $databox = $appbox->get_databox($record->getDataboxId()); foreach ($databox->get_meta_structure() as $meta) { /** @var \databox_field $meta */ if ($meta->get_name() === $fieldName) { return $meta->get_label($this->app['locale']); } } } return ''; }
[ "public", "function", "getCaptionFieldLabel", "(", "RecordInterface", "$", "record", ",", "$", "fieldName", ")", "{", "if", "(", "$", "record", ")", "{", "/** @var \\appbox $appbox */", "$", "appbox", "=", "$", "this", "->", "app", "[", "'phraseanet.appbox'", ...
get localized field's label @param RecordInterface $record @param $fieldName @return string - the name label
[ "get", "localized", "field", "s", "label" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php#L63-L78
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php
PhraseanetExtension.isGrantedOnCollection
public function isGrantedOnCollection($baseId, Array $rights) { if (false === ($this->app->getAuthenticatedUser() instanceof User)) { return false; } $acl = $this->app->getAclForUser($this->app->getAuthenticatedUser()); foreach ($rights as $right) { if (! $acl->has_right_on_base($baseId, $right)) { return false; } } return true; }
php
public function isGrantedOnCollection($baseId, Array $rights) { if (false === ($this->app->getAuthenticatedUser() instanceof User)) { return false; } $acl = $this->app->getAclForUser($this->app->getAuthenticatedUser()); foreach ($rights as $right) { if (! $acl->has_right_on_base($baseId, $right)) { return false; } } return true; }
[ "public", "function", "isGrantedOnCollection", "(", "$", "baseId", ",", "Array", "$", "rights", ")", "{", "if", "(", "false", "===", "(", "$", "this", "->", "app", "->", "getAuthenticatedUser", "(", ")", "instanceof", "User", ")", ")", "{", "return", "fa...
returns true if user is authenticated and has all the passed rights on the base todo : wtf $rights is an array since it's never called with more than 1 right in it ? @param $baseId @param array $rights @return bool @throws \Exception
[ "returns", "true", "if", "user", "is", "authenticated", "and", "has", "all", "the", "passed", "rights", "on", "the", "base", "todo", ":", "wtf", "$rights", "is", "an", "array", "since", "it", "s", "never", "called", "with", "more", "than", "1", "right", ...
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php#L193-L209
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Notification/Mail/MailSuccessFTPSender.php
MailSuccessFTPSender.getSubject
public function getSubject() { if (!$this->server) { throw new LogicException('You must set server before calling getSubject'); } return $this->app->trans('task::ftp:Status about your FTP transfert from %application% to %server%', [ '%application%' => $this->getPhraseanetTitle(), '%server%' => $this->server, ]); }
php
public function getSubject() { if (!$this->server) { throw new LogicException('You must set server before calling getSubject'); } return $this->app->trans('task::ftp:Status about your FTP transfert from %application% to %server%', [ '%application%' => $this->getPhraseanetTitle(), '%server%' => $this->server, ]); }
[ "public", "function", "getSubject", "(", ")", "{", "if", "(", "!", "$", "this", "->", "server", ")", "{", "throw", "new", "LogicException", "(", "'You must set server before calling getSubject'", ")", ";", "}", "return", "$", "this", "->", "app", "->", "tran...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessFTPSender.php#L34-L44
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.determine
protected function determine() { $this->checkPlatform(); $this->checkBrowsers(); $this->checkForAol(); $this->checkIP(); $this->checkChromeFrame(); $this->checkNewGeneration(); $this->checkAge(); $this->checkHTML5(); }
php
protected function determine() { $this->checkPlatform(); $this->checkBrowsers(); $this->checkForAol(); $this->checkIP(); $this->checkChromeFrame(); $this->checkNewGeneration(); $this->checkAge(); $this->checkHTML5(); }
[ "protected", "function", "determine", "(", ")", "{", "$", "this", "->", "checkPlatform", "(", ")", ";", "$", "this", "->", "checkBrowsers", "(", ")", ";", "$", "this", "->", "checkForAol", "(", ")", ";", "$", "this", "->", "checkIP", "(", ")", ";", ...
Protected routine to calculate and determine what the browser is in use (including platform)
[ "Protected", "routine", "to", "calculate", "and", "determine", "what", "the", "browser", "is", "in", "use", "(", "including", "platform", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L480-L490
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkChromeFrame
protected function checkChromeFrame() { $this->_chrome_frame = false; if (preg_match('/chromeframe/i', $this->_agent)) { $this->_chrome_frame = true; $aresult = explode('/', stristr($this->_agent, 'chromeframe')); $aversion = explode(' ', $aresult[1]); $chrome_version = explode('.', $aversion[0]); $this->_chrome_frame_version = $chrome_version[0]; } return $this->_chrome_frame; }
php
protected function checkChromeFrame() { $this->_chrome_frame = false; if (preg_match('/chromeframe/i', $this->_agent)) { $this->_chrome_frame = true; $aresult = explode('/', stristr($this->_agent, 'chromeframe')); $aversion = explode(' ', $aresult[1]); $chrome_version = explode('.', $aversion[0]); $this->_chrome_frame_version = $chrome_version[0]; } return $this->_chrome_frame; }
[ "protected", "function", "checkChromeFrame", "(", ")", "{", "$", "this", "->", "_chrome_frame", "=", "false", ";", "if", "(", "preg_match", "(", "'/chromeframe/i'", ",", "$", "this", "->", "_agent", ")", ")", "{", "$", "this", "->", "_chrome_frame", "=", ...
Protected routine to determine if the browser is chrome frame enabled @return boolean True if the browser was detected otherwise false
[ "Protected", "routine", "to", "determine", "if", "the", "browser", "is", "chrome", "frame", "enabled" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L496-L509
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowserGoogleBot
protected function checkBrowserGoogleBot() { if (stripos($this->_agent, 'googlebot') !== false) { $aresult = explode('/', stristr($this->_agent, 'googlebot')); $aversion = explode(' ', $aresult[1]); $this->setVersion(str_replace(';', '', $aversion[0])); $this->_browser_name = self::BROWSER_GOOGLEBOT; $this->setRobot(true); return true; } return false; }
php
protected function checkBrowserGoogleBot() { if (stripos($this->_agent, 'googlebot') !== false) { $aresult = explode('/', stristr($this->_agent, 'googlebot')); $aversion = explode(' ', $aresult[1]); $this->setVersion(str_replace(';', '', $aversion[0])); $this->_browser_name = self::BROWSER_GOOGLEBOT; $this->setRobot(true); return true; } return false; }
[ "protected", "function", "checkBrowserGoogleBot", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'googlebot'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "$", "this", "-...
Determine if the browser is the GoogleBot or not (last updated 1.7) @return boolean True if the browser is the GoogletBot otherwise false
[ "Determine", "if", "the", "browser", "is", "the", "GoogleBot", "or", "not", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L610-L623
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowserMSNBot
protected function checkBrowserMSNBot() { if (stripos($this->_agent, "msnbot") !== false) { $aresult = explode("/", stristr($this->_agent, "msnbot")); $aversion = explode(" ", $aresult[1]); $this->setVersion(str_replace(";", "", $aversion[0])); $this->_browser_name = self::BROWSER_MSNBOT; $this->setRobot(true); return true; } return false; }
php
protected function checkBrowserMSNBot() { if (stripos($this->_agent, "msnbot") !== false) { $aresult = explode("/", stristr($this->_agent, "msnbot")); $aversion = explode(" ", $aresult[1]); $this->setVersion(str_replace(";", "", $aversion[0])); $this->_browser_name = self::BROWSER_MSNBOT; $this->setRobot(true); return true; } return false; }
[ "protected", "function", "checkBrowserMSNBot", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "\"msnbot\"", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "\"/\"", ",", "stristr", "(", "$", "this", "->"...
Determine if the browser is the MSNBot or not (last updated 1.9) @return boolean True if the browser is the MSNBot otherwise false
[ "Determine", "if", "the", "browser", "is", "the", "MSNBot", "or", "not", "(", "last", "updated", "1", ".", "9", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L629-L642
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowserChrome
protected function checkBrowserChrome() { if (stripos($this->_agent, 'Chrome') !== false) { if (preg_match('/chrome\/([\.0-9]+) (mobile)?/i', $this->_agent, $matches)) { $this->setVersion($matches[1]); $this->setBrowser(self::BROWSER_CHROME); if (isset($matches[2])) { $this->setMobile(true); } return true; } } return false; }
php
protected function checkBrowserChrome() { if (stripos($this->_agent, 'Chrome') !== false) { if (preg_match('/chrome\/([\.0-9]+) (mobile)?/i', $this->_agent, $matches)) { $this->setVersion($matches[1]); $this->setBrowser(self::BROWSER_CHROME); if (isset($matches[2])) { $this->setMobile(true); } return true; } } return false; }
[ "protected", "function", "checkBrowserChrome", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'Chrome'", ")", "!==", "false", ")", "{", "if", "(", "preg_match", "(", "'/chrome\\/([\\.0-9]+) (mobile)?/i'", ",", "$", "this", "->",...
Determine if the browser is Chrome or not (last updated 1.7) @return boolean True if the browser is Chrome otherwise false
[ "Determine", "if", "the", "browser", "is", "Chrome", "or", "not", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L799-L814
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowserNetPositive
protected function checkBrowserNetPositive() { if (stripos($this->_agent, 'NetPositive') !== false) { $aresult = explode('/', stristr($this->_agent, 'NetPositive')); $aversion = explode(' ', $aresult[1]); $this->setVersion(str_replace(['(', ')', ';'], '', $aversion[0])); $this->setBrowser(self::BROWSER_NETPOSITIVE); return true; } return false; }
php
protected function checkBrowserNetPositive() { if (stripos($this->_agent, 'NetPositive') !== false) { $aresult = explode('/', stristr($this->_agent, 'NetPositive')); $aversion = explode(' ', $aresult[1]); $this->setVersion(str_replace(['(', ')', ';'], '', $aversion[0])); $this->setBrowser(self::BROWSER_NETPOSITIVE); return true; } return false; }
[ "protected", "function", "checkBrowserNetPositive", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'NetPositive'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "$", "this", ...
Determine if the browser is NetPositive or not (last updated 1.7) @return boolean True if the browser is NetPositive otherwise false
[ "Determine", "if", "the", "browser", "is", "NetPositive", "or", "not", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L838-L850
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowserFirefox
protected function checkBrowserFirefox() { if (stripos($this->_agent, 'safari') === false) { if (preg_match("/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches)) { $this->setVersion($matches[1]); $this->setBrowser(self::BROWSER_FIREFOX); return true; } elseif (preg_match("/Firefox$/i", $this->_agent, $matches)) { $this->setVersion(""); $this->setBrowser(self::BROWSER_FIREFOX); return true; } } return false; }
php
protected function checkBrowserFirefox() { if (stripos($this->_agent, 'safari') === false) { if (preg_match("/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches)) { $this->setVersion($matches[1]); $this->setBrowser(self::BROWSER_FIREFOX); return true; } elseif (preg_match("/Firefox$/i", $this->_agent, $matches)) { $this->setVersion(""); $this->setBrowser(self::BROWSER_FIREFOX); return true; } } return false; }
[ "protected", "function", "checkBrowserFirefox", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'safari'", ")", "===", "false", ")", "{", "if", "(", "preg_match", "(", "\"/Firefox[\\/ \\(]([^ ;\\)]+)/i\"", ",", "$", "this", "->",...
Determine if the browser is Firefox or not (last updated 1.7) @return boolean True if the browser is Firefox otherwise false
[ "Determine", "if", "the", "browser", "is", "Firefox", "or", "not", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1036-L1053
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowserIceweasel
protected function checkBrowserIceweasel() { if (stripos($this->_agent, 'Iceweasel') !== false) { $aresult = explode('/', stristr($this->_agent, 'Iceweasel')); $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_ICEWEASEL); return true; } return false; }
php
protected function checkBrowserIceweasel() { if (stripos($this->_agent, 'Iceweasel') !== false) { $aresult = explode('/', stristr($this->_agent, 'Iceweasel')); $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_ICEWEASEL); return true; } return false; }
[ "protected", "function", "checkBrowserIceweasel", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'Iceweasel'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "$", "this", "-...
Determine if the browser is Firefox or not (last updated 1.7) @return boolean True if the browser is Firefox otherwise false
[ "Determine", "if", "the", "browser", "is", "Firefox", "or", "not", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1059-L1071
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowserMozilla
protected function checkBrowserMozilla() { if (stripos($this->_agent, 'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->_agent) && stripos($this->_agent, 'netscape') === false) { $aversion = explode(' ', stristr($this->_agent, 'rv:')); preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion); $this->setVersion(str_replace('rv:', '', $aversion[0])); $this->setBrowser(self::BROWSER_MOZILLA); return true; } elseif (stripos($this->_agent, 'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i', $this->_agent) && stripos($this->_agent, 'netscape') === false) { $aversion = explode('', stristr($this->_agent, 'rv:')); $this->setVersion(str_replace('rv:', '', $aversion[0])); $this->setBrowser(self::BROWSER_MOZILLA); return true; } elseif (stripos($this->_agent, 'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i', $this->_agent, $matches) && stripos($this->_agent, 'netscape') === false) { $this->setVersion($matches[1]); $this->setBrowser(self::BROWSER_MOZILLA); return true; } return false; }
php
protected function checkBrowserMozilla() { if (stripos($this->_agent, 'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->_agent) && stripos($this->_agent, 'netscape') === false) { $aversion = explode(' ', stristr($this->_agent, 'rv:')); preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion); $this->setVersion(str_replace('rv:', '', $aversion[0])); $this->setBrowser(self::BROWSER_MOZILLA); return true; } elseif (stripos($this->_agent, 'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i', $this->_agent) && stripos($this->_agent, 'netscape') === false) { $aversion = explode('', stristr($this->_agent, 'rv:')); $this->setVersion(str_replace('rv:', '', $aversion[0])); $this->setBrowser(self::BROWSER_MOZILLA); return true; } elseif (stripos($this->_agent, 'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i', $this->_agent, $matches) && stripos($this->_agent, 'netscape') === false) { $this->setVersion($matches[1]); $this->setBrowser(self::BROWSER_MOZILLA); return true; } return false; }
[ "protected", "function", "checkBrowserMozilla", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'mozilla'", ")", "!==", "false", "&&", "preg_match", "(", "'/rv:[0-9].[0-9][a-b]?/i'", ",", "$", "this", "->", "_agent", ")", "&&", ...
Determine if the browser is Mozilla or not (last updated 1.7) @return boolean True if the browser is Mozilla otherwise false
[ "Determine", "if", "the", "browser", "is", "Mozilla", "or", "not", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1077-L1100
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowserLynx
protected function checkBrowserLynx() { if (stripos($this->_agent, 'lynx') !== false) { $aresult = explode('/', stristr($this->_agent, 'Lynx')); $aversion = explode(' ', (isset($aresult[1]) ? $aresult[1] : "")); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_LYNX); return true; } return false; }
php
protected function checkBrowserLynx() { if (stripos($this->_agent, 'lynx') !== false) { $aresult = explode('/', stristr($this->_agent, 'Lynx')); $aversion = explode(' ', (isset($aresult[1]) ? $aresult[1] : "")); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_LYNX); return true; } return false; }
[ "protected", "function", "checkBrowserLynx", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'lynx'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "$", "this", "->", "_ag...
Determine if the browser is Lynx or not (last updated 1.7) @return boolean True if the browser is Lynx otherwise false
[ "Determine", "if", "the", "browser", "is", "Lynx", "or", "not", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1106-L1118
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowserAmaya
protected function checkBrowserAmaya() { if (stripos($this->_agent, 'amaya') !== false) { $aresult = explode('/', stristr($this->_agent, 'Amaya')); $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_AMAYA); return true; } return false; }
php
protected function checkBrowserAmaya() { if (stripos($this->_agent, 'amaya') !== false) { $aresult = explode('/', stristr($this->_agent, 'Amaya')); $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_AMAYA); return true; } return false; }
[ "protected", "function", "checkBrowserAmaya", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'amaya'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "$", "this", "->", "_...
Determine if the browser is Amaya or not (last updated 1.7) @return boolean True if the browser is Amaya otherwise false
[ "Determine", "if", "the", "browser", "is", "Amaya", "or", "not", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1124-L1136
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowseriPhone
protected function checkBrowseriPhone() { if (stripos($this->_agent, 'iPhone') !== false) { $aresult = explode('/', stristr($this->_agent, 'Version')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); } else { $this->setVersion(self::VERSION_UNKNOWN); } $this->setMobile(true); $this->setBrowser(self::BROWSER_IPHONE); return true; } return false; }
php
protected function checkBrowseriPhone() { if (stripos($this->_agent, 'iPhone') !== false) { $aresult = explode('/', stristr($this->_agent, 'Version')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); } else { $this->setVersion(self::VERSION_UNKNOWN); } $this->setMobile(true); $this->setBrowser(self::BROWSER_IPHONE); return true; } return false; }
[ "protected", "function", "checkBrowseriPhone", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'iPhone'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "$", "this", "->", ...
Determine if the browser is iPhone or not (last updated 1.7) @return boolean True if the browser is iPhone otherwise false
[ "Determine", "if", "the", "browser", "is", "iPhone", "or", "not", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1164-L1181
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkBrowseriPod
protected function checkBrowseriPod() { if (stripos($this->_agent, 'iPod') !== false) { $aresult = explode('/', stristr($this->_agent, 'Version')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); } else { $this->setVersion(self::VERSION_UNKNOWN); } $this->setMobile(true); $this->setBrowser(self::BROWSER_IPOD); return true; } return false; }
php
protected function checkBrowseriPod() { if (stripos($this->_agent, 'iPod') !== false) { $aresult = explode('/', stristr($this->_agent, 'Version')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); } else { $this->setVersion(self::VERSION_UNKNOWN); } $this->setMobile(true); $this->setBrowser(self::BROWSER_IPOD); return true; } return false; }
[ "protected", "function", "checkBrowseriPod", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'iPod'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "$", "this", "->", "_ag...
Determine if the browser is iPod or not (last updated 1.7) @return boolean True if the browser is iPod otherwise false
[ "Determine", "if", "the", "browser", "is", "iPod", "or", "not", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1211-L1228
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkPlatform
protected function checkPlatform() { if (stripos($this->_agent, 'windows') !== false) { $this->_platform = self::PLATFORM_WINDOWS; } elseif (stripos($this->_agent, 'iPad') !== false) { $this->_platform = self::PLATFORM_IPAD; } elseif (stripos($this->_agent, 'iPod') !== false) { $this->_platform = self::PLATFORM_IPOD; } elseif (stripos($this->_agent, 'iPhone') !== false) { $this->_platform = self::PLATFORM_IPHONE; } elseif (stripos($this->_agent, 'mac') !== false) { $this->_platform = self::PLATFORM_APPLE; } elseif (stripos($this->_agent, 'android') !== false) { $this->_platform = self::PLATFORM_ANDROID; } elseif (stripos($this->_agent, 'linux') !== false) { $this->_platform = self::PLATFORM_LINUX; } elseif (stripos($this->_agent, 'Nokia') !== false) { $this->_platform = self::PLATFORM_NOKIA; } elseif (stripos($this->_agent, 'BlackBerry') !== false) { $this->_platform = self::PLATFORM_BLACKBERRY; } elseif (stripos($this->_agent, 'FreeBSD') !== false) { $this->_platform = self::PLATFORM_FREEBSD; } elseif (stripos($this->_agent, 'OpenBSD') !== false) { $this->_platform = self::PLATFORM_OPENBSD; } elseif (stripos($this->_agent, 'NetBSD') !== false) { $this->_platform = self::PLATFORM_NETBSD; } elseif (stripos($this->_agent, 'OpenSolaris') !== false) { $this->_platform = self::PLATFORM_OPENSOLARIS; } elseif (stripos($this->_agent, 'SunOS') !== false) { $this->_platform = self::PLATFORM_SUNOS; } elseif (stripos($this->_agent, 'OS\/2') !== false) { $this->_platform = self::PLATFORM_OS2; } elseif (stripos($this->_agent, 'BeOS') !== false) { $this->_platform = self::PLATFORM_BEOS; } elseif (stripos($this->_agent, 'win') !== false) { $this->_platform = self::PLATFORM_WINDOWS; } }
php
protected function checkPlatform() { if (stripos($this->_agent, 'windows') !== false) { $this->_platform = self::PLATFORM_WINDOWS; } elseif (stripos($this->_agent, 'iPad') !== false) { $this->_platform = self::PLATFORM_IPAD; } elseif (stripos($this->_agent, 'iPod') !== false) { $this->_platform = self::PLATFORM_IPOD; } elseif (stripos($this->_agent, 'iPhone') !== false) { $this->_platform = self::PLATFORM_IPHONE; } elseif (stripos($this->_agent, 'mac') !== false) { $this->_platform = self::PLATFORM_APPLE; } elseif (stripos($this->_agent, 'android') !== false) { $this->_platform = self::PLATFORM_ANDROID; } elseif (stripos($this->_agent, 'linux') !== false) { $this->_platform = self::PLATFORM_LINUX; } elseif (stripos($this->_agent, 'Nokia') !== false) { $this->_platform = self::PLATFORM_NOKIA; } elseif (stripos($this->_agent, 'BlackBerry') !== false) { $this->_platform = self::PLATFORM_BLACKBERRY; } elseif (stripos($this->_agent, 'FreeBSD') !== false) { $this->_platform = self::PLATFORM_FREEBSD; } elseif (stripos($this->_agent, 'OpenBSD') !== false) { $this->_platform = self::PLATFORM_OPENBSD; } elseif (stripos($this->_agent, 'NetBSD') !== false) { $this->_platform = self::PLATFORM_NETBSD; } elseif (stripos($this->_agent, 'OpenSolaris') !== false) { $this->_platform = self::PLATFORM_OPENSOLARIS; } elseif (stripos($this->_agent, 'SunOS') !== false) { $this->_platform = self::PLATFORM_SUNOS; } elseif (stripos($this->_agent, 'OS\/2') !== false) { $this->_platform = self::PLATFORM_OS2; } elseif (stripos($this->_agent, 'BeOS') !== false) { $this->_platform = self::PLATFORM_BEOS; } elseif (stripos($this->_agent, 'win') !== false) { $this->_platform = self::PLATFORM_WINDOWS; } }
[ "protected", "function", "checkPlatform", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'windows'", ")", "!==", "false", ")", "{", "$", "this", "->", "_platform", "=", "self", "::", "PLATFORM_WINDOWS", ";", "}", "elseif", ...
Determine the user's platform (last updated 1.7)
[ "Determine", "the", "user", "s", "platform", "(", "last", "updated", "1", ".", "7", ")" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1256-L1293
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkNewGeneration
protected function checkNewGeneration() { $this->_is_new_generation = false; if (in_array($this->_browser_name, ['Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'])) { switch ($this->_browser_name) { case 'Opera': if ($this->_version >= 10) $this->_is_new_generation = true; break; case 'Internet Explorer': if ($this->_version >= 7) $this->_is_new_generation = true; if ($this->_chrome_frame === true && $this->_chrome_frame_version >= 6) $this->_is_new_generation = true; break; case 'Firefox': case 'Iceweasel': if ($this->_version >= 3) $this->_is_new_generation = true; break; case 'Safari': if ($this->_version >= 4) $this->_is_new_generation = true; break; case 'Chrome': if ($this->_version >= 4) $this->_is_new_generation = true; break; case 'iPhone': case 'iPod': $this->_is_new_generation = true; break; } } }
php
protected function checkNewGeneration() { $this->_is_new_generation = false; if (in_array($this->_browser_name, ['Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'])) { switch ($this->_browser_name) { case 'Opera': if ($this->_version >= 10) $this->_is_new_generation = true; break; case 'Internet Explorer': if ($this->_version >= 7) $this->_is_new_generation = true; if ($this->_chrome_frame === true && $this->_chrome_frame_version >= 6) $this->_is_new_generation = true; break; case 'Firefox': case 'Iceweasel': if ($this->_version >= 3) $this->_is_new_generation = true; break; case 'Safari': if ($this->_version >= 4) $this->_is_new_generation = true; break; case 'Chrome': if ($this->_version >= 4) $this->_is_new_generation = true; break; case 'iPhone': case 'iPod': $this->_is_new_generation = true; break; } } }
[ "protected", "function", "checkNewGeneration", "(", ")", "{", "$", "this", "->", "_is_new_generation", "=", "false", ";", "if", "(", "in_array", "(", "$", "this", "->", "_browser_name", ",", "[", "'Opera'", ",", "'Internet Explorer'", ",", "'Firefox'", ",", ...
Check if is new generation
[ "Check", "if", "is", "new", "generation" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1298-L1333
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkHTML5
protected function checkHTML5() { if (in_array($this->_browser_name, ['Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'])) { switch ($this->_browser_name) { case 'Opera': if ($this->_version >= 10) $this->_is_html5 = true; break; case 'Internet Explorer': if ($this->_version >= 9) $this->_is_html5 = true; if ($this->_chrome_frame === true && $this->_chrome_frame_version >= 6) $this->_is_html5 = true; break; case 'Firefox': case 'Iceweasel': if ($this->_version >= 4) $this->_is_html5 = true; break; case 'Safari': if ($this->_version >= 5) $this->_is_html5 = true; break; case 'Chrome': if ($this->_version >= 9) $this->_is_html5 = true; break; case 'iPhone': case 'iPod': $this->_is_html5 = true; break; } } }
php
protected function checkHTML5() { if (in_array($this->_browser_name, ['Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'])) { switch ($this->_browser_name) { case 'Opera': if ($this->_version >= 10) $this->_is_html5 = true; break; case 'Internet Explorer': if ($this->_version >= 9) $this->_is_html5 = true; if ($this->_chrome_frame === true && $this->_chrome_frame_version >= 6) $this->_is_html5 = true; break; case 'Firefox': case 'Iceweasel': if ($this->_version >= 4) $this->_is_html5 = true; break; case 'Safari': if ($this->_version >= 5) $this->_is_html5 = true; break; case 'Chrome': if ($this->_version >= 9) $this->_is_html5 = true; break; case 'iPhone': case 'iPod': $this->_is_html5 = true; break; } } }
[ "protected", "function", "checkHTML5", "(", ")", "{", "if", "(", "in_array", "(", "$", "this", "->", "_browser_name", ",", "[", "'Opera'", ",", "'Internet Explorer'", ",", "'Firefox'", ",", "'Iceweasel'", ",", "'Safari'", ",", "'Chrome'", ",", "'iPhone'", ",...
Check if is HTML5
[ "Check", "if", "is", "HTML5" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1338-L1371
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkAge
protected function checkAge() { $this->_is_old = false; switch ($this->_browser_name) { case 'Opera': if ($this->_version < 10) $this->_is_old = true; break; case 'Firefox': case 'Iceweasel': if ($this->_version < 3) $this->_is_old = true; break; case 'Safari': if ($this->_version < 5) $this->_is_old = true; break; case 'Chrome': if (version_compare($this->_version, 5, '<')) $this->_is_old = true; break; case 'iPhone': case 'iPod': $this->_is_old = true; break; } }
php
protected function checkAge() { $this->_is_old = false; switch ($this->_browser_name) { case 'Opera': if ($this->_version < 10) $this->_is_old = true; break; case 'Firefox': case 'Iceweasel': if ($this->_version < 3) $this->_is_old = true; break; case 'Safari': if ($this->_version < 5) $this->_is_old = true; break; case 'Chrome': if (version_compare($this->_version, 5, '<')) $this->_is_old = true; break; case 'iPhone': case 'iPod': $this->_is_old = true; break; } }
[ "protected", "function", "checkAge", "(", ")", "{", "$", "this", "->", "_is_old", "=", "false", ";", "switch", "(", "$", "this", "->", "_browser_name", ")", "{", "case", "'Opera'", ":", "if", "(", "$", "this", "->", "_version", "<", "10", ")", "$", ...
Check the version of browser
[ "Check", "the", "version", "of", "browser" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1376-L1403
alchemy-fr/Phraseanet
lib/classes/Browser.php
Browser.checkIP
protected function checkIP() { if (getenv("HTTP_CLIENT_IP")) $this->_ip = getenv("HTTP_CLIENT_IP"); elseif (getenv("HTTP_X_FORWARDED_FOR")) $this->_ip = getenv("HTTP_X_FORWARDED_FOR"); else $this->_ip = getenv("REMOTE_ADDR"); }
php
protected function checkIP() { if (getenv("HTTP_CLIENT_IP")) $this->_ip = getenv("HTTP_CLIENT_IP"); elseif (getenv("HTTP_X_FORWARDED_FOR")) $this->_ip = getenv("HTTP_X_FORWARDED_FOR"); else $this->_ip = getenv("REMOTE_ADDR"); }
[ "protected", "function", "checkIP", "(", ")", "{", "if", "(", "getenv", "(", "\"HTTP_CLIENT_IP\"", ")", ")", "$", "this", "->", "_ip", "=", "getenv", "(", "\"HTTP_CLIENT_IP\"", ")", ";", "elseif", "(", "getenv", "(", "\"HTTP_X_FORWARDED_FOR\"", ")", ")", "...
GET the IP address
[ "GET", "the", "IP", "address" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/Browser.php#L1408-L1416
alchemy-fr/Phraseanet
lib/classes/patch/386alpha2a.php
patch_386alpha2a.apply
public function apply(base $appbox, Application $app) { $config = $app['phraseanet.configuration']->getConfig(); $parser = new CrossDomainParser(); try { $crossDomainConfig = $parser->parse($app['root.path'].'/www/crossdomain.xml'); } catch (RuntimeException $e) { $crossDomainConfig = array( 'allow-access-from' => array( array( 'domain' => '*.cooliris.com', 'secure' => 'false', ) ) ); } $config['crossdomain'] = $crossDomainConfig; $app['phraseanet.configuration']->setConfig($config); return true; }
php
public function apply(base $appbox, Application $app) { $config = $app['phraseanet.configuration']->getConfig(); $parser = new CrossDomainParser(); try { $crossDomainConfig = $parser->parse($app['root.path'].'/www/crossdomain.xml'); } catch (RuntimeException $e) { $crossDomainConfig = array( 'allow-access-from' => array( array( 'domain' => '*.cooliris.com', 'secure' => 'false', ) ) ); } $config['crossdomain'] = $crossDomainConfig; $app['phraseanet.configuration']->setConfig($config); return true; }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "$", "config", "=", "$", "app", "[", "'phraseanet.configuration'", "]", "->", "getConfig", "(", ")", ";", "$", "parser", "=", "new", "CrossDomainParser", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/386alpha2a.php#L56-L79
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php
PropertyController.displayStatusProperty
public function displayStatusProperty(Request $request) { if (!$request->isXmlHttpRequest()) { $this->app->abort(400); } $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CHGSTATUS]); $databoxes = $records->databoxes(); if (count($databoxes) > 1) { return new Response($this->render('prod/actions/Property/index.html.twig', [ 'records' => $records, ])); } $databox = reset($databoxes); $statusStructure = $databox->getStatusStructure(); $recordsStatuses = []; foreach ($records->received() as $record) { foreach ($statusStructure as $status) { $bit = $status['bit']; if (!isset($recordsStatuses[$bit])) { $recordsStatuses[$bit] = $status; } $statusSet = \databox_status::bitIsSet($record->getStatusBitField(), $bit); if (!isset($recordsStatuses[$bit]['flag'])) { $recordsStatuses[$bit]['flag'] = (int) $statusSet; } // if flag property was already set and the value is different from the previous one // it means that records share different value for the same flag if ($recordsStatuses[$bit]['flag'] !== (int) $statusSet) { $recordsStatuses[$bit]['flag'] = 2; } } } return new Response($this->render('prod/actions/Property/index.html.twig', [ 'records' => $records, 'status' => $recordsStatuses, ])); }
php
public function displayStatusProperty(Request $request) { if (!$request->isXmlHttpRequest()) { $this->app->abort(400); } $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CHGSTATUS]); $databoxes = $records->databoxes(); if (count($databoxes) > 1) { return new Response($this->render('prod/actions/Property/index.html.twig', [ 'records' => $records, ])); } $databox = reset($databoxes); $statusStructure = $databox->getStatusStructure(); $recordsStatuses = []; foreach ($records->received() as $record) { foreach ($statusStructure as $status) { $bit = $status['bit']; if (!isset($recordsStatuses[$bit])) { $recordsStatuses[$bit] = $status; } $statusSet = \databox_status::bitIsSet($record->getStatusBitField(), $bit); if (!isset($recordsStatuses[$bit]['flag'])) { $recordsStatuses[$bit]['flag'] = (int) $statusSet; } // if flag property was already set and the value is different from the previous one // it means that records share different value for the same flag if ($recordsStatuses[$bit]['flag'] !== (int) $statusSet) { $recordsStatuses[$bit]['flag'] = 2; } } } return new Response($this->render('prod/actions/Property/index.html.twig', [ 'records' => $records, 'status' => $recordsStatuses, ])); }
[ "public", "function", "displayStatusProperty", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "this", "->", "app", "->", "abort", "(", "400", ")", ";", "}", "$", "records", ...
Display Status property @param Request $request @return Response
[ "Display", "Status", "property" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php#L28-L73
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php
PropertyController.displayTypeProperty
public function displayTypeProperty(Request $request) { if (!$request->isXmlHttpRequest()) { $this->app->abort(400); } $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CANMODIFRECORD]); $recordsType = []; foreach ($records as $record) { //perform logic $sbasId = $record->getDataboxId(); if (!isset($recordsType[$sbasId])) { $recordsType[$sbasId] = []; } if (!isset($recordsType[$sbasId][$record->getType()])) { $recordsType[$sbasId][$record->getType()] = []; } $recordsType[$sbasId][$record->getType()][] = $record; } return new Response($this->render('prod/actions/Property/type.html.twig', [ 'records' => $records, 'recordsType' => $recordsType, ])); }
php
public function displayTypeProperty(Request $request) { if (!$request->isXmlHttpRequest()) { $this->app->abort(400); } $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CANMODIFRECORD]); $recordsType = []; foreach ($records as $record) { //perform logic $sbasId = $record->getDataboxId(); if (!isset($recordsType[$sbasId])) { $recordsType[$sbasId] = []; } if (!isset($recordsType[$sbasId][$record->getType()])) { $recordsType[$sbasId][$record->getType()] = []; } $recordsType[$sbasId][$record->getType()][] = $record; } return new Response($this->render('prod/actions/Property/type.html.twig', [ 'records' => $records, 'recordsType' => $recordsType, ])); }
[ "public", "function", "displayTypeProperty", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "this", "->", "app", "->", "abort", "(", "400", ")", ";", "}", "$", "records", "...
Display type property @param Request $request @return Response
[ "Display", "type", "property" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php#L81-L110
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php
PropertyController.changeStatus
public function changeStatus(Request $request) { $applyStatusToChildren = $request->request->get('apply_to_children', []); $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CHGSTATUS]); $updated = []; $postStatus = (array) $request->request->get('status'); foreach ($records as $record) { $sbasId = $record->getDataboxId(); //update record if (null !== $updatedStatus = $this->updateRecordStatus($record, $postStatus)) { $updated[$record->getId()] = $updatedStatus; } //update children if current record is a story if (isset($applyStatusToChildren[$sbasId]) && $record->isStory()) { foreach ($record->getChildren() as $child) { if (null !== $updatedStatus = $this->updateRecordStatus($child, $postStatus)) { $updated[$record->getId()] = $updatedStatus; } } } } return $this->app->json(['success' => true, 'updated' => $updated], 201); }
php
public function changeStatus(Request $request) { $applyStatusToChildren = $request->request->get('apply_to_children', []); $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CHGSTATUS]); $updated = []; $postStatus = (array) $request->request->get('status'); foreach ($records as $record) { $sbasId = $record->getDataboxId(); //update record if (null !== $updatedStatus = $this->updateRecordStatus($record, $postStatus)) { $updated[$record->getId()] = $updatedStatus; } //update children if current record is a story if (isset($applyStatusToChildren[$sbasId]) && $record->isStory()) { foreach ($record->getChildren() as $child) { if (null !== $updatedStatus = $this->updateRecordStatus($child, $postStatus)) { $updated[$record->getId()] = $updatedStatus; } } } } return $this->app->json(['success' => true, 'updated' => $updated], 201); }
[ "public", "function", "changeStatus", "(", "Request", "$", "request", ")", "{", "$", "applyStatusToChildren", "=", "$", "request", "->", "request", "->", "get", "(", "'apply_to_children'", ",", "[", "]", ")", ";", "$", "records", "=", "RecordsRequest", "::",...
Change record status @param Request $request @return Response
[ "Change", "record", "status" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php#L118-L144
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php
PropertyController.changeType
public function changeType(Request $request) { $typeLst = $request->request->get('types', []); $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CANMODIFRECORD]); $mimeLst = $request->request->get('mimes', []); $forceType = $request->request->get('force_types', ''); $updated = []; foreach ($records as $record) { try { $recordType = !empty($forceType) ? $forceType : (isset($typeLst[$record->getId()]) ? $typeLst[$record->getId()] : null); $mimeType = isset($mimeLst[$record->getId()]) ? $mimeLst[$record->getId()] : null; if ($recordType) { $record->setType($recordType); $updated[$record->getId()]['record_type'] = $recordType; } if ($mimeType) { $record->setMimeType($mimeType); $updated[$record->getId()]['mime_type'] = $mimeType; } } catch (\Exception $e) { } } return $this->app->json(['success' => true, 'updated' => $updated], 201); }
php
public function changeType(Request $request) { $typeLst = $request->request->get('types', []); $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CANMODIFRECORD]); $mimeLst = $request->request->get('mimes', []); $forceType = $request->request->get('force_types', ''); $updated = []; foreach ($records as $record) { try { $recordType = !empty($forceType) ? $forceType : (isset($typeLst[$record->getId()]) ? $typeLst[$record->getId()] : null); $mimeType = isset($mimeLst[$record->getId()]) ? $mimeLst[$record->getId()] : null; if ($recordType) { $record->setType($recordType); $updated[$record->getId()]['record_type'] = $recordType; } if ($mimeType) { $record->setMimeType($mimeType); $updated[$record->getId()]['mime_type'] = $mimeType; } } catch (\Exception $e) { } } return $this->app->json(['success' => true, 'updated' => $updated], 201); }
[ "public", "function", "changeType", "(", "Request", "$", "request", ")", "{", "$", "typeLst", "=", "$", "request", "->", "request", "->", "get", "(", "'types'", ",", "[", "]", ")", ";", "$", "records", "=", "RecordsRequest", "::", "fromRequest", "(", "...
Change record type @param Request $request @return Response
[ "Change", "record", "type" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php#L152-L180
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php
PropertyController.updateRecordStatus
private function updateRecordStatus(\record_adapter $record, array $postStatus) { $sbasId = $record->getDataboxId(); if (isset($postStatus[$sbasId]) && is_array($postStatus[$sbasId])) { $postStatus = $postStatus[$sbasId]; $currentStatus = strrev($record->getStatus()); $newStatus = ''; foreach (range(0, 31) as $i) { $newStatus .= isset($postStatus[$i]) ? ($postStatus[$i] ? '1' : '0') : $currentStatus[$i]; } $record->setStatus(strrev($newStatus)); $this->getDataboxLogger($record->getDatabox()) ->log($record, \Session_Logger::EVENT_STATUS, '', ''); return [ 'current_status' => $currentStatus, 'new_status' => $newStatus, ]; } return null; }
php
private function updateRecordStatus(\record_adapter $record, array $postStatus) { $sbasId = $record->getDataboxId(); if (isset($postStatus[$sbasId]) && is_array($postStatus[$sbasId])) { $postStatus = $postStatus[$sbasId]; $currentStatus = strrev($record->getStatus()); $newStatus = ''; foreach (range(0, 31) as $i) { $newStatus .= isset($postStatus[$i]) ? ($postStatus[$i] ? '1' : '0') : $currentStatus[$i]; } $record->setStatus(strrev($newStatus)); $this->getDataboxLogger($record->getDatabox()) ->log($record, \Session_Logger::EVENT_STATUS, '', ''); return [ 'current_status' => $currentStatus, 'new_status' => $newStatus, ]; } return null; }
[ "private", "function", "updateRecordStatus", "(", "\\", "record_adapter", "$", "record", ",", "array", "$", "postStatus", ")", "{", "$", "sbasId", "=", "$", "record", "->", "getDataboxId", "(", ")", ";", "if", "(", "isset", "(", "$", "postStatus", "[", "...
Set new status to selected record @param \record_adapter $record @param array $postStatus @return array|null
[ "Set", "new", "status", "to", "selected", "record" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php#L189-L214
alchemy-fr/Phraseanet
lib/classes/caption/record.php
caption_record.get_fields
public function get_fields(array $grep_fields = null, $includeBusiness = false) { $fields = []; foreach ($this->retrieve_fields() as $meta_struct_id => $field) { if ($grep_fields && ! in_array($field->get_name(), $grep_fields, true)) { continue; } if ((!$includeBusiness) && $field->get_databox_field()->isBusiness() === true) { continue; } $fields[] = $field; } return $fields; }
php
public function get_fields(array $grep_fields = null, $includeBusiness = false) { $fields = []; foreach ($this->retrieve_fields() as $meta_struct_id => $field) { if ($grep_fields && ! in_array($field->get_name(), $grep_fields, true)) { continue; } if ((!$includeBusiness) && $field->get_databox_field()->isBusiness() === true) { continue; } $fields[] = $field; } return $fields; }
[ "public", "function", "get_fields", "(", "array", "$", "grep_fields", "=", "null", ",", "$", "includeBusiness", "=", "false", ")", "{", "$", "fields", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "retrieve_fields", "(", ")", "as", "$", "meta_...
@param array $grep_fields @param bool $includeBusiness @return \caption_field[]
[ "@param", "array", "$grep_fields", "@param", "bool", "$includeBusiness" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/caption/record.php#L84-L101
alchemy-fr/Phraseanet
lib/classes/caption/record.php
caption_record.set_data_to_cache
public function set_data_to_cache($value, $option = null, $duration = 0) { return $this->getDatabox()->set_data_to_cache($value, $this->get_cache_key($option), $duration); }
php
public function set_data_to_cache($value, $option = null, $duration = 0) { return $this->getDatabox()->set_data_to_cache($value, $this->get_cache_key($option), $duration); }
[ "public", "function", "set_data_to_cache", "(", "$", "value", ",", "$", "option", "=", "null", ",", "$", "duration", "=", "0", ")", "{", "return", "$", "this", "->", "getDatabox", "(", ")", "->", "set_data_to_cache", "(", "$", "value", ",", "$", "this"...
Part of the cache_cacheableInterface @param mixed $value @param string $option @param int $duration @return caption_field
[ "Part", "of", "the", "cache_cacheableInterface" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/caption/record.php#L222-L225
alchemy-fr/Phraseanet
lib/classes/caption/record.php
caption_record.delete_data_from_cache
public function delete_data_from_cache($option = null) { $this->fields = null; $this->getDataRepository()->invalidate($this->getRecordReference()->getRecordId()); return $this->getDatabox()->delete_data_from_cache($this->get_cache_key($option)); }
php
public function delete_data_from_cache($option = null) { $this->fields = null; $this->getDataRepository()->invalidate($this->getRecordReference()->getRecordId()); return $this->getDatabox()->delete_data_from_cache($this->get_cache_key($option)); }
[ "public", "function", "delete_data_from_cache", "(", "$", "option", "=", "null", ")", "{", "$", "this", "->", "fields", "=", "null", ";", "$", "this", "->", "getDataRepository", "(", ")", "->", "invalidate", "(", "$", "this", "->", "getRecordReference", "(...
Part of the cache_cacheableInterface @param string $option @return caption_field
[ "Part", "of", "the", "cache_cacheableInterface" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/caption/record.php#L233-L240
alchemy-fr/Phraseanet
lib/classes/patch/381alpha4a.php
patch_381alpha4a.apply
public function apply(base $appbox, Application $app) { $sql = "SELECT usr_id, prop, value FROM usr_settings WHERE prop = 'editing_top_box' OR prop = 'editing_right_box' OR prop = 'editing_left_box'"; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); $sql = 'UPDATE usr_settings SET value = :value WHERE usr_id = :usr_id AND prop = :prop'; $stmt = $appbox->get_connection()->prepare($sql); foreach ($rows as $row) { $value = $row['value']; if ('px' === substr($value, -2)) { $value = 35; } elseif ('%' === substr($value, -1)) { $value = substr($value, 0, -1); } $stmt->execute([':value' => $value, ':usr_id' => $row['usr_id'], ':prop' => $row['prop']]); } $stmt->closeCursor(); return true; }
php
public function apply(base $appbox, Application $app) { $sql = "SELECT usr_id, prop, value FROM usr_settings WHERE prop = 'editing_top_box' OR prop = 'editing_right_box' OR prop = 'editing_left_box'"; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); $sql = 'UPDATE usr_settings SET value = :value WHERE usr_id = :usr_id AND prop = :prop'; $stmt = $appbox->get_connection()->prepare($sql); foreach ($rows as $row) { $value = $row['value']; if ('px' === substr($value, -2)) { $value = 35; } elseif ('%' === substr($value, -1)) { $value = substr($value, 0, -1); } $stmt->execute([':value' => $value, ':usr_id' => $row['usr_id'], ':prop' => $row['prop']]); } $stmt->closeCursor(); return true; }
[ "public", "function", "apply", "(", "base", "$", "appbox", ",", "Application", "$", "app", ")", "{", "$", "sql", "=", "\"SELECT usr_id, prop, value FROM usr_settings\n WHERE prop = 'editing_top_box'\n OR prop = 'editing_right_box'\n OR...
{@inheritdoc}
[ "{" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/381alpha4a.php#L49-L81
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Api/SearchController.php
SearchController.searchAction
public function searchAction(Request $request) { $fractal = new Manager(); $fractal->setSerializer(new ArraySerializer()); $fractal->parseIncludes([]); $searchView = new SearchResultView($this->doSearch($request)); $ret = $fractal->createData(new Item($searchView, new V2SearchTransformer()))->toArray(); return Result::create($request, $ret)->createResponse(); }
php
public function searchAction(Request $request) { $fractal = new Manager(); $fractal->setSerializer(new ArraySerializer()); $fractal->parseIncludes([]); $searchView = new SearchResultView($this->doSearch($request)); $ret = $fractal->createData(new Item($searchView, new V2SearchTransformer()))->toArray(); return Result::create($request, $ret)->createResponse(); }
[ "public", "function", "searchAction", "(", "Request", "$", "request", ")", "{", "$", "fractal", "=", "new", "Manager", "(", ")", ";", "$", "fractal", "->", "setSerializer", "(", "new", "ArraySerializer", "(", ")", ")", ";", "$", "fractal", "->", "parseIn...
Search Records @param Request $request @return Response
[ "Search", "Records" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Api/SearchController.php#L35-L45
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/RecordsRequest.php
RecordsRequest.databoxes
public function databoxes() { if (!$this->databoxes) { $this->databoxes = []; foreach ($this as $record) { if (false === array_key_exists($record->get_databox()->get_sbas_id(), $this->databoxes)) { $this->databoxes[$record->get_databox()->get_sbas_id()] = $record->get_databox(); } } $this->databoxes = array_values($this->databoxes); } return $this->databoxes; }
php
public function databoxes() { if (!$this->databoxes) { $this->databoxes = []; foreach ($this as $record) { if (false === array_key_exists($record->get_databox()->get_sbas_id(), $this->databoxes)) { $this->databoxes[$record->get_databox()->get_sbas_id()] = $record->get_databox(); } } $this->databoxes = array_values($this->databoxes); } return $this->databoxes; }
[ "public", "function", "databoxes", "(", ")", "{", "if", "(", "!", "$", "this", "->", "databoxes", ")", "{", "$", "this", "->", "databoxes", "=", "[", "]", ";", "foreach", "(", "$", "this", "as", "$", "record", ")", "{", "if", "(", "false", "===",...
Return all distinct databoxes related to the contained records @return \databox[]
[ "Return", "all", "distinct", "databoxes", "related", "to", "the", "contained", "records" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/RecordsRequest.php#L79-L94
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/RecordsRequest.php
RecordsRequest.collections
public function collections() { if (!$this->collections) { $this->collections = []; /** @var \record_adapter $record */ foreach ($this as $record) { if (! isset($this->collections[$record->getBaseId()])) { $this->collections[$record->getBaseId()] = $record->get_collection(); } } $this->collections = array_values($this->collections); } return $this->collections; }
php
public function collections() { if (!$this->collections) { $this->collections = []; /** @var \record_adapter $record */ foreach ($this as $record) { if (! isset($this->collections[$record->getBaseId()])) { $this->collections[$record->getBaseId()] = $record->get_collection(); } } $this->collections = array_values($this->collections); } return $this->collections; }
[ "public", "function", "collections", "(", ")", "{", "if", "(", "!", "$", "this", "->", "collections", ")", "{", "$", "this", "->", "collections", "=", "[", "]", ";", "/** @var \\record_adapter $record */", "foreach", "(", "$", "this", "as", "$", "record", ...
Return all distinct collections related to the contained records @return \collection[]
[ "Return", "all", "distinct", "collections", "related", "to", "the", "contained", "records" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/RecordsRequest.php#L101-L117
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/RecordsRequest.php
RecordsRequest.serializedList
public function serializedList() { if ($this->isSingleStory()) { return $this->singleStory()->getId(); } $basrec = []; foreach ($this as $record) { $basrec[] = $record->get_serialize_key(); } return implode(';', $basrec); }
php
public function serializedList() { if ($this->isSingleStory()) { return $this->singleStory()->getId(); } $basrec = []; foreach ($this as $record) { $basrec[] = $record->get_serialize_key(); } return implode(';', $basrec); }
[ "public", "function", "serializedList", "(", ")", "{", "if", "(", "$", "this", "->", "isSingleStory", "(", ")", ")", "{", "return", "$", "this", "->", "singleStory", "(", ")", "->", "getId", "(", ")", ";", "}", "$", "basrec", "=", "[", "]", ";", ...
Return a serialized list of elements @return string
[ "Return", "a", "serialized", "list", "of", "elements" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/RecordsRequest.php#L182-L194
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/RecordsRequest.php
RecordsRequest.fromRequest
public static function fromRequest(Application $app, Request $request, $flattenStories = self::FLATTEN_NO, array $rightsColl = [], array $rightsDatabox = []) { $elements = $received = []; $basket = null; if ($request->get('ssel')) { $basket = $app['converter.basket']->convert($request->get('ssel')); $app['acl.basket']->hasAccess($basket, $app->getAuthenticatedUser()); foreach ($basket->getElements() as $basket_element) { $received[$basket_element->getRecord($app)->getId()] = $basket_element->getRecord($app); } } elseif ($request->get('story')) { $repository = $app['repo.story-wz']; $storyWZ = $repository->findByUserAndId( $app, $app->getAuthenticatedUser(), $request->get('story') ); $received[$storyWZ->getRecord($app)->get_serialize_key()] = $storyWZ->getRecord($app); } else { foreach (explode(";", $request->get('lst')) as $bas_rec) { $basrec = explode('_', $bas_rec); if (count($basrec) != 2) { continue; } try { $record = new \record_adapter($app, (int) $basrec[0], (int) $basrec[1]); $received[$record->getId()] = $record; unset($record); } catch (NotFoundHttpException $e) { continue; } } } $elements = $received; $to_remove = []; foreach ($elements as $id => $record) { if (!$app->getAclForUser($app->getAuthenticatedUser())->has_access_to_record($record)) { $to_remove[] = $id; continue; } foreach ($rightsColl as $right) { if (!$app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($record->get_base_id(), $right)) { $to_remove[] = $id; continue; } } foreach ($rightsDatabox as $right) { if (!$app->getAclForUser($app->getAuthenticatedUser())->has_right_on_sbas($record->get_sbas_id(), $right)) { $to_remove[] = $id; continue; } } } foreach ($to_remove as $id) { unset($elements[$id]); } return new static($elements, new ArrayCollection($received), $basket, $flattenStories); }
php
public static function fromRequest(Application $app, Request $request, $flattenStories = self::FLATTEN_NO, array $rightsColl = [], array $rightsDatabox = []) { $elements = $received = []; $basket = null; if ($request->get('ssel')) { $basket = $app['converter.basket']->convert($request->get('ssel')); $app['acl.basket']->hasAccess($basket, $app->getAuthenticatedUser()); foreach ($basket->getElements() as $basket_element) { $received[$basket_element->getRecord($app)->getId()] = $basket_element->getRecord($app); } } elseif ($request->get('story')) { $repository = $app['repo.story-wz']; $storyWZ = $repository->findByUserAndId( $app, $app->getAuthenticatedUser(), $request->get('story') ); $received[$storyWZ->getRecord($app)->get_serialize_key()] = $storyWZ->getRecord($app); } else { foreach (explode(";", $request->get('lst')) as $bas_rec) { $basrec = explode('_', $bas_rec); if (count($basrec) != 2) { continue; } try { $record = new \record_adapter($app, (int) $basrec[0], (int) $basrec[1]); $received[$record->getId()] = $record; unset($record); } catch (NotFoundHttpException $e) { continue; } } } $elements = $received; $to_remove = []; foreach ($elements as $id => $record) { if (!$app->getAclForUser($app->getAuthenticatedUser())->has_access_to_record($record)) { $to_remove[] = $id; continue; } foreach ($rightsColl as $right) { if (!$app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($record->get_base_id(), $right)) { $to_remove[] = $id; continue; } } foreach ($rightsDatabox as $right) { if (!$app->getAclForUser($app->getAuthenticatedUser())->has_right_on_sbas($record->get_sbas_id(), $right)) { $to_remove[] = $id; continue; } } } foreach ($to_remove as $id) { unset($elements[$id]); } return new static($elements, new ArrayCollection($received), $basket, $flattenStories); }
[ "public", "static", "function", "fromRequest", "(", "Application", "$", "app", ",", "Request", "$", "request", ",", "$", "flattenStories", "=", "self", "::", "FLATTEN_NO", ",", "array", "$", "rightsColl", "=", "[", "]", ",", "array", "$", "rightsDatabox", ...
Create a new RecordRequest from current request @param Application $app @param Request $request @param boolean $flattenStories @param array $rightsColl @param array $rightsDatabox @return RecordsRequest|\record_adapter[]
[ "Create", "a", "new", "RecordRequest", "from", "current", "request" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/RecordsRequest.php#L206-L273
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Admin/DashboardController.php
DashboardController.slash
public function slash(Request $request) { switch ($emailStatus = $request->query->get('email')) { case 'sent'; $emailStatus = $this->app->trans('Mail sent'); break; case 'error': $emailStatus = $this->app->trans('Could not send email'); break; } return $this->render('admin/dashboard.html.twig', [ 'cache_flushed' => $request->query->get('flush_cache') === 'ok', 'admins' => $this->getUserRepository()->findAdmins(), 'email_status' => $emailStatus, ]); }
php
public function slash(Request $request) { switch ($emailStatus = $request->query->get('email')) { case 'sent'; $emailStatus = $this->app->trans('Mail sent'); break; case 'error': $emailStatus = $this->app->trans('Could not send email'); break; } return $this->render('admin/dashboard.html.twig', [ 'cache_flushed' => $request->query->get('flush_cache') === 'ok', 'admins' => $this->getUserRepository()->findAdmins(), 'email_status' => $emailStatus, ]); }
[ "public", "function", "slash", "(", "Request", "$", "request", ")", "{", "switch", "(", "$", "emailStatus", "=", "$", "request", "->", "query", "->", "get", "(", "'email'", ")", ")", "{", "case", "'sent'", ";", "$", "emailStatus", "=", "$", "this", "...
Display admin dashboard page @param Request $request @return string
[ "Display", "admin", "dashboard", "page" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Admin/DashboardController.php#L37-L53
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Admin/DashboardController.php
DashboardController.flush
public function flush() { /** @var Cache $cache */ $cache = $this->app['phraseanet.cache-service']; $flushOK = $cache->flushAll() ? 'ok' : 'ko'; return $this->app->redirectPath('admin_dashboard', ['flush_cache' => $flushOK]); }
php
public function flush() { /** @var Cache $cache */ $cache = $this->app['phraseanet.cache-service']; $flushOK = $cache->flushAll() ? 'ok' : 'ko'; return $this->app->redirectPath('admin_dashboard', ['flush_cache' => $flushOK]); }
[ "public", "function", "flush", "(", ")", "{", "/** @var Cache $cache */", "$", "cache", "=", "$", "this", "->", "app", "[", "'phraseanet.cache-service'", "]", ";", "$", "flushOK", "=", "$", "cache", "->", "flushAll", "(", ")", "?", "'ok'", ":", "'ko'", "...
Flush all cache services @return RedirectResponse
[ "Flush", "all", "cache", "services" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Admin/DashboardController.php#L60-L67
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Admin/DashboardController.php
DashboardController.sendMail
public function sendMail(Request $request) { if (null === $mail = $request->request->get('email')) { $this->app->abort(400, 'Bad request missing email parameter'); }; if (!\Swift_Validate::email($mail)) { $this->app->abort(400, 'Bad request missing email parameter'); }; try { $receiver = new Receiver(null, $mail); } catch (InvalidArgumentException $e) { return $this->app->redirectPath('admin_dashboard', ['email' => 'not-sent']); } $mail = MailTest::create($this->app, $receiver); $this->deliver($mail); /** @var \Swift_SpoolTransport $spoolTransport */ $spoolTransport = $this->app['swiftmailer.spooltransport']; /** @var \Swift_Transport $transport */ $transport = $this->app['swiftmailer.transport']; $spoolTransport->getSpool()->flushQueue($transport); return $this->app->redirectPath('admin_dashboard', ['email' => 'sent']); }
php
public function sendMail(Request $request) { if (null === $mail = $request->request->get('email')) { $this->app->abort(400, 'Bad request missing email parameter'); }; if (!\Swift_Validate::email($mail)) { $this->app->abort(400, 'Bad request missing email parameter'); }; try { $receiver = new Receiver(null, $mail); } catch (InvalidArgumentException $e) { return $this->app->redirectPath('admin_dashboard', ['email' => 'not-sent']); } $mail = MailTest::create($this->app, $receiver); $this->deliver($mail); /** @var \Swift_SpoolTransport $spoolTransport */ $spoolTransport = $this->app['swiftmailer.spooltransport']; /** @var \Swift_Transport $transport */ $transport = $this->app['swiftmailer.transport']; $spoolTransport->getSpool()->flushQueue($transport); return $this->app->redirectPath('admin_dashboard', ['email' => 'sent']); }
[ "public", "function", "sendMail", "(", "Request", "$", "request", ")", "{", "if", "(", "null", "===", "$", "mail", "=", "$", "request", "->", "request", "->", "get", "(", "'email'", ")", ")", "{", "$", "this", "->", "app", "->", "abort", "(", "400"...
Test a mail address @param Request $request @return RedirectResponse
[ "Test", "a", "mail", "address" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Admin/DashboardController.php#L75-L102
alchemy-fr/Phraseanet
lib/Alchemy/Phrasea/Controller/Admin/DashboardController.php
DashboardController.resetAdminRights
public function resetAdminRights() { /** @var ACLManipulator $aclManipulator */ $aclManipulator = $this->app['manipulator.acl']; $aclManipulator->resetAdminRights($this->getUserRepository()->findAdmins()); return $this->app->redirectPath('admin_dashboard'); }
php
public function resetAdminRights() { /** @var ACLManipulator $aclManipulator */ $aclManipulator = $this->app['manipulator.acl']; $aclManipulator->resetAdminRights($this->getUserRepository()->findAdmins()); return $this->app->redirectPath('admin_dashboard'); }
[ "public", "function", "resetAdminRights", "(", ")", "{", "/** @var ACLManipulator $aclManipulator */", "$", "aclManipulator", "=", "$", "this", "->", "app", "[", "'manipulator.acl'", "]", ";", "$", "aclManipulator", "->", "resetAdminRights", "(", "$", "this", "->", ...
Reset admin rights @return RedirectResponse
[ "Reset", "admin", "rights" ]
train
https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Admin/DashboardController.php#L109-L116