Index: uc_po.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/uc_po/uc_po.info,v retrieving revision 1.1 diff -u -r1.1 uc_po.info --- uc_po.info 7 May 2008 19:35:39 -0000 1.1 +++ uc_po.info 11 Feb 2009 04:29:55 -0000 @@ -1,6 +1,8 @@ ; $Id: uc_po.info,v 1.1 2008/05/07 19:35:39 rszrama Exp $ name = Purchase Order description = Grant customers permission to pay by purchase order. -dependencies = uc_order uc_payment +dependencies[] = uc_order +dependencies[] = uc_payment package = Ubercart - payment +core = 6.x Index: uc_po.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/uc_po/uc_po.install,v retrieving revision 1.1 diff -u -r1.1 uc_po.install --- uc_po.install 7 May 2008 19:35:39 -0000 1.1 +++ uc_po.install 11 Feb 2009 04:29:55 -0000 @@ -2,42 +2,42 @@ // $Id: uc_po.install,v 1.1 2008/05/07 19:35:39 rszrama Exp $ /** + * @file + * + * Provide functions to install and uninstall the purchase + * order module in the database + */ + + +/** + * Implementation of hook_schema(). + */ +function uc_po_schema() { + $schema['uc_payment_po'] = array( + 'fields' => array( + 'po_id' => array('type' => 'serial', 'size' => 'medium', 'not null' => TRUE, 'disp-width' => '9'), + 'order_id' => array('type' => 'int', 'size' => 'medium', 'not null' => TRUE, 'disp-width' => '9'), + 'po_number' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE)), + 'primary key' => array('po_id'), + 'indexes' => array( + 'order_id' => array('order_id')), + ); + return $schema; +} + +/** * Implementation of hook_install(). */ function uc_po_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {uc_payment_po} ( - po_id mediumint(9) NOT NULL, - order_id mediumint(9) NOT NULL, - po_number varchar(255) NOT NULL, - PRIMARY KEY (po_id), - KEY order_id (order_id) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); - break; - case 'pgsql': - db_query("CREATE TABLE {uc_payment_po} ( - po_id serial NOT NULL, - order_id integer NOT NULL default 0, - po_number varchar(255) NOT NULL default '', - PRIMARY KEY (po_id) - )"); - db_query("CREATE INDEX {uc_payment_po}_order_id ON {uc_payment_po} (order_id)"); - break; - } + drupal_install_schema('uc_po'); } + +/** + * Implementation of hook_uninstall(). + */ function uc_po_uninstall() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("DROP TABLE IF EXISTS {uc_payment_po}"); - break; - case 'pgsql': - db_query("DROP TABLE {uc_payment_po}"); - break; - } + drupal_uninstall_schema('uc_po'); variable_del('uc_po_instructions'); variable_del('uc_po_roles'); Index: uc_po.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/uc_po/uc_po.module,v retrieving revision 1.1 diff -u -r1.1 uc_po.module --- uc_po.module 7 May 2008 19:35:39 -0000 1.1 +++ uc_po.module 11 Feb 2009 04:29:55 -0000 @@ -18,21 +18,19 @@ /** * Implementation of hook_menu(). */ -function uc_po_menu($may_cache) { +function uc_po_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/store/orders/po', - 'title' => t('Search by PO'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('uc_po_search_form'), - 'access' => user_access('administer store'), - 'description' => t('Search orders by PO number.'), - 'weight' => 5, - 'type' => MENU_NORMAL_ITEM, - ); - } + + $items['admin/store/orders/po'] = array( + 'title' => 'Search by PO', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('uc_po_search_form'), + 'access arguments' => array('administer store'), + 'description' => 'Search orders by PO number.', + 'weight' => 5, + 'type' => MENU_NORMAL_ITEM, + ); return $items; } @@ -93,8 +91,8 @@ db_query("UPDATE {uc_payment_po} SET po_number = '%s' WHERE order_id = %d", $arg1->payment_details['po_number'], $arg1->order_id); if (db_affected_rows() == 0) { - db_query("INSERT INTO {uc_payment_po} (po_id, order_id, po_number) " - ."VALUES (%d, %d, '%s')", db_next_id('{uc_payment_po}_po_id'), + db_query("INSERT INTO {uc_payment_po} (order_id, po_number) " + ."VALUES (%d, '%s')", $arg1->order_id, $arg1->payment_details['po_number']); } } @@ -140,6 +138,18 @@ return $methods; } +/** + * Implementatio of hook_theme(). + */ +function uc_po_theme($existing, $type, $theme, $path) { + return array( + 'uc_payment_method_po_form' => array( + 'arguments' => array( + 'form' => NULL, + ), + ), + ); +} /******************************************************************************* * Callback Functions, Forms, and Tables @@ -264,7 +274,7 @@ return $form; } -function uc_po_search_form_submit($form_id, $form_values) { - return 'admin/store/orders/po/'. check_plain($form_values['po_number']); +function uc_po_search_form_submit($form, &$form_state) { + return 'admin/store/orders/po/'. check_plain($form_state['values']['po_number']); }