Пример #1
0
 public static function get_ads_by_posidiont_identify($identify, $allow_cache = true)
 {
     if (isset(Yii::app()->cache) && $allow_cache) {
         //
         $_cache_key = md5("game.ad.data.identify.{$identify}");
         $_r = json_decode(Yii::app()->cache->get($_cache_key), true);
         if (!empty($_r) && is_array($_r)) {
             return $_r;
         }
     }
     $_sql = "SELECT ad.*, ap.ad_position_relative_type FROM {{ad_position}} ap\n\t\t\t\tINNER JOIN {{ad_data}} ad ON ad.ad_position_id=ap.ad_position_id\n\t\t\t\tWHERE ad.ad_data_status=:ad_data_status AND ap.ad_position_identify = :ad_position_identify AND ad.ad_data_is_show=:ad_data_is_show\n\t\t\t\tORDER BY ap.ad_position_rank, ad.ad_data_rank ASC";
     $_cmd = Yii::app()->db->createCommand($_sql);
     $_cmd->bindValue(':ad_data_status', self::STAT_NORMAL, PDO::PARAM_INT);
     $_cmd->bindValue(':ad_position_identify', $identify, PDO::PARAM_STR);
     $_cmd->bindValue(':ad_data_is_show', 1, PDO::PARAM_INT);
     $_r = $_cmd->queryAll();
     foreach ($_r as $_k => $_v) {
         if ($_v['ad_position_relative_type'] == 'archives') {
             $_r[$_k] += ContentArchives::get_archive_by_id($_v['ad_data_relative_id']);
             if ($_v['ad_data_subject'] == '') {
                 $_r[$_k]['ad_data_subject'] = $_r[$_k]['content_archives_subject'];
             }
             if ($_v['ad_data_link'] == '') {
                 $_r[$_k]['ad_data_link'] = Common::sign_archives_url($_v['ad_data_relative_id']);
             }
         }
         if ($_v['ad_data_image_md5'] != '') {
             $_r[$_k]['image'] = UploadFile::get_file_path($_v['ad_data_image_md5'], 'ad/images');
         }
         if ($_v['ad_data_flash_md5'] != '') {
             $_r[$_k]['flash'] = UploadFile::get_file_path($_v['ad_data_flash_md5'], 'ad/flash');
         }
     }
     if (!empty($_r) && isset(Yii::app()->cache) && $allow_cache) {
         //
         Yii::app()->cache->set($_cache_key, json_encode($_r));
     }
     return $_r;
 }
Пример #2
0
 /**
  * @param notes	array of note beans
  */
 function handleAttachments($notes)
 {
     global $sugar_config;
     //replace references to cache/images with cid tag
     $this->Body = str_replace($GLOBALS['sugar_config']['cache_dir'] . 'images/', 'cid:', $this->Body);
     if (empty($notes)) {
         return;
     }
     // cn: bug 4864 - reusing same SugarPHPMailer class, need to clear attachments
     $this->ClearAttachments();
     require_once 'include/upload_file.php';
     $fileBasePath = "{$sugar_config['upload_dir']}";
     $filePatternSearch = "{$sugar_config['upload_dir']}";
     $filePatternSearch = str_replace("/", "\\/", $filePatternSearch);
     if (strpos($this->Body, "\"{$fileBasePath}")) {
         $matches = array();
         preg_match_all("/{$filePatternSearch}.+?\"/i", $this->Body, $matches);
         foreach ($matches[0] as $match) {
             $filename = str_replace($fileBasePath, '', $match);
             $filename = urldecode(substr($filename, 0, -1));
             $cid = $filename;
             $file_location = clean_path(getcwd() . "/{$sugar_config['upload_dir']}{$filename}");
             $mime_type = "image/" . strtolower(substr($filename, strrpos($filename, ".") + 1, strlen($filename)));
             if (file_exists($file_location)) {
                 $this->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type);
             }
         }
         //replace references to cache with cid tag
         $this->Body = str_replace($fileBasePath, 'cid:', $this->Body);
     }
     foreach ($notes as $note) {
         $mime_type = 'text/plain';
         $file_location = '';
         $filename = '';
         if ($note->object_name == 'Note') {
             if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
                 $file_location = $note->file->temp_file_location;
                 $filename = $note->file->original_file_name;
                 $mime_type = $note->file->mime_type;
             } else {
                 $file_location = rawurldecode(UploadFile::get_file_path($note->filename, $note->id));
                 $filename = $note->id . $note->filename;
                 $mime_type = $note->file_mime_type;
             }
         } elseif ($note->object_name == 'DocumentRevision') {
             // from Documents
             $filename = $note->id . $note->filename;
             $file_location = getcwd() . '/' . $GLOBALS['sugar_config']['upload_dir'] . $filename;
             $mime_type = $note->file_mime_type;
         }
         $filename = substr($filename, 36, strlen($filename));
         // strip GUID	for PHPMailer class to name outbound file
         if (!$note->embed_flag) {
             $this->AddAttachment($file_location, $filename, 'base64', $mime_type);
         }
         // else
     }
 }
