-
- // Our overall intention is to keep the code simple and manageable.
- // If a users wishes to delete a field, we will delete all its options and log entries.
- // Otherwise we have to do conditional queries depending on field status (this complicates things).
-
- global $user;
- $mdb2 = getConnection();
-
- // First make sure that the field is ours so that we can safely delete it.
- $sql = "select team_id from tt_custom_fields where id = $field_id";
- $res = $mdb2->query($sql);
- if (is_a($res, 'PEAR_Error'))
- return false;
- $val = $res->fetchRow();
- if ($user->team_id != $val['team_id'])
- return false;
-
- // Mark log entries as deleted.
- $sql = "update tt_custom_field_log set status = NULL where field_id = $field_id";
+ global $user;
+ $mdb2 = getConnection();
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ // Mark log entries as deleted. TODO: why are we doing this? Research impact.
+ $sql = "update tt_custom_field_log set status = null".
+ " where field_id = $field_id and group_id = $group_id and org_id = $org_id";