function _edit_score($OID = 0, $CID = 0)
{
    loginRequireMgmt();
    if (!loginCheckPermission(USER::MGMT_TEAM)) {
        redirect("errors/401");
    }
    $item = "Team";
    $urlPrefix = "mgmt_team";
    $object = new Team();
    $object->retrieve($OID, $CID);
    if (!$object->exists()) {
        $data['body'][] = "<p>{$item} Not Found!</p>";
    } else {
        $fdata['form_heading'] = "Edit {$item} Score";
        $fdata['object'] = $object;
        $fdata['actionUrl'] = myUrl("{$urlPrefix}/ops_update_score");
        $fdata['actionLabel'] = "Submit";
        $fdata['cancelUrl'] = myUrl("{$urlPrefix}/manage");
        $fdata['cancelLabel'] = "Cancel";
        $form = View::do_fetch(VIEW_PATH . "{$urlPrefix}/score_form.php", $fdata);
        $data['head'][] = View::do_fetch(VIEW_PATH . "{$urlPrefix}/score_form_js.php");
        $data['body'][] = "<h2>Edit {$item} Score</h2>";
        $data['body'][] = $form;
    }
    View::do_dump(VIEW_PATH . 'layouts/mgmtlayout.php', $data);
}
function _ops_update_score()
{
    $OID = max(0, intval($_POST['OID']));
    $CID = max(0, intval($_POST['CID']));
    $msg = "";
    loginRequireMgmt();
    if (!loginCheckPermission(USER::MGMT_TEAM)) {
        redirect("errors/401");
    }
    $itemName = "Team";
    $urlPrefix = "mgmt_team";
    $object = new Team();
    if ($OID) {
        $object->retrieve($OID, $CID);
        if (!$object->exists()) {
            $msg = "{$itemName} not found!";
        } else {
            transactionBegin();
            if ($object->updateTotalScore()) {
                Event::createEvent(EVENT::TYPE_EDIT, $object, Station::getRegistrationStation(), 0, $_POST);
                // just put the post data into the event
                transactionCommit();
                $msg = "{$itemName} updated!";
            } else {
                transactionRollback();
                $msg = "{$itemName} update failed";
            }
        }
    } else {
        $msg = "attempting to create team from ops_update_score which is not supported";
    }
    redirect("{$urlPrefix}/manage", $msg);
}
function _ops_update()
{
    $OID = max(0, intval($_POST['OID']));
    $CID = max(0, intval($_POST['CID']));
    $msg = "";
    loginRequireMgmt();
    if (!loginCheckPermission(USER::MGMT_TEAM)) {
        redirect("errors/401");
    }
    $itemName = "Team";
    $urlPrefix = "mgmt_team";
    $object = new Team();
    if ($OID) {
        $object->retrieve($OID, $CID);
        if (!$object->exists()) {
            $msg = "{$itemName} not found!";
        } else {
            transactionBegin();
            $object->merge($_POST);
            if ($object->update()) {
                transactionCommit();
                $msg = "{$itemName} updated!";
            } else {
                transactionRollback();
                $msg = "{$itemName} update failed";
            }
        }
    } else {
        $object->merge($_POST);
        for ($retry = 0; $retry < PIN_RETRY_MAX; $retry++) {
            $pin = Team::generatePIN();
            if (Team::getFromPin($pin) === false) {
                // not a duplicate
                $object->set('pin', $pin);
                transactionBegin();
                if ($object->create() !== false) {
                    transactionCommit();
                    $msg = "{$itemName} created!";
                    break;
                }
            }
        }
        if ($retry >= PIN_RETRY_MAX) {
            transactionRollback();
            $msg = "{$itemName} Create failed";
        }
    }
    redirect("{$urlPrefix}/manage", $msg);
}
 /**
  * For a group email account, create subscriptions for all users associated with the
  * team assigned to the account.
  *
  */
 function createUserSubscriptionsForGroupAccount()
 {
     $team = new Team();
     $team->retrieve($this->team_id);
     $usersList = $team->get_team_members(true);
     foreach ($usersList as $userObject) {
         $previousSubscriptions = unserialize(base64_decode($userObject->getPreference('showFolders', 'Emails', $userObject)));
         if ($previousSubscriptions === FALSE) {
             $previousSubscriptions = array();
         }
         $previousSubscriptions[] = $this->id;
         $encodedSubs = base64_encode(serialize($previousSubscriptions));
         $userObject->setPreference('showFolders', $encodedSubs, '', 'Emails');
         $userObject->savePreferencesToDB();
     }
 }
}
logThis('database repaired', $path);
logThis('Start rebuild relationships.', $path);
@rebuildRelations();
logThis('End rebuild relationships.', $path);
include "{$unzip_dir}/manifest.php";
$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';
function template_calendar(&$args)
{
    global $timedate;
    if (isset($args['size']) && ($args['size'] = 'small')) {
        $args['calendar']->show_activities = false;
        $args['calendar']->show_week_on_month_view = false;
    }
    $newargs = array();
    $newargs['view'] = $args['view'];
    $newargs['calendar'] = $args['calendar'];
    if (!isset($args['size']) || $args['size'] != 'small') {
        template_cal_tabs($newargs);
    }
    if (isset($_REQUEST['view']) && $_REQUEST['view'] == 'shared') {
        global $ids;
        global $current_user;
        global $mod_strings;
        global $app_list_strings, $current_language, $currentModule, $action, $app_strings;
        $current_module_strings = return_module_language($current_language, 'Calendar');
        $ids = array();
        $user_ids = $current_user->getPreference('shared_ids');
        //get list of user ids for which to display data
        if (!empty($user_ids) && count($user_ids) != 0 && !isset($_REQUEST['shared_ids'])) {
            $ids = $user_ids;
        } elseif (isset($_REQUEST['shared_ids']) && count($_REQUEST['shared_ids']) > 0) {
            $ids = $_REQUEST['shared_ids'];
            $current_user->setPreference('shared_ids', $_REQUEST['shared_ids']);
        } else {
            //$ids = get_user_array(false);
            //$ids = array_keys($ids);
            $ids = array($current_user->id);
        }
        //get team id for which to display user list
        $team = $current_user->getPreference('team_id');
        if (!empty($team) && !isset($_REQUEST['team_id'])) {
            $team_id = $team;
        } elseif (isset($_REQUEST['team_id'])) {
            $team_id = $_REQUEST['team_id'];
            $current_user->setPreference('team_id', $_REQUEST['team_id']);
        } else {
            $team_id = '';
        }
        if (empty($_SESSION['team_id'])) {
            $_SESSION['team_id'] = "";
        }
        $tools = '<div align="right"><a href="index.php?module=' . $currentModule . '&action=' . $action . '&view=shared" class="tabFormAdvLink">&nbsp;<a href="javascript: toggleDisplay(\'shared_cal_edit\');" class="tabFormAdvLink">' . SugarThemeRegistry::current()->getImage('edit', 'alt="' . $current_module_strings['LBL_EDIT'] . '"  border="0"  align="absmiddle"') . '&nbsp;' . $current_module_strings['LBL_EDIT'] . '</a></div>';
        echo get_form_header($mod_strings['LBL_SHARED_CAL_TITLE'], $tools, false);
        if (empty($_SESSION['shared_ids'])) {
            $_SESSION['shared_ids'] = "";
        }
        echo "\n\t\t\t<script language=\"javascript\">\n\t\t\tfunction up(name) {\n\t\t\t\tvar td = document.getElementById(name+'_td');\n\t\t\t\tvar obj = td.getElementsByTagName('select')[0];\n\t\t\t\tobj =(typeof obj == \"string\") ? document.getElementById(obj) : obj;\n\t\t\t\tif(obj.tagName.toLowerCase() != \"select\" && obj.length < 2)\n\t\t\t\t\treturn false;\n\t\t\t\tvar sel = new Array();\n\t\t\t\n\t\t\t\tfor(i=0; i<obj.length; i++) {\n\t\t\t\t\tif(obj[i].selected == true) {\n\t\t\t\t\t\tsel[sel.length] = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(i in sel) {\n\t\t\t\t\tif(sel[i] != 0 && !obj[sel[i]-1].selected) {\n\t\t\t\t\t\tvar tmp = new Array(obj[sel[i]-1].text, obj[sel[i]-1].value);\n\t\t\t\t\t\tobj[sel[i]-1].text = obj[sel[i]].text;\n\t\t\t\t\t\tobj[sel[i]-1].value = obj[sel[i]].value;\n\t\t\t\t\t\tobj[sel[i]].text = tmp[0];\n\t\t\t\t\t\tobj[sel[i]].value = tmp[1];\n\t\t\t\t\t\tobj[sel[i]-1].selected = true;\n\t\t\t\t\t\tobj[sel[i]].selected = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tfunction down(name) {\n\t\t\t\tvar td = document.getElementById(name+'_td');\n\t\t\t\tvar obj = td.getElementsByTagName('select')[0];\n\t\t\t\tif(obj.tagName.toLowerCase() != \"select\" && obj.length < 2)\n\t\t\t\t\treturn false;\n\t\t\t\tvar sel = new Array();\n\t\t\t\tfor(i=obj.length-1; i>-1; i--) {\n\t\t\t\t\tif(obj[i].selected == true) {\n\t\t\t\t\t\tsel[sel.length] = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(i in sel) {\n\t\t\t\t\tif(sel[i] != obj.length-1 && !obj[sel[i]+1].selected) {\n\t\t\t\t\t\tvar tmp = new Array(obj[sel[i]+1].text, obj[sel[i]+1].value);\n\t\t\t\t\t\tobj[sel[i]+1].text = obj[sel[i]].text;\n\t\t\t\t\t\tobj[sel[i]+1].value = obj[sel[i]].value;\n\t\t\t\t\t\tobj[sel[i]].text = tmp[0];\n\t\t\t\t\t\tobj[sel[i]].value = tmp[1];\n\t\t\t\t\t\tobj[sel[i]+1].selected = true;\n\t\t\t\t\t\tobj[sel[i]].selected = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t</script>\n\t\t\t\n\t\t\t<div id='shared_cal_edit' style='display: none;'>\n\t\t\t<form name='shared_cal' action=\"index.php\" method=\"post\" >\n\t\t\t<input type=\"hidden\" name=\"module\" value=\"" . $currentModule . "\">\n\t\t\t<input type=\"hidden\" name=\"action\" value=\"" . $action . "\">\n\t\t\t<input type=\"hidden\" name=\"view\" value=\"shared\">\n\t\t\t<input type=\"hidden\" name=\"edit\" value=\"0\">\n\t\t\t<table cellpadding=\"0\" cellspacing=\"3\" border=\"0\" align=\"center\">\n\t\t\t<tr><th valign=\"top\"  align=\"center\" colspan=\"2\">\n\t\t\t";
        echo $current_module_strings['LBL_SELECT_USERS'];
        echo "\n\t\t\t</th>\n\t\t\t</tr>\n\t\t\t<tr><td valign=\"top\">";
        echo "\n\t\t\t<table cellpadding=\"1\" cellspacing=\"1\" border=\"0\" class=\"edit view\" align=\"center\">\n\n\t\t\t<tr>\n\t\t\t\t<td valign='top' nowrap><b>" . $current_module_strings['LBL_FILTER_BY_TEAM'] . "</b></td>\n\t\t\t\t<td valign='top' id=\"teams\"><select id=\"team_id\" onchange='this.form.edit.value=1; this.form.submit();' name=\"team_id\">";
        $teams = get_team_array(false);
        array_unshift($teams, '');
        echo get_select_options_with_id($teams, $team_id);
        echo "</select></td>\n\t\t\t</tr>\n\t\t\t</table>";
        echo "\n            </td><td valign=\"top\">\n\n\t\t\t<table cellpadding=\"1\" cellspacing=\"1\" border=\"0\" class=\"edit view\" align=\"center\">\n\t\t\t<tr>\n\t\t\t\t<td valign='top' nowrap><b>" . $current_module_strings['LBL_USERS'] . "</b></td>\n\t\t\t\t<td valign='top' id=\"shared_ids_td\"><select id=\"shared_ids\" name=\"shared_ids[]\" multiple size='3'>";
        if (!empty($team_id)) {
            $team = new Team();
            $team->retrieve($team_id);
            $users = $team->get_team_members();
            $user_ids = array();
            foreach ($users as $user) {
                $user_ids[$user->id] = $user->user_name;
            }
            echo get_select_options_with_id($user_ids, $ids);
        } else {
            echo get_select_options_with_id(get_user_array(false), $ids);
        }
        echo "\t</select></td>\n\t\t\t\t<td><a onclick=\"up('shared_ids');\">" . SugarThemeRegistry::current()->getImage('uparrow_big', 'border="0" style="margin-bottom: 1px;" alt="' . $app_strings['LBL_SORT'] . '"') . "</a><br>\n\t\t\t\t<a onclick=\"down('shared_ids');\">" . SugarThemeRegistry::current()->getImage('downarrow_big', 'border="0" style="margin-top: 1px;"  alt="' . $app_strings['LBL_SORT'] . '"') . "</a></td>\n\t\t\t</tr>\n\t\t\t<tr>";
        echo "<td align=\"right\" colspan=\"2\"><input class=\"button\" type=\"submit\" title=\"" . $app_strings['LBL_SELECT_BUTTON_TITLE'] . "\" accessKey=\"" . $app_strings['LBL_SELECT_BUTTON_KEY'] . "\" value=\"" . $app_strings['LBL_SELECT_BUTTON_LABEL'] . "\" /><input class=\"button\" onClick=\"javascript: toggleDisplay('shared_cal_edit');\" type=\"button\" title=\"" . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . "\" accessKey=\"" . $app_strings['LBL_CANCEL_BUTTON_KEY'] . "\" value=\"" . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . "\"/></td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</td></tr>\n\t\t\t</table>\n\t\t\t</form>";
    }
    // end "shared" view
    echo "</div></p>\n\t\t<script language=\"javascript\">";
    if (isset($_REQUEST['edit']) && $_REQUEST['edit']) {
        echo "toggleDisplay('shared_cal_edit');";
    }
    if (isset($_REQUEST['view']) && !empty($_REQUEST['month'])) {
        if ($_REQUEST['view'] == 'day') {
            if (ACLController::checkAccess('Calls', 'edit', true)) {
                echo "\n\t\t\t\tdocument.CallSave.date_start.value = \"" . $timedate->to_display_date($args['calendar']->date_time->get_mysql_date(), false) . "\"\n\t\t\t\tdocument.CallSave.time_start.value = \"" . $timedate->to_display_time($args['calendar']->date_time->get_mysql_time() . ':00', false) . "\"";
            }
        }
    }
    echo "\n\t\tfunction set_dates(date,time)\n\t\t{\n\t\tdocument.CallSave.date_start.value = date;\n\t\tdocument.CallSave.time_start.value = time;\n\t\t\n\t\t}\n\t\t</script>\n\t\t<table id=\"daily_cal_table_outside\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"monthBox\">\n\t\t<tr>\n\t\t<td>\n\t\t  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"monthHeader\">\n\t\t  <tr>\n\t\t  <td width=\"1%\" nowrap>";
    if (!isset($args['size']) || $args['size'] != 'small') {
        template_get_previous_calendar($args);
    }
    echo "\n\t\t  </td>\n\t\t  <td width=\" 98 % \" align=center scope='row'>";
    if (isset($args['size']) && ($args['size'] = 'small')) {
        ?>
		<a style="text-decoration: none;" 
			href="index.php?module=ECalendar&action=index&view=month&<?php 
        echo $args['calendar']->date_time->get_date_str();
        ?>
">
<?php 
    }
    ?>
<h3>
<?php 
    template_echo_date_info($args['view'], $args['calendar']->date_time);
    ?>
</h3>
<?php 
    if (isset($args['size']) && ($args['size'] = 'small')) {
        echo "</a>";
    }
    ?>

  </td>
  <td align="right" width="1%" nowrap><?php 
    if (!isset($args['size']) || $args['size'] != 'small') {
        template_get_next_calendar($args);
    }
    ?>
 </td>
  </tr>
  </table>
</td>
</tr>
<tr>
<td class="monthCalBody">
<?php 
    if ($args['calendar']->view == 'month') {
        template_calendar_month($args);
    } else {
        if ($args['calendar']->view == 'year') {
            template_calendar_year($args);
        } else {
            if ($args['calendar']->view == 'shared') {
                global $current_user, $shared_user;
                $shared_args = array();
                foreach ($args as $key => $val) {
                    $shared_args[$key] = $val;
                }
                $shared_args['calendar'] = $args['calendar'];
                $shared_user = new User();
                foreach ($ids as $member) {
                    $shared_user->retrieve($member);
                    $shared_args['calendar']->show_tasks = true;
                    $shared_args['calendar']->add_activities($shared_user);
                    $shared_args['show_link'] = 'off';
                    if ($shared_user->id == $current_user->id) {
                        $shared_args['show_link'] = 'on';
                    }
                    echo '<h5 class="calSharedUser">' . $shared_user->full_name . '</h5>';
                    template_calendar_horizontal($shared_args);
                }
            } else {
                template_calendar_vertical($args);
            }
        }
    }
    ?>
</td>
</tr>
<tr>
<td>
  <table width="100%" cellspacing="0" cellpadding="0" class="monthFooter">
  <tr>
  <td width="50%"><?php 
    template_get_previous_calendar($args);
    ?>
</td>
  <td align="right" width="50%"><?php 
    template_get_next_calendar($args);
    ?>
</td>
  </tr>
  </table>

</td>
</tr>
</table>
<?php 
}
示例#7
0
 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");
 }