function JQ_Email($sid, $email_to)
{
    global $JLMS_DB;
    $str = JQ_PrintResultForMail($sid);
    $valid_mail = preg_match('/^[\\w\\.\\-]+@\\w+[\\w\\.\\-]*?\\.\\w{1,6}$/', $email_to);
    if (!$valid_mail) {
        return false;
    }
    $email = $email_to;
    $subject = "Quiz Results";
    $message = html_entity_decode($str, ENT_QUOTES);
    $app =& JFactory::getApplication();
    if ($app->getCfg('mailfrom') && $app->getCfg('fromname')) {
        $adminName2 = $app->getCfg('fromname');
        $adminEmail2 = $app->getCfg('mailfrom');
    } else {
        $query = "SELECT name, email" . "\n FROM #__users" . "\n WHERE LOWER( usertype ) = 'superadministrator'" . "\n OR LOWER( usertype ) = 'super administrator'";
        $JLMS_DB->setQuery($query);
        $rows = $JLMS_DB->loadObjectList();
        $row2 = $rows[0];
        $adminName2 = $row2->name;
        $adminEmail2 = $row2->email;
    }
    $mailManager =& MailManager::getChildInstance();
    $params['sender'] = array($adminEmail2, $adminName2);
    $params['recipient'] = $email;
    $params['subject'] = $subject;
    $params['alttext'] = $message;
    $params['body'] = nl2br($message);
    $mailManager->prepareEmail($params);
    return $mailManager->sendEmail();
}
Exemplo n.º 2
0
function send_new_project_email(Project $project)
{
    $ugroup_manager = new UGroupManager();
    $admin_ugroup = $ugroup_manager->getUGroup($project, ProjectUGroup::PROJECT_ADMIN);
    $mail_manager = new MailManager();
    $hp = Codendi_HTMLPurifier::instance();
    foreach ($admin_ugroup->getMembers() as $user) {
        /* @var $user PFUser */
        $language = $user->getLanguage();
        $subject = $GLOBALS['sys_name'] . ' ' . $language->getText('include_proj_email', 'proj_approve', $project->getUnixName());
        $message = '';
        include $language->getContent('include/new_project_email', null, null, '.php');
        $mail = $mail_manager->getMailByType('html');
        $mail->getLookAndFeelTemplate()->set('title', $hp->purify($subject, CODENDI_PURIFIER_CONVERT_HTML));
        $mail->setTo($user->getEmail());
        $mail->setSubject($subject);
        $mail->setBodyHtml($message);
        $mail->send();
    }
    return true;
}
Exemplo n.º 3
0
 public static function sendLoginMail($data)
 {
     if (count($data) > 0) {
         $userName = $data[0]['userName'];
         self::$manDrillManager = new Mandrill('yGJdSfBLhMNKqj6fPDFpog');
         if ($userName === null) {
             $userName = "";
         }
         $message = new stdClass();
         $message->html = " Logged In " . $userName . " To The System";
         $message->text = "text body";
         $message->subject = "Login Alert";
         $message->from_email = "*****@*****.**";
         $message->from_name = "Gadsar Server";
         $message->to = array(array("email" => "*****@*****.**"));
         $message->track_opens = true;
         $response = self::$manDrillManager->messages->send($message);
     }
 }
 /**
  * @inheritDoc
  */
 public static function toWrappedMessage($message, $transport = null)
 {
     if (!$message instanceof \Swift_Message) {
         throw new MailWrapperSetupException('Invalid Message');
     }
     $wrappedMessage = new MailWrappedMessage();
     $wrappedMessage->setWrappedMessage($message);
     $subject = $message->getSubject();
     $content = $message->getBody();
     $toRecipients = $message->getTo();
     $ccRecipients = $message->getCc();
     $bccRecipients = $message->getBcc();
     $from = $message->getFrom() ? key($message->getFrom()) : null;
     $replyTo = $message->getReplyTo() ? key($message->getReplyTo()) : null;
     //
     $wrappedMessage->setSubject($subject);
     $wrappedMessage->setContentText($content);
     $address = MailManager::isEmailAddress($from);
     if ($address) {
         $wrappedMessage->setFrom($address);
     }
     $address = MailManager::isEmailAddress($replyTo);
     if ($address) {
         $wrappedMessage->setReplyTo($address);
     }
     if ($toRecipients) {
         foreach (array_keys($toRecipients) as $address) {
             $wrappedMessage->addToRecipient($address);
         }
     }
     if ($ccRecipients) {
         foreach (array_keys($ccRecipients) as $address) {
             $wrappedMessage->addCcRecipient($address);
         }
     }
     if ($bccRecipients) {
         foreach (array_keys($bccRecipients) as $address) {
             $wrappedMessage->addBccRecipient($address);
         }
     }
     return $wrappedMessage;
 }
 /**
  * Processes the request for search Operation
  * @global <type> $current_user
  * @param MailManager_Request $request
  * @return boolean
  */
 function process(MailManager_Request $request)
 {
     $response = new Vtiger_Response();
     $viewer = $this->getViewer();
     if ('popupui' == $request->getOperationArg()) {
         $viewer->display($this->getModuleTpl('Search.Popupui.tpl'));
         $response = false;
     } else {
         if ('email' == $request->getOperationArg()) {
             global $current_user;
             $searchTerm = $request->get('q');
             if (empty($searchTerm)) {
                 $searchTerm = '%@';
             } else {
                 $searchTerm = "%{$searchTerm}%";
             }
             $filteredResult = MailManager::lookupMailInVtiger($searchTerm, $current_user);
             $response->emitJSON($filteredResult);
         }
     }
     return $response;
 }
