Beispiel #1
0
 private function _doBatchMail($subject, $title, $body, $committeeOnly = FALSE)
 {
     Permissions::require_authorized(Permissions::MAILER_ADMIN);
     $this->load->library('email');
     $config = array('protocol' => 'sendmail', 'mailtype' => 'html', 'charset' => 'utf-8', 'wordwrap' => TRUE, 'bcc_batch_mode' => TRUE);
     $this->email->initialize($config);
     $this->email->from('*****@*****.**', 'CompSoc Committee');
     $result = NULL;
     if ($committeeOnly) {
         $result = $this->db->query("SELECT email FROM users WHERE committee=1;");
     } else {
         $result = $this->db->query("SELECT email FROM users;");
     }
     $result = $result->result();
     $recipients = array();
     foreach ($result as $email) {
         array_push($recipients, $email->email);
     }
     log_message('debug', 'Batch mail being sent to ' . sizeof($recipients) . ' people' . ($committeeOnly ? ' (committee only)' : '') . '.');
     $this->email->bcc($recipients);
     $this->email->subject($subject);
     $this->email->message(BatchHelper::make_batch_mail_message($subject, $title, $body));
     if (!$this->email->send()) {
         log_message('error', "Couldn't send batch mail.");
     }
     return sizeof($recipients);
 }
Beispiel #2
0
 public function batch_register_process()
 {
     Permissions::require_authorized(Permissions::BATCH_USER_CREATE);
     $rules = array(array('field' => 'reg_emailone', 'label' => 'e-mail 1', 'rules' => 'valid_email|trim|is_unique[users.email]'), array('field' => 'reg_fullnameone', 'label' => 'full name 1', 'rules' => 'trim'), array('field' => 'reg_emailtwo', 'label' => 'e-mail 2', 'rules' => 'valid_email|trim|is_unique[users.email]'), array('field' => 'reg_fullnametwo', 'label' => 'full name 2', 'rules' => 'trim'), array('field' => 'reg_emailthree', 'label' => 'e-mail 3', 'rules' => 'valid_email|trim|is_unique[users.email]'), array('field' => 'reg_fullnamethree', 'label' => 'full name 3', 'rules' => 'trim'), array('field' => 'reg_emailfour', 'label' => 'e-mail 4', 'rules' => 'valid_email|trim|is_unique[users.email]'), array('field' => 'reg_fullnamefour', 'label' => 'full name 4', 'rules' => 'trim'), array('field' => 'reg_emailfive', 'label' => 'e-mail 5', 'rules' => 'valid_email|trim|is_unique[users.email]'), array('field' => 'reg_fullnamefive', 'label' => 'full name 5', 'rules' => 'trim'));
     $this->form_validation->set_rules($rules);
     $userdata = $this->user_model->get_logged_in();
     $arr = (array) $userdata;
     $arr["notification_message"] = "";
     if ($this->form_validation->run() === TRUE) {
         // verify
         $passwordlength = 12;
         $batchuserdata = array('emailone' => $this->input->post('reg_emailone', TRUE), 'fullnameone' => $this->input->post('reg_fullnameone', TRUE), 'passwordone' => substr(preg_replace("/[^A-Za-z0-9 ]/", '', hash('md5', time())), 0, $passwordlength), 'emailtwo' => $this->input->post('reg_emailtwo', TRUE), 'fullnametwo' => $this->input->post('reg_fullnametwo', TRUE), 'passwordtwo' => substr(preg_replace("/[^A-Za-z0-9 ]/", '', hash('md5', time() - 1)), 0, $passwordlength), 'emailthree' => $this->input->post('reg_emailthree', TRUE), 'fullnamethree' => $this->input->post('reg_fullnamethree', TRUE), 'passwordthree' => substr(preg_replace("/[^A-Za-z0-9 ]/", '', hash('md5', time() - 2)), 0, $passwordlength), 'emailfour' => $this->input->post('reg_emailfour', TRUE), 'fullnamefour' => $this->input->post('reg_fullnamefour', TRUE), 'passwordfour' => substr(preg_replace("/[^A-Za-z0-9 ]/", '', hash('md5', time() - 3)), 0, $passwordlength), 'emailfive' => $this->input->post('reg_emailfive', TRUE), 'fullnamefive' => $this->input->post('reg_fullnamefive', TRUE), 'passwordfive' => substr(preg_replace("/[^A-Za-z0-9 ]/", '', hash('md5', time() - 4)), 0, $passwordlength));
         $result = $this->user_model->batch_insert($batchuserdata['emailone'], $batchuserdata['fullnameone'], $batchuserdata['passwordone']);
         if ($result === TRUE) {
             $arr["notification_message"] .= "Created user {$batchuserdata['emailone']}.</br>";
         } else {
             if ($result === FALSE) {
                 $arr["notification_message"] .= "Could not create {$batchuserdata['emailone']}.</br>";
             }
         }
         $result = $this->user_model->batch_insert($batchuserdata['emailtwo'], $batchuserdata['fullnametwo'], $batchuserdata['passwordtwo']);
         if ($result === TRUE) {
             $arr["notification_message"] .= "Created user {$batchuserdata['emailtwo']}.</br>";
         } else {
             if ($result === FALSE) {
                 $arr["notification_message"] .= "Could not create {$batchuserdata['emailtwo']}.</br>";
             }
         }
         $result = $this->user_model->batch_insert($batchuserdata['emailthree'], $batchuserdata['fullnamethree'], $batchuserdata['passwordthree']);
         if ($result === TRUE) {
             $arr["notification_message"] .= "Created user {$batchuserdata['emailthree']}.</br>";
         } else {
             if ($result === FALSE) {
                 $arr["notification_message"] .= "Could not create {$batchuserdata['emailthree']}.</br>";
             }
         }
         $result = $this->user_model->batch_insert($batchuserdata['emailfour'], $batchuserdata['fullnamefour'], $batchuserdata['passwordfour']);
         if ($result === TRUE) {
             $arr["notification_message"] .= "Created user {$batchuserdata['emailfour']}.</br>";
         } else {
             if ($result === FALSE) {
                 $arr["notification_message"] .= "Could not create {$batchuserdata['emailfour']}.</br>";
             }
         }
         $result = $this->user_model->batch_insert($batchuserdata['emailfive'], $batchuserdata['fullnamefive'], $batchuserdata['passwordfive']);
         if ($result === TRUE) {
             $arr["notification_message"] .= "Created user {$batchuserdata['emailfive']}.</br>";
         } else {
             if ($result === FALSE) {
                 $arr["notification_message"] .= "Could not create {$batchuserdata['emailfive']}.</br>";
             }
         }
         $_POST = array();
     }
     $this->load->view('batch/create', $arr);
 }
