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); }
function action_optimise() { set_time_limit(6000); $index = BeanFactory::getBean("AOD_Index")->getIndex(); $index->optimise(); SugarApplication::redirect('index.php?module=AOD_Index'); }
/** * 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; } }
/** * @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(); }
/** * 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'); } }
public function logout() { session_destroy(); ob_clean(); $this->box->deleteSession(); SugarApplication::redirect($this->box->loginUrl()); }
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); }
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; }
/** * @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']}"); } }
function get_token_access($code = "SUGARCRM", $redirect_uri = "") { global $sugar_config, $current_user; $this->init_curl_session("/oauth/authorize", false); if (isset($sugar_config['tilkee']['client_id']) && !empty($sugar_config['tilkee']['client_id'])) { $get_parameters = array("response_type" => "token", "client_id" => $sugar_config['tilkee']['client_id'], "redirect_uri" => $sugar_config['site_url'] . '/retourToken.php'); $url = $this->app_base_url . "/oauth/authorize?" . http_build_query($get_parameters); SugarApplication::redirect($url); } }
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'); }
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'); } }
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."); } }
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"]); }
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); }
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."); } }
/** * 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)); } } }
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."); } }
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('"', '"', $_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; }
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."); } }
/** * @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); } }
/** * @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); } }
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); } } } }
/** * 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'); }
/** * 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'); } }
/** * 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'); }
/** * Redirect to login page * * @param SugarApplication $app */ public function redirectToLogin(SugarApplication $app) { $loginVars = $app->createLoginVars(); $app->redirect('index.php?action=Login&module=Users' . $loginVars); }
<?php /* * Copyright 2014 TILKEE. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ global $sugar_config, $current_user; // URL Example from TILKEE : // <site_url>/index.php?entryPoint=retourToken#access_token=4abd700617e78253e28f9bfecdfb9b924fefb67cb57e021b973371ca59db8379&token_type=bearer&expires_in=7200 /* * Retrieve and save token in a cookie */ if (isset($_REQUEST['access_token']) && !empty($_REQUEST['access_token'])) { $current_user->tilkee_refresh_token_c = $_REQUEST['refresh_token']; $current_user->tilkee_token_c = $_REQUEST['access_token']; $current_user->tilkee_expires_c = time() + $_REQUEST['expires_in']; $current_user->save(); $GLOBALS['log']->debug('TILKEE - retourToken:' . $_REQUEST['access_token']); SugarApplication::redirect("index.php"); }
/** * Load the authenticated user. If there is not an authenticated user then redirect to login screen. */ function loadUser() { global $authController, $sugar_config; // Double check the server's unique key is in the session. Make sure this is not an attempt to hijack a session $user_unique_key = isset($_SESSION['unique_key']) ? $_SESSION['unique_key'] : ''; $server_unique_key = isset($sugar_config['unique_key']) ? $sugar_config['unique_key'] : ''; $allowed_actions = !empty($this->controller->allowed_actions) ? $this->controller->allowed_actions : ($allowed_actions = array('Authenticate', 'Login', 'LoggedOut')); $authController = new AuthenticationController(); if ($user_unique_key != $server_unique_key && !in_array($this->controller->action, $allowed_actions) && !isset($_SESSION['login_error'])) { session_destroy(); if (!empty($this->controller->action)) { if (strtolower($this->controller->action) == 'delete') { $this->controller->action = 'DetailView'; } elseif (strtolower($this->controller->action) == 'save') { $this->controller->action = 'EditView'; } elseif (strtolower($this->controller->action) == 'quickcreate') { $this->controller->action = 'index'; $this->controller->module = 'home'; } elseif (isset($_REQUEST['massupdate']) || isset($_GET['massupdate']) || isset($_POST['massupdate'])) { $this->controller->action = 'index'; } elseif ($this->isModifyAction()) { $this->controller->action = 'index'; } elseif ($this->controller->action == $this->default_action && $this->controller->module == $this->default_module) { $this->controller->action = ''; $this->controller->module = ''; } } $authController->authController->redirectToLogin($this); } $GLOBALS['current_user'] = new User(); if (isset($_SESSION['authenticated_user_id'])) { // set in modules/Users/Authenticate.php if (!$authController->sessionAuthenticate()) { // if the object we get back is null for some reason, this will break - like user prefs are corrupted $GLOBALS['log']->fatal('User retrieval for ID: (' . $_SESSION['authenticated_user_id'] . ') does not exist in database or retrieval failed catastrophically. Calling session_destroy() and sending user to Login page.'); session_destroy(); SugarApplication::redirect('index.php?action=Login&module=Users'); die; } //fi } elseif (!($this->controller->module == 'Users' && in_array($this->controller->action, $allowed_actions))) { session_destroy(); SugarApplication::redirect('index.php?action=Login&module=Users'); die; } $GLOBALS['log']->debug('Current user is: ' . $GLOBALS['current_user']->user_name); //set cookies if (isset($_SESSION['authenticated_user_id'])) { $GLOBALS['log']->debug("setting cookie ck_login_id_20 to " . $_SESSION['authenticated_user_id']); self::setCookie('ck_login_id_20', $_SESSION['authenticated_user_id'], time() + 86400 * 90); } if (isset($_SESSION['authenticated_user_theme'])) { $GLOBALS['log']->debug("setting cookie ck_login_theme_20 to " . $_SESSION['authenticated_user_theme']); self::setCookie('ck_login_theme_20', $_SESSION['authenticated_user_theme'], time() + 86400 * 90); } if (isset($_SESSION['authenticated_user_theme_color'])) { $GLOBALS['log']->debug("setting cookie ck_login_theme_color_20 to " . $_SESSION['authenticated_user_theme_color']); self::setCookie('ck_login_theme_color_20', $_SESSION['authenticated_user_theme_color'], time() + 86400 * 90); } if (isset($_SESSION['authenticated_user_theme_font'])) { $GLOBALS['log']->debug("setting cookie ck_login_theme_font_20 to " . $_SESSION['authenticated_user_theme_font']); self::setCookie('ck_login_theme_font_20', $_SESSION['authenticated_user_theme_font'], time() + 86400 * 90); } if (isset($_SESSION['authenticated_user_language'])) { $GLOBALS['log']->debug("setting cookie ck_login_language_20 to " . $_SESSION['authenticated_user_language']); self::setCookie('ck_login_language_20', $_SESSION['authenticated_user_language'], time() + 86400 * 90); } //check if user can access }
/** * Perform redirection based on the redirect_url * */ protected function redirect() { if (!empty($this->redirect_url)) { SugarApplication::redirect($this->redirect_url); } }