function create_tables() { global $current_language; $mod_strings = return_module_language($current_language, 'Teams'); parent::create_tables(); Team::create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $this->global_team); }
$ce_to_pro_ent = isset($manifest['name']) && ($manifest['name'] == 'SugarCE to SugarPro' || $manifest['name'] == 'SugarCE to SugarEnt' || $manifest['name'] == 'SugarCE to SugarCorp' || $manifest['name'] == 'SugarCE to SugarUlt'); $sugar_version = getSilentUpgradeVar('origVersion'); if (!$sugar_version) { global $silent_upgrade_vars_loaded; logThis("Error retrieving silent upgrade var for sugar_version: cache dir is {$GLOBALS['sugar_config']['cache_dir']} -- full cache for \$silent_upgrade_vars_loaded is " . var_export($silent_upgrade_vars_loaded, true), $path); } if ($ce_to_pro_ent) { //add the global team if it does not exist $globalteam = new Team(); $globalteam->retrieve('1'); require_once $unzip_dir . '/' . $zip_from_dir . '/modules/Administration/language/en_us.lang.php'; if (isset($globalteam->name)) { echo 'Global ' . $mod_strings['LBL_UPGRADE_TEAM_EXISTS'] . '<br>'; logThis(" Finish Building Global Team", $path); } else { $globalteam->create_team("Global", $mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team); } logThis(" Start Building private teams", $path); upgradeModulesForTeam(); logThis(" Finish Building private teams", $path); logThis(" Start Building the team_set and team_sets_teams", $path); upgradeModulesForTeamsets(); logThis(" Finish Building the team_set and team_sets_teams", $path); logThis(" Start modules/Administration/upgradeTeams.php", $path); include 'modules/Administration/upgradeTeams.php'; logThis(" Finish modules/Administration/upgradeTeams.php", $path); if (check_FTS()) { $GLOBALS['db']->full_text_indexing_setup(); } } //bug: 37214 - merge config_si.php settings if available
function process_all_team_access($user, $add_to_global_team = false, $private_team = false, $process_implict_teams = false) { global $current_language; $mod_strings = return_module_language($current_language, 'Users'); $team = BeanFactory::getBean('Teams'); // add the user to the global team. if ($add_to_global_team) { $GLOBALS['log']->debug("RepairTeams:Processing Global({$user->global_team}) team membership for {$user->user_name}"); $team->retrieve($user->global_team); $team->add_user_to_team($user->id); } // If private teams are enabled, then manage private team member, //create private teams for the user if one does not exist. if ($private_team) { $GLOBALS['log']->debug("RepairTeams:Processing Private team membership for {$user->user_name}"); $team_id = $user->getPrivateTeamID(); //create a private team if (empty($team_id) && !empty($user->user_name)) { $GLOBALS['log']->debug("RepairTeams:No private team found creating new for {$user->user_name}"); $name = ''; $name2 = ''; if (!empty($user->first_name)) { $name = $user->first_name; $name2 = $user->last_name; } if (empty($user->first_name) && !empty($user->last_name)) { $name = $user->last_name; $name2 = ''; } $description = "{$mod_strings['LBL_PRIVATE_TEAM_FOR']} {$user->user_name}"; $team_id = Team::create_team($name, $description, create_guid(), 1, $name2, $user->id); } $GLOBALS['log']->debug("RepairTeams:User {$user->user_name} private team id is {$team_id}"); $team->retrieve($team_id); $team->add_user_to_team($user->id); } //process team hierarchy for all teams except private team and global team. Separate repair options exists if ($process_implict_teams) { $GLOBALS['log']->debug("RepairTeams:Processing Implicit team access for {$user->user_name}"); $team = BeanFactory::getBean('Teams'); $query = "select distinct team_id from team_memberships where deleted=0 and user_id='{$user->id}' and explicit_assign=1 and team_id not in (select id from teams where private=1 and deleted=0) and team_id != '{$user->global_team}'"; $result = $user->db->query($query, true, "Error finding the full membership list for a user: "******"RepairTeams:Processing Implicit team. User:{$user->user_name} Team:{$row['team_id']}"); //delete current users membership record for the selected team. $d_query = "update team_memberships set deleted=1 where user_id='{$user->id}' and team_id='{$row['team_id']}' "; $user->db->query($d_query); //re-add the membership so it cascades. $team = BeanFactory::getBean('Teams', $row['team_id']); // Make sure the team is valid if (!empty($team->id)) { $team->add_user_to_team($user->id, $user); } } } }
public function run() { if (!($this->from_flavor == 'ce' && $this->toFlavor('pro'))) { return; } require_once 'ModuleInstall/ModuleInstaller.php'; $globalteam = new Team(); $globalteam->retrieve('1'); if (empty($globalteam->name)) { $globalteam->create_team("Global", $this->mod_strings['LBL_GLOBAL_TEAM_DESC'], $globalteam->global_team); } $this->log("Start Building private teams"); $result = $this->db->query("SELECT id, user_name, first_name, last_name FROM users where deleted=0"); while ($row = $this->db->fetchByAssoc($result)) { $results2 = $this->db->query("SELECT id FROM teams WHERE name = '({$row['user_name']})'"); $assoc = ''; if (!($assoc = $this->db->fetchByAssoc($results2))) { //if team does not exist, then lets create the team for this user $team = new Team(); $user = new User(); $user->retrieve($row['id']); $team->new_user_created($user); $team_id = $team->id; } else { $team_id = $assoc['id']; } //upgrade the team $name = is_null($row['first_name']) ? '' : $row['first_name']; $name_2 = is_null($row['last_name']) ? '' : $row['last_name']; $associated_user_id = $row['id']; //Bug 32914 //Ensure team->name is not empty by using team->name_2 if available if (empty($name) && !empty($name_2)) { $name = $name_2; $name_2 = ''; } $this->db->query("UPDATE teams SET name = '{$name}', name_2 = '{$name_2}', associated_user_id = '{$associated_user_id}' WHERE id = '{$team_id}'"); } //while $this->db->query("update users set team_set_id = (select teams.id from teams where teams.associated_user_id = users.id)"); $this->db->query("update users set default_team = (select teams.id from teams where teams.associated_user_id = users.id)"); $this->log("Done Building private teams"); $this->log("Start Building the team_set and team_sets_teams"); require 'include/modules.php'; foreach ($beanList as $moduleName => $beanName) { if ($moduleName == 'TeamMemberships' || $moduleName == 'ForecastOpportunities') { continue; } $bean = loadBean($moduleName); if (empty($bean) || empty($bean->table_name)) { continue; } $FieldArray = $this->db->get_columns($bean->table_name); if (!isset($FieldArray['team_id'])) { continue; } $this->upgradeTeamColumn($bean, 'team_id'); } //foreach //Upgrade users table $bean = BeanFactory::getBean('Users'); $this->upgradeTeamColumn($bean, 'default_team'); $result = $this->db->query("SELECT id FROM teams where deleted=0"); while ($row = $this->db->fetchByAssoc($result)) { $teamset = new TeamSet(); $teamset->addTeams($row['id']); } $this->log("Finish Building the team_set and team_sets_teams"); $this->log("Start modules/Administration/upgradeTeams.php"); ob_start(); include 'modules/Administration/upgradeTeams.php'; ob_end_clean(); $this->log("Finish modules/Administration/upgradeTeams.php"); }