Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create barcodes for user accounts upon user registration. #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions sites/all/modules/barcode/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
*******************************************************************************

barcode
barcodefield

Description:
-------------------------------------------------------------------------------
This module provides a barcode FAPI element and barcode field type.


Installation & Use:
-------------------------------------------------------------------------------
1. Enable module in module list located at administer > build > modules.
2. Configuration barcode settings at admin/config/barcode


Features:
-------------------------------------------------------------------------------
* Generate a barcode image on the fly. Supports EAN-13, EAN-8, UPC-A, UPC-E,
* ISBN, 2 of 5 Symbologies (std, ind, interleaved), postnet, codabar, code128,
* code39, code93 symbologies.


Authors:
-------------------------------------------------------------------------------
Harish Chauhan - create image from barcode with php
http://phpclasses.ca/browse/author/182909.html

Jingsheng Wang - Drupal module
http://drupal.org/user/228712


References:
-------------------------------------------------------------------------------
Symbology http://www.barcodeisland.com/symbolgy.phtml

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
diff --git a/barcode.info b/barcode.info
index d484e6e..a16de75 100755
--- a/barcode.info
+++ b/barcode.info
@@ -3,6 +3,9 @@ description = Implements a barcode form element. Generate a barcode image on the
core = 7.x
package = Fields

+dependencies[] = entity
+dependencies[] = entity_token
+
files[] = barcode.module
files[] = barcode.install
files[] = includes/barcode.plugins.inc
diff --git a/barcode.module b/barcode.module
index 04f2558..20a6b07 100755
--- a/barcode.module
+++ b/barcode.module
@@ -352,7 +352,7 @@ function barcode_field_formatter_view($object_type, $object, $field, $instance,
function barcode_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
foreach ($items as $entity_id => $entity_items) {
foreach ($entity_items as $delta => $value) {
- _barcode_sanitize($items[$entity_id][$delta], $delta, $field, $instances[$entity_id], $entities[$entity_id]);
+ _barcode_sanitize($items[$entity_id][$delta], $delta, $field, $instances[$entity_id], $entities[$entity_id], $entity_type);
}
}
}
@@ -414,13 +414,14 @@ function barcode_field_widget_form(&$form, &$form_state, $field, $instance, $lan
* change token to appropriate values.
*
*/
-function _barcode_sanitize(&$item, $delta, &$field, $instance, &$node) {
+function _barcode_sanitize(&$item, $delta, &$field, $instance, $entity, $entity_type) {
if (empty($item['value'])) {
return;
}
-
- $token_node = isset($node->nid) ? node_load($node->nid) : $node;
- $item['value'] = token_replace($item['value'], array('node' => $token_node), array('clear' => 1));
+ if (is_numeric($entity)) {
+ $entity = entity_load_single($entity_type, $entity);
+ }
+ $item['value'] = token_replace($item['value'], array($entity_type => $entity), array('clear' => 1));
}

/**************************************************************************
27 changes: 27 additions & 0 deletions sites/all/modules/barcode/barcode.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name = Barcode
description = Implements a barcode form element. Generate a barcode image on the fly. Supports many barcode symbologies.
core = 7.x
package = Fields

dependencies[] = entity
dependencies[] = entity_token

files[] = barcode.module
files[] = barcode.install
files[] = includes/barcode.plugins.inc
files[] = includes/barcode.admin.inc
files[] = includes/barcode.theme.inc

; Supported barcodes
files[] = plugins/i25.inc
files[] = plugins/s2o5.inc
files[] = plugins/ean8.inc
files[] = plugins/ean.inc
files[] = plugins/codabar.inc
files[] = plugins/code93.inc
files[] = plugins/code39.inc
files[] = plugins/code128.inc
files[] = plugins/postnet.inc
files[] = plugins/upce.inc

configure = admin/config/media/barcode
109 changes: 109 additions & 0 deletions sites/all/modules/barcode/barcode.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

/**
* @file
* Install file for barcode module.
*/

/**
* Implements hook_uninstall().
*/
function barcode_uninstall() {
// Delete variables.
variable_del('barcode_default_path');
variable_del('barcode_encoding');
variable_del('barcode_font');
}

/**
* Implements hook_field_schema().
*/
function barcode_field_schema($field) {
if(isset($field['settings']['dbsize'])) {
$columns = array(
'value' => array('type' => 'varchar', 'length' => $field['settings']['dbsize'], 'not null' => FALSE),
);
}
else {
$columns = array(
'value' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
);
}

return array('columns' => $columns);
}

/**
* Implements hook_install().
*/
function barcode_install() {
// Create the default barcode directory and ensure it's writable.
$path = file_build_uri('barcodes');
if (file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
variable_set('barcode_default_path', $path);
}
}

/**
* Implements hook_requirements().
*/
function barcode_requirements($phase) {
$requirements = array();
if ($phase != 'runtime') {
return $requirements;
}

// Create the styles directory and ensure it's writable.
$settings = barcode_get_settings();
$created = file_prepare_directory($settings['default_path'], FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);

if (!$created) {
$requirements['barcode_dirs'] = array(
'value' => t('Missing directory'),
'severity' => REQUIREMENT_ERROR,
'description' => t("The barcode module's default directory %barcode-dir can not be created.", array('%barcode-dir' => $settings['default_path'])),
);
}
else {
$requirements['barcode_dirs'] = array(
'value' => t('Barcode directory exists (%path).', array('%path' => $settings['default_path'])),
'severity' => REQUIREMENT_OK,
);
}
$requirements['barcode_dirs']['title'] = t('Barcode module directories');

// Image library check.
if (!function_exists("imagecreate")) {
$requirements['barcode_image_library'] = array(
'value' => t('Missing image library'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The barcode module needs GD library support.'),
);
}
else {
$requirements['barcode_image_library'] = array(
'value' => t('Image library exists.'),
'severity' => REQUIREMENT_OK,
);
}
$requirements['barcode_image_library']['title'] = t('Barcode image library');

// FreeType Support check.
if (!function_exists("imagettftext")) {
$requirements['barcode_freetype_gd'] = array(
'value' => t('Missing FreeType extension for GD'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The barcode module needs FreeType extension of GD library to be enabled.'),
);
}
else {
$requirements['barcode_freetype_gd'] = array(
'value' => t('FreeType extnesion of GD library exists.'),
'severity' => REQUIREMENT_OK,
);
}
$requirements['barcode_freetype_gd']['title'] = t('FreeType extension');


return $requirements;
}
Loading