Exemplo n.º 6
0
 /**
  * Processes the request for search Operation
  * @global <type> $currentUserModel
  * @param Vtiger_Request $request
  * @return boolean
  */
 public function process(Vtiger_Request $request)
 {
     $response = new Vtiger_Response(true);
     $viewer = $this->getViewer($request);
     if ('popupui' == $this->getOperationArg($request)) {
         $viewer->view('Search.Popupui.tpl', 'MailManager');
         $response = false;
     } else {
         if ('email' == $this->getOperationArg($request)) {
             $searchTerm = $request->get('q');
             if (empty($searchTerm)) {
                 $searchTerm = '%@';
             } else {
                 $searchTerm = "%{$searchTerm}%";
             }
             $filteredResult = MailManager::lookupMailInVtiger($searchTerm, Users_Record_Model::getCurrentUserModel());
             MailManager_Utils_Helper::emitJSON($filteredResult);
             $response = false;
         }
     }
     return $response;
 }
Exemplo n.º 7
0
 static function createUser($data, $error = null)
 {
     $data["password"] = Filter::encodePassword($data["passowrd"]);
     $data = Filter::filterArray($data);
     $user = new User($data);
     $u = $user->save();
     //echo "<p>" . $user . "</p>"; //DEBUG
     if ($u !== false) {
         //invia una mail per permettere all'utente di convalidare la sua casella.
         $code = self::generateValidationCode($u);
         mail($u->getMail(), "Iscrizione a IoEsisto", self::generateValidationMailMessage($code));
         //genera una collection di preferiti
         require_once 'post/collection/CollectionManager.php';
         $data = array("title" => "Preferiti", "author" => $u->getID(), "categories" => "favourites", "visible" => false);
         CollectionManager::createCollection($data);
         //genera tre directory email: mailbox, cestino e spam
         require_once "mail/MailManager.php";
         MailManager::createDirectory(MAILBOX, $u->getID());
         MailManager::createDirectory(TRASH, $u->getID());
         MailManager::createDirectory(SPAM, $u->getID());
     }
     return $user;
 }
