original_string: public static function move_courses_into_category($categoryorid, $courseids = array()) {
          global $DB;
          if (!is_array($courseids)) {
              // Just a single course ID.
              $courseids = array($courseids);
          }
          // Bulk move courses from one category to another.
          if (count($courseids) === 0) {
              return false;
          }
          if ($categoryorid instanceof \core_course_category) {
              $moveto = $categoryorid;
          } else {
              $moveto = \core_course_category::get($categoryorid);
          }
          if (!$moveto->can_move_courses_out_of() || !$moveto->can_move_courses_into()) {
              throw new \moodle_exception('cannotmovecourses');
          }
  
          list($where, $params) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);
          $sql = "SELECT c.id, c.category FROM {course} c WHERE c.id {$where}";
          $courses = $DB->get_records_sql($sql, $params);
          $checks = array();
          foreach ($courseids as $id) {
              if (!isset($courses[$id])) {
                  throw new \moodle_exception('invalidcourseid');
              }
              $catid = $courses[$id]->category;
              if (!isset($checks[$catid])) {
                  $coursecat = \core_course_category::get($catid);
                  $checks[$catid] = $coursecat->can_move_courses_out_of() && $coursecat->can_move_courses_into();
              }
              if (!$checks[$catid]) {
                  throw new \moodle_exception('cannotmovecourses');
              }
          }
          return \move_courses($courseids, $moveto->id);
      }
code: public static function move_courses_into_category($categoryorid, $courseids = array()) {
          global $DB;
          if (!is_array($courseids)) {
              // Just a single course ID.
              $courseids = array($courseids);
          }
          // Bulk move courses from one category to another.
          if (count($courseids) === 0) {
              return false;
          }
          if ($categoryorid instanceof \core_course_category) {
              $moveto = $categoryorid;
          } else {
              $moveto = \core_course_category::get($categoryorid);
          }
          if (!$moveto->can_move_courses_out_of() || !$moveto->can_move_courses_into()) {
              throw new \moodle_exception('cannotmovecourses');
          }
  
          list($where, $params) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);
          $sql = "SELECT c.id, c.category FROM {course} c WHERE c.id {$where}";
          $courses = $DB->get_records_sql($sql, $params);
          $checks = array();
          foreach ($courseids as $id) {
              if (!isset($courses[$id])) {
                  throw new \moodle_exception('invalidcourseid');
              }
              $catid = $courses[$id]->category;
              if (!isset($checks[$catid])) {
                  $coursecat = \core_course_category::get($catid);
                  $checks[$catid] = $coursecat->can_move_courses_out_of() && $coursecat->can_move_courses_into();
              }
              if (!$checks[$catid]) {
                  throw new \moodle_exception('cannotmovecourses');
              }
          }
          return \move_courses($courseids, $moveto->id);
      }
code_tokens: public static function move_courses_into_category ( $ categoryorid , $ courseids = array ( ) ) { global $ DB ; if ( ! is_array ( $ courseids ) ) { // Just a single course ID. $ courseids = array ( $ courseids ) ; } // Bulk move courses from one category to another. if ( count ( $ courseids ) === 0 ) { return false ; } if ( $ categoryorid instanceof \ core_course_category ) { $ moveto = $ categoryorid ; } else { $ moveto = \ core_course_category :: get ( $ categoryorid ) ; } if ( ! $ moveto -> can_move_courses_out_of ( ) || ! $ moveto -> can_move_courses_into ( ) ) { throw new \ moodle_exception ( 'cannotmovecourses' ) ; } list ( $ where , $ params ) = $ DB -> get_in_or_equal ( $ courseids , SQL_PARAMS_NAMED ) ; $ sql = "SELECT c.id, c.category FROM {course} c WHERE c.id {$where}" ; $ courses = $ DB -> get_records_sql ( $ sql , $ params ) ; $ checks = array ( ) ; foreach ( $ courseids as $ id ) { if ( ! isset ( $ courses [ $ id ] ) ) { throw new \ moodle_exception ( 'invalidcourseid' ) ; } $ catid = $ courses [ $ id ] -> category ; if ( ! isset ( $ checks [ $ catid ] ) ) { $ coursecat = \ core_course_category :: get ( $ catid ) ; $ checks [ $ catid ] = $ coursecat -> can_move_courses_out_of ( ) && $ coursecat -> can_move_courses_into ( ) ; } if ( ! $ checks [ $ catid ] ) { throw new \ moodle_exception ( 'cannotmovecourses' ) ; } } return \ move_courses ( $ courseids , $ moveto -> id ) ; }
docstring: Moves one or more courses out of the category they are currently in and into a new category.
  
  This function works much the same way as action_category_move_courses_into however it allows courses from multiple
  categories to be moved into a single category.
  
  @param int|\core_course_category $categoryorid The category to move them into.
  @param array|int $courseids An array of course id's or optionally just a single course id.
  @return bool True on success or false on failure.
  @throws \moodle_exception
docstring_tokens: Moves one or more courses out of the category they are currently in and into a new category .