/*Code extracted from mass update generated php file in hooks*/I'm a newbie to php code. Should I insert the code in the mass update generated php code? Following is the snippet of code I extract from the generated php code, anyone able to explain on the bold code and comment the newly inserted code (in blue). I do not fully understand the php code and have difficulty to make it works for ownership assignment 'after update' via mass updating. Any expert can give guidance? :
/*Start here*/
$new_value = makeSafe($_REQUEST['newValue']);
/* prepare a safe comma-separated list of IDs to use in the query */
$cs_ids = array();
foreach($ids as $id) $cs_ids[] = "'" . makeSafe($id) . "'";
$cs_ids = implode(', ', $cs_ids);
$tn = 'Block_Yield';
$field = 'to_reviewer';
$pk = getPKFieldName($tn);
/* Declare additional variables */
$today = time();
$groupID = sqlValue("SELECT `groupID` FROM `membership_users` WHERE `memberID`='{$new_value]}' LIMIT 1");
$query = "UPDATE `{$tn}` SET `{$field}`='{$new_value}' WHERE `{$pk}` IN ({$cs_ids})";
/* Is it right to insert my second query to update the membership_userrecords */
$query2 = "UPDATE membership_userrecords SET
memberID= '{$new_value}' ,
dateUpdated='{$today}',
groupID='{$groupID}'
WHERE tableName='{$tn}' AND `{$pk}` IN ({$cs_ids})
";
/* Can you explain the if statement for the following code and the purpose of reconstructing the $query statement */
if($new_value == 'MASS_UPDATE_TOGGLE_CHECKBOX')
$query = "UPDATE `{$tn}` SET
`{$field}` = IF(ISNULL(`{$field}`), '1', IF(`{$field}`, '0', '1'))
WHERE `{$pk}` IN ({$cs_ids})";
$e = array('silentErrors' => true);
sql($query, $e);
sql($query2, $e);
/*End here*/