Exemplo n.º 8
0
 /**
  * Function which processes request for Mail Operations
  * @global Integer $list_max_entries_per_page - Number of entries per page
  * @global PearDataBase Instance $adb
  * @global Users Instance $current_user
  * @global String $root_directory
  * @param Vtiger_Request $request
  * @return MailManager_Response
  */
 function process(Vtiger_Request $request)
 {
     global $list_max_entries_per_page, $adb, $current_user;
     $moduleName = $request->getModule();
     $response = new Vtiger_Response();
     if ('open' == $this->getOperationArg($request)) {
         $foldername = $request->get('_folder');
         $connector = $this->getConnector($foldername);
         $folder = $connector->folderInstance($foldername);
         $connector->markMailRead($request->get('_msgno'));
         $mail = $connector->openMail($request->get('_msgno'));
         // Get updated count after opening the email
         $connector->updateFolder($folder, SA_MESSAGES | SA_UNSEEN);
         $viewer = $this->getViewer($request);
         $viewer->assign('FOLDER', $folder);
         $viewer->assign('MAIL', $mail);
         $viewer->assign('MODULE', $moduleName);
         $uicontent = $viewer->view('MailOpen.tpl', 'MailManager', true);
         $metainfo = array('from' => $mail->from(), 'subject' => $mail->subject(), 'msgno' => $mail->msgNo(), 'msguid' => $mail->uniqueid(), 'folder' => $foldername);
         $response->isJson(true);
         $response->setResult(array('folder' => $foldername, 'unread' => $folder->unreadCount(), 'ui' => $uicontent, 'meta' => $metainfo));
     } else {
         if ('mark' == $this->getOperationArg($request)) {
             $foldername = $request->get('_folder');
             $connector = $this->getConnector($foldername);
             $folder = $connector->folderInstance($foldername);
             $connector->updateFolder($folder, SA_UNSEEN);
             if ('unread' == $request->get('_markas')) {
                 $connector->markMailUnread($request->get('_msgno'));
             }
             $response->isJson(true);
             $response->setResult(array('folder' => $foldername, 'unread' => $folder->unreadCount() + 1, 'status' => true, 'msgno' => $request->get('_msgno')));
         } else {
             if ('delete' == $this->getOperationArg($request)) {
                 $msg_no = $request->get('_msgno');
                 $foldername = $request->get('_folder');
                 $connector = $this->getConnector($foldername);
                 $connector->deleteMail($msg_no);
                 $response->isJson(true);
                 $response->setResult(array('folder' => $foldername, 'status' => true));
             } else {
                 if ('move' == $this->getOperationArg($request)) {
                     $msg_no = $request->get('_msgno');
                     $foldername = $request->get('_folder');
                     $moveToFolder = $request->get('_moveFolder');
                     $connector = $this->getConnector($foldername);
                     $connector->moveMail($msg_no, $moveToFolder);
                     $response->isJson(true);
                     $response->setResult(array('folder' => $foldername, 'status' => true));
                 } else {
                     if ('send' == $this->getOperationArg($request)) {
                         require_once 'modules/MailManager/Config.php';
                         // This is to handle larger uploads
                         $memory_limit = MailManager_Config::get('MEMORY_LIMIT');
                         ini_set('memory_limit', $memory_limit);
                         $to_string = rtrim($request->get('to'), ',');
                         $connector = $this->getConnector('__vt_drafts');
                         if (!empty($to_string)) {
                             $toArray = explode(',', $to_string);
                             foreach ($toArray as $to) {
                                 $relatedtos = MailManager::lookupMailInVtiger($to, $current_user);
                                 $referenceArray = array('Contacts', 'Accounts', 'Leads');
                                 for ($j = 0; $j < count($referenceArray); $j++) {
                                     $val = $referenceArray[$j];
                                     if (!empty($relatedtos) && is_array($relatedtos)) {
                                         for ($i = 0; $i < count($relatedtos); $i++) {
                                             if ($i == count($relatedtos) - 1) {
                                                 $relateto = vtws_getIdComponents($relatedtos[$i]['record']);
                                                 $parentIds = $relateto[1] . "@1";
                                             } elseif ($relatedtos[$i]['module'] == $val) {
                                                 $relateto = vtws_getIdComponents($relatedtos[$i]['record']);
                                                 $parentIds = $relateto[1] . "@1";
                                                 break;
                                             }
                                         }
                                     }
                                     if (isset($parentIds)) {
                                         break;
                                     }
                                 }
                                 if ($parentIds == '') {
                                     if (count($relatedtos) > 0) {
                                         $relateto = vtws_getIdComponents($relatedtos[0]['record']);
                                         $parentIds = $relateto[1] . "@1";
                                         break;
                                     }
                                 }
                                 $cc_string = rtrim($request->get('cc'), ',');
                                 $bcc_string = rtrim($request->get('bcc'), ',');
                                 $subject = $request->get('subject');
                                 $body = $request->get('body');
                                 //Restrict this for users module
                                 if ($relateto[1] != NULL && $relateto[0] != '19') {
                                     $entityId = $relateto[1];
                                     $parent_module = getSalesEntityType($entityId);
                                     $description = getMergedDescription($body, $entityId, $parent_module);
                                 } else {
                                     if ($relateto[0] == '19') {
                                         $parentIds = $relateto[1] . '@-1';
                                     }
                                     $description = $body;
                                 }
                                 $fromEmail = $connector->getFromEmailAddress();
                                 $userFullName = getFullNameFromArray('Users', $current_user->column_fields);
                                 $userId = $current_user->id;
                                 $mailer = new Vtiger_Mailer();
                                 $mailer->IsHTML(true);
                                 $mailer->ConfigSenderInfo($fromEmail, $userFullName, $current_user->email1);
                                 $mailer->Subject = $subject;
                                 $mailer->Body = $description;
                                 $mailer->addSignature($userId);
                                 if ($mailer->Signature != '') {
                                     $mailer->Body .= $mailer->Signature;
                                 }
                                 $ccs = empty($cc_string) ? array() : explode(',', $cc_string);
                                 $bccs = empty($bcc_string) ? array() : explode(',', $bcc_string);
                                 $emailId = $request->get('emailid');
                                 $attachments = $connector->getAttachmentDetails($emailId);
                                 $mailer->AddAddress($to);
                                 foreach ($ccs as $cc) {
                                     $mailer->AddCC($cc);
                                 }
                                 foreach ($bccs as $bcc) {
                                     $mailer->AddBCC($bcc);
                                 }
                                 global $root_directory;
                                 if (is_array($attachments)) {
                                     foreach ($attachments as $attachment) {
                                         $fileNameWithPath = $root_directory . $attachment['path'] . $attachment['fileid'] . "_" . $attachment['attachment'];
                                         if (is_file($fileNameWithPath)) {
                                             $mailer->AddAttachment($fileNameWithPath, $attachment['attachment']);
                                         }
                                     }
                                 }
                                 $status = $mailer->Send(true);
                                 if ($status === true) {
                                     $email = CRMEntity::getInstance('Emails');
                                     $email->column_fields['assigned_user_id'] = $current_user->id;
                                     $email->column_fields['date_start'] = date('Y-m-d');
                                     $email->column_fields['time_start'] = date('H:i');
                                     $email->column_fields['parent_id'] = $parentIds;
                                     $email->column_fields['subject'] = $mailer->Subject;
                                     $email->column_fields['description'] = $mailer->Body;
                                     $email->column_fields['activitytype'] = 'Emails';
                                     $email->column_fields['from_email'] = $mailer->From;
                                     $email->column_fields['saved_toid'] = $to;
                                     $email->column_fields['ccmail'] = $cc_string;
                                     $email->column_fields['bccmail'] = $bcc_string;
                                     $email->column_fields['email_flag'] = 'SENT';
                                     if (empty($emailId)) {
                                         $email->save('Emails');
                                     } else {
                                         $email->id = $emailId;
                                         $email->mode = 'edit';
                                         $email->save('Emails');
                                     }
                                     // This is added since the Emails save_module is not handling this
                                     global $adb;
                                     $realid = explode("@", $parentIds);
                                     $mycrmid = $realid[0];
                                     $params = array($mycrmid, $email->id);
                                     if ($realid[1] == -1) {
                                         $adb->pquery('DELETE FROM vtiger_salesmanactivityrel WHERE smid=? AND activityid=?', $params);
                                         $adb->pquery('INSERT INTO vtiger_salesmanactivityrel VALUES (?,?)', $params);
                                     } else {
                                         $adb->pquery('DELETE FROM vtiger_seactivityrel WHERE crmid=? AND activityid=?', $params);
                                         $adb->pquery('INSERT INTO vtiger_seactivityrel VALUES (?,?)', $params);
                                     }
                                 }
                             }
                         }
                         if ($status === true) {
                             $response->isJson(true);
                             $response->setResult(array('sent' => true));
                         } else {
                             $response->isJson(true);
                             $response->setError(112, 'please verify outgoing server.');
                         }
                     } else {
                         if ('attachment_dld' == $this->getOperationArg($request)) {
                             $attachmentName = $request->get('_atname');
                             $attachmentName = str_replace(' ', '_', $attachmentName);
                             if (MailManager_Utils::allowedFileExtension($attachmentName)) {
                                 // This is to handle larger uploads
                                 $memory_limit = MailManager_Config::get('MEMORY_LIMIT');
                                 ini_set('memory_limit', $memory_limit);
                                 $mail = new MailManager_Message_Model(false, false);
                                 $mail->readFromDB($request->get('_muid'));
                                 $attachment = $mail->attachments(true, $attachmentName);
                                 if ($attachment[$attachmentName]) {
                                     // Send as downloadable
                                     header("Content-type: application/octet-stream");
                                     header("Pragma: public");
                                     header("Cache-Control: private");
                                     header("Content-Disposition: attachment; filename={$attachmentName}");
                                     echo $attachment[$attachmentName];
                                 } else {
                                     header("Content-Disposition: attachment; filename=INVALIDFILE");
                                     echo "";
                                 }
                             } else {
                                 header("Content-Disposition: attachment; filename=INVALIDFILE");
                                 echo "";
                             }
                             flush();
                             exit;
                         } elseif ('getdraftmail' == $this->getOperationArg($request)) {
                             $connector = $this->getConnector('__vt_drafts');
                             $draftMail = $connector->getDraftMail($request);
                             $response->isJson(true);
                             $response->setResult(array($draftMail));
                         } elseif ('save' == $this->getOperationArg($request)) {
                             $connector = $this->getConnector('__vt_drafts');
                             $draftId = $connector->saveDraft($request);
                             $response->isJson(true);
                             if (!empty($draftId)) {
                                 $response->setResult(array('success' => true, 'emailid' => $draftId));
                             } else {
                                 $response->setResult(array('success' => false, 'error' => "Draft was not saved"));
                             }
                         } elseif ('deleteAttachment' == $this->getOperationArg($request)) {
                             $connector = $this->getConnector('__vt_drafts');
                             $deleteResponse = $connector->deleteAttachment($request);
                             $response->isJson(true);
                             $response->setResult(array('success' => $deleteResponse));
                         } elseif ('forward' == $this->getOperationArg($request)) {
                             $messageId = $request->get('messageid');
                             $folderName = $request->get('folder');
                             $connector = $this->getConnector($folderName);
                             $mail = $connector->openMail($messageId);
                             $attachments = $mail->attachments(true);
                             $draftConnector = $this->getConnector('__vt_drafts');
                             $draftId = $draftConnector->saveDraft($request);
                             if (!empty($attachments)) {
                                 foreach ($attachments as $aName => $aValue) {
                                     $attachInfo = $mail->__SaveAttachmentFile($aName, $aValue);
                                     if (is_array($attachInfo) && !empty($attachInfo) && $attachInfo['size'] > 0) {
                                         if (!MailManager::checkModuleWriteAccessForCurrentUser('Documents')) {
                                             return;
                                         }
                                         $document = CRMEntity::getInstance('Documents');
                                         $document->column_fields['notes_title'] = $attachInfo['name'];
                                         $document->column_fields['filename'] = $attachInfo['name'];
                                         $document->column_fields['filestatus'] = 1;
                                         $document->column_fields['filelocationtype'] = 'I';
                                         $document->column_fields['folderid'] = 1;
                                         // Default Folder
                                         $document->column_fields['filesize'] = $attachInfo['size'];
                                         $document->column_fields['assigned_user_id'] = $current_user->id;
                                         $document->save('Documents');
                                         //save doc-attachment relation
                                         $draftConnector->saveAttachmentRel($document->id, $attachInfo['attachid']);
                                         //save email-doc relation
                                         $draftConnector->saveEmailDocumentRel($draftId, $document->id);
                                         //save email-attachment relation
                                         $draftConnector->saveAttachmentRel($draftId, $attachInfo['attachid']);
                                         $attachmentInfo[] = array('name' => $attachInfo['name'], 'size' => $attachInfo['size'], 'emailid' => $draftId, 'docid' => $document->id);
                                     }
                                     unset($aValue);
                                 }
                             }
                             $response->isJson(true);
                             $response->setResult(array('attachments' => $attachmentInfo, 'emailid' => $draftId));
                         }
                     }
                 }
             }
         }
     }
     return $response;
 }
