public function initElements()
 {
     parent::initElements();
     if (method_exists($this->plugin, "parseExternalConfig") && !$this->plugin->isConfigured()) {
         $this->addFolderSelect();
     }
     $this->addOtherDb();
     $this->addDbPrefix();
     $this->addGroupSettings();
     $this->addFieldsPrefix("protect.{$this->pageId}.");
     $this->addScript('script')->setScript($this->getJs());
     if ($this->plugin->canAutoCreate()) {
         $this->addAdvCheckbox('auto_create')->setLabel(___("Create aMember Users By Demand\n" . "silently create customer in aMember if\n" . "user tries to login into aMember with\n" . "the same username and password as for %s", $this->getTitle()));
     }
     if (defined($const = get_class($this->plugin) . "::PLUGIN_STATUS") && (constant($const) == Am_Plugin::STATUS_BETA || constant($const) == Am_Plugin::STATUS_DEV)) {
         $beta = constant($const) == Am_Plugin::STATUS_DEV ? 'ALPHA' : 'BETA';
         $this->addProlog("<div class='warning_box'>This plugin is currently in {$beta} testing stage, some functions may work unstable." . "Please test it carefully before use.</div>");
     }
     $this->plugin->afterAddConfigItems($this);
 }
Пример #2
0
    public function initElements()
    {
        parent::initElements();
        if (method_exists($this->plugin, "parseExternalConfig") && !$this->plugin->isConfigured()) {
            $this->addFolderSelect();
        }
        $this->addOtherDb();
        $this->addDbPrefix();
        $this->addGroupSettings();
        if ($this->plugin->canAutoCreate() && $this->plugin->isConfigured()) {
            $gr = $this->addGroup()->setLabel(___("Create aMember Users By Demand\n" . "silently create customer in aMember if\n" . "user tries to login into aMember with\n" . "the same username and password as for %s", $this->getTitle()));
            $el = $gr->addAdvCheckbox('auto_create');
            $auto_create_id = $el->getId();
            $options = array('' => ___('Please Select'));
            if ($this->plugin->canAutoCreateFromGroups()) {
                $options['-1'] = ___('Add Access depends on current user\'s groups in ' . $this->plugin->getTitle());
            }
            foreach (Am_Di::getInstance()->billingPlanTable->selectAllSorted() as $p) {
                try {
                    $k = $p->product_id . '_' . $p->plan_id;
                    $v = $p->getProduct()->title;
                    $v .= ' (' . $p->getTerms() . ')';
                    $options[$k] = $v;
                } catch (Exception $e) {
                }
            }
            $el = $gr->addSelect("auto_create_billing_plan")->setLabel(___("Default Level\n" . "users created by demand\n" . "will have access to the sele\n" . "(for example all subscriptions expired)"))->loadOptions($options);
            $auto_create_billing_plan_id = $el->getId();
            $el = $gr->addStatic("auto_create_billing_plan_text")->setContent('<span id=auto_create_billing_plan_text-0><br/>' . ___('please select billing plan to add manual access to users added by demand') . '</span>');
            $auto_create_billing_plan_text_id = $el->getId();
            if ($this->plugin->canAutoCreateFromGroups()) {
                //$group_plans = $gr->addGroup('auto_create_bpgroups');
                $group_plans = $gr;
                unset($options['-1']);
                $group_plans->addStatic()->setContent('<div id="auto_create_billing_plan_products">');
                try {
                    foreach ($this->plugin->getAvailableUserGroups() as $g) {
                        $group_plans->addStatic()->setContent('<div class="acbp_left">' . $g->getTitle() . '</div><div class="acbp_right">');
                        $group_plans->addElement('select', "auto_create_bpgroups_" . $g->getId())->loadOptions($options);
                        $group_plans->addStatic()->setContent('</div><br/>');
                    }
                } catch (Am_Exception_Db $e) {
                    // to avoid errors while db is not yet configured
                }
                $group_plans->addStatic()->setContent('</div>');
            }
            $this->addScript('script_auto_create')->setScript(<<<CUT
\$(function(){
    \$('#{$auto_create_id}').change(function(){
        \$('#{$auto_create_billing_plan_id},#{$auto_create_billing_plan_text_id}').toggle(this.checked);
        \$('#auto_create_billing_plan_products').toggle(\$('#{$auto_create_billing_plan_id}').val()=='-1' && this.checked);
    }).change();
    \$('#{$auto_create_billing_plan_id}').change(function(){
        \$('#auto_create_billing_plan_products').toggle(\$('#{$auto_create_billing_plan_id}').val()=='-1' && \$('#{$auto_create_id}').is(':checked'));
    }).change();
})
CUT
);
        }
        $this->addFieldsPrefix("protect.{$this->pageId}.");
        $this->addScript('script')->setScript($this->getJs());
        if (defined($const = get_class($this->plugin) . "::PLUGIN_STATUS") && (constant($const) == Am_Plugin::STATUS_BETA || constant($const) == Am_Plugin::STATUS_DEV)) {
            $beta = constant($const) == Am_Plugin::STATUS_DEV ? 'ALPHA' : 'BETA';
            $this->addProlog("<div class='warning_box'>This plugin is currently in {$beta} testing stage, some functions may work unstable." . "Please test it carefully before use.</div>");
        }
        $this->plugin->afterAddConfigItems($this);
    }