Beispiel #3
0
 /**
  * Method that controls the entire points adding process
  */
 public function add()
 {
     Permissions::require_authorized(Permissions::POINTS_ADMIN);
     $rules = array(array('field' => 'email', 'label' => 'Email', 'rules' => 'required'), array('field' => 'amount', 'label' => 'Amount', 'rules' => 'required'), array('field' => 'pointtype', 'label' => 'Point Type', 'rules' => 'required'), array('field' => 'comment', 'label' => 'Comment', 'rules' => 'trim'));
     $this->form_validation->set_rules($rules);
     /*
      * If there is POST data (form has been submitted) then use that data instead blank data
      */
     $data = array();
     $data['email'] = $this->input->post('email') != FALSE ? $this->input->post('email', TRUE) : '';
     $data['amount'] = $this->input->post('amount') != FALSE ? $this->input->post('amount', TRUE) : '';
     $data['pointtype'] = $this->input->post('pointtype') != FALSE ? $this->input->post('pointtype', TRUE) : '1';
     $data['comment'] = $this->input->post('comment') != FALSE ? $this->input->post('comment', TRUE) : '';
     $data['pointtypes'] = $this->db->get('point_types')->result();
     /*
      * Check if the page is being visited for the first time
      */
     if ($this->form_validation->run() === FALSE) {
         // Load empty page
         $this->load->view('point/add', $data);
     } else {
         // Get the userid associated with the user getting the points
         $query = $this->db->get_where('users', array('email' => $this->input->post('email', TRUE)));
         $user = $query->row();
         $this->db->flush_cache();
         // Gets the userid of the user giving the points
         $query = $this->db->get_where('users', array('email' => get_instance()->session->userdata('email')));
         $assigner = $query->row();
         // Add the data to the array
         $data['userid'] = $user->userid;
         $data['assignerid'] = $assigner->userid;
         $data['timecreated'] = date('Y-m-d H:i:s');
         // Check that the user is not giving themselves points
         if ($user->userid != $assigner->userid) {
             // Attempt to insert the record into the database
             if ($this->transaction_model->insert($data) == TRUE) {
                 // Log the points being added in the database
                 $this->_logAdd($data);
                 // Clear the form data
                 $data['message'] = 'Assigned ' . $data['amount'] . ' points to ' . $user->fullname;
                 $data['email'] = '';
                 $data['amount'] = '';
                 $data['pointtype'] = '1';
                 $data['comment'] = '';
                 $data['clear'] = true;
             } else {
                 // Adding the record failed
                 $data['errormessage'] = 'Failure to assign points' . $this->db->_error_message();
             }
         } else {
             $this->_logSelfAdd($data);
             $data['errormessage'] = 'You cannot assign points to yourself ' . $assigner->fullname;
         }
         $this->load->view('point/add', $data);
     }
 }
