123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- /* For licensing terms, see /license.txt */
- use Brumann\Polyfill\Unserialize;
- /**
- * Class UnserializeApi.
- */
- class UnserializeApi
- {
- /**
- * Unserialize content using Brummann\Polyfill\Unserialize.
- *
- * @param string $type
- * @param string $serialized
- * @param bool $ignoreErrors. Optional.
- *
- * @return mixed
- */
- public static function unserialize($type, $serialized, $ignoreErrors = false)
- {
- $allowedClasses = [];
- switch ($type) {
- case 'career':
- case 'sequence_graph':
- $allowedClasses = [
- \Fhaculty\Graph\Graph::class,
- \Fhaculty\Graph\Set\VerticesMap::class,
- \Fhaculty\Graph\Set\Vertices::class,
- \Fhaculty\Graph\Set\Edges::class,
- \Fhaculty\Graph\Vertex::class,
- \Fhaculty\Graph\Edge\Base::class,
- \Fhaculty\Graph\Edge\Directed::class,
- \Fhaculty\Graph\Edge\Undirected::class,
- ];
- break;
- case 'course':
- $allowedClasses = [
- \Chamilo\CourseBundle\Component\CourseCopy\Course::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Announcement::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Asset::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Attendance::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\CalendarEvent::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseCopyLearnpath::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseCopyTestCategory::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseDescription::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseSession::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Document::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Forum::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\ForumCategory::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\ForumPost::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\ForumTopic::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Glossary::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\GradeBookBackup::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\LearnPathCategory::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Link::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\LinkCategory::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Quiz::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\QuizQuestion::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\QuizQuestionOption::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\ScormDocument::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Survey::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\SurveyInvitation::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\SurveyQuestion::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Thematic::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\ToolIntro::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Wiki::class,
- \Chamilo\CourseBundle\Component\CourseCopy\Resources\Work::class,
- \Chamilo\CourseBundle\Entity\CLpCategory::class,
- stdClass::class,
- Category::class,
- AttendanceLink::class,
- DropboxLink::class,
- Evaluation::class,
- ExerciseLink::class,
- ForumThreadLink::class,
- LearnpathLink::class,
- LinkFactory::class,
- Result::class,
- StudentPublicationLink::class,
- SurveyLink::class,
- ];
- // no break
- case 'lp':
- $allowedClasses = array_merge(
- $allowedClasses,
- [
- learnpath::class,
- learnpathItem::class,
- aicc::class,
- aiccBlock::class,
- aiccItem::class,
- aiccObjective::class,
- aiccResource::class,
- scorm::class,
- scormItem::class,
- scormMetadata::class,
- scormOrganization::class,
- scormResource::class,
- Link::class,
- LpItem::class,
- ]
- );
- break;
- case 'not_allowed_classes':
- default:
- $allowedClasses = false;
- }
- if ($ignoreErrors) {
- return @Unserialize::unserialize(
- $serialized,
- ['allowed_classes' => $allowedClasses]
- );
- }
- return Unserialize::unserialize(
- $serialized,
- ['allowed_classes' => $allowedClasses]
- );
- }
- }
|