security update link,module_filters,search_api_solr,ubercart,views
This commit is contained in:
@@ -33,7 +33,7 @@ class UbercartFileTestCase extends UbercartTestHelper {
|
||||
$this->configureDownloadDirectory();
|
||||
}
|
||||
|
||||
function testFilePurchaseCheckout() {
|
||||
public function testFilePurchaseCheckout() {
|
||||
// Add file download feature to the test product.
|
||||
$filename = $this->uploadTestFile();
|
||||
$this->drupalLogin($this->adminUser);
|
||||
@@ -89,7 +89,6 @@ class UbercartFileTestCase extends UbercartTestHelper {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to upload test file for downloading.
|
||||
*/
|
||||
@@ -106,7 +105,7 @@ class UbercartFileTestCase extends UbercartTestHelper {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function tearDown() {
|
||||
protected function tearDown() {
|
||||
// Cleanup file download directory after test.
|
||||
drupal_unlink('sites/default/files/file-downloads/README.txt');
|
||||
drupal_rmdir('sites/default/files/file-downloads');
|
||||
|
@@ -16,6 +16,7 @@ define('UC_FILE_FORM_ACTION', 1 );
|
||||
*
|
||||
* @see uc_file_admin_files_form_show_files()
|
||||
* @see uc_file_admin_files_form_action()
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function uc_file_admin_files_form($form, &$form_state) {
|
||||
@@ -45,6 +46,7 @@ function uc_file_admin_files_form($form, &$form_state) {
|
||||
* @see uc_file_admin_files_form_show_validate()
|
||||
* @see uc_file_admin_files_form_show_submit()
|
||||
* @see theme_uc_file_admin_files_form_show()
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function uc_file_admin_files_form_show_files($form, &$form_state) {
|
||||
@@ -53,7 +55,7 @@ function uc_file_admin_files_form_show_files($form, &$form_state) {
|
||||
$header = array(
|
||||
'filename' => array('data' => t('File'), 'field' => 'f.filename', 'sort' => 'asc'),
|
||||
'title' => array('data' => t('Product'), 'field' => 'n.title'),
|
||||
'model' => array('data' => t('SKU'), 'field' => 'fp.model')
|
||||
'model' => array('data' => t('SKU'), 'field' => 'fp.model'),
|
||||
);
|
||||
|
||||
// Create pager.
|
||||
@@ -109,7 +111,7 @@ function uc_file_admin_files_form_show_files($form, &$form_state) {
|
||||
'uc_file_delete' => t('Delete file(s)'),
|
||||
);
|
||||
|
||||
// Check if any hook_uc_file_action('info', $args) are implemented
|
||||
// Check if any hook_uc_file_action('info', $args) are implemented.
|
||||
foreach (module_implements('uc_file_action') as $module) {
|
||||
$name = $module . '_uc_file_action';
|
||||
$result = $name('info', NULL);
|
||||
@@ -190,6 +192,7 @@ function uc_file_admin_files_form_show_submit($form, &$form_state) {
|
||||
* - form: A render element representing the form.
|
||||
*
|
||||
* @see uc_file_admin_files_form_show_files()
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_uc_file_admin_files_form_show($variables) {
|
||||
@@ -211,6 +214,7 @@ function theme_uc_file_admin_files_form_show($variables) {
|
||||
* @see uc_file_admin_files_form()
|
||||
* @see uc_file_admin_files_form_action_validate()
|
||||
* @see uc_file_admin_files_form_action_submit()
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function uc_file_admin_files_form_action($form, &$form_state) {
|
||||
@@ -258,7 +262,7 @@ function uc_file_admin_files_form_action($form, &$form_state) {
|
||||
);
|
||||
|
||||
// Don't even show the recursion checkbox unless we have any directories.
|
||||
if ($has_directory && $affected_list[TRUE] !== FALSE ) {
|
||||
if ($has_directory && $affected_list[TRUE] !== FALSE) {
|
||||
$form['recurse_directories'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Delete selected directories and their sub directories'),
|
||||
@@ -276,14 +280,12 @@ function uc_file_admin_files_form_action($form, &$form_state) {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'uc_file_upload':
|
||||
|
||||
// Calculate the max size of uploaded files, in bytes.
|
||||
$max_bytes = trim(ini_get('post_max_size'));
|
||||
switch (strtolower($max_bytes{strlen($max_bytes)-1})) {
|
||||
switch (strtolower($max_bytes{strlen($max_bytes) - 1})) {
|
||||
case 'g':
|
||||
$max_bytes *= 1024;
|
||||
case 'm':
|
||||
@@ -323,13 +325,11 @@ function uc_file_admin_files_form_action($form, &$form_state) {
|
||||
);
|
||||
|
||||
// Must add this after confirm_form, as it runs over $form['#attributes'].
|
||||
// Issue logged at d#319723
|
||||
// Issue logged at https://www.drupal.org/node/319723.
|
||||
$form['#attributes']['enctype'] = 'multipart/form-data';
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
// This action isn't handled by us, so check if any
|
||||
// hook_uc_file_action('form', $args) are implemented.
|
||||
foreach (module_implements('uc_file_action') as $module) {
|
||||
@@ -337,7 +337,6 @@ function uc_file_admin_files_form_action($form, &$form_state) {
|
||||
$result = $name('form', array('action' => $form_state['values']['uc_file_action']['action'], 'file_ids' => $file_ids));
|
||||
$form = (is_array($result)) ? array_merge($form, $result) : $form;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -378,7 +377,7 @@ function uc_file_admin_files_form_action_validate($form, &$form_state) {
|
||||
default:
|
||||
|
||||
// This action isn't handled by us, so check if any
|
||||
// hook_uc_file_action('validate', $args) are implemented
|
||||
// hook_uc_file_action('validate', $args) are implemented.
|
||||
foreach (module_implements('uc_file_action') as $module) {
|
||||
$name = $module . '_uc_file_action';
|
||||
$result = $name('validate', array('form_id' => $form_id, 'form_state' => $form_state));
|
||||
@@ -398,7 +397,6 @@ function uc_file_admin_files_form_action_submit($form, &$form_state) {
|
||||
switch ($form_state['values']['action']) {
|
||||
|
||||
case 'uc_file_delete':
|
||||
|
||||
// File deletion status.
|
||||
$status = TRUE;
|
||||
|
||||
@@ -411,11 +409,9 @@ function uc_file_admin_files_form_action_submit($form, &$form_state) {
|
||||
else {
|
||||
drupal_set_message(t('One or more files could not be deleted.'), 'warning');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'uc_file_upload':
|
||||
|
||||
// Build the destination location. We start with the base directory,
|
||||
// then add any directory which was explicitly selected.
|
||||
$dir = variable_get('uc_file_base_dir', NULL) . '/';
|
||||
@@ -428,13 +424,13 @@ function uc_file_admin_files_form_action_submit($form, &$form_state) {
|
||||
// Copy the file to its final location.
|
||||
if (copy($file_object->uri, $dir . '/' . $file_object->filename)) {
|
||||
|
||||
// Check if any hook_uc_file_action('upload', $args) are implemented
|
||||
// Check if any hook_uc_file_action('upload', $args) are implemented.
|
||||
foreach (module_implements('uc_file_action') as $module) {
|
||||
$name = $module . '_uc_file_action';
|
||||
$result = $name('upload', array('file_object' => $file_object, 'form_id' => $form_id, 'form_state' => $form_state));
|
||||
}
|
||||
|
||||
// Update the file list
|
||||
// Update the file list.
|
||||
uc_file_refresh();
|
||||
|
||||
drupal_set_message(t('The file %file has been uploaded to %dir', array('%file' => $file_object->filename, '%dir' => $dir)));
|
||||
@@ -446,13 +442,11 @@ function uc_file_admin_files_form_action_submit($form, &$form_state) {
|
||||
else {
|
||||
drupal_set_message(t('Can not move file to %dir', array('%dir' => $dir)), 'error');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
// This action isn't handled by us, so check if any
|
||||
// hook_uc_file_action('submit', $args) are implemented
|
||||
// hook_uc_file_action('submit', $args) are implemented.
|
||||
foreach (module_implements('uc_file_action') as $module) {
|
||||
$name = $module . '_uc_file_action';
|
||||
$result = $name('submit', array('form_id' => $form_id, 'form_state' => $form_state));
|
||||
|
@@ -122,11 +122,13 @@ function hook_uc_file_action($op, $args) {
|
||||
switch ($op) {
|
||||
case 'info':
|
||||
return array('uc_image_watermark_add_mark' => 'Add Watermark');
|
||||
|
||||
case 'insert':
|
||||
// Automatically adds watermarks to any new files that are uploaded to
|
||||
// the file download directory.
|
||||
_add_watermark($args['file_object']->uri);
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'form':
|
||||
if ($args['action'] == 'uc_image_watermark_add_mark') {
|
||||
$form['watermark_text'] = array(
|
||||
@@ -139,23 +141,27 @@ function hook_uc_file_action($op, $args) {
|
||||
'#value' => t('Add watermark'),
|
||||
);
|
||||
}
|
||||
return $form;
|
||||
return $form;
|
||||
|
||||
case 'upload':
|
||||
_add_watermark($args['file_object']->uri);
|
||||
break;
|
||||
|
||||
case 'upload_validate':
|
||||
// Given a file path, function checks if file is valid JPEG.
|
||||
if (!_check_image($args['file_object']->uri)) {
|
||||
form_set_error('upload', t('Uploaded file is not a valid JPEG'));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'validate':
|
||||
if ($args['form_values']['action'] == 'uc_image_watermark_add_mark') {
|
||||
if (empty($args['form_values']['watermark_text'])) {
|
||||
form_set_error('watermar_text', t('Must fill in text'));
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'submit':
|
||||
if ($args['form_values']['action'] == 'uc_image_watermark_add_mark') {
|
||||
foreach ($args['form_values']['file_ids'] as $file_id) {
|
||||
@@ -164,7 +170,7 @@ function hook_uc_file_action($op, $args) {
|
||||
_add_watermark($filename);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.duration {
|
||||
.duration {
|
||||
display: inline;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
@@ -11,9 +11,8 @@ files[] = tests/uc_file.test
|
||||
stylesheets[all][] = uc_file.css
|
||||
scripts[] = uc_file.js
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-07-16
|
||||
version = "7.x-3.10"
|
||||
; Information added by Drupal.org packaging script on 2019-03-06
|
||||
version = "7.x-3.12"
|
||||
core = "7.x"
|
||||
project = "ubercart"
|
||||
datestamp = "1468644909"
|
||||
|
||||
datestamp = "1551862392"
|
||||
|
@@ -9,8 +9,6 @@
|
||||
* download link via email. Additionally, after logging on a customer can
|
||||
* download files via their account page. Optionally, an admininstrator can set
|
||||
* restrictions on how and when files are downloaded.
|
||||
*
|
||||
* Development sponsored by the Ubercart project. http://www.ubercart.org
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -267,7 +265,7 @@ function uc_file_user_form_validate($form, &$form_state) {
|
||||
// Determine if any downloads were modified.
|
||||
if (isset($edit['file_download'])) {
|
||||
|
||||
foreach ((array)$edit['file_download'] as $key => $download_modification) {
|
||||
foreach ((array) $edit['file_download'] as $key => $download_modification) {
|
||||
// We don't care... it's about to be deleted.
|
||||
if ($download_modification['remove']) {
|
||||
continue;
|
||||
@@ -313,7 +311,7 @@ function uc_file_user_form_submit($form, &$form_state) {
|
||||
|
||||
// Check out if any downloads were modified.
|
||||
if (isset($edit['file_download'])) {
|
||||
foreach ((array)$edit['file_download'] as $fid => $download_modification) {
|
||||
foreach ((array) $edit['file_download'] as $fid => $download_modification) {
|
||||
// Remove this user download?
|
||||
if ($download_modification['remove']) {
|
||||
uc_file_remove_user_file_by_id($account, $fid);
|
||||
@@ -340,7 +338,7 @@ function uc_file_user_form_submit($form, &$form_state) {
|
||||
// Check out if any downloads were added. We pass NULL to file_user_renew,
|
||||
// because this shouldn't be associated with a random product.
|
||||
if (isset($edit['file_add'])) {
|
||||
foreach ((array)$edit['file_add'] as $fid => $data) {
|
||||
foreach ((array) $edit['file_add'] as $fid => $data) {
|
||||
$download_modification['download_limit'] = variable_get('uc_file_download_limit_number', NULL);
|
||||
$download_modification['address_limit'] = variable_get('uc_file_download_limit_addresses', NULL);
|
||||
|
||||
@@ -427,7 +425,7 @@ function uc_file_uc_add_to_cart($nid, $qty, $data) {
|
||||
|
||||
// Get the current limits, and calculate the new limits to show the user.
|
||||
if ($file_user = _uc_file_user_get($user, $product_feature->fid)) {
|
||||
$file_user = (array)$file_user;
|
||||
$file_user = (array) $file_user;
|
||||
|
||||
$old_limits = $file_user;
|
||||
|
||||
@@ -556,7 +554,7 @@ function uc_file_feature_form($form, &$form_state, $node, $feature) {
|
||||
|
||||
// Rescan the file directory to populate {uc_files} with the current list
|
||||
// because files uploaded via any method other than the Upload button
|
||||
// (e.g. by FTP) won'b be in {uc_files} yet.
|
||||
// (e.g. by FTP) won't be in {uc_files} yet.
|
||||
|
||||
uc_file_refresh();
|
||||
|
||||
@@ -809,7 +807,8 @@ function uc_file_feature_form_submit($form, &$form_state) {
|
||||
|
||||
$form_state['redirect'] = uc_product_feature_save($data);
|
||||
|
||||
$file_product['pfid'] = $data['pfid'];
|
||||
// Updating the 'pfid' on $file_product and on $form_state for future use.
|
||||
$form_state['values']['pfid'] = $file_product['pfid'] = $data['pfid'];
|
||||
|
||||
// Insert or update uc_file_product table.
|
||||
$key = array();
|
||||
@@ -1629,12 +1628,12 @@ function uc_file_user_renew($fid, $user, $pfid, $file_limits, $force_overwrite)
|
||||
$force_overwrite = TRUE;
|
||||
}
|
||||
else {
|
||||
$file_user = (array)$file_user;
|
||||
$file_user = (array) $file_user;
|
||||
$key = 'fuid';
|
||||
}
|
||||
|
||||
// Add file data in as well.
|
||||
$file_info = (array)uc_file_get_by_id($fid);
|
||||
$file_info = (array) uc_file_get_by_id($fid);
|
||||
|
||||
$file_user += $user_file_global + $file_info;
|
||||
|
||||
@@ -1658,7 +1657,7 @@ function uc_file_user_renew($fid, $user, $pfid, $file_limits, $force_overwrite)
|
||||
watchdog('uc_file', '%user has been allowed to download %file.', array('%user' => format_username($user), '%file' => $file_user['filename']));
|
||||
}
|
||||
|
||||
$result[] = (object)$file_user;
|
||||
$result[] = (object) $file_user;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ define('UC_FILE_ERROR_HOOK_ERROR' , 7);
|
||||
* - address_limit: Integer limit on IP addresses.
|
||||
*
|
||||
* @see theme_table()
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_uc_file_user_downloads($variables) {
|
||||
@@ -134,7 +135,7 @@ function uc_file_user_downloads($account) {
|
||||
),
|
||||
);
|
||||
|
||||
// Expiration set to 'never'
|
||||
// Expiration set to 'never'.
|
||||
if ($file->expiration == FALSE) {
|
||||
$file_link = l(basename($file->filename), 'download/' . $file->fid, $onclick);
|
||||
}
|
||||
@@ -338,7 +339,7 @@ function _uc_file_download_transfer($file_user, $ip) {
|
||||
$filename = preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1);
|
||||
}
|
||||
|
||||
// Check if HTTP_RANGE is sent by browser (or download manager)
|
||||
// Check if HTTP_RANGE is sent by browser (or download manager).
|
||||
$range = NULL;
|
||||
if (isset($_SERVER['HTTP_RANGE'])) {
|
||||
if (substr($_SERVER['HTTP_RANGE'], 0, 6) == 'bytes=') {
|
||||
@@ -354,7 +355,7 @@ function _uc_file_download_transfer($file_user, $ip) {
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out download piece from range (if set)
|
||||
// Figure out download piece from range (if set).
|
||||
if (isset($range)) {
|
||||
list($seek_start, $seek_end) = explode('-', $range, 2);
|
||||
}
|
||||
@@ -370,7 +371,7 @@ function _uc_file_download_transfer($file_user, $ip) {
|
||||
drupal_add_http_header('Status', '206 Partial Content');
|
||||
}
|
||||
|
||||
// Standard headers, including content-range and length
|
||||
// Standard headers, including content-range and length.
|
||||
drupal_add_http_header('Pragma', 'public');
|
||||
drupal_add_http_header('Cache-Control', 'cache, must-revalidate');
|
||||
drupal_add_http_header('Accept-Ranges', 'bytes');
|
||||
@@ -379,20 +380,20 @@ function _uc_file_download_transfer($file_user, $ip) {
|
||||
drupal_add_http_header('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
||||
drupal_add_http_header('Content-Length', $seek_end - $seek_start + 1);
|
||||
|
||||
// Last-Modified is required for content served dynamically
|
||||
// Last-Modified is required for content served dynamically.
|
||||
drupal_add_http_header('Last-Modified', gmdate("D, d M Y H:i:s", filemtime($file_user->full_path)) . " GMT");
|
||||
|
||||
// Etag header is required for Firefox3 and other managers
|
||||
// Etag header is required for Firefox3 and other managers.
|
||||
drupal_add_http_header('ETag', md5($file_user->full_path));
|
||||
|
||||
// Open the file and seek to starting byte
|
||||
// Open the file and seek to starting byte.
|
||||
$fp = fopen($file_user->full_path, 'rb');
|
||||
fseek($fp, $seek_start);
|
||||
|
||||
// Start buffered download
|
||||
// Start buffered download.
|
||||
while (!feof($fp)) {
|
||||
|
||||
// Reset time limit for large files
|
||||
// Reset time limit for large files.
|
||||
drupal_set_time_limit(0);
|
||||
|
||||
// Push the data to the client.
|
||||
@@ -429,7 +430,7 @@ function _uc_file_log_download($file_user, $ip) {
|
||||
// Accessed again.
|
||||
$file_user->accessed++;
|
||||
|
||||
// Calculate hash
|
||||
// Calculate hash.
|
||||
$file_user->file_key = drupal_get_token(serialize($file_user));
|
||||
|
||||
drupal_write_record('uc_file_users', $file_user, 'fuid');
|
||||
|
@@ -102,6 +102,7 @@ function uc_file_get_expiration_properties($expiration, array $options, $name, $
|
||||
switch ($name) {
|
||||
case 'user':
|
||||
return $expiration->uid;
|
||||
|
||||
case 'file':
|
||||
return $expiration->fid;
|
||||
}
|
||||
@@ -138,7 +139,7 @@ function uc_file_rules_action_info() {
|
||||
),
|
||||
);
|
||||
|
||||
// Send an email to an order with a file expiration
|
||||
// Send an email to an order with a file expiration.
|
||||
$actions['uc_file_order_email'] = array(
|
||||
'label' => t('Send an order email regarding files.'),
|
||||
'group' => t('Notification'),
|
||||
@@ -230,7 +231,7 @@ function uc_file_action_order_email($order, $file_expiration, $from, $addresses,
|
||||
'format' => $format,
|
||||
);
|
||||
|
||||
// Token replacements for the subject and body
|
||||
// Token replacements for the subject and body.
|
||||
$settings['replacements'] = array(
|
||||
'uc_order' => $order,
|
||||
'uc_file' => $file_expiration,
|
||||
@@ -262,7 +263,7 @@ function uc_file_action_order_email($order, $file_expiration, $from, $addresses,
|
||||
* user is notified in Drupal, as well as through the email address associated
|
||||
* with the order.
|
||||
*
|
||||
* @param $order
|
||||
* @param object $order
|
||||
* An Ubercart order object.
|
||||
*/
|
||||
function uc_file_action_order_renew($order) {
|
||||
@@ -292,14 +293,14 @@ function uc_file_action_order_renew($order) {
|
||||
// as an offset of the previous.
|
||||
$file_user = _uc_file_user_get($order_user, $file->fid);
|
||||
|
||||
// Get the limit info from the product feature
|
||||
// Get the limit info from the product feature.
|
||||
$file_modification = array(
|
||||
'download_limit' => uc_file_get_download_limit($file),
|
||||
'address_limit' => uc_file_get_address_limit($file),
|
||||
'expiration' => _uc_file_expiration_date(uc_file_get_time_limit($file), ($file_user ? max($file_user->expiration, REQUEST_TIME) : NULL)),
|
||||
);
|
||||
|
||||
// Add file_user(s) for this file/directory. (No overwrite)
|
||||
// Add file_user(s) for this file/directory. (No overwrite).
|
||||
$new_files = uc_file_user_renew($file->fid, $order_user, $file->pfid, $file_modification, FALSE);
|
||||
|
||||
// Save for notification.
|
||||
|
Reference in New Issue
Block a user