Beispiel #4
0
 public function edit($userid = -1)
 {
     Permissions::require_authorized(Permissions::USER_ADMIN);
     $userid = $this->security->xss_clean($userid);
     // TODO add check for integer
     if ($userid == -1 && $this->input->server('REQUEST_METHOD') != 'POST') {
         $this->listview();
         return;
     }
     $rules = array(array('field' => 'userid', 'label' => 'userid', 'rules' => 'required'), array('field' => 'email', 'label' => 'Email', 'rules' => 'required'), array('field' => 'fullname', 'label' => 'Full Name', 'rules' => 'required'), array('field' => 'githubID', 'label' => 'Github ID', 'rules' => 'trim'), array('field' => '$linkedinURL', 'label' => 'Linkedin URL', 'rules' => 'trim'), array('field' => 'steamID', 'label' => 'Steam ID', 'rules' => 'trim'), array('field' => 'twitterID', 'label' => 'Twitter Handle', 'rules' => 'trim'));
     $this->form_validation->set_rules($rules);
     if ($this->form_validation->run() === FALSE) {
         $query = $this->db->get_where('users', array('userid' => $userid));
         $user = $query->row();
         $userdata = array('userid' => $user->userid, 'email' => $user->email, 'fullname' => $user->fullname, 'githubID' => $user->githubID, 'linkedinURL' => $user->linkedinURL, 'steamID' => $user->steamID, 'twitterID' => $user->twitterID, 'permissions' => $this->_permissions_to_array($user->permissions));
         $this->load->view('user/edit', $userdata);
     } else {
         $permissionValue = 0;
         $this->input->post('p_confirmed', TRUE) == 1 ? $permissionValue += Permissions::USER_CONFIRMED : NULL;
         $this->input->post('p_user', TRUE) == 1 ? $permissionValue += Permissions::USER_ADMIN : NULL;
         $this->input->post('p_points', TRUE) == 1 ? $permissionValue += Permissions::POINTS_ADMIN : NULL;
         $this->input->post('p_portfolio', TRUE) == 1 ? $permissionValue += Permissions::PORTFOLIO_ADMIN : NULL;
         $this->input->post('p_batch', TRUE) == 1 ? $permissionValue += Permissions::BATCH_USER_CREATE : NULL;
         $this->input->post('p_clothing', TRUE) == 1 ? $permissionValue += Permissions::CLOTHING_ADMIN : NULL;
         $this->input->post('p_mailer', TRUE) == 1 ? $permissionValue += Permissions::MAILER_ADMIN : NULL;
         $userdata = array('userid' => $this->input->post('userid', TRUE), 'email' => $this->input->post('email', TRUE), 'fullname' => $this->input->post('fullname', TRUE), 'githubID' => $this->input->post('githubID', TRUE), 'linkedinURL' => $this->input->post('$linkedinURL', TRUE), 'steamID' => $this->input->post('steamID', TRUE), 'twitterID' => $this->input->post('twitterID', TRUE), 'permissions' => $permissionValue);
         $updated = $this->user_model->update($userdata);
         $userdata['permissions'] = $this->_permissions_to_array($permissionValue);
         if ($updated !== FALSE) {
             $userdata['message'] = "Update Successful";
             $this->load->view('user/edit', $userdata);
         } else {
             $userdata['errormessage'] = "Update Failed: " . $this->db->_error_message();
             $this->load->view('user/edit', $userdata);
         }
     }
 }