Пример #3
0
 /**
  * Sends Email
  * @return bool True on success
  */
 function send()
 {
     global $mod_strings, $app_strings;
     global $current_user;
     global $sugar_config;
     global $locale;
     $OBCharset = $locale->getPrecedentPreference('default_email_charset');
     $mail = new SugarPHPMailer();
     foreach ($this->to_addrs_arr as $addr_arr) {
         if (empty($addr_arr['display'])) {
             $mail->AddAddress($addr_arr['email'], "");
         } else {
             $mail->AddAddress($addr_arr['email'], $locale->translateCharsetMIME(trim($addr_arr['display']), 'UTF-8', $OBCharset));
         }
     }
     foreach ($this->cc_addrs_arr as $addr_arr) {
         if (empty($addr_arr['display'])) {
             $mail->AddCC($addr_arr['email'], "");
         } else {
             $mail->AddCC($addr_arr['email'], $locale->translateCharsetMIME(trim($addr_arr['display']), 'UTF-8', $OBCharset));
         }
     }
     foreach ($this->bcc_addrs_arr as $addr_arr) {
         if (empty($addr_arr['display'])) {
             $mail->AddBCC($addr_arr['email'], "");
         } else {
             $mail->AddBCC($addr_arr['email'], $locale->translateCharsetMIME(trim($addr_arr['display']), 'UTF-8', $OBCharset));
         }
     }
     $mail = $this->setMailer($mail);
     // FROM ADDRESS
     if (!empty($this->from_addr)) {
         $mail->From = $this->from_addr;
     } else {
         $mail->From = $current_user->getPreference('mail_fromaddress');
         $this->from_addr = $mail->From;
     }
     // FROM NAME
     if (!empty($this->from_name)) {
         $mail->FromName = $this->from_name;
     } else {
         $mail->FromName = $current_user->getPreference('mail_fromname');
         $this->from_name = $mail->FromName;
     }
     //Reply to information for case create and autoreply.
     if (!empty($this->reply_to_name)) {
         $ReplyToName = $this->reply_to_name;
     } else {
         $ReplyToName = $mail->FromName;
     }
     if (!empty($this->reply_to_addr)) {
         $ReplyToAddr = $this->reply_to_addr;
     } else {
         $ReplyToAddr = $mail->From;
     }
     $mail->Sender = $mail->From;
     /* set Return-Path field in header to reduce spam score in emails sent via Sugar's Email module */
     $mail->AddReplyTo($ReplyToAddr, $locale->translateCharsetMIME(trim($ReplyToName), 'UTF-8', $OBCharset));
     //$mail->Subject = html_entity_decode($this->name, ENT_QUOTES, 'UTF-8');
     $mail->Subject = $this->name;
     ///////////////////////////////////////////////////////////////////////
     ////	ATTACHMENTS
     foreach ($this->saved_attachments as $note) {
         $mime_type = 'text/plain';
         if ($note->object_name == 'Note') {
             if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
                 // brandy-new file upload/attachment
                 $file_location = $sugar_config['upload_dir'] . $note->id;
                 $filename = $note->file->original_file_name;
                 $mime_type = $note->file->mime_type;
             } else {
                 // attachment coming from template/forward
                 $file_location = rawurldecode(UploadFile::get_file_path($note->filename, $note->id));
                 // cn: bug 9723 - documents from EmailTemplates sent with Doc Name, not file name.
                 $filename = !empty($note->filename) ? $note->filename : $note->name;
                 $mime_type = $note->file_mime_type;
             }
         } elseif ($note->object_name == 'DocumentRevision') {
             // from Documents
             $filePathName = $note->id;
             // cn: bug 9723 - Emails with documents send GUID instead of Doc name
             $filename = $note->getDocumentRevisionNameForDisplay();
             $file_location = getcwd() . '/' . $GLOBALS['sugar_config']['upload_dir'] . $filePathName;
             $mime_type = $note->file_mime_type;
         }
         // strip out the "Email attachment label if exists
         $filename = str_replace($mod_strings['LBL_EMAIL_ATTACHMENT'] . ': ', '', $filename);
         //is attachment in our list of bad files extensions?  If so, append .txt to file location
         //get position of last "." in file name
         $file_ext_beg = strrpos($file_location, ".");
         $file_ext = "";
         //get file extension
         if ($file_ext_beg > 0) {
             $file_ext = substr($file_location, $file_ext_beg + 1);
         }
         //check to see if this is a file with extension located in "badext"
         foreach ($sugar_config['upload_badext'] as $badExt) {
             if (strtolower($file_ext) == strtolower($badExt)) {
                 //if found, then append with .txt to filename and break out of lookup
                 //this will make sure that the file goes out with right extension, but is stored
                 //as a text in db.
                 $file_location = $file_location . ".txt";
                 break;
                 // no need to look for more
             }
         }
         $mail->AddAttachment($file_location, $locale->translateCharsetMIME(trim($filename), 'UTF-8', $OBCharset), 'base64', $mime_type);
         // embedded Images
         if ($note->embed_flag == true) {
             $cid = $filename;
             $mail->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type);
         }
     }
     ////	END ATTACHMENTS
     ///////////////////////////////////////////////////////////////////////
     $mail = $this->handleBody($mail);
     $GLOBALS['log']->debug('Email sending --------------------- ');
     ///////////////////////////////////////////////////////////////////////
     ////	I18N TRANSLATION
     $mail->prepForOutbound();
     ////	END I18N TRANSLATION
     ///////////////////////////////////////////////////////////////////////
     if ($mail->Send()) {
         ///////////////////////////////////////////////////////////////////
         ////	INBOUND EMAIL HANDLING
         // mark replied
         if (!empty($_REQUEST['inbound_email_id'])) {
             $ieMail = new Email();
             $ieMail->retrieve($_REQUEST['inbound_email_id']);
             $ieMail->status = 'replied';
             $ieMail->save();
         }
         $GLOBALS['log']->debug(' --------------------- buh bye -- sent successful');
         ////	END INBOUND EMAIL HANDLING
         ///////////////////////////////////////////////////////////////////
         return true;
     }
     $GLOBALS['log']->debug($app_strings['LBL_EMAIL_ERROR_PREPEND'] . $mail->ErrorInfo);
     return false;
 }
}
$xtpl->assign("CREATED_BY", $focus->created_by_name);
$xtpl->assign("MODIFIED_BY", $focus->modified_by_name);
$xtpl->assign("PARENT_NAME", $focus->parent_name);
$xtpl->assign("PARENT_ID", $focus->parent_id);
$xtpl->assign("NAME", $focus->name);
$xtpl->assign("DATE_MODIFIED", $focus->date_modified);
$xtpl->assign("DATE_ENTERED", $focus->date_entered);
global $current_user;
if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
    $xtpl->assign("ADMIN_EDIT", "<a href='index.php?action=index&module=DynamicLayout&from_action=" . $_REQUEST['action'] . "&from_module=" . $_REQUEST['module'] . "&record=" . $_REQUEST['record'] . "'>" . get_image($image_path . "EditLayout", "border='0' alt='Edit Layout' align='bottom'") . "</a>");
}
if (isset($focus->filename) && $focus->filename != '') {
    global $sugar_config;
    $save_file = urlencode(basename(UploadFile::get_url($focus->filename, $focus->id)));
    $file_path = UploadFile::get_file_path($focus->filename, $focus->id);
    $display = false;
    if (file_exists($file_path)) {
        $display = true;
        $xtpl->assign("FILELINK", "<a href='download.php?id=" . $save_file . "&type=Notes' class='tabDetailViewDFLink'>" . $focus->filename . "</a>&nbsp");
    }
    if ($display) {
        $xtpl->assign("SAVE_FILE", $save_file);
        $xtpl->assign("FILE_NAME", $focus->filename);
    }
}
$xtpl->assign("DESCRIPTION", nl2br(url2html($focus->description)));
$xtpl->parse("main.open_source");
$detailView->processListNavigation($xtpl, "NOTE", $offset);
// adding custom fields:
require_once 'modules/DynamicFields/templates/Files/DetailView.php';
Пример #5
0
 function send()
 {
     global $mod_strings;
     global $current_user;
     global $sugar_config;
     global $locale;
     $mail = new SugarPHPMailer();
     foreach ($this->to_addrs_arr as $addr_arr) {
         if (empty($addr_arr['display'])) {
             $mail->AddAddress($addr_arr['email'], "");
         } else {
             $mail->AddAddress($addr_arr['email'], $addr_arr['display']);
         }
     }
     foreach ($this->cc_addrs_arr as $addr_arr) {
         if (empty($addr_arr['display'])) {
             $mail->AddCC($addr_arr['email'], "");
         } else {
             $mail->AddCC($addr_arr['email'], $addr_arr['display']);
         }
     }
     foreach ($this->bcc_addrs_arr as $addr_arr) {
         if (empty($addr_arr['display'])) {
             $mail->AddBCC($addr_arr['email'], "");
         } else {
             $mail->AddBCC($addr_arr['email'], $addr_arr['display']);
         }
     }
     if ($current_user->getPreference('mail_sendtype') == "SMTP") {
         $mail->Mailer = "smtp";
         $mail->Host = $current_user->getPreference('mail_smtpserver');
         $mail->Port = $current_user->getPreference('mail_smtpport');
         if ($current_user->getPreference('mail_smtpauth_req')) {
             $mail->SMTPAuth = TRUE;
             $mail->Username = $current_user->getPreference('mail_smtpuser');
             $mail->Password = $current_user->getPreference('mail_smtppass');
         }
     } else {
         // cn:no need to check since we default to it in any case!
         $mail->Mailer = "sendmail";
     }
     // FROM ADDRESS
     if (!empty($this->from_addr)) {
         $mail->From = $this->from_addr;
     } else {
         $mail->From = $current_user->getPreference('mail_fromaddress');
         $this->from_addr = $mail->From;
     }
     // FROM NAME
     if (!empty($this->from_name)) {
         $mail->FromName = $this->from_name;
     } else {
         $mail->FromName = $current_user->getPreference('mail_fromname');
         $this->from_name = $mail->FromName;
     }
     $mail->Sender = $mail->From;
     /* set Return-Path field in header to reduce spam score in emails sent via Sugar's Email module */
     $mail->AddReplyTo($mail->From, $mail->FromName);
     $encoding = version_compare(phpversion(), '5.0', '>=') ? 'UTF-8' : 'ISO-8859-1';
     $mail->Subject = html_entity_decode($this->name, ENT_QUOTES, $encoding);
     ///////////////////////////////////////////////////////////////////////
     ////	ATTACHMENTS
     foreach ($this->saved_attachments as $note) {
         $mime_type = 'text/plain';
         if ($note->object_name == 'Note') {
             if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
                 // brandy-new file upload/attachment
                 $file_location = $sugar_config['upload_dir'] . $note->id;
                 $filename = $note->file->original_file_name;
                 $mime_type = $note->file->mime_type;
             } else {
                 // attachment coming from template/forward
                 $file_location = rawurldecode(UploadFile::get_file_path($note->filename, $note->id));
                 $filename = $note->name;
                 $mime_type = $note->file_mime_type;
             }
         } elseif ($note->object_name == 'DocumentRevision') {
             // from Documents
             $filename = $note->id;
             $file_location = getcwd() . '/cache/upload/' . $filename;
             $mime_type = $note->file_mime_type;
         }
         // strip out the "Email attachment label if exists
         $filename = str_replace($mod_strings['LBL_EMAIL_ATTACHMENT'] . ': ', '', $filename);
         // cn: bug 9233 attachment filenames need to be translated into the destination charset.
         $filename = $locale->translateCharset($filename, 'UTF-8', $locale->getPrecedentPreference('default_email_charset'));
         //is attachment in our list of bad files extensions?  If so, append .txt to file location
         //get position of last "." in file name
         $file_ext_beg = strrpos($file_location, ".");
         $file_ext = "";
         //get file extension
         if ($file_ext_beg > 0) {
             $file_ext = substr($file_location, $file_ext_beg + 1);
         }
         //check to see if this is a file with extension located in "badext"
         foreach ($sugar_config['upload_badext'] as $badExt) {
             if (strtolower($file_ext) == strtolower($badExt)) {
                 //if found, then append with .txt to filename and break out of lookup
                 //this will make sure that the file goes out with right extension, but is stored
                 //as a text in db.
                 $file_location = $file_location . ".txt";
                 break;
                 // no need to look for more
             }
         }
         $mail->AddAttachment($file_location, $filename, 'base64', $mime_type);
     }
     ////	END ATTACHMENTS
     ///////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////
     ////	HANDLE EMAIL FORMAT PREFERENCE
     // the if() below is HIGHLY dependent on the Javascript unchecking the Send HTML Email box
     // HTML email
     if (isset($_REQUEST['setEditor']) && $_REQUEST['setEditor'] == 1 && trim($_REQUEST['description_html']) != '' || trim($this->description_html) != '') {
         // wp: if body is html, then insert new lines at 996 characters. no effect on client side
         // due to RFC 2822 which limits email lines to 998
         $mail->IsHTML(true);
         $body = from_html(wordwrap($this->description_html, 996));
         $mail->Body = $body;
         // if alternative body is defined, use that, else, striptags the HTML part
         if (trim($this->description) == '') {
             $plainText = from_html($this->description_html);
             $plainText = strip_tags(br2nl($plainText));
             //$plainText = $locale->translateCharset($plainText, 'UTF-8', $locale->getPrecedentPreference('default_email_charset'));
             $mail->AltBody = $plainText;
             $this->description = $plainText;
         } else {
             $mail->AltBody = wordwrap(from_html($this->description), 996);
         }
         // cn: bug 9709 - html email sent accidentally
         // handle signatures fubar'ing the type
         $sigs = $current_user->getDefaultSignature();
         $htmlSig = trim(str_replace(" ", "", strip_tags(from_html($sigs['signature_html']))));
         $htmlBody = trim(str_replace(" ", "", strip_tags(from_html($this->description_html))));
         if ($htmlSig == $htmlBody) {
             // found just a sig. ignore it.
             $this->description_html = '';
             $mail->IsHTML(false);
             $mail->Body = wordwrap(from_html($this->description, 996));
         }
     } else {
         // plain text only
         $this->description_html = '';
         $mail->IsHTML(false);
         $mail->Body = wordwrap(from_html($this->description, 996));
     }
     // wp: if plain text version has lines greater than 998, use base64 encoding
     foreach (explode("\n", $mail->ContentType == "text/html" ? $mail->AltBody : $mail->Body) as $line) {
         if (strlen($line) > 998) {
             $mail->Encoding = 'base64';
             break;
         }
     }
     ////	HANDLE EMAIL FORMAT PREFERENCE
     ///////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////
     ////    SAVE RAW MESSAGE
     $mail->SetMessageType();
     $raw = $mail->CreateHeader();
     $raw .= $mail->CreateBody();
     $this->raw_source = urlencode($raw);
     ////    END SAVE RAW MESSAGE
     ///////////////////////////////////////////////////////////////////////
     $GLOBALS['log']->debug('Email sending --------------------- ');
     ///////////////////////////////////////////////////////////////////////
     ////	I18N TRANSLATION
     $mail->prepForOutbound();
     ////	END I18N TRANSLATION
     ///////////////////////////////////////////////////////////////////////
     if ($mail->Send()) {
         ///////////////////////////////////////////////////////////////////
         ////	INBOUND EMAIL HANDLING
         // mark replied
         if (!empty($_REQUEST['inbound_email_id'])) {
             $ieMail = new Email();
             $ieMail->retrieve($_REQUEST['inbound_email_id']);
             $ieMail->status = 'replied';
             $ieMail->save();
         }
         $GLOBALS['log']->debug(' --------------------- buh bye -- sent successful');
         ////	END INBOUND EMAIL HANDLING
         ///////////////////////////////////////////////////////////////////
         return true;
     }
     $GLOBALS['log']->fatal("Error emailing:" . $mail->ErrorInfo);
     return false;
 }
