Exemplo n.º 1
0
function get_unique_system_id($session, $unique_key, $system_name = '', $install_method = 'web')
{
    global $beanList, $beanFiles, $current_user, $server;
    $error = new SoapError();
    if (!empty($server->requestHeaders)) {
        $header = explode('=', $server->requestHeaders);
        $uh = new UpgradeHistory();
        if (count($header) == 2 && $uh->is_right_version_greater(explode('.', '5.0.0'), explode('.', $header[1]))) {
            $output_list = array();
            if (!validate_authenticated($session)) {
                $error->set_error('invalid_login');
                return array('id' => '', 'error' => $error->get_soap_array());
            }
            $system = new System();
            if ($system->canAddNewOfflineClient()) {
                $system->system_key = $unique_key;
                $system->user_id = $current_user->id;
                $system->system_name = $system_name;
                $system->install_method = $install_method;
                $system->last_connect_date = TimeDate::getInstance()->nowDb();
                $system_id = $system->retrieveNextKey();
                if ($system_id == -1) {
                    $error->set_error('client_deactivated');
                }
            } else {
                $system_id = -1;
                $error->set_error('cannot_add_client');
            }
        } else {
            $system_id = -1;
            $error->set_error('upgrade_client');
        }
    } else {
        $system_id = -1;
        $error->set_error('upgrade_client');
    }
    return array('id' => $system_id, 'error' => $error->get_soap_array());
}
require_once 'modules/Administration/UpgradeHistory.php';
$admin_option_defs = array();
// Invoice options
$admin_option_defs[] = array('Administration', 'LBL_FACT_CONFIG', 'LBL_FACT_CONFIG_DESC', './index.php?module=Configurator&action=reg_invoices_Config');
// Dependencies checker
$admin_option_defs[] = array('Administration', 'LBL_FACT_CHECK', 'LBL_FACT_CHECK_DESC', './index.php?module=Administration&action=reg_invoices_Check');
/*
 * Add administration options to page
 * Supports:
 */
$US = new UpgradeHistory();
/*
 * Prepare for < 5.5
 */
$minimal = explode(".", "5.5.0");
$current = explode(".", $GLOBALS['sugar_version']);
if (!$US->is_right_version_greater($minimal, $current, true)) {
    foreach ($admin_option_defs as $key => $val) {
        //Add $image_path
        $admin_option_defs[$key][0] = $image_path . $admin_option_defs[$key][0];
    }
}
$minimal = explode(".", "5.2.0");
$current = explode(".", $GLOBALS['sugar_version']);
// 5.2 and later
if ($US->is_right_version_greater($minimal, $current, true)) {
    $admin_group_header[] = array('LBL_FACT_CONFIG_GROUP', '', false, array("Administration" => $admin_option_defs), 'LBL_FACT_CONFIG_GROUP_DESC');
    //5.1 and earlier
} else {
    $admin_group_header[] = array('LBL_FACT_CONFIG_GROUP', '', false, $admin_option_defs, 'LBL_FACT_CONFIG_GROUP_DESC');
}