Beispiel #5
0
<?php

defined('BASEPATH') or exit('No direct script access allowed');
Permissions::require_authorized(Permissions::CLOTHING_ADMIN);
?>
<!DOCTYPE html>
<html lang="en">

<head>
<?php 
/*
 * This should be the first "require" because it contains the charset,
 * which should come directly after the <head> tag.
 */
$this->load->view('include/head_common.php');
?>

<title>CompSoc :: Clothing</title>
</head>

<body>
	<?php 
$this->load->view('include/navbar.php');
?>

	<!-- Page Content -->
	<div class="container">
		<?php 
$this->load->view('include/sitewide_banner.php');
?>
Beispiel #6
0
<?php

defined('BASEPATH') or exit('No direct script access allowed');
Permissions::require_authorized(Permissions::MAILER_ADMIN);
?>
<!DOCTYPE html>
<html lang="en">

<head>
<?php 
$this->load->view('include/head_common.php');
?>

<title>CompSoc :: Batch Mailer</title>
</head>

<body>
	<?php 
$this->load->view('include/navbar.php');
?>

	<!-- Page Content -->
	<div class="container">
		<?php 
$this->load->view('include/sitewide_banner.php');
?>
		<?php 
$this->load->view('include/notification_message.php');
?>

		<div class="row">
Beispiel #7
0
 public function listview($campaign_id = -1, $data = array())
 {
     Permissions::require_authorized(Permissions::CLOTHING_ADMIN);
     if ($campaign_id == -1 || $this->_getCampaign($campaign_id)->first_row() == NULL) {
         $data['active'] = $this->_getActiveCampaigns()->result();
         $data['expired'] = $this->_getExpiredCampaigns()->result();
         $this->load->view('clothing/listview', $data);
         return;
     }
     $data['campaign'] = $this->_getCampaign($campaign_id)->first_row();
     $data['aggregate'] = $this->_getAggregatedList($campaign_id)->result();
     $data['orders'] = $this->_getList($campaign_id)->result();
     $this->load->view('clothing/listdetails', $data);
 }
Beispiel #8
0
<?php

defined('BASEPATH') or exit('No direct script access allowed');
Permissions::require_authorized(Permissions::POINTS_ADMIN);
?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">

<head>

    <?php 
$this->load->view('include/head_common.php');
?>

    <title>CompSoc :: Add Points</title>

</head>

<body>
<?php 
$this->load->view('include/navbar.php');
?>

<!-- Page Content -->
	<div class="container">

    <?php 
$this->load->view('include/notification_message.php');
?>

    <?php 
Beispiel #9
0
<?php

defined('BASEPATH') or exit('No direct script access allowed');
Permissions::require_authorized(Permissions::BATCH_USER_CREATE);
?>
<!DOCTYPE html>
<html lang="en">

<head>
	<?php 
$this->load->view('include/head_common.php');
?>

	<title>CompSoc :: Batch User Creation</title>
</head>

<body>
<?php 
$this->load->view('include/navbar.php');
?>

<!-- Page Content -->
	<div class="container"> 
	<?php 
$this->load->view('include/notification_message.php');
$validation_errors = validation_errors();
if ($validation_errors !== '') {
    ?>
	<div class="row alert alert-danger">
		<?php 
    echo $validation_errors;