Пример #6
0
 function get_list_view_data()
 {
     $note_fields = $this->get_list_view_array();
     global $app_list_strings, $focus, $action, $currentModule, $mod_strings, $sugar_config;
     $this->_create_proper_name_field();
     if (isset($this->parent_type)) {
         $note_fields['PARENT_MODULE'] = $this->parent_type;
     }
     if (!isset($this->filename) || $this->filename != '') {
         $file_path = UploadFile::get_file_path($this->filename, $this->id);
         if (file_exists($file_path)) {
             $save_file = urlencode(basename(UploadFile::get_url($this->filename, $this->id)));
             $note_fields['FILENAME'] = $this->filename;
             $note_fields['FILE_URL'] = "index.php?entryPoint=download&id=" . $save_file . "&type=Notes";
         }
     }
     if (isset($this->contact_name)) {
         $note_fields['CONTACT_NAME'] = $this->contact_name;
     }
     global $current_language;
     $mod_strings = return_module_language($current_language, 'Notes');
     $note_fields['STATUS'] = $mod_strings['LBL_NOTE_STATUS'];
     return $note_fields;
 }
 /**
  * wrapper for this::get_file_path()
  * @param string stored_file_name File name in filesystem
  * @param string bean_id note bean ID
  * @return string path with file name
  */
 function get_url($stored_file_name, $bean_id)
 {
     global $sugar_config;
     return UploadFile::get_file_path($stored_file_name, $bean_id);
 }
