本文整理汇总了PHP中file_storage::load_data_bytype方法的典型用法代码示例。如果您正苦于以下问题:PHP file_storage::load_data_bytype方法的具体用法?PHP file_storage::load_data_bytype怎么用?PHP file_storage::load_data_bytype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file_storage
的用法示例。
在下文中一共展示了file_storage::load_data_bytype方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function prepare_add_file($fieldname, $file_extension, $file_type, $file_id)
{
log_debug("template_engine", "Executing prepare_add_file({$fieldname}, {$file_extension}, {$file_type}, {$file_id})");
$tmp_filename = file_generate_name("/tmp/{$fieldname}", $file_extension);
// output file data
$file_obj = new file_storage();
$file_obj->data["type"] = $file_type;
$file_obj->data["customid"] = $file_id;
if (!$file_obj->load_data_bytype()) {
log_write("error", "template_engine", "Unable to find company logo image - use the administration config page to upload a company logo");
return 0;
}
$file_obj->filedata_write($tmp_filename);
// work out the filename without path or extension
//
// we have to do this, since latex will not tolerate file extensions in the filename when
// the file is referenced in the tex data.
//
preg_match("/\\S*\\/(\\S*).{$file_extension}\$/", $tmp_filename, $matches);
$tmp_filename_short = $matches[1];
// map fieldname to filename
$this->data_files[$fieldname]["filename"] = $tmp_filename;
$this->data_files[$fieldname]["filename_short"] = $tmp_filename_short;
log_debug("template_engine", "Wrote tempory file {$tmp_filename} with shortname of {$tmp_filename_short}");
return 1;
}
示例2: files
function action_delete()
{
log_debug("journal_process", "Executing action_delete()");
/*
Start Transaction
*/
$sql_obj = new sql_query();
$sql_obj->trans_begin();
/*
Delete files (if applicable)
*/
if ($this->structure["type"] == "file") {
$file_obj = new file_storage();
$file_obj->data["type"] = "journal";
$file_obj->data["customid"] = $this->structure["id"];
$file_obj->load_data_bytype();
$file_obj->action_delete();
}
/*
Delete journal record
*/
$sql_obj->string = "DELETE FROM `journal` WHERE id='" . $this->structure["id"] . "' LIMIT 1";
$sql_obj->execute();
/*
Commit
*/
if (error_check()) {
log_write("error", "journal_process", "An error occured preventing the journal record from being deleted");
$sql_obj->trans_rollback();
return 0;
} else {
log_write("notification", "journal_process", "Journal record cleanly removed.");
$sql_obj->trans_commit();
return 1;
}
return 0;
}
示例3: array
function email_invoice($email_sender, $email_to, $email_cc, $email_bcc, $email_subject, $email_message)
{
log_debug("invoice", "Executing email_invoice([options])");
// external dependency of Mail_Mime
if (!@(include_once 'Mail.php')) {
log_write("error", "invoice", "Unable to find Mail module required for sending email");
return 0;
}
if (!@(include_once 'Mail/mime.php')) {
log_write("error", "invoice", "Unable to find Mail::Mime module required for sending email");
return 0;
}
// track attachment files to tidy up
$file_attachments = array();
/*
Prepare Email Mime Data & Headers
*/
// fetch sender address
//
// users have the choice of sending as the company or as their own staff email address & name.
//
if ($email_sender == "user") {
// send as the user
$email_sender = "\"" . user_information("realname") . "\" <" . user_information("contact_email") . ">";
} else {
// send as the system
$email_sender = "\"" . sql_get_singlevalue("SELECT value FROM config WHERE name='COMPANY_NAME'") . "\" <" . sql_get_singlevalue("SELECT value FROM config WHERE name='COMPANY_CONTACT_EMAIL'") . ">";
}
// prepare headers
$mail_headers = array('From' => $email_sender, 'Subject' => $email_subject, 'Cc' => $email_cc, 'Bcc' => $email_bcc);
$mail_mime = new Mail_mime("\n");
$mail_mime->setTXTBody($email_message);
/*
Generate a PDF of the invoice and save to tmp file
*/
log_debug("invoice", "Generating invoice PDF for emailing");
// generate PDF
$this->generate_pdf();
if (error_check()) {
return 0;
}
// save to a temporary file
if ($this->type == "ar") {
$tmp_file_invoice = file_generate_name($GLOBALS["config"]["PATH_TMPDIR"] . "/invoice_" . $this->data["code_invoice"] . "", "pdf");
} else {
$tmp_file_invoice = file_generate_name($GLOBALS["config"]["PATH_TMPDIR"] . "/quote_" . $this->data["code_quote"] . "", "pdf");
//$email_template = sql_get_singlevalue("SELECT value FROM config WHERE name IN('TEMPLATE_QUOTE_EMAIL') LIMIT 1");
}
if (!($fhandle = fopen($tmp_file_invoice, "w"))) {
log_write("error", "invoice", "A fatal error occured whilst writing invoice PDF to file {$tmp_file_invoice}, unable to send email");
return 0;
}
fwrite($fhandle, $this->obj_pdf->output);
fclose($fhandle);
// attach
$mail_mime->addAttachment($tmp_file_invoice, 'application/pdf');
$file_attachments[] = $tmp_file_invoice;
/*
Fetch Extra Attachments
Certain billing processes may add file attachments to the journal that should be sent along with the invoice
when an email is generated.
Here we grab those file attachments and send each one.
*/
$obj_sql_journal = new sql_query();
$obj_sql_journal->string = "SELECT id FROM journal WHERE journalname='account_ar' AND customid='" . $this->id . "' AND title LIKE 'SERVICE:%'";
$obj_sql_journal->execute();
if ($obj_sql_journal->num_rows()) {
$obj_sql_journal->fetch_array();
foreach ($obj_sql_journal->data as $data_journal) {
// there are journaled attachments to send
//
// we don't care about any of the journal data, we just need to pull the file attachment from
// storage, write to disk and then attach to the email
//
// fetch file object
$file_obj = new file_storage();
$file_obj->data["type"] = "journal";
$file_obj->data["customid"] = $data_journal["id"];
if (!$file_obj->load_data_bytype()) {
log_write("error", "inc_invoices", "Unable to load file from journal to attach to invoice email - possible file storage issue?");
return 0;
}
$file_extension = format_file_extension($file_obj->data["file_name"]);
$file_name = format_file_noextension($file_obj->data["file_name"]);
$file_ctype = format_file_contenttype($file_extension);
// we have to write the file to disk before attaching it
$tmp_file_attach = file_generate_name($GLOBALS["config"]["PATH_TMPDIR"] . "/" . $file_name, $file_extension);
if (!$file_obj->filedata_write($tmp_file_attach)) {
log_write("error", "inc_invoices", "Unable to write file attachments from journal to tmp space");
return 0;
}
// add to the invoice
$mail_mime->addAttachment($tmp_file_attach, $file_ctype);
$file_attachments[] = $tmp_file_attach;
// cleanup - tmp file will be removed ;ater
unset($file_obj);
}
// end of for each journal item
//.........这里部分代码省略.........
示例4: foreach
We have already loaded the data for all the fields, so simply need to go and set all the values
based on the naming of the $data array.
*/
foreach (array_keys($data) as $data_key) {
$sql_obj->string = "UPDATE config SET value='" . $data[$data_key] . "' WHERE name='{$data_key}' LIMIT 1";
$sql_obj->execute();
}
/*
Update the logo file if required
*/
if ($_FILES["COMPANY_LOGO"]["size"] > 1) {
// set file variables
$file_obj->data["type"] = "COMPANY_LOGO";
$file_obj->data["customid"] = "0";
// see if a file already exists
if ($file_obj->load_data_bytype()) {
log_debug("process", "Old file exists, will overwrite.");
} else {
log_debug("process", "No previous file exists, performing clean upload.");
}
// force the filename
$file_obj->data["file_name"] = "company_logo.png";
// call the upload function
if (!$file_obj->action_update_form("COMPANY_LOGO")) {
log_write("error", "process", "Unable to upload company logo");
}
}
/*
Commit
*/
if (error_check()) {