/** * Funzione che invia una mail di conferma */ public function sendConfirmEmail($type, CV $cv) { //type identifica il tipo di mail da spedire //type == 'user' --> Invia una mail di conferma all'utente //type == 'admin' --> invia una mail di notifica all'amministratore $msg = ''; $title = ''; $email = ''; switch ($type) { case 'user': $email = $cv->getEmail(); $title = $this->language->getTranslation('email-save-title-user'); $msg = $this->language->getTranslation('msg-save-email-user'); break; case 'admin': $email = get_option('admin_email'); $title = $this->language->getTranslation('email-save-title-admin') . ' - ' . $cv->getCognome() . ' ' . $cv->getNome(); if ($cv->getPubblicato() == 0) { $msg = $this->language->getTranslation('msg-save-email-admin-cv-to-approve'); } else { $msg = $this->language->getTranslation('msg-save-email-admin'); } break; case 'update': $email = $cv->getEmail(); $title = $this->language->getTranslation('msg-approved-email-title'); $msg = $this->language->getTranslation('msg-approved-email-msg'); break; } try { //aggiungo il filtro per l'html sulla mail add_filter('wp_mail_content_type', create_function('', 'return "text/html"; ')); //invio la mail wp_mail($email, $title, $msg); return true; } catch (Exception $ex) { _e($ex); return false; } }
/** * La funzione dato un determinato cv, restituisce il suo ID * * @param CV $cv * @return type */ public function getCvID(CV $cv) { try { $result = $this->wpdb->get_var($this->wpdb->prepare("SELECT ID FROM " . $this->table . " WHERE email = %s AND categoria = %d", addslashes($cv->getEmail()), addslashes($cv->getCategoria()))); if ($result != null) { return stripslashes($result); } return false; } catch (Exception $ex) { _e($ex); return -1; } }