function promote($EntityId, $OrgId) { //has user got access to office if (!CheckPermissions('editor')) { return; } $this->load->model('user_auth'); if (!($this->user_auth->officeType == 'High' || $this->user_auth->officeType == 'Admin')) { $this->messages->AddMessage('error', 'Permission denied. You must be an editor to perform this operation.'); redirect('/office/'); } if ($this->members_model->UpdateVipStatus('approved', $EntityId, $OrgId)) { $user = $this->members_model->GetUsername($EntityId); $org = $this->members_model->GetOrganisationFromId($OrgId); $to = $user->entity_username . $this->config->Item('username_email_postfix'); $from = $this->pages_model->GetPropertyText('system_email', true); $subject = $this->pages_model->GetPropertyText('vip_promotion_email_subject', true); $message = str_replace('%%nickname%%', $user->nickname, str_replace('%%organisation%%', $org->organisation_name, $this->pages_model->GetPropertyText('vip_promotion_email_body', true))); $this->load->helper('yorkermail'); try { yorkermail($to, $subject, $message, $from); $this->main_frame->AddMessage('success', 'Member promoted successfully. A notification e-mail has also been sent.'); } catch (Exception $e) { $this->main_frame->AddMessage('error', 'Member promoted successfully, but e-mail sending <b>failed</b>. ' . $e->getMessage()); } } else { $this->messages->AddMessage('error', 'No changes were made to the membership.'); } return redirect('/office/vipmanager'); }
function index() { if (!CheckPermissions('vip')) { return; } //load the required models and libraries $this->load->model('pr_model', 'pr_model'); $this->load->model('members_model', 'members_model'); $this->load->model('directory_model'); //setup the page properties $this->pages_model->SetPageCode('viparea_contactpr'); //set the defaults for the email $signature = $this->directory_model->GetOrganisationEmailSignature(VIPOrganisation()); $subject = ''; $content = "\r\r" . $signature; //get the rep data from the pr model $rep_data = $this->pr_model->GetOrganisationRatings(VipOrganisation()); if (isset($rep_data['rep'])) { $rep = $rep_data['rep']; $rep['email'] = $this->members_model->GetMemberEmail($rep['id']); $rep['has_rep'] = true; } else { $rep['name'] = $this->config->item('pr_officer_name'); $rep['email'] = $this->config->item('pr_officer_email_address'); $rep['has_rep'] = false; } //users data $user_name = $this->members_model->GetMemberName($this->user_auth->entityId); if (isset($_POST['submit_save_advert'])) { if ($_POST['a_subject'] == '') { $this->messages->AddMessage('error', 'You must enter a subject for the email.'); $content = $_POST['a_content']; } else { if ($_POST['a_content'] == '') { $this->messages->AddMessage('error', 'You must enter a message for the email.'); $subject = $_POST['a_subject']; } else { //no errors so send the email $this->load->helper('yorkermail'); $to = $rep['email']; $from = VipOrganisationName() . ' - ' . $user_name . ' <' . $this->members_model->GetMemberEmail($this->user_auth->entityId) . '>'; //try to send the email, report fail if error occurs try { yorkermail($to, $_POST['a_subject'], $_POST['a_content'], $from); $this->messages->AddMessage('success', 'The email has been sent.'); } catch (Exception $e) { $this->main_frame->AddMessage('error', $e->getMessage()); } } } } $data = array('main_text' => $this->pages_model->GetPropertyWikitext('main_text'), 'message_pr_target' => vip_url('contactpr'), 'rep' => $rep, 'subject' => $subject, 'content' => $content); $this->main_frame->SetContentSimple('viparea/contactpr', $data); $this->main_frame->Load(); }
/** * @param $Event CalendarEvent The event to submit. * @param $Id Int The id of the calendar (the keys return by GetAllOpenCalendars()). * @return 0 on success or error code. */ function SubmitEventToCalendar(&$Event, $Id) { // This checks that the org is capable of receiving submissions // and that the event exists, but not that the event is visible or whatever $sql = 'INSERT INTO event_entities' . ' (`event_entity_entity_id`, `event_entity_event_id`, `event_entity_relationship`, `event_entity_confirmed`)' . ' SELECT `organisation_entity_id`, `event_id`, ?, ?' . ' FROM `organisations`, `events`' . ' WHERE `organisation_entity_id` = ?' . ' AND `organisation_events` = True' . ' AND `organisation_event_submission_text` IS NOT NULL' . ' AND `event_id` = ?' . ' LIMIT 1' . ' ON DUPLICATE KEY UPDATE `event_entity_confirmed`=`event_entity_confirmed`'; $bind = array('subscribe', false, $Id, $Event->SourceEventId); $CI =& get_instance(); $query = $CI->db->query($sql, $bind); $affected = $CI->db->affected_rows(); if ($affected > 0) { // Send the email to this person $body_template = $CI->pages_model->GetPropertyText('calendar_notification_event_submission', '_emails', null); $subject_template = $CI->pages_model->GetPropertyText('calendar_notification_event_submission_subject', '_emails', '%%CALNAME%% event submission: "%%EVSUMMARY%%"'); if (null !== $body_template) { // It has worked // We should now email the VIPs to let them know $sql = 'SELECT `user_firstname` AS FIRSTNAME,' . ' `user_surname` AS SURNAME,' . ' `user_nickname` AS NICKNAME,' . ' `user_email` AS EMAIL,' . ' `organisation_name` AS CALNAME,' . ' `organisation_directory_entry_name` AS CALSHORTNAME' . ' FROM `subscriptions`' . ' INNER JOIN `users`' . ' ON `subscription_user_entity_id` = `user_entity_id`' . ' INNER JOIN `organisations`' . ' ON `organisation_entity_id` = `subscription_organisation_entity_id`' . ' WHERE `subscription_vip_status` = "approved"' . ' AND `subscription_deleted` = FALSE' . ' AND `subscription_organisation_entity_id` = ?'; $vips = $CI->db->query($sql, array($Id))->result_array(); if (!empty($vips)) { $CI->load->helper('yorkermail'); foreach ($vips as $vip) { // Find names of organisers $orgs; foreach ($Event->Organisations as $org) { if ($org['confirmed']) { $organisation =& $org['org']; $orgs[] = $organisation->Name; } } $vip['EVSUMMARY'] = $Event->Name; $vip['ORGNAME'] = implode(', ', $orgs); $shortname = $vip['CALSHORTNAME']; $vip['URL'] = "http://www.theyorker.co.uk/viparea/{$shortname}/calendar"; // Put together the email $keys = array_keys($vip); foreach ($keys as &$key) { $key = "%%{$key}%%"; } $to = $vip['FIRSTNAME'] . ' ' . $vip['SURNAME'] . ' <' . $vip['EMAIL'] . '>'; $from = 'The Yorker Calendar'; $body = str_replace($keys, array_values($vip), $body_template); $subject = str_replace($keys, array_values($vip), $subject_template); try { yorkermail($to, $subject, $body, $from); } catch (Exception $e) { } } } } } return $affected; }
function sendmail() { //Still need to add captcha if (!CheckPermissions('public')) { return; } $contact = $this->Contact_Model->GetContact($this->input->post('recipient')); $to = $contact->contact_us_email; $from = $this->input->post('contact_email'); $subject = $this->input->post('contact_subject'); $message = $this->input->post('contact_message'); if (!$subject) { $subject = 'No subject'; } if ($to && $subject && $message && $from) { $this->load->helper('yorkermail'); try { yorkermail($to, $subject, $message, $from); $this->main_frame->AddMessage('success', 'Thank you for contacting us.'); redirect('/about'); } catch (Exception $e) { $this->main_frame->AddMessage('error', 'E-mail sending failed: ' . $e->getMessage()); redirect('/about/contact'); } } elseif (!$to) { $this->main_frame->AddMessage('error', 'E-mail sending failed. Please enter your e-mail address.'); redirect('/about/contact'); } else { $this->main_frame->AddMessage('error', 'E-mail sending failed. Please enter a message to send.'); redirect('/about/contact'); } }
function index() { if (!CheckPermissions('public', FALSE)) { return; } $this->load->model('feedback_model', 'feedback_model'); $redirect_path = $this->input->post('r_redirecturl', ''); $page_title = $this->input->post('a_pagetitle'); $author_name = $this->input->post('a_authorname'); $author_email = $this->input->post('a_authoremail'); $rating = $this->input->post('a_rating'); $feedback_text = $this->input->post('a_feedbacktext'); $article_heading = $this->input->post('a_articleheading'); $antispam = $this->input->post('email'); $include_browser_info = $this->input->post('a_browser_info') == '1'; $this->load->library('user_agent'); $rating_converstion = array('1' => 'What\'s this for?', '2' => 'Good idea - but what does it do?', '3' => 'Useful.. I guess.', '4' => 'Great idea, and easy to use!', '5' => 'Amazing!!'); if (array_key_exists($rating, $rating_converstion)) { $rating = $rating_converstion[$rating]; } else { $rating = 'None'; } if (FALSE !== $feedback_text) { if ($feedback_text != '') { if ($article_heading) { $feedback_text = 'Article: ' . $article_heading . "\n\n" . $feedback_text; } if ($antispam === '' && !preg_match('/viagra|phentermine|o****m|<\\/a>|<a\\s+href/i', $feedback_text)) { $this->feedback_model->AddNewFeedback($page_title, $author_name, $author_email, $rating, $feedback_text, 'http://' . $_SERVER['SERVER_NAME'] . $redirect_path); $to = $this->pages_model->GetPropertyText('feedback_email', true); $from = strpos($author_email, '@') ? $author_email : '*****@*****.**'; $subject = "The Yorker: Site Feedback"; $message = 'Name: ' . $author_name . ' Email: ' . $author_email . ' '; if ($include_browser_info) { $message .= ' Browser: ' . $this->agent->browser() . ' Version: ' . $this->agent->version() . ' Platform: ' . $this->agent->platform() . ' '; } $message .= ' Page Title: ' . $page_title . ' Page URL: http://' . $_SERVER['SERVER_NAME'] . $redirect_path . ' Rating: ' . $rating . ' ' . $feedback_text . ' '; $this->load->helper('yorkermail'); try { yorkermail($to, $subject, $message, $from); $this->messages->AddMessage('success', 'You have successfully left feedback, thanks for your thoughts.'); } catch (Exception $e) { $this->messages->AddMessage('error', 'You have successfully left feedback, thanks for your thoughts. However there was a problem sending this feedback by e-mail, so we might take a while to respond. ' . $e->getMessage()); } } else { $this->messages->AddMessage('error', 'Your feedback looks like spam. Please do not include any HTML code.'); } } else { $this->messages->AddMessage('error', 'Please ensure that you have enterred some feedback text before submitting.'); } } else { $this->messages->AddMessage('error', 'To leave feedback use the feedback form at the bottom of each page.'); } if ($redirect_path === '/') { $redirect_path = ''; } redirect($redirect_path); }
public function resetpassword($username, $email) { $sql = 'SELECT entity_id, entity_username, entity_password, entity_salt, user_nickname, user_email FROM entities INNER JOIN users ON user_entity_id = entity_id WHERE entity_username = ?'; $query = $this->db->query($sql, array($username)); $random = $this->getRandomData(); // See if we have an entity with this username if ($query->num_rows() == 0) { throw new Exception('Specfied user does not exist!'); } else { $row = $query->row(); $entityId = $row->entity_id; $nick = $row->user_nickname; $email = $row->user_email; $new = false; } $sql = 'UPDATE entities SET entity_pwreset = ? WHERE entity_id = ?'; $query = $this->db->query($sql, array($random, $entityId)); if ($this->db->affected_rows() == 0) { throw new Exception('Internal error: failed setting passkey'); } $from = $this->pages_model->GetPropertyText('system_email', true); $subject = $this->pages_model->GetPropertyText('user_password_reset_email_subject', true); $body = $this->pages_model->GetPropertyText('user_password_reset_email_body', true); $body = str_replace('%%link%%', 'http://www.theyorker.co.uk/login/newpass/' . urlencode($username) . '/' . $random, $body); $body = str_replace('%%nickname%%', $nick, $body); $this->load->helper('yorkermail'); try { yorkermail($email, $subject, $body, $from); return true; } catch (Exception $e) { throw new Exception('There was a problem sending the confirmation e-mail.'); } return false; }
/** */ function compose($members = NULL) { if (!CheckPermissions('vip')) { return; } //add any members in the session to the list of recipients if (isset($_SESSION['members_email_to']) && is_array($_SESSION['members_email_to'])) { $members = $_SESSION['members_email_to']; $_SESSION['members_email_to'] = NULL; //clear the send list } else { $members = array(); } //set the defaults for the email $signature = $this->directory_model->GetOrganisationEmailSignature(VIPOrganisation()); $subject = ''; $content = "\r\r" . $signature; if (!empty($_POST)) { $selected_members = array(); //make an array of selected member ids where checked boxes are ticked if (isset($_POST['cb'])) { foreach ($_POST['cb'] as $key => $value) { if ($value = 'on') { $selected_members[] = $key; } } } else { $selected_members = array(); } if (count($selected_members) == 0) { $this->messages->AddMessage('error', 'You must select some members to send the email to.'); $content = $_POST['a_content']; $subject = $_POST['a_subject']; } else { if ($_POST['a_subject'] == '') { $this->messages->AddMessage('error', 'You must enter a subject for the email.'); $members = $selected_members; $content = $_POST['a_content']; } else { if ($_POST['a_content'] == '') { $this->messages->AddMessage('error', 'You must enter a message for the email.'); $members = $selected_members; $subject = $_POST['a_subject']; } else { //no errors so send the email $this->load->helper('yorkermail'); foreach ($selected_members as $member) { $member_emails[] = $this->members_model->GetMemberEmail($member); } $from = $this->members_model->GetMemberEmail($this->user_auth->entityId); $from = VipOrganisationName() . ' <' . $from . '>'; //try to send the email, report fail if error occurs try { yorkermail(array(), $_POST['a_subject'], $_POST['a_content'], $from, array(), $member_emails); $this->messages->AddMessage('success', 'The email has been sent.'); } catch (Exception $e) { $this->main_frame->AddMessage('error', $e->getMessage()); } } } } } //set page code and setup tab nav bar $this->pages_model->SetPageCode('viparea_members_compose'); $this->_SetupTabs('compose'); //view data $data = array('main_text' => $this->pages_model->GetPropertyWikitext('main_text'), 'target' => $this->uri->uri_string(), 'to_members' => $members, 'subject' => $subject, 'content' => $content, 'from' => VipOrganisationName() . ' <' . $this->members_model->GetMemberEmail($this->user_auth->entityId) . '>'); // get member details $member_details = $this->members_model->GetMemberDetails(VipOrganisationId()); $members = array(); //add required member info to the data array foreach ($member_details as $details) { $data['members'][] = array('id' => $details['user_id'], 'name' => $details['firstname'] . ' ' . $details['surname'], 'email' => $details['email']); } //$this->messages->AddDumpMessage('members', $members); //set content view $this->main_frame->SetContentSimple('members/compose', $data); // Load the main frame $this->main_frame->Load(); }