Exemplo n.º 1
0
 /**
  * @see SugarView::process()
  */
 public function process()
 {
     global $current_user;
     if (!is_admin($current_user)) {
         sugar_die("Unauthorized access to administration.");
     }
     // Check if the theme is valid
     if (!isset($_REQUEST['theme']) || !in_array($_REQUEST['theme'], array_keys(SugarThemeRegistry::allThemes()))) {
         sugar_die("theme is invalid.");
     }
     if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'save') {
         $theme_config = SugarThemeRegistry::getThemeConfig($_REQUEST['theme']);
         $configurator = new Configurator();
         foreach ($theme_config as $name => $def) {
             if (isset($_REQUEST[$name])) {
                 if ($_REQUEST[$name] == 'true') {
                     $_REQUEST[$name] = true;
                 } else {
                     if ($_REQUEST[$name] == 'false') {
                         $_REQUEST[$name] = false;
                     }
                 }
                 $configurator->config['theme_settings'][$_REQUEST['theme']][$name] = $_REQUEST[$name];
             }
         }
         $configurator->handleOverride();
         SugarApplication::redirect('index.php?module=Administration&action=ThemeSettings');
         exit;
     }
     parent::process();
 }
Exemplo n.º 2
0
 function action_optimise()
 {
     set_time_limit(6000);
     $index = BeanFactory::getBean("AOD_Index")->getIndex();
     $index->optimise();
     SugarApplication::redirect('index.php?module=AOD_Index');
 }
Exemplo n.º 3
0
 /**
  * OAuth Login
  *
  * @return bool Success or failure
  */
 public function oauthLogin()
 {
     global $sugar_config;
     $apiKey = $this->getConnector()->getProperty('oauth_consumer_key');
     if (!isset($_REQUEST['code'])) {
         $callback = $sugar_config['site_url'] . '/index.php?module=EAPM&action=oauth&record=' . $this->eapmBean->id;
         $callback = $this->formatCallbackURL($callback);
         $queryData = array('client_id' => $apiKey, 'redirect_uri' => $callback);
         SugarApplication::redirect($this->getOauthAuthURL() . '?' . http_build_query($queryData));
     } else {
         $code = $_REQUEST['code'];
         $queryData = array('grant_type' => 'authorization_code', 'code' => $code, 'client_id' => $apiKey);
         $accReq = $this->getOauthAccessURL() . '?' . http_build_query($queryData);
         $rawResponse = $this->makeRequest($accReq);
         if ($rawResponse && $rawResponse->isSuccessful()) {
             $response = json_decode($rawResponse->getBody(), true);
             if (!empty($response['access_token'])) {
                 $this->eapmBean->oauth_token = $response['access_token'];
                 $this->eapmBean->validated = 1;
                 $this->eapmBean->save();
                 return true;
             }
         }
         return false;
     }
 }
Exemplo n.º 4
0
 public function logout()
 {
     session_destroy();
     ob_clean();
     $this->box->deleteSession();
     SugarApplication::redirect($this->box->loginUrl());
 }
Exemplo n.º 5
0
 function action_archived()
 {
     $this->bean->archived = 'true';
     $this->bean->won = '';
     $this->bean->save();
     SugarApplication::redirect('index.php?module=TILKEE_TILKS&action=DetailView&record=' . $this->bean->id);
 }
Exemplo n.º 6
0
 /**
  * pre_login
  * 
  * Override the pre_login function from SugarAuthenticate so that user is
  * redirected to SAML entry point if other is not specified
  */
 function pre_login()
 {
     parent::pre_login();
     if (empty($_REQUEST['no_saml'])) {
         SugarApplication::redirect('?entryPoint=SAML');
     }
 }
Exemplo n.º 7
0
 public function save(&$bean, $params, $field, $vardef, $prefix = '')
 {
     $fakeDisplayParams = array();
     $this->fillInOptions($vardef, $fakeDisplayParams);
     require_once 'include/upload_file.php';
     $upload_file = new UploadFile($prefix . $field . '_file');
     //remove file
     if (isset($_REQUEST['remove_file_' . $field]) && $params['remove_file_' . $field] == 1) {
         $upload_file->unlink_file($bean->{$field});
         $bean->{$field} = "";
     }
     $move = false;
     if (isset($_FILES[$prefix . $field . '_file']) && $upload_file->confirm_upload()) {
         if ($this->verify_image($upload_file)) {
             $bean->{$field} = $upload_file->get_stored_file_name();
             $move = true;
         } else {
             //not valid image.
             $GLOBALS['log']->fatal("Image Field : Not a Valid Image.");
             $temp = $vardef['vname'];
             $temp = translate($temp, $bean->module_name);
             SugarApplication::appendErrorMessage($temp . " Field :  Not a valid image format.");
         }
     }
     if (empty($bean->id)) {
         $bean->id = create_guid();
         $bean->new_with_id = true;
     }
     if ($move) {
         $upload_file->final_move($bean->id . '_' . $field);
         //BEAN ID IS THE FILE NAME IN THE INSTANCE.
         $upload_file->upload_doc($bean, $bean->id, $params[$prefix . $vardef['docType']], $bean->{$field}, $upload_file->mime_type);
     } else {
         if (!empty($old_id)) {
             // It's a duplicate, I think
             if (empty($params[$prefix . $vardef['docUrl']])) {
                 $upload_file->duplicate_file($old_id, $bean->id, $bean->{$field});
             } else {
                 $docType = $vardef['docType'];
                 $bean->{$docType} = $params[$prefix . $field . '_old_doctype'];
             }
         } else {
             if (!empty($params[$prefix . $field . '_remoteName'])) {
                 // We aren't moving, we might need to do some remote linking
                 $displayParams = array();
                 $this->fillInOptions($vardef, $displayParams);
                 if (isset($params[$prefix . $vardef['docId']]) && !empty($params[$prefix . $vardef['docId']]) && isset($params[$prefix . $vardef['docType']]) && !empty($params[$prefix . $vardef['docType']])) {
                     $bean->{$field} = $params[$prefix . $field . '_remoteName'];
                     require_once 'include/utils/file_utils.php';
                     $extension = get_file_extension($bean->{$field});
                     if (!empty($extension)) {
                         $bean->file_ext = $extension;
                         $bean->file_mime_type = get_mime_content_type_from_filename($bean->{$field});
                     }
                 }
             }
         }
     }
 }
    public function preDisplay()
    {
        ?>
<link rel="stylesheet" href="modules/Nexmo/views/style.css" /><?php 
        if (isset($this->view_object_map['val_error'])) {
            SugarApplication::appendErrorMessage($this->view_object_map['val_error']);
        }
    }
