You are here

public static function OpignoModuleManagerController::getPptConvertAllow in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Controller/OpignoModuleManagerController.php \Drupal\opigno_module\Controller\OpignoModuleManagerController::getPptConvertAllow()

Returns ppt convert allow flag.

1 call to OpignoModuleManagerController::getPptConvertAllow()
OpignoModuleManagerController::getActivityTypes in src/Controller/OpignoModuleManagerController.php
Get the list of the existing activity types.

File

src/Controller/OpignoModuleManagerController.php, line 410

Class

OpignoModuleManagerController
Controller for all the actions of the Opigno module manager.

Namespace

Drupal\opigno_module\Controller

Code

public static function getPptConvertAllow() {
  static $allow;
  if (!isset($allow)) {
    $allow = FALSE;
    $module = FALSE;
    $moduleHandler = \Drupal::service('module_handler');
    if ($moduleHandler
      ->moduleExists('h5p')) {
      $module = TRUE;
    }
    $libreoffice = FALSE;
    if (shell_exec(ExternalPackageController::getLibreOfficeBinPath() . ' --version')) {
      $libreoffice = TRUE;
    }
    $imagemagick = FALSE;
    if (shell_exec(ExternalPackageController::getImagemagickBinPath() . ' --version')) {
      $imagemagick = TRUE;
    }
    $h5p_library = FALSE;
    $editor = H5PEditorUtilities::getInstance();
    $content_types = $editor->ajaxInterface
      ->getContentTypeCache();
    if ($content_types) {
      foreach ($content_types as $activity) {
        if ($activity->machine_name == 'H5P.CoursePresentation') {
          $h5p_library = TRUE;
          break;
        }
      }
    }
    if ($module && $libreoffice && $imagemagick && $h5p_library) {
      $allow = TRUE;
    }
  }
  return $allow;
}