/**
  * Constructor
  *
  * @param mixed $categoryId null or valid category identifier
  * @param mixed $userId null or valid user identifier
  * @return ClaroCategoriesBrowser object
  */
 function ClaroCategoriesBrowser($categoryId = null, $userId = null)
 {
     $this->categoryId = $categoryId;
     $this->userId = $userId;
     $this->currentCategory = new claroCategory();
     $this->currentCategory->load($categoryId);
     $this->categoriesList = claroCategory::getCategories($categoryId, 1);
     $this->coursesList = claroCourse::getRestrictedCourses($categoryId, $userId);
 }
 /**
  * Constructor
  *
  * @param mixed $categoryId null or valid category identifier
  * @param mixed $userId null or valid user identifier
  */
 public function __construct($categoryId = null, $userId = null)
 {
     $this->categoryId = $categoryId;
     $this->userId = $userId;
     $this->currentCategory = new claroCategory();
     $this->currentCategory->load($categoryId);
     $this->categoryList = claroCategory::getCategories($categoryId, 1);
     $this->coursesList = claroCourse::getRestrictedCourses($categoryId, $userId);
     $this->viewOptions = new CourseTreeViewOptions();
 }
Exemple #3
0
 /**
  * Display form
  *
  * @param $cancelUrl string url of the cancel button
  * @return string html output of form
  */
 public function displayForm($cancelUrl = null)
 {
     JavascriptLoader::getInstance()->load('course_form');
     $languageList = get_language_to_display_list('availableLanguagesForCourses');
     $categoriesList = claroCategory::getAllCategoriesFlat();
     $linkedCategoriesListHtml = '';
     // Categories linked to the course
     $unlinkedCategoriesListHtml = '';
     // Other categories (not linked to the course)
     foreach ($categoriesList as $category) {
         // Is that category linked to the current course or not ?
         $match = false;
         foreach ($this->categories as $searchCategory) {
             if ($category['id'] == (int) $searchCategory->id) {
                 $match = true;
                 break;
             } else {
                 $match = false;
             }
         }
         // Dispatch in the lists
         if ($match) {
             $linkedCategoriesListHtml .= '<option ' . (!$category['visible'] ? 'class="hidden" ' : '') . 'value="' . $category['id'] . '">' . $category['path'] . '</option>' . "\n";
         } else {
             if ($category['canHaveCoursesChild'] || claro_is_platform_admin()) {
                 $unlinkedCategoriesListHtml .= '<option ' . (!$category['visible'] ? 'class="hidden" ' : '') . 'value="' . $category['id'] . '">' . $category['path'] . '</option>' . "\n";
             }
         }
     }
     $publicDisabled = !(get_conf('allowPublicCourses', true) || claro_is_platform_admin()) ? ' disabled="disabled"' : '';
     $publicCssClass = !(get_conf('allowPublicCourses', true) || claro_is_platform_admin()) ? ' class="notice"' : '';
     $publicMessage = $this->access != 'public' && !(get_conf('allowPublicCourses', true) || claro_is_platform_admin()) ? '<br /><span class="notice">' . get_lang('If you need to create a public course, please contact the platform administrator') . '</span>' : '';
     $cancelUrl = is_null($cancelUrl) ? get_path('clarolineRepositoryWeb') . 'course/index.php?cid=' . claro_htmlspecialchars($this->courseId) : $cancelUrl;
     $template = new CoreTemplate('course_form.tpl.php');
     $template->assign('formAction', $_SERVER['PHP_SELF']);
     $template->assign('relayContext', claro_form_relay_context());
     $template->assign('course', $this);
     $template->assign('linkedCategoriesListHtml', $linkedCategoriesListHtml);
     $template->assign('unlinkedCategoriesListHtml', $unlinkedCategoriesListHtml);
     $template->assign('languageList', $languageList);
     $template->assign('publicDisabled', $publicDisabled);
     $template->assign('publicCssClass', $publicCssClass);
     $template->assign('publicMessage', $publicMessage);
     $template->assign('cancelUrl', $cancelUrl);
     $template->assign('nonRootCategoryRequired', !get_conf('clcrs_rootCategoryAllowed', true));
     return $template->render();
 }
<?php 
if (count($this->categoriesList) - 1 >= 0) {
    ?>
    
    <?php 
    echo claro_html_title(get_lang('Sub categories'), 4);
    ?>
    
    <ul>
    <?php 
    foreach ($this->categoriesList as $category) {
        ?>
        <li>
        
        <?php 
        if (claroCategory::countAllCourses($category['id']) + claroCategory::countAllSubCategories($category['id']) > 0) {
            ?>
           <?php 
            echo '<a href="' . $_SERVER['PHP_SELF'] . '?category=' . urlencode($category['id']) . '#categoryContent">' . $category['name'] . '</a>';
            ?>
        <?php 
        } else {
            ?>
            <?php 
            echo $category['name'];
            ?>
        <?php 
        }
        ?>
        
        </li>
Exemple #5
0
        $category = new claroCategory();
        if ($category->load($id)) {
            $category->increaseRank();
            if (claro_failure::get_last_failure() == 'category_no_successor') {
                $dialogBox->error(get_lang('This category can\'t be moved down'));
            } else {
                $dialogBox->success(get_lang('Category moved down'));
            }
        } else {
            $dialogBox->error(get_lang('Category not found'));
        }
        break;
        // Change the visibility of a category
    // Change the visibility of a category
    case 'exVisibility':
        $category = new claroCategory(null, null, null, null, null, null, null, null);
        if ($category->load($id)) {
            if ($category->swapVisibility()) {
                $dialogBox->success(get_lang('Category\'s visibility modified'));
            } else {
                switch (claro_failure::get_last_failure()) {
                    case 'category_not_found':
                        $dialogBox->error(get_lang('Error : Category not found'));
                        break;
                }
            }
        } else {
            $dialogBox->error(get_lang('Category not found'));
        }
        break;
}
Exemple #6
0
 /**
  * Exchange ranks between the current category and another one
  * and save the modification in database.
  *
  * @param int       identifier of the other category
  */
 public function exchangeRanks($id)
 {
     // Get the other category
     $swapCategory = new claroCategory();
     $swapCategory->load($id);
     // Exchange the ranks
     $tempRank = $this->rank;
     $this->rank = $swapCategory->rank;
     $swapCategory->rank = $tempRank;
     // Save the modifications
     $this->save();
     $swapCategory->save();
 }