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; } // Get categories
/** * Retrieve course data from a course's form. */ public function handleForm() { /* * Manage the multiple select. * If it has been left empty (no selection), create an array with * the identifier of the root category (0). * If it has been serialized in the progress URL, unserialized it. */ if (isset($_REQUEST['linked_categories'])) { $_REQUEST['linked_categories'] = is_array($_REQUEST['linked_categories']) ? $_REQUEST['linked_categories'] : unserialize($_REQUEST['linked_categories']); } else { $_REQUEST['linked_categories'] = array(0); } if (isset($_REQUEST['isSourceCourse'])) { $this->title = trim(strip_tags($_REQUEST['isSourceCourse'])); } if (isset($_REQUEST['sourceCourseId'])) { $this->title = trim(strip_tags($_REQUEST['sourceCourseId'])); } if (isset($_REQUEST['course_title'])) { $this->title = trim(strip_tags($_REQUEST['course_title'])); } if (isset($_REQUEST['course_officialCode'])) { $this->officialCode = trim(strip_tags($_REQUEST['course_officialCode'])); $this->officialCode = preg_replace('/[^A-Za-z0-9_]/', '', $this->officialCode); switch (get_conf('forceCodeCase')) { case 'upper': $this->officialCode = strtoupper($this->officialCode); break; case 'lower': $this->officialCode = strtolower($this->officialCode); break; case 'nochange': break; default: break; } } if (isset($_REQUEST['course_titular'])) { $this->titular = trim(strip_tags($_REQUEST['course_titular'])); } if (isset($_REQUEST['course_email'])) { $this->email = trim(strip_tags($_REQUEST['course_email'])); } if (count($_REQUEST['linked_categories']) > 0) { $categoriesList = array(); foreach ($_REQUEST['linked_categories'] as $category) { // Bypass the loading page "course creating, please wait" $categoryId = is_a($category, 'claroCategory') ? strip_tags($category->id) : strip_tags($category); $tempCat = new claroCategory(); $tempCat->load($categoryId); $categoriesList[] = $tempCat; } $this->categories = $categoriesList; } else { $rootCat = new claroCategory(); $rootCat->load(0); $this->categories = array($rootCat); } if (isset($_REQUEST['course_departmentName'])) { $this->departmentName = trim(strip_tags($_REQUEST['course_departmentName'])); } if (isset($_REQUEST['course_extLinkUrl'])) { $this->extLinkUrl = trim(strip_tags($_REQUEST['course_extLinkUrl'])); } if (isset($_REQUEST['course_language'])) { $this->language = trim(strip_tags($_REQUEST['course_language'])); } if (isset($_REQUEST['course_visibility'])) { $this->visibility = (bool) $_REQUEST['course_visibility']; } if (isset($_REQUEST['course_access'])) { $this->access = $_REQUEST['course_access']; } if (isset($_REQUEST['course_registration'])) { if (isset($_REQUEST['registration_validation']) && $_REQUEST['registration_validation'] == 'on') { $this->registration = 'validation'; } else { $this->registration = trim(strip_tags($_REQUEST['course_registration'])); } } if (isset($_REQUEST['registration_key']) || isset($_REQUEST['course_registrationKey'])) { $this->registrationKey = trim(strip_tags($_REQUEST['course_registrationKey'])); } else { $this->registrationKey = null; } if (isset($_REQUEST['course_status_selection'])) { if ($_REQUEST['course_status_selection'] == 'disable') { $this->status = isset($_REQUEST['course_status']) ? trim($_REQUEST['course_status']) : null; } elseif ($_REQUEST['course_status_selection'] == 'date') { $this->status = 'date'; if (isset($_REQUEST['course_publicationDate'])) { $this->publicationDate = trim(strip_tags($_REQUEST['course_publicationDate'])); } elseif (isset($_REQUEST['course_publicationYear']) && isset($_REQUEST['course_publicationMonth']) && isset($_REQUEST['course_publicationDay'])) { $this->publicationDate = mktime(0, 0, 0, $_REQUEST['course_publicationMonth'], $_REQUEST['course_publicationDay'], $_REQUEST['course_publicationYear']); } else { $this->publicationDate = mktime(23, 59, 59); } $this->useExpirationDate = (bool) (isset($_REQUEST['useExpirationDate']) && $_REQUEST['useExpirationDate']); if ($this->useExpirationDate) { if (isset($_REQUEST['course_expirationDate'])) { $this->expirationDate = trim(strip_tags($_REQUEST['course_expirationDate'])); } elseif (isset($_REQUEST['course_expirationYear']) && isset($_REQUEST['course_expirationMonth']) && isset($_REQUEST['course_expirationDay'])) { $this->expirationDate = mktime(23, 59, 59, $_REQUEST['course_expirationMonth'], $_REQUEST['course_expirationDay'], $_REQUEST['course_expirationYear']); } else { $this->expirationDate = mktime(0, 0, 0); } } } else { $this->status = 'enable'; } } if (isset($_REQUEST['course_userLimit']) && $_REQUEST['course_userLimit'] > 0) { $this->userLimit = (int) $_REQUEST['course_userLimit']; } else { $this->userLimit = 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(); }