У меня быстрый вопрос. В настоящее время я запускаю тестовый сайт Drupal.У меня есть модуль, который был написан и поддерживается для версий до 6.16 тестового сайта, на котором я хотел бы использовать этот модуль в аварийных ситуациях при включении модуля.
Я хотел бы знать, какие основные элементы можно использоватьубедитесь, что код совместим и / или необходимы изменения.
Этот модуль обеспечивает интеграцию CRM в Drupal для SSO.
Я подумал, что кто-то еще сталкивался с созданиеммодуль для преодоления разрыва между системами, они могут указывать мне в правильном направлении.
Это ошибка, которую я получаю при включении модуля:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /homepages/22/d223624283/htdocs/drupal6/sites/all/modules/convio/convio.module on line 104
Это код вфайл с именем convio.module, который вызывает у меня проблему:
<?php
/**
* Classes. (The order is important.)
*/
module_load_include("inc", "convio", "ConvioConstants");
module_load_include("inc", "convio", "ConvioUtils");
module_load_include("inc", "convio", "ConvioConfiguration");
module_load_include("inc", "convio", "ConvioAPIClient");
module_load_include("inc", "convio", "ConvioUser");
module_load_include("inc", "convio", "ConvioLoginHandler");
module_load_include("inc", "convio", "ConvioTokenHandler");
/**
* Implementation of hook_help.
*/
function convio_help() {
if ($path == 'admin/help#convio') {
$txt = 'The Convio module uses the !convio_url API to .';
$link = l('Convio Open', 'http://open.convio.com');
$replace = array('!convio_url' => $link);
return '<p>' . t($txt, $replace) . '</p>';
}
}
/**
* Implementation of hook_menu.
*/
function convio_menu() {
// Test
$items['convio/test'] = array(
'title' => 'Convio Test',
'description' => 'Testing.',
'page callback' => 'convio_test',
'file' => 'ui/test.inc',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
// Admin configuration page.
$items['admin/convio/configure'] = array(
'title' => 'Convio Integration',
'description' => 'Settings for the Convio Open API.',
'page callback' => 'drupal_get_form',
'page arguments' => array('convio_configuration_form'),
'file' => 'ui/admin/configure.inc',
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
// SSO Authentication callback.
$items['convio/session/status'] = array(
'title' => 'Convio Session Status',
'description' => 'Validates the Convio user session and updates the Drupal user session.',
'page callback' => 'convio_session_status',
'file' => 'ui/session/status.inc',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
// SSO Authentication callback.
$items['convio/session/validate'] = array(
'title' => 'Convio Session Validation',
'description' => 'Validates the Convio user session and updates the Drupal user session.',
'page callback' => 'convio_session_validate',
'file' => 'ui/session/validate.inc',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
// SSO Authentication callback.
$items['convio/session/clear'] = array(
'title' => 'Convio Session Reset',
'description' => 'Clears the Drupal user session.',
'page callback' => 'convio_session_clear',
'file' => 'ui/session/clear.inc',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
// Only enable the following hooks if the Open APIs have been configured.
if (ConvioConfiguration::getInstance()->isEnabled()) {
/**
* Implementation of hook_menu_alter()
*
* Alter the user/registration menu item to point to the external
* user account registration page
*/
function convio_menu_alter($items) {
// Always allow access to the user/login.
$items['user/login']['access callback'] = TRUE;
/**
* Overrides user/register from user.module.
*
* $items['user/register'] = array(
* 'title' => 'Create new account',
* 'page callback' => 'drupal_get_form',
* 'page arguments' => array('user_register'),
* 'access callback' => 'user_register_access',
* 'type' => MENU_LOCAL_TASK,
* 'file' => 'user.pages.inc',
* );
*/
unset($items['user/register']);
$items['user/register'] = array(
'title' => 'Sign up',
'page callback' => 'convio_user_signup',
'access callback' => 'user_register_access',
'type' => MENU_CALLBACK,
'file path' => drupal_get_path('module','convio'),
'file' => 'ui/register.inc',
);
// Disable Forgot/Reset Password pages from user.module.
unset($items['user/password']);
unset($items['user/reset/%/%/%']);
// Disable Manage User Profile pages from user.module.
unset($items['user/autocomplete']);
unset($items['user/%user/delete']);
//TODO: alter profile edit form
//unset($items['user/%user_category/edit']);
unset($items['user/%user_category/edit/account']);
unset($items['admin/user/user/create']);
return $items;
}
/**
* Implementation of hook_form_alter.
*
* Replaces the standard login form with a Convio login form.
*/
function convio_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'user_login_block' || $form_id == 'user_login') {
ConvioLoginHandler::getInstance()->getLoginForm($form, $form_state, $form_id);
}
return $form;
}
/**
* Implementation of hook_user.
*
* Maps cons_id to the Drupal user account.
*/
function convio_user($op, &$edit, &$account, $category = NULL) {
if ($op == "load") {
// Make cons_id available from the user.
$result = db_query("SELECT user_id, cons_id FROM {convio_users} where cons_id = %d", $cons_id);
$convio_user = db_fetch_object($result);
if ($convio_user) {
$account->convio_cons_id = $convio_user->cons_id;
}
} else if ($op == "insert") {
// The user account was created. Map it to the cons_id.
db_query("INSERT INTO {convio_users} (user_id, cons_id) VALUES (%d, %d)",
$account->uid,
$edit["convio_cons_id"]);
} else if ($op == "after_update") {
// The user account was updated.
$result = db_query("SELECT user_id, cons_id FROM {convio_users} where cons_id = %d", $edit["convio_cons_id"]);
$convio_user = db_fetch_object($result);
if (! $convio_user) {
db_query("INSERT INTO {convio_users} (user_id, cons_id) VALUES (%d, %d)",
$account->uid,
$edit["convio_cons_id"]);
}
} else if ($op == "delete") {
// The user account was deleted. Delete any associated Convio mappings.
// It would be better to have MySQL FK support with cascading deletes.
db_query("DELETE FROM {convio_users} WHERE user_id = %d", $account->uid);
} else if ($op == "logout") {
ConvioLoginHandler::getInstance()->logout();
}
}
/**
* Implements hook_token_values();
*/
function convio_token_values($type, $object = NULL) {
if ($type == 'convio') {
return ConvioTokenHandler::getInstance()->getValues();
}
}
/**
* Implements hook_token_list();
*/
function convio_token_list($type = 'all') {
if ($type == 'convio' || $type == 'all') {
return ConvioTokenHandler::getInstance()->getList();
}
}
/**
* Adds standard includes to every page.
*
* 1) Open API JS lib and init script -> <head>
* 2) Session tracking beacon -> header region
* 3) Keep-alive beacon -> footer region
*/
function _convio_add_includes() {
static $included = FALSE;
if (!$included) {
$api_config = ConvioConfiguration::getInstance();
// Establish a new C360 session if one doesn't exist already.
if (ConvioLoginHandler::getInstance()->newUserSession()) {
return;
}
$api_uri = $api_config->getURI();
$api_key = $api_config->getPublicKey();
// TODO: allow the regions to be overriden in the module configuration.
$region_header = "header";
$region_footer = "footer";
// Add Convio Open API JS library and init script.
drupal_set_html_head('<script type="text/javascript" src="' . $api_uri . '/../api/ConvioApi.js"></script>');
$script = '<script type="text/javascript">';
$script .= ' var CONVIO = {};';
$script .= ' CONVIO.OPEN = new ConvioApiClient("' . $api_key . '","/api_client.html","json");';
$script .= '</script>';
drupal_set_html_head($script);
// Add the session tracking beacon to the body of every page.
$trackerUrl = url('convio/session/status', array('query' => drupal_get_destination()));
$tracker = '<script type="text/javascript" src="' . $trackerUrl . '"></script>';
drupal_set_content($region_header, $tracker);
// Add a keepalive beacon to the bottom of every page.
$img = '<img src="' . $api_uri . '/PixelServer" />';
drupal_set_content($region_footer, $img);
}
$included = TRUE;
}
// Include Convio module JS libraries on every page.
_convio_add_includes();
} // end: if (ConvioConfiguration::getInstance()->isEnabled())