PDA

View Full Version : تغییر در کد php



neda_barnamenevis
دوشنبه 25 شهریور 1392, 15:09 عصر
این قسمتی از کد در ماژول کنفرانس در دروپال است
این قسمت از کد می گه برای ارسال مقاله یک paper id ایجاد کن زمانی که مقاله ذخیره شد برای مقاله بعدی paperid+1 کن
ولی من می خواهم هر زمانی که insert را زدیم paperid+1 کنه و به ما نشون بده منظورم اینه تا قبل از این که مقاله ذخیره بشه paperid جدید بزنه چون در این حالت اگر 2 نفر همزمان paper insert را کلیک کنند 2 تا paper id یکسان بهشون می ده که نمی خوام اینطوری باشه کسی می تونه کمکم کنه؟؟؟؟؟








<?php
function conference_nodeapi(&$node, $op) {
switch ($op) {
case 'prepare':
//NOTE: I think this could be a problem when there are simultaneous submissions
//Need to check it out
$ctype_paper = variable_get('conference_ctype_paper', 0);
if ($ctype_paper == $node->type) {
$paper_id_prefix = variable_get ('conference_default_paperid_prefix', '');
if (!$node->field_paper_id) {
$current_max_num = 0;
$current_max_id = db_result (db_query ("SELECT (field_paper_id_value) FROM {content_type_conference_paper} ORDER BY field_paper_id_val\
ue DESC LIMIT 1"));
if ($current_max_id == NULL) {
//since there are no new papers just set up the prefix
$current_max_id = $paper_id_prefix;
}
else {
//Get the max number and then add one and create a new paper
$current_max_num = split ($paper_id_prefix, $current_max_id);
$current_max_num[1] = intval ($current_max_num[1]) + 1;
}
$node->field_paper_id[0]['value'] = $paper_id_prefix.sprintf ("%04d",$current_max_num[1]);
}
}
break;
?>

neda_barnamenevis
سه شنبه 26 شهریور 1392, 14:45 عصر
کسی نمیدونه؟؟؟؟؟؟؟؟؟؟؟