Exemplo n.º 9
0
 function action_desarchived()
 {
     //$this->bean->status = 'activated';
     //$this->bean->won    = '';
     //$this->bean->save();
     $this->bean->update_from_API('', 'false');
     SugarApplication::redirect('index.php?module=TILKEE_PROJECTS&action=DetailView&record=' . $this->bean->id);
 }
Exemplo n.º 10
0
 public function preDisplay()
 {
     if (!$GLOBALS['current_user']->isAdminForModule('Users')) {
         //instead of just dying here with unauthorized access will send the user back to his/her settings
         SugarApplication::redirect('index.php?module=Users&action=DetailView&record=' . $GLOBALS['current_user']->id);
     }
     $this->lv = new ListViewSmarty();
     $this->lv->delete = false;
     $this->lv->email = false;
 }
Exemplo n.º 11
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     if (isset($_FILES['vcard']['tmp_name']) && isset($_FILES['vcard']['size']) > 0) {
         $vcard = new vCard();
         $record = $vcard->importVCard($_FILES['vcard']['tmp_name'], $_REQUEST['module']);
         SugarApplication::redirect("index.php?action=DetailView&module={$_REQUEST['module']}&record={$record}");
     } else {
         SugarApplication::redirect("index.php?action=Importvcard&module={$_REQUEST['module']}");
     }
 }
Exemplo n.º 12
0
 function action_generatePdfJava()
 {
     global $mod_string;
     $id = $_REQUEST['uid'];
     $templateID = $_REQUEST['templateID'];
     $path = "/var/www/vhosts/portadainmobiliaria.iatech.com.co/httpdocs/crm/custom/modules/AOS_Contracts/ReportGenerator.jar";
     $command = "/usr/bin/java -Djava.awt.headless=true -jar  {$path} {$id} {$templateID}";
     exec($command, $output);
     $this->printRequest($_REQUEST, $path, $id, $templateID, $output, $command);
     //SugarApplication::redirect('index.php?entryPoint=download&id='.$id.'&type=Notes');
     SugarApplication::redirect('index.php?module=AOS_Contracts&action=DetailView&record=' . $id . '#history');
 }
Exemplo n.º 13
0
 public function display()
 {
     if (!SugarOAuthServer::enabled()) {
         sugar_die($GLOBALS['mod_strings']['LBL_OAUTH_DISABLED']);
     }
     global $current_user;
     if (!isset($_REQUEST['token']) && isset($_REQUEST['oauth_token'])) {
         $_REQUEST['token'] = $_REQUEST['oauth_token'];
     }
     $sugar_smarty = new Sugar_Smarty();
     $sugar_smarty->assign('APP', $GLOBALS['app_strings']);
     $sugar_smarty->assign('MOD', $GLOBALS['mod_strings']);
     $sugar_smarty->assign('token', $_REQUEST['token']);
     $sugar_smarty->assign('sid', session_id());
     $token = OAuthToken::load($_REQUEST['token']);
     if (empty($token) || empty($token->consumer) || $token->tstate != OAuthToken::REQUEST || empty($token->consumer_obj)) {
         sugar_die('Invalid token');
     }
     if (empty($_REQUEST['confirm'])) {
         $sugar_smarty->assign('consumer', sprintf($GLOBALS['mod_strings']['LBL_OAUTH_CONSUMERREQ'], $token->consumer_obj->name));
         // SM: roles disabled for now
         //            $roles = array('' => '');
         //            $allroles = ACLRole::getAllRoles();
         //            foreach($allroles as $role) {
         //                $roles[$role->id] = $role->name;
         //            }
         //            $sugar_smarty->assign('roles', $roles);
         $hash = md5(rand());
         $_SESSION['oauth_hash'] = $hash;
         $sugar_smarty->assign('hash', $hash);
         echo $sugar_smarty->fetch('modules/OAuthTokens/tpl/authorize.tpl');
     } else {
         if ($_REQUEST['sid'] != session_id() || $_SESSION['oauth_hash'] != $_REQUEST['hash']) {
             sugar_die('Invalid request');
         }
         $verify = $token->authorize(array("user" => $current_user->id));
         if (!empty($token->callback_url)) {
             $redirect_url = $token->callback_url;
             if (strchr($redirect_url, "?") !== false) {
                 $redirect_url .= '&';
             } else {
                 $redirect_url .= '?';
             }
             $redirect_url .= "oauth_verifier=" . $verify . '&oauth_token=' . $_REQUEST['token'];
             SugarApplication::redirect($redirect_url);
         }
         $sugar_smarty->assign('VERIFY', $verify);
         $sugar_smarty->assign('token', '');
         echo $sugar_smarty->fetch('modules/OAuthTokens/tpl/authorized.tpl');
     }
 }
Exemplo n.º 14
0
 protected function action_delete()
 {
     if ($_REQUEST['record'] != $GLOBALS['current_user']->id && $GLOBALS['current_user']->isAdminForModule('Users')) {
         $u = new User();
         $u->retrieve($_REQUEST['record']);
         $u->deleted = 1;
         $u->status = 'Inactive';
         $u->employee_status = 'Terminated';
         $u->save();
         $GLOBALS['log']->info("User id: {$GLOBALS['current_user']->id} deleted user record: {$_REQUEST['record']}");
         SugarApplication::redirect("index.php?module=Employees&action=index");
     } else {
         sugar_die("Unauthorized access to administration.");
     }
 }
Exemplo n.º 15
0
 public function action_log_autonote()
 {
     //Load a notes bean
     $notes_bean = BeanFactory::getBean("Notes");
     //Create a new note and save it
     $notes_bean->name = "Leads autonote";
     $notes_bean->description = "This note is autologged for a lead.";
     $note_id = $notes_bean->save();
     //Load leads-notes relationship
     $lead_bean = BeanFactory::getBean("Leads", $_REQUEST["record"]);
     $lead_bean->load_relationship("notes");
     //Save relationship record
     $lead_bean->notes->add($note_id);
     $lead_bean->save();
     SugarApplication::redirect('index.php?module=Leads&action=DetailView&record=' . $_REQUEST["record"]);
 }
Exemplo n.º 16
0
 public function action_schedule_followup()
 {
     //Create a new Calls bean
     $calls_bean = BeanFactory::getBean("Calls");
     $calls_bean->name = "A followup call";
     $calls_bean->direction = "Outbound";
     $calls_bean->status = "Planned";
     $unix_timestamp = strtotime("+7 day");
     $datetime = date("Y-m-d H:i:s", $unix_timestamp);
     $calls_bean->date_start = $datetime;
     $calls_bean->duration_hours = 0;
     $calls_bean->duration_minutes = 30;
     $calls_bean->save();
     //Create a relationship
     $this->bean->load_relationship("calls");
     $this->bean->calls->add($calls_bean->id);
     SugarApplication::redirect("index.php?module=Contacts&action=DetailView&record=" . $this->bean->id);
 }