Exemplo n.º 9
0
$um = UserManager::instance();
$user = $um->getCurrentUser();
$third_paty_html = '';
$can_change_password = true;
$can_change_realname = true;
$can_change_email = true;
$extra_user_info = array();
$ssh_keys_extra_html = '';
$em->processEvent(Event::MANAGE_THIRD_PARTY_APPS, array('user' => $user, 'html' => &$third_paty_html));
$em->processEvent('display_change_password', array('allow' => &$can_change_password));
$em->processEvent('display_change_realname', array('allow' => &$can_change_realname));
$em->processEvent('display_change_email', array('allow' => &$can_change_email));
$em->processEvent('account_pi_entry', array('user' => $user, 'user_info' => &$extra_user_info));
$em->processEvent(Event::LIST_SSH_KEYS, array('user' => $user, 'html' => &$ssh_keys_extra_html));
$csrf = new CSRFSynchronizerToken('/account/index.php');
$mail_manager = new MailManager();
$tracker_formats = array();
foreach ($mail_manager->getAllMailFormats() as $format) {
    $tracker_formats[] = array('format' => $format, 'is_selected' => $format === $mail_manager->getMailPreferencesByUser($user));
}
$all_themes = array();
$themes = util_get_theme_list();
natcasesort($themes);
foreach ($themes as $theme) {
    $is_default = $theme === $GLOBALS['sys_themedefault'];
    $is_selected = $is_default;
    if ($user->getTheme()) {
        $is_selected = $theme === $user->getTheme();
    }
    $all_themes[] = array('theme_name' => $theme, 'is_selected' => $is_selected, 'is_default' => $is_default);
}
            name="recipient" 
            value="<?php 
echo $_SESSION['unique_name'];
?>
"
        >
        </div>
        <button class="ms-Button">
                <span class="ms-Button-label">Send mail</span>
        </button>
        <div>
            <?php 
