public function batch_insert($email, $fullname, $password) { $email_check = $this->db->get_where('users', 'email', $email); if ($email_check->num_rows() > 0) { log_message('debug', "Attempt to create accounts collided with existing e-mail in DB. Form validation is probably off."); return FALSE; } // Check if email/full name pair is complete if (isset($email) && strlen($email) && isset($fullname) && strlen($fullname)) { $insertdata = array('email' => $email, 'fullname' => $fullname, 'datejoined' => date('Y-m-d'), 'permissions' => 0x0, 'passwordhash' => password_hash($password, PASSWORD_BCRYPT)); if (!$this->db->insert('users', $insertdata)) { log_message('error', "Insert failed on database when creating user: "******"Couldn't send batch creation email, user {$email} is lost forever."); return FALSE; } syslog(LOG_INFO, "Successfully created user {$email}."); return TRUE; } else { syslog(LOG_INFO, "Invalid data in batch creation system."); return FALSE; } }
public function actionEdit($id) { $batch = new Batch(); $batch->load($id); $data = new stdClass(); $data->errors = array(); if (Yii::app()->request->isPostRequest) { $errors = BatchHelper::validateBatch($batch); if (empty($errors)) { $batch->organizationId = Yii::app()->user->getOrgId(); /*this is important to avoid one moderator to edit/delete other org batches*/ $batch->save(); } $data->errors = $errors; } else { $batch->load($id); } $data->batch = $batch; $this->render('edit', $data); }
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); }