diff -urp ../qb/qb.inc ./qb.inc --- ../qb/qb.inc 2008-09-02 15:31:06.000000000 +0900 +++ ./qb.inc 2008-09-02 15:38:14.000000000 +0900 @@ -1,15 +1,2 @@ 'textfield', - '#title' => t('Company file'), - '#description' => t('The full path to your quickbooks company file, e.g. C:\Data\MyCompany\MyCompany.qdb. If you leave this blank, applications will use the file that is currently open on your workstation.'), - ); - // Make sure the buttons show up someplace responsible. - $form['buttons'] = array('#weight' => 10); - - return system_settings_form($form); -} diff -urp ../qb/qb.info ./qb.info --- ../qb/qb.info 2008-09-02 15:31:06.000000000 +0900 +++ ./qb.info 2008-09-02 15:40:44.000000000 +0900 @@ -1,4 +1,3 @@ ; $Id: qb.info,v 1.1 2008/06/13 00:29:38 vauxia Exp $ name = Quickbooks -description = Basic Quickbooks support -core = 6.x +description = Basic Quickbooks support \ No newline at end of file diff -urp ../qb/qb.module ./qb.module --- ../qb/qb.module 2008-09-02 15:31:06.000000000 +0900 +++ ./qb.module 2008-09-02 15:38:28.000000000 +0900 @@ -1,22 +1,39 @@ array( - 'title' => t('Quickbooks'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('qb_settings'), - 'access arguments' => array('administer quickbooks'), - 'file' => 'qb.inc', - 'type' => MENU_NORMAL_ITEM, - ), - ); +function qb_menu($may_cache = true) { + $items = array(); + + if ($may_cache) { + $items[] = array( + 'path' => 'admin/settings/qb', + 'title' => t('Quickbooks Settings'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('qb_settings'), + 'access' => array('administer quickbooks') + ); + } + + return $items; } function qb_perm() { return array('administer quickbooks'); } +function qb_settings() { + $form = array(); + + $form['qb_company_file'] = array( + '#type' => 'textfield', + '#title' => t('Company file'), + '#description' => t('The full path to your quickbooks company file, e.g. C:\Data\MyCompany\MyCompany.qdb. If you leave this blank, applications will use the file that is currently open on your workstation.'), + ); + // Make sure the buttons show up someplace responsible. + $form['buttons'] = array('#weight' => 10); + + return system_settings_form($form); +} + function qb_qbxml($root_entity, $elements) { $qbxml = new DOMDocument('1.0'); $xml = $qbxml->appendChild($qbxml->createElement($root_entity)); diff -urp ../qb/qbwc.inc ./qbwc.inc --- ../qb/qbwc.inc 2008-09-02 15:31:06.000000000 +0900 +++ ./qbwc.inc 2008-09-02 15:44:02.000000000 +0900 @@ -21,7 +21,7 @@ class qbwc { $name = $params->strUserName; $pass = $params->strPassword; - $hostname = ip_address(); + $hostname = $_SERVER['REMOTE_ADDR']; // Generate a ticket to be used for all further communication $ticket = md5(time() . $name); @@ -35,7 +35,7 @@ class qbwc { // Authenticate as the quickbooks drupal user if ($name && ($name == variable_get('qbwc_user', ''))) { - if ($user = user_authenticate(array('name' => $name, 'pass' => $pass))) { + if ($user = user_authenticate($name, $pass)) { // Return company file or empty, which means "currently open file". $ret = variable_get('qb_company_file', ''); diff -urp ../qb/qbwc.info ./qbwc.info --- ../qb/qbwc.info 2008-09-02 15:31:06.000000000 +0900 +++ ./qbwc.info 2008-09-02 15:45:19.000000000 +0900 @@ -1,5 +1,4 @@ ; $Id: qbwc.info,v 1.1 2008/06/13 00:29:38 vauxia Exp $ name = Web Connector description = Implements a Quickbooks Web Connector server -core = 6.x -dependencies[] = qb +dependencies = qb diff -urp ../qb/qbwc.install ./qbwc.install --- ../qb/qbwc.install 2008-09-02 15:31:06.000000000 +0900 +++ ./qbwc.install 2008-09-02 15:50:30.000000000 +0900 @@ -1,30 +1,39 @@ array( - 'fields' => array( - 'ticket' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE), - 'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), - 'hostname' => array('type' => 'varchar', 'length' => 15), - 'open_ts' => array('type' => 'int', 'not null' => TRUE), - 'close_ts' => array('type' => 'int', 'default' => 0), - ), - 'indexes' => array( - 'ticket' => array('ticket'), - ), - ), - ); -} - function qbwc_install() { variable_set('qbwc_owner_id', uniqid()); variable_set('qbwc_file_id', uniqid()); - drupal_install_schema('qbwc'); + + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + db_query(" + CREATE TABLE {qbwc_sessions} ( + ticket varchar(64) NOT NULL default '', + uid int unsigned NOT NULL default '0', + hostname varchar(15) NOT NULL default '', + open_ts int NOT NULL default '0', + close_ts int default '0', + PRIMARY KEY (ticket) + ) /*!40100 DEFAULT CHARACTER SET utf8 */; + "); + break; + case 'pgsql': + db_query("CREATE TABLE {qbwc_sessions} ( + ticket varchar(64) NOT NULL default '', + uid int NOT NULL default '0', + hostname varchar(15) NOT NULL default '', + open_ts int NOT NULL default '0', + close_ts int default '0', + PRIMARY KEY (ticket) + )"); + break; + } } function qbwc_uninstall() { variable_del('qbwc_owner_id'); variable_del('qbwc_file_id'); - drupal_uninstall_schema('qbwc'); + + db_query('DROP TABLE {qbwc_sessions}'); } diff -urp ../qb/qbwc.module ./qbwc.module --- ../qb/qbwc.module 2008-09-02 15:31:06.000000000 +0900 +++ ./qbwc.module 2008-09-02 15:53:48.000000000 +0900 @@ -1,20 +1,24 @@ t('Quickbooks Web Connector'), - 'page callback' => 'qbwc', - 'access arguments' => array('access qbwc'), - 'type' => MENU_CALLBACK, - ); - $items['admin/settings/qb/qwc'] = array( - 'title' => t('QWC File'), - 'page callback' => 'qbwc_qwc', - 'access arguments' => array('access qbwc'), - 'type' => MENU_CALLBACK, - ); + if ($may_cache) { + $items[] = array( + 'title' => t('Quickbooks Web Connector'), + 'path' => 'qbwc', + 'callback' => 'qbwc', + 'type' => MENU_CALLBACK, + 'access' => user_access('access qbwc') + ); + $items[] = array( + 'title' => t('QWC File'), + 'path' => 'admin/settings/qb/qwc', + 'callback' => 'qbwc_qwc', + 'access' => user_access('access qbwc'), + 'type' => MENU_CALLBACK, + ); + } return $items; } @@ -23,7 +27,7 @@ function qbwc_perm() { return array('access qbwc'); } -function qbwc_form_alter(&$form, $form_state, $form_id) { +function qbwc_form_alter($form_id, &$form) { // Add QBWC settings to the Quickbooks settings page if ($form_id == 'qb_settings') { $form['qbwc'] = array(