Exemplo n.º 17
0
 public function pre_save()
 {
     parent::pre_save();
     $this->api = ExternalAPIFactory::loadAPI($this->bean->application, true);
     if (empty($this->api)) {
         return $this->failed(translate('LBL_AUTH_UNSUPPORTED', $this->bean->module_dir));
     }
     if (empty($this->bean->id)) {
         $eapmBean = EAPM::getLoginInfo($this->bean->application, true);
         if ($eapmBean) {
             SugarApplication::appendErrorMessage(translate('LBL_APPLICATION_FOUND_NOTICE', $this->bean->module_dir));
             $this->bean->id = $eapmBean->id;
         }
     }
     $this->bean->validated = false;
     $this->bean->save_cleanup();
     $this->api->loadEAPM($this->bean);
 }
Exemplo n.º 18
0
 protected function action_delete()
 {
     if ($_REQUEST['record'] != $GLOBALS['current_user']->id && $GLOBALS['current_user']->isAdminForModule('Users')) {
         $u = new User();
         $u->retrieve($_REQUEST['record']);
         $u->status = 'Inactive';
         $u->employee_status = 'Terminated';
         $u->save();
         $u->mark_deleted($u->id);
         $GLOBALS['log']->info("User id: {$GLOBALS['current_user']->id} deleted user record: {$_REQUEST['record']}");
         $eapm = loadBean('EAPM');
         $eapm->delete_user_accounts($_REQUEST['record']);
         $GLOBALS['log']->info("Removing user's External Accounts");
         SugarApplication::redirect("index.php?module=Users&action=index");
     } else {
         sugar_die("Unauthorized access to administration.");
     }
 }
Exemplo n.º 19
0
 /**
  * Written by: Hatim Alam
  * Dated: 11th Feb 2016
  * Controller action to logout temporary user and login back the original user
  */
 protected function action_sudo_logout_user()
 {
     //check if current user id is same as record id
     if (!empty($_REQUEST) && isset($_REQUEST['record']) && $_REQUEST['module'] == 'Users') {
         $requested_user_id = $_REQUEST['record'];
         if ($GLOBALS['current_user']->id == $requested_user_id && !empty($_SESSION['original_sudo_user_id'])) {
             $original_user_bean = BeanFactory::getBean('Users', $_SESSION['original_sudo_user_id']);
             $GLOBALS['current_user'] = $original_user_bean;
             $_SESSION['authenticated_user_id'] = $original_user_bean->id;
             $_SESSION['user_id'] = $original_user_bean->id;
             //unset session variables
             unset($_SESSION['original_sudo_user_id']);
             unset($_SESSION['original_sudo_user_name']);
             //redirect to original sudo user profile
             $query_params = array('module' => 'Users', 'action' => 'DetailView', 'record' => $original_user_bean->id);
             SugarApplication::redirect('index.php?' . http_build_query($query_params));
         }
     }
 }
Exemplo n.º 20
0
 protected function action_delete()
 {
     if ($_REQUEST['record'] != $GLOBALS['current_user']->id && $GLOBALS['current_user']->isAdminForModule('Users')) {
         $u = BeanFactory::getBean('Users', $_REQUEST['record']);
         $u->deleted = 1;
         $u->status = 'Inactive';
         $u->employee_status = 'Terminated';
         $u->save();
         $GLOBALS['log']->info("User id: {$GLOBALS['current_user']->id} deleted user record: {$_REQUEST['record']}");
         if (!empty($u->user_name)) {
             //If user redirect back to assignment screen.
             SugarApplication::redirect("index.php?module=Users&action=reassignUserRecords&record={$u->id}");
         } else {
             SugarApplication::redirect("index.php?module=Employees&action=index");
         }
     } else {
         sugar_die("Unauthorized access to administration.");
     }
 }
Exemplo n.º 21
0
 public function checkLogin($eapmBean = null)
 {
     $reply = parent::checkLogin($eapmBean);
     if (!$reply['success']) {
         return $reply;
     }
     if (!$this->setupFacebookLib()) {
         // FIXME: Translate
         return array('success' => FALSE, 'errorMessage' => 'Facebook does not have the required libraries.');
     }
     $GLOBALS['log']->debug('Checking login.');
     if (empty($this->eapmBean->oauth_secret)) {
         // We must be saving, try re-authing
         $GLOBALS['log']->debug('We must be saving.');
         if (!empty($_REQUEST['session'])) {
             $_REQUEST['session'] = str_replace('&quot;', '"', $_REQUEST['session']);
             $GLOBALS['log']->debug('Have a session from facebook: ' . $_REQUEST['session']);
             $fbSession = $this->fb->getSession();
             if (!empty($fbSession)) {
                 $GLOBALS['log']->debug('Have a VALID session from facebook:' . print_r($fbSession, true));
                 // Put a string in here so we can tell when it resets it.
                 $this->eapmBean->oauth_secret = 'SECRET';
                 $this->eapmBean->api_data = base64_encode(json_encode(array('fbSession' => $fbSession)));
                 $this->eapmBean->validated = 1;
                 $this->eapmBean->save();
                 return array('success' => true);
             } else {
                 // FIXME: Translate
                 $GLOBALS['log']->error('Have an INVALID session from facebook:' . print_r($fbSession, true));
                 return array('success' => false, 'errorMessage' => 'No authentication.');
             }
         } else {
             $callback_url = $GLOBALS['sugar_config']['site_url'] . '/index.php?module=EAPM&action=oauth&record=' . $this->eapmBean->id;
             $callback_url = $this->formatCallbackURL($callback_url);
             $loginUrl = $this->fb->getLoginUrl(array('next' => $callback_url, 'cancel' => $callback_url, 'req_perms' => 'read_stream,offline_access'));
             SugarApplication::redirect($loginUrl);
             return array('success' => false);
         }
     }
     return $reply;
 }
Exemplo n.º 22
0
 protected function action_delete()
 {
     if ($_REQUEST['record'] != $GLOBALS['current_user']->id && $GLOBALS['current_user']->isAdminForModule('Users')) {
         $u = BeanFactory::getBean('Users', $_REQUEST['record']);
         $u->status = 'Inactive';
         $u->deleted = 1;
         $u->employee_status = 'Terminated';
         $u->save();
         $GLOBALS['log']->info("User id: {$GLOBALS['current_user']->id} deleted user record: {$_REQUEST['record']}");
         $eapm = BeanFactory::getBean('EAPM');
         $eapm->delete_user_accounts($_REQUEST['record']);
         $GLOBALS['log']->info("Removing user's External Accounts");
         if ($u->portal_only == '0') {
             SugarApplication::redirect("index.php?module=Users&action=reassignUserRecords&record={$u->id}");
         } else {
             SugarApplication::redirect("index.php?module=Users&action=index");
         }
     } else {
         sugar_die("Unauthorized access to administration.");
     }
 }
