Loading modules/course_certificate/course_certificate.install 0 → 100644 +41 −0 Changes for modules/course_certificate/course_certificate.install: 41 added lines, 0 removed lines. Original line number Diff line number Diff line <?php function course_certificate_install() { course_certificate_update_6101(); } /** * Create certificate course objects at the end of a course for courses that had * the "certificate" checkbox checked. Drop the old field. */ function course_certificate_update_6101() { $ret = array(); drupal_get_schema(NULL, TRUE); drupal_load('module', 'uuid'); if (db_column_exists('course_node', 'certificate')) { // Find courses that had certificate checked, but no course object. $sql = "select * from {course_node} cn inner join {course_outline} co on (cn.nid = co.nid and co.requirement_type = 'course_certificate') where cn.certificate and co.snid is null"; $result = db_query($sql); while ($row = db_fetch_object($result)) { $object = array( 'requirement_type' => 'course_certificate', 'requirement_component' => 'certificate', 'nid' => $row->nid, 'enabled' => 1, 'required' => 0, 'hidden' => 0, 'title' => 'Certificate', 'weight' => 999, 'uuid' => uuid_uuid(), ); drupal_write_record('course_outline', $object); } } db_drop_field($ret, 'course_node', 'certificate'); return $ret; } Loading
modules/course_certificate/course_certificate.install 0 → 100644 +41 −0 Changes for modules/course_certificate/course_certificate.install: 41 added lines, 0 removed lines. Original line number Diff line number Diff line <?php function course_certificate_install() { course_certificate_update_6101(); } /** * Create certificate course objects at the end of a course for courses that had * the "certificate" checkbox checked. Drop the old field. */ function course_certificate_update_6101() { $ret = array(); drupal_get_schema(NULL, TRUE); drupal_load('module', 'uuid'); if (db_column_exists('course_node', 'certificate')) { // Find courses that had certificate checked, but no course object. $sql = "select * from {course_node} cn inner join {course_outline} co on (cn.nid = co.nid and co.requirement_type = 'course_certificate') where cn.certificate and co.snid is null"; $result = db_query($sql); while ($row = db_fetch_object($result)) { $object = array( 'requirement_type' => 'course_certificate', 'requirement_component' => 'certificate', 'nid' => $row->nid, 'enabled' => 1, 'required' => 0, 'hidden' => 0, 'title' => 'Certificate', 'weight' => 999, 'uuid' => uuid_uuid(), ); drupal_write_record('course_outline', $object); } } db_drop_field($ret, 'course_node', 'certificate'); return $ret; }