Пример #8
0
     Yii::app()->clientScript->registerScript(uniqid(), "\n\t\t\t\t\t\t\$('#Archive_{$_v['content_model_field_identify']}').keypress(\n\t\t\t\t\t\t\tfunction(e){\n\t\t\t\t\t\t\t\tif(e.which>13){\n\t\t\t\t\t\t\t\t\tvar c = String.fromCharCode(e.which);\n\t\t\t\t\t\t\t\t\tif(!/\\d/.test(c)){\n\t\t\t\t\t\t\t\t\t\tif((c != '-') || (\$(this).val() != '')){\n\t\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);");
     break;
 case ContentModelField::DATA_TYPE_INTEGER_UNSIGNED:
     echo "<input type=\"text\" name=\"Archive[{$_v['content_model_field_identify']}]\" id=\"Archive_{$_v['content_model_field_identify']}\" value=\"{$_archive_value}\" maxlength=\"11\" style=\"width:150px;\" />";
     Yii::app()->clientScript->registerScript(uniqid(), "\n\t\t\t\t\t\t\$('#Archive_{$_v['content_model_field_identify']}').keypress(\n\t\t\t\t\t\t\tfunction(e){\n\t\t\t\t\t\t\t\tif(e.which>13){\n\t\t\t\t\t\t\t\t\tvar c = String.fromCharCode(e.which);\n\t\t\t\t\t\t\t\t\tif(!/\\d/.test(c)){\n\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);");
     break;
 case ContentModelField::DATA_TYPE_FLOAT:
     echo "<input type=\"text\" name=\"Archive[{$_v['content_model_field_identify']}]\" id=\"Archive_{$_v['content_model_field_identify']}\" value=\"{$_archive_value}\" maxlength=\"11\" style=\"width:150px;\" />";
     Yii::app()->clientScript->registerScript(uniqid(), "\n\t\t\t\t\t\t\$('#Archive_{$_v['content_model_field_identify']}').keypress(\n\t\t\t\t\t\t\tfunction(e){\n\t\t\t\t\t\t\t\tif(e.which>13){\n\t\t\t\t\t\t\t\t\tvar c = String.fromCharCode(e.which);\n\t\t\t\t\t\t\t\t\tif (!/[\\.\\d]/.test(c)){\n\t\t\t\t\t\t\t\t\t\tif((c != '-') || (\$(this).val() != '')){\n\t\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else if ((c == '.') && (\$(this).val().indexOf('.')>=0)) {\n\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t} else if ((c == '.') && ((\$(this).val() == '') || (\$(this).val() == '-'))) {\n\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t} else if (\$(this).val().indexOf('.')>=0) {\n\t\t\t\t\t\t\t\t\t\tif(\$(this).val().substr(\$(this).val().indexOf('.')).length>2) {\n\t\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);");
     break;
 case ContentModelField::DATA_TYPE_DATE_TIME:
     echo "<input type=\"text\" name=\"Archive[{$_v['content_model_field_identify']}]\" id=\"Archive_{$_v['content_model_field_identify']}\" value=\"{$_archive_value}\" style=\"width:150px;\" readonly=\"true\" />";
     Yii::app()->clientScript->registerScript(uniqid(), "\$.datepicker.setDefaults(\$.datepicker.regional['zh-CN']);\r\n\$('#Archive_{$_v['content_model_field_identify']}').datepicker();");
     break;
 case ContentModelField::DATA_TYPE_IMAGE:
     $content_archives_thumb = $_archive_value ? UploadFile::get_file_path($_archive_value, 'images') : '';
     $preview_display = $_archive_value ? 'block' : 'none';
     echo "<input type=\"text\" name=\"Archive[{$_v['content_model_field_identify']}]\" id=\"Archive_{$_v['content_model_field_identify']}\" value=\"{$_archive_value}\" style=\"width:300px;\" readonly=\"true\" />\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<span id=\"upload_file_{$_v['content_model_field_identify']}\" class=\"btn\">上传</span>\n\t\t\t\t\t\t<span id=\"processer_{$_v['content_model_field_identify']}\" style=\"border:1px solid #ccc; display:block; width: 50px; height:2px;\"><div style=\"width:0px;height:2px;background:#0f0;\"></div></span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div id=\"preview_{$_v['content_model_field_identify']}\" style=\"display:{$preview_display}; position: absolute; border: 1px solid #ccc; padding: 3px; background: #fff; z-index:" . (300 - $_k) . "\">\n\t\t\t\t\t\t<img src=\"{$content_archives_thumb}\" width=\"200\" />\n\t\t\t\t\t</div>";
     $request_url = url($this->module->id . '/Content/Archives/UploadFile');
     $csrf_token = Yii::app()->request->csrfToken;
     Yii::app()->clientScript->registerScript(uniqid(), "\n\t\t\t\t\t\t\$(function() {\n\t\t\t\t\t\t\tvar uploader_{$_v['content_model_field_identify']} = new plupload.Uploader({\n\t\t\t\t\t\t\t\truntimes : 'flash,html5,silverlight,gears,browserplus',\n\t\t\t\t\t\t\t\tbrowse_button : 'upload_file_{$_v['content_model_field_identify']}',\n\t\t\t\t\t\t\t\tmax_file_size : '10mb',\n\t\t\t\t\t\t\t\tchunk_size : '1mb',\n\t\t\t\t\t\t\t\tunique_names : true,\n\t\t\t\t\t\t\t\turl : '{$request_url}',\n\t\t\t\t\t\t\t\tflash_swf_url : '{$this->module->assetsUrl}/js/plupload/plupload.flash.swf',\n\t\t\t\t\t\t\t\tsilverlight_xap_url : '{$this->module->assetsUrl}/js/plupload/plupload.silverlight.xap',\n\t\t\t\t\t\t\t\tfilters : [\n\t\t\t\t\t\t\t\t\t{title : \"Image files\", extensions : \"jpg,gif,png\"}\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tmultipart_params:{\"upload_dir\":\"images\",\"YII_CSRF_TOKEN\":\"{$csrf_token}\"}\n\t\t\t\t\t\t\t});\n\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.bind('Init', function(up, params) {\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.init();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.bind('FilesAdded', function(up, files) {\n\t\t\t\t\t\t\t\t\$('#processer_{$_v['content_model_field_identify']}').css({\"background\":\"#0f0\"});\n\t\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.start();\n\t\t\t\t\t\t\t\tup.refresh();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.bind('UploadProgress', function(up, file) {\n\t\t\t\t\t\t\t\tvar p_width = Math.floor(file.percent/2);\n\t\t\t\t\t\t\t\t\$('#processer_{$_v['content_model_field_identify']}').css({\"width\":p_width+\"px\"});\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.bind('Error', function(up, err) {\n\t\t\t\t\t\t\t\tup.refresh();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.bind('FileUploaded', function(up, file, response) {\n\t\t\t\t\t\t\t\tvar r = \$.parseJSON(response.response);\n\t\t\t\t\t\t\t\tif(r.result != 0) {\n\t\t\t\t\t\t\t\t\t\$('#processer_{$_v['content_model_field_identify']}').css({\"width\":\"50px\",\"background\":\"#f00\"});\n\t\t\t\t\t\t\t\t\t\$('#Archive_{$_v['content_model_field_identify']}').val(r.md5_filename);\n\t\t\t\t\t\t\t\t\t\$('#preview_{$_v['content_model_field_identify']}').children().attr(\"src\", r.filename).show();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\$('#processer_{$_v['content_model_field_identify']}').css({\"width\":\"50px\",\"background\":\"#00f\"});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\n\t\t\t\t\t\t\$('#Archive_{$_v['content_model_field_identify']}').mouseover(function(){\n\t\t\t\t\t\t\tif(\$(this).val() != '') {\n\t\t\t\t\t\t\t\t\$('#preview_{$_v['content_model_field_identify']}').show();\n\t\t\t\t\t\t\t\t\$(this).bind('mouseout', function(){\n\t\t\t\t\t\t\t\t\t\$('#preview_{$_v['content_model_field_identify']}').hide();\n\t\t\t\t\t\t\t\t\t\$(this).unbind('mouseout');\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\t", CClientScript::POS_READY);
     break;
 case ContentModelField::DATA_TYPE_MEDIA:
     $preview_display = $_archive_value ? 'block' : 'none';
     echo "<input type=\"text\" name=\"Archive[{$_v['content_model_field_identify']}]\" id=\"Archive_{$_v['content_model_field_identify']}\" value=\"{$_archive_value}\" style=\"width:300px;\" readonly=\"true\" />\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<span id=\"upload_file_{$_v['content_model_field_identify']}\" class=\"btn\">上传</span>\n\t\t\t\t\t\t<span id=\"processer_{$_v['content_model_field_identify']}\" style=\"border:1px solid #ccc; display:block; width: 50px; height:2px;\"><div style=\"width:0px;height:2px;background:#0f0;\"></div></span>\n\t\t\t\t\t</div>";
     $request_url = url($this->module->id . '/Content/Archives/UploadFile');
     $csrf_token = Yii::app()->request->csrfToken;
     Yii::app()->clientScript->registerScript(uniqid(), "\n\t\t\t\t\t\t\$(function() {\n\t\t\t\t\t\t\tvar uploader_{$_v['content_model_field_identify']} = new plupload.Uploader({\n\t\t\t\t\t\t\t\truntimes : 'flash,html5,silverlight,gears,browserplus',\n\t\t\t\t\t\t\t\tbrowse_button : 'upload_file_{$_v['content_model_field_identify']}',\n\t\t\t\t\t\t\t\tmax_file_size : '10mb',\n\t\t\t\t\t\t\t\tchunk_size : '1mb',\n\t\t\t\t\t\t\t\tunique_names : true,\n\t\t\t\t\t\t\t\turl : '{$request_url}',\n\t\t\t\t\t\t\t\tflash_swf_url : '{$this->module->assetsUrl}/js/plupload/plupload.flash.swf',\n\t\t\t\t\t\t\t\tsilverlight_xap_url : '{$this->module->assetsUrl}/js/plupload/plupload.silverlight.xap',\n\t\t\t\t\t\t\t\tfilters : [\n\t\t\t\t\t\t\t\t\t{title : \"Image files\", extensions : \"avi,mpg,mpeg,mov,wmv,rm,rmvb,mp4,swf,flv,mp3,wma\"}\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tmultipart_params:{\"upload_dir\":\"video\",\"YII_CSRF_TOKEN\":\"{$csrf_token}\"}\n\t\t\t\t\t\t\t});\n\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.bind('Init', function(up, params) {\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.init();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.bind('FilesAdded', function(up, files) {\n\t\t\t\t\t\t\t\t\$('#processer_{$_v['content_model_field_identify']}').css({\"background\":\"#0f0\"});\n\t\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.start();\n\t\t\t\t\t\t\t\tup.refresh();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.bind('UploadProgress', function(up, file) {\n\t\t\t\t\t\t\t\tvar p_width = Math.floor(file.percent/2);\n\t\t\t\t\t\t\t\t\$('#processer_{$_v['content_model_field_identify']}').css({\"width\":p_width+\"px\"});\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.bind('Error', function(up, err) {\n\t\t\t\t\t\t\t\tup.refresh();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tuploader_{$_v['content_model_field_identify']}.bind('FileUploaded', function(up, file, response) {\n\t\t\t\t\t\t\t\tvar r = \$.parseJSON(response.response);\n\t\t\t\t\t\t\t\tif(r.result != 0) {\n\t\t\t\t\t\t\t\t\t\$('#processer_{$_v['content_model_field_identify']}').css({\"width\":\"50px\",\"background\":\"#f00\"});\n\t\t\t\t\t\t\t\t\t\$('#Archive_{$_v['content_model_field_identify']}').val(r.md5_filename);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\$('#processer_{$_v['content_model_field_identify']}').css({\"width\":\"50px\",\"background\":\"#00f\"});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t", CClientScript::POS_READY);
     break;
 case ContentModelField::DATA_TYPE_ATTACH_OTHER:
     $preview_display = $_archive_value ? 'block' : 'none';
