<?php

require_once 'modules/admin/views/SignupView.php';
require_once 'newedge/classes/NE_PluginCollection.php';

/**
* @package Admin
*/
class Signup_6_Finish extends SignupView
{
    var $permission     = '';

    function preHeaders()
    {
        if (trim($this->settings->get('Signup Completion URL')) != "") {
            $pass = ($_REQUEST['pass'] == 1)? 1 : 0;
            NE_Lib::redirectPage($this->settings->get('Signup Completion URL').'?succes='.$pass);
        }
        $this->initialize();
    }
    function dispatch()
    {
        $tPass=1;
        if ($_REQUEST['pass']==0) $tPass=0;
        if(!$this->settings->get('Signup Completion URL')){
            $this->templateInit();
            
            $this->tpl->assign("COMPANYNAME", $this->settings->get("Company Name"));
            $this->tpl->assign("SUPPORTEMAIL", $this->settings->get("Support E-mail"));
            $this->tpl->assign("CLIENTAPPLICATIONURL", NE_Lib::getSoftwareURL());
            $this->tpl->assign("COMPANYURL", $this->settings->get("Company URL"));
            
            if ($tPass == 1) {

                // Setup Affiliate Plugins
                $plugins = new NE_PluginCollection('affiliates', $this->user);
                while ($plugin = $plugins->getNext()) {
                    if (@$this->settings->get("plugin_".$plugin->getInternalName()."_Enabled") == 1 && isset($_SESSION['affiliate'])) {
                        $params = array();
                        $affiliateVariables = $plugin->getVariables();
                        foreach ($affiliateVariables as $key => $var) {
                            $settingname = "plugin_".$plugin->getInternalName()."_".$key;
                            $params = array_merge($params,array( $key => $this->settings->get($settingname) ));
                        }
                        $params = array_merge($params, $_SESSION['affiliate']);
                        
                        $this->tpl->assign("AffiliatePluginImage", $plugin->getImage($params));
                        $this->tpl->parse("AffiliatePlugins_out", ".AffiliatePlugins");
                        
                        unset($_SESSION['affiliate']);
                        break;
                    }
                }
                
                $this->tpl->parse("SignupCompletion_out", "SignupCompletion");
            } else {
                $this->tpl->parse("SignupRejection_out", "SignupRejection");
            }
            
            $this->tpl->parse("SIGNUP_6_FINISH", "signup_6_finish");
            $this->tpl->FastPrint("SIGNUP_6_FINISH");
    
            $this->tpl->FastPrint("FOOTER");
        }
    }
}

?>
