public function assign_activityToGroups($activityID, $groupIDs)
{
if (!$this->conn->TransactionBegin()) {
$this->logLastError('assign_activityToGroups');
return false;
}
$table = $this->kga['server_prefix'] . "groups_activities";
$filter['activityID'] = MySQL::SQLValue($activityID, MySQL::SQLVALUE_NUMBER);
$d_query = MySQL::BuildSQLDelete($table, $filter);
$d_result = $this->conn->Query($d_query);
if ($d_result == false) {
$this->logLastError('assign_activityToGroups');
$this->conn->TransactionRollback();
return false;
}
foreach ($groupIDs as $groupID) {
$values['groupID'] = MySQL::SQLValue($groupID, MySQL::SQLVALUE_NUMBER);
$values['activityID'] = MySQL::SQLValue($activityID, MySQL::SQLVALUE_NUMBER);
$query = MySQL::BuildSQLInsert($table, $values);
$result = $this->conn->Query($query);
if ($result == false) {
$this->logLastError('assign_activityToGroups');
$this->conn->TransactionRollback();
return false;
}
}
if ($this->conn->TransactionEnd() == true) {
return true;
} else {
$this->logLastError('assign_activityToGroups');
return false;
}
}