Пример #9
0
 /**
  * Function finds the reference email for the campaign. Since a campaign can have multiple email templates
  * the reference email has same id as the marketing id.
  * this function will create an email if one does not exist. also the function will load these relationships leads, accounts, contacts
  * users and targets
  *
  * @param varchar marketing_id message id
  * @param string $subject email subject
  * @param string $body_text Email Body Text
  * @param string $body_html Email Body HTML
  * @param string $campaign_name Campaign Name
  * @param string from_address Email address of the sender, usually email address of the configured inbox.
  * @param string sender_id If of the user sending the campaign.
  * @param array  macro_nv array of name value pair, one row for each replacable macro in email template text.
  * @return
  */
 function create_ref_email($marketing_id, $subject, $body_text, $body_html, $campagin_name, $from_address, $sender_id, $notes, $macro_nv, $newmessage)
 {
     global $mod_Strings;
     $upd_ref_email = false;
     if ($newmessage or empty($this->ref_email->id)) {
         $this->ref_email = new Email();
         $this->ref_email->retrieve($marketing_id, true, false);
         //the reference email should be updated when user swithces from test mode to regular mode,and, for every run in test mode, and is user
         //switches back to test mode.
         //this is to account for changes to email template.
         $upd_ref_email = (!empty($this->ref_email->id) and $this->ref_email->parent_type == 'test' and $this->ref_email->parent_id == 'test');
         //following condition is for switching back to test mode.
         if (!$upd_ref_email) {
             $upd_ref_email = ($this->test and !empty($this->ref_email->id) and empty($this->ref_email->parent_type) and empty($this->ref_email->parent_id));
         }
         if (empty($this->ref_email->id) or $upd_ref_email) {
             //create email record.
             $this->ref_email->id = $marketing_id;
             $this->ref_email->date_sent = '';
             if ($upd_ref_email == false) {
                 $this->ref_email->new_with_id = true;
             }
             $this->ref_email->to_addrs = '';
             $this->ref_email->to_addrs_ids = '';
             $this->ref_email->to_addrs_names = '';
             $this->ref_email->to_addrs_emails = '';
             $this->ref_email->type = 'campaign';
             $this->ref_email->deleted = '0';
             $this->ref_email->name = $campagin_name . ': ' . $subject;
             $this->ref_email->description_html = $body_html;
             $this->ref_email->description = $body_text;
             $this->ref_email->from_addr = $from_address;
             $this->ref_email->assigned_user_id = $sender_id;
             if ($this->test) {
                 $this->ref_email->parent_type = 'test';
                 $this->ref_email->parent_id = 'test';
             } else {
                 $this->ref_email->parent_type = '';
                 $this->ref_email->parent_id = '';
             }
             $this->ref_email->date_start = $GLOBALS['timedate']->to_display_date(gmdate($GLOBALS['timedate']->dbDayFormat));
             $this->ref_email->time_start = $GLOBALS['timedate']->to_display_time(gmdate($GLOBALS['timedate']->dbTimeFormat));
             $this->ref_email->status = 'sent';
             $retId = $this->ref_email->save();
             if (count($notes) > 0) {
                 if (!class_exists('Note')) {
                     if (!class_exists('UploadFile')) {
                         require_once 'include/upload_file.php';
                     }
                 }
             }
             foreach ($notes as $note) {
                 if ($note->object_name == 'Note') {
                     if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
                         $file_location = $note->file->temp_file_location;
                         $filename = $note->file->original_file_name;
                         $mime_type = $note->file->mime_type;
                     } else {
                         $file_location = rawurldecode(UploadFile::get_file_path($note->filename, $note->id));
                         $filename = $note->id . $note->filename;
                         $mime_type = $note->file_mime_type;
                     }
                 } elseif ($note->object_name == 'DocumentRevision') {
                     // from Documents
                     $filename = $note->id . $note->filename;
                     $file_location = getcwd() . '/' . $GLOBALS['sugar_config']['upload_dir'] . $filename;
                     $mime_type = $note->file_mime_type;
                 }
                 $noteAudit = new Note();
                 $noteAudit->parent_id = $retId;
                 $noteAudit->parent_type = $this->ref_email->module_dir;
                 $noteAudit->description = "[" . $note->filename . "] " . $mod_strings['LBL_ATTACHMENT_AUDIT'];
                 $noteAudit->filename = $filename;
                 $noteAudit->file_mime_type = $mime_type;
                 $noteAudit_id = $noteAudit->save();
                 UploadFile::duplicate_file($note->id, $noteAudit_id, $filename);
             }
         }
         //load relationships.
         $this->ref_email->load_relationship('users');
         $this->ref_email->load_relationship('prospects');
         $this->ref_email->load_relationship('contacts');
         $this->ref_email->load_relationship('leads');
         $this->ref_email->load_relationship('accounts');
     }
     if (!empty($this->related_id) && !empty($this->related_type)) {
         //save relationships.
         switch ($this->related_type) {
             case 'Users':
                 $rel_name = "users";
                 break;
             case 'Prospects':
                 $rel_name = "prospects";
                 break;
             case 'Contacts':
                 $rel_name = "contacts";
                 break;
             case 'Leads':
                 $rel_name = "leads";
                 break;
             case 'Accounts':
                 $rel_name = "accounts";
                 break;
         }
         //required for one email per campaign per marketing message.
         $this->ref_email->{$rel_name}->add($this->related_id, array('campaign_data' => serialize($macro_nv)));
     }
     return $this->ref_email->id;
 }
 /**
  * @param notes	array of note beans
  */
 function handleAttachments($notes)
 {
     // cn: bug 4864 - reusing same SugarPHPMailer class, need to clear attachments
     $this->ClearAttachments();
     require_once 'include/upload_file.php';
     foreach ($notes as $note) {
         $mime_type = 'text/plain';
         $file_location = '';
         $filename = '';
         if ($note->object_name == 'Note') {
             if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
                 $file_location = $note->file->temp_file_location;
                 $filename = $note->file->original_file_name;
                 $mime_type = $note->file->mime_type;
             } else {
                 $file_location = rawurldecode(UploadFile::get_file_path($note->filename, $note->id));
                 $filename = $note->id . $note->filename;
                 $mime_type = $note->file_mime_type;
             }
         } elseif ($note->object_name == 'DocumentRevision') {
             // from Documents
             $filename = $note->id . $note->filename;
             $file_location = getcwd() . '/cache/upload/' . $filename;
             $mime_type = $note->file_mime_type;
         }
         $filename = substr($filename, 36, strlen($filename));
         // strip GUID	for PHPMailer class to name outbound file
         $this->AddAttachment($file_location, $filename, 'base64', $mime_type);
     }
 }