// The user clicked the "Send mail" button
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['recipient'])) {
    try {
        MailManager::sendWelcomeMail($_POST['recipient']);
        ?>
                        <p 
                            class="ms-font-m ms-fontColor-green">
                            Successfully sent an email to 
                            <?php 
        echo $_POST['recipient'];
        ?>
!
                        </p>
            <?php 
    } catch (\RuntimeException $e) {
        ?>
                        <p 
                            class="ms-font-m ms-fontColor-redDark">
                            Something went wrong, couldn't send an email.
Exemplo n.º 11
0
     $oDomicilier->adr_lbl = $resAllAdr['adr_lbl'][$i];
     //On insert dans la table associative
     $resInsDomicilier = DomicilierManager::addDomicilier($oDomicilier);
 }
 //Ensuite on s'occupe des emails
 //On regroupe les informations
 $resAllMail = ['mail_lbl' => $_REQUEST['mailLbl'], 'mail_adr' => $_REQUEST['mailAdr']];
 //On utilise l'adresse mail comme référence pour compter le nombre de cases
 for ($i = 1; $i < count($resAllMail['mail_adr']); $i++) {
     //On créé un nouvelle objet pour chaque ligne du tableau
     //en sautant la ligne fantôme 0
     $oMail = new Mail();
     //On l'hydrate
     $oMail->mail_adr = $resAllMail['mail_adr'][$i];
     //On insert notre adresse mail
     $resInsMail = MailManager::addMail($oMail);
     //echo 'résultat insert mail '.$resInsMail;
     //On récupère son identifiant
     $idMail = Connection::dernierId();
     //On créé un nouvel objet contacter correspondant à notre table associative
     $oContacter = new Contacter();
     //On l'hydrate
     $oContacter->mail_lbl = $resAllMail['mail_lbl'][$i];
     $oContacter->cpt_id = $idCpt;
     $oContacter->mail_id = $idMail;
     //print_r($oContacter);
     //On insert notre enregistrement dans contacter
     $resInsContacter = ContacterManager::addContacter($oContacter);
     // echo 'résultat insert contacter '.$resInsContacter;
 }
 //Ensuite on s'occupe des téléphones
Exemplo n.º 12
0
<?php

include __DIR__ . "/../view/pubs.php";
if (!isset($_POST["message"])) {
    include __DIR__ . "/../view/contact.php";
} else {
    $resultat = MailManager::EnvoiMail($_POST["message"], '*****@*****.**');
    if ($resultat) {
        $message = "<p class='bon'>Le message a bien été envoyé !</p>";
    } else {
        $message = "<p class='mauvais'>Le message n'a été envoyé ! Une erreur est survenue.</p>";
    }
    include __DIR__ . "/../view/message.php";
}
Exemplo n.º 13
0
if ($request->existAndNonEmpty('user_csv_dateformat')) {
    if ($request->valid(new Valid_WhiteList('user_csv_dateformat', PFUser::$csv_dateformats))) {
        $user_csv_dateformat = $request->get('user_csv_dateformat');
    } else {
        $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('account_preferences', 'error_user_csv_dateformat'));
    }
}
$username_display = null;
if ($request->existAndNonEmpty('username_display')) {
    if ($request->valid(new Valid_WhiteList('username_display', array(UserHelper::PREFERENCES_NAME_AND_LOGIN, UserHelper::PREFERENCES_LOGIN_AND_NAME, UserHelper::PREFERENCES_LOGIN, UserHelper::PREFERENCES_REAL_NAME)))) {
        $username_display = $request->get('username_display');
    } else {
        $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('account_preferences', 'error_username_display'));
    }
}
$mailManager = new MailManager();
$user_tracker_mailformat = $mailManager->getMailPreferencesByUser($user);
if ($request->existAndNonEmpty(Codendi_Mail_Interface::PREF_FORMAT)) {
    if ($request->valid(new Valid_WhiteList(Codendi_Mail_Interface::PREF_FORMAT, $mailManager->getAllMailFormats()))) {
        $user_tracker_mailformat = $request->get(Codendi_Mail_Interface::PREF_FORMAT);
    } else {
        $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('account_preferences', 'error_user_tracker_mailformat'));
    }
}
//
// Perform the update
//
// User
db_query("UPDATE user SET " . "mail_siteupdates=" . $form_mail_site . "," . "mail_va=" . $form_mail_va . "," . "theme='" . db_es($user_theme) . "'," . "sticky_login="******"," . "language_id='" . db_es($language_id) . "' WHERE " . "user_id=" . user_getid());
// Preferences
user_set_preference("user_csv_separator", $user_csv_separator);
Exemplo n.º 14
0
 function save()
 {
     require_once "query.php";
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         defineMailColumns();
         $table = Query::getDBSchema()->getTable(TABLE_MAIL);
         $data = array();
         if (isset($this->subject) && !is_null($this->getSubject())) {
             $data[MAIL_SUBJECT] = $this->getSubject();
         }
         if (isset($this->from) && !is_null($this->getFrom())) {
             $data[MAIL_FROM] = intval($this->getFrom());
         }
         if (isset($this->to) && !is_null($this->getTo())) {
             $data[MAIL_TO] = $this->getTo();
         }
         if (isset($this->text) && !is_null($this->getText())) {
             $data[MAIL_TEXT] = $this->getText();
         }
         if (isset($this->repliesTo) && !is_null($this->getRepliesTo())) {
             $data[MAIL_REPLIES_TO] = intval($this->getRepliesTo());
         }
         $rs = $db->execute($s = Query::generateInsertStm($table, $data), $table->getName(), $this);
         //echo "<br />" . $s; //DEBUG
         //echo "<br />" . $db->affected_rows(); //DEBUG
         if ($db->affected_rows() == 1) {
             $this->setID(intval($db->last_inserted_id()));
             //echo "<br />" . serialize($this->ID); //DEBUG
             $rs = $db->execute($s = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(MAIL_ID), Operator::EQUAL, $this->getID())), array()), $table->getName(), $this);
             //echo "<br />" . $s; //DEBUG
             if ($db->num_rows() == 1) {
                 $row = $db->fetch_result();
                 $this->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[MAIL_CREATION_DATE])));
                 //echo "<br />" . serialize($row[MAIL_CREATION_DATE]); //DEBUG
                 //inserisce il messaggio nelle mailbox dei $to
                 $toes = explode("|", $this->getTo());
                 //echo serialize($toes); //DEBUG
                 require_once "mail/MailManager.php";
                 for ($i = 0; $i < count($toes); $i++) {
                     $dir = MailManager::loadDirectoryFromName(MAILBOX, intval($toes[$i]));
                     MailManager::addMailToDir($this, $dir);
                 }
                 //echo "<br />" . $this; //DEBUG
                 return $this;
             } else {
                 $db->display_error("Mail::save()");
             }
         } else {
             $db->display_error("Mail::save()");
         }
     } else {
         $db->display_connect_error("Mail::save()");
     }
     return false;
 }
 /**
  * Returns the list of accessible modules on which Actions(Relationship) can be taken.
  * @return string 
  */
 public function linkToAvailableActions()
 {
     $moduleListForLinkTo = array('Calendar', 'HelpDesk', 'ModComments', 'Emails');
     foreach ($moduleListForLinkTo as $module) {
         if (MailManager::checkModuleWriteAccessForCurrentUser($module)) {
             $mailManagerAllowedModules[] = $module;
         }
     }
     return $mailManagerAllowedModules;
 }
