예제 #1
0
 function get_my_teams($return_obj = false)
 {
     $query = "SELECT DISTINCT rel.team_id, teams.name, teams.name_2, rel.implicit_assign FROM team_memberships rel RIGHT JOIN teams ON (rel.team_id = teams.id) WHERE rel.user_id = '{$this->id}' AND rel.deleted = 0 ORDER BY teams.name ASC";
     $result = $this->db->query($query, false, "Error retrieving user ID: ");
     $out = array();
     if ($return_obj) {
         $x = 0;
     }
     while ($row = $this->db->fetchByAssoc($result)) {
         if ($return_obj) {
             $out[$x] = BeanFactory::getBean('Teams');
             $out[$x]->retrieve($row['team_id']);
             $out[$x++]->implicit_assign = $row['implicit_assign'];
         } else {
             $out[$row['team_id']] = Team::getDisplayName($row['name'], $row['name_2']);
         }
     }
     return $out;
 }
예제 #2
0
 /**
  * Returns formatted data
  *
  * @param array $results
  * @param array $args
  * @return array
  */
 protected function formatResults($results, $args)
 {
     global $sugar_config;
     $app_list_strings = null;
     $data['totalCount'] = count($results);
     $data['fields'] = array();
     for ($i = 0; $i < count($results); $i++) {
         $data['fields'][$i] = array();
         $data['fields'][$i]['module'] = $results[$i]->object_name;
         //C.L.: Bug 43395 - For Quicksearch, do not return values with salutation and title formatting
         if ($results[$i] instanceof Person) {
             $results[$i]->createLocaleFormattedName = false;
         }
         $listData = $results[$i]->get_list_view_data();
         foreach ($args['field_list'] as $field) {
             // handle enums
             if (isset($results[$i]->field_name_map[$field]['type']) && $results[$i]->field_name_map[$field]['type'] == 'enum' || isset($results[$i]->field_name_map[$field]['custom_type']) && $results[$i]->field_name_map[$field]['custom_type'] == 'enum') {
                 // get fields to match enum vals
                 if (empty($app_list_strings)) {
                     if (isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != '') {
                         $current_language = $_SESSION['authenticated_user_language'];
                     } else {
                         $current_language = $sugar_config['default_language'];
                     }
                     $app_list_strings = return_app_list_strings_language($current_language);
                 }
                 // match enum vals to text vals in language pack for return
                 if (!empty($app_list_strings[$results[$i]->field_name_map[$field]['options']])) {
                     $results[$i]->{$field} = $app_list_strings[$results[$i]->field_name_map[$field]['options']][$results[$i]->{$field}];
                 }
             }
             if ($results[$i] instanceof Team) {
                 $results[$i]->name = Team::getDisplayName($results[$i]->name, $results[$i]->name_2);
             }
             if (isset($listData[$field])) {
                 $data['fields'][$i][$field] = $listData[$field];
             } else {
                 if (isset($results[$i]->{$field})) {
                     $data['fields'][$i][$field] = $results[$i]->{$field};
                 } else {
                     $data['fields'][$i][$field] = '';
                 }
             }
         }
     }
     if (is_array($data['fields'])) {
         foreach ($data['fields'] as $i => $recordIn) {
             if (!is_array($recordIn)) {
                 continue;
             }
             foreach ($recordIn as $col => $dataIn) {
                 if (!is_scalar($dataIn)) {
                     continue;
                 }
                 $data['fields'][$i][$col] = html_entity_decode($dataIn, ENT_QUOTES, 'UTF-8');
             }
         }
     }
     return $data;
 }
