示例#1
0
 function savecoursepath()
 {
     checkPerm('mod');
     $re = true;
     if (isset($_POST['id_path'])) {
         // Update existing
         $query_update = "\r\n\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_coursepath\r\n\t\tSET path_code = '" . $_POST['path_code'] . "',\r\n\t\t\tpath_name = '" . $_POST['path_name'] . "',\r\n\t\t\tpath_descr = '" . $_POST['path_descr'] . "',\r\n\t\t\tsubscribe_method = '" . $_POST['subscribe_method'] . "'\r\n\t\tWHERE id_path = '" . (int) $_POST['id_path'] . "'";
         $re = sql_query($query_update);
     } else {
         // Create new
         $query_insert = "\r\n\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_coursepath\r\n\t\t( path_code, path_name, path_descr, subscribe_method ) VALUES\r\n\t\t( '" . $_POST['path_code'] . "',\r\n\t\t  '" . ($_POST['path_name'] != '' ? $_POST['path_name'] : Lang::t('_EMPTY_NAME', 'coursegpath')) . "',\r\n\t\t  '" . $_POST['path_descr'] . "',\r\n\t\t  '" . $_POST['subscribe_method'] . "' )";
         $re = sql_query($query_insert);
         if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
             list($id_path) = sql_fetch_row(sql_query("SELECT LAST_INSERT_ID()"));
             require_once _base_ . '/lib/lib.preference.php';
             $adminManager = new AdminPreference();
             $adminManager->addAdminCoursepath($id_path, Docebo::user()->getIdSt());
         }
     }
     Util::jump_to('index.php?modname=coursepath&op=pathlist&result=' . ($re ? 'ok' : 'err'));
 }