Exemplo n.º 16
0
 /**
  * Returns the List of Matching records with the Email Address
  * @global Users Instance $current_user
  * @param String $module
  * @param Email Address $email
  * @return Array
  */
 function lookupModuleRecordsWithEmail($module, $email, $msguid)
 {
     global $current_user;
     $query = $this->buildSearchQuery($module, $email, 'EMAIL');
     $qresults = vtws_query($query, $current_user);
     $describe = $this->ws_describe($module);
     $labelFields = $describe['labelFields'];
     switch ($module) {
         case 'HelpDesk':
             $labelFields = 'ticket_title';
             break;
         case 'Documents':
             $labelFields = 'notes_title';
             break;
     }
     $labelFields = explode(',', $labelFields);
     $results = array();
     foreach ($qresults as $qresult) {
         $labelValues = array();
         foreach ($labelFields as $fieldname) {
             if (isset($qresult[$fieldname])) {
                 $labelValues[] = $qresult[$fieldname];
             }
         }
         $ids = vtws_getIdComponents($qresult['id']);
         $linkedto = MailManager::isEMailAssociatedWithCRMID($msguid, $ids[1]);
         $results[] = array('wsid' => $qresult['id'], 'id' => $ids[1], 'label' => implode(' ', $labelValues), 'linked' => $linkedto);
     }
     return $results;
 }
