function platform_new($nom) { $id_pf = pick_id('platforms_id_pf_seq'); try { $result = sql_do('INSERT INTO platforms (id_pf,name_pf) VALUES (' . int($id_pf) . ',\'' . int($nom) . '\')'); } catch (DatabaseException $e) { return 0; } return $id_pf; }
function license_new($nom, $term) { $id_lic = pick_id('licenses_id_lic_seq'); try { sql_do('INSERT INTO licenses (id_lic,name_lic,terms) VALUES (\'' . int($id_lic) . '\',\'' . str($nom) . '\',\'' . str($term) . '\')'); } catch (DatabaseException $e) { return 0; } return $id_lic; }
function language_new($nom) { $id_lang = pick_id('languages_id_lang_seq'); try { sql_do('INSERT INTO languages (id_lang,name_lang) VALUES (' . int($id_lang) . ',\'' . str($nom) . '\')'); } catch (DatabaseException $e) { return 0; } return $id_lang; }
function user_new_pseudo($name, $email) { $result = sql_do("SELECT id_user FROM users WHERE mail='{$email}'"); if ($result->numRows()) { append_error("This email address is already registered. Please choose another."); return 0; } $id_user = pick_id('users_id_user_seq'); try { $result = sql_do('INSERT INTO users (id_user,name_user,mail,date_user,valid_user) VALUES (\'' . int($id_user) . '\',\'' . str($name) . '\',\'' . str($email) . '\',\'' . date('Y-m-d H:i:s') . '\',0)'); } catch (DatabaseException $e) { //append_error("Unknown error executing [$sql]."); return 0; } return $id_user; }
function project_new($name_prj, $shortname, $description, $homepage) { $result = sql_do('SELECT id_prj FROM projects WHERE shortname=\'' . str($shortname) . '\''); if ($result->numRows()) { append_error("Shortname '{$shortname}' already taken."); return 0; } $id_prj = pick_id('projects_id_prj_seq'); try { $result = sql_do('INSERT INTO projects (id_prj,name_prj,shortname,desc_prj,url_prj,date_prj,valid_prj) VALUES (\'' . int($id_prj) . '\',\'' . str($name_prj) . '\',\'' . str($shortname) . '\',\'' . str($description) . '\',\'' . str($homepage) . '\',\'' . date('Y-m-d H:i:s') . '\',0)'); } catch (DatabaseException $e) { return 0; } return $id_prj; }
function branch_new($name, $id_prj) { $id_branch = pick_id('branches_id_branch_seq'); try { sql_do('INSERT INTO branches (id_branch,name_branch,id_prj,date_branch) VALUES (\'' . int($id_branch) . '\',\'' . str($name) . '\',\'' . int($id_prj) . '\',\'' . date('Y-m-d H:i:s') . '\')'); } catch (DatabaseException $e) { return 0; } return $id_branch; }
function category_new($index, $nom) { # FIXME: increase the actual limit of 10 children by category /* recuperation des index existants et correspondants */ $result = sql_do('SELECT index FROM categories WHERE index LIKE \'' . str($index) . '_\' ORDER BY index'); for ($i = 0; $i < 10; $i++) { $row = $result->fetchRow(); if ($row[0] != $index . $i) { break; } } if ($i == 10) { return -1; } $id_cat = pick_id('categories_id_cat_seq'); try { sql_do('INSERT INTO categories (id_cat,index,name_cat) VALUES (\'' . int($id_cat) . '\',\'' . str($index) . int($i) . '\',\'' . str($nom) . '\')'); } catch (DatabaseException $e) { return 0; } return $id_cat; }
function release_new($id_branch, $name_rel, $status, $changes, $download, $valid_rel) { $id_rel = pick_id('releases_id_rel_seq'); try { $result = sql_do('INSERT INTO releases (id_rel,name_rel,date_rel,status,nb_projs,changes,download,valid_rel) VALUES (\'' . int($id_rel) . '\',\'' . str($name_rel) . '\',\'' . date('Y-m-d H:i:s') . '\',\'' . int($status) . '\',\'' . int($nb_projs) . '\',\'' . str($changes) . '\',\'' . str($download) . '\',\'' . (bool) int($valid_rel) . '\')'); } catch (DatabaseException $e) { return 0; } return $id_rel; }