Пример #11
0
 /**
  * @param notes	array of note beans
  */
 function handleAttachments($notes)
 {
     global $sugar_config;
     //replace references to cache/images with cid tag
     $this->Body = str_replace($GLOBALS['sugar_config']['cache_dir'] . 'images/', 'cid:', $this->Body);
     if (empty($notes)) {
         return;
     }
     // cn: bug 4864 - reusing same SugarPHPMailer class, need to clear attachments
     $this->ClearAttachments();
     require_once 'include/upload_file.php';
     //Handle legacy attachments
     $fileBasePath = "{$sugar_config['upload_dir']}";
     $filePatternSearch = "{$sugar_config['upload_dir']}";
     $filePatternSearch = str_replace("/", "\\/", $filePatternSearch);
     if (strpos($this->Body, "\"{$fileBasePath}")) {
         $matches = array();
         preg_match_all("/{$filePatternSearch}.+?\"/i", $this->Body, $matches);
         foreach ($matches[0] as $match) {
             $filename = str_replace($fileBasePath, '', $match);
             $filename = urldecode(substr($filename, 0, -1));
             $cid = $filename;
             $file_location = clean_path(getcwd() . "/{$sugar_config['upload_dir']}{$filename}");
             $mime_type = "image/" . strtolower(substr($filename, strrpos($filename, ".") + 1, strlen($filename)));
             if (file_exists($file_location)) {
                 $this->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type);
             }
         }
         //replace references to cache with cid tag
         $this->Body = str_replace($fileBasePath, 'cid:', $this->Body);
     }
     //Handle secure embeded images.
     $noteImgRegex = "/<img[^>]*[\\s]+src[^=]*=\"index.php\\?entryPoint=download(\\&amp;|\\&)id=([^\\&]*)[^>]*>/im";
     $embededImageMatches = array();
     preg_match_all($noteImgRegex, $this->Body, $embededImageMatches, PREG_SET_ORDER);
     foreach ($embededImageMatches as $singleMatch) {
         $fullMatch = $singleMatch[0];
         $noteId = $singleMatch[2];
         $cid = $noteId;
         $filename = $noteId;
         //Retrieve note for mimetype
         $tmpNote = new Note();
         $tmpNote->retrieve($noteId);
         //Replace the src part of img tag with new cid tag
         $cidRegex = "/src=\"([^\"]*)\"/im";
         $replaceMatch = preg_replace($cidRegex, "src=\"cid:{$noteId}\"", $fullMatch);
         //Replace the body, old tag for new tag
         $this->Body = str_replace($fullMatch, $replaceMatch, $this->Body);
         //Attach the file
         $file_location = clean_path(getcwd() . "/{$sugar_config['upload_dir']}{$noteId}");
         if (file_exists($file_location)) {
             $this->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $tmpNote->file_mime_type);
         }
     }
     //Handle regular attachments.
     foreach ($notes as $note) {
         $mime_type = 'text/plain';
         $file_location = '';
         $filename = '';
         if ($note->object_name == 'Note') {
             if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
                 $file_location = $note->file->temp_file_location;
                 $filename = $note->file->original_file_name;
                 $mime_type = $note->file->mime_type;
             } else {
                 $file_location = rawurldecode(UploadFile::get_file_path($note->filename, $note->id));
                 $filename = $note->id . $note->filename;
                 $mime_type = $note->file_mime_type;
             }
         } elseif ($note->object_name == 'DocumentRevision') {
             // from Documents
             $filename = $note->id . $note->filename;
             $file_location = getcwd() . '/' . $GLOBALS['sugar_config']['upload_dir'] . $filename;
             $mime_type = $note->file_mime_type;
         }
         $filename = substr($filename, 36, strlen($filename));
         // strip GUID	for PHPMailer class to name outbound file
         if (!$note->embed_flag) {
             $this->AddAttachment($file_location, $filename, 'base64', $mime_type);
         }
         // else
     }
 }
