/** * Add a course to a curricula * * @param array $curriculums array value is the curriculum id * @return nothing * TODO: need to add some error checking */ function add_course_to_curricula($curriculums = array()) { $curcourse = new curriculumcourse(); // Add course to curricula (one or more) $curcrsrecord = array(); $curcrsrecord['id'] = 0; $curcrsrecord['courseid'] = $this->id; $curcrsrecord['required'] = 0; $curcrsrecord['frequency'] = 0; $curcrsrecord['timeperiod'] = key($curcourse->timeperiod_values); $curcrsrecord['position'] = 0; if (is_array($curriculums)) { foreach ($curriculums as $curr) { $curcrsrecord['curriculumid'] = $curr; $newcurcrs = new curriculumcourse($curcrsrecord); $status = $newcurcrs->data_insert_record(); if ($status !== true) { if (!empty($status->message)) { //$output .= cm_error('Record not created. Reason: '.$status->message); } else { //echo cm_error('Record not created.'); } } else { //echo 'New record created.'; } } } }