Exemplo n.º 23
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     $redirect = "index.php?action=Importvcard&module={$_REQUEST['module']}";
     if (!empty($_FILES['vcard']) && $_FILES['vcard']['error'] == 0) {
         $vcard = new vCard();
         $record = $vcard->importVCard($_FILES['vcard']['tmp_name'], $_REQUEST['module']);
         if (empty($record)) {
             SugarApplication::redirect($redirect . '&error=vcardErrorRequired');
         }
         SugarApplication::redirect("index.php?action=DetailView&module={$_REQUEST['module']}&record={$record}");
     } else {
         switch ($_FILES['vcard']['error']) {
             case UPLOAD_ERR_FORM_SIZE:
                 $redirect .= "&error=vcardErrorFilesize";
                 break;
             default:
                 $redirect .= "&error=vcardErrorDefault";
                 $GLOBALS['log']->error('Upload error code: ' . $_FILES['vcard']['error'] . '. Please refer to the error codes http://php.net/manual/en/features.file-upload.errors.php');
                 break;
         }
         SugarApplication::redirect($redirect);
     }
 }
Exemplo n.º 24
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     $redirect = "index.php?action=Importvcard&module={$_REQUEST['module']}";
     if (!empty($_FILES['vcard']) && is_uploaded_file($_FILES['vcard']['tmp_name']) && $_FILES['vcard']['error'] == 0) {
         $vcard = new vCard();
         try {
             $record = $vcard->importVCard($_FILES['vcard']['tmp_name'], $_REQUEST['module']);
         } catch (Exception $e) {
             SugarApplication::redirect($redirect . '&error=vcardErrorRequired');
         }
         SugarApplication::redirect("index.php?action=DetailView&module={$_REQUEST['module']}&record={$record}");
     } else {
         switch ($_FILES['vcard']['error']) {
             case UPLOAD_ERR_FORM_SIZE:
                 $redirect .= "&error=vcardErrorFilesize";
                 break;
             default:
                 $redirect .= "&error=vcardErrorDefault";
                 $GLOBALS['log']->info('Upload error code: ' . $_FILES['vcard']['error'] . '.');
                 break;
         }
         SugarApplication::redirect($redirect);
     }
 }
