本文整理汇总了PHP中db_insertid函数的典型用法代码示例。如果您正苦于以下问题:PHP db_insertid函数的具体用法?PHP db_insertid怎么用?PHP db_insertid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_insertid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: account_register_new
function account_register_new($unix_name, $realname, $password1, $password2, $email, $language, $timezone, $mail_site, $mail_va, $language_id, $timezone)
{
global $feedback;
if (db_numrows(db_query("SELECT user_id FROM users WHERE user_name LIKE '{$unix_name}'")) > 0) {
$feedback .= "That username already exists.";
return false;
}
// Check that username is not identical with an existing unix groupname (groups) helix 22.06.2001
if (db_numrows(db_query("SELECT unix_group_name FROM groups WHERE unix_group_name LIKE '{$unix_name}'")) > 0) {
$feedback .= "That username is identical with the unixname of an existing group.";
return false;
}
// End of change helix 22.06.2001
if (!$unix_name) {
$feedback .= "You must supply a username.";
return false;
}
if (!$password1) {
$feedback .= "You must supply a password.";
return false;
}
if ($password1 != $password2) {
$feedback .= "Passwords do not match.";
return false;
}
if (!account_pwvalid($password1)) {
$feedback .= ' Password must be at least 6 characters. ';
return false;
}
if (!account_namevalid($unix_name)) {
$feedback .= ' Invalid Unix Name ';
return false;
}
if (!validate_email($email)) {
$feedback .= ' Invalid Email Address ';
return false;
}
// if we got this far, it must be good
$confirm_hash = substr(md5($session_hash . $HTTP_POST_VARS['form_pw'] . time()), 0, 16);
$result = db_query("INSERT INTO users (user_name,user_pw,unix_pw,realname,email,add_date," . "status,confirm_hash,mail_siteupdates,mail_va,language,timezone) " . "VALUES ('{$unix_name}'," . "'" . md5($password1) . "'," . "'" . account_genunixpw($password1) . "'," . "'" . "{$realname}'," . "'{$email}'," . "'" . time() . "'," . "'P'," . "'{$confirm_hash}'," . "'" . ($mail_site ? "1" : "0") . "'," . "'" . ($mail_va ? "1" : "0") . "'," . "'{$language_id}'," . "'{$timezone}')");
$user_id = db_insertid($result, 'users', 'user_id');
if (!$result || !$user_id) {
$feedback .= ' Insert Failed ' . db_error();
return false;
} else {
// send mail
$message = "Thank you for registering on the " . $GLOBALS['sys_default_name'] . " web site. In order\n" . "to complete your registration, visit the following url: \n\n" . "https://" . $GLOBALS['HTTP_HOST'] . "/account/verify.php?confirm_hash={$confirm_hash}\n\n" . "Enjoy the site.\n\n" . " -- the " . $GLOBALS['sys_default_name'] . " staff\n";
mail($email, $GLOBALS['sys_default_name'] . " Account Registration", $message, "From: noreply@" . $GLOBALS['sys_default_domain']);
return $user_id;
}
}
示例2: create
function create(&$request)
{
$content_id = false;
$vId = new Valid_Uint($this->widget_id . '_job_id');
$vId->setErrorMessage("Can't add empty job id");
$vId->required();
if ($request->valid($vId)) {
$job_id = $request->get($this->widget_id . '_job_id');
$sql = 'INSERT INTO plugin_hudson_widget (widget_name, owner_id, owner_type, job_id) VALUES ("' . $this->id . '", ' . $this->owner_id . ", '" . $this->owner_type . "', " . db_escape_int($job_id) . " )";
$res = db_query($sql);
$content_id = db_insertid($res);
}
return $content_id;
}
示例3: copyReports
/**
*
* Copy all the reports informations from a tracker to another.
*
* @param atid_source: source tracker
* @param atid_dest: destination tracker
*
* @return boolean
*/
function copyReports($atid_source, $atid_dest)
{
global $Language;
$report_mapping = array(100 => 100);
//The system report 'Default' (sic)
//
// Copy artifact_report records which are not individual/personal
//
$sql = "SELECT report_id,user_id,name,description,scope,is_default " . "FROM artifact_report " . "WHERE group_artifact_id='" . db_ei($atid_source) . "'" . "AND scope != 'I'";
//echo $sql;
$res = db_query($sql);
while ($report_array = db_fetch_array($res)) {
$sql_insert = 'INSERT INTO artifact_report (group_artifact_id,user_id,name,description,scope,is_default) VALUES (' . db_ei($atid_dest) . ',' . db_ei($report_array["user_id"]) . ',"' . db_es($report_array["name"]) . '","' . db_es($report_array["description"]) . '","' . db_es($report_array["scope"]) . '","' . db_es($report_array["is_default"]) . '")';
$res_insert = db_query($sql_insert);
if (!$res_insert || db_affected_rows($res_insert) <= 0) {
$this->setError($Language->getText('tracker_common_reportfactory', 'ins_err', array($report_array["report_id"], $atid_dest, db_error())));
return false;
}
$report_id = db_insertid($res_insert, 'artifact_report', 'report_id');
$report_mapping[$report_array["report_id"]] = $report_id;
//
// Copy artifact_report_field records
//
$sql_fields = 'SELECT field_name,show_on_query,show_on_result,place_query,place_result,col_width ' . 'FROM artifact_report_field ' . 'WHERE report_id=' . db_ei($report_array["report_id"]);
//echo $sql_fields;
$res_fields = db_query($sql_fields);
while ($field_array = db_fetch_array($res_fields)) {
$show_on_query = $field_array["show_on_query"] == "" ? "null" : $field_array["show_on_query"];
$show_on_result = $field_array["show_on_result"] == "" ? "null" : $field_array["show_on_result"];
$place_query = $field_array["place_query"] == "" ? "null" : $field_array["place_query"];
$place_result = $field_array["place_result"] == "" ? "null" : $field_array["place_result"];
$col_width = $field_array["col_width"] == "" ? "null" : $field_array["col_width"];
$sql_insert = 'INSERT INTO artifact_report_field VALUES (' . db_ei($report_id) . ',"' . db_es($field_array["field_name"]) . '",' . db_ei($show_on_query) . ',' . db_ei($show_on_result) . ',' . db_ei($place_query) . ',' . db_ei($place_result) . ',' . db_ei($col_width) . ')';
//echo $sql_insert;
$res_insert = db_query($sql_insert);
if (!$res_insert || db_affected_rows($res_insert) <= 0) {
$this->setError($Language->getText('tracker_common_reportfactory', 'f_ind_err', array($report_array["report_id"], $field_array["field_name"], db_error())));
return false;
}
}
// while
}
// while
return $report_mapping;
}
示例4: create
function create($label, $languageId)
{
global $Language;
if (strlen($label) == 0) {
// set error
return false;
}
$sql = 'INSERT INTO trove_category_labels ' . '(category_id, label, language_id) VALUES (' . $this->category->getId() . ', ' . "'" . $label . "'," . "'" . $languageId . "')";
db_begin();
$result = db_query($sql);
echo db_error();
if (!$result) {
db_rollback();
return false;
}
$this->labelId = db_insertid($result, 'trove_category_labels', 'label_id');
$this->fetchData($this->labelId);
db_commit();
}
示例5: GetKeysArray
/**
* GetKeysArray
* Form aray of primary keys and their values for audit
* @param {array} $arr array of inserting values
* @param {bool} $searchId - find last inserted id or not
* @return {array} array of keys and their values
*/
function GetKeysArray($arr, $searchId = false)
{
global $conn;
$keyfields = GetTableKeys();
$aKeys = array();
if (count($keyfields)) {
foreach ($keyfields as $kfield) {
if (array_key_exists($kfield, $arr)) {
$aKeys[$kfield] = $arr[$kfield];
}
}
if (count($aKeys) == 0 && searchId) {
$lastId = db_insertid($conn);
if ($lastId > 0) {
$aKeys[$keyfields[0]] = $lastId;
}
}
}
return $aKeys;
}
示例6: exit_error
if ($group_id && user_ismember($group_id, 'A')) {
if ($add_job) {
/*
create a new job
*/
if (!$title || !$description || $category_id == 100) {
//required info
exit_error('error - missing info', 'Fill in all required fields');
}
$sql = "INSERT INTO people_job (group_id,created_by,title,description,date,status_id,category_id) " . "VALUES ('{$group_id}','" . user_getid() . "','{$title}','{$description}','" . time() . "','1','{$category_id}')";
$result = db_query($sql);
if (!$result || db_affected_rows($result) < 1) {
$feedback .= ' JOB insert FAILED ';
echo db_error();
} else {
$job_id = db_insertid($result, 'people_job', 'job_id');
$feedback .= ' JOB inserted successfully ';
}
} else {
if ($update_job) {
/*
update the job's description, status, etc
*/
if (!$title || !$description || $category_id == 100 || $status_id == 100 || !$job_id) {
//required info
exit_error('error - missing info', 'Fill in all required fields');
}
$sql = "UPDATE people_job SET title='{$title}',description='{$description}',status_id='{$status_id}',category_id='{$category_id}' " . "WHERE job_id='{$job_id}' AND group_id='{$group_id}'";
$result = db_query($sql);
if (!$result || db_affected_rows($result) < 1) {
$feedback .= ' JOB update FAILED ';
示例7: create
function create(&$request)
{
$content_id = false;
$vId = new Valid_Uint('chart_id');
$vId->setErrorMessage("Can't add empty chart id");
$vId->required();
if ($request->validInArray('chart', $vId)) {
$chart = $request->get('chart');
$sql = 'INSERT INTO plugin_graphontrackersv5_widget_chart (owner_id, owner_type, title, chart_id) VALUES (' . $this->owner_id . ", '" . $this->owner_type . "', '" . db_escape_string($chart['title']) . "', " . db_escape_int($chart['chart_id']) . ")";
$res = db_query($sql);
$content_id = db_insertid($res);
}
return $content_id;
}
示例8: insertmsg
/**
* insertmsg - inserts the message into the main table (forum)
* @param string The subject of the message.
* @param string The body of the message.
* @param int The thread_id of the message, if known.
* @param int The message_id of the parent message, if any.
* @param int The id of the user that is posting the message
* @param boolean Whether the message has an attach associated. Defaults to false
* @return boolean success.
*/
function insertmsg($subject, $body, $thread_id = '', $is_followup_to = '', $user_id, $has_attach = false)
{
if (!$thread_id) {
$thread_id = $this->Forum->getNextThreadID();
$is_followup_to = 0;
if (!$thread_id) {
$this->setError('ForumMessage::create() ' . _('Getting next thread_id failed'));
db_rollback();
return false;
}
} else {
//
// increment the parent's followup count if necessary
//
$res4 = db_query("UPDATE forum SET most_recent_date='" . time() . "' \n\t\t\t\tWHERE thread_id='{$thread_id}' AND is_followup_to='0'");
if (!$res4 || db_affected_rows($res4) < 1) {
$this->setError(_('Couldn\'t Update Master Thread parent with current time'));
db_rollback();
return false;
} else {
//
// mark the parent with followups as an optimization later
//
$res3 = db_query("UPDATE forum SET has_followups='1',most_recent_date='" . time() . "' \n\t\t\t\t\tWHERE msg_id='{$is_followup_to}'");
if (!$res3) {
$this->setError(_('Could Not Update Parent'));
db_rollback();
return false;
}
}
}
$sql = "INSERT INTO forum (group_forum_id,posted_by,subject,\n\t\t\tbody,post_date,is_followup_to,thread_id,most_recent_date) \n\t\t\tVALUES ('" . $this->Forum->getID() . "', '{$user_id}', '" . htmlspecialchars($subject) . "', \n\t\t\t'" . $body . "', '" . time() . "','{$is_followup_to}','{$thread_id}','" . time() . "')";
$result = db_query($sql);
if (!$result || db_affected_rows($result) < 1) {
$this->setError(_('ForumMessage::create() Posting Failed') . ' ' . db_error());
db_rollback();
return false;
}
$msg_id = db_insertid($result, 'forum', 'msg_id');
if (!$this->fetchData($msg_id)) {
db_rollback();
return false;
}
if (!$msg_id) {
db_rollback();
$this->setError(_('ForumMessage::create() Unable to get new message id'));
return false;
}
if (!$this->sendNotice($has_attach)) {
db_rollback();
return false;
}
//echo "Committing";
db_commit();
//echo "db_error()".db_error();
$this->awaits_moderation = false;
return true;
}
示例9: addTaskLog
/**
* Add a entry in the DataBase for a Tracker associated to a commit
*
* @param array $Config Config
* @param string $GroupId The GroupId to insert it into
* @param string $Num The tracker_id
*
* @return array Returns 'check'=true if check passed, group, group_id
*/
function addTaskLog($Config, $GroupId, $Num)
{
$return = array();
$Query = "SELECT * from project_task,project_group_list WHERE " . "project_task.group_project_id=" . "project_group_list.group_project_id " . "AND project_task.project_task_id='" . $Num . "' AND " . " project_group_list.group_id='" . $GroupId . "'";
var_dump($Query);
$Result = db_query($Query);
$Rows = db_numrows($Result);
if ($Rows == 0) {
$return['Error'] .= "Task:{$Num} Not Found.";
}
if ($Rows == 1) {
db_begin();
$Query = "INSERT INTO plugin_svntracker_data_artifact " . "(kind, project_task_id) VALUES " . "('1', '" . $Num . "')";
$DBRes = db_query($Query);
$HolderID = db_insertid($DBRes, 'plugin_svntracker_data_artifact', 'id');
if (!$DBRes || !$HolderID) {
$return['Error'] = 'Problems with Task $Num: ' . db_error($DBRes);
db_rollback();
} else {
$Query = "INSERT INTO plugin_svntracker_data_master " . "(holder_id, svn_date, log_text, file, prev_version, " . "actual_version, author)" . " VALUES ('" . $HolderID . "','" . $Config['SvnDate'] . "','" . $Config['Log'] . "','" . $Config['FileName'] . "','" . $Config['PrevVersion'] . "','" . $Config['ActualVersion'] . "','" . $Config['UserName'] . "')";
$DBRes = db_query($Query);
if (!$DBRes) {
db_rollback();
} else {
db_commit();
}
}
}
if ($Rows > 1) {
$return['Error'] .= "Unknown problem adding Task:{$Num}.";
}
return $return;
}
示例10: create
/**
* create - create a row in the table that stores a saved query for * a tracker.
*
* @param string Name of the saved query.
* @return true on success / false on failure.
*/
function create($name, $status, $assignee, $moddaterange, $sort_col, $sort_ord, $extra_fields, $opendaterange = 0, $closedaterange = 0)
{
//
// data validation
//
if (!$name) {
$this->setMissingParamsError();
return false;
}
if (!session_loggedin()) {
$this->setError('Must Be Logged In');
return false;
}
if ($this->Exist(htmlspecialchars($name))) {
$this->setError(_('Query already exists'));
return false;
}
$sql = "INSERT INTO artifact_query (group_artifact_id,query_name,user_id) \n\t\t\tVALUES ('" . $this->ArtifactType->getID() . "','" . htmlspecialchars($name) . "','" . user_getid() . "')";
db_begin();
$result = db_query($sql);
if ($result && db_affected_rows($result) > 0) {
$this->clearError();
$id = db_insertid($result, 'artifact_query', 'artifact_query_id');
if (!$id) {
$this->setError('Error getting id ' . db_error());
db_rollback();
return false;
} else {
if (!$this->insertElements($id, $status, $assignee, $moddaterange, $sort_col, $sort_ord, $extra_fields, $opendaterange, $closedaterange)) {
db_rollback();
return false;
}
}
} else {
$this->setError(db_error());
db_rollback();
return false;
}
//
// Now set up our internal data structures
//
if ($this->fetchData($id)) {
db_commit();
return true;
} else {
db_rollback();
return false;
}
}
示例11: create
/**
* create - use this to create a new Report in the database.
*
* @param string The report name.
* @param string The report description.
* @return id on success, false on failure.
*/
public static function create($atid, $user_id, $name, $description, $scope)
{
$sql = sprintf("INSERT INTO plugin_graphontrackers_report_graphic \n (group_artifact_id,user_id,name,description,scope) \n VALUES (%d,%d,'%s','%s','%s')", db_ei($atid), db_ei($user_id), db_es($name), db_es($description), db_es($scope));
$res = db_query($sql);
$report = null;
if ($res && db_affected_rows($res)) {
$report = new GraphOnTrackers_Report(db_insertid($res));
}
return $report;
}
示例12: create
/**
* create - construct a new Artifact in the database.
*
* @param string The artifact summary.
* @param string Details of the artifact.
* @param int The ID of the user to which this artifact is to be assigned.
* @param int The artifacts priority.
* @param array Array of extra fields like: array(15=>'foobar',22=>'1');
* @return id on success / false on failure.
*/
function create($summary, $details, $assigned_to = 100, $priority = 3, $extra_fields = array())
{
//
// make sure this person has permission to add artifacts
//
if (!$this->ArtifactType->isPublic()) {
//
// Only admins can post/modify private artifacts
//
if (!$this->ArtifactType->userIsAdmin()) {
$this->setError(_('Artifact: Only Artifact Admins Can Modify Private ArtifactTypes'));
return false;
}
}
//
// get the user_id
//
if (session_loggedin()) {
$user = user_getid();
} else {
if ($this->ArtifactType->allowsAnon()) {
$user = 100;
} else {
$this->setError(_('Artifact: This ArtifactType Does Not Allow Anonymous Submissions. Please Login.'));
return false;
}
}
//
// data validation
//
if (!$summary) {
$this->setError(_('Artifact: Message Summary Is Required'));
return false;
}
if (!$details) {
$this->setError(_('Artifact: Message Body Is Required'));
return false;
}
if (!$assigned_to) {
$assigned_to = 100;
}
if (!$priority) {
$priority = 3;
}
// if (!$status_id) {
$status_id = 1;
// on creation, status is set to "open"
// }
//
// They may be using an extra field "status" box so we have to remap
// the status_id based on the extra field - this keeps the counters
// accurate
//
$status_id = $this->ArtifactType->remapStatus($status_id, $extra_fields);
if (!$status_id) {
$this->setError(_('Artifact: Error remapping status'));
return false;
}
db_begin();
$sql = "INSERT INTO artifact \n\t\t\t(group_artifact_id,status_id,priority,\n\t\t\tsubmitted_by,assigned_to,open_date,summary,details) \n\t\t\tVALUES \n\t\t\t('" . $this->ArtifactType->getID() . "','{$status_id}','{$priority}',\n\t\t\t'{$user}','{$assigned_to}','" . time() . "','" . htmlspecialchars($summary) . "','" . htmlspecialchars($details) . "')";
$res = db_query($sql);
if (!$res) {
$this->setError('Artifact: ' . db_error());
db_rollback();
return false;
}
$artifact_id = db_insertid($res, 'artifact', 'artifact_id');
if (!$res || !$artifact_id) {
$this->setError('Artifact: ' . db_error());
db_rollback();
return false;
} else {
//
// Now set up our internal data structures
//
if (!$this->fetchData($artifact_id)) {
db_rollback();
return false;
} else {
// the changes to the extra fields will be logged in this array.
// (we won't use it however)
$extra_field_changes = array();
if (!$this->updateExtraFields($extra_fields, $extra_field_changes)) {
db_rollback();
return false;
}
}
//
// now send an email if appropriate
//
//.........这里部分代码省略.........
示例13: db_query
//create a new release of this package
//see if this package belongs to this project
$res1 = db_query("SELECT * FROM frs_package WHERE package_id='{$package_id}' AND group_id='{$group_id}'");
if (!$res1 || db_numrows($res1) < 1) {
$feedback .= ' | Package Doesn\'t Exist Or Isn\'t Yours ';
echo db_error();
} else {
//package_id was fine - now insert the release
$res = db_query("INSERT INTO frs_release (package_id,name,notes,changes,status_id,release_date,released_by) " . "VALUES ('{$package_id}','{$release_name}','{$release_notes}','{$release_changes}','{$status_id}','" . time() . "','" . user_getid() . "')");
if (!$res) {
$feedback .= ' | Adding Release Failed ';
echo db_error();
//insert failed - go back to definition screen
} else {
//release added - now show the detail page for this new release
$release_id = db_insertid($res, 'frs_release', 'release_id');
$feedback .= ' Added Release <BR>';
}
}
/*
Add a file to this release
First, make sure this release belongs to this group
iterate the following for each file:
Second see if the filename is legal
Third see if they already have a file by the same name
Fourth if file actually exists, physically move the file on garbage to the new location
Fifth insert it into the database
*/
示例14: create
/**
* create - use this function to create a survey
*
* @param string The survey title
* @param int array The question numbers to be added
* @param is_active 1: Active, 0: Inactive
* For future options
* @param is_public 0: Admins Only, 1: Group Members, 2: Gforge user, 3:Every body
* @param is_result_public 0: Admins Only, 1: Group Members, 2: Gforge user, 3:voted user 4:Every body
* @param double_vote Allow double vote if it is 1
* @return boolean success.
*/
function create($survey_title, $add_questions, $is_active = 0, $is_public = 1, $is_result_public = 0, $double_vote = 0)
{
if (!$survey_title) {
$this->setError(_('UPDATE FAILED: Survey Title Required'));
return false;
/* We need at least one survey question at this point */
} else {
if (!$add_questions || !is_array($add_questions) || count($add_questions) < 1) {
$this->setError(_('UPDATE FAILED: Survey Questions Required'));
return false;
}
}
$group_id = $this->Group->GetID();
/* Make old style survey string from array: 1, 2, 3, ..., n */
$survey_questions = $this->_makeQuestionString(array_reverse($add_questions));
$sql = "INSERT INTO surveys (survey_title,group_id,survey_questions,is_active) VALUES ('" . htmlspecialchars($survey_title) . "','{$group_id}','{$survey_questions}','{$is_active}')";
$result = db_query($sql);
if (!$result) {
$this->setError(_('Insert Error') . db_error());
return false;
}
/* Load question to data array */
$survey_id = db_insertid($res, 'surveys', 'survey_id');
return $this->fetchData($survey_id);
}
示例15: create_project
/**
* create_project
*
* Create a new project
*
* @param data
*/
function create_project($data, $do_not_exit = false)
{
srand((double) microtime() * 1000000);
$random_num = rand(0, 1000000);
// Make sure default project privacy status is defined. If not
// then default to "public"
if (!isset($GLOBALS['sys_is_project_public'])) {
$GLOBALS['sys_is_project_public'] = 1;
}
if (isset($GLOBALS['sys_disable_subdomains']) && $GLOBALS['sys_disable_subdomains']) {
$http_domain = $GLOBALS['sys_default_domain'];
} else {
$http_domain = $data['project']['form_unix_name'] . '.' . $GLOBALS['sys_default_domain'];
}
//Verify if the approbation of the new project is automatic or not
$auto_approval = ForgeConfig::get('sys_project_approval', 1) ? PROJECT_APPROVAL_BY_ADMIN : PROJECT_APPROVAL_AUTO;
if (isset($data['project']['is_public'])) {
$access = $data['project']['is_public'] ? Project::ACCESS_PUBLIC : Project::ACCESS_PRIVATE;
} else {
$access = ForgeConfig::get('sys_is_project_public') ? Project::ACCESS_PUBLIC : Project::ACCESS_PRIVATE;
}
// make group entry
$insert_data = array('group_name' => "'" . htmlspecialchars(mysql_real_escape_string($data['project']['form_full_name'])) . "'", 'access' => "'" . $access . "'", 'unix_group_name' => "'" . db_es($data['project']['form_unix_name']) . "'", 'http_domain' => "'" . db_es($http_domain) . "'", 'status' => "'P'", 'unix_box' => "'shell1'", 'cvs_box' => "'cvs1'", 'license' => "'" . htmlspecialchars(mysql_real_escape_string($data['project']['form_license'])) . "'", 'license_other' => "'" . htmlspecialchars(mysql_real_escape_string($data['project']['form_license_other'])) . "'", 'short_description' => "'" . htmlspecialchars(mysql_real_escape_string($data['project']['form_short_description'])) . "'", 'register_time' => time(), 'rand_hash' => "'" . md5($random_num) . "'", 'built_from_template' => db_ei($data['project']['built_from_template']), 'type' => $data['project']['is_test'] ? 3 : 1);
$sql = 'INSERT INTO groups(' . implode(', ', array_keys($insert_data)) . ') VALUES (' . implode(', ', array_values($insert_data)) . ')';
$result = db_query($sql);
if (!$result) {
exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'upd_fail', array($GLOBALS['sys_email_admin'], db_error())));
} else {
$group_id = db_insertid($result);
// insert descriptions
$descfieldsinfos = getProjectsDescFieldsInfos();
for ($i = 0; $i < sizeof($descfieldsinfos); $i++) {
if (isset($data['project']["form_" . $descfieldsinfos[$i]["group_desc_id"]]) && $data['project']["form_" . $descfieldsinfos[$i]["group_desc_id"]] != '') {
$sql = "INSERT INTO group_desc_value (group_id, group_desc_id, value) VALUES ('" . db_ei($group_id) . "','" . db_ei($descfieldsinfos[$i]["group_desc_id"]) . "','" . db_escape_string(trim($data['project']["form_" . $descfieldsinfos[$i]["group_desc_id"]])) . "')";
$result = db_query($sql);
if (!$result) {
list($host, $port) = explode(':', $GLOBALS['sys_default_domain']);
exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'ins_desc_fail', array($host, db_error())));
}
}
}
// insert trove categories
if (isset($data['project']['trove'])) {
foreach ($data['project']['trove'] as $root => $values) {
foreach ($values as $value) {
db_query("INSERT INTO trove_group_link (trove_cat_id,trove_cat_version," . "group_id,trove_cat_root) VALUES (" . db_ei($value) . "," . time() . "," . db_ei($group_id) . "," . db_ei($root) . ")");
}
}
}
// define a module
$project_manager = ProjectManager::instance();
$result = db_query("INSERT INTO filemodule (group_id,module_name) VALUES ('{$group_id}','" . $project_manager->getProject($group_id)->getUnixName() . "')");
if (!$result) {
list($host, $port) = explode(':', $GLOBALS['sys_default_domain']);
exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'ins_file_fail', array($host, db_error())));
}
// make the current user a project admin as well as admin
// on all Codendi services
$result = db_query("INSERT INTO user_group (user_id,group_id,admin_flags,bug_flags,forum_flags,project_flags,patch_flags,support_flags,doc_flags,file_flags,wiki_flags,svn_flags,news_flags) VALUES (" . user_getid() . "," . $group_id . "," . "'A'," . "2," . "2," . "2," . "2," . "2," . "2," . "2," . "2," . "2," . "2)");
// news_flags
if (!$result) {
exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'set_owner_fail', array($GLOBALS['sys_email_admin'], db_error())));
}
// clear the user data to take into account this new group.
$user = UserManager::instance()->getCurrentUser();
$user->clearGroupData();
// Instanciate all services from the project template that are 'active'
$group = $project_manager->getProject($group_id);
if (!$group || !is_object($group)) {
exit_no_group();
}
//set up the group_id
$_REQUEST['group_id'] = $_GET['group_id'] = $group_id;
$request =& HTTPRequest::instance();
$request->params['group_id'] = $_REQUEST['group_id'];
$template_id = $group->getTemplate();
$template_group = $project_manager->getProject($template_id);
if (!$template_group || !is_object($template_group) || $template_group->isError()) {
exit_no_group();
}
$system_template = $template_group->getStatus() == 's' || $template_group->getStatus() == 'S';
if (!$system_template) {
$template_name = $template_group->getUnixName();
}
$sql = "SELECT * FROM service WHERE group_id={$template_id} AND is_active=1";
$result = db_query($sql);
while ($arr = db_fetch_array($result)) {
if (isset($data['project']['services'][$arr['service_id']]['is_used'])) {
$is_used = $data['project']['services'][$arr['service_id']]['is_used'];
} else {
$is_used = '0';
if ($arr['short_name'] == 'admin' || $arr['short_name'] == 'summary') {
$is_used = '1';
//.........这里部分代码省略.........