Add copyoriginal, copyparent, and notes(currently unused) to conferences table

Add code in create conference and copy conference to set copyoriginal and copyparent
Add missing json_decode to API (we expect ALL arrays being POSTED to be json encoded)
This commit is contained in:
james 2010-11-25 20:45:44 +00:00
parent e9f46edb0e
commit 46b39f81e0
5 changed files with 14 additions and 7 deletions

View File

@ -732,7 +732,7 @@ switch($request[0]) {
return(fields array)
*/
case 'fields':
$reqroles=$_POST['roles'];
$reqroles=json_decode($_POST['roles'],true);
if(is_array($reqroles)) {
for($x=0;$x<count($reqroles);$x++) {
if(is_numeric($reqroles[$x]))

View File

@ -1 +1 @@
223
225

View File

@ -1,6 +1,2 @@
INSERT INTO `rolestasks` (`id`, `pid`, `roles_id`, `level`, `task`, `ord`, `link`, `navident`, `conferencetype`) VALUES
(128, 89, 10, 2, 'School Information', 1, '/schoolinfo.php', '', 'scienceolympics'),
(129, 90, 10, 2, 'School Feedback', 1, '/schoolfeedback.php', '', 'scienceolympics');
ALTER TABLE `pagetext` DROP INDEX `textname` , ADD UNIQUE `textname` ( `textname` , `conferences_id` , `lang` );
UPDATE roles SET `type` = 'participant', `name` = 'Participant' WHERE type = 'student';

6
db/db.update.225.sql Normal file
View File

@ -0,0 +1,6 @@
ALTER TABLE `conferences`
ADD `copyoriginal` INT NOT NULL AFTER `status` ,
ADD `copyparent` INT NOT NULL AFTER `copyoriginal` ,
ADD `notes` TEXT NOT NULL AFTER `copyparent`;
UPDATE `conferences` SET copyoriginal=id, copyparent=id;

View File

@ -629,6 +629,11 @@ function create_conference($params){
$cname = mysql_real_escape_string($params['name']);
$ctype = $params['type'];
mysql_query("INSERT INTO conferences (oid, name, type, status) VALUES (1, '" . mysql_real_escape_string($cname) . "', '$ctype', 'pending')");
//if its created brand spanking new, we set the copyoriginal and copyparent to be the same as the id
$id=mysql_insert_id();
mysql_query("UPDATE conferences SET copyoriginal='$id', copyparent='$id' WHERE id='$id'");
$errorMessage = mysql_error();
if($errorMessage){
return "SQL Error:<br/>$errorMessage";
@ -726,7 +731,7 @@ function copy_conference($params){
$oldConfId = $params['mastercopy'];
$oldConf = mysql_fetch_assoc(mysql_query("SELECT * FROM conferences WHERE id = {$oldConfId}"));
mysql_query("INSERT INTO conferences (oid, name, type, status) VALUES (1, '" . mysql_real_escape_string($params['name']) . "', '{$oldConf['type']}', 'pending')");
mysql_query("INSERT INTO conferences (oid, name, type, status, copyoriginal, copyparent) VALUES (1, '" . mysql_real_escape_string($params['name']) . "', '{$oldConf['type']}', 'pending','{$oldConf['copyoriginal']}','{$oldConf['id']}')");
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error on line #' . (__LINE__ - 1) . ': <br/>' . mysql_error()); return false; }
$newConfId = mysql_insert_id();