本文整理汇总了PHP中valid::email方法的典型用法代码示例。如果您正苦于以下问题:PHP valid::email方法的具体用法?PHP valid::email怎么用?PHP valid::email使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类valid
的用法示例。
在下文中一共展示了valid::email方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unique_key
/**
* Allows a model to be loaded by username or email address.
*/
public function unique_key($id)
{
if (!empty($id) and is_string($id) and !ctype_digit($id)) {
return valid::email($id) ? 'email' : 'username';
}
return parent::unique_key($id);
}
示例2: save
public function save()
{
if (!$_POST) {
die;
}
$this->rsp = Response::instance();
if (!valid::email($_POST['email'])) {
$this->rsp->msg = 'Invalid Email!';
$this->rsp->send();
} elseif ($this->owner->unique_key_exists($_POST['email'])) {
$this->rsp->msg = 'Email already exists!';
$this->rsp->send();
}
$pw = text::random('alnum', 8);
$this->owner->email = $_POST['email'];
$this->owner->password = $pw;
$this->owner->save();
$replyto = 'unknown';
$body = "Hi there, thanks for saving your progess over at http://pluspanda.com \r\n" . "Your auto-generated password is: {$pw} \r\n" . "Change your password to something more appropriate by going here:\r\n" . "http://pluspanda.com/admin/account?old={$pw} \r\n\n" . "Thank you! - Jade from pluspanda";
# to do FIX THE HEADERS.
$subject = 'Your Pluspanda account information =)';
$headers = "From: welcome@pluspanda.com \r\n" . "Reply-To: Jade \r\n" . 'X-Mailer: PHP/' . phpversion();
mail($_POST['email'], $subject, $body, $headers);
# add to mailing list.
include Kohana::find_file('vendor/mailchimp', 'MCAPI');
$config = Kohana::config('mailchimp');
$mailchimp = new MCAPI($config['apikey']);
$mailchimp->listSubscribe($config['list_id'], $_POST['email'], '', 'text', FALSE, TRUE, TRUE, FALSE);
$this->rsp->status = 'success';
$this->rsp->msg = 'Thanks, Account Saved!';
$this->rsp->send();
}
示例3: __construct
public function __construct($username = '', $password = '', $email = '')
{
// load database library into $this->db
parent::__construct();
if ($username != '' and $password != '' and $email != '') {
if (strlen($username) < 3) {
throw new Exception('Username too short');
} elseif (strlen($username) > 12) {
throw new Exception('Username too long');
} elseif (strlen($password) < 6) {
throw new Exception('Password too short');
} elseif (strlen($username) > 255) {
throw new Exception('Password too long');
} elseif (valid::email($email) == False) {
throw new Exception('Invalid email supplied');
} elseif ($this->user_exists($username, $email)) {
throw new Exception('User already exists (login or email matched)');
}
if ($this->register($username, $password, $email)->valid()) {
return true;
} else {
return false;
}
}
}
示例4: validate_email_form
private function validate_email_form()
{
$messages = array();
if (valid::email($this->input->post('email')) == false) {
$messages[] = 'The supplied email address does not appear valid';
}
if ($this->input->post('body') == '') {
$messages[] = 'The body of your message should not be empty';
}
return $messages;
}
示例5: user
/**
* Displays a profile page for a user
*/
public function user()
{
// Cacheable Controller
$this->is_cachable = TRUE;
$this->template->header->this_page = 'profile';
// Check if we are looking for a user. Argument must be set to continue.
if (!isset(Router::$arguments[0])) {
url::redirect('profile');
}
$username = Router::$arguments[0];
// We won't allow profiles to be public if the username is an email address
if (valid::email($username)) {
url::redirect('profile');
}
$user = User_Model::get_user_by_username($username);
// We only want to show public profiles here
if ($user->public_profile == 1) {
$this->template->content = new View('profile/user');
$this->template->content->user = $user;
// User Reputation Score
$this->template->content->reputation = reputation::calculate($user->id);
// All users reports
$this->template->content->reports = ORM::factory('incident')->where(array('user_id' => $user->id, 'incident_active' => 1))->with('incident:location')->find_all();
// Get Badges
$this->template->content->badges = Badge_Model::users_badges($user->id);
// Logged in user id (false if not logged in)
$logged_in_id = FALSE;
if (isset(Auth::instance()->get_user()->id)) {
$logged_in_id = Auth::instance()->get_user()->id;
}
$this->template->content->logged_in_id = $logged_in_id;
// Is this the logged in user?
$logged_in_user = FALSE;
if ($logged_in_id == $user->id) {
$logged_in_user = TRUE;
}
$this->template->content->logged_in_user = $logged_in_user;
} else {
// this is a private profile so get out of here
url::redirect('profile');
}
$this->template->header->page_title .= $user->name . Kohana::config('settings.title_delimiter');
$this->template->header->header_block = $this->themes->header_block();
$this->template->footer->footer_block = $this->themes->footer_block();
}
示例6: validate
public function validate($array)
{
$default = array("title" => "", "display_name" => "", "email" => "");
$array = arr::overwrite($default, $array);
$errors = array();
if ($array['display_name'] == "") {
$errors['display_name'] = "Please enter a display name";
}
if (!valid::email($array['email'])) {
$errors['email'] = "Please enter a valid email";
}
if ($array['title'] == "") {
$errors['title'] = "Please enter text for your comment";
}
$array['title'] = strip_tags($array['title']);
$array['errors'] = $errors;
return $array;
}
示例7: save
public function save(array $person = array(), $person_id = null)
{
$result = array('success' => false, 'error' => '');
$valid = true;
$person = $this->get_trimmed_allowed($person, array('space_id', 'email', 'x', 'y', 'active'));
if (isset($person['space_id']) && !valid::digit($person['space_id'])) {
$valid = false;
}
if (isset($person['email']) && !valid::email($person['email'])) {
$valid = false;
}
if (isset($person['x']) && !valid::numeric($person['x'])) {
$valid = false;
}
if (isset($person['y']) && !valid::numeric($person['y'])) {
$valid = false;
}
if (isset($person['active']) && !valid::digit($person['active'])) {
$valid = false;
}
if ($valid) {
if ($person_id) {
//UPDATE
$this->db->from('people')->set($person)->where(array('id' => (int) $person_id))->update();
$result['success'] = true;
} else {
// INSERT
$new_person = $this->db->from('people')->set($person)->insert();
$result['success'] = true;
$person_id = $new_person->insert_id();
}
$person = $this->db->select('people.*')->from('people')->where(array('id' => $person_id))->get();
$person = $this->result_as_array($person);
$result['person'] = $person;
} else {
$result['error'] = "The supplied data was invalid";
}
return $result;
}
示例8: password_recovery
public function password_recovery()
{
$id = 0;
$passto = false;
$errors = array();
$msg = "";
if ($this->ispost()) {
$input = Input::Instance();
$mail = $input->post('mail');
if ($mail == '') {
$errors[] = __("El Email no puede estar vacio", false);
} else {
if (valid::email($mail) == false) {
$errors[] = __("El Email no es valido", false);
} else {
$orm = $this->table->db2cls();
$result = $orm->load($mail, 'mail_client');
$id = (int) $result->id_client;
if ($id == 0) {
$errors[] = __("El Email no existe", false);
} else {
$passto = true;
$passwordgenorig = basics::passwordgenerator();
$passwordgen = fpp::cryptme($passwordgenorig);
$result->password_client = $passwordgen;
$href = html::anchor($this->href_store);
basics::mail_html_utf8($mail, __('Recuperación de clave de acceso', false), __("Estimado Cliente, <br/>Su nueva contraseña es", false) . " {$passwordgenorig} <br/>{$href}", $this->mail_store, "Floreria Rosabel");
$passto = true;
$result->save();
}
}
}
$msg = $passto == false ? basics::diverror($errors) : basics::diverror(array(__("E-mail enviado, revise su buzón", false)));
}
$this->content = View::factory("main/recovery_password")->set("msg", $msg)->render();
}
示例9: import_user
/**
* Import a single user.
*/
static function import_user(&$queue)
{
$messages = array();
$g2_user_id = array_shift($queue);
if (self::map($g2_user_id)) {
return t("User with id: %id already imported, skipping", array("id" => $g2_user_id));
}
if (g2(GalleryCoreApi::isAnonymousUser($g2_user_id))) {
self::set_map($g2_user_id, identity::guest()->id, "group");
return t("Skipping anonymous user");
}
$g2_admin_group_id = g2(GalleryCoreApi::getPluginParameter("module", "core", "id.adminGroup"));
try {
$g2_user = g2(GalleryCoreApi::loadEntitiesById($g2_user_id));
} catch (Exception $e) {
throw new G2_Import_Exception(t("Failed to import Gallery 2 user with id: %id\n%exception", array("id" => $g2_user_id, "exception" => (string) $e)), $e);
}
$g2_groups = g2(GalleryCoreApi::fetchGroupsForUser($g2_user->getId()));
$user = identity::lookup_user_by_name($g2_user->getUsername());
if ($user) {
$messages[] = t("Loaded existing user: '%name'.", array("name" => $user->name));
} else {
$email = $g2_user->getEmail();
if (empty($email) || !valid::email($email)) {
$email = "unknown@unknown.com";
}
try {
$user = identity::create_user($g2_user->getUserName(), $g2_user->getFullName(), $g2_user->getHashedPassword(), $email);
} catch (Exception $e) {
throw new G2_Import_Exception(t("Failed to create user: '%name' (id: %id)", array("name" => $g2_user->getUserName(), "id" => $g2_user_id)), $e, $messages);
}
if (class_exists("User_Model") && $user instanceof User_Model) {
// This will work if G2's password is a PasswordHash password as well.
$user->hashed_password = $g2_user->getHashedPassword();
}
$messages[] = t("Created user: '%name'.", array("name" => $user->name));
if ($email == "unknown@unknown.com") {
$messages[] = t("Fixed invalid email (was '%invalid_email')", array("invalid_email" => $g2_user->getEmail()));
}
}
$user->locale = $g2_user->getLanguage();
foreach ($g2_groups as $g2_group_id => $g2_group_name) {
if ($g2_group_id == $g2_admin_group_id) {
$user->admin = true;
$messages[] = t("Added 'admin' flag to user");
} else {
$group = identity::lookup_group(self::map($g2_group_id));
$user->add($group);
$messages[] = t("Added user to group '%group'.", array("group" => $group->name));
}
}
try {
$user->save();
self::set_map($g2_user->getId(), $user->id, "user");
} catch (Exception $e) {
throw new G2_Import_Exception(t("Failed to create user: '%name'", array("name" => $user->name)), $e, $messages);
}
return $messages;
}
示例10: action_affiliate
public function action_affiliate()
{
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Affiliate')));
$this->template->title = __('Affiliate Panel');
$user = Auth::instance()->get_user();
//Hack so the admin can see the stats for any user! cool!
if ($user->id_role == Model_Role::ROLE_ADMIN) {
$id_user = $this->request->param('id');
if (is_numeric($id_user)) {
$user = new Model_User($id_user);
}
}
$this->template->styles = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/css/datepicker.css' => 'screen');
$this->template->scripts['footer'] = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/js/bootstrap-datepicker.js', 'js/oc-panel/stats/dashboard.js');
$this->template->bind('content', $content);
$this->template->content = View::factory('oc-panel/profile/affiliate');
$content->user = $user;
// list of all products to build affiliate links
$products = new Model_Product();
$products = $products->where('status', '=', Model_Product::STATUS_ACTIVE)->find_all();
$content->products = $products;
//change paypal account->profile, put a warning if he didnt set it yet with a link
if (!valid::email($user->paypal_email)) {
Alert::set(Alert::INFO, __('Please set your paypal email at your profile'));
}
//list all his payments->orders paid
$payments = new Model_Order();
$content->payments = $payments->where('id_user', '=', $user->id_user)->where('id_product', 'is', NULL)->where('status', '=', Model_Order::STATUS_PAID)->order_by('pay_date', 'DESC')->find_all();
//see stats
////////////////////
//total earned commissions
$query = DB::select(DB::expr('SUM(amount) total'))->from('affiliates')->where('id_user', '=', $user->id_user)->group_by('id_user')->execute();
$total_earnings = $query->as_array();
$content->total_earnings = isset($total_earnings[0]['total']) ? $total_earnings[0]['total'] : 0;
//total since last payment
$last_payment_date = DB::select('pay_date')->from('orders')->where('id_user', '=', $user->id_user)->where('id_product', 'is', NULL)->where('status', '=', Model_Order::STATUS_PAID)->order_by('pay_date', 'ASC')->limit(1)->execute();
$last_payment_date = $last_payment_date->as_array();
$content->last_payment_date = isset($last_payment_date[0]['pay_date']) ? $last_payment_date[0]['pay_date'] : NULL;
$content->last_earnings = 0;
if ($content->last_payment_date != NULL) {
//commissions since last payment
$query = DB::select(DB::expr('SUM(amount) total'))->from('affiliates')->where('id_user', '=', $user->id_user)->where('created', 'between', array($content->last_payment_date, Date::unix2mysql()))->where('status', '=', Model_Affiliate::STATUS_CREATED)->group_by('id_user')->execute();
$last_earnings = $query->as_array();
$content->last_earnings = isset($last_earnings[0]['total']) ? $last_earnings[0]['total'] : 0;
}
//due to pay, is commisions with to pay date bigger than today
//commissions due to pay
$query = DB::select(DB::expr('SUM(amount) total'))->from('affiliates')->where('id_user', '=', $user->id_user)->where('date_to_pay', '<', Date::unix2mysql())->where('status', '=', Model_Affiliate::STATUS_CREATED)->group_by('id_user')->execute();
$due_to_pay = $query->as_array();
$content->due_to_pay = isset($due_to_pay[0]['total']) ? $due_to_pay[0]['total'] : 0;
//Getting the dates and range
$from_date = Core::post('from_date', strtotime('-1 month'));
$to_date = Core::post('to_date', time());
//we assure is a proper time stamp if not we transform it
if (is_string($from_date) === TRUE) {
$from_date = strtotime($from_date);
}
if (is_string($to_date) === TRUE) {
$to_date = strtotime($to_date);
}
//mysql formated dates
$my_from_date = Date::unix2mysql($from_date);
$my_to_date = Date::unix2mysql($to_date);
//dates range we are filtering
$dates = Date::range($from_date, $to_date, '+1 day', 'Y-m-d', array('date' => 0, 'count' => 0), 'date');
//dates displayed in the form
$content->from_date = date('Y-m-d', $from_date);
$content->to_date = date('Y-m-d', $to_date);
//visits created last XX days
$query = DB::select(DB::expr('DATE(created) date'))->select(DB::expr('COUNT(id_visit) count'))->from('visits')->where('id_affiliate', '=', $user->id_user)->where('created', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( created )'))->order_by('date', 'asc')->execute();
$visits = $query->as_array('date');
//commissions created last XX days
$query = DB::select(DB::expr('DATE(created) date'))->select(DB::expr('SUM(amount) total'))->from('affiliates')->where('id_user', '=', $user->id_user)->where('created', 'between', array($my_from_date, $my_to_date))->group_by(DB::expr('DATE( created )'))->order_by('date', 'asc')->execute();
$earnings = $query->as_array('date');
$stats_daily = array();
foreach ($dates as $date) {
$count_views = isset($visits[$date['date']]['count']) ? $visits[$date['date']]['count'] : 0;
$earned = isset($earnings[$date['date']]['total']) ? $earnings[$date['date']]['total'] : 0;
$stats_daily[] = array('date' => $date['date'], 'views' => $count_views, '$' => $earned);
}
$content->stats_daily = $stats_daily;
////////////////////////////////////////////////
//list paginated with commissions
/////////////////////////////////
$commissions = new Model_Affiliate();
$commissions = $commissions->where('id_user', '=', $user->id_user);
$pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $commissions->count_all(), 'items_per_page' => 100))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action(), 'id' => $this->request->param('id')));
$pagination->title($this->template->title);
$commissions = $commissions->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
$pagination = $pagination->render();
$content->pagination = $pagination;
$content->commissions = $commissions;
//////////////////////////////////
}
示例11: validate_custom_form_fields
/**
* Validate Custom Form Fields
* @param Validation $post Validation object from form post
* XXX This whole function is being done backwards
* Need to pull the list of custom form fields first
* Then look through them to see if they're set, not the other way around.
*/
public static function validate_custom_form_fields(&$post)
{
$custom_fields = array();
if (!isset($post->custom_field)) {
return;
}
/* XXX Checkboxes hackery
Checkboxes are submitted in the post as custom_field[field_id-boxnum]
This foreach loop consolidates them into one variable separated by commas.
If no checkboxes are selected then the custom_field[] for that variable is not sent
To get around that the view sets a hidden custom_field[field_id-BLANKHACK] field that
ensures the checkbox custom_field is there to be tested.
*/
foreach ($post->custom_field as $field_id => $field_response) {
$split = explode("-", $field_id);
if (isset($split[1])) {
// The view sets a hidden field for blankhack
if ($split[1] == 'BLANKHACK') {
if (!isset($custom_fields[$split[0]])) {
// then no checkboxes were checked
$custom_fields[$split[0]] = '';
}
// E.Kala - Removed the else {} block; either way continue is still invoked
continue;
}
if (isset($custom_fields[$split[0]])) {
$custom_fields[$split[0]] .= ",{$field_response}";
} else {
$custom_fields[$split[0]] = $field_response;
}
} else {
$custom_fields[$split[0]] = $field_response;
}
}
$post->custom_field = $custom_fields;
// Kohana::log('debug', Kohana::debug($custom_fields));
foreach ($post->custom_field as $field_id => $field_response) {
$field_param = ORM::factory('form_field', $field_id);
$custom_name = $field_param->field_name;
// Validate that this custom field already exists
if (!$field_param->loaded) {
// Populate the error field
//$errors[$field_id] = "The $custom_name field does not exist";
$post->add_error('custom_field', 'not_exist', array($field_id));
return;
}
$max_auth = self::get_user_max_auth();
$required_role = ORM::factory('role', $field_param->field_ispublic_submit);
if (($required_role->loaded ? $required_role->access_level : 0) > $max_auth) {
// Populate the error field
$post->add_error('custom_field', 'permission', array($custom_name));
return;
}
// Validate that the field is required
if ($field_param->field_required == 1 and $field_response == "") {
$post->add_error('custom_field', 'required', array($custom_name));
return;
}
// Grab the custom field options for this field
$field_options = self::get_custom_field_options($field_id);
// Validate Custom fields for text boxes
if ($field_param->field_type == 1 and isset($field_options) and $field_response != '') {
if (isset($field_options['field_datatype'])) {
if ($field_options['field_datatype'] == 'email' and !valid::email($field_response)) {
$post->add_error('custom_field', 'email', array($custom_name));
}
if ($field_options['field_datatype'] == 'phonenumber' and !valid::phone($field_response)) {
$post->add_error('custom_field', 'phone', array($custom_name));
}
if ($field_options['field_datatype'] == 'numeric' and !valid::numeric($field_response)) {
$post->add_error('custom_field', 'numeric', array($custom_name));
}
}
}
// Validate for date
if ($field_param->field_type == 3 and $field_response != "") {
$field_default = $field_param->field_default;
if (!valid::date_mmddyyyy($field_response)) {
$post->add_error('custom_field', 'date_mmddyyyy', array($custom_name));
}
}
// Validate multi-value boxes only have acceptable values
if ($field_param->field_type >= 5 and $field_param->field_type <= 7) {
$defaults = explode('::', $field_param->field_default);
$options = array();
if (preg_match("/[0-9]+-[0-9]+/", $defaults[0]) and count($defaults) == 1) {
$dashsplit = explode('-', $defaults[0]);
$start = $dashsplit[0];
$end = $dashsplit[1];
for ($i = $start; $i <= $end; $i++) {
array_push($options, $i);
}
} else {
//.........这里部分代码省略.........
示例12: request
public function request()
{
if (!IN_PRODUCTION) {
$profiler = new Profiler();
}
$post = new Validation($_POST);
$post->add_rules('email', 'required', array('valid', 'email'));
$is_resending = $this->input->get('resend', 0);
if ($is_resending || $post->validate()) {
$db = Database::instance();
// Check for re-entry of the page here.
if ($is_resending) {
$email = trim($this->session->get('saved_email'));
if (!$email || !valid::email($email)) {
if (!$email) {
$error_str_id = 'form_error_messages.email.required';
} else {
$error_str_id = 'form_error_messages.email.email';
}
$this->session->set_flash('signup_email_error', Kohana::lang($error_str_id));
url::redirect('signup');
return;
}
} else {
$email = trim($this->input->post('email'));
}
if (!$is_resending) {
$email_users_set = $db->from('email_users')->select('user_id', 'last_emailed_timestamp', 'is_validated')->where('email', $email)->limit(1)->get();
}
if (!$is_resending && count($email_users_set)) {
foreach ($email_users_set as $row) {
$email_user = $row;
}
$this->prepend_title("Sign up");
if ($email_user->is_validated) {
$this->render_markdown_template(new View('account_already_active'));
} else {
$this->session->set_flash('saved_email', $email);
$this->render_markdown_template(new View('account_resend_email'));
}
} else {
$validation_key = $this->getUniqueCode($email, 32);
// What kind of email address is it?
if (eregi('@([a-z0-9]+\\.)*uwaterloo\\.ca$', $email)) {
$public_api_key = $this->getUniqueCode($email, 32);
$private_api_key = $this->getUniqueCode($email, 32);
$successfully_sent_email = $this->send_api_key_email($email, $validation_key, $public_api_key, $private_api_key);
} else {
$successfully_sent_email = $this->send_coming_soon_email($email, $validation_key);
}
if (!$is_resending) {
$user_details_values = array('primary_email' => $email);
if (isset($public_api_key) && isset($private_api_key)) {
$user_details_values['public_api_key'] = $public_api_key;
$user_details_values['private_api_key'] = $private_api_key;
}
$user_details = $db->insert('user_details', $user_details_values);
}
if (!$is_resending) {
$email_users_values = array('email' => $email, 'validation_key' => $validation_key, 'user_id' => $user_details->insert_id());
$db->insert('email_users', $email_users_values);
if ($successfully_sent_email) {
$db->from('email_users')->set('last_emailed_timestamp', 'CURRENT_TIMESTAMP', $disable_escaping = true)->where('email', $email)->update();
}
} else {
if ($successfully_sent_email) {
$db->from('email_users')->set('validation_key', $validation_key)->set('last_emailed_timestamp', 'CURRENT_TIMESTAMP', $disable_escaping = true)->where('email', $email)->update();
}
}
$this->session->set_flash('just_completed', true);
url::redirect('signup/completed');
}
} else {
$errors = $post->errors();
$this->session->set_flash('signup_email_error', Kohana::lang('form_error_messages.email.' . $errors['email']));
url::redirect('signup');
}
}
示例13: send_notifications
public static function send_notifications($recipient_id, $item_id, $mailtype)
{
//Load the item
$item = ORM::factory("item")->where("id", "=", $item_id)->find();
if (!$item->loaded()) {
return false;
}
//Load the user
$recipient = ORM::factory("user")->where("id", "=", $recipient_id)->find();
if (!$recipient->loaded()) {
return false;
}
//Only send mail if the notifications are switched on globally
if (!module::get_var("photoannotation", "nonotifications", false)) {
//Check if the use has a valid e-mail
if (!valid::email($recipient->email)) {
return false;
}
//Get the users settings
$notification_settings = self::get_user_notification_settings($recipient);
//Check which type of mail to send
switch ($mailtype) {
case "newtag":
//Only send if user has this option enabled
if ($notification_settings->newtag) {
//Get subject and body and send the mail
$subject = module::get_var("photoannotation", "newtagsubject", "Someone tagged a photo of you");
$body = module::get_var("photoannotation", "newtagbody", "Hello %name, please visit %url to view the photo.");
$body = str_ireplace(array("%url", "%name"), array($item->abs_url(), $recipient->display_name()), $body);
return self::_send_mail($recipient->email, $subject, $body);
}
break;
case "newcomment":
//Only send if user has this option enabled
if ($notification_settings->comment) {
//Don't send if the notification module is active and the user is watching this item
if (module::is_active("notification")) {
if (notification::is_watching($item, $recipient)) {
return false;
}
}
//Get subject and body and send the mail
$subject = module::get_var("photoannotation", "newcommentsubject", "Someone added a comment to photo of you");
$body = module::get_var("photoannotation", "newcommentbody", "Hello %name, please visit %url to read the comment.");
$body = str_ireplace(array("%url", "%name"), array($item->abs_url(), $recipient->display_name()), $body);
return self::_send_mail($recipient->email, $subject, $body);
}
break;
case "updatecomment":
//Only send if user has this option enabled
if ($notification_settings->comment) {
//Don't send if the notification module is active and the user is watching this item
if (module::is_active("notification")) {
if (notification::is_watching($item, $recipient)) {
return false;
}
}
//Get subject and body and send the mail
$subject = module::get_var("photoannotation", "updatedcommentsubject", "Someone updated a comment to photo of you");
$body = module::get_var("photoannotation", "updatedcommentbody", "Hello %name, please visit %url to read the comment.");
$body = str_ireplace(array("%url", "%name"), array($item->abs_url(), $recipient->display_name()), $body);
return self::_send_mail($recipient->email, $subject, $body);
}
}
}
return false;
}
示例14: processCreateAdmin
private function processCreateAdmin()
{
$valid = TRUE;
if (!valid::email($this->session->get('installer.adminEmailAddress'))) {
message::set('You must enter a valid email address to continue!');
$valid = FALSE;
} elseif (strlen($this->session->get('installer.adminPassword')) < 1) {
message::set('You need to set a password!');
$valid = FALSE;
} elseif ($this->session->get('installer.adminPassword') != $this->session->get('installer.adminConfirmPassword')) {
message::set('Passwords do not match!');
$valid = FALSE;
}
return $valid;
}
示例15: import_report
/**
* Function to import a report form a row in the CSV file
* @param array $row
* @return bool
*/
function import_report($row)
{
// If the date is not in proper date format
if (!strtotime($row['INCIDENT DATE'])) {
$this->errors[] = Kohana::lang('import.incident_date') . ($this->rownumber + 1) . ': ' . $row['INCIDENT DATE'];
}
// If a value of Yes or No is NOT set for approval status for the imported row
if (isset($row["APPROVED"]) and !in_array(utf8::strtoupper($row["APPROVED"]), array('NO', 'YES'))) {
$this->errors[] = Kohana::lang('import.csv.approved') . ($this->rownumber + 1);
}
// If a value of Yes or No is NOT set for verified status for the imported row
if (isset($row["VERIFIED"]) and !in_array(utf8::strtoupper($row["VERIFIED"]), array('NO', 'YES'))) {
$this->errors[] = Kohana::lang('import.csv.verified') . ($this->rownumber + 1);
}
if (count($this->errors)) {
return false;
}
// STEP 1: SAVE LOCATION
if (isset($row['LOCATION'])) {
$location = new Location_Model();
$location->location_name = isset($row['LOCATION']) ? $row['LOCATION'] : '';
// For Geocoding purposes
$location_geocoded = map::geocode($location->location_name);
// If we have LATITUDE and LONGITUDE use those
if (isset($row['LATITUDE']) and isset($row['LONGITUDE'])) {
$location->latitude = isset($row['LATITUDE']) ? $row['LATITUDE'] : 0;
$location->longitude = isset($row['LONGITUDE']) ? $row['LONGITUDE'] : 0;
} else {
$location->latitude = $location_geocoded ? $location_geocoded['latitude'] : 0;
$location->longitude = $location_geocoded ? $location_geocoded['longitude'] : 0;
}
$location->country_id = $location_geocoded ? $location_geocoded['country_id'] : 0;
$location->location_date = $this->time;
$location->save();
$this->locations_added[] = $location->id;
}
// STEP 2: SAVE INCIDENT
$incident = new Incident_Model();
$incident->location_id = isset($row['LOCATION']) ? $location->id : 0;
$incident->user_id = 0;
$incident->form_id = (isset($row['FORM #']) and Form_Model::is_valid_form($row['FORM #'])) ? $row['FORM #'] : 1;
$incident->incident_title = $row['INCIDENT TITLE'];
$incident->incident_description = isset($row['DESCRIPTION']) ? $row['DESCRIPTION'] : '';
$incident->incident_date = date("Y-m-d H:i:s", strtotime($row['INCIDENT DATE']));
$incident->incident_dateadd = $this->time;
$incident->incident_active = (isset($row['APPROVED']) and utf8::strtoupper($row['APPROVED']) == 'YES') ? 1 : 0;
$incident->incident_verified = (isset($row['VERIFIED']) and utf8::strtoupper($row['VERIFIED']) == 'YES') ? 1 : 0;
$incident->save();
$this->incidents_added[] = $incident->id;
// STEP 3: Save Personal Information
if (isset($row['FIRST NAME']) or isset($row['LAST NAME']) or isset($row['EMAIL'])) {
$person = new Incident_Person_Model();
$person->incident_id = $incident->id;
$person->person_first = isset($row['FIRST NAME']) ? $row['FIRST NAME'] : '';
$person->person_last = isset($row['LAST NAME']) ? $row['LAST NAME'] : '';
$person->person_email = (isset($row['EMAIL']) and valid::email($row['EMAIL'])) ? $row['EMAIL'] : '';
$person->person_date = date("Y-m-d H:i:s", time());
// Make sure that you're not importing an empty record i.e at least one field has been recorded
// If all fields are empty i.e you have an empty record, don't save
if (!empty($person->person_first) or !empty($person->person_last) or !empty($person->person_email)) {
$person->save();
// Add to array of incident persons added
$this->incident_persons_added[] = $person->id;
}
}
// STEP 4: SAVE CATEGORIES
// If CATEGORY column exists
if (isset($row['CATEGORY'])) {
$categorynames = explode(',', trim($row['CATEGORY']));
// Trim whitespace from array values
$categorynames = array_map('trim', $categorynames);
// Get rid of duplicate category entries in a row
$categories = array_unique(array_map('strtolower', $categorynames));
// Add categories to incident
foreach ($categories as $categoryname) {
// Convert the first string character of the category name to Uppercase
$categoryname = utf8::ucfirst($categoryname);
// For purposes of adding an entry into the incident_category table
$incident_category = new Incident_Category_Model();
$incident_category->incident_id = $incident->id;
// If category name exists, add entry in incident_category table
if ($categoryname != '') {
// Check if the category exists (made sure to convert to uppercase for comparison)
if (!isset($this->existing_categories[utf8::strtoupper($categoryname)])) {
$this->notices[] = Kohana::lang('import.new_category') . $categoryname;
$category = new Category_Model();
$category->category_title = $categoryname;
// We'll just use black for now. Maybe something random?
$category->category_color = '000000';
// because all current categories are of type '5'
$category->category_visible = 1;
$category->category_description = $categoryname;
$category->category_position = count($this->existing_categories);
$category->save();
$this->categories_added[] = $category->id;
//.........这里部分代码省略.........