id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
40,200 | claroline/Distribution | plugin/blog/Controller/API/PostController.php | PostController.updatePostAction | public function updatePostAction(Request $request, Blog $blog, Post $post, User $user)
{
$this->checkPermission('EDIT', $blog->getResourceNode(), [], true);
$data = json_decode($request->getContent(), true);
$post = $this->postManager->updatePost($blog, $post, $this->postSerializer->deserialize($data), $user);
return new JsonResponse($this->postSerializer->serialize($post));
} | php | public function updatePostAction(Request $request, Blog $blog, Post $post, User $user)
{
$this->checkPermission('EDIT', $blog->getResourceNode(), [], true);
$data = json_decode($request->getContent(), true);
$post = $this->postManager->updatePost($blog, $post, $this->postSerializer->deserialize($data), $user);
return new JsonResponse($this->postSerializer->serialize($post));
} | [
"public",
"function",
"updatePostAction",
"(",
"Request",
"$",
"request",
",",
"Blog",
"$",
"blog",
",",
"Post",
"$",
"post",
",",
"User",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"checkPermission",
"(",
"'EDIT'",
",",
"$",
"blog",
"->",
"getResourceNod... | Update blog post.
@EXT\Route("/update/{postId}", name="apiv2_blog_post_update")
@EXT\Method("PUT")
@EXT\ParamConverter("post", class="IcapBlogBundle:Post", options={"mapping": {"postId": "uuid"}})
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})
@param Blog $blog
@param Post $post
@param User $user
@return array | [
"Update",
"blog",
"post",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L204-L212 |
40,201 | claroline/Distribution | plugin/blog/Controller/API/PostController.php | PostController.deletePostAction | public function deletePostAction(Request $request, Blog $blog, Post $post, User $user)
{
$this->checkPermission('EDIT', $blog->getResourceNode(), [], true);
$this->postManager->deletePost($blog, $post, $user);
return new JsonResponse($post->getId());
} | php | public function deletePostAction(Request $request, Blog $blog, Post $post, User $user)
{
$this->checkPermission('EDIT', $blog->getResourceNode(), [], true);
$this->postManager->deletePost($blog, $post, $user);
return new JsonResponse($post->getId());
} | [
"public",
"function",
"deletePostAction",
"(",
"Request",
"$",
"request",
",",
"Blog",
"$",
"blog",
",",
"Post",
"$",
"post",
",",
"User",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"checkPermission",
"(",
"'EDIT'",
",",
"$",
"blog",
"->",
"getResourceNod... | Delete blog post.
@EXT\Route("/delete/{postId}", name="apiv2_blog_post_delete")
@EXT\Method("DELETE")
@EXT\ParamConverter("post", class="IcapBlogBundle:Post", options={"mapping": {"postId": "uuid"}})
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})
@param Blog $blog
@param Post $post
@param User $user
@return array | [
"Delete",
"blog",
"post",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L228-L234 |
40,202 | claroline/Distribution | plugin/blog/Controller/API/PostController.php | PostController.publishPostAction | public function publishPostAction(Request $request, Blog $blog, Post $post, User $user)
{
if ($this->checkPermission('EDIT', $blog->getResourceNode())
|| $this->checkPermission('MODERATE', $blog->getResourceNode())) {
$this->postManager->switchPublicationState($post);
return new JsonResponse($this->postSerializer->serialize($post));
} else {
throw new AccessDeniedException();
}
} | php | public function publishPostAction(Request $request, Blog $blog, Post $post, User $user)
{
if ($this->checkPermission('EDIT', $blog->getResourceNode())
|| $this->checkPermission('MODERATE', $blog->getResourceNode())) {
$this->postManager->switchPublicationState($post);
return new JsonResponse($this->postSerializer->serialize($post));
} else {
throw new AccessDeniedException();
}
} | [
"public",
"function",
"publishPostAction",
"(",
"Request",
"$",
"request",
",",
"Blog",
"$",
"blog",
",",
"Post",
"$",
"post",
",",
"User",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkPermission",
"(",
"'EDIT'",
",",
"$",
"blog",
"->",
... | Switch post publication state.
@EXT\Route("/publish/{postId}", name="apiv2_blog_post_publish")
@EXT\Method("PUT")
@EXT\ParamConverter("post", class="IcapBlogBundle:Post", options={"mapping": {"postId": "uuid"}})
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})
@param Blog $blog
@param Post $post
@param User $user
@return array | [
"Switch",
"post",
"publication",
"state",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L250-L260 |
40,203 | claroline/Distribution | plugin/blog/Controller/API/PostController.php | PostController.pinPostAction | public function pinPostAction(Request $request, Blog $blog, Post $post, User $user)
{
$this->checkPermission('EDIT', $blog->getResourceNode(), [], true);
$this->postManager->switchPinState($post);
return new JsonResponse($this->postSerializer->serialize($post));
} | php | public function pinPostAction(Request $request, Blog $blog, Post $post, User $user)
{
$this->checkPermission('EDIT', $blog->getResourceNode(), [], true);
$this->postManager->switchPinState($post);
return new JsonResponse($this->postSerializer->serialize($post));
} | [
"public",
"function",
"pinPostAction",
"(",
"Request",
"$",
"request",
",",
"Blog",
"$",
"blog",
",",
"Post",
"$",
"post",
",",
"User",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"checkPermission",
"(",
"'EDIT'",
",",
"$",
"blog",
"->",
"getResourceNode",... | Pin post.
@EXT\Route("/pin/{postId}", name="apiv2_blog_post_pin")
@EXT\Method("PUT")
@EXT\ParamConverter("post", class="IcapBlogBundle:Post", options={"mapping": {"postId": "uuid"}})
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})
@param Blog $blog
@param Post $post
@param User $user
@return array | [
"Pin",
"post",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L276-L283 |
40,204 | claroline/Distribution | plugin/blog/Controller/API/PostController.php | PostController.getBlogAuthorsAction | public function getBlogAuthorsAction(Blog $blog)
{
$this->checkPermission('OPEN', $blog->getResourceNode(), [], true);
return $this->postManager->getAuthors($blog);
} | php | public function getBlogAuthorsAction(Blog $blog)
{
$this->checkPermission('OPEN', $blog->getResourceNode(), [], true);
return $this->postManager->getAuthors($blog);
} | [
"public",
"function",
"getBlogAuthorsAction",
"(",
"Blog",
"$",
"blog",
")",
"{",
"$",
"this",
"->",
"checkPermission",
"(",
"'OPEN'",
",",
"$",
"blog",
"->",
"getResourceNode",
"(",
")",
",",
"[",
"]",
",",
"true",
")",
";",
"return",
"$",
"this",
"->... | Get all authors for a given blog.
@EXT\Route("/authors/get", name="apiv2_blog_post_authors")
@EXT\Method("GET") | [
"Get",
"all",
"authors",
"for",
"a",
"given",
"blog",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L291-L296 |
40,205 | claroline/Distribution | plugin/claco-form/Serializer/FieldChoiceCategorySerializer.php | FieldChoiceCategorySerializer.serialize | public function serialize(FieldChoiceCategory $fieldChoiceCategory)
{
$serialized = [
'id' => $fieldChoiceCategory->getUuid(),
'field' => $this->fieldSerializer->serialize($fieldChoiceCategory->getField(), [Options::SERIALIZE_MINIMAL]),
'category' => [
'id' => $fieldChoiceCategory->getCategory()->getUuid(),
],
'value' => $fieldChoiceCategory->getValue(),
];
return $serialized;
} | php | public function serialize(FieldChoiceCategory $fieldChoiceCategory)
{
$serialized = [
'id' => $fieldChoiceCategory->getUuid(),
'field' => $this->fieldSerializer->serialize($fieldChoiceCategory->getField(), [Options::SERIALIZE_MINIMAL]),
'category' => [
'id' => $fieldChoiceCategory->getCategory()->getUuid(),
],
'value' => $fieldChoiceCategory->getValue(),
];
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"FieldChoiceCategory",
"$",
"fieldChoiceCategory",
")",
"{",
"$",
"serialized",
"=",
"[",
"'id'",
"=>",
"$",
"fieldChoiceCategory",
"->",
"getUuid",
"(",
")",
",",
"'field'",
"=>",
"$",
"this",
"->",
"fieldSerializer",
"... | Serializes a FieldChoiceCategory entity for the JSON api.
@param FieldChoiceCategory $fieldChoiceCategory
@return array - the serialized representation of the field | [
"Serializes",
"a",
"FieldChoiceCategory",
"entity",
"for",
"the",
"JSON",
"api",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/claco-form/Serializer/FieldChoiceCategorySerializer.php#L52-L64 |
40,206 | claroline/Distribution | main/core/Manager/IconSetManager.php | IconSetManager.calibrateIconSets | public function calibrateIconSets()
{
$this->log('Calibrating icon sets...');
// Get decalibrated icon types
$mimeTypes = $this->iconItemRepo->findMimeTypesForCalibration();
if (!empty($mimeTypes)) {
$this->log('Calibrating icons for mime types: \''.implode('\', \'', $mimeTypes).'\'');
$activeSet = $this->getActiveResourceIconSet();
$activeSetIcons = $this->getIconSetIconsByType($activeSet, true);
$resourceIcons = $this
->om
->getRepository('ClarolineCoreBundle:Resource\ResourceIcon')
->findByMimeTypes($mimeTypes);
// Fix paths for resourceIcons
foreach ($resourceIcons as $resourceIcon) {
$curMimeType = $resourceIcon->getMimeType();
$activeSetIcon = $activeSetIcons->getByMimeType($curMimeType);
if (!is_null($activeSetIcon) && $activeSetIcon->getResourceIcon()->getId() !== $resourceIcon->getId()) {
$resourceIcon->setRelativeUrl($activeSetIcon->getRelativeUrl());
$resourceIconShortcut = $resourceIcon->getShortcutIcon();
$resourceIconShortcut->setRelativeUrl(
$activeSetIcon->getResourceIcon()->getShortcutIcon()->getRelativeUrl()
);
$this->om->persist($resourceIcon);
$this->om->persist($resourceIconShortcut);
}
}
$this->om->flush();
// Recalibrate IconItems
$this->iconItemRepo->recalibrateIconItemsForMimeTypes($mimeTypes);
// Update resource icons reference after calibration
$this->iconItemRepo->updateResourceIconsReferenceAfterCalibration($mimeTypes);
// Delete redundant resource icons (the one's duplicated)
$this->iconItemRepo->deleteRedundantResourceIconsAfterCalibration($mimeTypes);
$this->log('Icon sets calibrated with success.');
return;
}
$this->log('No mime types found for calibration. Everything works fine.');
return;
} | php | public function calibrateIconSets()
{
$this->log('Calibrating icon sets...');
// Get decalibrated icon types
$mimeTypes = $this->iconItemRepo->findMimeTypesForCalibration();
if (!empty($mimeTypes)) {
$this->log('Calibrating icons for mime types: \''.implode('\', \'', $mimeTypes).'\'');
$activeSet = $this->getActiveResourceIconSet();
$activeSetIcons = $this->getIconSetIconsByType($activeSet, true);
$resourceIcons = $this
->om
->getRepository('ClarolineCoreBundle:Resource\ResourceIcon')
->findByMimeTypes($mimeTypes);
// Fix paths for resourceIcons
foreach ($resourceIcons as $resourceIcon) {
$curMimeType = $resourceIcon->getMimeType();
$activeSetIcon = $activeSetIcons->getByMimeType($curMimeType);
if (!is_null($activeSetIcon) && $activeSetIcon->getResourceIcon()->getId() !== $resourceIcon->getId()) {
$resourceIcon->setRelativeUrl($activeSetIcon->getRelativeUrl());
$resourceIconShortcut = $resourceIcon->getShortcutIcon();
$resourceIconShortcut->setRelativeUrl(
$activeSetIcon->getResourceIcon()->getShortcutIcon()->getRelativeUrl()
);
$this->om->persist($resourceIcon);
$this->om->persist($resourceIconShortcut);
}
}
$this->om->flush();
// Recalibrate IconItems
$this->iconItemRepo->recalibrateIconItemsForMimeTypes($mimeTypes);
// Update resource icons reference after calibration
$this->iconItemRepo->updateResourceIconsReferenceAfterCalibration($mimeTypes);
// Delete redundant resource icons (the one's duplicated)
$this->iconItemRepo->deleteRedundantResourceIconsAfterCalibration($mimeTypes);
$this->log('Icon sets calibrated with success.');
return;
}
$this->log('No mime types found for calibration. Everything works fine.');
return;
} | [
"public",
"function",
"calibrateIconSets",
"(",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'Calibrating icon sets...'",
")",
";",
"// Get decalibrated icon types",
"$",
"mimeTypes",
"=",
"$",
"this",
"->",
"iconItemRepo",
"->",
"findMimeTypesForCalibration",
"(",
")"... | Re-calibrates icons for icon sets for the case where these icons have been de-calibrated. | [
"Re",
"-",
"calibrates",
"icons",
"for",
"icon",
"sets",
"for",
"the",
"case",
"where",
"these",
"icons",
"have",
"been",
"de",
"-",
"calibrated",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/IconSetManager.php#L464-L505 |
40,207 | claroline/Distribution | main/core/Manager/IconSetManager.php | IconSetManager.extractResourceIconSetZipAndReturnNewIconItems | private function extractResourceIconSetZipAndReturnNewIconItems(
IconSet $iconSet,
ResourceIconSetIconItemList $iconSetIconItemList
) {
$ds = DIRECTORY_SEPARATOR;
$zipFile = $iconSet->getIconsZipfile();
$cname = $iconSet->getCname();
$iconSetDir = $this->iconSetsWebDir.$ds.$cname;
if (!empty($zipFile)) {
$zipArchive = new \ZipArchive();
if (true === $zipArchive->open($zipFile)) {
//Test to see if a resource stamp icon is present in zip file
$resourceStamp = $this->extractResourceStampIconFromZip($zipArchive, $iconSetDir);
if (!empty($resourceStamp)) {
$iconSet->setResourceStampIcon($resourceStamp);
$this->om->persist($iconSet);
if ($iconSet->isActive()) {
$this->regenerateShortcutForAllResourceIcons($resourceStamp);
}
}
//List filenames and extract all files without subfolders
for ($i = 0; $i < $zipArchive->numFiles; ++$i) {
$file = $zipArchive->getNameIndex($i);
$fileinfo = pathinfo($file);
$filename = $fileinfo['filename'];
//If file associated with one of mimeTypes then extract it. Otherwise don't
$alreadyInSet = $iconSetIconItemList->isInSetIcons($filename);
$iconItemFilenameList = $alreadyInSet ?
$iconSetIconItemList->getSetIcons() :
$iconSetIconItemList->getDefaultIcons();
$iconNameTypes = $iconItemFilenameList->getItemByKey($filename);
if (!empty($iconNameTypes)) {
$iconPath = $iconSetDir.$ds.$fileinfo['basename'];
$this->fs->remove($iconSetDir.DIRECTORY_SEPARATOR.$fileinfo['basename']);
$zipArchive->extractTo($iconSetDir, [$file]);
foreach ($iconNameTypes->getMimeTypes() as $type) {
// If icon don't exist, create it, otherwise update it's url in case of extension change
$icon = $iconItemFilenameList->getIconByMimeType($type);
if (!$alreadyInSet) {
$resourceIcon = $icon->getResourceIcon();
$this->createIconItemForResourceIconSet(
$iconSet,
$this->getRelativePathForResourceIcon($iconPath),
$resourceIcon
);
} else {
$this->updateIconItemForResourceIconSet(
$iconSet,
$this->getRelativePathForResourceIcon($iconPath),
$icon
);
}
}
}
}
$zipArchive->close();
}
}
} | php | private function extractResourceIconSetZipAndReturnNewIconItems(
IconSet $iconSet,
ResourceIconSetIconItemList $iconSetIconItemList
) {
$ds = DIRECTORY_SEPARATOR;
$zipFile = $iconSet->getIconsZipfile();
$cname = $iconSet->getCname();
$iconSetDir = $this->iconSetsWebDir.$ds.$cname;
if (!empty($zipFile)) {
$zipArchive = new \ZipArchive();
if (true === $zipArchive->open($zipFile)) {
//Test to see if a resource stamp icon is present in zip file
$resourceStamp = $this->extractResourceStampIconFromZip($zipArchive, $iconSetDir);
if (!empty($resourceStamp)) {
$iconSet->setResourceStampIcon($resourceStamp);
$this->om->persist($iconSet);
if ($iconSet->isActive()) {
$this->regenerateShortcutForAllResourceIcons($resourceStamp);
}
}
//List filenames and extract all files without subfolders
for ($i = 0; $i < $zipArchive->numFiles; ++$i) {
$file = $zipArchive->getNameIndex($i);
$fileinfo = pathinfo($file);
$filename = $fileinfo['filename'];
//If file associated with one of mimeTypes then extract it. Otherwise don't
$alreadyInSet = $iconSetIconItemList->isInSetIcons($filename);
$iconItemFilenameList = $alreadyInSet ?
$iconSetIconItemList->getSetIcons() :
$iconSetIconItemList->getDefaultIcons();
$iconNameTypes = $iconItemFilenameList->getItemByKey($filename);
if (!empty($iconNameTypes)) {
$iconPath = $iconSetDir.$ds.$fileinfo['basename'];
$this->fs->remove($iconSetDir.DIRECTORY_SEPARATOR.$fileinfo['basename']);
$zipArchive->extractTo($iconSetDir, [$file]);
foreach ($iconNameTypes->getMimeTypes() as $type) {
// If icon don't exist, create it, otherwise update it's url in case of extension change
$icon = $iconItemFilenameList->getIconByMimeType($type);
if (!$alreadyInSet) {
$resourceIcon = $icon->getResourceIcon();
$this->createIconItemForResourceIconSet(
$iconSet,
$this->getRelativePathForResourceIcon($iconPath),
$resourceIcon
);
} else {
$this->updateIconItemForResourceIconSet(
$iconSet,
$this->getRelativePathForResourceIcon($iconPath),
$icon
);
}
}
}
}
$zipArchive->close();
}
}
} | [
"private",
"function",
"extractResourceIconSetZipAndReturnNewIconItems",
"(",
"IconSet",
"$",
"iconSet",
",",
"ResourceIconSetIconItemList",
"$",
"iconSetIconItemList",
")",
"{",
"$",
"ds",
"=",
"DIRECTORY_SEPARATOR",
";",
"$",
"zipFile",
"=",
"$",
"iconSet",
"->",
"g... | Extracts icons from provided zipfile into iconSet directory.
@param IconSet $iconSet
@param $iconSetIconItemList
@return array | [
"Extracts",
"icons",
"from",
"provided",
"zipfile",
"into",
"iconSet",
"directory",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/IconSetManager.php#L538-L597 |
40,208 | claroline/Distribution | plugin/agenda/Entity/EventInvitation.php | EventInvitation.setEvent | public function setEvent(\Claroline\AgendaBundle\Entity\Event $event)
{
$this->event = $event;
return $this;
} | php | public function setEvent(\Claroline\AgendaBundle\Entity\Event $event)
{
$this->event = $event;
return $this;
} | [
"public",
"function",
"setEvent",
"(",
"\\",
"Claroline",
"\\",
"AgendaBundle",
"\\",
"Entity",
"\\",
"Event",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"event",
"=",
"$",
"event",
";",
"return",
"$",
"this",
";",
"}"
] | Set event.
@param \Claroline\AgendaBundle\Entity\Event $event
@return EventInvitation | [
"Set",
"event",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/agenda/Entity/EventInvitation.php#L130-L135 |
40,209 | claroline/Distribution | plugin/competency/Manager/CompetencyManager.php | CompetencyManager.ensureHasScale | public function ensureHasScale()
{
if (!$this->hasScales()) {
$defaultScale = new Scale();
$defaultScale->setName(
$this->translator->trans('scale.default_name', [], 'competency')
);
$defaultLevel = new Level();
$defaultLevel->setValue(0);
$defaultLevel->setName(
$this->translator->trans('scale.default_level_name', [], 'competency')
);
$defaultScale->setLevels(new ArrayCollection([$defaultLevel]));
$this->om->persist($defaultScale);
$this->om->flush();
}
} | php | public function ensureHasScale()
{
if (!$this->hasScales()) {
$defaultScale = new Scale();
$defaultScale->setName(
$this->translator->trans('scale.default_name', [], 'competency')
);
$defaultLevel = new Level();
$defaultLevel->setValue(0);
$defaultLevel->setName(
$this->translator->trans('scale.default_level_name', [], 'competency')
);
$defaultScale->setLevels(new ArrayCollection([$defaultLevel]));
$this->om->persist($defaultScale);
$this->om->flush();
}
} | [
"public",
"function",
"ensureHasScale",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasScales",
"(",
")",
")",
"{",
"$",
"defaultScale",
"=",
"new",
"Scale",
"(",
")",
";",
"$",
"defaultScale",
"->",
"setName",
"(",
"$",
"this",
"->",
"transla... | Creates a default scale if no scale exists yet. | [
"Creates",
"a",
"default",
"scale",
"if",
"no",
"scale",
"exists",
"yet",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L70-L86 |
40,210 | claroline/Distribution | plugin/competency/Manager/CompetencyManager.php | CompetencyManager.exportFramework | public function exportFramework(Competency $framework)
{
$loaded = $this->loadCompetency($framework);
return $this->converter->convertToJson($loaded);
} | php | public function exportFramework(Competency $framework)
{
$loaded = $this->loadCompetency($framework);
return $this->converter->convertToJson($loaded);
} | [
"public",
"function",
"exportFramework",
"(",
"Competency",
"$",
"framework",
")",
"{",
"$",
"loaded",
"=",
"$",
"this",
"->",
"loadCompetency",
"(",
"$",
"framework",
")",
";",
"return",
"$",
"this",
"->",
"converter",
"->",
"convertToJson",
"(",
"$",
"lo... | Returns the JSON representation of a competency framework.
@param Competency $framework
@return string | [
"Returns",
"the",
"JSON",
"representation",
"of",
"a",
"competency",
"framework",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L109-L114 |
40,211 | claroline/Distribution | plugin/competency/Manager/CompetencyManager.php | CompetencyManager.importFramework | public function importFramework($frameworkData)
{
$framework = $this->converter->convertToEntity($frameworkData);
$this->om->persist($framework);
$this->om->flush();
return $framework;
} | php | public function importFramework($frameworkData)
{
$framework = $this->converter->convertToEntity($frameworkData);
$this->om->persist($framework);
$this->om->flush();
return $framework;
} | [
"public",
"function",
"importFramework",
"(",
"$",
"frameworkData",
")",
"{",
"$",
"framework",
"=",
"$",
"this",
"->",
"converter",
"->",
"convertToEntity",
"(",
"$",
"frameworkData",
")",
";",
"$",
"this",
"->",
"om",
"->",
"persist",
"(",
"$",
"framewor... | Imports a competency framework described in a JSON string.
@param string $frameworkData
@return Competency | [
"Imports",
"a",
"competency",
"framework",
"described",
"in",
"a",
"JSON",
"string",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L123-L131 |
40,212 | claroline/Distribution | plugin/competency/Manager/CompetencyManager.php | CompetencyManager.walkCollection | public function walkCollection($collection, \Closure $callback)
{
if (is_array($collection)) {
$result = [];
foreach ($collection as $key => $item) {
$result[$key] = $this->walkCollection($item, $callback);
}
return $callback($result);
}
return $collection;
} | php | public function walkCollection($collection, \Closure $callback)
{
if (is_array($collection)) {
$result = [];
foreach ($collection as $key => $item) {
$result[$key] = $this->walkCollection($item, $callback);
}
return $callback($result);
}
return $collection;
} | [
"public",
"function",
"walkCollection",
"(",
"$",
"collection",
",",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"collection",
")",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"collection",
"as",
... | Utility method. Walks a collection recursively, applying a callback on
each element.
Unlike array_walk_recursive :
- the result is a *copy* of the original collection
- all the nodes are visited, not only the leafs
@param mixed $collection
@param \Closure $callback
@return mixed | [
"Utility",
"method",
".",
"Walks",
"a",
"collection",
"recursively",
"applying",
"a",
"callback",
"on",
"each",
"element",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L181-L194 |
40,213 | claroline/Distribution | plugin/competency/Manager/CompetencyManager.php | CompetencyManager.associateCompetencyToResources | public function associateCompetencyToResources(Competency $competency, array $nodes)
{
$associatedNodes = [];
foreach ($nodes as $node) {
if (!$competency->isLinkedToResource($node)) {
$competency->linkResource($node);
$associatedNodes[] = $node;
}
}
$this->om->persist($competency);
$this->om->flush();
return $associatedNodes;
} | php | public function associateCompetencyToResources(Competency $competency, array $nodes)
{
$associatedNodes = [];
foreach ($nodes as $node) {
if (!$competency->isLinkedToResource($node)) {
$competency->linkResource($node);
$associatedNodes[] = $node;
}
}
$this->om->persist($competency);
$this->om->flush();
return $associatedNodes;
} | [
"public",
"function",
"associateCompetencyToResources",
"(",
"Competency",
"$",
"competency",
",",
"array",
"$",
"nodes",
")",
"{",
"$",
"associatedNodes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"!",
"$"... | Associates a competency to several resource nodes.
@param Competency $competency
@param array $nodes
@return string | [
"Associates",
"a",
"competency",
"to",
"several",
"resource",
"nodes",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L204-L218 |
40,214 | claroline/Distribution | plugin/competency/Manager/CompetencyManager.php | CompetencyManager.dissociateCompetencyFromResources | public function dissociateCompetencyFromResources(Competency $competency, array $nodes)
{
foreach ($nodes as $node) {
$competency->removeResource($node);
}
$this->om->persist($competency);
$this->om->flush();
} | php | public function dissociateCompetencyFromResources(Competency $competency, array $nodes)
{
foreach ($nodes as $node) {
$competency->removeResource($node);
}
$this->om->persist($competency);
$this->om->flush();
} | [
"public",
"function",
"dissociateCompetencyFromResources",
"(",
"Competency",
"$",
"competency",
",",
"array",
"$",
"nodes",
")",
"{",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"competency",
"->",
"removeResource",
"(",
"$",
"node",
")"... | Dissociates a competency from several resource nodes.
@param Competency $competency
@param array $nodes
@return string | [
"Dissociates",
"a",
"competency",
"from",
"several",
"resource",
"nodes",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L228-L235 |
40,215 | claroline/Distribution | plugin/competency/Manager/CompetencyManager.php | CompetencyManager.associateAbilityToResources | public function associateAbilityToResources(Ability $ability, array $nodes)
{
$associatedNodes = [];
foreach ($nodes as $node) {
if (!$ability->isLinkedToResource($node)) {
$ability->linkResource($node);
$associatedNodes[] = $node;
}
}
$this->om->persist($ability);
$this->om->flush();
return $associatedNodes;
} | php | public function associateAbilityToResources(Ability $ability, array $nodes)
{
$associatedNodes = [];
foreach ($nodes as $node) {
if (!$ability->isLinkedToResource($node)) {
$ability->linkResource($node);
$associatedNodes[] = $node;
}
}
$this->om->persist($ability);
$this->om->flush();
return $associatedNodes;
} | [
"public",
"function",
"associateAbilityToResources",
"(",
"Ability",
"$",
"ability",
",",
"array",
"$",
"nodes",
")",
"{",
"$",
"associatedNodes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"!",
"$",
"abil... | Associates an ability to several resource nodes.
@param Ability $ability
@param array $nodes
@return string | [
"Associates",
"an",
"ability",
"to",
"several",
"resource",
"nodes",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L245-L259 |
40,216 | claroline/Distribution | plugin/competency/Manager/CompetencyManager.php | CompetencyManager.dissociateAbilityFromResources | public function dissociateAbilityFromResources(Ability $ability, array $nodes)
{
foreach ($nodes as $node) {
$ability->removeResource($node);
}
$this->om->persist($ability);
$this->om->flush();
} | php | public function dissociateAbilityFromResources(Ability $ability, array $nodes)
{
foreach ($nodes as $node) {
$ability->removeResource($node);
}
$this->om->persist($ability);
$this->om->flush();
} | [
"public",
"function",
"dissociateAbilityFromResources",
"(",
"Ability",
"$",
"ability",
",",
"array",
"$",
"nodes",
")",
"{",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"ability",
"->",
"removeResource",
"(",
"$",
"node",
")",
";",
"... | Dissociates an ability from several resource nodes.
@param Ability $ability
@param array $nodes
@return string | [
"Dissociates",
"an",
"ability",
"from",
"several",
"resource",
"nodes",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L269-L276 |
40,217 | claroline/Distribution | plugin/competency/Manager/CompetencyManager.php | CompetencyManager.listFrameworks | public function listFrameworks($shortArrays = false)
{
$frameworks = $this->competencyRepo->findBy(['parent' => null]);
return !$shortArrays ?
$frameworks :
array_map(function ($framework) {
return [
'id' => $framework->getId(),
'name' => $framework->getName(),
'description' => $framework->getDescription(),
];
}, $frameworks);
} | php | public function listFrameworks($shortArrays = false)
{
$frameworks = $this->competencyRepo->findBy(['parent' => null]);
return !$shortArrays ?
$frameworks :
array_map(function ($framework) {
return [
'id' => $framework->getId(),
'name' => $framework->getName(),
'description' => $framework->getDescription(),
];
}, $frameworks);
} | [
"public",
"function",
"listFrameworks",
"(",
"$",
"shortArrays",
"=",
"false",
")",
"{",
"$",
"frameworks",
"=",
"$",
"this",
"->",
"competencyRepo",
"->",
"findBy",
"(",
"[",
"'parent'",
"=>",
"null",
"]",
")",
";",
"return",
"!",
"$",
"shortArrays",
"?... | Returns the list of registered frameworks.
@param bool $shortArrays Whether full entities or minimal arrays should be returned
@return array | [
"Returns",
"the",
"list",
"of",
"registered",
"frameworks",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L287-L300 |
40,218 | claroline/Distribution | plugin/competency/Manager/CompetencyManager.php | CompetencyManager.loadAbility | public function loadAbility(Competency $parent, Ability $ability)
{
$link = $this->competencyAbilityRepo->findOneByTerms($parent, $ability);
$ability->setLevel($link->getLevel());
} | php | public function loadAbility(Competency $parent, Ability $ability)
{
$link = $this->competencyAbilityRepo->findOneByTerms($parent, $ability);
$ability->setLevel($link->getLevel());
} | [
"public",
"function",
"loadAbility",
"(",
"Competency",
"$",
"parent",
",",
"Ability",
"$",
"ability",
")",
"{",
"$",
"link",
"=",
"$",
"this",
"->",
"competencyAbilityRepo",
"->",
"findOneByTerms",
"(",
"$",
"parent",
",",
"$",
"ability",
")",
";",
"$",
... | Sets the level temporary attribute of an ability.
@param Competency $parent
@param Ability $ability | [
"Sets",
"the",
"level",
"temporary",
"attribute",
"of",
"an",
"ability",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L308-L312 |
40,219 | claroline/Distribution | plugin/competency/Repository/ObjectiveRepository.php | ObjectiveRepository.findByUser | public function findByUser(User $user, $asArray = true)
{
$groupQb = $this->_em->createQueryBuilder()
->select('g')
->from('Claroline\CoreBundle\Entity\Group', 'g')
->join('g.users', 'gu')
->where('gu = :user');
$select = $asArray ? 'o.id, o.name, op.percentage AS progress, COUNT(oc) AS competencyCount' : 'o';
$query = $this->createQueryBuilder('o')
->select($select)
->leftJoin('o.objectiveCompetencies', 'oc')
->leftJoin('o.users', 'ou')
->leftJoin('o.groups', 'og')
->leftJoin(
'HeVinci\CompetencyBundle\Entity\Progress\ObjectiveProgress',
'op',
'WITH',
'op.user = :user AND op.objective = o'
)
->andWhere($groupQb->expr()->orX(
'ou = :user',
$groupQb->expr()->in('og', $groupQb->getQuery()->getDQL())
))
->groupBy('o.id')
->setParameter(':user', $user)
->getQuery();
return $query->{$asArray ? 'getArrayResult' : 'getResult'}();
} | php | public function findByUser(User $user, $asArray = true)
{
$groupQb = $this->_em->createQueryBuilder()
->select('g')
->from('Claroline\CoreBundle\Entity\Group', 'g')
->join('g.users', 'gu')
->where('gu = :user');
$select = $asArray ? 'o.id, o.name, op.percentage AS progress, COUNT(oc) AS competencyCount' : 'o';
$query = $this->createQueryBuilder('o')
->select($select)
->leftJoin('o.objectiveCompetencies', 'oc')
->leftJoin('o.users', 'ou')
->leftJoin('o.groups', 'og')
->leftJoin(
'HeVinci\CompetencyBundle\Entity\Progress\ObjectiveProgress',
'op',
'WITH',
'op.user = :user AND op.objective = o'
)
->andWhere($groupQb->expr()->orX(
'ou = :user',
$groupQb->expr()->in('og', $groupQb->getQuery()->getDQL())
))
->groupBy('o.id')
->setParameter(':user', $user)
->getQuery();
return $query->{$asArray ? 'getArrayResult' : 'getResult'}();
} | [
"public",
"function",
"findByUser",
"(",
"User",
"$",
"user",
",",
"$",
"asArray",
"=",
"true",
")",
"{",
"$",
"groupQb",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'g'",
")",
"->",
"from",
"(",
"'Claro... | Returns the objectives assigned to a user. Objectives assigned to
groups whose the user is a member of are also returned.
@param User $user
@param bool $asArray
@return array | [
"Returns",
"the",
"objectives",
"assigned",
"to",
"a",
"user",
".",
"Objectives",
"assigned",
"to",
"groups",
"whose",
"the",
"user",
"is",
"a",
"member",
"of",
"are",
"also",
"returned",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/ObjectiveRepository.php#L40-L70 |
40,220 | claroline/Distribution | plugin/competency/Repository/ObjectiveRepository.php | ObjectiveRepository.findByGroup | public function findByGroup(Group $group)
{
return $this->createQueryBuilder('o')
->select('o.id', 'o.name')
->join('o.groups', 'g')
->where('g = :group')
->groupBy('o.id')
->setParameter(':group', $group)
->getQuery()
->getArrayResult();
} | php | public function findByGroup(Group $group)
{
return $this->createQueryBuilder('o')
->select('o.id', 'o.name')
->join('o.groups', 'g')
->where('g = :group')
->groupBy('o.id')
->setParameter(':group', $group)
->getQuery()
->getArrayResult();
} | [
"public",
"function",
"findByGroup",
"(",
"Group",
"$",
"group",
")",
"{",
"return",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'o'",
")",
"->",
"select",
"(",
"'o.id'",
",",
"'o.name'",
")",
"->",
"join",
"(",
"'o.groups'",
",",
"'g'",
")",
"->",
... | Returns an array representation of the objectives assigned to a group.
@param Group $group
@return array | [
"Returns",
"an",
"array",
"representation",
"of",
"the",
"objectives",
"assigned",
"to",
"a",
"group",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/ObjectiveRepository.php#L91-L101 |
40,221 | claroline/Distribution | plugin/competency/Repository/ObjectiveRepository.php | ObjectiveRepository.findByCompetencyAndUser | public function findByCompetencyAndUser(Competency $competency, User $user)
{
$groupQb = $this->_em->createQueryBuilder()
->select('g')
->from('Claroline\CoreBundle\Entity\Group', 'g')
->join('g.users', 'gu')
->where('gu = :user');
return $this->createQueryBuilder('o')
->select('o')
->leftJoin('o.objectiveCompetencies', 'oc')
->leftJoin('o.users', 'ou')
->leftJoin('o.groups', 'og')
->where('oc.competency = :competency')
->andWhere($groupQb->expr()->orX(
'ou = :user',
$groupQb->expr()->in('og', $groupQb->getQuery()->getDQL())
))
->setParameters([
'competency' => $competency,
'user' => $user,
])
->distinct()
->getQuery()
->getResult();
} | php | public function findByCompetencyAndUser(Competency $competency, User $user)
{
$groupQb = $this->_em->createQueryBuilder()
->select('g')
->from('Claroline\CoreBundle\Entity\Group', 'g')
->join('g.users', 'gu')
->where('gu = :user');
return $this->createQueryBuilder('o')
->select('o')
->leftJoin('o.objectiveCompetencies', 'oc')
->leftJoin('o.users', 'ou')
->leftJoin('o.groups', 'og')
->where('oc.competency = :competency')
->andWhere($groupQb->expr()->orX(
'ou = :user',
$groupQb->expr()->in('og', $groupQb->getQuery()->getDQL())
))
->setParameters([
'competency' => $competency,
'user' => $user,
])
->distinct()
->getQuery()
->getResult();
} | [
"public",
"function",
"findByCompetencyAndUser",
"(",
"Competency",
"$",
"competency",
",",
"User",
"$",
"user",
")",
"{",
"$",
"groupQb",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'g'",
")",
"->",
"from",
... | Returns the objectives assigned to a user which includes a
given competency. Objectives assigned to groups whose the
user is a member of are also returned.
@param Competency $competency
@param User $user
@return array | [
"Returns",
"the",
"objectives",
"assigned",
"to",
"a",
"user",
"which",
"includes",
"a",
"given",
"competency",
".",
"Objectives",
"assigned",
"to",
"groups",
"whose",
"the",
"user",
"is",
"a",
"member",
"of",
"are",
"also",
"returned",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/ObjectiveRepository.php#L113-L138 |
40,222 | claroline/Distribution | plugin/competency/Repository/ObjectiveRepository.php | ObjectiveRepository.findUsersWithObjective | public function findUsersWithObjective(Objective $objective)
{
$usersQb = $this->createQueryBuilder('o1')
->select('ou.id')
->join('o1.users', 'ou')
->where('o1 = :objective');
$groupsQb = $this->createQueryBuilder('o2')
->select('og.id')
->join('o2.groups', 'og')
->where('o2 = :objective');
return $this->_em->createQueryBuilder()
->select('u')
->from('Claroline\CoreBundle\Entity\User', 'u')
->leftJoin('HeVinci\CompetencyBundle\Entity\Progress\UserProgress', 'up', 'WITH', 'up.user = u')
->leftJoin('u.groups', 'ug')
->where((new Expr())->in('u.id', $usersQb->getDQL()))
->orWhere((new Expr())->in('ug.id', $groupsQb->getDQL()))
->setParameter(':objective', $objective)
->getQuery()
->getResult();
} | php | public function findUsersWithObjective(Objective $objective)
{
$usersQb = $this->createQueryBuilder('o1')
->select('ou.id')
->join('o1.users', 'ou')
->where('o1 = :objective');
$groupsQb = $this->createQueryBuilder('o2')
->select('og.id')
->join('o2.groups', 'og')
->where('o2 = :objective');
return $this->_em->createQueryBuilder()
->select('u')
->from('Claroline\CoreBundle\Entity\User', 'u')
->leftJoin('HeVinci\CompetencyBundle\Entity\Progress\UserProgress', 'up', 'WITH', 'up.user = u')
->leftJoin('u.groups', 'ug')
->where((new Expr())->in('u.id', $usersQb->getDQL()))
->orWhere((new Expr())->in('ug.id', $groupsQb->getDQL()))
->setParameter(':objective', $objective)
->getQuery()
->getResult();
} | [
"public",
"function",
"findUsersWithObjective",
"(",
"Objective",
"$",
"objective",
")",
"{",
"$",
"usersQb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'o1'",
")",
"->",
"select",
"(",
"'ou.id'",
")",
"->",
"join",
"(",
"'o1.users'",
",",
"'ou'",
... | Returns all the users and group members who have a given objective.
@param Objective $objective
@return array | [
"Returns",
"all",
"the",
"users",
"and",
"group",
"members",
"who",
"have",
"a",
"given",
"objective",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/ObjectiveRepository.php#L147-L168 |
40,223 | claroline/Distribution | plugin/competency/Repository/CompetencyRepository.php | CompetencyRepository.findByResource | public function findByResource(ResourceNode $resource)
{
return $this->createQueryBuilder('c')
->select('c')
->join('c.resources', 'r')
->where('r = :resource')
->setParameter(':resource', $resource)
->getQuery()
->getResult();
} | php | public function findByResource(ResourceNode $resource)
{
return $this->createQueryBuilder('c')
->select('c')
->join('c.resources', 'r')
->where('r = :resource')
->setParameter(':resource', $resource)
->getQuery()
->getResult();
} | [
"public",
"function",
"findByResource",
"(",
"ResourceNode",
"$",
"resource",
")",
"{",
"return",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'c'",
")",
"->",
"select",
"(",
"'c'",
")",
"->",
"join",
"(",
"'c.resources'",
",",
"'r'",
")",
"->",
"where",... | Returns the competencies associated with a resource.
@param ResourceNode $resource
@return array | [
"Returns",
"the",
"competencies",
"associated",
"with",
"a",
"resource",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyRepository.php#L30-L39 |
40,224 | claroline/Distribution | plugin/competency/Repository/CompetencyRepository.php | CompetencyRepository.findFirstUsersByName | public function findFirstUsersByName($search)
{
return $this->_em->createQueryBuilder()
->select(
'u.id',
"CONCAT(u.firstName, ' ', u.lastName, ' (', u.username, ')') AS name"
)
->from('ClarolineCoreBundle:User', 'u')
->where('u.firstName LIKE :search')
->orWhere('u.lastName LIKE :search')
->orWhere('u.username LIKE :search')
->setMaxResults(5)
->setParameter(':search', "%{$search}%")
->getQuery()
->getArrayResult();
} | php | public function findFirstUsersByName($search)
{
return $this->_em->createQueryBuilder()
->select(
'u.id',
"CONCAT(u.firstName, ' ', u.lastName, ' (', u.username, ')') AS name"
)
->from('ClarolineCoreBundle:User', 'u')
->where('u.firstName LIKE :search')
->orWhere('u.lastName LIKE :search')
->orWhere('u.username LIKE :search')
->setMaxResults(5)
->setParameter(':search', "%{$search}%")
->getQuery()
->getArrayResult();
} | [
"public",
"function",
"findFirstUsersByName",
"(",
"$",
"search",
")",
"{",
"return",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'u.id'",
",",
"\"CONCAT(u.firstName, ' ', u.lastName, ' (', u.username, ')') AS name\"",
")",
"-... | Returns the first five users whose first name, last name or
username include a given string.
Note: this should definitely not be here
@param string $search
@return array | [
"Returns",
"the",
"first",
"five",
"users",
"whose",
"first",
"name",
"last",
"name",
"or",
"username",
"include",
"a",
"given",
"string",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyRepository.php#L51-L66 |
40,225 | claroline/Distribution | plugin/competency/Repository/CompetencyRepository.php | CompetencyRepository.findFirstGroupsByName | public function findFirstGroupsByName($search)
{
return $this->_em->createQueryBuilder()
->select('g.id, g.name')
->from('ClarolineCoreBundle:Group', 'g')
->where('g.name LIKE :search')
->setMaxResults(5)
->setParameter(':search', "%{$search}%")
->getQuery()
->getArrayResult();
} | php | public function findFirstGroupsByName($search)
{
return $this->_em->createQueryBuilder()
->select('g.id, g.name')
->from('ClarolineCoreBundle:Group', 'g')
->where('g.name LIKE :search')
->setMaxResults(5)
->setParameter(':search', "%{$search}%")
->getQuery()
->getArrayResult();
} | [
"public",
"function",
"findFirstGroupsByName",
"(",
"$",
"search",
")",
"{",
"return",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'g.id, g.name'",
")",
"->",
"from",
"(",
"'ClarolineCoreBundle:Group'",
",",
"'g'",
")"... | Returns the first five users whose name includes a given string.
Note: this should definitely not be here
@param string $search
@return array | [
"Returns",
"the",
"first",
"five",
"users",
"whose",
"name",
"includes",
"a",
"given",
"string",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyRepository.php#L77-L87 |
40,226 | claroline/Distribution | plugin/exo/Serializer/Item/HintSerializer.php | HintSerializer.serialize | public function serialize(Hint $hint, array $options = [])
{
$serialized = [
'id' => $hint->getUuid(),
'penalty' => $hint->getPenalty(),
];
if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
$serialized['value'] = $hint->getData();
}
return $serialized;
} | php | public function serialize(Hint $hint, array $options = [])
{
$serialized = [
'id' => $hint->getUuid(),
'penalty' => $hint->getPenalty(),
];
if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
$serialized['value'] = $hint->getData();
}
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"Hint",
"$",
"hint",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serialized",
"=",
"[",
"'id'",
"=>",
"$",
"hint",
"->",
"getUuid",
"(",
")",
",",
"'penalty'",
"=>",
"$",
"hint",
"->",
"getPe... | Converts a Hint into a JSON-encodable structure.
@param Hint $hint
@param array $options
@return array | [
"Converts",
"a",
"Hint",
"into",
"a",
"JSON",
"-",
"encodable",
"structure",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/HintSerializer.php#L28-L40 |
40,227 | claroline/Distribution | plugin/exo/Serializer/Item/HintSerializer.php | HintSerializer.deserialize | public function deserialize($data, Hint $hint = null, array $options = [])
{
$hint = $hint ?: new Hint();
$this->sipe('id', 'setUuid', $data, $hint);
$this->sipe('penalty', 'setPenalty', $data, $hint);
$this->sipe('value', 'setData', $data, $hint);
if (in_array(Transfer::REFRESH_UUID, $options)) {
$hint->refreshUuid();
}
return $hint;
} | php | public function deserialize($data, Hint $hint = null, array $options = [])
{
$hint = $hint ?: new Hint();
$this->sipe('id', 'setUuid', $data, $hint);
$this->sipe('penalty', 'setPenalty', $data, $hint);
$this->sipe('value', 'setData', $data, $hint);
if (in_array(Transfer::REFRESH_UUID, $options)) {
$hint->refreshUuid();
}
return $hint;
} | [
"public",
"function",
"deserialize",
"(",
"$",
"data",
",",
"Hint",
"$",
"hint",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"hint",
"=",
"$",
"hint",
"?",
":",
"new",
"Hint",
"(",
")",
";",
"$",
"this",
"->",
"sipe... | Converts raw data into a Hint entity.
@param array $data
@param Hint $hint
@param array $options
@return Hint | [
"Converts",
"raw",
"data",
"into",
"a",
"Hint",
"entity",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/HintSerializer.php#L51-L63 |
40,228 | claroline/Distribution | main/core/API/Serializer/Resource/ResourceCommentSerializer.php | ResourceCommentSerializer.serialize | public function serialize(ResourceComment $comment, array $options = [])
{
$serialized = [
'id' => $comment->getUuid(),
'content' => $comment->getContent(),
'user' => $comment->getUser() ? $this->userSerializer->serialize($comment->getUser(), [Options::SERIALIZE_MINIMAL]) : null,
'creationDate' => $comment->getCreationDate() ? DateNormalizer::normalize($comment->getCreationDate()) : null,
'editionDate' => $comment->getEditionDate() ? DateNormalizer::normalize($comment->getEditionDate()) : null,
];
return $serialized;
} | php | public function serialize(ResourceComment $comment, array $options = [])
{
$serialized = [
'id' => $comment->getUuid(),
'content' => $comment->getContent(),
'user' => $comment->getUser() ? $this->userSerializer->serialize($comment->getUser(), [Options::SERIALIZE_MINIMAL]) : null,
'creationDate' => $comment->getCreationDate() ? DateNormalizer::normalize($comment->getCreationDate()) : null,
'editionDate' => $comment->getEditionDate() ? DateNormalizer::normalize($comment->getEditionDate()) : null,
];
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"ResourceComment",
"$",
"comment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serialized",
"=",
"[",
"'id'",
"=>",
"$",
"comment",
"->",
"getUuid",
"(",
")",
",",
"'content'",
"=>",
"$",
"commen... | Serializes a ResourceComment entity for the JSON api.
@param ResourceComment $comment - the comment to serialize
@param array $options
@return array - the serialized representation of the comment | [
"Serializes",
"a",
"ResourceComment",
"entity",
"for",
"the",
"JSON",
"api",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/ResourceCommentSerializer.php#L53-L64 |
40,229 | claroline/Distribution | main/core/Manager/RoleManager.php | RoleManager.validateRoleInsert | public function validateRoleInsert(AbstractRoleSubject $ars, Role $role)
{
$total = $this->countUsersByRoleIncludingGroup($role);
//cli always win!
if ('ROLE_ADMIN' === $role->getName() && 'cli' === php_sapi_name() ||
//web installer too
null === $this->container->get('security.token_storage')->getToken()) {
return true;
}
if ('ROLE_ADMIN' === $role->getName() && !$this->container->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) {
return false;
}
//if we already have the role, then it's ok
if ($ars->hasRole($role->getName())) {
return true;
}
if (null === $role->getMaxUsers()) {
return true;
}
if ($role->getWorkspace()) {
$maxUsers = $role->getWorkspace()->getMaxUsers();
$countByWorkspace = $this->container->get('claroline.api.finder')->fetch(
User::class,
['workspace' => $role->getWorkspace()->getUuid()],
null,
0,
-1,
true
);
if ($maxUsers <= $countByWorkspace) {
return false;
}
}
if ($ars instanceof User) {
return $total < $role->getMaxUsers();
}
if ($ars instanceof Group) {
$userCount = $this->userRepo->countUsersOfGroup($ars);
$userWithRoleCount = $this->userRepo->countUsersOfGroupByRole($ars, $role);
return $total + $userCount - $userWithRoleCount < $role->getMaxUsers();
}
return false;
} | php | public function validateRoleInsert(AbstractRoleSubject $ars, Role $role)
{
$total = $this->countUsersByRoleIncludingGroup($role);
//cli always win!
if ('ROLE_ADMIN' === $role->getName() && 'cli' === php_sapi_name() ||
//web installer too
null === $this->container->get('security.token_storage')->getToken()) {
return true;
}
if ('ROLE_ADMIN' === $role->getName() && !$this->container->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) {
return false;
}
//if we already have the role, then it's ok
if ($ars->hasRole($role->getName())) {
return true;
}
if (null === $role->getMaxUsers()) {
return true;
}
if ($role->getWorkspace()) {
$maxUsers = $role->getWorkspace()->getMaxUsers();
$countByWorkspace = $this->container->get('claroline.api.finder')->fetch(
User::class,
['workspace' => $role->getWorkspace()->getUuid()],
null,
0,
-1,
true
);
if ($maxUsers <= $countByWorkspace) {
return false;
}
}
if ($ars instanceof User) {
return $total < $role->getMaxUsers();
}
if ($ars instanceof Group) {
$userCount = $this->userRepo->countUsersOfGroup($ars);
$userWithRoleCount = $this->userRepo->countUsersOfGroupByRole($ars, $role);
return $total + $userCount - $userWithRoleCount < $role->getMaxUsers();
}
return false;
} | [
"public",
"function",
"validateRoleInsert",
"(",
"AbstractRoleSubject",
"$",
"ars",
",",
"Role",
"$",
"role",
")",
"{",
"$",
"total",
"=",
"$",
"this",
"->",
"countUsersByRoleIncludingGroup",
"(",
"$",
"role",
")",
";",
"//cli always win!",
"if",
"(",
"'ROLE_A... | Returns if a role can be added to a RoleSubject.
@param AbstractRoleSubject $ars
@param Role $role
@return bool | [
"Returns",
"if",
"a",
"role",
"can",
"be",
"added",
"to",
"a",
"RoleSubject",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/RoleManager.php#L820-L872 |
40,230 | claroline/Distribution | main/core/Manager/RoleManager.php | RoleManager.initializeLimit | public function initializeLimit(Role $role)
{
$count = $this->countUsersByRoleIncludingGroup($role);
$role->setMaxUsers($count);
$this->om->persist($role);
$this->om->flush();
} | php | public function initializeLimit(Role $role)
{
$count = $this->countUsersByRoleIncludingGroup($role);
$role->setMaxUsers($count);
$this->om->persist($role);
$this->om->flush();
} | [
"public",
"function",
"initializeLimit",
"(",
"Role",
"$",
"role",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"countUsersByRoleIncludingGroup",
"(",
"$",
"role",
")",
";",
"$",
"role",
"->",
"setMaxUsers",
"(",
"$",
"count",
")",
";",
"$",
"this",
... | This functions sets the role limit equal to the current number of users having that role.
@param Role $role | [
"This",
"functions",
"sets",
"the",
"role",
"limit",
"equal",
"to",
"the",
"current",
"number",
"of",
"users",
"having",
"that",
"role",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/RoleManager.php#L918-L924 |
40,231 | claroline/Distribution | main/core/Listener/Administration/WorkspaceListener.php | WorkspaceListener.onDisplayTool | public function onDisplayTool(OpenAdministrationToolEvent $event)
{
$workspaceTools = $this->toolManager->getAvailableWorkspaceTools();
$content = $this->templating->render(
'ClarolineCoreBundle:administration:workspaces.html.twig',
[
'parameters' => $this->parametersSerializer->serialize(),
'tools' => array_map(function (Tool $tool) {
return ['name' => $tool->getName()];
}, $workspaceTools),
'models' => $this->finder->search(
Workspace::class,
['filters' => ['model' => true]],
[Options::SERIALIZE_MINIMAL]
),
]
);
$event->setResponse(new Response($content));
$event->stopPropagation();
} | php | public function onDisplayTool(OpenAdministrationToolEvent $event)
{
$workspaceTools = $this->toolManager->getAvailableWorkspaceTools();
$content = $this->templating->render(
'ClarolineCoreBundle:administration:workspaces.html.twig',
[
'parameters' => $this->parametersSerializer->serialize(),
'tools' => array_map(function (Tool $tool) {
return ['name' => $tool->getName()];
}, $workspaceTools),
'models' => $this->finder->search(
Workspace::class,
['filters' => ['model' => true]],
[Options::SERIALIZE_MINIMAL]
),
]
);
$event->setResponse(new Response($content));
$event->stopPropagation();
} | [
"public",
"function",
"onDisplayTool",
"(",
"OpenAdministrationToolEvent",
"$",
"event",
")",
"{",
"$",
"workspaceTools",
"=",
"$",
"this",
"->",
"toolManager",
"->",
"getAvailableWorkspaceTools",
"(",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"templatin... | Displays workspace administration tool.
@DI\Observe("administration_tool_workspace_management")
@param OpenAdministrationToolEvent $event | [
"Displays",
"workspace",
"administration",
"tool",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/WorkspaceListener.php#L68-L89 |
40,232 | claroline/Distribution | plugin/slideshow/Entity/Resource/Slideshow.php | Slideshow.addSlide | public function addSlide(Slide $slide)
{
if (!$this->slides->contains($slide)) {
$this->slides->add($slide);
$slide->setSlideshow($this);
}
} | php | public function addSlide(Slide $slide)
{
if (!$this->slides->contains($slide)) {
$this->slides->add($slide);
$slide->setSlideshow($this);
}
} | [
"public",
"function",
"addSlide",
"(",
"Slide",
"$",
"slide",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"slides",
"->",
"contains",
"(",
"$",
"slide",
")",
")",
"{",
"$",
"this",
"->",
"slides",
"->",
"add",
"(",
"$",
"slide",
")",
";",
"$",
... | Add a slide to the slideshow.
@param Slide $slide | [
"Add",
"a",
"slide",
"to",
"the",
"slideshow",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/slideshow/Entity/Resource/Slideshow.php#L205-L211 |
40,233 | claroline/Distribution | plugin/exo/Serializer/Item/ItemObjectSerializer.php | ItemObjectSerializer.serialize | public function serialize(ItemObject $itemObject, array $options = [])
{
$serialized = [
'id' => $itemObject->getUuid(),
'type' => $itemObject->getMimeType(),
];
if (1 === preg_match('#^text\/[^/]+$#', $itemObject->getMimeType())) {
$serialized['data'] = $itemObject->getData();
} else {
$serialized['url'] = $itemObject->getData();
}
return $serialized;
} | php | public function serialize(ItemObject $itemObject, array $options = [])
{
$serialized = [
'id' => $itemObject->getUuid(),
'type' => $itemObject->getMimeType(),
];
if (1 === preg_match('#^text\/[^/]+$#', $itemObject->getMimeType())) {
$serialized['data'] = $itemObject->getData();
} else {
$serialized['url'] = $itemObject->getData();
}
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"ItemObject",
"$",
"itemObject",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serialized",
"=",
"[",
"'id'",
"=>",
"$",
"itemObject",
"->",
"getUuid",
"(",
")",
",",
"'type'",
"=>",
"$",
"itemObje... | Converts a ItemObject into a JSON-encodable structure.
@param ItemObject $itemObject
@param array $options
@return array | [
"Converts",
"a",
"ItemObject",
"into",
"a",
"JSON",
"-",
"encodable",
"structure",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemObjectSerializer.php#L28-L42 |
40,234 | claroline/Distribution | plugin/exo/Serializer/Item/ItemObjectSerializer.php | ItemObjectSerializer.deserialize | public function deserialize($data, ItemObject $itemObject = null, array $options = [])
{
$itemObject = $itemObject ?: new ItemObject();
$this->sipe('id', 'setUuid', $data, $itemObject);
if (in_array(Transfer::REFRESH_UUID, $options)) {
$itemObject->refreshUuid();
}
$this->sipe('type', 'setMimeType', $data, $itemObject);
$this->sipe('url', 'setData', $data, $itemObject);
$this->sipe('data', 'setData', $data, $itemObject);
return $itemObject;
} | php | public function deserialize($data, ItemObject $itemObject = null, array $options = [])
{
$itemObject = $itemObject ?: new ItemObject();
$this->sipe('id', 'setUuid', $data, $itemObject);
if (in_array(Transfer::REFRESH_UUID, $options)) {
$itemObject->refreshUuid();
}
$this->sipe('type', 'setMimeType', $data, $itemObject);
$this->sipe('url', 'setData', $data, $itemObject);
$this->sipe('data', 'setData', $data, $itemObject);
return $itemObject;
} | [
"public",
"function",
"deserialize",
"(",
"$",
"data",
",",
"ItemObject",
"$",
"itemObject",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"itemObject",
"=",
"$",
"itemObject",
"?",
":",
"new",
"ItemObject",
"(",
")",
";",
... | Converts raw data into a ItemObject entity.
@param array $data
@param ItemObject $itemObject
@param array $options
@return ItemObject | [
"Converts",
"raw",
"data",
"into",
"a",
"ItemObject",
"entity",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemObjectSerializer.php#L53-L67 |
40,235 | claroline/Distribution | main/core/Manager/FacetManager.php | FacetManager.createField | public function createField($name, $isRequired, $type, ResourceNode $resourceNode = null)
{
$fieldFacet = new FieldFacet();
$fieldFacet->setLabel($name);
$fieldFacet->setType($type);
$fieldFacet->setRequired($isRequired);
$fieldFacet->setResourceNode($resourceNode);
$this->om->persist($fieldFacet);
$this->om->flush();
return $fieldFacet;
} | php | public function createField($name, $isRequired, $type, ResourceNode $resourceNode = null)
{
$fieldFacet = new FieldFacet();
$fieldFacet->setLabel($name);
$fieldFacet->setType($type);
$fieldFacet->setRequired($isRequired);
$fieldFacet->setResourceNode($resourceNode);
$this->om->persist($fieldFacet);
$this->om->flush();
return $fieldFacet;
} | [
"public",
"function",
"createField",
"(",
"$",
"name",
",",
"$",
"isRequired",
",",
"$",
"type",
",",
"ResourceNode",
"$",
"resourceNode",
"=",
"null",
")",
"{",
"$",
"fieldFacet",
"=",
"new",
"FieldFacet",
"(",
")",
";",
"$",
"fieldFacet",
"->",
"setLab... | used by clacoForm Manager.
@deprecated
@todo remove me | [
"used",
"by",
"clacoForm",
"Manager",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/FacetManager.php#L81-L92 |
40,236 | claroline/Distribution | main/core/Manager/FacetManager.php | FacetManager.addField | public function addField(PanelFacet $panelFacet, $name, $isRequired, $type)
{
$this->om->startFlushSuite();
$position = $this->om->count('Claroline\CoreBundle\Entity\Facet\FieldFacet');
$fieldFacet = $this->createField($name, $isRequired, $type);
$fieldFacet->setPanelFacet($panelFacet);
$fieldFacet->setPosition($position);
$this->om->persist($fieldFacet);
$this->om->endFlushSuite();
return $fieldFacet;
} | php | public function addField(PanelFacet $panelFacet, $name, $isRequired, $type)
{
$this->om->startFlushSuite();
$position = $this->om->count('Claroline\CoreBundle\Entity\Facet\FieldFacet');
$fieldFacet = $this->createField($name, $isRequired, $type);
$fieldFacet->setPanelFacet($panelFacet);
$fieldFacet->setPosition($position);
$this->om->persist($fieldFacet);
$this->om->endFlushSuite();
return $fieldFacet;
} | [
"public",
"function",
"addField",
"(",
"PanelFacet",
"$",
"panelFacet",
",",
"$",
"name",
",",
"$",
"isRequired",
",",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"om",
"->",
"startFlushSuite",
"(",
")",
";",
"$",
"position",
"=",
"$",
"this",
"->",
"o... | Creates a new field for a facet.
@param PanelFacet $facet
@param string $name
@param int $type
@deprecated
@todo remove me
Used by claco form widget config | [
"Creates",
"a",
"new",
"field",
"for",
"a",
"facet",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/FacetManager.php#L107-L118 |
40,237 | claroline/Distribution | main/core/Manager/FacetManager.php | FacetManager.addPanel | public function addPanel(Facet $facet, $name, $collapse = false, $autoEditable = false)
{
$panelFacet = new PanelFacet();
$panelFacet->setName($name);
$panelFacet->setFacet($facet);
$panelFacet->setIsDefaultCollapsed($collapse);
$panelFacet->setIsEditable($autoEditable);
$panelFacet->setPosition($this->om->count('Claroline\CoreBundle\Entity\Facet\PanelFacet'));
$this->om->persist($panelFacet);
$this->om->flush();
return $panelFacet;
} | php | public function addPanel(Facet $facet, $name, $collapse = false, $autoEditable = false)
{
$panelFacet = new PanelFacet();
$panelFacet->setName($name);
$panelFacet->setFacet($facet);
$panelFacet->setIsDefaultCollapsed($collapse);
$panelFacet->setIsEditable($autoEditable);
$panelFacet->setPosition($this->om->count('Claroline\CoreBundle\Entity\Facet\PanelFacet'));
$this->om->persist($panelFacet);
$this->om->flush();
return $panelFacet;
} | [
"public",
"function",
"addPanel",
"(",
"Facet",
"$",
"facet",
",",
"$",
"name",
",",
"$",
"collapse",
"=",
"false",
",",
"$",
"autoEditable",
"=",
"false",
")",
"{",
"$",
"panelFacet",
"=",
"new",
"PanelFacet",
"(",
")",
";",
"$",
"panelFacet",
"->",
... | Adds a panel in a facet.
Used by persister and Updater04000
Can be removed.
@param Facet $facet
@param string $name
@return PanelFacet | [
"Adds",
"a",
"panel",
"in",
"a",
"facet",
".",
"Used",
"by",
"persister",
"and",
"Updater04000",
"Can",
"be",
"removed",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/FacetManager.php#L130-L142 |
40,238 | claroline/Distribution | main/core/Manager/FacetManager.php | FacetManager.setFieldValue | public function setFieldValue(User $user, FieldFacet $field, $value, $force = false)
{
if (!$this->authorization->isGranted('edit', new FieldFacetCollection([$field], $user)) && !$force) {
throw new AccessDeniedException();
}
$fieldFacetValue = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacetValue')
->findOneBy(['user' => $user, 'fieldFacet' => $field]);
if (null === $fieldFacetValue) {
$fieldFacetValue = new FieldFacetValue();
$fieldFacetValue->setUser($user);
$fieldFacetValue->setFieldFacet($field);
}
switch ($field->getType()) {
case FieldFacet::DATE_TYPE:
$date = is_string($value) ?
new \DateTime($value) :
$value;
$fieldFacetValue->setDateValue($date);
break;
case FieldFacet::NUMBER_TYPE:
$fieldFacetValue->setFloatValue($value);
break;
case FieldFacet::CHOICE_TYPE:
$options = $field->getOptions();
if (isset($options['multiple']) && $options['multiple']) {
$fieldFacetValue->setArrayValue($value);
} else {
$fieldFacetValue->setStringValue($value);
}
break;
case FieldFacet::CASCADE_TYPE:
$fieldFacetValue->setArrayValue($value);
break;
default:
$fieldFacetValue->setStringValue($value);
}
$this->om->persist($fieldFacetValue);
$this->om->flush();
} | php | public function setFieldValue(User $user, FieldFacet $field, $value, $force = false)
{
if (!$this->authorization->isGranted('edit', new FieldFacetCollection([$field], $user)) && !$force) {
throw new AccessDeniedException();
}
$fieldFacetValue = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacetValue')
->findOneBy(['user' => $user, 'fieldFacet' => $field]);
if (null === $fieldFacetValue) {
$fieldFacetValue = new FieldFacetValue();
$fieldFacetValue->setUser($user);
$fieldFacetValue->setFieldFacet($field);
}
switch ($field->getType()) {
case FieldFacet::DATE_TYPE:
$date = is_string($value) ?
new \DateTime($value) :
$value;
$fieldFacetValue->setDateValue($date);
break;
case FieldFacet::NUMBER_TYPE:
$fieldFacetValue->setFloatValue($value);
break;
case FieldFacet::CHOICE_TYPE:
$options = $field->getOptions();
if (isset($options['multiple']) && $options['multiple']) {
$fieldFacetValue->setArrayValue($value);
} else {
$fieldFacetValue->setStringValue($value);
}
break;
case FieldFacet::CASCADE_TYPE:
$fieldFacetValue->setArrayValue($value);
break;
default:
$fieldFacetValue->setStringValue($value);
}
$this->om->persist($fieldFacetValue);
$this->om->flush();
} | [
"public",
"function",
"setFieldValue",
"(",
"User",
"$",
"user",
",",
"FieldFacet",
"$",
"field",
",",
"$",
"value",
",",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"authorization",
"->",
"isGranted",
"(",
"'edit'",
",",
... | Set the value of a field for a user.
@param User $user
@param FieldFacet $field
@param mixed $value
Has some use at the registration/csv import.
Should be removed eventually
@deprecated
@throws \Exception | [
"Set",
"the",
"value",
"of",
"a",
"field",
"for",
"a",
"user",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/FacetManager.php#L158-L201 |
40,239 | claroline/Distribution | main/core/Manager/FacetManager.php | FacetManager.editField | public function editField(FieldFacet $fieldFacet, $name, $isRequired, $type)
{
$fieldFacet->setLabel($name);
$fieldFacet->setType($type);
$fieldFacet->setRequired($isRequired);
$this->om->persist($fieldFacet);
$this->om->flush();
return $fieldFacet;
} | php | public function editField(FieldFacet $fieldFacet, $name, $isRequired, $type)
{
$fieldFacet->setLabel($name);
$fieldFacet->setType($type);
$fieldFacet->setRequired($isRequired);
$this->om->persist($fieldFacet);
$this->om->flush();
return $fieldFacet;
} | [
"public",
"function",
"editField",
"(",
"FieldFacet",
"$",
"fieldFacet",
",",
"$",
"name",
",",
"$",
"isRequired",
",",
"$",
"type",
")",
"{",
"$",
"fieldFacet",
"->",
"setLabel",
"(",
"$",
"name",
")",
";",
"$",
"fieldFacet",
"->",
"setType",
"(",
"$"... | Used by clacoform manager.
@deprecated | [
"Used",
"by",
"clacoform",
"manager",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/FacetManager.php#L219-L228 |
40,240 | claroline/Distribution | plugin/exo/Serializer/Attempt/AnswerSerializer.php | AnswerSerializer.serialize | public function serialize(Answer $answer, array $options = [])
{
$serialized = [
'id' => $answer->getUuid(),
'questionId' => $answer->getQuestionId(),
'tries' => $answer->getTries(),
'usedHints' => array_map(function ($hintId) use ($options) {
return $options['hints'][$hintId];
}, $answer->getUsedHints()),
];
if (!empty($answer->getData())) {
$serialized['data'] = json_decode($answer->getData(), true);
}
// Adds user score
if (in_array(Transfer::INCLUDE_USER_SCORE, $options)) {
$serialized = array_merge($serialized, [
'score' => $answer->getScore(),
'feedback' => $answer->getFeedback(),
]);
}
return $serialized;
} | php | public function serialize(Answer $answer, array $options = [])
{
$serialized = [
'id' => $answer->getUuid(),
'questionId' => $answer->getQuestionId(),
'tries' => $answer->getTries(),
'usedHints' => array_map(function ($hintId) use ($options) {
return $options['hints'][$hintId];
}, $answer->getUsedHints()),
];
if (!empty($answer->getData())) {
$serialized['data'] = json_decode($answer->getData(), true);
}
// Adds user score
if (in_array(Transfer::INCLUDE_USER_SCORE, $options)) {
$serialized = array_merge($serialized, [
'score' => $answer->getScore(),
'feedback' => $answer->getFeedback(),
]);
}
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"Answer",
"$",
"answer",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serialized",
"=",
"[",
"'id'",
"=>",
"$",
"answer",
"->",
"getUuid",
"(",
")",
",",
"'questionId'",
"=>",
"$",
"answer",
"->... | Converts an Answer into a JSON-encodable structure.
@param Answer $answer
@param array $options
@return array | [
"Converts",
"an",
"Answer",
"into",
"a",
"JSON",
"-",
"encodable",
"structure",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Attempt/AnswerSerializer.php#L28-L51 |
40,241 | claroline/Distribution | plugin/exo/Serializer/Attempt/AnswerSerializer.php | AnswerSerializer.deserialize | public function deserialize($data, Answer $answer = null, array $options = [])
{
$answer = $answer ?: new Answer();
$this->sipe('id', 'setUuid', $data, $answer);
$this->sipe('questionId', 'setQuestionId', $data, $answer);
$this->sipe('tries', 'setTries', $data, $answer);
$this->sipe('score', 'setScore', $data, $answer);
$this->sipe('feedback', 'setFeedback', $data, $answer);
if (isset($data['usedHints'])) {
foreach ($data['usedHints'] as $usedHint) {
$answer->addUsedHint($usedHint['id']);
}
}
if (!empty($data['data'])) {
$answer->setData(json_encode($data['data']));
}
return $answer;
} | php | public function deserialize($data, Answer $answer = null, array $options = [])
{
$answer = $answer ?: new Answer();
$this->sipe('id', 'setUuid', $data, $answer);
$this->sipe('questionId', 'setQuestionId', $data, $answer);
$this->sipe('tries', 'setTries', $data, $answer);
$this->sipe('score', 'setScore', $data, $answer);
$this->sipe('feedback', 'setFeedback', $data, $answer);
if (isset($data['usedHints'])) {
foreach ($data['usedHints'] as $usedHint) {
$answer->addUsedHint($usedHint['id']);
}
}
if (!empty($data['data'])) {
$answer->setData(json_encode($data['data']));
}
return $answer;
} | [
"public",
"function",
"deserialize",
"(",
"$",
"data",
",",
"Answer",
"$",
"answer",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"answer",
"=",
"$",
"answer",
"?",
":",
"new",
"Answer",
"(",
")",
";",
"$",
"this",
"->... | Converts raw data into a Answer entity.
@param array $data
@param Answer $answer
@param array $options
@return Answer | [
"Converts",
"raw",
"data",
"into",
"a",
"Answer",
"entity",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Attempt/AnswerSerializer.php#L62-L82 |
40,242 | claroline/Distribution | plugin/exo/Serializer/StepSerializer.php | StepSerializer.serialize | public function serialize(Step $step, array $options = [])
{
$serialized = [
'id' => $step->getUuid(),
'parameters' => $this->serializeParameters($step),
'picking' => $this->serializePicking($step),
'items' => $this->serializeItems($step, $options),
];
if (!empty($step->getTitle())) {
$serialized['title'] = $step->getTitle();
}
if (!empty($step->getDescription())) {
$serialized['description'] = $step->getDescription();
}
return $serialized;
} | php | public function serialize(Step $step, array $options = [])
{
$serialized = [
'id' => $step->getUuid(),
'parameters' => $this->serializeParameters($step),
'picking' => $this->serializePicking($step),
'items' => $this->serializeItems($step, $options),
];
if (!empty($step->getTitle())) {
$serialized['title'] = $step->getTitle();
}
if (!empty($step->getDescription())) {
$serialized['description'] = $step->getDescription();
}
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"Step",
"$",
"step",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serialized",
"=",
"[",
"'id'",
"=>",
"$",
"step",
"->",
"getUuid",
"(",
")",
",",
"'parameters'",
"=>",
"$",
"this",
"->",
"se... | Converts a Step into a JSON-encodable structure.
@param Step $step
@param array $options
@return array | [
"Converts",
"a",
"Step",
"into",
"a",
"JSON",
"-",
"encodable",
"structure",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/StepSerializer.php#L50-L67 |
40,243 | claroline/Distribution | plugin/exo/Serializer/StepSerializer.php | StepSerializer.deserialize | public function deserialize($data, Step $step = null, array $options = [])
{
$step = $step ?: new Step();
$this->sipe('id', 'setUuid', $data, $step);
$this->sipe('title', 'setTitle', $data, $step);
$this->sipe('description', 'setDescription', $data, $step);
if (in_array(Transfer::REFRESH_UUID, $options)) {
$step->refreshUuid();
}
if (!empty($data['parameters'])) {
$this->deserializeParameters($step, $data['parameters']);
}
if (!empty($data['picking'])) {
$this->deserializePicking($step, $data['picking']);
}
if (!empty($data['items'])) {
$this->deserializeItems($step, $data['items'], $options);
}
return $step;
} | php | public function deserialize($data, Step $step = null, array $options = [])
{
$step = $step ?: new Step();
$this->sipe('id', 'setUuid', $data, $step);
$this->sipe('title', 'setTitle', $data, $step);
$this->sipe('description', 'setDescription', $data, $step);
if (in_array(Transfer::REFRESH_UUID, $options)) {
$step->refreshUuid();
}
if (!empty($data['parameters'])) {
$this->deserializeParameters($step, $data['parameters']);
}
if (!empty($data['picking'])) {
$this->deserializePicking($step, $data['picking']);
}
if (!empty($data['items'])) {
$this->deserializeItems($step, $data['items'], $options);
}
return $step;
} | [
"public",
"function",
"deserialize",
"(",
"$",
"data",
",",
"Step",
"$",
"step",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"step",
"=",
"$",
"step",
"?",
":",
"new",
"Step",
"(",
")",
";",
"$",
"this",
"->",
"sipe... | Converts raw data into a Step entity.
@param array $data
@param Step $step
@param array $options
@return Step | [
"Converts",
"raw",
"data",
"into",
"a",
"Step",
"entity",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/StepSerializer.php#L78-L103 |
40,244 | claroline/Distribution | plugin/exo/Serializer/StepSerializer.php | StepSerializer.deserializeParameters | private function deserializeParameters(Step $step, array $parameters)
{
$this->sipe('maxAttempts', 'setMaxAttempts', $parameters, $step);
$this->sipe('duration', 'setDuration', $parameters, $step);
} | php | private function deserializeParameters(Step $step, array $parameters)
{
$this->sipe('maxAttempts', 'setMaxAttempts', $parameters, $step);
$this->sipe('duration', 'setDuration', $parameters, $step);
} | [
"private",
"function",
"deserializeParameters",
"(",
"Step",
"$",
"step",
",",
"array",
"$",
"parameters",
")",
"{",
"$",
"this",
"->",
"sipe",
"(",
"'maxAttempts'",
",",
"'setMaxAttempts'",
",",
"$",
"parameters",
",",
"$",
"step",
")",
";",
"$",
"this",
... | Deserializes Step parameters.
@param Step $step
@param array $parameters | [
"Deserializes",
"Step",
"parameters",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/StepSerializer.php#L126-L130 |
40,245 | claroline/Distribution | plugin/exo/Serializer/StepSerializer.php | StepSerializer.serializeItems | public function serializeItems(Step $step, array $options = [])
{
return array_values(array_map(function (StepItem $stepQuestion) use ($options) {
$serialized = $this->itemSerializer->serialize($stepQuestion->getQuestion(), $options);
$serialized['meta']['mandatory'] = $stepQuestion->isMandatory();
return $serialized;
}, $step->getStepQuestions()->toArray()));
} | php | public function serializeItems(Step $step, array $options = [])
{
return array_values(array_map(function (StepItem $stepQuestion) use ($options) {
$serialized = $this->itemSerializer->serialize($stepQuestion->getQuestion(), $options);
$serialized['meta']['mandatory'] = $stepQuestion->isMandatory();
return $serialized;
}, $step->getStepQuestions()->toArray()));
} | [
"public",
"function",
"serializeItems",
"(",
"Step",
"$",
"step",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"array_values",
"(",
"array_map",
"(",
"function",
"(",
"StepItem",
"$",
"stepQuestion",
")",
"use",
"(",
"$",
"options",
"... | Serializes Step items.
Forwards the item serialization to ItemSerializer.
@param Step $step
@param array $options
@return array | [
"Serializes",
"Step",
"items",
".",
"Forwards",
"the",
"item",
"serialization",
"to",
"ItemSerializer",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/StepSerializer.php#L165-L173 |
40,246 | claroline/Distribution | plugin/exo/Serializer/StepSerializer.php | StepSerializer.deserializeItems | public function deserializeItems(Step $step, array $items = [], array $options = [])
{
$stepQuestions = $step->getStepQuestions()->toArray();
foreach ($items as $index => $itemData) {
$item = null;
$stepQuestion = null;
// Searches for an existing item entity.
foreach ($stepQuestions as $entityIndex => $entityStepQuestion) {
/** @var StepItem $entityStepQuestion */
if ($entityStepQuestion->getQuestion()->getUuid() === $itemData['id']) {
$stepQuestion = $entityStepQuestion;
$item = $stepQuestion->getQuestion();
unset($stepQuestions[$entityIndex]);
break;
}
}
$entity = $this->itemSerializer->deserialize($itemData, $item, $options);
if (empty($stepQuestion)) {
// Creation of a new item (we need to link it to the Step)
$stepQuestion = $step->addQuestion($entity);
} else {
// Update order of the Item in the Step
$stepQuestion->setOrder($index);
}
if (isset($itemData['meta']['mandatory'])) {
$stepQuestion->setMandatory($itemData['meta']['mandatory']);
}
}
// Remaining items are no longer in the Step
if (0 < count($stepQuestions)) {
foreach ($stepQuestions as $stepQuestionToRemove) {
$step->removeStepQuestion($stepQuestionToRemove);
}
}
} | php | public function deserializeItems(Step $step, array $items = [], array $options = [])
{
$stepQuestions = $step->getStepQuestions()->toArray();
foreach ($items as $index => $itemData) {
$item = null;
$stepQuestion = null;
// Searches for an existing item entity.
foreach ($stepQuestions as $entityIndex => $entityStepQuestion) {
/** @var StepItem $entityStepQuestion */
if ($entityStepQuestion->getQuestion()->getUuid() === $itemData['id']) {
$stepQuestion = $entityStepQuestion;
$item = $stepQuestion->getQuestion();
unset($stepQuestions[$entityIndex]);
break;
}
}
$entity = $this->itemSerializer->deserialize($itemData, $item, $options);
if (empty($stepQuestion)) {
// Creation of a new item (we need to link it to the Step)
$stepQuestion = $step->addQuestion($entity);
} else {
// Update order of the Item in the Step
$stepQuestion->setOrder($index);
}
if (isset($itemData['meta']['mandatory'])) {
$stepQuestion->setMandatory($itemData['meta']['mandatory']);
}
}
// Remaining items are no longer in the Step
if (0 < count($stepQuestions)) {
foreach ($stepQuestions as $stepQuestionToRemove) {
$step->removeStepQuestion($stepQuestionToRemove);
}
}
} | [
"public",
"function",
"deserializeItems",
"(",
"Step",
"$",
"step",
",",
"array",
"$",
"items",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"stepQuestions",
"=",
"$",
"step",
"->",
"getStepQuestions",
"(",
")",
"->",
"t... | Deserializes Step items.
Forwards the item deserialization to ItemSerializer.
@param Step $step
@param array $items
@param array $options | [
"Deserializes",
"Step",
"items",
".",
"Forwards",
"the",
"item",
"deserialization",
"to",
"ItemSerializer",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/StepSerializer.php#L183-L223 |
40,247 | claroline/Distribution | plugin/claco-form/Serializer/EntryUserSerializer.php | EntryUserSerializer.serialize | public function serialize(EntryUser $entryUser, array $options = [])
{
$serialized = [
'id' => $entryUser->getUuid(),
'autoId' => $entryUser->getId(),
'entry' => [
'id' => $entryUser->getEntry()->getUuid(),
],
'user' => [
'id' => $entryUser->getUser()->getUuid(),
],
'shared' => $entryUser->isShared(),
'notifyEdition' => $entryUser->getNotifyEdition(),
'notifyComment' => $entryUser->getNotifyComment(),
'notifyVote' => $entryUser->getNotifyVote(),
];
return $serialized;
} | php | public function serialize(EntryUser $entryUser, array $options = [])
{
$serialized = [
'id' => $entryUser->getUuid(),
'autoId' => $entryUser->getId(),
'entry' => [
'id' => $entryUser->getEntry()->getUuid(),
],
'user' => [
'id' => $entryUser->getUser()->getUuid(),
],
'shared' => $entryUser->isShared(),
'notifyEdition' => $entryUser->getNotifyEdition(),
'notifyComment' => $entryUser->getNotifyComment(),
'notifyVote' => $entryUser->getNotifyVote(),
];
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"EntryUser",
"$",
"entryUser",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serialized",
"=",
"[",
"'id'",
"=>",
"$",
"entryUser",
"->",
"getUuid",
"(",
")",
",",
"'autoId'",
"=>",
"$",
"entryUser... | Serializes an EntryUser entity for the JSON api.
@param EntryUser $entryUser - the entry user to serialize
@param array $options - a list of serialization options
@return array - the serialized representation of the entry user | [
"Serializes",
"an",
"EntryUser",
"entity",
"for",
"the",
"JSON",
"api",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/claco-form/Serializer/EntryUserSerializer.php#L25-L43 |
40,248 | claroline/Distribution | plugin/agenda/Controller/API/EventController.php | EventController.listAction | public function listAction(Request $request, $class)
{
$query = $request->query->all();
$hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : [];
$query['hiddenFilters'] = array_merge($hiddenFilters, $this->getDefaultHiddenFilters());
//get start & end date and add them to the hidden filters list
$query['hiddenFilters']['createdAfter'] = $query['start'];
//we want to be able to fetch events that start a months before and ends a month after
$date = new \DateTime($query['end']);
$interval = new \DateInterval('P2M');
$date->add($interval);
$end = $date->format('Y-m-d');
$query['hiddenFilters']['endBefore'] = $end;
$data = $this->finder->search(
$class,
$query,
$this->options['list']
);
return new JsonResponse($data['data']);
} | php | public function listAction(Request $request, $class)
{
$query = $request->query->all();
$hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : [];
$query['hiddenFilters'] = array_merge($hiddenFilters, $this->getDefaultHiddenFilters());
//get start & end date and add them to the hidden filters list
$query['hiddenFilters']['createdAfter'] = $query['start'];
//we want to be able to fetch events that start a months before and ends a month after
$date = new \DateTime($query['end']);
$interval = new \DateInterval('P2M');
$date->add($interval);
$end = $date->format('Y-m-d');
$query['hiddenFilters']['endBefore'] = $end;
$data = $this->finder->search(
$class,
$query,
$this->options['list']
);
return new JsonResponse($data['data']);
} | [
"public",
"function",
"listAction",
"(",
"Request",
"$",
"request",
",",
"$",
"class",
")",
"{",
"$",
"query",
"=",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
";",
"$",
"hiddenFilters",
"=",
"isset",
"(",
"$",
"query",
"[",
"'hiddenFilters'"... | tweaked for fullcalendar.
@param Request $request
@param string $class
@return JsonResponse | [
"tweaked",
"for",
"fullcalendar",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/agenda/Controller/API/EventController.php#L48-L72 |
40,249 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.getWorkspaceTeamParameters | public function getWorkspaceTeamParameters(Workspace $workspace)
{
$teamParams = $this->workspaceTeamParamsRepo->findOneBy(['workspace' => $workspace]);
if (empty($teamParams)) {
$teamParams = new WorkspaceTeamParameters();
$teamParams->setWorkspace($workspace);
}
return $teamParams;
} | php | public function getWorkspaceTeamParameters(Workspace $workspace)
{
$teamParams = $this->workspaceTeamParamsRepo->findOneBy(['workspace' => $workspace]);
if (empty($teamParams)) {
$teamParams = new WorkspaceTeamParameters();
$teamParams->setWorkspace($workspace);
}
return $teamParams;
} | [
"public",
"function",
"getWorkspaceTeamParameters",
"(",
"Workspace",
"$",
"workspace",
")",
"{",
"$",
"teamParams",
"=",
"$",
"this",
"->",
"workspaceTeamParamsRepo",
"->",
"findOneBy",
"(",
"[",
"'workspace'",
"=>",
"$",
"workspace",
"]",
")",
";",
"if",
"("... | Gets team parameters for a workspace.
@param Workspace $workspace
@return WorkspaceTeamParameters | [
"Gets",
"team",
"parameters",
"for",
"a",
"workspace",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L77-L87 |
40,250 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.deleteTeams | public function deleteTeams(array $teams)
{
$this->om->startFlushSuite();
foreach ($teams as $team) {
$this->deleteTeam($team);
}
$this->om->endFlushSuite();
} | php | public function deleteTeams(array $teams)
{
$this->om->startFlushSuite();
foreach ($teams as $team) {
$this->deleteTeam($team);
}
$this->om->endFlushSuite();
} | [
"public",
"function",
"deleteTeams",
"(",
"array",
"$",
"teams",
")",
"{",
"$",
"this",
"->",
"om",
"->",
"startFlushSuite",
"(",
")",
";",
"foreach",
"(",
"$",
"teams",
"as",
"$",
"team",
")",
"{",
"$",
"this",
"->",
"deleteTeam",
"(",
"$",
"team",
... | Deletes multiple teams.
@param array $teams | [
"Deletes",
"multiple",
"teams",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L170-L179 |
40,251 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.deleteTeam | public function deleteTeam(Team $team)
{
$teamRole = $team->getRole();
$teamManagerRole = $team->getTeamManagerRole();
if (!is_null($teamManagerRole)) {
$this->om->remove($teamManagerRole);
}
if (!is_null($teamRole)) {
$this->om->remove($teamRole);
}
$teamDirectory = $team->getDirectory();
if ($team->isDirDeletable() && !is_null($teamDirectory)) {
$this->resourceManager->delete($teamDirectory->getResourceNode());
}
$this->om->remove($team);
$this->om->flush();
} | php | public function deleteTeam(Team $team)
{
$teamRole = $team->getRole();
$teamManagerRole = $team->getTeamManagerRole();
if (!is_null($teamManagerRole)) {
$this->om->remove($teamManagerRole);
}
if (!is_null($teamRole)) {
$this->om->remove($teamRole);
}
$teamDirectory = $team->getDirectory();
if ($team->isDirDeletable() && !is_null($teamDirectory)) {
$this->resourceManager->delete($teamDirectory->getResourceNode());
}
$this->om->remove($team);
$this->om->flush();
} | [
"public",
"function",
"deleteTeam",
"(",
"Team",
"$",
"team",
")",
"{",
"$",
"teamRole",
"=",
"$",
"team",
"->",
"getRole",
"(",
")",
";",
"$",
"teamManagerRole",
"=",
"$",
"team",
"->",
"getTeamManagerRole",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
... | Deletes a team.
@param Team $team | [
"Deletes",
"a",
"team",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L186-L204 |
40,252 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.computeValidTeamName | public function computeValidTeamName(Workspace $workspace, $teamName, $index = 0)
{
$name = 0 === $index ? $teamName : $teamName.' '.$index;
$teams = $this->teamRepo->findBy(['workspace' => $workspace, 'name' => $name]);
while (count($teams) > 0) {
++$index;
$name = $teamName.' '.$index;
$teams = $this->teamRepo->findBy(['workspace' => $workspace, 'name' => $name]);
}
return ['name' => $name, 'index' => $index];
} | php | public function computeValidTeamName(Workspace $workspace, $teamName, $index = 0)
{
$name = 0 === $index ? $teamName : $teamName.' '.$index;
$teams = $this->teamRepo->findBy(['workspace' => $workspace, 'name' => $name]);
while (count($teams) > 0) {
++$index;
$name = $teamName.' '.$index;
$teams = $this->teamRepo->findBy(['workspace' => $workspace, 'name' => $name]);
}
return ['name' => $name, 'index' => $index];
} | [
"public",
"function",
"computeValidTeamName",
"(",
"Workspace",
"$",
"workspace",
",",
"$",
"teamName",
",",
"$",
"index",
"=",
"0",
")",
"{",
"$",
"name",
"=",
"0",
"===",
"$",
"index",
"?",
"$",
"teamName",
":",
"$",
"teamName",
".",
"' '",
".",
"$... | Checks if name already exists and returns a incremented version if it does.
@param Workspace $workspace
@param string $teamName
@param int $index
@return array | [
"Checks",
"if",
"name",
"already",
"exists",
"and",
"returns",
"a",
"incremented",
"version",
"if",
"it",
"does",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L215-L228 |
40,253 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.createTeamRole | public function createTeamRole(Team $team, $isManager = false)
{
$workspace = $team->getWorkspace();
$teamName = $team->getName();
$roleName = $this->computeValidRoleName(
strtoupper(str_replace(' ', '_', $isManager ? $teamName.'_MANAGER' : $teamName)),
$workspace->getUuid()
);
$roleKey = $this->computeValidRoleTranslationKey($workspace, $isManager ? $teamName.' manager' : $teamName);
$role = $this->roleManager->createWorkspaceRole($roleName, $roleKey, $workspace);
$root = $this->resourceManager->getWorkspaceRoot($workspace);
$this->rightsManager->editPerms(['open' => true], $role, $root);
$orderedTool = $this->om
->getRepository('ClarolineCoreBundle:Tool\OrderedTool')
->findOneBy(['workspace' => $workspace, 'name' => 'resource_manager']);
if (!empty($orderedTool)) {
$this->toolRightsManager->setToolRights($orderedTool, $role, 1);
}
$this->setRightsForOldTeams($workspace, $role);
return $role;
} | php | public function createTeamRole(Team $team, $isManager = false)
{
$workspace = $team->getWorkspace();
$teamName = $team->getName();
$roleName = $this->computeValidRoleName(
strtoupper(str_replace(' ', '_', $isManager ? $teamName.'_MANAGER' : $teamName)),
$workspace->getUuid()
);
$roleKey = $this->computeValidRoleTranslationKey($workspace, $isManager ? $teamName.' manager' : $teamName);
$role = $this->roleManager->createWorkspaceRole($roleName, $roleKey, $workspace);
$root = $this->resourceManager->getWorkspaceRoot($workspace);
$this->rightsManager->editPerms(['open' => true], $role, $root);
$orderedTool = $this->om
->getRepository('ClarolineCoreBundle:Tool\OrderedTool')
->findOneBy(['workspace' => $workspace, 'name' => 'resource_manager']);
if (!empty($orderedTool)) {
$this->toolRightsManager->setToolRights($orderedTool, $role, 1);
}
$this->setRightsForOldTeams($workspace, $role);
return $role;
} | [
"public",
"function",
"createTeamRole",
"(",
"Team",
"$",
"team",
",",
"$",
"isManager",
"=",
"false",
")",
"{",
"$",
"workspace",
"=",
"$",
"team",
"->",
"getWorkspace",
"(",
")",
";",
"$",
"teamName",
"=",
"$",
"team",
"->",
"getName",
"(",
")",
";... | Creates role for team members.
@param Team $team
@param bool $isManager
@return Role | [
"Creates",
"role",
"for",
"team",
"members",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L238-L261 |
40,254 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.createTeamDirectory | public function createTeamDirectory(Team $team, User $user, ResourceNode $resource = null, array $creatableResources = [])
{
$workspace = $team->getWorkspace();
$teamRole = $team->getRole();
$teamManagerRole = $team->getTeamManagerRole();
$rootDirectory = $this->resourceManager->getWorkspaceRoot($workspace);
$directoryType = $this->resourceManager->getResourceTypeByName('directory');
$resourceTypes = $this->resourceManager->getAllResourceTypes();
$directory = $this->resourceManager->createResource(
'Claroline\CoreBundle\Entity\Resource\Directory',
$team->getName()
);
$teamRoleName = $teamRole->getName();
$teamManagerRoleName = $teamManagerRole->getName();
$rights = [];
$rights[$teamRoleName] = [];
$rights[$teamRoleName]['role'] = $teamRole;
$rights[$teamRoleName]['create'] = [];
$rights[$teamManagerRoleName] = [];
$rights[$teamManagerRoleName]['role'] = $teamManagerRole;
$rights[$teamManagerRoleName]['create'] = [];
foreach ($resourceTypes as $resourceType) {
$rights[$teamManagerRoleName]['create'][] = ['name' => $resourceType->getName()];
}
foreach ($creatableResources as $creatableResource) {
$rights[$teamRoleName]['create'][] = ['name' => $creatableResource];
}
$decoders = $directoryType->getMaskDecoders();
foreach ($decoders as $decoder) {
$decoderName = $decoder->getName();
if ('create' !== $decoderName) {
$rights[$teamManagerRoleName][$decoderName] = true;
}
if ('administrate' !== $decoderName && 'delete' !== $decoderName && 'create' !== $decoderName) {
$rights[$teamRoleName][$decoderName] = true;
}
}
$teamDirectory = $this->resourceManager->create(
$directory,
$directoryType,
$user,
$workspace,
$rootDirectory,
null,
$rights
);
// TODO : manage rights
if (!is_null($resource)) {
$this->resourceManager->copy(
$resource,
$teamDirectory->getResourceNode(),
$user,
true,
false
);
}
return $teamDirectory;
} | php | public function createTeamDirectory(Team $team, User $user, ResourceNode $resource = null, array $creatableResources = [])
{
$workspace = $team->getWorkspace();
$teamRole = $team->getRole();
$teamManagerRole = $team->getTeamManagerRole();
$rootDirectory = $this->resourceManager->getWorkspaceRoot($workspace);
$directoryType = $this->resourceManager->getResourceTypeByName('directory');
$resourceTypes = $this->resourceManager->getAllResourceTypes();
$directory = $this->resourceManager->createResource(
'Claroline\CoreBundle\Entity\Resource\Directory',
$team->getName()
);
$teamRoleName = $teamRole->getName();
$teamManagerRoleName = $teamManagerRole->getName();
$rights = [];
$rights[$teamRoleName] = [];
$rights[$teamRoleName]['role'] = $teamRole;
$rights[$teamRoleName]['create'] = [];
$rights[$teamManagerRoleName] = [];
$rights[$teamManagerRoleName]['role'] = $teamManagerRole;
$rights[$teamManagerRoleName]['create'] = [];
foreach ($resourceTypes as $resourceType) {
$rights[$teamManagerRoleName]['create'][] = ['name' => $resourceType->getName()];
}
foreach ($creatableResources as $creatableResource) {
$rights[$teamRoleName]['create'][] = ['name' => $creatableResource];
}
$decoders = $directoryType->getMaskDecoders();
foreach ($decoders as $decoder) {
$decoderName = $decoder->getName();
if ('create' !== $decoderName) {
$rights[$teamManagerRoleName][$decoderName] = true;
}
if ('administrate' !== $decoderName && 'delete' !== $decoderName && 'create' !== $decoderName) {
$rights[$teamRoleName][$decoderName] = true;
}
}
$teamDirectory = $this->resourceManager->create(
$directory,
$directoryType,
$user,
$workspace,
$rootDirectory,
null,
$rights
);
// TODO : manage rights
if (!is_null($resource)) {
$this->resourceManager->copy(
$resource,
$teamDirectory->getResourceNode(),
$user,
true,
false
);
}
return $teamDirectory;
} | [
"public",
"function",
"createTeamDirectory",
"(",
"Team",
"$",
"team",
",",
"User",
"$",
"user",
",",
"ResourceNode",
"$",
"resource",
"=",
"null",
",",
"array",
"$",
"creatableResources",
"=",
"[",
"]",
")",
"{",
"$",
"workspace",
"=",
"$",
"team",
"->"... | Creates team directory.
@param Team $team
@param User $user
@param ResourceNode $resource
@param array $creatableResources
@return Directory | [
"Creates",
"team",
"directory",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L273-L338 |
40,255 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.getTeamsByUserAndWorkspace | public function getTeamsByUserAndWorkspace(User $user, Workspace $workspace)
{
return $this->teamRepo->findTeamsByUserAndWorkspace($user, $workspace);
} | php | public function getTeamsByUserAndWorkspace(User $user, Workspace $workspace)
{
return $this->teamRepo->findTeamsByUserAndWorkspace($user, $workspace);
} | [
"public",
"function",
"getTeamsByUserAndWorkspace",
"(",
"User",
"$",
"user",
",",
"Workspace",
"$",
"workspace",
")",
"{",
"return",
"$",
"this",
"->",
"teamRepo",
"->",
"findTeamsByUserAndWorkspace",
"(",
"$",
"user",
",",
"$",
"workspace",
")",
";",
"}"
] | Gets user teams in a workspace.
@param User $user
@param Workspace $workspace
@return array | [
"Gets",
"user",
"teams",
"in",
"a",
"workspace",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L348-L351 |
40,256 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.initializeTeamRights | public function initializeTeamRights(Team $team)
{
$workspace = $team->getWorkspace();
$teamRole = $team->getRole();
$teamManagerRole = $team->getTeamManagerRole();
$resourceNode = !is_null($team->getDirectory()) ? $team->getDirectory()->getResourceNode() : null;
if (!is_null($resourceNode)) {
$workspaceRoles = $this->roleManager->getRolesByWorkspace($workspace);
$rights = [];
foreach ($workspaceRoles as $role) {
if (!in_array($role->getUuid(), [$teamRole->getUuid(), $teamManagerRole->getUuid()])) {
$rights[$role->getName()] = [
'role' => $role,
'create' => [],
'open' => $team->isPublic(),
];
}
}
$this->applyRightsToResourceNode($resourceNode, $rights);
}
} | php | public function initializeTeamRights(Team $team)
{
$workspace = $team->getWorkspace();
$teamRole = $team->getRole();
$teamManagerRole = $team->getTeamManagerRole();
$resourceNode = !is_null($team->getDirectory()) ? $team->getDirectory()->getResourceNode() : null;
if (!is_null($resourceNode)) {
$workspaceRoles = $this->roleManager->getRolesByWorkspace($workspace);
$rights = [];
foreach ($workspaceRoles as $role) {
if (!in_array($role->getUuid(), [$teamRole->getUuid(), $teamManagerRole->getUuid()])) {
$rights[$role->getName()] = [
'role' => $role,
'create' => [],
'open' => $team->isPublic(),
];
}
}
$this->applyRightsToResourceNode($resourceNode, $rights);
}
} | [
"public",
"function",
"initializeTeamRights",
"(",
"Team",
"$",
"team",
")",
"{",
"$",
"workspace",
"=",
"$",
"team",
"->",
"getWorkspace",
"(",
")",
";",
"$",
"teamRole",
"=",
"$",
"team",
"->",
"getRole",
"(",
")",
";",
"$",
"teamManagerRole",
"=",
"... | Sets rights to team directory for all workspace roles.
@param Team $team | [
"Sets",
"rights",
"to",
"team",
"directory",
"for",
"all",
"workspace",
"roles",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L358-L380 |
40,257 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.updateTeamDirectoryPerms | public function updateTeamDirectoryPerms(Team $team)
{
$directory = $team->getDirectory();
if (!is_null($directory)) {
$this->om->startFlushSuite();
$workspace = $team->getWorkspace();
$teamRole = $team->getRole();
$teamManagerRole = $team->getTeamManagerRole();
$workspaceRoles = $this->roleManager->getRolesByWorkspace($workspace);
foreach ($workspaceRoles as $role) {
if (!in_array($role->getUuid(), [$teamRole->getUuid(), $teamManagerRole->getUuid()])) {
$rights = ['open' => $team->isPublic()];
$this->rightsManager->editPerms($rights, $role, $directory->getResourceNode(), true);
}
}
$this->om->endFlushSuite();
}
} | php | public function updateTeamDirectoryPerms(Team $team)
{
$directory = $team->getDirectory();
if (!is_null($directory)) {
$this->om->startFlushSuite();
$workspace = $team->getWorkspace();
$teamRole = $team->getRole();
$teamManagerRole = $team->getTeamManagerRole();
$workspaceRoles = $this->roleManager->getRolesByWorkspace($workspace);
foreach ($workspaceRoles as $role) {
if (!in_array($role->getUuid(), [$teamRole->getUuid(), $teamManagerRole->getUuid()])) {
$rights = ['open' => $team->isPublic()];
$this->rightsManager->editPerms($rights, $role, $directory->getResourceNode(), true);
}
}
$this->om->endFlushSuite();
}
} | [
"public",
"function",
"updateTeamDirectoryPerms",
"(",
"Team",
"$",
"team",
")",
"{",
"$",
"directory",
"=",
"$",
"team",
"->",
"getDirectory",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"this",
"->",
"om",
"... | Updates permissions of team directory..
@param Team $team | [
"Updates",
"permissions",
"of",
"team",
"directory",
".."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L387-L407 |
40,258 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.initializeTeamPerms | public function initializeTeamPerms(Team $team, array $roles)
{
$directory = $team->getDirectory();
if (!is_null($directory)) {
$this->om->startFlushSuite();
$node = $directory->getResourceNode();
foreach ($roles as $role) {
if ($role === $team->getRole()) {
$perms = ['open' => true, 'edit' => true, 'export' => true, 'copy' => true];
$creatable = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll();
} elseif ($role === $team->getTeamManagerRole()) {
$perms = ['open' => true, 'edit' => true, 'export' => true, 'copy' => true, 'delete' => true, 'administrate' => true];
$creatable = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll();
} elseif ($team->isPublic()) {
$perms = ['open' => true];
$creatable = [];
}
$this->rightsManager->editPerms($perms, $role, $node, true, $creatable, true);
}
$this->om->endFlushSuite();
}
} | php | public function initializeTeamPerms(Team $team, array $roles)
{
$directory = $team->getDirectory();
if (!is_null($directory)) {
$this->om->startFlushSuite();
$node = $directory->getResourceNode();
foreach ($roles as $role) {
if ($role === $team->getRole()) {
$perms = ['open' => true, 'edit' => true, 'export' => true, 'copy' => true];
$creatable = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll();
} elseif ($role === $team->getTeamManagerRole()) {
$perms = ['open' => true, 'edit' => true, 'export' => true, 'copy' => true, 'delete' => true, 'administrate' => true];
$creatable = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll();
} elseif ($team->isPublic()) {
$perms = ['open' => true];
$creatable = [];
}
$this->rightsManager->editPerms($perms, $role, $node, true, $creatable, true);
}
$this->om->endFlushSuite();
}
} | [
"public",
"function",
"initializeTeamPerms",
"(",
"Team",
"$",
"team",
",",
"array",
"$",
"roles",
")",
"{",
"$",
"directory",
"=",
"$",
"team",
"->",
"getDirectory",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"directory",
")",
")",
"{",
"$"... | Initializes directory permissions. Used in command.
@param Team $team
@param array $roles | [
"Initializes",
"directory",
"permissions",
".",
"Used",
"in",
"command",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L415-L440 |
40,259 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.registerManagersToTeam | public function registerManagersToTeam(Team $team, array $users)
{
$teamManagerRole = $team->getTeamManagerRole();
if (!is_null($teamManagerRole) && 0 < count($users)) {
$this->om->startFlushSuite();
$team->setTeamManager($users[0]);
foreach ($users as $user) {
$this->roleManager->associateRole($user, $teamManagerRole);
}
$this->om->persist($team);
$this->om->endFlushSuite();
}
} | php | public function registerManagersToTeam(Team $team, array $users)
{
$teamManagerRole = $team->getTeamManagerRole();
if (!is_null($teamManagerRole) && 0 < count($users)) {
$this->om->startFlushSuite();
$team->setTeamManager($users[0]);
foreach ($users as $user) {
$this->roleManager->associateRole($user, $teamManagerRole);
}
$this->om->persist($team);
$this->om->endFlushSuite();
}
} | [
"public",
"function",
"registerManagersToTeam",
"(",
"Team",
"$",
"team",
",",
"array",
"$",
"users",
")",
"{",
"$",
"teamManagerRole",
"=",
"$",
"team",
"->",
"getTeamManagerRole",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"teamManagerRole",
")"... | Registers users as team managers.
@param Team $team
@param array $users | [
"Registers",
"users",
"as",
"team",
"managers",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L492-L507 |
40,260 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.unregisterManagersFromTeam | public function unregisterManagersFromTeam(Team $team, array $users)
{
$teamManagerRole = $team->getTeamManagerRole();
if (!is_null($teamManagerRole)) {
$this->om->startFlushSuite();
$teamManager = $team->getTeamManager();
foreach ($users as $user) {
$this->roleManager->dissociateRole($user, $teamManagerRole);
if ($teamManager && $teamManager->getid() === $user->getId()) {
$team->setTeamManager(null);
}
}
$this->om->persist($team);
$this->om->endFlushSuite();
}
} | php | public function unregisterManagersFromTeam(Team $team, array $users)
{
$teamManagerRole = $team->getTeamManagerRole();
if (!is_null($teamManagerRole)) {
$this->om->startFlushSuite();
$teamManager = $team->getTeamManager();
foreach ($users as $user) {
$this->roleManager->dissociateRole($user, $teamManagerRole);
if ($teamManager && $teamManager->getid() === $user->getId()) {
$team->setTeamManager(null);
}
}
$this->om->persist($team);
$this->om->endFlushSuite();
}
} | [
"public",
"function",
"unregisterManagersFromTeam",
"(",
"Team",
"$",
"team",
",",
"array",
"$",
"users",
")",
"{",
"$",
"teamManagerRole",
"=",
"$",
"team",
"->",
"getTeamManagerRole",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"teamManagerRole",
... | Unregisters team managers.
@param Team $team
@param array $users | [
"Unregisters",
"team",
"managers",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L515-L534 |
40,261 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.emptyTeams | public function emptyTeams(array $teams)
{
$this->om->startFlushSuite();
foreach ($teams as $team) {
$users = $team->getRole()->getUsers()->toArray();
$this->unregisterUsersFromTeam($team, $users);
}
$this->om->endFlushSuite();
} | php | public function emptyTeams(array $teams)
{
$this->om->startFlushSuite();
foreach ($teams as $team) {
$users = $team->getRole()->getUsers()->toArray();
$this->unregisterUsersFromTeam($team, $users);
}
$this->om->endFlushSuite();
} | [
"public",
"function",
"emptyTeams",
"(",
"array",
"$",
"teams",
")",
"{",
"$",
"this",
"->",
"om",
"->",
"startFlushSuite",
"(",
")",
";",
"foreach",
"(",
"$",
"teams",
"as",
"$",
"team",
")",
"{",
"$",
"users",
"=",
"$",
"team",
"->",
"getRole",
"... | Empty teams from all members.
@param array $teams | [
"Empty",
"teams",
"from",
"all",
"members",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L541-L550 |
40,262 | claroline/Distribution | plugin/team/Manager/TeamManager.php | TeamManager.computeValidRoleTranslationKey | private function computeValidRoleTranslationKey(Workspace $workspace, $key)
{
$i = 1;
$translationKey = $key;
$role = $this->roleManager->getRoleByTranslationKeyAndWorkspace($translationKey, $workspace);
while (!is_null($role)) {
$translationKey = $key.' ('.$i.')';
$role = $this->roleManager->getRoleByTranslationKeyAndWorkspace($translationKey, $workspace);
++$i;
}
return $translationKey;
} | php | private function computeValidRoleTranslationKey(Workspace $workspace, $key)
{
$i = 1;
$translationKey = $key;
$role = $this->roleManager->getRoleByTranslationKeyAndWorkspace($translationKey, $workspace);
while (!is_null($role)) {
$translationKey = $key.' ('.$i.')';
$role = $this->roleManager->getRoleByTranslationKeyAndWorkspace($translationKey, $workspace);
++$i;
}
return $translationKey;
} | [
"private",
"function",
"computeValidRoleTranslationKey",
"(",
"Workspace",
"$",
"workspace",
",",
"$",
"key",
")",
"{",
"$",
"i",
"=",
"1",
";",
"$",
"translationKey",
"=",
"$",
"key",
";",
"$",
"role",
"=",
"$",
"this",
"->",
"roleManager",
"->",
"getRo... | Checks and updates role translation key for unicity.
@param Workspace $workspace
@param string $key
@return string | [
"Checks",
"and",
"updates",
"role",
"translation",
"key",
"for",
"unicity",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Manager/TeamManager.php#L621-L634 |
40,263 | claroline/Distribution | main/app/API/Finder/AbstractFinder.php | AbstractFinder.setObjectManager | public function setObjectManager(
ObjectManager $om,
EntityManager $em,
StrictDispatcher $eventDispatcher
) {
$this->om = $om;
$this->_em = $em;
$this->eventDispatcher = $eventDispatcher;
} | php | public function setObjectManager(
ObjectManager $om,
EntityManager $em,
StrictDispatcher $eventDispatcher
) {
$this->om = $om;
$this->_em = $em;
$this->eventDispatcher = $eventDispatcher;
} | [
"public",
"function",
"setObjectManager",
"(",
"ObjectManager",
"$",
"om",
",",
"EntityManager",
"$",
"em",
",",
"StrictDispatcher",
"$",
"eventDispatcher",
")",
"{",
"$",
"this",
"->",
"om",
"=",
"$",
"om",
";",
"$",
"this",
"->",
"_em",
"=",
"$",
"em",... | AbstractFinder constructor.
@DI\InjectParams({
"om" = @DI\Inject("claroline.persistence.object_manager"),
"em" = @DI\Inject("doctrine.orm.entity_manager"),
"eventDispatcher" = @DI\Inject("claroline.event.event_dispatcher")
})
@param ObjectManager $om
@param EntityManager $em
@param StrictDispatcher $eventDispatcher | [
"AbstractFinder",
"constructor",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Finder/AbstractFinder.php#L49-L57 |
40,264 | claroline/Distribution | main/app/API/Finder/AbstractFinder.php | AbstractFinder.delete | public function delete(array $filters = [])
{
/** @var QueryBuilder $qb */
$qb = $this->om->createQueryBuilder();
$qb->delete($this->getClass(), 'obj');
// filter query - let's the finder implementation process the filters to configure query
$query = $this->configureQueryBuilder($qb, $filters);
if ($query instanceof QueryBuilder) {
$qb = $query;
}
if (!($query instanceof NativeQuery)) {
// order query if implementation has not done it
$query = $qb->getQuery();
}
$query->getResult();
} | php | public function delete(array $filters = [])
{
/** @var QueryBuilder $qb */
$qb = $this->om->createQueryBuilder();
$qb->delete($this->getClass(), 'obj');
// filter query - let's the finder implementation process the filters to configure query
$query = $this->configureQueryBuilder($qb, $filters);
if ($query instanceof QueryBuilder) {
$qb = $query;
}
if (!($query instanceof NativeQuery)) {
// order query if implementation has not done it
$query = $qb->getQuery();
}
$query->getResult();
} | [
"public",
"function",
"delete",
"(",
"array",
"$",
"filters",
"=",
"[",
"]",
")",
"{",
"/** @var QueryBuilder $qb */",
"$",
"qb",
"=",
"$",
"this",
"->",
"om",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"delete",
"(",
"$",
"this",
"->"... | Might not be fully functional with the unions. | [
"Might",
"not",
"be",
"fully",
"functional",
"with",
"the",
"unions",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Finder/AbstractFinder.php#L72-L91 |
40,265 | claroline/Distribution | main/app/Persistence/ObjectManager.php | ObjectManager.rollBack | public function rollBack()
{
$this->assertIsSupported($this->supportsTransactions, __METHOD__);
$this->wrapped->getConnection()->rollBack();
} | php | public function rollBack()
{
$this->assertIsSupported($this->supportsTransactions, __METHOD__);
$this->wrapped->getConnection()->rollBack();
} | [
"public",
"function",
"rollBack",
"(",
")",
"{",
"$",
"this",
"->",
"assertIsSupported",
"(",
"$",
"this",
"->",
"supportsTransactions",
",",
"__METHOD__",
")",
";",
"$",
"this",
"->",
"wrapped",
"->",
"getConnection",
"(",
")",
"->",
"rollBack",
"(",
")",... | Rollbacks a transaction.
@throws UnsupportedMethodException if the method is not supported by
the underlying object manager | [
"Rollbacks",
"a",
"transaction",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/Persistence/ObjectManager.php#L199-L203 |
40,266 | claroline/Distribution | main/app/Persistence/ObjectManager.php | ObjectManager.findList | public function findList($class, $property, array $list, $orderStrict = false)
{
if (0 === count($list)) {
return [];
}
$dql = "SELECT object FROM {$class} object WHERE object.{$property} IN (:list)";
$query = $this->wrapped->createQuery($dql);
$query->setParameter('list', $list);
$objects = $query->getResult();
if (($entityCount = count($objects)) !== ($idCount = count($list))) {
$this->monolog->warning("{$entityCount} out of {$idCount} ids don't match any existing object");
}
if ($orderStrict) {
// Sort objects to have the same order as given $ids array
$sortIds = array_flip($list);
usort($objects, function ($a, $b) use ($sortIds) {
return $sortIds[$a->getId()] - $sortIds[$b->getId()];
});
}
return $objects;
} | php | public function findList($class, $property, array $list, $orderStrict = false)
{
if (0 === count($list)) {
return [];
}
$dql = "SELECT object FROM {$class} object WHERE object.{$property} IN (:list)";
$query = $this->wrapped->createQuery($dql);
$query->setParameter('list', $list);
$objects = $query->getResult();
if (($entityCount = count($objects)) !== ($idCount = count($list))) {
$this->monolog->warning("{$entityCount} out of {$idCount} ids don't match any existing object");
}
if ($orderStrict) {
// Sort objects to have the same order as given $ids array
$sortIds = array_flip($list);
usort($objects, function ($a, $b) use ($sortIds) {
return $sortIds[$a->getId()] - $sortIds[$b->getId()];
});
}
return $objects;
} | [
"public",
"function",
"findList",
"(",
"$",
"class",
",",
"$",
"property",
",",
"array",
"$",
"list",
",",
"$",
"orderStrict",
"=",
"false",
")",
"{",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"list",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
... | Finds a set of objects.
@param $class
@param $property
@param array $list
@param bool $orderStrict keep the same order as ids array
@return array [object]
@throws MissingObjectException if any of the requested objects cannot be found
@internal param string $objectClass
@todo make this method compatible with odm implementations | [
"Finds",
"a",
"set",
"of",
"objects",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/Persistence/ObjectManager.php#L269-L293 |
40,267 | claroline/Distribution | main/app/Persistence/ObjectManager.php | ObjectManager.count | public function count($class)
{
$dql = "SELECT COUNT(object) FROM {$class} object";
$query = $this->wrapped->createQuery($dql);
return (int) $query->getSingleScalarResult();
} | php | public function count($class)
{
$dql = "SELECT COUNT(object) FROM {$class} object";
$query = $this->wrapped->createQuery($dql);
return (int) $query->getSingleScalarResult();
} | [
"public",
"function",
"count",
"(",
"$",
"class",
")",
"{",
"$",
"dql",
"=",
"\"SELECT COUNT(object) FROM {$class} object\"",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"wrapped",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"return",
"(",
"int",
")",
... | Counts objects of a given class.
@param string $class
@return int
@todo make this method compatible with odm implementations | [
"Counts",
"objects",
"of",
"a",
"given",
"class",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/Persistence/ObjectManager.php#L304-L310 |
40,268 | claroline/Distribution | main/core/Library/View/Serializer/Serializer.php | Serializer.getClass | private function getClass($array, &$objects)
{
foreach ($array as $el) {
if (is_object($el)) {
$objects = $array;
$class = get_class($el);
} else {
if (is_array($el)) {
$class = $this->getClass($el, $objects);
}
}
}
return $class;
} | php | private function getClass($array, &$objects)
{
foreach ($array as $el) {
if (is_object($el)) {
$objects = $array;
$class = get_class($el);
} else {
if (is_array($el)) {
$class = $this->getClass($el, $objects);
}
}
}
return $class;
} | [
"private",
"function",
"getClass",
"(",
"$",
"array",
",",
"&",
"$",
"objects",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"el",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"el",
")",
")",
"{",
"$",
"objects",
"=",
"$",
"array",
";",
"$... | it is the only thing I'll support. | [
"it",
"is",
"the",
"only",
"thing",
"I",
"ll",
"support",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Library/View/Serializer/Serializer.php#L196-L211 |
40,269 | claroline/Distribution | plugin/path/Entity/Path/Path.php | Path.getStructure | public function getStructure()
{
$isPublished = $this->isPublished();
if ($isPublished && !$this->modified) {
// Rebuild the structure of the Path from generated data
// This permits to merge modifications made on generated data into the Path
$structure = json_encode($this); // See `jsonSerialize` to know how it's populated
} else {
// There are unpublished data so get the structure generated by the editor
$structure = $this->structure;
}
return $structure;
} | php | public function getStructure()
{
$isPublished = $this->isPublished();
if ($isPublished && !$this->modified) {
// Rebuild the structure of the Path from generated data
// This permits to merge modifications made on generated data into the Path
$structure = json_encode($this); // See `jsonSerialize` to know how it's populated
} else {
// There are unpublished data so get the structure generated by the editor
$structure = $this->structure;
}
return $structure;
} | [
"public",
"function",
"getStructure",
"(",
")",
"{",
"$",
"isPublished",
"=",
"$",
"this",
"->",
"isPublished",
"(",
")",
";",
"if",
"(",
"$",
"isPublished",
"&&",
"!",
"$",
"this",
"->",
"modified",
")",
"{",
"// Rebuild the structure of the Path from generat... | Get a JSON version of the Path.
@return string | [
"Get",
"a",
"JSON",
"version",
"of",
"the",
"Path",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Entity/Path/Path.php#L127-L140 |
40,270 | claroline/Distribution | plugin/path/Entity/Path/Path.php | Path.addStep | public function addStep(Step $step)
{
if (!$this->steps->contains($step)) {
$this->steps->add($step);
}
return $this;
} | php | public function addStep(Step $step)
{
if (!$this->steps->contains($step)) {
$this->steps->add($step);
}
return $this;
} | [
"public",
"function",
"addStep",
"(",
"Step",
"$",
"step",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"steps",
"->",
"contains",
"(",
"$",
"step",
")",
")",
"{",
"$",
"this",
"->",
"steps",
"->",
"add",
"(",
"$",
"step",
")",
";",
"}",
"retur... | Add step.
@param Step $step
@return Path | [
"Add",
"step",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Entity/Path/Path.php#L149-L156 |
40,271 | claroline/Distribution | plugin/path/Entity/Path/Path.php | Path.getRootSteps | public function getRootSteps()
{
$roots = [];
if (!empty($this->steps)) {
foreach ($this->steps as $step) {
if (null === $step->getParent()) {
// Root step found
$roots[] = $step;
}
}
}
return $roots;
} | php | public function getRootSteps()
{
$roots = [];
if (!empty($this->steps)) {
foreach ($this->steps as $step) {
if (null === $step->getParent()) {
// Root step found
$roots[] = $step;
}
}
}
return $roots;
} | [
"public",
"function",
"getRootSteps",
"(",
")",
"{",
"$",
"roots",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"steps",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"steps",
"as",
"$",
"step",
")",
"{",
"if",
"(",
... | Get root step of the path.
@return Step[] | [
"Get",
"root",
"step",
"of",
"the",
"path",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Entity/Path/Path.php#L273-L287 |
40,272 | claroline/Distribution | plugin/path/Entity/Path/Path.php | Path.initializeStructure | public function initializeStructure()
{
$structure = [
'id' => $this->getId(),
'name' => $this->getName(),
'description' => $this->getDescription(),
'manualProgressionAllowed' => $this->manualProgressionAllowed,
'steps' => [],
];
$this->setStructure(json_encode($structure));
return $this;
} | php | public function initializeStructure()
{
$structure = [
'id' => $this->getId(),
'name' => $this->getName(),
'description' => $this->getDescription(),
'manualProgressionAllowed' => $this->manualProgressionAllowed,
'steps' => [],
];
$this->setStructure(json_encode($structure));
return $this;
} | [
"public",
"function",
"initializeStructure",
"(",
")",
"{",
"$",
"structure",
"=",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"'name'",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'description'",
"=>",
"$",
"this",
"->",
"g... | Initialize JSON structure.
@return Path
@deprecated | [
"Initialize",
"JSON",
"structure",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Entity/Path/Path.php#L296-L309 |
40,273 | claroline/Distribution | main/core/Security/Voter/WorkspaceVoter.php | WorkspaceVoter.checkCreation | private function checkCreation(TokenInterface $token)
{
if ($this->hasAdminToolAccess($token, 'workspace_management') || $this->isWorkspaceCreator($token)) {
return VoterInterface::ACCESS_GRANTED;
}
return VoterInterface::ACCESS_DENIED;
} | php | private function checkCreation(TokenInterface $token)
{
if ($this->hasAdminToolAccess($token, 'workspace_management') || $this->isWorkspaceCreator($token)) {
return VoterInterface::ACCESS_GRANTED;
}
return VoterInterface::ACCESS_DENIED;
} | [
"private",
"function",
"checkCreation",
"(",
"TokenInterface",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasAdminToolAccess",
"(",
"$",
"token",
",",
"'workspace_management'",
")",
"||",
"$",
"this",
"->",
"isWorkspaceCreator",
"(",
"$",
"token",
... | workspace creator handling ? | [
"workspace",
"creator",
"handling",
"?"
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Security/Voter/WorkspaceVoter.php#L75-L82 |
40,274 | claroline/Distribution | plugin/tag/Manager/TagManager.php | TagManager.getUowScheduledTag | private function getUowScheduledTag($name, User $user = null)
{
$scheduledForInsert = $this->om->getUnitOfWork()->getScheduledEntityInsertions();
foreach ($scheduledForInsert as $entity) {
/** @var Tag $entity */
if ($entity instanceof Tag
&& $name === $entity->getName()
&& $user === $entity->getUser()) {
return $entity;
}
}
return null;
} | php | private function getUowScheduledTag($name, User $user = null)
{
$scheduledForInsert = $this->om->getUnitOfWork()->getScheduledEntityInsertions();
foreach ($scheduledForInsert as $entity) {
/** @var Tag $entity */
if ($entity instanceof Tag
&& $name === $entity->getName()
&& $user === $entity->getUser()) {
return $entity;
}
}
return null;
} | [
"private",
"function",
"getUowScheduledTag",
"(",
"$",
"name",
",",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"scheduledForInsert",
"=",
"$",
"this",
"->",
"om",
"->",
"getUnitOfWork",
"(",
")",
"->",
"getScheduledEntityInsertions",
"(",
")",
";",
"... | Avoids duplicate creation of a tag when inside a flushSuite.
The only way to do that is to search in the current UOW if a tag with the same name
is already scheduled for insertion.
@param string $name
@param User $user
@return Tag|null | [
"Avoids",
"duplicate",
"creation",
"of",
"a",
"tag",
"when",
"inside",
"a",
"flushSuite",
".",
"The",
"only",
"way",
"to",
"do",
"that",
"is",
"to",
"search",
"in",
"the",
"current",
"UOW",
"if",
"a",
"tag",
"with",
"the",
"same",
"name",
"is",
"alread... | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Manager/TagManager.php#L114-L127 |
40,275 | claroline/Distribution | main/core/Library/Utilities/ThumbnailCreator.php | ThumbnailCreator.fromVideo | public function fromVideo($originalPath, $destinationPath, $newWidth, $newHeight)
{
if (!$this->isGdLoaded || !$this->isFfmpegLoaded) {
$message = '';
if (!$this->isGdLoaded) {
$message .= 'The GD extension is missing \n';
}
if (!$this->isFfmpegLoaded) {
$message .= 'The Ffmpeg extension is missing \n';
}
throw new UnloadedExtensionException($message);
}
$media = new \ffmpeg_movie($originalPath);
$frameCount = $media->getFrameCount();
$frame = $media->getFrame(round($frameCount / 2));
if ($frame) {
$image = $frame->toGDImage();
$this->resize($newWidth, $newHeight, $image, $destinationPath);
return $destinationPath;
}
$exception = new ExtensionNotSupportedException();
$exception->setExtension(pathinfo($originalPath, PATHINFO_EXTENSION));
throw $exception;
} | php | public function fromVideo($originalPath, $destinationPath, $newWidth, $newHeight)
{
if (!$this->isGdLoaded || !$this->isFfmpegLoaded) {
$message = '';
if (!$this->isGdLoaded) {
$message .= 'The GD extension is missing \n';
}
if (!$this->isFfmpegLoaded) {
$message .= 'The Ffmpeg extension is missing \n';
}
throw new UnloadedExtensionException($message);
}
$media = new \ffmpeg_movie($originalPath);
$frameCount = $media->getFrameCount();
$frame = $media->getFrame(round($frameCount / 2));
if ($frame) {
$image = $frame->toGDImage();
$this->resize($newWidth, $newHeight, $image, $destinationPath);
return $destinationPath;
}
$exception = new ExtensionNotSupportedException();
$exception->setExtension(pathinfo($originalPath, PATHINFO_EXTENSION));
throw $exception;
} | [
"public",
"function",
"fromVideo",
"(",
"$",
"originalPath",
",",
"$",
"destinationPath",
",",
"$",
"newWidth",
",",
"$",
"newHeight",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isGdLoaded",
"||",
"!",
"$",
"this",
"->",
"isFfmpegLoaded",
")",
"{",
... | Create an thumbnail from a video. Returns null if the creation failed.
@param string $originalPath the path of the orignal video
@param string $destinationPath the path were the thumbnail will be copied
@param int $newWidth the width of the thumbnail
@param int $newHeight the width of the thumbnail
@return string | [
"Create",
"an",
"thumbnail",
"from",
"a",
"video",
".",
"Returns",
"null",
"if",
"the",
"creation",
"failed",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Library/Utilities/ThumbnailCreator.php#L60-L88 |
40,276 | claroline/Distribution | plugin/slideshow/Serializer/SlideshowSerializer.php | SlideshowSerializer.serialize | public function serialize(Slideshow $slideshow)
{
return [
'id' => $slideshow->getUuid(),
'autoPlay' => $slideshow->getAutoPlay(),
'interval' => $slideshow->getInterval(),
'display' => [
'description' => $slideshow->getDescription(),
'showOverview' => $slideshow->getShowOverview(),
'showControls' => $slideshow->getShowControls(),
],
'slides' => array_map(function (Slide $slide) {
$content = null;
// TODO : enhance to allow more than files
if (!empty($slide->getContent())) {
/** @var PublicFile $file */
$file = $this->om
->getRepository(PublicFile::class)
->findOneBy(['url' => $slide->getContent()]);
if ($file) {
$content = $this->fileSerializer->serialize($file);
}
}
return [
'id' => $slide->getUuid(),
'content' => $content,
'meta' => [
'title' => $slide->getTitle(),
'description' => $slide->getDescription(),
],
];
}, $slideshow->getSlides()->toArray()),
];
} | php | public function serialize(Slideshow $slideshow)
{
return [
'id' => $slideshow->getUuid(),
'autoPlay' => $slideshow->getAutoPlay(),
'interval' => $slideshow->getInterval(),
'display' => [
'description' => $slideshow->getDescription(),
'showOverview' => $slideshow->getShowOverview(),
'showControls' => $slideshow->getShowControls(),
],
'slides' => array_map(function (Slide $slide) {
$content = null;
// TODO : enhance to allow more than files
if (!empty($slide->getContent())) {
/** @var PublicFile $file */
$file = $this->om
->getRepository(PublicFile::class)
->findOneBy(['url' => $slide->getContent()]);
if ($file) {
$content = $this->fileSerializer->serialize($file);
}
}
return [
'id' => $slide->getUuid(),
'content' => $content,
'meta' => [
'title' => $slide->getTitle(),
'description' => $slide->getDescription(),
],
];
}, $slideshow->getSlides()->toArray()),
];
} | [
"public",
"function",
"serialize",
"(",
"Slideshow",
"$",
"slideshow",
")",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"slideshow",
"->",
"getUuid",
"(",
")",
",",
"'autoPlay'",
"=>",
"$",
"slideshow",
"->",
"getAutoPlay",
"(",
")",
",",
"'interval'",
"=>",
... | Serializes a Slideshow entity for the JSON api.
@param Slideshow $slideshow
@return array | [
"Serializes",
"a",
"Slideshow",
"entity",
"for",
"the",
"JSON",
"api",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/slideshow/Serializer/SlideshowSerializer.php#L70-L105 |
40,277 | claroline/Distribution | plugin/slideshow/Serializer/SlideshowSerializer.php | SlideshowSerializer.deserialize | public function deserialize($data, Slideshow $slideshow, array $options = [])
{
$this->sipe('autoPlay', 'setAutoPlay', $data, $slideshow);
$this->sipe('interval', 'setInterval', $data, $slideshow);
$this->sipe('display.description', 'setDescription', $data, $slideshow);
$this->sipe('display.showOverview', 'setShowOverview', $data, $slideshow);
$this->sipe('display.showControls', 'setShowControls', $data, $slideshow);
if (isset($data['slides'])) {
// we will remove updated slides from this list
// remaining ones will be deleted
$existingSlides = $slideshow->getSlides()->toArray();
foreach ($data['slides'] as $slideOrder => $slideData) {
$slide = new Slide();
/**
* check if slide already exists.
*
* @var int
* @var Slide $existing
*/
foreach ($existingSlides as $index => $existing) {
if (isset($existing) && $existing->getUuid() === $slideData['id']) {
// slide found
$slide = $existing;
unset($existingSlides[$index]);
break;
}
}
$slide->setOrder($slideOrder);
if (!in_array(Options::REFRESH_UUID, $options)) {
$this->sipe('id', 'setUuid', $data, $slideshow);
}
$this->sipe('meta.title', 'setTitle', $slideData, $slide);
$this->sipe('meta.description', 'setDescription', $slideData, $slide);
// TODO : enhance to allow more than files (eg. HTML)
$this->sipe('content.url', 'setContent', $slideData, $slide);
$slideshow->addSlide($slide);
}
// Delete slides which no longer exist
$slidesToDelete = array_values($existingSlides);
foreach ($slidesToDelete as $toDelete) {
$slideshow->removeSlide($toDelete);
}
}
return $slideshow;
} | php | public function deserialize($data, Slideshow $slideshow, array $options = [])
{
$this->sipe('autoPlay', 'setAutoPlay', $data, $slideshow);
$this->sipe('interval', 'setInterval', $data, $slideshow);
$this->sipe('display.description', 'setDescription', $data, $slideshow);
$this->sipe('display.showOverview', 'setShowOverview', $data, $slideshow);
$this->sipe('display.showControls', 'setShowControls', $data, $slideshow);
if (isset($data['slides'])) {
// we will remove updated slides from this list
// remaining ones will be deleted
$existingSlides = $slideshow->getSlides()->toArray();
foreach ($data['slides'] as $slideOrder => $slideData) {
$slide = new Slide();
/**
* check if slide already exists.
*
* @var int
* @var Slide $existing
*/
foreach ($existingSlides as $index => $existing) {
if (isset($existing) && $existing->getUuid() === $slideData['id']) {
// slide found
$slide = $existing;
unset($existingSlides[$index]);
break;
}
}
$slide->setOrder($slideOrder);
if (!in_array(Options::REFRESH_UUID, $options)) {
$this->sipe('id', 'setUuid', $data, $slideshow);
}
$this->sipe('meta.title', 'setTitle', $slideData, $slide);
$this->sipe('meta.description', 'setDescription', $slideData, $slide);
// TODO : enhance to allow more than files (eg. HTML)
$this->sipe('content.url', 'setContent', $slideData, $slide);
$slideshow->addSlide($slide);
}
// Delete slides which no longer exist
$slidesToDelete = array_values($existingSlides);
foreach ($slidesToDelete as $toDelete) {
$slideshow->removeSlide($toDelete);
}
}
return $slideshow;
} | [
"public",
"function",
"deserialize",
"(",
"$",
"data",
",",
"Slideshow",
"$",
"slideshow",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"sipe",
"(",
"'autoPlay'",
",",
"'setAutoPlay'",
",",
"$",
"data",
",",
"$",
"slideshow... | Deserializes Slideshow data into entities.
@param array $data
@param Slideshow $slideshow
@return Slideshow | [
"Deserializes",
"Slideshow",
"data",
"into",
"entities",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/slideshow/Serializer/SlideshowSerializer.php#L115-L169 |
40,278 | claroline/Distribution | plugin/exo/Controller/Api/AttemptController.php | AttemptController.startAction | public function startAction(Exercise $exercise, User $user = null)
{
$this->assertHasPermission('OPEN', $exercise);
if (!$this->isAdmin($exercise) && !$this->attemptManager->canPass($exercise, $user)) {
return new JsonResponse([
'message' => $exercise->getAttemptsReachedMessage(),
'accessErrors' => $this->attemptManager->getErrors($exercise, $user),
'lastAttempt' => $this->paperManager->serialize(
$this->attemptManager->getLastPaper($exercise, $user)
),
], 403);
}
return new JsonResponse($this->paperManager->serialize(
$this->attemptManager->startOrContinue($exercise, $user)
));
} | php | public function startAction(Exercise $exercise, User $user = null)
{
$this->assertHasPermission('OPEN', $exercise);
if (!$this->isAdmin($exercise) && !$this->attemptManager->canPass($exercise, $user)) {
return new JsonResponse([
'message' => $exercise->getAttemptsReachedMessage(),
'accessErrors' => $this->attemptManager->getErrors($exercise, $user),
'lastAttempt' => $this->paperManager->serialize(
$this->attemptManager->getLastPaper($exercise, $user)
),
], 403);
}
return new JsonResponse($this->paperManager->serialize(
$this->attemptManager->startOrContinue($exercise, $user)
));
} | [
"public",
"function",
"startAction",
"(",
"Exercise",
"$",
"exercise",
",",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"assertHasPermission",
"(",
"'OPEN'",
",",
"$",
"exercise",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isAdmin... | Opens an exercise, creating a new paper or re-using an unfinished one.
Also check that max attempts are not reached if needed.
@EXT\Route("", name="exercise_attempt_start")
@EXT\Method("POST")
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=true})
@param Exercise $exercise
@param User $user
@return JsonResponse | [
"Opens",
"an",
"exercise",
"creating",
"a",
"new",
"paper",
"or",
"re",
"-",
"using",
"an",
"unfinished",
"one",
".",
"Also",
"check",
"that",
"max",
"attempts",
"are",
"not",
"reached",
"if",
"needed",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/AttemptController.php#L98-L115 |
40,279 | claroline/Distribution | plugin/exo/Controller/Api/AttemptController.php | AttemptController.submitAnswersAction | public function submitAnswersAction(Paper $paper, User $user = null, Request $request)
{
$this->assertHasPermission('OPEN', $paper->getExercise());
$this->assertHasPaperAccess($paper, $user);
$errors = [];
$data = $this->decodeRequestData($request);
if (empty($data) || !is_array($data)) {
$errors[] = [
'path' => '',
'message' => 'Invalid JSON data',
];
} else {
try {
$this->attemptManager->submit($paper, $data, $request->getClientIp());
} catch (InvalidDataException $e) {
$errors = $e->getErrors();
}
}
if (!empty($errors)) {
return new JsonResponse($errors, 422);
} else {
return new JsonResponse(null, 204);
}
} | php | public function submitAnswersAction(Paper $paper, User $user = null, Request $request)
{
$this->assertHasPermission('OPEN', $paper->getExercise());
$this->assertHasPaperAccess($paper, $user);
$errors = [];
$data = $this->decodeRequestData($request);
if (empty($data) || !is_array($data)) {
$errors[] = [
'path' => '',
'message' => 'Invalid JSON data',
];
} else {
try {
$this->attemptManager->submit($paper, $data, $request->getClientIp());
} catch (InvalidDataException $e) {
$errors = $e->getErrors();
}
}
if (!empty($errors)) {
return new JsonResponse($errors, 422);
} else {
return new JsonResponse(null, 204);
}
} | [
"public",
"function",
"submitAnswersAction",
"(",
"Paper",
"$",
"paper",
",",
"User",
"$",
"user",
"=",
"null",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"assertHasPermission",
"(",
"'OPEN'",
",",
"$",
"paper",
"->",
"getExercise",
"(",
... | Submits answers to an Exercise.
@EXT\Route("/{id}", name="exercise_attempt_submit")
@EXT\Method("PUT")
@EXT\ParamConverter("paper", class="UJMExoBundle:Attempt\Paper", options={"mapping": {"id": "uuid"}})
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=true})
@param User $user
@param Paper $paper
@param Request $request
@return JsonResponse | [
"Submits",
"answers",
"to",
"an",
"Exercise",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/AttemptController.php#L131-L158 |
40,280 | claroline/Distribution | plugin/exo/Controller/Api/AttemptController.php | AttemptController.finishAction | public function finishAction(Paper $paper, User $user = null)
{
$this->assertHasPermission('OPEN', $paper->getExercise());
$this->assertHasPaperAccess($paper, $user);
$this->attemptManager->end($paper, true, !empty($user));
$userEvaluation = !empty($user) ?
$this->resourceEvalManager->getResourceUserEvaluation($paper->getExercise()->getResourceNode(), $user) :
null;
return new JsonResponse(
[
'paper' => $this->paperManager->serialize($paper),
'userEvaluation' => !empty($userEvaluation) ? $this->userEvalSerializer->serialize($userEvaluation) : null,
],
200
);
} | php | public function finishAction(Paper $paper, User $user = null)
{
$this->assertHasPermission('OPEN', $paper->getExercise());
$this->assertHasPaperAccess($paper, $user);
$this->attemptManager->end($paper, true, !empty($user));
$userEvaluation = !empty($user) ?
$this->resourceEvalManager->getResourceUserEvaluation($paper->getExercise()->getResourceNode(), $user) :
null;
return new JsonResponse(
[
'paper' => $this->paperManager->serialize($paper),
'userEvaluation' => !empty($userEvaluation) ? $this->userEvalSerializer->serialize($userEvaluation) : null,
],
200
);
} | [
"public",
"function",
"finishAction",
"(",
"Paper",
"$",
"paper",
",",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"assertHasPermission",
"(",
"'OPEN'",
",",
"$",
"paper",
"->",
"getExercise",
"(",
")",
")",
";",
"$",
"this",
"->",
... | Flags a paper as finished.
@EXT\Route("/{id}/end", name="exercise_attempt_finish")
@EXT\Method("PUT")
@EXT\ParamConverter("paper", class="UJMExoBundle:Attempt\Paper", options={"mapping": {"id": "uuid"}})
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=true})
@param Paper $paper
@param User $user
@return JsonResponse | [
"Flags",
"a",
"paper",
"as",
"finished",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/AttemptController.php#L173-L190 |
40,281 | claroline/Distribution | plugin/exo/Controller/Api/AttemptController.php | AttemptController.useHintAction | public function useHintAction(Paper $paper, $questionId, $hintId, User $user = null, Request $request)
{
$this->assertHasPermission('OPEN', $paper->getExercise());
$this->assertHasPaperAccess($paper, $user);
try {
$hint = $this->attemptManager->useHint($paper, $questionId, $hintId, $request->getClientIp());
} catch (\Exception $e) {
return new JsonResponse([[
'path' => '',
'message' => $e->getMessage(),
]], 422);
}
return new JsonResponse($hint);
} | php | public function useHintAction(Paper $paper, $questionId, $hintId, User $user = null, Request $request)
{
$this->assertHasPermission('OPEN', $paper->getExercise());
$this->assertHasPaperAccess($paper, $user);
try {
$hint = $this->attemptManager->useHint($paper, $questionId, $hintId, $request->getClientIp());
} catch (\Exception $e) {
return new JsonResponse([[
'path' => '',
'message' => $e->getMessage(),
]], 422);
}
return new JsonResponse($hint);
} | [
"public",
"function",
"useHintAction",
"(",
"Paper",
"$",
"paper",
",",
"$",
"questionId",
",",
"$",
"hintId",
",",
"User",
"$",
"user",
"=",
"null",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"assertHasPermission",
"(",
"'OPEN'",
",",
... | Returns the content of a question hint, and records the fact that it has
been consulted within the context of a given paper.
@EXT\Route("/{id}/{questionId}/hints/{hintId}", name="exercise_attempt_hint_show")
@EXT\Method("GET")
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=true})
@EXT\ParamConverter("paper", class="UJMExoBundle:Attempt\Paper", options={"mapping": {"id": "uuid"}})
@param Paper $paper
@param string $questionId
@param string $hintId
@param User $user
@param Request $request
@return JsonResponse | [
"Returns",
"the",
"content",
"of",
"a",
"question",
"hint",
"and",
"records",
"the",
"fact",
"that",
"it",
"has",
"been",
"consulted",
"within",
"the",
"context",
"of",
"a",
"given",
"paper",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/AttemptController.php#L209-L224 |
40,282 | claroline/Distribution | plugin/exo/Controller/Api/AttemptController.php | AttemptController.assertHasPaperAccess | private function assertHasPaperAccess(Paper $paper, User $user = null)
{
if (!$this->attemptManager->canUpdate($paper, $user)) {
throw new AccessDeniedException();
}
} | php | private function assertHasPaperAccess(Paper $paper, User $user = null)
{
if (!$this->attemptManager->canUpdate($paper, $user)) {
throw new AccessDeniedException();
}
} | [
"private",
"function",
"assertHasPaperAccess",
"(",
"Paper",
"$",
"paper",
",",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"attemptManager",
"->",
"canUpdate",
"(",
"$",
"paper",
",",
"$",
"user",
")",
")",
"{",
"t... | Checks whether a User has access to a Paper.
@param Paper $paper
@param User $user
@throws AccessDeniedException | [
"Checks",
"whether",
"a",
"User",
"has",
"access",
"to",
"a",
"Paper",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/AttemptController.php#L234-L239 |
40,283 | claroline/Distribution | plugin/exo/Repository/AnswerRepository.php | AnswerRepository.findByQuestion | public function findByQuestion(Item $question, Exercise $exercise = null, $finishedPapersOnly = false)
{
$qb = $this->createQueryBuilder('a')
->join('a.paper', 'p', 'WITH', 'p.exercise = :exercise')
->where('a.questionId = :question')
->setParameters([
'exercise' => $exercise,
'question' => $question->getUuid(),
]);
if ($finishedPapersOnly) {
$qb->andWhere('p.end IS NOT NULL');
}
return $qb->getQuery()->getResult();
} | php | public function findByQuestion(Item $question, Exercise $exercise = null, $finishedPapersOnly = false)
{
$qb = $this->createQueryBuilder('a')
->join('a.paper', 'p', 'WITH', 'p.exercise = :exercise')
->where('a.questionId = :question')
->setParameters([
'exercise' => $exercise,
'question' => $question->getUuid(),
]);
if ($finishedPapersOnly) {
$qb->andWhere('p.end IS NOT NULL');
}
return $qb->getQuery()->getResult();
} | [
"public",
"function",
"findByQuestion",
"(",
"Item",
"$",
"question",
",",
"Exercise",
"$",
"exercise",
"=",
"null",
",",
"$",
"finishedPapersOnly",
"=",
"false",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'a'",
")",
"->",
"... | Returns all answers to a question.
It can be limited to only one exercise.
@param Item $question
@param Exercise $exercise
@param bool $finishedPapersOnly
@return Answer[] | [
"Returns",
"all",
"answers",
"to",
"a",
"question",
".",
"It",
"can",
"be",
"limited",
"to",
"only",
"one",
"exercise",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Repository/AnswerRepository.php#L25-L40 |
40,284 | claroline/Distribution | main/app/API/Transfer/Adapter/CsvAdapter.php | CsvAdapter.decodeSchema | public function decodeSchema($content, Explanation $explanation)
{
$data = [];
$lines = str_getcsv($content, PHP_EOL);
$header = array_shift($lines);
$headers = array_filter(
str_getcsv($header, ';'),
function ($header) {
return '' !== $header;
}
);
foreach ($lines as $line) {
$properties = str_getcsv($line, ';');
$data[] = $this->buildObjectFromLine($properties, $headers, $explanation);
}
return $data;
} | php | public function decodeSchema($content, Explanation $explanation)
{
$data = [];
$lines = str_getcsv($content, PHP_EOL);
$header = array_shift($lines);
$headers = array_filter(
str_getcsv($header, ';'),
function ($header) {
return '' !== $header;
}
);
foreach ($lines as $line) {
$properties = str_getcsv($line, ';');
$data[] = $this->buildObjectFromLine($properties, $headers, $explanation);
}
return $data;
} | [
"public",
"function",
"decodeSchema",
"(",
"$",
"content",
",",
"Explanation",
"$",
"explanation",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"lines",
"=",
"str_getcsv",
"(",
"$",
"content",
",",
"PHP_EOL",
")",
";",
"$",
"header",
"=",
"array_shi... | Create a php array object from the schema according to the data passed on.
Each line is a new object.
@param string $content
@param Explanation $explanation | [
"Create",
"a",
"php",
"array",
"object",
"from",
"the",
"schema",
"according",
"to",
"the",
"data",
"passed",
"on",
".",
"Each",
"line",
"is",
"a",
"new",
"object",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Transfer/Adapter/CsvAdapter.php#L40-L58 |
40,285 | claroline/Distribution | main/app/API/Transfer/Adapter/CsvAdapter.php | CsvAdapter.getCsvSerialized | private function getCsvSerialized(\stdClass $object, $path)
{
//it's easier to work with objects here
$parts = explode('.', $path);
$first = array_shift($parts);
if (property_exists($object, $first) && is_object($object->{$first})) {
return $this->getCsvSerialized($object->{$first}, implode($parts, '.'));
}
if (property_exists($object, $first) && is_array($object->{$first})) {
return $this->getCsvArraySerialized($object->{$first}, implode($parts, '.'));
}
if (property_exists($object, $first) && !is_array($object->$first)) {
return $object->{$first};
}
} | php | private function getCsvSerialized(\stdClass $object, $path)
{
//it's easier to work with objects here
$parts = explode('.', $path);
$first = array_shift($parts);
if (property_exists($object, $first) && is_object($object->{$first})) {
return $this->getCsvSerialized($object->{$first}, implode($parts, '.'));
}
if (property_exists($object, $first) && is_array($object->{$first})) {
return $this->getCsvArraySerialized($object->{$first}, implode($parts, '.'));
}
if (property_exists($object, $first) && !is_array($object->$first)) {
return $object->{$first};
}
} | [
"private",
"function",
"getCsvSerialized",
"(",
"\\",
"stdClass",
"$",
"object",
",",
"$",
"path",
")",
"{",
"//it's easier to work with objects here",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
"$",
"first",
"=",
"array_shift",
"(... | Returns the property of the object according to the path for the csv export.
@param \stdClass $object
@param string $path
@return string | [
"Returns",
"the",
"property",
"of",
"the",
"object",
"according",
"to",
"the",
"path",
"for",
"the",
"csv",
"export",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Transfer/Adapter/CsvAdapter.php#L164-L181 |
40,286 | claroline/Distribution | main/app/API/Transfer/Adapter/CsvAdapter.php | CsvAdapter.getCsvArraySerialized | private function getCsvArraySerialized(array $elements, $path)
{
$data = [];
foreach ($elements as $element) {
$data[] = $this->getCsvSerialized($element, $path);
}
return implode($data, ',');
} | php | private function getCsvArraySerialized(array $elements, $path)
{
$data = [];
foreach ($elements as $element) {
$data[] = $this->getCsvSerialized($element, $path);
}
return implode($data, ',');
} | [
"private",
"function",
"getCsvArraySerialized",
"(",
"array",
"$",
"elements",
",",
"$",
"path",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"element",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"this",
"-... | Returns the serialized array for the csv export.
@param array $elements - the array to serialize
@param string $path - the property path inside the array
@return string | [
"Returns",
"the",
"serialized",
"array",
"for",
"the",
"csv",
"export",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Transfer/Adapter/CsvAdapter.php#L191-L200 |
40,287 | claroline/Distribution | plugin/dropzone/Entity/Dropzone.php | Dropzone.setForceCommentInCorrection | public function setForceCommentInCorrection($forceCommentInCorrection)
{
if (true === $this->getAllowCommentInCorrection()) {
$this->forceCommentInCorrection = $forceCommentInCorrection;
} else {
$this->forceCommentInCorrection = false;
}
} | php | public function setForceCommentInCorrection($forceCommentInCorrection)
{
if (true === $this->getAllowCommentInCorrection()) {
$this->forceCommentInCorrection = $forceCommentInCorrection;
} else {
$this->forceCommentInCorrection = false;
}
} | [
"public",
"function",
"setForceCommentInCorrection",
"(",
"$",
"forceCommentInCorrection",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"getAllowCommentInCorrection",
"(",
")",
")",
"{",
"$",
"this",
"->",
"forceCommentInCorrection",
"=",
"$",
"forceComm... | when there is no comment allowed, the comment can't be mandatory.
@param bool $forceCommentInCorrection | [
"when",
"there",
"is",
"no",
"comment",
"allowed",
"the",
"comment",
"can",
"t",
"be",
"mandatory",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Entity/Dropzone.php#L357-L364 |
40,288 | claroline/Distribution | plugin/dropzone/Entity/Dropzone.php | Dropzone.addCriterion | public function addCriterion(Criterion $criterion)
{
$criterion->setDropzone($this);
$this->peerReviewCriteria[] = $criterion;
return $this;
} | php | public function addCriterion(Criterion $criterion)
{
$criterion->setDropzone($this);
$this->peerReviewCriteria[] = $criterion;
return $this;
} | [
"public",
"function",
"addCriterion",
"(",
"Criterion",
"$",
"criterion",
")",
"{",
"$",
"criterion",
"->",
"setDropzone",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"peerReviewCriteria",
"[",
"]",
"=",
"$",
"criterion",
";",
"return",
"$",
"this",
"... | Add criterion.
@param \Icap\DropzoneBundle\Entity\Criterion $criterion
@return Dropzone | [
"Add",
"criterion",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Entity/Dropzone.php#L878-L884 |
40,289 | claroline/Distribution | plugin/dropzone/Entity/Dropzone.php | Dropzone.setAutoCloseState | public function setAutoCloseState($autoCloseState)
{
$authorizedValues = [self::AUTO_CLOSED_STATE_CLOSED, self::AUTO_CLOSED_STATE_WAITING];
if (in_array($autoCloseState, $authorizedValues)) {
$this->autoCloseState = $autoCloseState;
}
} | php | public function setAutoCloseState($autoCloseState)
{
$authorizedValues = [self::AUTO_CLOSED_STATE_CLOSED, self::AUTO_CLOSED_STATE_WAITING];
if (in_array($autoCloseState, $authorizedValues)) {
$this->autoCloseState = $autoCloseState;
}
} | [
"public",
"function",
"setAutoCloseState",
"(",
"$",
"autoCloseState",
")",
"{",
"$",
"authorizedValues",
"=",
"[",
"self",
"::",
"AUTO_CLOSED_STATE_CLOSED",
",",
"self",
"::",
"AUTO_CLOSED_STATE_WAITING",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"autoCloseState... | Param that indicate if all drop have already been auto closed or not.
@param string $autoCloseState | [
"Param",
"that",
"indicate",
"if",
"all",
"drop",
"have",
"already",
"been",
"auto",
"closed",
"or",
"not",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Entity/Dropzone.php#L907-L913 |
40,290 | claroline/Distribution | plugin/exo/Controller/Api/Item/ItemController.php | ItemController.listAction | public function listAction(Request $request)
{
return new JsonResponse(
$this->finder->search(
'UJM\ExoBundle\Entity\Item\Item',
$request->query->all(),
[Transfer::INCLUDE_SOLUTIONS, Transfer::INCLUDE_ADMIN_META]
)
);
} | php | public function listAction(Request $request)
{
return new JsonResponse(
$this->finder->search(
'UJM\ExoBundle\Entity\Item\Item',
$request->query->all(),
[Transfer::INCLUDE_SOLUTIONS, Transfer::INCLUDE_ADMIN_META]
)
);
} | [
"public",
"function",
"listAction",
"(",
"Request",
"$",
"request",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"$",
"this",
"->",
"finder",
"->",
"search",
"(",
"'UJM\\ExoBundle\\Entity\\Item\\Item'",
",",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
... | Searches for questions.
@EXT\Route("", name="question_list")
@EXT\Method("GET")
@param Request $request
@return JsonResponse | [
"Searches",
"for",
"questions",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/Item/ItemController.php#L69-L78 |
40,291 | claroline/Distribution | plugin/exo/Controller/Api/Item/ItemController.php | ItemController.createAction | public function createAction(Request $request)
{
$errors = [];
$question = null;
$data = $this->decodeRequestData($request);
if (empty($data)) {
// Invalid or empty JSON data received
$errors[] = [
'path' => '',
'message' => 'Invalid JSON data',
];
} else {
// Try to update question with data
try {
$question = $this->manager->create($data);
} catch (InvalidDataException $e) {
$errors = $e->getErrors();
}
}
if (empty($errors)) {
// Item updated
return new JsonResponse(
$this->manager->serialize($question, [Transfer::INCLUDE_SOLUTIONS, Transfer::INCLUDE_ADMIN_META])
);
} else {
// Invalid data received
return new JsonResponse($errors, 422);
}
} | php | public function createAction(Request $request)
{
$errors = [];
$question = null;
$data = $this->decodeRequestData($request);
if (empty($data)) {
// Invalid or empty JSON data received
$errors[] = [
'path' => '',
'message' => 'Invalid JSON data',
];
} else {
// Try to update question with data
try {
$question = $this->manager->create($data);
} catch (InvalidDataException $e) {
$errors = $e->getErrors();
}
}
if (empty($errors)) {
// Item updated
return new JsonResponse(
$this->manager->serialize($question, [Transfer::INCLUDE_SOLUTIONS, Transfer::INCLUDE_ADMIN_META])
);
} else {
// Invalid data received
return new JsonResponse($errors, 422);
}
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"$",
"question",
"=",
"null",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"decodeRequestData",
"(",
"$",
"request",
")",
";",
"if",
"(",
... | Creates a new Item.
@EXT\Route("", name="question_create")
@EXT\Method("POST")
@param Request $request
@return JsonResponse | [
"Creates",
"a",
"new",
"Item",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/Item/ItemController.php#L90-L120 |
40,292 | claroline/Distribution | plugin/exo/Controller/Api/Item/ItemController.php | ItemController.updateAction | public function updateAction(Item $question, Request $request)
{
$errors = [];
$data = $this->decodeRequestData($request);
if (empty($data)) {
// Invalid or empty JSON data received
$errors[] = [
'path' => '',
'message' => 'Invalid JSON data',
];
} else {
// Try to update question with data
try {
$question = $this->manager->update($question, $data);
} catch (InvalidDataException $e) {
$errors = $e->getErrors();
}
}
if (empty($errors)) {
// Item updated
return new JsonResponse(
$this->manager->serialize($question, [Transfer::INCLUDE_SOLUTIONS, Transfer::INCLUDE_ADMIN_META])
);
} else {
// Invalid data received
return new JsonResponse($errors, 422);
}
} | php | public function updateAction(Item $question, Request $request)
{
$errors = [];
$data = $this->decodeRequestData($request);
if (empty($data)) {
// Invalid or empty JSON data received
$errors[] = [
'path' => '',
'message' => 'Invalid JSON data',
];
} else {
// Try to update question with data
try {
$question = $this->manager->update($question, $data);
} catch (InvalidDataException $e) {
$errors = $e->getErrors();
}
}
if (empty($errors)) {
// Item updated
return new JsonResponse(
$this->manager->serialize($question, [Transfer::INCLUDE_SOLUTIONS, Transfer::INCLUDE_ADMIN_META])
);
} else {
// Invalid data received
return new JsonResponse($errors, 422);
}
} | [
"public",
"function",
"updateAction",
"(",
"Item",
"$",
"question",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"decodeRequestData",
"(",
"$",
"request",
")",
";",
"if",
"(",
"empt... | Updates a Item.
@EXT\Route("/{id}", name="question_update")
@EXT\Method("PUT")
@EXT\ParamConverter("question", class="UJMExoBundle:Item\Item", options={"mapping": {"id": "uuid"}})
@param Item $question
@param Request $request
@return JsonResponse | [
"Updates",
"a",
"Item",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/Item/ItemController.php#L134-L163 |
40,293 | claroline/Distribution | main/core/Listener/DoctrineDebug.php | DoctrineDebug.onFlush | public function onFlush(OnFlushEventArgs $eventArgs)
{
//reduce the amount of flushes to increase performances !
//you can also activate the log from the claroline.persistence.object_manager service when you use it
//if you want additional informations about transactions
if ($this->activateLog) {
$this->log('onFlush event fired !!!', LogLevel::DEBUG);
if (self::DEBUG_NONE !== $this->debugLevel) {
$stack = debug_backtrace();
foreach ($stack as $call) {
if (isset($call['file'])) {
$file = $call['file'];
if (self::DEBUG_CLAROLINE === $this->debugLevel) {
if (strpos($file, 'claroline')) {
$this->logTrace($call);
}
} elseif (self::DEBUG_ALL === $this->debugLevel) {
$this->logTrace($call);
} elseif (self::DEBUG_VENDOR === $this->debugLevel) {
if (strpos($file, $this->debugVendor)) {
$this->logTrace($call);
}
}
}
}
$this->log('Data printed !');
}
}
} | php | public function onFlush(OnFlushEventArgs $eventArgs)
{
//reduce the amount of flushes to increase performances !
//you can also activate the log from the claroline.persistence.object_manager service when you use it
//if you want additional informations about transactions
if ($this->activateLog) {
$this->log('onFlush event fired !!!', LogLevel::DEBUG);
if (self::DEBUG_NONE !== $this->debugLevel) {
$stack = debug_backtrace();
foreach ($stack as $call) {
if (isset($call['file'])) {
$file = $call['file'];
if (self::DEBUG_CLAROLINE === $this->debugLevel) {
if (strpos($file, 'claroline')) {
$this->logTrace($call);
}
} elseif (self::DEBUG_ALL === $this->debugLevel) {
$this->logTrace($call);
} elseif (self::DEBUG_VENDOR === $this->debugLevel) {
if (strpos($file, $this->debugVendor)) {
$this->logTrace($call);
}
}
}
}
$this->log('Data printed !');
}
}
} | [
"public",
"function",
"onFlush",
"(",
"OnFlushEventArgs",
"$",
"eventArgs",
")",
"{",
"//reduce the amount of flushes to increase performances !",
"//you can also activate the log from the claroline.persistence.object_manager service when you use it",
"//if you want additional informations abo... | Gets all the entities to flush.
@param OnFlushEventArgs $eventArgs Event args | [
"Gets",
"all",
"the",
"entities",
"to",
"flush",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/DoctrineDebug.php#L47-L78 |
40,294 | claroline/Distribution | plugin/forum/Serializer/SubjectSerializer.php | SubjectSerializer.serialize | public function serialize(Subject $subject, array $options = [])
{
$first = $this->messageRepo->findOneBy([
'subject' => $subject,
'first' => true,
]);
return [
'id' => $subject->getUuid(),
'forum' => [
'id' => $subject->getForum()->getUuid(),
],
'tags' => $this->serializeTags($subject),
'content' => $first ? $first->getContent() : null,
'title' => $subject->getTitle(),
'meta' => $this->serializeMeta($subject, $options),
'restrictions' => $this->serializeRestrictions($subject, $options),
'poster' => $subject->getPoster() ? $this->fileSerializer->serialize($subject->getPoster()) : null,
];
} | php | public function serialize(Subject $subject, array $options = [])
{
$first = $this->messageRepo->findOneBy([
'subject' => $subject,
'first' => true,
]);
return [
'id' => $subject->getUuid(),
'forum' => [
'id' => $subject->getForum()->getUuid(),
],
'tags' => $this->serializeTags($subject),
'content' => $first ? $first->getContent() : null,
'title' => $subject->getTitle(),
'meta' => $this->serializeMeta($subject, $options),
'restrictions' => $this->serializeRestrictions($subject, $options),
'poster' => $subject->getPoster() ? $this->fileSerializer->serialize($subject->getPoster()) : null,
];
} | [
"public",
"function",
"serialize",
"(",
"Subject",
"$",
"subject",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"first",
"=",
"$",
"this",
"->",
"messageRepo",
"->",
"findOneBy",
"(",
"[",
"'subject'",
"=>",
"$",
"subject",
",",
"'first'... | Serializes a Subject entity.
@param Subject $subject
@param array $options
@return array | [
"Serializes",
"a",
"Subject",
"entity",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/forum/Serializer/SubjectSerializer.php#L102-L121 |
40,295 | claroline/Distribution | main/migration/Generator/Generator.php | Generator.getSchemas | public function getSchemas()
{
if (count($this->schemas) === 0) {
$this->schemas['metadata'] = $this->em->getMetadataFactory()->getAllMetadata();
$this->schemas['fromSchema'] = $this->em->getConnection()->getSchemaManager()->createSchema();
$this->schemas['toSchema'] = $this->schemaTool->getSchemaFromMetadata($this->schemas['metadata']);
}
// cloning schemas is much more ligther than re-generating them for each platform
return array(
'fromSchema' => clone $this->schemas['fromSchema'],
'toSchema' => clone $this->schemas['toSchema'],
'metadata' => $this->schemas['metadata'],
);
} | php | public function getSchemas()
{
if (count($this->schemas) === 0) {
$this->schemas['metadata'] = $this->em->getMetadataFactory()->getAllMetadata();
$this->schemas['fromSchema'] = $this->em->getConnection()->getSchemaManager()->createSchema();
$this->schemas['toSchema'] = $this->schemaTool->getSchemaFromMetadata($this->schemas['metadata']);
}
// cloning schemas is much more ligther than re-generating them for each platform
return array(
'fromSchema' => clone $this->schemas['fromSchema'],
'toSchema' => clone $this->schemas['toSchema'],
'metadata' => $this->schemas['metadata'],
);
} | [
"public",
"function",
"getSchemas",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"schemas",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"schemas",
"[",
"'metadata'",
"]",
"=",
"$",
"this",
"->",
"em",
"->",
"getMetadataFactory",
"(",
... | Returns the "from" an "to" schemas and the metadata used to generate them.
Note: this method is public for testing purposes only
@return array | [
"Returns",
"the",
"from",
"an",
"to",
"schemas",
"and",
"the",
"metadata",
"used",
"to",
"generate",
"them",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/migration/Generator/Generator.php#L76-L90 |
40,296 | claroline/Distribution | main/core/Listener/Tool/ResourcesListener.php | ResourcesListener.onDisplayDesktop | public function onDisplayDesktop(DisplayToolEvent $event)
{
$content = $this->templating->render(
'ClarolineCoreBundle:tool:resources.html.twig', [
'context' => [
'type' => Widget::CONTEXT_DESKTOP,
],
'root' => null,
]
);
$event->setContent($content);
$event->stopPropagation();
} | php | public function onDisplayDesktop(DisplayToolEvent $event)
{
$content = $this->templating->render(
'ClarolineCoreBundle:tool:resources.html.twig', [
'context' => [
'type' => Widget::CONTEXT_DESKTOP,
],
'root' => null,
]
);
$event->setContent($content);
$event->stopPropagation();
} | [
"public",
"function",
"onDisplayDesktop",
"(",
"DisplayToolEvent",
"$",
"event",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"'ClarolineCoreBundle:tool:resources.html.twig'",
",",
"[",
"'context'",
"=>",
"[",
"'type'",
"=>"... | Displays resources on Desktop.
@DI\Observe("open_tool_desktop_resource_manager")
@param DisplayToolEvent $event | [
"Displays",
"resources",
"on",
"Desktop",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Tool/ResourcesListener.php#L71-L84 |
40,297 | claroline/Distribution | main/core/Listener/Tool/ResourcesListener.php | ResourcesListener.onDisplayWorkspace | public function onDisplayWorkspace(DisplayToolEvent $event)
{
$workspace = $event->getWorkspace();
$content = $this->templating->render(
'ClarolineCoreBundle:tool:resources.html.twig', [
'workspace' => $workspace,
'context' => [
'type' => Widget::CONTEXT_WORKSPACE,
'data' => $this->serializer->serialize($workspace),
],
'root' => $this->serializer->serialize(
$this->resourceRepository->findWorkspaceRoot($workspace)
),
]
);
$event->setContent($content);
$event->stopPropagation();
} | php | public function onDisplayWorkspace(DisplayToolEvent $event)
{
$workspace = $event->getWorkspace();
$content = $this->templating->render(
'ClarolineCoreBundle:tool:resources.html.twig', [
'workspace' => $workspace,
'context' => [
'type' => Widget::CONTEXT_WORKSPACE,
'data' => $this->serializer->serialize($workspace),
],
'root' => $this->serializer->serialize(
$this->resourceRepository->findWorkspaceRoot($workspace)
),
]
);
$event->setContent($content);
$event->stopPropagation();
} | [
"public",
"function",
"onDisplayWorkspace",
"(",
"DisplayToolEvent",
"$",
"event",
")",
"{",
"$",
"workspace",
"=",
"$",
"event",
"->",
"getWorkspace",
"(",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"'ClarolineCoreB... | Displays resources on Workspace.
@DI\Observe("open_tool_workspace_resource_manager")
@param DisplayToolEvent $event | [
"Displays",
"resources",
"on",
"Workspace",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Tool/ResourcesListener.php#L93-L112 |
40,298 | claroline/Distribution | main/core/Manager/Workspace/Transfer/OrderedToolTransfer.php | OrderedToolTransfer.deserialize | public function deserialize(array $data, OrderedTool $orderedTool, array $options = [], Workspace $workspace = null, FileBag $bag = null)
{
$om = $this->container->get('claroline.persistence.object_manager');
$tool = $om->getRepository(Tool::class)->findOneByName($data['tool']);
if ($tool) {
$orderedTool->setWorkspace($workspace);
$orderedTool->setTool($tool);
$orderedTool->setName($data['name']);
$orderedTool->setOrder($data['position']);
foreach ($data['restrictions'] as $restriction) {
if (isset($restriction['role']['name'])) {
$role = $om->getRepository(Role::class)->findOneBy(['name' => $restriction['role']['name']]);
} else {
$role = $om->getRepository(Role::class)->findOneBy([
'translationKey' => $restriction['role']['translationKey'],
'workspace' => $workspace->getId(),
]);
}
$rights = new ToolRights();
$rights->setRole($role);
$rights->setMask($restriction['mask']);
$rights->setOrderedTool($orderedTool);
$om->persist($rights);
}
//use event instead maybe ? or tagged service
$serviceName = 'claroline.transfer.'.$orderedTool->getTool()->getName();
if ($this->container->has($serviceName)) {
$importer = $this->container->get($serviceName);
if (method_exists($importer, 'setLogger')) {
$importer->setLogger($this->logger);
}
if (isset($data['data'])) {
$importer->deserialize($data['data'], $orderedTool->getWorkspace(), [Options::REFRESH_UUID], $bag);
}
}
}
} | php | public function deserialize(array $data, OrderedTool $orderedTool, array $options = [], Workspace $workspace = null, FileBag $bag = null)
{
$om = $this->container->get('claroline.persistence.object_manager');
$tool = $om->getRepository(Tool::class)->findOneByName($data['tool']);
if ($tool) {
$orderedTool->setWorkspace($workspace);
$orderedTool->setTool($tool);
$orderedTool->setName($data['name']);
$orderedTool->setOrder($data['position']);
foreach ($data['restrictions'] as $restriction) {
if (isset($restriction['role']['name'])) {
$role = $om->getRepository(Role::class)->findOneBy(['name' => $restriction['role']['name']]);
} else {
$role = $om->getRepository(Role::class)->findOneBy([
'translationKey' => $restriction['role']['translationKey'],
'workspace' => $workspace->getId(),
]);
}
$rights = new ToolRights();
$rights->setRole($role);
$rights->setMask($restriction['mask']);
$rights->setOrderedTool($orderedTool);
$om->persist($rights);
}
//use event instead maybe ? or tagged service
$serviceName = 'claroline.transfer.'.$orderedTool->getTool()->getName();
if ($this->container->has($serviceName)) {
$importer = $this->container->get($serviceName);
if (method_exists($importer, 'setLogger')) {
$importer->setLogger($this->logger);
}
if (isset($data['data'])) {
$importer->deserialize($data['data'], $orderedTool->getWorkspace(), [Options::REFRESH_UUID], $bag);
}
}
}
} | [
"public",
"function",
"deserialize",
"(",
"array",
"$",
"data",
",",
"OrderedTool",
"$",
"orderedTool",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"Workspace",
"$",
"workspace",
"=",
"null",
",",
"FileBag",
"$",
"bag",
"=",
"null",
")",
"{",
"$"... | only work for creation... other not supported. It's not a true Serializer anyway atm | [
"only",
"work",
"for",
"creation",
"...",
"other",
"not",
"supported",
".",
"It",
"s",
"not",
"a",
"true",
"Serializer",
"anyway",
"atm"
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Workspace/Transfer/OrderedToolTransfer.php#L102-L143 |
40,299 | claroline/Distribution | main/core/Listener/Tool/AnalyticsListener.php | AnalyticsListener.onDisplayWorkspace | public function onDisplayWorkspace(DisplayToolEvent $event)
{
$workspace = $event->getWorkspace();
$content = $this->templating->render(
'ClarolineCoreBundle:workspace:analytics.html.twig', [
'workspace' => $workspace,
]
);
$event->setContent($content);
$event->stopPropagation();
} | php | public function onDisplayWorkspace(DisplayToolEvent $event)
{
$workspace = $event->getWorkspace();
$content = $this->templating->render(
'ClarolineCoreBundle:workspace:analytics.html.twig', [
'workspace' => $workspace,
]
);
$event->setContent($content);
$event->stopPropagation();
} | [
"public",
"function",
"onDisplayWorkspace",
"(",
"DisplayToolEvent",
"$",
"event",
")",
"{",
"$",
"workspace",
"=",
"$",
"event",
"->",
"getWorkspace",
"(",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"'ClarolineCoreB... | Displays analytics on Workspace.
@DI\Observe("open_tool_workspace_analytics")
@param DisplayToolEvent $event | [
"Displays",
"analytics",
"on",
"Workspace",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Tool/AnalyticsListener.php#L48-L60 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.