Пример #12
0
						<input type="text" id="content_archives_thumb" name="Archive[content_archives_thumb]" value="<?php 
echo $archive['content_archives_thumb'];
?>
" readonly="true" class="txt" style="width:300px;" />
						(鼠标放上去可以预览图片内容)
						<div>
							<span id="upload_file" class="btn">上传</span>
							<span id="processer" style="border:1px solid #ccc; display:block; width: 50px; height:2px;"><div style="width:0px;height:2px;background:#0f0;"></div></span>
						</div>
						
						<div id="preview" style="display:<?php 
echo $archive['content_archives_thumb'] ? 'block' : 'none';
?>
; position: absolute; border: 1px solid #ccc; padding: 3px; background: #fff;">
							<img src="<?php 
echo $archive['content_archives_thumb'] ? UploadFile::get_file_path($archive['content_archives_thumb'], 'images') : '';
?>
" width="200" />
						</div>
					</dd>
				</dl>
			</td>
		</tr>
		
		<tr>
			<td colspan="5">
				<dl>
					<dt>文章来源:</dt>
					<dd><input type="text" name="Archive[content_archives_source]" value="<?php 
echo $archive['content_archives_source'];
?>
Пример #13
0
 public function actionUpdate($id, $page = null)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!isset($_POST['F']) || !is_array($_POST['F'])) {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('保存信息错误', self::MSG_ERROR, true);
         }
         /*if($_POST['F']['ad_data_subject'] =='') {
         			$this->redirect[] = array(
         				'text' => '',
         				'href' => 'javascript:history.go(-1);',
         			);
         			$this->message('名称不能为空', self::MSG_ERROR, true);
         		}
         		if($_POST['F']['ad_data_link'] =='') {
         			$this->redirect[] = array(
         				'text' => '',
         				'href' => 'javascript:history.go(-1);',
         			);
         			$this->message('链接不能为空', self::MSG_ERROR, true);
         		}*/
         if (count($_POST['F']['ad_data_page'])) {
             $page = implode(",", $_POST['F']['ad_data_page']);
         } else {
             $page = "";
         }
         $user = Yii::app()->user;
         $flag = Yii::app()->db->createCommand()->update('{{ad_data}}', array('ad_position_id' => $_POST['F']['ad_position_id'], 'ad_data_type' => $_POST['F']['ad_data_type'], 'ad_data_page' => $page, 'ad_data_subject' => $_POST['F']['ad_data_subject'], 'ad_data_image_md5' => $_POST['F']['ad_data_image_md5'], 'ad_data_flash_md5' => $_POST['F']['ad_data_flash_md5'], 'ad_data_link' => $_POST['F']['ad_data_link'], 'ad_data_html' => $_POST['F']['ad_data_html'], 'ad_data_expire_start' => strtotime($_POST['F']['ad_data_expire_start']), 'ad_data_expire_end' => strtotime($_POST['F']['ad_data_expire_end']), 'ad_data_rank' => $_POST['F']['ad_data_rank'], 'update_user_id' => $user->id, 'ad_data_relative_id' => $_POST['F']['ad_data_relative_id']), 'ad_data_id=:ad_data_id', array(':ad_data_id' => $id));
         if ($flag) {
             $ad_data_id = $id;
             $ad_data_subject = $_POST['F']['ad_data_subject'];
             //更新缓存
             AdData::update_cache();
             //记录操作日志
             $message = '{user_name}修改了广告素材{ad_data_subject}';
             $data = array('user_id' => $user->id, 'user_name' => $user->name, 'ad_data_subject' => $ad_data_subject, 'addons_data' => array('ad_data_id' => $ad_data_id));
             AdminLogs::add($user->id, 'Ad/Data', $ad_data_id, 'Modify', 'success', $message, $data);
         }
         if (!isset($_GET['ajax'])) {
             $this->redirect[] = array('text' => '', 'href' => url($this->module->id . '/Ad/Data/Index'));
             $this->message('保存成功', self::MSG_SUCCESS, true);
         }
     }
     $data = AdData::get_one_by_id($id, false);
     if (empty($data)) {
         $this->redirect[] = array('text' => '', 'href' => url($this->module->id . '/Ad/Position/Index'));
         $this->message('id不存在或已被删除', self::MSG_ERROR, true);
     }
     //print_r($data);
     $sql = "SELECT `ad_position_id`,`ad_position_name`,`ad_position_relative_type` FROM `ad_position` WHERE `ad_position_status`!=:ad_position_status";
     $cmd = Yii::app()->db->createCommand($sql);
     $cmd->execute(array(':ad_position_status' => AdPosition::STAT_DELETED));
     $position_arr = $cmd->queryAll();
     if ($data['ad_data_expire_start']) {
         $data['ad_data_expire_start'] = date("Y-m-d H:i:s", $data['ad_data_expire_start']);
     } else {
         $data['ad_data_expire_start'] = "";
     }
     if ($data['ad_data_expire_end']) {
         $data['ad_data_expire_end'] = date("Y-m-d H:i:s", $data['ad_data_expire_end']);
     } else {
         $data['ad_data_expire_end'] = "";
     }
     if ($data['ad_data_page']) {
         $data['ad_data_page'] = explode(",", $data['ad_data_page']);
     } else {
         $data['ad_data_page'] = array();
     }
     $pages = AdData::$PAGE;
     if ($data['ad_data_image_md5']) {
         $data['image_full_path'] = UploadFile::get_file_path($data['ad_data_image_md5'], 'images');
     }
     $this->render('update', array('data' => $data, 'position_arr' => $position_arr, "pages" => $pages));
 }
Пример #14
0
 function get_list_view_data()
 {
     $note_fields = $this->get_list_view_array();
     global $app_list_strings, $focus, $action, $currentModule, $mod_strings, $sugar_config;
     $note_fields["DATE_MODIFIED"] = substr($note_fields["DATE_MODIFIED"], 0, 10);
     if (isset($this->parent_type)) {
         $note_fields['PARENT_MODULE'] = $this->parent_type;
     }
     if (!isset($this->filename) || $this->filename != '') {
         $file_path = UploadFile::get_file_path($this->filename, $this->id);
         if (file_exists($file_path)) {
             $save_file = urlencode(basename(UploadFile::get_url($this->filename, $this->id)));
             $note_fields['FILENAME'] = $this->filename;
             $note_fields['FILE_URL'] = "download.php?id=" . $save_file . "&type=Notes";
         }
     }
     global $current_language;
     $mod_strings = return_module_language($current_language, 'Notes');
     $note_fields['STATUS'] = $mod_strings['LBL_NOTE_STATUS'];
     return $note_fields;
 }