Exemplo n.º 25
0
 public function action_sendinvitemails()
 {
     global $db;
     global $sugar_config;
     global $mod_strings;
     $id = $_GET['record'];
     //get event
     $event = new FP_events();
     $event->retrieve($id);
     $event->load_relationship('fp_events_contacts');
     // get related contacts
     $event->load_relationship('fp_events_prospects_1');
     //get related targets
     $event->load_relationship('fp_events_leads_1');
     //get related leads
     //Count the number of delegates linked to the event that have not yet been invited
     $query = "SELECT * FROM fp_events_contacts_c WHERE fp_events_contactsfp_events_ida='" . $event->id . "' AND (invite_status='Not Invited' OR invite_status='' OR invite_status IS NULL) AND deleted='0'";
     $result = $db->query($query);
     $contact_count = $db->getRowCount($result);
     //count contacts
     $query = "SELECT * FROM fp_events_prospects_1_c WHERE fp_events_prospects_1fp_events_ida='" . $event->id . "' AND (invite_status='Not Invited' OR invite_status='' OR invite_status IS NULL) AND deleted='0'";
     $result = $db->query($query);
     $prospect_count = $db->getRowCount($result);
     //count targets
     $query = "SELECT * FROM fp_events_leads_1_c WHERE fp_events_leads_1fp_events_ida='" . $event->id . "' AND (invite_status='Not Invited' OR invite_status='' OR invite_status IS NULL) AND deleted='0'";
     $result = $db->query($query);
     $lead_count = $db->getRowCount($result);
     //count leads
     $delegate_count = $contact_count + $prospect_count + $lead_count;
     //Total up delegates
     $invite_count = 0;
     //used to count the number of emails sent
     $error_count = 0;
     //used to count the number of failed email attempts
     //loop through related contacts
     foreach ($event->fp_events_contacts->getBeans() as $contact) {
         //Get accept status of contact
         $query = 'SELECT invite_status FROM fp_events_contacts_c WHERE fp_events_contactsfp_events_ida="' . $event->id . '" AND fp_events_contactscontacts_idb="' . $contact->id . '"';
         $status = $db->getOne($query);
         if ($status == null || $status == '' || $status == 'Not Invited') {
             $invite_count++;
             //set email links
             $event->link = "<a href='" . $sugar_config['site_url'] . "/index.php?entryPoint=responseEntryPoint&event=" . $event->id . "&delegate=" . $contact->id . "&type=c&response=accept'>Accept</a>";
             $event->link_declined = "<a href='" . $sugar_config['site_url'] . "/index.php?entryPoint=responseEntryPoint&event=" . $event->id . "&delegate=" . $contact->id . "&type=c&response=decline'>Decline</a>";
             //Get the TO name and e-mail address for the message
             $rcpt_name = $contact->first_name . ' ' . $contact->last_name;
             $rcpt_email = $contact->email1;
             $emailTemp = new EmailTemplate();
             $emailTemp->disable_row_level_security = true;
             $emailTemp->retrieve($event->invite_templates);
             //Use the ID value of the email template record
             //check email template is set, if not return error
             if ($emailTemp->id == '') {
                 SugarApplication::appendErrorMessage($mod_strings['LBL_ERROR_MSG_5']);
                 SugarApplication::redirect("index.php?module=FP_events&return_module=FP_events&action=DetailView&record=" . $event->id);
                 die;
             }
             //parse the lead varibales first
             $firstpass = $emailTemp->parse_template_bean($emailTemp->body_html, 'Contacts', $contact);
             $email_subject = $emailTemp->parse_template_bean($emailTemp->subject, 'FP_events', $event);
             $email_body = from_html($emailTemp->parse_template_bean($firstpass, 'FP_events', $event));
             $alt_emailbody = wordwrap($emailTemp->parse_template_bean($firstpass, 'FP_events', $event), 900);
             //get attachments
             $attachmentBean = new Note();
             $attachment_list = $attachmentBean->get_full_list('', "parent_type = 'Emails' AND parent_id = '" . $event->invite_templates . "'");
             $attachments = array();
             if ($attachment_list != null) {
                 foreach ($attachment_list as $attachment) {
                     $attachments[] = $attachment;
                 }
             }
             //send the email
             $send_invite = $this->sendEmail($rcpt_email, $email_subject, $rcpt_name, $email_body, $alt_emailbody, $contact, $attachments);
             //Send the message, log if error occurs
             if (!$send_invite) {
                 $GLOBALS['log']->fatal('ERROR: Invite email failed to send to: ' . $rcpt_name . ' at ' . $rcpt_email);
                 $error_count++;
             } else {
                 //update contact to invites
                 $query = 'UPDATE fp_events_contacts_c SET invite_status="Invited" WHERE fp_events_contactsfp_events_ida="' . $event->id . '" AND fp_events_contactscontacts_idb="' . $contact->id . '"';
                 $res = $db->query($query);
             }
         }
     }
     //loop through related targets
     foreach ($event->fp_events_prospects_1->getBeans() as $target) {
         //Get accept status of contact
         $query = 'SELECT invite_status FROM fp_events_prospects_1_c WHERE fp_events_prospects_1fp_events_ida="' . $event->id . '" AND fp_events_prospects_1prospects_idb="' . $target->id . '"';
         $status = $db->getOne($query);
         if ($status == null || $status == '' || $status == 'Not Invited') {
             $invite_count++;
             //set email links
             $event->link = "<a href='" . $sugar_config['site_url'] . "/index.php?entryPoint=responseEntryPoint&event=" . $event->id . "&delegate=" . $target->id . "&type=t&response=accept'>Accept</a>";
             $event->link_declined = "<a href='" . $sugar_config['site_url'] . "/index.php?entryPoint=responseEntryPoint&event=" . $event->id . "&delegate=" . $target->id . "&type=t&response=decline'>Decline</a>";
             //Get the TO name and e-mail address for the message
             $rcpt_name = $target->first_name . ' ' . $target->last_name;
             $rcpt_email = $target->email1;
             $emailTemp = new EmailTemplate();
             $emailTemp->disable_row_level_security = true;
             $emailTemp->retrieve($event->invite_templates);
             //Use the ID value of the email template record
             //parse the lead varibales first
             $firstpass = $emailTemp->parse_template_bean($emailTemp->body_html, 'Contacts', $target);
             $email_subject = $emailTemp->parse_template_bean($emailTemp->subject, 'FP_events', $event);
             $email_body = from_html($emailTemp->parse_template_bean($firstpass, 'FP_events', $event));
             $alt_emailbody = wordwrap($emailTemp->parse_template_bean($firstpass, 'FP_events', $event), 900);
             //get attachments
             $attachmentBean = new Note();
             $attachment_list = $attachmentBean->get_full_list('', "parent_type = 'Emails' AND parent_id = '" . $event->invite_templates . "'");
             $attachments = array();
             if ($attachment_list != null) {
                 foreach ($attachment_list as $attachment) {
                     $attachments[] = $attachment;
                 }
             }
             //send the email
             $send_invite = $this->sendEmail($rcpt_email, $email_subject, $rcpt_name, $email_body, $alt_emailbody, $target, $attachments);
             //Send the message, log if error occurs
             if (!$send_invite) {
                 $GLOBALS['log']->fatal('ERROR: Invite email failed to send to: ' . $rcpt_name . ' at ' . $rcpt_email);
                 $error_count++;
             } else {
                 //update contact to invites
                 $query = 'UPDATE fp_events_prospects_1_c SET invite_status="Invited" WHERE fp_events_prospects_1fp_events_ida="' . $event->id . '" AND fp_events_prospects_1prospects_idb="' . $target->id . '"';
                 $res = $db->query($query);
             }
         }
     }
     //loop through related leads
     foreach ($event->fp_events_leads_1->getBeans() as $lead) {
         //Get accept status of contact
         $query = 'SELECT invite_status FROM fp_events_leads_1_c WHERE fp_events_leads_1fp_events_ida="' . $event->id . '" AND fp_events_leads_1leads_idb="' . $lead->id . '"';
         $status = $db->getOne($query);
         if ($status == null || $status == '' || $status == 'Not Invited') {
             $invite_count++;
             //set email links
             $event->link = "<a href='" . $sugar_config['site_url'] . "/index.php?entryPoint=responseEntryPoint&event=" . $event->id . "&delegate=" . $lead->id . "&type=l&response=accept'>Accept</a>";
             $event->link_declined = "<a href='" . $sugar_config['site_url'] . "/index.php?entryPoint=responseEntryPoint&event=" . $event->id . "&delegate=" . $lead->id . "&type=l&response=decline'>Decline</a>";
             //Get the TO name and e-mail address for the message
             $rcpt_name = $lead->first_name . ' ' . $lead->last_name;
             $rcpt_email = $lead->email1;
             $emailTemp = new EmailTemplate();
             $emailTemp->disable_row_level_security = true;
             $emailTemp->retrieve($event->invite_templates);
             //Use the ID value of the email template record
             //parse the lead varibales first
             $firstpass = $emailTemp->parse_template_bean($emailTemp->body_html, 'Contacts', $lead);
             $email_subject = $emailTemp->parse_template_bean($emailTemp->subject, 'FP_events', $event);
             $email_body = from_html($emailTemp->parse_template_bean($firstpass, 'FP_events', $event));
             $alt_emailbody = wordwrap($emailTemp->parse_template_bean($firstpass, 'FP_events', $event), 900);
             //get attachments
             $attachmentBean = new Note();
             $attachment_list = $attachmentBean->get_full_list('', "parent_type = 'Emails' AND parent_id = '" . $event->invite_templates . "'");
             $attachments = array();
             if ($attachment_list != null) {
                 foreach ($attachment_list as $attachment) {
                     $attachments[] = $attachment;
                 }
             }
             //send the email
             $send_invite = $this->sendEmail($rcpt_email, $email_subject, $rcpt_name, $email_body, $alt_emailbody, $lead, $attachments);
             //Send the message, log if error occurs
             if (!$send_invite) {
                 $GLOBALS['log']->fatal('ERROR: Invite email failed to send to: ' . $rcpt_name . ' at ' . $rcpt_email);
                 $error_count++;
             } else {
                 //update contact to invites
                 $query = 'UPDATE fp_events_leads_1_c SET invite_status="Invited" WHERE fp_events_leads_1fp_events_ida="' . $event->id . '" AND fp_events_leads_1leads_idb="' . $lead->id . '"';
                 $res = $db->query($query);
             }
         }
     }
     //Redirect with error message if all linked contacts have already been invited
     if ($invite_count == 0) {
         SugarApplication::appendErrorMessage($mod_strings['LBL_ERROR_MSG_1']);
         SugarApplication::redirect("index.php?module=FP_events&return_module=FP_events&action=DetailView&record=" . $event->id);
     }
     //Redirect if all emails fail to send
     if ($error_count == $delegate_count) {
         $_SESSION['user_error_message'] = array();
         //clear the error message array
         SugarApplication::appendErrorMessage($mod_strings['LBL_ERROR_MSG_2'] . $delegate_count);
         SugarApplication::redirect("index.php?module=FP_events&return_module=FP_events&action=DetailView&record=" . $event->id);
     } else {
         if ($error_count > 0 && $error_count <= 10) {
             //redirect with failed email count.
             $_SESSION['user_error_message'] = array();
             SugarApplication::appendErrorMessage($error_count . $mod_strings['LBL_ERROR_MSG_4']);
             SugarApplication::redirect("index.php?module=FP_events&return_module=FP_events&action=DetailView&record=" . $event->id);
         } else {
             if ($error_count > 10) {
                 $_SESSION['user_error_message'] = array();
                 SugarApplication::appendErrorMessage($mod_strings['LBL_ERROR_MSG_3']);
                 SugarApplication::redirect("index.php?module=FP_events&return_module=FP_events&action=DetailView&record=" . $event->id);
             } else {
                 SugarApplication::appendErrorMessage($mod_strings['LBL_SUCCESS_MSG']);
                 SugarApplication::redirect("index.php?module=FP_events&return_module=FP_events&action=DetailView&record=" . $event->id);
             }
         }
     }
 }