예제 #3
0
    sugar_die("Unauthorized access to administration.");
}
$error_message = '';
if (isset($_REQUEST['team_id']) && isset($_REQUEST['teams'])) {
    $new_team = BeanFactory::getBean('Teams', $_REQUEST['team_id']);
    //Grab the list of teams to reassign
    $old_teams = explode(",", $_REQUEST['teams']);
    if (!in_array($new_team->id, $old_teams)) {
        unset($_SESSION['REASSIGN_TEAMS']);
        //Call method to reassign the teams
        $new_team->reassign_team_records($old_teams);
        //Redirect to listview
        header("Location: index.php?module=Teams&action=index");
        return;
    }
    $error_message = string_format($mod_strings['ERR_INVALID_TEAM_REASSIGNMENT'], array(Team::getDisplayName($new_team->name, $new_team->name_2, false)));
}
$teams = array();
$focus = BeanFactory::getBean('Teams');
if (isset($_SESSION['REASSIGN_TEAMS'])) {
    foreach ($_SESSION['REASSIGN_TEAMS'] as $team_id) {
        $focus->retrieve($team_id);
        $teams[$team_id] = $focus->name;
    }
} else {
    if (isset($_REQUEST['record'])) {
        $focus->retrieve($_REQUEST['record']);
        $teams[$focus->id] = $focus->name;
    }
}
if (empty($teams) && !isset($error_message)) {
예제 #4
0
 /**
  * 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);
 }
예제 #5
0
$sub_xtpl = $xtpl;
$old_contents = ob_get_contents();
ob_end_clean();
ob_start();
echo $old_contents;
require_once 'include/SubPanel/SubPanelTiles.php';
$subpanel = new SubPanelTiles($focus, 'Teams');
echo $subpanel->display();
$error_message = isset($_REQUEST['message']) ? $_REQUEST['message'] : '';
if (!empty($error_message)) {
    if ($error_message == 'LBL_MASSUPDATE_DELETE_GLOBAL_TEAM') {
        $error_message = $app_strings['LBL_MASSUPDATE_DELETE_GLOBAL_TEAM'];
    } else {
        if ($error_message == 'LBL_MASSUPDATE_DELETE_USER_EXISTS') {
            $user = BeanFactory::getBean('Users', $focus->associated_user_id);
            $error_message = string_format($app_strings['LBL_MASSUPDATE_DELETE_USER_EXISTS'], array(Team::getDisplayName($focus->name, $focus->name_2), $user->full_name));
        }
    }
    echo <<<EOQ
<script type="text/javascript">
\tpopup_window = new YAHOO.widget.SimpleDialog("emptyLayout", {
\t\twidth: "300px",
\t\tdraggable: true,
\t\tconstraintoviewport: true,
\t\tmodal: true,
\t\tfixedcenter: true,
\t\ttext: "{$error_message}",
\t\tbodyStyle: "padding:5px",
\t\tbuttons: [{
\t\t\ttext: SUGAR.language.get('app_strings', 'LBL_EMAIL_OK'),
\t\t\tisDefault:true,
예제 #6
0
 public static function getFormattedTeamNames($teams_arr = array())
 {
     //Add a safety check (in the event that team_set_id is not set (maybe perhaps from manual SQL or failed unit tests)
     if (!is_array($teams_arr)) {
         return array();
     }
     //now format the returned values relative to how the user has their locale
     $teams = array();
     foreach ($teams_arr as $team) {
         $display_name = Team::getDisplayName($team['name'], $team['name_2']);
         $teams[] = array('id' => (string) $team['id'], 'display_name' => $display_name, 'name' => $team['name'], 'name_2' => $team['name_2']);
     }
     return $teams;
 }
 function setup()
 {
     $this->related_module = 'Teams';
     $this->value_name = 'team_set_id_values';
     $this->vardef['name'] = $this->name;
     if (!empty($GLOBALS['beanList'][$this->module_dir])) {
         $class = $GLOBALS['beanList'][$this->module_dir];
         if (SugarAutoLoader::fileExists($GLOBALS['beanFiles'][$class])) {
             $this->bean = BeanFactory::getBean($this->module_dir);
             $secondaries = array();
             $primary = false;
             $this->bean->{$this->value_name} = array('role_field' => 'team_name');
             if (!empty($this->team_id)) {
                 $this->bean->team_id = $this->team_id;
                 if (!empty($this->team_set_id)) {
                     $this->bean->team_set_id = $this->team_set_id;
                 }
             } else {
                 if (!empty($_REQUEST['record'])) {
                     $this->bean->retrieve($_REQUEST['record']);
                 }
             }
             if (!empty($this->bean->team_set_id)) {
                 require_once 'modules/Teams/TeamSetManager.php';
                 $teams = TeamSetManager::getTeamsFromSet($this->bean->team_set_id);
                 foreach ($teams as $row) {
                     if (empty($primary) && $this->bean->team_id == $row['id']) {
                         $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, array('primary' => array('id' => $row['id'], 'name' => $row['display_name'])));
                         $primary = true;
                     } else {
                         $secondaries['secondaries'][] = array('id' => $row['id'], 'name' => $row['display_name']);
                     }
                 }
                 //foreach
             } elseif (!empty($this->bean->team_id)) {
                 //since the team_set_id is not set, but the team_id is.
                 $focus = BeanFactory::getBean('Teams', $this->bean->team_id);
                 $display_name = Team::getDisplayName($focus->name, $focus->name_2);
                 $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, array('primary' => array('id' => $focus->id, 'name' => $display_name)));
             } elseif (empty($this->bean->team_id) && empty($this->bean->team_set_id)) {
                 require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
                 $teams = SugarFieldTeamset::getTeamsFromRequest($this->bean->{$this->value_name}['role_field'], $_POST);
                 $primary_id = SugarFieldTeamset::getPrimaryTeamidFromRequest($this->bean->{$this->value_name}['role_field'], $_POST);
                 foreach ($teams as $id => $name) {
                     // getting strings of values is needed because some problems appears when compare '1' and md5 value which begins from '1'
                     if (strval($primary_id) === strval($id)) {
                         $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, array('primary' => array('id' => $id, 'name' => $name)));
                     } else {
                         $secondaries['secondaries'][] = array('id' => $id, 'name' => $name);
                     }
                 }
             }
             $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, $secondaries);
         }
     }
     $this->skipModuleQuickSearch = true;
     $this->showSelectButton = false;
 }
예제 #8
0
$return_action = isset($_REQUEST['return_action']) ? $_REQUEST['return_action'] : '';
if (empty($return_id)) {
    $return_action = 'index';
}
if (isset($_REQUEST['error_string'])) {
    $xtpl->assign("ERROR_STRING", "<span class='error'>Error: " . $_REQUEST['error_string'] . "</span>");
}
$xtpl->assign("RETURN_MODULE", $return_module);
$xtpl->assign("RETURN_ID", $return_id);
$xtpl->assign("RETURN_ACTION", $return_action);
if (isset($_REQUEST['isDuplicate'])) {
    $xtpl->assign("IS_DUPLICATE", $_REQUEST['isDuplicate']);
}
$xtpl->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']);
$xtpl->assign("ID", $focus->id);
$xtpl->assign("NAME", Team::getDisplayName($focus->name, $focus->name_2));
$xtpl->assign("DESCRIPTION", $focus->description);
global $current_user;
if ($current_user->isAdminForModule('Users') && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
    $record = '';
    if (!empty($_REQUEST['record'])) {
        $record = $_REQUEST['record'];
    }
    $xtpl->assign("ADMIN_EDIT", "<a href='index.php?action=index&module=DynamicLayout&from_action=" . $_REQUEST['action'] . "&from_module=" . $_REQUEST['module'] . "&record=" . $record . "'>" . SugarThemeRegistry::current()->getImage("EditLayout", "border='0' align='bottom'", null, null, '.gif', $mod_strings['LBL_EDITLAYOUT']) . "</a>");
}
$javascript = new javascript();
$javascript->setFormName("EditView");
$javascript->addFieldGeneric("name", "varchar", $mod_strings['LBL_NAME'], TRUE, "");
$xtpl->parse("main");
$xtpl->out("main");
echo $javascript->getScript();
예제 #9
0
}
global $mod_strings;
global $app_strings;
$focus = BeanFactory::getBean('Teams', $_REQUEST['record']);
//Check if there are module records where this team is assigned to in a team_set_id
//if so, redirect to prompt the Administrator to select a new team
if ($focus->has_records_in_modules()) {
    header("Location: index.php?module=Teams&action=ReassignTeams&record={$focus->id}");
} else {
    //todo: Verify that no items are still assigned to this team.
    if ($focus->id == $focus->global_team) {
        $msg = $GLOBALS['app_strings']['LBL_MASSUPDATE_DELETE_GLOBAL_TEAM'];
        $GLOBALS['log']->fatal($msg);
        $error_message = $app_strings['LBL_MASSUPDATE_DELETE_GLOBAL_TEAM'];
        SugarApplication::appendErrorMessage($error_message);
        header('Location: index.php?module=Teams&action=DetailView&record=' . $focus->id);
        return;
    }
    //Check if the associated user is deleted
    $user = BeanFactory::getBean('Users', $focus->associated_user_id);
    if ($focus->private == 1 && (!empty($user->id) && $user->deleted != 1)) {
        $msg = string_format($GLOBALS['app_strings']['LBL_MASSUPDATE_DELETE_USER_EXISTS'], array(Team::getDisplayName($focus->name, $focus->name_2), $user->full_name));
        $GLOBALS['log']->error($msg);
        SugarApplication::appendErrorMessage($msg);
        header('Location: index.php?module=Teams&action=DetailView&record=' . $focus->id);
        return;
    }
    //Call mark_deleted function
    $focus->mark_deleted();
    header("Location: index.php?module=Teams&action=index");
}
예제 #10
0
function get_display_text($temp_module, $field, $field_value, $adv_type = null, $ext1 = null, $context = null)
{
    global $app_list_strings, $current_user;
    if ($temp_module->field_defs[$field]['type'] == "relate") {
        //echo $field;
        //bug 23502, assigned user should be displayed as username here. But I don't know if created user, modified user or even other module should display names instead of ids.
        if ($temp_module->field_defs[$field]['name'] == 'assigned_user_id' && !empty($field_value) && !empty($context['for_action_display'])) {
            if ($adv_type != 'exist_user') {
                return get_username_by_id($field_value);
            } else {
                $target_type = "assigned_user_name";
            }
        } else {
            if (!empty($temp_module->field_defs[$field]['dbType'])) {
                $target_type = $temp_module->field_defs[$field]['dbType'];
            } else {
                return $field_value;
            }
        }
    } else {
        if (!empty($temp_module->field_defs[$field]['calculated']) && !empty($context['for_action_display'])) {
            //Cannot set the value of calculated fields.
            return false;
        } else {
            $target_type = $temp_module->field_defs[$field]['type'];
        }
    }
    //Land of the "one offs"
    //This is for meetings and calls, the reminder time
    if ($temp_module->field_defs[$field]['name'] == "reminder_time") {
        $target_type = "enum";
        $temp_module->field_defs[$field]['options'] = "reminder_time_options";
    }
    // handle currency_id field to display the actual currency name vs the id when in edit view.
    if ($target_type == 'currency_id' && !empty($field_value)) {
        $currency = SugarCurrency::getCurrencyByID($field_value);
        return $currency->name;
    }
    // display team name for team_id field
    if ($field == 'team_id' && !empty($field_value)) {
        $team = BeanFactory::getBean('Teams', $field_value, array('strict_retrieve' => true));
        if ($team) {
            return Team::getDisplayName($team->name, $team->name_2);
        }
    }
    if ($target_type == "assigned_user_name") {
        if ($adv_type == null) {
            $user_array = get_user_array(TRUE, "Active", $field_value, true);
            if (!isset($user_array[$field_value])) {
                return false;
            }
            return $user_array[$field_value];
        }
        if ($adv_type == "exist_user") {
            if ($ext1 == "Manager") {
                return "Manager of the " . $app_list_strings['wflow_adv_user_type_dom'][$field_value];
            } else {
                return $app_list_strings['wflow_adv_user_type_dom'][$field_value];
            }
        }
    }
    if ($adv_type == "datetime") {
        if (empty($field_value)) {
            $field_value = 0;
        }
        return $app_list_strings['tselect_type_dom'][$field_value] . " from " . $app_list_strings['wflow_action_datetime_type_dom'][$ext1];
    }
    if ($adv_type == "exist_team") {
        return $app_list_strings['wflow_adv_team_type_dom'][$field_value];
    }
    if ($adv_type == "value_calc") {
        return "existing value" . $app_list_strings['query_calc_oper_dom'][$ext1] . " by " . $field_value;
    }
    if ($adv_type == "enum_step") {
        return $app_list_strings['wflow_adv_enum_type_dom'][$ext1] . " " . $field_value . " step(s)";
    }
    //Used primarily for alert templates
    require_once 'include/SugarFields/SugarFieldHandler.php';
    $sugarField = SugarFieldHandler::getSugarField($target_type);
    $field_value = $sugarField->getEmailTemplateValue($field_value, $temp_module->field_defs[$field], $context);
    return $field_value;
    //end get_display_text
}