本文整理汇总了PHP中dol_mimetype函数的典型用法代码示例。如果您正苦于以下问题:PHP dol_mimetype函数的具体用法?PHP dol_mimetype怎么用?PHP dol_mimetype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dol_mimetype函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDocumentsLink
/**
* Show only Document icon with link
*
* @param string $modulepart propal, facture, facture_fourn, ...
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
* @param string $filedir Directory to scan
* @return string Output string with HTML link of documents (might be empty string)
*/
function getDocumentsLink($modulepart, $modulesubdir, $filedir)
{
if (!function_exists('dol_dir_list')) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
}
$out = '';
$this->numoffiles = 0;
$file_list = dol_dir_list($filedir, 'files', 0, preg_quote($modulesubdir . '.pdf', '/'), '\\.meta$|\\.png$');
// For ajax treatment
$out .= '<div id="gen_pdf_' . $modulesubdir . '" class="linkobject hideobject">' . img_picto('', 'refresh') . '</div>' . "\n";
if (!empty($file_list)) {
// Loop on each file found
foreach ($file_list as $file) {
// Define relative path for download link (depends on module)
$relativepath = $file["name"];
// Cas general
if ($modulesubdir) {
$relativepath = $modulesubdir . "/" . $file["name"];
}
// Cas propal, facture...
// Autre cas
if ($modulepart == 'donation') {
$relativepath = get_exdir($modulesubdir, 2) . $file["name"];
}
if ($modulepart == 'export') {
$relativepath = $file["name"];
}
// Show file name with link to download
$out .= '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . '"';
$mime = dol_mimetype($relativepath, '', 0);
if (preg_match('/text/', $mime)) {
$out .= ' target="_blank"';
}
$out .= '>';
$out .= img_pdf($file["name"], 2);
$out .= '</a>' . "\n";
$this->numoffiles++;
}
}
return $out;
}
示例2: img_mime
/**
* Show MIME img of a file
* @param file Filename
* @param alt Alternate text to show on img mous hover
* @return string Return img tag
*/
function img_mime($file, $alt = '')
{
require_once DOL_DOCUMENT_ROOT . '/lib/files.lib.php';
$mimetype = dol_mimetype($file, '', 1);
$mimeimg = dol_mimetype($file, '', 2);
if (empty($alt)) {
$alt = 'Mime type: ' . $mimetype;
}
return '<img src="' . DOL_URL_ROOT . '/theme/common/mime/' . $mimeimg . '" border="0" alt="' . $alt . '" title="' . $alt . '">';
}
示例3: send
/**
* Check if notification are active for couple action/company.
* If yes, send mail and save trace into llx_notify.
*
* @param string $notifcode Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* @param Object $object Object the notification deals on
* @return int <0 if KO, or number of changes if OK
*/
function send($notifcode, $object)
{
global $user, $conf, $langs, $mysoc, $dolibarr_main_url_root;
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
dol_syslog(get_class($this) . "::send notifcode=" . $notifcode . ", object=" . $object->id);
$langs->load("other");
// Define $urlwithroot
$urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
// This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Define some vars
$application = $mysoc->name;
//if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE;
$replyto = $conf->notification->email_from;
$filename = basename($file);
$mimefile = dol_mimetype($file);
$object_type = '';
$link = '';
$num = 0;
if (!in_array($notifcode, array('BILL_VALIDATE', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', 'FICHINTER_VALIDATE', 'ORDER_SUPPLIER_VALIDATE', 'ORDER_SUPPLIER_APPROVE', 'ORDER_SUPPLIER_REFUSE', 'SHIPPING_VALIDATE'))) {
return 0;
}
$oldref = empty($object->oldref) ? $object->ref : $object->oldref;
$newref = empty($object->newref) ? $object->ref : $object->newref;
// Check notification per third party
$sql = "SELECT s.nom, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
$sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type";
$sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as c,";
$sql .= " " . MAIN_DB_PREFIX . "c_action_trigger as a,";
$sql .= " " . MAIN_DB_PREFIX . "notify_def as n,";
$sql .= " " . MAIN_DB_PREFIX . "societe as s";
$sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
$sql .= " AND n.fk_soc = s.rowid";
if (is_numeric($notifcode)) {
$sql .= " AND n.fk_action = " . $notifcode;
} else {
$sql .= " AND a.code = '" . $notifcode . "'";
}
// New usage
$sql .= " AND s.rowid = " . $object->socid;
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
if ($num > 0) {
$i = 0;
while ($i < $num && !$error) {
$obj = $this->db->fetch_object($result);
$sendto = dolGetFirstLastname($obj->firstname, $obj->lastname) . " <" . $obj->email . ">";
$notifcodedefid = $obj->adid;
if (dol_strlen($obj->email)) {
// Set output language
$outputlangs = $langs;
if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($obj->default_lang);
}
switch ($notifcode) {
case 'BILL_VALIDATE':
$link = '/compta/facture.php?facid=' . $object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'facture';
$mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated", $newref);
break;
case 'ORDER_VALIDATE':
$link = '/commande/card.php?id=' . $object->id;
$dir_output = $conf->commande->dir_output;
$object_type = 'order';
$mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $newref);
break;
case 'PROPAL_VALIDATE':
$link = '/comm/propal.php?id=' . $object->id;
$dir_output = $conf->propal->dir_output;
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated", $newref);
break;
case 'FICHINTER_VALIDATE':
$link = '/fichinter/card.php?id=' . $object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $object->ref);
break;
case 'ORDER_SUPPLIER_VALIDATE':
$link = '/fourn/commande/card.php?id=' . $object->id;
$dir_output = $conf->fournisseur->dir_output . '/commande/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello") . ",\n\n";
$mesg .= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $object->ref, $user->getFullName($langs));
$mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
break;
case 'ORDER_SUPPLIER_APPROVE':
$link = '/fourn/commande/card.php?id=' . $object->id;
//.........这里部分代码省略.........
示例4: foreach
foreach ($contactarr as $contact) {
if ($contact['libelle'] == $langs->trans('TypeContact_facture_external_BILLING')) {
// TODO Use code and not label
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
$contactstatic = new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact = $contactstatic->getFullName($langs, 1);
}
}
if (!empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
}
}
// Tableau des parametres complementaires du post
$formmail->param['action'] = $action;
$formmail->param['models'] = $modelmail;
$formmail->param['models_id'] = GETPOST('modelmailselected', 'int');
$formmail->param['facid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
// Init list of files
if (GETPOST("mode") == 'init') {
$formmail->clear_attached_files();
$formmail->add_attached_files($file, basename($file), dol_mimetype($file));
}
print $formmail->get_form();
dol_fiche_end();
}
}
}
llxFooter();
$db->close();
示例5: showdocuments
//.........这里部分代码省略.........
$out .= ' ' . img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
}
$out .= '</th>';
$out .= '</tr>';
// Execute hooks
$parameters = array('socid' => isset($GLOBALS['socid']) ? $GLOBALS['socid'] : '', 'id' => isset($GLOBALS['id']) ? $GLOBALS['id'] : '', 'modulepart' => $modulepart);
if (is_object($hookmanager)) {
$out .= $hookmanager->executeHooks('formBuilddocOptions', $parameters, $GLOBALS['object']);
}
}
// Get list of files
if ($filedir) {
$png = '';
$filter = '';
if ($iconPDF == 1) {
$png = '\\.png$';
$filter = $filename . '.pdf';
}
$file_list = dol_dir_list($filedir, 'files', 0, $filter, '\\.meta$' . ($png ? '|' . $png : ''), 'date', SORT_DESC);
// Affiche en-tete tableau si non deja affiche
if (!empty($file_list) && !$headershown && !$iconPDF) {
$headershown = 1;
$out .= '<div class="titre">' . $titletoshow . '</div>';
$out .= '<table class="border" summary="listofdocumentstable" width="100%">';
} else {
if (empty($file_list) && !empty($iconPDF)) {
// For ajax treatment
$out .= '<div id="gen_pdf_' . $filename . '" class="linkobject hideobject">' . img_picto('', 'refresh') . '</div>' . "\n";
}
}
// Loop on each file found
foreach ($file_list as $file) {
$var = !$var;
// Define relative path for download link (depends on module)
$relativepath = $file["name"];
// Cas general
if ($filename) {
$relativepath = $filename . "/" . $file["name"];
}
// Cas propal, facture...
// Autre cas
if ($modulepart == 'donation') {
$relativepath = get_exdir($filename, 2) . $file["name"];
}
if ($modulepart == 'export') {
$relativepath = $file["name"];
}
if (!$iconPDF) {
$out .= "<tr " . $bc[$var] . ">";
}
// Show file name with link to download
if (!$iconPDF) {
$out .= '<td nowrap="nowrap">';
}
$out .= '<a href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . '"';
$mime = dol_mimetype($relativepath, '', 0);
if (preg_match('/text/', $mime)) {
$out .= ' target="_blank"';
}
$out .= '>';
if (!$iconPDF) {
$out .= img_mime($file["name"], $langs->trans("File") . ': ' . $file["name"]) . ' ' . dol_trunc($file["name"], $maxfilenamelength);
} else {
$out .= img_pdf($file["name"], 2);
}
$out .= '</a>' . "\n";
if (!$iconPDF) {
$out .= '</td>';
// Show file size
$out .= '<td align="right" nowrap="nowrap">' . dol_print_size(dol_filesize($filedir . "/" . $file["name"])) . '</td>';
// Show file date
$out .= '<td align="right" nowrap="nowrap">' . dol_print_date(dol_filemtime($filedir . "/" . $file["name"]), 'dayhour') . '</td>';
}
if ($delallowed) {
$out .= '<td align="right">';
//$out.= '<a href="'.DOL_URL_ROOT.'/document.php?action=remove_file&modulepart='.$modulepart.'&file='.urlencode($relativepath);
$out .= '<a href="' . $urlsource . '&action=remove_file&modulepart=' . $modulepart . '&file=' . urlencode($relativepath);
$out .= $param ? '&' . $param : '';
$out .= '&urlsource=' . urlencode($urlsource);
$out .= '">' . img_delete() . '</a></td>';
}
if (!$iconPDF) {
$out .= '</tr>';
}
$this->numoffiles++;
}
}
if ($headershown) {
// Affiche pied du tableau
$out .= "</table>\n";
if ($genallowed) {
if (empty($noform)) {
$out .= '</form>' . "\n";
}
}
}
$out .= '<!-- End show_document -->' . "\n";
//return ($i?$i:$headershown);
return $out;
}
示例6: write_file
//.........这里部分代码省略.........
}
$this->type = 'pdf';
// standard format or custom
if ($this->Tformat['paper-size'] != 'custom') {
$this->format = $this->Tformat['paper-size'];
} else {
//custom
$resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
$this->format = $resolution;
}
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("admin");
$title = $outputlangs->transnoentities('Labels');
$keywords = $title . " " . $outputlangs->convToOutputCharset($mysoc->name);
$dir = empty($outputdir) ? $conf->adherent->dir_temp : $outputdir;
$file = $dir . "/" . $filename;
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
}
$pdf = pdf_getInstance($this->format, $this->Tformat['metric'], $this->Tformat['orientation']);
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
$pdf->SetTitle($title);
$pdf->SetSubject($title);
$pdf->SetCreator("Dolibarr " . DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($keywords);
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
$pdf->SetCompression(false);
}
$pdf->SetMargins(0, 0);
$pdf->SetAutoPageBreak(false);
$this->_Metric_Doc = $this->Tformat['metric'];
// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
$posX = 1;
$posY = 1;
if ($posX > 0) {
$posX--;
} else {
$posX = 0;
}
if ($posY > 0) {
$posY--;
} else {
$posY = 0;
}
$this->_COUNTX = $posX;
$this->_COUNTY = $posY;
$this->_Set_Format($pdf, $this->Tformat);
$pdf->Open();
$pdf->AddPage();
// Add each record
foreach ($arrayofrecords as $val) {
// imprime le texte specifique sur la carte
$this->addSticker($pdf, $outputlangs, $val);
}
//$pdf->SetXY(10, 295);
//$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
// Output to file
$pdf->Output($file, 'F');
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($file, octdec($conf->global->MAIN_UMASK));
}
// Output to http stream
clearstatcache();
$attachment = true;
if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) {
$attachment = false;
}
$type = dol_mimetype($filename);
//if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) {
header('Content-Type: ' . $type);
}
if ($attachment) {
header('Content-Disposition: attachment; filename="' . $filename . '"');
} else {
header('Content-Disposition: inline; filename="' . $filename . '"');
}
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
readfile($file);
return 1;
}
示例7: getDocumentsLink
/**
* Show only Document icon with link
*
* @param string $modulepart propal, facture, facture_fourn, ...
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
* @param string $filedir Directory to scan
* @param string $filter Filter filenames on this regex string (Example: '\.pdf$')
* @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles
*/
function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '')
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$out = '';
$this->infofiles = array('nboffiles' => 0, 'extensions' => array(), 'files' => array());
$file_list = dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir), '/') . '[^\\-]+', '\\.meta$|\\.png$');
// Get list of files starting with name fo ref (but not followed by "-" to discard uploaded files)
// For ajax treatment
$out .= '<div id="gen_pdf_' . $modulesubdir . '" class="linkobject hideobject">' . img_picto('', 'refresh') . '</div>' . "\n";
if (!empty($file_list)) {
// Loop on each file found
foreach ($file_list as $file) {
if ($filter && !preg_match('/' . $filter . '/i', $file["name"])) {
continue;
}
// Discard this. It does not match provided filter.
// Define relative path for download link (depends on module)
$relativepath = $file["name"];
// Cas general
if ($modulesubdir) {
$relativepath = $modulesubdir . "/" . $file["name"];
}
// Cas propal, facture...
// Autre cas
if ($modulepart == 'donation') {
$relativepath = get_exdir($modulesubdir, 2, 0, 0, null, 'donation') . $file["name"];
}
if ($modulepart == 'export') {
$relativepath = $file["name"];
}
if ($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_fournisseur') {
$relativepath = get_exdir($modulesubdir, 2, 0, 0, null, 'invoice_supplier') . $modulesubdir . "/" . $file["name"];
}
// Show file name with link to download
$out .= '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . '"';
$mime = dol_mimetype($relativepath, '', 0);
if (preg_match('/text/', $mime)) {
$out .= ' target="_blank"';
}
$out .= '>';
$out .= img_mime($relativepath, $file["name"]);
$out .= '</a>' . "\n";
$this->infofiles['nboffiles']++;
$this->infofiles['files'][] = $file['fullname'];
$ext = pathinfo($file["name"], PATHINFO_EXTENSION);
if (empty($this->infofiles[$ext])) {
$this->infofiles['extensions'][$ext] = 1;
} else {
$this->infofiles['extensions'][$ext]++;
}
}
}
return $out;
}
示例8: getDocument
/**
* Method to get a document by webservice
*
* @param array $authentication Array with permissions
* @param string $modulepart Properties of document
* @param string $file Relative path
* @param string $refname Ref of object to check permission for external users (autodetect if not provided)
* @return void
*/
function getDocument($authentication, $modulepart, $file, $refname = '')
{
global $db, $conf, $langs, $mysoc;
dol_syslog("Function: getDocument login=" . $authentication['login'] . ' - modulepart=' . $modulepart . ' - file=' . $file);
if ($authentication['entity']) {
$conf->entity = $authentication['entity'];
}
$objectresp = array();
$errorcode = '';
$errorlabel = '';
$error = 0;
// Properties of doc
$original_file = $file;
$type = dol_mimetype($original_file);
//$relativefilepath = $ref . "/";
//$relativepath = $relativefilepath . $ref.'.pdf';
$accessallowed = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if ($fuser->societe_id) {
$socid = $fuser->societe_id;
}
// Check parameters
if (!$error && (!$file || !$modulepart)) {
$error++;
$errorcode = 'BAD_PARAMETERS';
$errorlabel = "Parameter file and modulepart must be both provided.";
}
if (!$error) {
$fuser->getrights();
// Suppression de la chaine de caractere ../ dans $original_file
$original_file = str_replace("../", "/", $original_file);
// find the subdirectory name as the reference
if (empty($refname)) {
$refname = basename(dirname($original_file) . "/");
}
// Security check
$check_access = dol_check_secure_access_document($modulepart, $original_file, $conf->entity, $fuser, $refname);
$accessallowed = $check_access['accessallowed'];
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
$original_file = $check_access['original_file'];
// Basic protection (against external users only)
if ($fuser->societe_id > 0) {
if ($sqlprotectagainstexternals) {
$resql = $db->query($sqlprotectagainstexternals);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($fuser->societe_id != $obj->fk_soc) {
$accessallowed = 0;
break;
}
$i++;
}
}
}
}
// Security:
// Limite acces si droits non corrects
if (!$accessallowed) {
$errorcode = 'NOT_PERMITTED';
$errorlabel = 'Access not allowed';
$error++;
}
// Security:
// On interdit les remontees de repertoire ainsi que les pipe dans
// les noms de fichiers.
if (preg_match('/\\.\\./', $original_file) || preg_match('/[<>|]/', $original_file)) {
dol_syslog("Refused to deliver file " . $original_file);
$errorcode = 'REFUSED';
$errorlabel = '';
$error++;
}
clearstatcache();
if (!$error) {
if (file_exists($original_file)) {
dol_syslog("Function: getDocument {$original_file} {$filename} content-type={$type}");
$file = $fileparams['fullname'];
$filename = basename($file);
$f = fopen($original_file, 'r');
$content_file = fread($f, filesize($original_file));
$objectret = array('filename' => basename($original_file), 'mimetype' => dol_mimetype($original_file), 'content' => base64_encode($content_file), 'length' => filesize($original_file));
// Create return object
$objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'document' => $objectret);
} else {
dol_syslog("File doesn't exist " . $original_file);
$errorcode = 'NOT_FOUND';
$errorlabel = '';
$error++;
}
//.........这里部分代码省略.........
示例9: sendOrderByMail
/**
*
* @param unknown $object
*/
static function sendOrderByMail(&$object)
{
global $conf, $langs, $user, $db;
if (empty($object->thirdparty)) {
$object->fetch_thirdparty();
}
$sendto = $object->thirdparty->email;
$sendtocc = '';
$from = empty($user->email) ? $conf->global->MAIN_MAIL_EMAIL_FROM : $user->email;
$id = $object->id;
$_POST['receiver'] = '-1';
$_POST['frommail'] = $_POST['replytomail'] = $from;
$_POST['fromname'] = $_POST['replytoname'] = $user->getFullName($langs);
dol_include_once('/core/class/html.formmail.class.php');
$formmail = new Formmail($db);
$outputlangs = clone $langs;
$id_template = (int) $conf->global->GRAPEFRUIT_SEND_BILL_BY_MAIL_ON_VALIDATE_MODEL;
$formmail->fetchAllEMailTemplate('facture_send', $user, $outputlangs);
foreach ($formmail->lines_model as &$model) {
if ($model->id == $id_template) {
break;
}
}
if (empty($model)) {
setEventMessage($langs->trans('ModelRequire'), 'errors');
}
// Make substitution
$substit['__REF__'] = $object->ref;
$substit['__SIGNATURE__'] = $user->signature;
$substit['__REFCLIENT__'] = $object->ref_client;
$substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name;
$substit['__PROJECT_REF__'] = is_object($object->projet) ? $object->projet->ref : '';
$substit['__PROJECT_NAME__'] = is_object($object->projet) ? $object->projet->title : '';
$substit['__PERSONALIZED__'] = '';
$substit['__CONTACTCIVNAME__'] = '';
// Find the good contact adress
$custcontact = '';
$contactarr = array();
$contactarr = $object->liste_contact(-1, 'external');
if (is_array($contactarr) && count($contactarr) > 0) {
foreach ($contactarr as $contact) {
dol_syslog(get_class($this) . '::' . __METHOD__ . ' lib=' . $contact['libelle']);
dol_syslog(get_class($this) . '::' . __METHOD__ . ' trans=' . $langs->trans('TypeContact_commande_external_BILLING'));
if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_BILLING')) {
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
$contactstatic = new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact = $contactstatic->getFullName($langs, 1);
dol_syslog(get_class($this) . '::' . __METHOD__ . ' email=' . $contactstatic->email);
}
}
if (!empty($custcontact)) {
$substit['__CONTACTCIVNAME__'] = $custcontact;
}
if (!empty($contactstatic->email)) {
$sendto = $contactstatic->email;
}
}
$topic = make_substitutions($model->topic, $substit);
$message = make_substitutions($model->content, $substit);
$_POST['message'] = $message;
$_POST['subject'] = $topic;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
// Add attached files
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $object->ref, preg_quote($object->ref, '/') . '[^\\-]+');
if (is_array($fileparams) && array_key_exists('fullname', $fileparams) && !empty($fileparams['fullname'])) {
$_SESSION["listofpaths"] = $fileparams['fullname'];
$_SESSION["listofnames"] = basename($fileparams['fullname']);
$_SESSION["listofmimes"] = dol_mimetype($fileparams['fullname']);
} else {
// generate invoice
$result = $object->generateDocument($object->modelpdf, $outputlangs, 0, 0, 0);
if ($result <= 0) {
$this->error = $object->error;
}
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $object->ref, preg_quote($object->ref, '/') . '[^\\-]+');
if (is_array($fileparams) && array_key_exists('fullname', $fileparams) && !empty($fileparams['fullname'])) {
$_SESSION["listofpaths"] = $fileparams['fullname'];
$_SESSION["listofnames"] = basename($fileparams['fullname']);
$_SESSION["listofmimes"] = dol_mimetype($fileparams['fullname']);
}
}
$action = 'send';
$actiontypecode = 'AC_FAC';
$trigger_name = 'BILL_SENTBYMAIL';
$paramname = 'id';
$mode = 'emailfrominvoice';
if (!empty($sendto)) {
require_once __DIR__ . '/../tpl/actions_sendmails.inc.php';
}
}
示例10: _sendByMail
function _sendByMail(&$db, &$conf, &$user, &$langs, &$facture, &$societe, $label)
{
$filename_list = array();
$mimetype_list = array();
$mimefilename_list = array();
$ref = dol_sanitizeFileName($facture->ref);
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/') . '([^\\-])+');
$file = $fileparams['fullname'];
// Build document if it not exists
if (!$file || !is_readable($file)) {
$result = $facture->generateDocument($facture->modelpdf, $langs, 0, 0, 0);
if ($result <= 0) {
$error = 1;
return $error;
}
}
$label = !empty($conf->global->SENDINVOICETOADHERENT_SUBJECT) ? $conf->global->SENDINVOICETOADHERENT_SUBJECT : $label;
$substitutionarray = array('__NAME__' => $societe->name, '__REF__' => $facture->ref);
$message = $conf->global->SENDINVOICETOADHERENT_MESSAGE;
$message = make_substitutions($message, $substitutionarray);
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/') . '([^\\-])+');
$file = $fileparams['fullname'];
$filename = basename($file);
$mimefile = dol_mimetype($file);
$filename_list[] = $file;
$mimetype_list[] = $mimefile;
$mimefilename_list[] = $filename;
$CMail = new CMailFile($label, $societe->email, $conf->global->MAIN_MAIL_EMAIL_FROM, $message, $filename_list, $mimetype_list, $mimefilename_list, '', '', '', '', $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO);
// Send mail
return $CMail->sendfile();
}
开发者ID:ATM-Consulting,项目名称:dolibarr_module_sendinvoicetoadherent,代码行数:31,代码来源:sendinvoicetoadherent.php
示例11: img_mime
/**
* Show MIME img of a file
*
* @param string $file Filename
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
* @return string Return img tag
*/
function img_mime($file, $titlealt = '')
{
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$mimetype = dol_mimetype($file, '', 1);
$mimeimg = dol_mimetype($file, '', 2);
if (empty($titlealt)) {
$titlealt = 'Mime type: ' . $mimetype;
}
return img_picto_common($titlealt, 'mime/' . $mimeimg);
}
示例12: Import
}
$filename = $langs->trans("ExampleOfImportFile") . '_' . $datatoimport . '.' . $format;
$objimport = new Import($db);
$objimport->load_arrays($user, $datatoimport);
// Load arrays from descriptor module
$entity = $objimport->array_import_entities[0][$code];
$entityicon = $entitytoicon[$entity] ? $entitytoicon[$entity] : $entity;
$entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $entity;
$fieldstarget = $objimport->array_import_fields[0];
$valuestarget = $objimport->array_import_examplevalues[0];
$attachment = true;
if (isset($_GET["attachment"])) {
$attachment = $_GET["attachment"];
}
//$attachment = false;
$contenttype = dol_mimetype($format);
if (isset($_GET["contenttype"])) {
$contenttype = $_GET["contenttype"];
}
//$contenttype='text/plain';
$outputencoding = 'UTF-8';
if ($contenttype) {
header('Content-Type: ' . $contenttype . ($outputencoding ? '; charset=' . $outputencoding : ''));
}
if ($attachment) {
header('Content-Disposition: attachment; filename="' . $filename . '"');
}
// List of targets fields
$headerlinefields = array();
$contentlinevalues = array();
$i = 0;
示例13: dol_init_file_process
/**
* Init $_SESSION with uploaded files
*
* @param string $pathtoscan Path to scan
* @return void
*/
function dol_init_file_process($pathtoscan = '')
{
$listofpaths = array();
$listofnames = array();
$listofmimes = array();
if ($pathtoscan) {
$listoffiles = dol_dir_list($pathtoscan, 'files');
foreach ($listoffiles as $key => $val) {
$listofpaths[] = $val['fullname'];
$listofnames[] = $val['name'];
$listofmimes[] = dol_mimetype($val['name']);
}
}
$_SESSION["listofpaths"] = join(';', $listofpaths);
$_SESSION["listofnames"] = join(';', $listofnames);
$_SESSION["listofmimes"] = join(';', $listofmimes);
}
示例14: testDolMimeType
/**
* testDolMimeType
*
* @return string
*/
public function testDolMimeType()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
// file.png
$result=dol_mimetype('file.png','',0);
$this->assertEquals('image/png',$result);
$result=dol_mimetype('file.png','',1);
$this->assertEquals('png',$result);
$result=dol_mimetype('file.png','',2);
$this->assertEquals('image.png',$result);
$result=dol_mimetype('file.png','',3);
$this->assertEquals('',$result);
// file.odt
$result=dol_mimetype('file.odt','',0);
$this->assertEquals('application/vnd.oasis.opendocument.text',$result);
$result=dol_mimetype('file.odt','',1);
$this->assertEquals('vnd.oasis.opendocument.text',$result);
$result=dol_mimetype('file.odt','',2);
$this->assertEquals('ooffice.png',$result);
$result=dol_mimetype('file.odt','',3);
$this->assertEquals('',$result);
// file.php
$result=dol_mimetype('file.php','',0);
$this->assertEquals('text/plain',$result);
$result=dol_mimetype('file.php','',1);
$this->assertEquals('plain',$result);
$result=dol_mimetype('file.php','',2);
$this->assertEquals('php.png',$result);
$result=dol_mimetype('file.php','',3);
$this->assertEquals('php',$result);
// file.php.noexe
$result=dol_mimetype('file.php.noexe','',0);
$this->assertEquals('text/plain',$result);
}
示例15: handleFileUpload
/**
* Enter description here ...
*
* @param string $uploaded_file Uploade file
* @param string $name Name
* @param int $size Size
* @param string $type Type
* @param string $error Error
* @param string $index Index
* @return stdClass
*/
protected function handleFileUpload($uploaded_file, $name, $size, $type, $error, $index)
{
$file = new stdClass();
$file->name = $this->trimFileName($name, $type, $index);
$file->mime = dol_mimetype($file->name, '', 2);
$file->size = intval($size);
$file->type = $type;
if ($this->validate($uploaded_file, $file, $error, $index) && dol_mkdir($this->options['upload_dir']) >= 0) {
$file_path = $this->options['upload_dir'] . $file->name;
$append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
clearstatcache();
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
// multipart/formdata uploads (POST method uploads)
if ($append_file) {
file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND);
} else {
dol_move_uploaded_file($uploaded_file, $file_path, 1, 0, 0, 0, 'userfile');
}
} else {
// Non-multipart uploads (PUT method support)
file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
}
$file_size = filesize($file_path);
if ($file_size === $file->size) {
$file->url = $this->options['upload_url'] . rawurlencode($file->name);
foreach ($this->options['image_versions'] as $version => $options) {
if ($this->createScaledImage($file->name, $options)) {
$tmp = explode('.', $file->name);
$file->{$version . '_url'} = $options['upload_url'] . rawurlencode($tmp[0] . '_mini.' . $tmp[1]);
}
}
} else {
if ($this->options['discard_aborted_uploads']) {
unlink($file_path);
$file->error = 'abort';
}
}
$file->size = $file_size;
$this->setFileDeleteUrl($file);
}
return $file;
}