Exemplo n.º 26
0
 /**
  * Generates custom field_defs for selected fields
  */
 function action_historyContactsEmailsSave()
 {
     if (!empty($_POST['modules']) && is_array($_POST['modules'])) {
         require_once 'include/SubPanel/SubPanelDefinitions.php';
         $modules = [];
         foreach ($_POST['modules'] as $moduleName => $enabled) {
             $bean = BeanFactory::getBean($moduleName);
             if (!$bean instanceof SugarBean) {
                 continue;
             }
             if (empty($bean->field_defs)) {
                 continue;
             }
             $subPanel = new SubPanelDefinitions($bean);
             if (empty($subPanel->layout_defs)) {
                 continue;
             }
             if (empty($subPanel->layout_defs['subpanel_setup'])) {
                 continue;
             }
             $isValid = false;
             foreach ($subPanel->layout_defs['subpanel_setup'] as $subPanelDef) {
                 if (empty($subPanelDef['module']) || $subPanelDef['module'] != 'History') {
                     continue;
                 }
                 if (empty($subPanelDef['collection_list'])) {
                     continue;
                 }
                 foreach ($subPanelDef['collection_list'] as $v) {
                     if (!empty($v['get_subpanel_data']) && $v['get_subpanel_data'] == 'function:get_emails_by_assign_or_link') {
                         $isValid = true;
                         break 2;
                     }
                 }
             }
             if (!$isValid) {
                 continue;
             }
             $bean->load_relationships();
             foreach ($bean->get_linked_fields() as $fieldName => $fieldDef) {
                 if ($bean->{$fieldName}->getRelatedModuleName() == 'Contacts') {
                     $modules[$moduleName] = !$enabled;
                     break;
                 }
             }
         }
         $configurator = new Configurator();
         $configurator->config['hide_history_contacts_emails'] = $modules;
         $configurator->handleOverride();
     }
     SugarApplication::redirect('index.php?module=Administration&action=index');
 }
Exemplo n.º 27
0
 /**
  * delete all address cache
  * Google Maps - geocoded_counts
  */
 function action_delete_all_address_cache()
 {
     // Define Address Cache Object
     $this->jjwg_Address_Cache = get_module_info('jjwg_Address_Cache');
     // Admin Only
     if (!empty($GLOBALS['current_user']->is_admin)) {
         if (is_object($this->jjwg_Address_Cache)) {
             // Post-Get-Redirect
             $delete_result = $this->jjwg_Address_Cache->deleteAllAddressCache();
             SugarApplication::redirect('index.php?module=jjwg_Maps&action=geocoded_counts');
         } else {
             $this->view = 'geocoded_counts';
         }
     } else {
         SugarApplication::redirect('index.php?module=jjwg_Maps&action=index');
     }
 }
Exemplo n.º 28
0
 /**
  * Generates custom field_defs for selected fields
  */
 function action_historyContactsEmailsSave()
 {
     if (!empty($_POST['modules']) && is_array($_POST['modules'])) {
         $modules = array();
         foreach ($_POST['modules'] as $moduleName => $enabled) {
             $bean = BeanFactory::getBean($moduleName);
             if (!$bean instanceof SugarBean) {
                 continue;
             }
             if (empty($bean->field_defs)) {
                 continue;
             }
             // these are the specific modules we care about
             if (!in_array($moduleName, array('Opportunities', 'Accounts', 'Cases'))) {
                 continue;
             }
             $bean->load_relationships();
             foreach ($bean->get_linked_fields() as $fieldName => $fieldDef) {
                 if ($bean->{$fieldName}->getRelatedModuleName() == 'Contacts') {
                     $modules[$moduleName] = !$enabled;
                     break;
                 }
             }
         }
         $configurator = new Configurator();
         $configurator->config['hide_history_contacts_emails'] = $modules;
         $configurator->handleOverride();
     }
     SugarApplication::redirect('index.php?module=Administration&action=index');
 }
Exemplo n.º 29
0
 /**
  * Redirect to login page
  * 
  * @param SugarApplication $app
  */
 public function redirectToLogin(SugarApplication $app)
 {
     $loginVars = $app->createLoginVars();
     $app->redirect('index.php?action=Login&module=Users' . $loginVars);
 }
