// loggedQuery(file_get_contents(dirname(__FILE__) . '/sql/update-user-preferences.sql')); // } if ($module == 'Users') { $content = 'YTo0OntzOjg6InRpbWV6b25lIjtzOjE1OiJBbWVyaWNhL1Bob2VuaXgiO3M6MjoidXQiO2k6MTtzOjI0OiJIb21lX1RFQU1OT1RJQ0VfT1JERVJfQlkiO3M6MTA6ImRhdGVfc3RhcnQiO3M6MTI6InVzZXJQcml2R3VpZCI7czozNjoiYTQ4MzYyMTEtZWU4OS0wNzE0LWE0YTItNDY2OTg3YzI4NGY0Ijt9'; $result = $GLOBALS['db']->query("SELECT id from users where id LIKE 'seed-Users%'"); while ($row = $GLOBALS['db']->fetchByAssoc($result)) { $hashed_id = md5($row['id']); $curdt = $datetime = date('Y-m-d H:i:s'); $stmt = "INSERT INTO user_preferences(id,category,date_entered,date_modified,assigned_user_id,contents) values ('" . $hashed_id . "', 'global', '" . $curdt . "', '" . $curdt . "', '" . $row['id'] . "', '" . $content . "')"; loggedQuery($stmt); } } if ($module == 'Teams') { require_once 'modules/Teams/TeamSet.php'; require_once 'modules/Teams/TeamSetManager.php'; TeamSetManager::flushBackendCache(); $teams_data = array(); $result = $GLOBALS['db']->query("SELECT id FROM teams"); while ($row = $GLOBALS['db']->fetchByAssoc($result)) { $teams_data[$row['id']] = $row['id']; } sort($teams_data); //Now generate the random team_sets $results = array(); $max_teams_per_set = 10; if (isset($opts['s']) && $opts['s'] > 0) { $max_teams_per_set = $opts['s']; } foreach ($teams_data as $team_id) { //If there are more than 20 teams, a reasonable number of teams for a maximum team set is 10 if ($max_teams_per_set == 1) {
/** * Delete a team and all team memberships. This method will only work if no items are assigned to the team. */ function delete_team() { //todo: Verify that no items are still assigned to this team. if ($this->id == $this->global_team) { $msg = $GLOBALS['app_strings']['LBL_MASSUPDATE_DELETE_GLOBAL_TEAM']; $GLOBALS['log']->fatal($msg); die($msg); } //Check if the associated user is deleted $user = BeanFactory::getBean('Users', $this->associated_user_id); if ($this->private == 1 && (!empty($user->id) && $user->deleted != 1)) { $msg = string_format($GLOBALS['app_strings']['LBL_MASSUPDATE_DELETE_USER_EXISTS'], array(Team::getDisplayName($this->name, $this->name_2), $user->full_name)); $GLOBALS['log']->error($msg); SugarApplication::appendErrorMessage($msg); return false; } // Update team_memberships table and set deleted = 1 $query = "UPDATE team_memberships SET deleted = 1 WHERE team_id='{$this->id}'"; $this->db->query($query, true, "Error deleting memberships while deleting team: "); // Update teams and set deleted = 1 $this->deleted = 1; $this->save(); require_once 'modules/Teams/TeamSetManager.php'; TeamSetManager::flushBackendCache(); //clean up any team sets that use this team id TeamSetManager::removeTeamFromSets($this->id); // Take the item off the recently viewed lists $tracker = BeanFactory::getBean('Trackers'); $tracker->makeInvisibleForAll($this->id); }