/**
* Assigns a group to 1-n activities by adding entries to the cross table
* (counterpart to assign_activityToGroups)
*
* @param array $groupID groupID of the group to which the activities will be assigned
* @param array $activityIDs contains one or more activityIDs
* @return boolean true on success, false on failure
* @author ob
*/
public function assign_groupToActivities($groupID, $activityIDs)
{
if (!$this->conn->TransactionBegin()) {
$this->logLastError('assign_groupToActivities');
return false;
}
$table = $this->kga['server_prefix'] . "groups_activities";
$filter['groupID'] = MySQL::SQLValue($groupID, MySQL::SQLVALUE_NUMBER);
$d_query = MySQL::BuildSQLDelete($table, $filter);
$d_result = $this->conn->Query($d_query);
if ($d_result == false) {
$this->logLastError('assign_groupToActivities');
$this->conn->TransactionRollback();
return false;
}
foreach ($activityIDs as $activityID) {
$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_groupToActivities');
$this->conn->TransactionRollback();
return false;
}
}
if ($this->conn->TransactionEnd() == true) {
return true;
} else {
$this->logLastError('assign_groupToActivities');
return false;
}
}