Exemplo n.º 30
0
 /**
  * Displays the header on section of the page; basically everything before the content
  */
 public function displayHeader($retModTabs = false)
 {
     global $theme;
     global $max_tabs;
     global $app_strings;
     global $current_user;
     global $sugar_config;
     global $app_list_strings;
     global $mod_strings;
     global $current_language;
     $GLOBALS['app']->headerDisplayed = true;
     $themeObject = SugarThemeRegistry::current();
     $theme = $themeObject->__toString();
     $ss = new Sugar_Smarty();
     $ss->assign("APP", $app_strings);
     $ss->assign("THEME", $theme);
     $ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true' : 'false');
     $ss->assign("MODULE_NAME", $this->module);
     $ss->assign("langHeader", get_language_header());
     // set ab testing if exists
     $testing = isset($_REQUEST["testing"]) ? $_REQUEST['testing'] : "a";
     $ss->assign("ABTESTING", $testing);
     // get browser title
     $ss->assign("SYSTEM_NAME", $this->getBrowserTitle());
     // get css
     $css = $themeObject->getCSS();
     if ($this->_getOption('view_print')) {
         $css .= '<link rel="stylesheet" type="text/css" href="' . $themeObject->getCSSURL('print.css') . '" media="all" />';
     }
     $ss->assign("SUGAR_CSS", $css);
     // get javascript
     ob_start();
     $this->renderJavascript();
     $ss->assign("SUGAR_JS", ob_get_contents() . $themeObject->getJS());
     ob_end_clean();
     // get favicon
     if (isset($GLOBALS['sugar_config']['default_module_favicon'])) {
         $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
     } else {
         $module_favicon = false;
     }
     $favicon = $this->getFavicon();
     $ss->assign('FAVICON_URL', $favicon['url']);
     // build the shortcut menu
     $shortcut_menu = array();
     foreach ($this->getMenu() as $key => $menu_item) {
         $shortcut_menu[$key] = array("URL" => $menu_item[0], "LABEL" => $menu_item[1], "MODULE_NAME" => $menu_item[2], "IMAGE" => $themeObject->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]));
     }
     $ss->assign("SHORTCUT_MENU", $shortcut_menu);
     // handle rtl text direction
     if (isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL') {
         $_SESSION['RTL'] = true;
     }
     if (isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR') {
         unset($_SESSION['RTL']);
     }
     if (isset($_SESSION['RTL']) && $_SESSION['RTL']) {
         $ss->assign("DIR", 'dir="RTL"');
     }
     // handle resizing of the company logo correctly on the fly
     $companyLogoURL = $themeObject->getImageURL('company_logo.png');
     $companyLogoURL_arr = explode('?', $companyLogoURL);
     $companyLogoURL = $companyLogoURL_arr[0];
     $company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
     if (!empty($company_logo_attributes)) {
         $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
         $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
         $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
     } else {
         // Always need to md5 the file
         $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
         list($width, $height) = getimagesize($companyLogoURL);
         if ($width > 212 || $height > 40) {
             $resizePctWidth = ($width - 212) / 212;
             $resizePctHeight = ($height - 40) / 40;
             if ($resizePctWidth > $resizePctHeight) {
                 $resizeAmount = $width / 212;
             } else {
                 $resizeAmount = $height / 40;
             }
             $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
             $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
         } else {
             $ss->assign("COMPANY_LOGO_WIDTH", $width);
             $ss->assign("COMPANY_LOGO_HEIGHT", $height);
         }
         // Let's cache the results
         sugar_cache_put('company_logo_attributes', array($ss->get_template_vars("COMPANY_LOGO_MD5"), $ss->get_template_vars("COMPANY_LOGO_WIDTH"), $ss->get_template_vars("COMPANY_LOGO_HEIGHT")));
     }
     $ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL) . "&logo_md5=" . $ss->get_template_vars("COMPANY_LOGO_MD5"));
     // get the global links
     $gcls = array();
     $global_control_links = array();
     require "include/globalControlLinks.php";
     foreach ($global_control_links as $key => $value) {
         if ($key == 'users') {
             //represents logout link.
             $ss->assign("LOGOUT_LINK", $value['linkinfo'][key($value['linkinfo'])]);
             $ss->assign("LOGOUT_LABEL", key($value['linkinfo']));
             //key value for first element.
             continue;
         }
         foreach ($value as $linkattribute => $attributevalue) {
             // get the main link info
             if ($linkattribute == 'linkinfo') {
                 $gcls[$key] = array("LABEL" => key($attributevalue), "URL" => current($attributevalue), "SUBMENU" => array());
                 if (substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
                     $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"], 11);
                     $gcls[$key]["URL"] = "javascript:void(0)";
                 }
             }
             // and now the sublinks
             if ($linkattribute == 'submenu' && is_array($attributevalue)) {
                 foreach ($attributevalue as $submenulinkkey => $submenulinkinfo) {
                     $gcls[$key]['SUBMENU'][$submenulinkkey] = array("LABEL" => key($submenulinkinfo), "URL" => current($submenulinkinfo));
                 }
                 if (substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
                     $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 11);
                     $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
                 }
             }
         }
     }
     $ss->assign("GCLS", $gcls);
     $ss->assign("SEARCH", isset($_REQUEST['query_string']) ? $_REQUEST['query_string'] : '');
     if ($this->action == "EditView" || $this->action == "Login") {
         $ss->assign("ONLOAD", 'onload="set_focus()"');
     }
     $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
     // get other things needed for page style popup
     if (isset($_SESSION["authenticated_user_id"])) {
         // get the current user name and id
         $ss->assign("CURRENT_USER", $current_user->full_name == '' || !showFullName() ? $current_user->user_name : $current_user->full_name);
         $ss->assign("CURRENT_USER_ID", $current_user->id);
         // get the last viewed records
         $tracker = new Tracker();
         $history = $tracker->get_recently_viewed($current_user->id);
         $ss->assign("recentRecords", $this->processRecentRecords($history));
     }
     $bakModStrings = $mod_strings;
     if (isset($_SESSION["authenticated_user_id"])) {
         // get the module list
         $moduleTopMenu = array();
         $max_tabs = $current_user->getPreference('max_tabs');
         // Attempt to correct if max tabs count is extremely high.
         if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
             $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
             $current_user->setPreference('max_tabs', $max_tabs, 0, 'global');
         }
         /*$moduleTab = $this->_getModuleTab();
           $ss->assign('MODULE_TAB',$moduleTab);*/
         // See if they are using grouped tabs or not (removed in 6.0, returned in 6.1)
         $user_navigation_paradigm = $current_user->getPreference('navigation_paradigm');
         if (!isset($user_navigation_paradigm)) {
             $user_navigation_paradigm = $GLOBALS['sugar_config']['default_navigation_paradigm'];
         }
         // Get the full module list for later use
         foreach (query_module_access_list($current_user) as $module) {
             // Bug 25948 - Check for the module being in the moduleList
             if (isset($app_list_strings['moduleList'][$module])) {
                 $fullModuleList[$module] = $app_list_strings['moduleList'][$module];
             }
         }
         if (!should_hide_iframes()) {
             $iFrame = new iFrame();
             $frames = $iFrame->lookup_frames('tab');
             foreach ($frames as $key => $values) {
                 $fullModuleList[$key] = $values;
             }
         } elseif (isset($fullModuleList['iFrames'])) {
             unset($fullModuleList['iFrames']);
         }
         if ($user_navigation_paradigm == 'gm' && isset($themeObject->group_tabs) && $themeObject->group_tabs) {
             // We are using grouped tabs
             require_once 'include/GroupedTabs/GroupedTabStructure.php';
             $groupedTabsClass = new GroupedTabStructure();
             $modules = query_module_access_list($current_user);
             //handle with submoremodules
             $max_tabs = $current_user->getPreference('max_tabs');
             // If the max_tabs isn't set incorrectly, set it within the range, to the default max sub tabs size
             if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
                 // We have a default value. Use it
                 if (isset($GLOBALS['sugar_config']['default_max_tabs'])) {
                     $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
                 } else {
                     $max_tabs = 8;
                 }
             }
             $subMoreModules = false;
             $groupTabs = $groupedTabsClass->get_tab_structure(get_val_array($modules));
             // We need to put this here, so the "All" group is valid for the user's preference.
             $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules'] = $fullModuleList;
             // Setup the default group tab.
             $allGroup = $app_strings['LBL_TABGROUP_ALL'];
             $ss->assign('currentGroupTab', $allGroup);
             $currentGroupTab = $allGroup;
             $usersGroup = $current_user->getPreference('theme_current_group');
             // Figure out which tab they currently have selected (stored as a user preference)
             if (!empty($usersGroup) && isset($groupTabs[$usersGroup])) {
                 $currentGroupTab = $usersGroup;
             } else {
                 $current_user->setPreference('theme_current_group', $currentGroupTab);
             }
             $ss->assign('currentGroupTab', $currentGroupTab);
             $usingGroupTabs = true;
         } else {
             // Setup the default group tab.
             $ss->assign('currentGroupTab', $app_strings['LBL_TABGROUP_ALL']);
             $usingGroupTabs = false;
             $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules'] = $fullModuleList;
         }
         $topTabList = array();
         // Now time to go through each of the tab sets and fix them up.
         foreach ($groupTabs as $tabIdx => $tabData) {
             $topTabs = $tabData['modules'];
             if (!is_array($topTabs)) {
                 $topTabs = array();
             }
             $extraTabs = array();
             // Split it in to the tabs that go across the top, and the ones that are on the extra menu.
             if (count($topTabs) > $max_tabs) {
                 $extraTabs = array_splice($topTabs, $max_tabs);
             }
             // Make sure the current module is accessable through one of the top tabs
             if (!isset($topTabs[$moduleTab])) {
                 // Nope, we need to add it.
                 // First, take it out of the extra menu, if it's there
                 if (isset($extraTabs[$moduleTab])) {
                     unset($extraTabs[$moduleTab]);
                 }
                 if (count($topTabs) >= $max_tabs - 1) {
                     // We already have the maximum number of tabs, so we need to shuffle the last one
                     // from the top to the first one of the extras
                     $lastElem = array_splice($topTabs, $max_tabs - 1);
                     $extraTabs = $lastElem + $extraTabs;
                 }
                 if (!empty($moduleTab)) {
                     $topTabs[$moduleTab] = $app_list_strings['moduleList'][$moduleTab];
                 }
             }
             /*
             // This was removed, but I like the idea, so I left the code in here in case we decide to turn it back on
             // If we are using group tabs, add all the "hidden" tabs to the end of the extra menu
             if ( $usingGroupTabs ) {
                 foreach($fullModuleList as $moduleKey => $module ) {
                     if ( !isset($topTabs[$moduleKey]) && !isset($extraTabs[$moduleKey]) ) {
                         $extraTabs[$moduleKey] = $module;
                     }
                 }
             }
             */
             // Get a unique list of the top tabs so we can build the popup menus for them
             foreach ($topTabs as $moduleKey => $module) {
                 $topTabList[$moduleKey] = $module;
             }
             $groupTabs[$tabIdx]['modules'] = $topTabs;
             $groupTabs[$tabIdx]['extra'] = $extraTabs;
         }
     }
     if (isset($topTabList) && is_array($topTabList)) {
         // Adding shortcuts array to menu array for displaying shortcuts associated with each module
         $shortcutTopMenu = array();
         foreach ($topTabList as $module_key => $label) {
             global $mod_strings;
             $mod_strings = return_module_language($current_language, $module_key);
             foreach ($this->getMenu($module_key) as $key => $menu_item) {
                 $shortcutTopMenu[$module_key][$key] = array("URL" => $menu_item[0], "LABEL" => $menu_item[1], "MODULE_NAME" => $menu_item[2], "IMAGE" => $themeObject->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]), "ID" => $menu_item[2] . "_link");
             }
         }
         $ss->assign("groupTabs", $groupTabs);
         $ss->assign("shortcutTopMenu", $shortcutTopMenu);
         $ss->assign('USE_GROUP_TABS', $usingGroupTabs);
         // This is here for backwards compatibility, someday, somewhere, it will be able to be removed
         $ss->assign("moduleTopMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules']);
         $ss->assign("moduleExtraMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['extra']);
     }
     if (isset($extraTabs) && is_array($extraTabs)) {
         // Adding shortcuts array to extra menu array for displaying shortcuts associated with each module
         $shortcutExtraMenu = array();
         foreach ($extraTabs as $module_key => $label) {
             global $mod_strings;
             $mod_strings = return_module_language($current_language, $module_key);
             foreach ($this->getMenu($module_key) as $key => $menu_item) {
                 $shortcutExtraMenu[$module_key][$key] = array("URL" => $menu_item[0], "LABEL" => $menu_item[1], "MODULE_NAME" => $menu_item[2], "IMAGE" => $themeObject->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]), "ID" => $menu_item[2] . "_link");
             }
         }
         $ss->assign("shortcutExtraMenu", $shortcutExtraMenu);
     }
     if (!empty($current_user)) {
         $ss->assign("max_tabs", $current_user->getPreference("max_tabs"));
     }
     $imageURL = SugarThemeRegistry::current()->getImageURL("dashboard.png");
     $homeImage = "<img src='{$imageURL}'>";
     $ss->assign("homeImage", $homeImage);
     global $mod_strings;
     $mod_strings = $bakModStrings;
     $headerTpl = $themeObject->getTemplate('header.tpl');
     if (inDeveloperMode()) {
         $ss->clear_compiled_tpl($headerTpl);
     }
     if ($retModTabs) {
         return $ss->fetch($themeObject->getTemplate('_headerModuleList.tpl'));
     } else {
         $ss->display($headerTpl);
         $this->includeClassicFile('modules/Administration/DisplayWarnings.php');
         $errorMessages = SugarApplication::getErrorMessages();
         if (!empty($errorMessages)) {
             foreach ($errorMessages as $error_message) {
                 echo '<p class="error">' . $error_message . '</p>';
             }
         }
     }
 }