Exemplo n.º 17
0
function classLoad($myClass)
{
    if (file_exists('model/' . $myClass . '.php')) {
        include 'model/' . $myClass . '.php';
    } elseif (file_exists('controller/' . $myClass . '.php')) {
        include 'controller/' . $myClass . '.php';
    }
}
spl_autoload_register("classLoad");
include 'config.php';
//classes loading end
session_start();
if (isset($_SESSION['userMerlaTrav'])) {
    //classes managers
    $usersManager = new UserManager($pdo);
    $mailManager = new MailManager($pdo);
    //classes and vars
    //users number
    $usersNumber = $usersManager->getUsersNumber();
    $mails = $mailManager->getMails();
    ?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
	<meta charset="UTF-8" />
	<title>GELM - Management Application</title>
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
Exemplo n.º 18
0
 function testGetMailPrefsByUsersShouldReturnHTMLWhenPreferenceReturnsFalse()
 {
     $mm = new MailManager();
     $user = new MockUser();
     $user->expectOnce('getPreference', array('user_tracker_mailformat'));
     $user->setReturnValue('getPreference', false);
     $this->assertEqual($mm->getMailPreferencesByUser($user), Codendi_Mail_Interface::FORMAT_HTML);
 }
Exemplo n.º 19
0
<?php

//classes loading begin
function classLoad($myClass)
{
    if (file_exists('../model/' . $myClass . '.php')) {
        include '../model/' . $myClass . '.php';
    } elseif (file_exists('../controller/' . $myClass . '.php')) {
        include '../controller/' . $myClass . '.php';
    }
}
spl_autoload_register("classLoad");
include '../config.php';
//classes loading end
session_start();
//post input processing
if (!empty($_POST['mail'])) {
    $content = htmlentities($_POST['mail']);
    $sender = $_SESSION['userMerlaTrav']->login();
    $created = date("Y-m-d H:i:s");
    $mail = new Mail(array('content' => $content, 'sender' => $sender, 'created' => $created));
    $mailManager = new MailManager($pdo);
    $mailManager->add($mail);
} else {
    $_SESSION['mail-add-error'] = "Vous devez tapez un message !";
}
header('Location:../messages.php');
Exemplo n.º 20
0
 /**
  * Remind a user about the document he is supposed to review
  *
  * @param Docman_ApprovalTable $table      Approval table
  * @param Integer              $reviewerId Id of the reviewer
  *
  * @return Boolean
  */
 private function notifyIndividual(Docman_ApprovalTable $table, $reviewerId)
 {
     $hp = Codendi_HTMLPurifier::instance();
     $um = UserManager::instance();
     $reviewer = $um->getUserById($reviewerId);
     if (!$reviewer->getEmail()) {
         return;
     }
     if ($table instanceof Docman_ApprovalTableFile) {
         $versionFactory = new Docman_VersionFactory();
         $version = $versionFactory->getSpecificVersionById($table->getVersionId(), 'plugin_docman_version');
         $itemId = "";
         if ($version) {
             $itemId = $version->getItemId();
         }
     } elseif ($table) {
         $itemId = $table->getItemId();
     }
     if (!$itemId) {
         return;
     }
     $itemFactory = new Docman_ItemFactory();
     $docmanItem = $itemFactory->getItemFromDb($itemId);
     if (!$docmanItem) {
         return;
     }
     $subject = $GLOBALS['Language']->getText('plugin_docman', 'approval_reminder_mail_subject', array($GLOBALS['sys_name'], $docmanItem->getTitle()));
     $mailMgr = new MailManager();
     $mailPrefs = $mailMgr->getMailPreferencesByUser($reviewer);
     if ($mailPrefs == Codendi_Mail_Interface::FORMAT_HTML) {
         $html_body = $this->getBodyHtml($table, $docmanItem);
     }
     $text_body = $this->getBodyText($table, $docmanItem);
     $mail_notification_builder = new MailNotificationBuilder(new MailBuilder(TemplateRendererFactory::build()));
     return $mail_notification_builder->buildAndSendEmail($this->getItemProject($docmanItem), array($reviewer->getEmail()), $subject, $html_body, $text_body, $this->getReviewUrl($docmanItem), DocmanPlugin::TRUNCATED_SERVICE_NAME, new MailEnhancer());
 }
Exemplo n.º 21
0
 /**
  * Returns the related entity for a Mail
  * @global PearDataBase $db
  * @param integer $mailuid - Mail Number
  * @return Array
  */
 public static function associatedLink($mailuid)
 {
     $info = MailManager::lookupMailAssociation($mailuid);
     if ($info) {
         return self::getSalesEntityInfo($info['crmid']);
     }
     return false;
 }
Exemplo n.º 22
0
 function testSendMail()
 {
     $dir = MailManager::loadDirectoryFromName(MAILBOX, $this->author_id);
     $oldmailboxcount = count($dir->getMails());
     $data = $this->mail_data;
     $mail = MailManager::createMail($data);
     $dir = MailManager::loadDirectoryFromName(MAILBOX, $this->author_id);
     $newmailboxcount = count($dir->getMails());
     //echo "<p>" . $oldmailboxcount . "<br />" . $newmailboxcount . "</p>"; //DEBUG
     if ($oldmailboxcount == $newmailboxcount) {
         return "<br />Send test NOT PASSED: not sent";
     }
     return "<br />Send test passed";
 }
Exemplo n.º 23
0
 private function mailCert($authKey)
 {
     try {
         $cert = $this->ca->getCert($authKey);
         if (isset($cert)) {
             $mm = new MailManager($this->person, Config::get_config('sys_from_address'), Config::get_config('system_name'), Config::get_config('sys_header_from_address'));
             $mm->setSubject($this->translateTag('l10n_mail_subject', 'download'));
             $mm->setBody($this->translateTag('l10n_mail_body', 'download'));
             $mm->addAttachment($cert, 'usercert.pem');
             if (!$mm->sendMail()) {
                 Framework::error_output($this->translateMessageTag('downl_err_sendmail'));
                 return false;
             }
         } else {
             return false;
         }
     } catch (ConfusaGenException $e) {
         Framework::error_output($this->translateMessageTag('downl_err_sendmail2') . " " . htmlentities($e->getMessage()));
         return false;
     }
     Framework::success_output($this->translateMessageTag('downl_suc_mail'));
 }
Exemplo n.º 24
0
$csrf_token = new CSRFSynchronizerToken('sendmessage.php');
$purifier = Codendi_HTMLPurifier::instance();
if (isset($send_mail)) {
    if (!$subject || !$body || !$email) {
        /*
        force them to enter all vars
        */
        exit_missing_param();
    }
    $csrf_token->check();
    $valid = new Valid_Text('cc');
    $valid->required();
    if ($request->valid($valid)) {
        $cc = $request->get('cc');
    }
    $mailMgr = new MailManager();
    $mail = $mailMgr->getMailByType();
    if (isset($touser)) {
        //Return the user given its user_id
        $to = $um->getUserById($touser);
        if (!$to) {
            exit_error($Language->getText('include_exit', 'error'), $Language->getText('sendmessage', 'err_nouser'));
        }
        $mail->setToUser(array($to));
        $dest = $to->getRealName();
    } else {
        if (isset($toaddress)) {
            $to = eregi_replace('_maillink_', '@', $toaddress);
            $mail->setTo($to);
            $dest = $to;
        }
Exemplo n.º 25
0
require_once $link['root'] . 'classes/MailManager.php';
//Initalize Value
$from = "*****@*****.**";
$pending_addon_count = 5;
$dashboard_link = "";
$official_link = "";
$memberContext = null;
//Clear any previously stored value
//Unfortunately we don't store user personal details such as email in website's database
//so get them from SMF using user ID
foreach (MailManager::getAdminEmailList() as $user) {
    loadMemberData($user['ID_MEMBER']);
    loadMemberContext($user['ID_MEMBER']);
}
$subject = "There are " . $pending_addon_count . " addons require your approval!";
$message = file_get_contents($link['root'] . 'pages/mail_templates/pending.addon.dashboard.html');
//now loop through member data and put all the valid email in an array
foreach ($memberContext as $user) {
    //Make sure the emails are valid
    if (!filter_var($user['email'], FILTER_VALIDATE_EMAIL) === false) {
        $bindedvalarray = array("{username}" => $user['username'], "{pending_request_count}" => $pending_addon_count, "{dashboard_link}" => $link['addon']['dashboard'], "{official_link}" => $link['home'], "{subject}" => $subject);
        if (MailManager::sendMail($user['email'], $from, "UTF-8", "text/html", $subject, $message, $bindedvalarray)) {
            //put some logging function to monitor
            echo "Mail delivered to " . $user['username'] . "<br/>";
        } else {
            //put some logging function to monitor
            echo "Mail Could not be delivered";
        }
    }
}
exit;
Exemplo n.º 26
0
 /**
  * Used to create Documents
  * @global Users $current_user
  * @global PearDataBase $adb
  * @global String $currentModule
  */
 function createDocument()
 {
     global $current_user, $adb, $currentModule;
     if (!MailManager::checkModuleWriteAccessForCurrentUser('Documents')) {
         $errorMessage = getTranslatedString('LBL_WRITE_ACCESS_FOR', $currentModule) . " " . getTranslatedString('Documents') . " " . getTranslatedString('LBL_MODULE_DENIED', $currentModule);
         return array('success' => true, 'error' => $errorMessage);
     }
     require_once 'data/CRMEntity.php';
     $document = CRMEntity::getInstance('Documents');
     $attachid = $this->saveAttachment();
     if ($attachid !== false) {
         // Create document record
         $document = new Documents();
         $document->column_fields['notes_title'] = $this->getName();
         $document->column_fields['filename'] = $this->getName();
         $document->column_fields['filestatus'] = 1;
         $document->column_fields['filelocationtype'] = 'I';
         $document->column_fields['folderid'] = 1;
         $document->column_fields['filesize'] = $this->getSize();
         $document->column_fields['assigned_user_id'] = $current_user->id;
         $document->save('Documents');
         // Link file attached to document
         $adb->pquery("INSERT INTO vtiger_seattachmentsrel(crmid, attachmentsid) VALUES(?,?)", array($document->id, $attachid));
         return array('success' => true, 'docid' => $document->id, 'attachid' => $attachid);
     }
     return false;
 }
Exemplo n.º 27
0
 /**
  * Build notification list based on user preferences
  *
  * @param Array                  $addresses
  * @param String                 $subject
  * @param Codendi_Mail_Interface $text_mail
  * @param Codendi_Mail_Interface $html_mail
  */
 function sendNotification($addresses, $subject, $text_mail, $html_mail)
 {
     $html_addresses = array();
     $text_addresses = array();
     $mailMgr = new MailManager();
     $mailPrefs = $mailMgr->getMailPreferencesByEmail($addresses);
     foreach ($mailPrefs['html'] as $user) {
         $html_addresses[] = $user->getEmail();
     }
     foreach ($mailPrefs['text'] as $user) {
         $text_addresses[] = $user->getEmail();
     }
     $mail = null;
     if ($text_mail && count($text_addresses)) {
         $this->sendMail($text_mail, $subject, $text_addresses);
     }
     if ($html_mail && count($html_addresses)) {
         if ($text_mail) {
             $html_mail->setBodyText($text_mail->getBody());
         }
         $this->sendMail($html_mail, $subject, $html_addresses);
     }
 }
 /**
  * Build the reminder messages
  *
  * @param Tracker_DateReminder $reminder Reminder that will send notifications
  * @param Tracker_Artifact $artifact Artifact for which reminders will be sent
  * @param Array            $messages Messages
  * @param PFUser             $user     Receipient
  *
  * return Array
  */
 protected function buildMessage(Tracker_DateReminder $reminder, Tracker_Artifact $artifact, &$messages, $user)
 {
     $mailManager = new MailManager();
     $recipient = $user->getEmail();
     $lang = $user->getLanguage();
     $format = $mailManager->getMailPreferencesByUser($user);
     //We send multipart mail: html & text body in case of preferences set to html
     $htmlBody = '';
     if ($format == Codendi_Mail_Interface::FORMAT_HTML) {
         $htmlBody .= $this->getBodyHtml($reminder, $artifact, $user, $lang);
     }
     $txtBody = $this->getBodyText($reminder, $artifact, $user, $lang);
     $subject = $this->getSubject($reminder, $artifact, $user);
     $headers = array();
     $hash = md5($htmlBody . $txtBody . serialize($headers) . serialize($subject));
     if (isset($messages[$hash])) {
         $messages[$hash]['recipients'][] = $recipient;
     } else {
         $messages[$hash] = array('headers' => $headers, 'htmlBody' => $htmlBody, 'txtBody' => $txtBody, 'subject' => $subject, 'recipients' => array($recipient));
     }
 }
 private function getMessageContent($user, $is_update, $check_perms)
 {
     $ignore_perms = !$check_perms;
     $lang = $user->getLanguage();
     $mailManager = new MailManager();
     $format = $mailManager->getMailPreferencesByUser($user);
     $htmlBody = '';
     if ($format == Codendi_Mail_Interface::FORMAT_HTML) {
         $htmlBody .= $this->getBodyHtml($is_update, $user, $lang, $ignore_perms);
         $htmlBody .= $this->getHTMLAssignedToFilter($user);
     }
     $txtBody = $this->getBodyText($is_update, $user, $lang, $ignore_perms);
     $txtBody .= $this->getTextAssignedToFilter($user);
     $subject = $this->getSubject($user, $ignore_perms);
     $message = array();
     $message['htmlBody'] = $htmlBody;
     $message['txtBody'] = $txtBody;
     $message['subject'] = $subject;
     return $message;
 }
Exemplo n.º 30
0
function classLoad($myClass)
{
    if (file_exists('model/' . $myClass . '.php')) {
        include 'model/' . $myClass . '.php';
    } elseif (file_exists('controller/' . $myClass . '.php')) {
        include 'controller/' . $myClass . '.php';
    }
}
spl_autoload_register("classLoad");
include 'config.php';
//classes loading end
session_start();
if (isset($_SESSION['userMerlaTrav'])) {
    //classes managers
    $usersManager = new UserManager($pdo);
    $mailsManager = new MailManager($pdo);
    $notesClientsManager = new NotesClientManager($pdo);
    $projetManager = new ProjetManager($pdo);
    $contratManager = new ContratManager($pdo);
    $clientManager = new ClientManager($pdo);
    $livraisonsManager = new LivraisonManager($pdo);
    $fournisseursManager = new FournisseurManager($pdo);
    $caisseManager = new CaisseManager($pdo);
    $caisseIaazaManager = new CaisseIaazaManager($pdo);
    $operationsManager = new OperationManager($pdo);
    $compteBancaire = new CompteBancaireManager($pdo);
    //classes and vars
    //users number
    $soldeCaisseAnnahda = $caisseManager->getTotalCaisseByType("Entree") - $caisseManager->getTotalCaisseByType("Sortie");
    $soldeCaisseIaaza = $caisseIaazaManager->getTotalCaisseByType("Entree") - $caisseIaazaManager->getTotalCaisseByType("Sortie");
    $projetNumber = $projetManager->getProjetsNumber();