/php/component/internal_syncer.class.php
https://bitbucket.org/chamilo/chamilo-ext-repo-box-dev/ · PHP · 72 lines · 65 code · 7 blank · 0 comment · 4 complexity · 9d758b08c8e504f342cb03277219d2c1 MD5 · raw file
- <?php
- namespace common\extensions\external_repository_manager\implementation\box;
-
- use common\libraries\Utilities;
- use common\libraries\Redirect;
- use common\libraries\PlatformSetting;
- use common\libraries\StringUtilities;
- use common\libraries\Application;
- use common\libraries\Translation;
-
- use common\extensions\external_repository_manager\ExternalRepositoryComponent;
- use common\extensions\external_repository_manager\ExternalRepositoryManager;
-
- use repository\RepositoryManager;
- use repository\ExternalRepositorySync;
-
- class BoxExternalRepositoryManagerInternalSyncerComponent extends BoxExternalRepositoryManager
- {
-
- function run()
- {
- $syncer = ExternalRepositoryComponent :: factory(ExternalRepositoryComponent :: INTERNAL_SYNCER_COMPONENT, $this);
- $syncer->run();
- }
-
- function synchronize_internal_repository_object(ExternalRepositoryObject $external_object)
- {
- $synchronization_data = $external_object->get_synchronization_data();
- $content_object = $synchronization_data->get_content_object();
- $content_object->set_title($external_object->get_title());
- if (PlatformSetting :: get('description_required', 'repository') && StringUtilities :: is_null_or_empty($external_object->get_description()))
- {
- $content_object->set_description('-');
- }
- else
- {
- $content_object->set_description($external_object->get_description());
- }
-
- if ($content_object->update())
- {
- $synchronization_data->set_content_object_timestamp($content_object->get_modification_date());
- $synchronization_data->set_external_object_timestamp($external_object->get_modified());
- if ($synchronization_data->update())
- {
- $parameters = $this->get_parameters();
- $parameters[Application :: PARAM_ACTION] = RepositoryManager :: ACTION_VIEW_CONTENT_OBJECTS;
- $parameters[RepositoryManager :: PARAM_CONTENT_OBJECT_ID] = $content_object->get_id();
- $this->redirect(Translation :: get('ObjectUpdated', array(
- 'OBJECT' => Translation :: get('ContentObject')), Utilities :: COMMON_LIBRARIES), false, $parameters, array(
- ExternalRepositoryManager :: PARAM_EXTERNAL_REPOSITORY,
- ExternalRepositoryManager :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION));
- }
- else
- {
- $parameters = $this->get_parameters();
- $parameters[ExternalRepositoryManager :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION] = ExternalRepositoryManager :: ACTION_VIEW_EXTERNAL_REPOSITORY;
- $parameters[ExternalRepositoryManager :: PARAM_EXTERNAL_REPOSITORY_ID] = $external_object->get_id();
- $this->redirect(Translation :: get('ObjectFailedUpdated', array(
- 'OBJECT' => Translation :: get('ContentObject')), Utilities :: COMMON_LIBRARIES), true, $parameters);
- }
- }
- else
- {
- $parameters = $this->get_parameters();
- $parameters[ExternalRepositoryManager :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION] = ExternalRepositoryManager :: ACTION_VIEW_EXTERNAL_REPOSITORY;
- $parameters[ExternalRepositoryManager :: PARAM_EXTERNAL_REPOSITORY_ID] = $external_object->get_id();
- $this->redirect(Translation :: get('ObjectUpdated', array('OBJECT' => Translation :: get('ContentObject')), Utilities :: COMMON_LIBRARIES), true, $parameters);
- }
- }
- }
- ?>