Example #1
0
function getManageBannersBlock()
{
    $sAsNew = _t('_adm_bann_Insert_as_new');
    $sErrorC = _t('_Error Occured');
    $sApplyChangesC = _t('_Submit');
    $sTopC = _t('_Top');
    $sLeftC = _t('_adm_bann_Left');
    $sRightC = _t('_adm_bann_Right');
    $sBottomC = _t('_Bottom');
    $sHShiftC = _t('_adm_bann_HShift');
    $sVShiftC = _t('_adm_bann_VShift');
    $sTitleC = _t('_Title');
    $sUrlC = _t('_URL');
    $sActiveC = _t('_Active');
    $sTextC = _t('_Text');
    $sStartDateC = _t('_Start date');
    $sEndDateC = _t('_Expiration date');
    $sDefaultC = _t('_adm_bann_default');
    $sPositionOnPageC = _t('_adm_bann_Position_on_the_page');
    // get start & end dates
    $start_date_default = "2008-01-01 00:00:00";
    $end_date_default = "2015-01-01 00:00:00";
    $start_date = bx_get('start_date') !== false ? bx_get('start_date') : $start_date_default;
    $end_date = bx_get('end_date') !== false ? bx_get('end_date') : $end_date_default;
    $Title = $Url = $Active = $Text = $Position = $lhshift = $lvshift = $rhshift = $rvshift = '';
    $iBannerID = (int) $_GET['banner_id'];
    $action = "new";
    if ($iBannerID > 0 && !strlen(bx_get('action'))) {
        //banner edit
        $banns_arr = db_arr("SELECT * FROM `sys_banners` WHERE `ID`='{$iBannerID}'");
        $action = "modify";
        $Title = $banns_arr['Title'];
        $Url = $banns_arr['Url'];
        $Text = $banns_arr['Text'];
        $Active = $banns_arr['Active'];
        $Position = $banns_arr['Position'];
        $lhshift = $banns_arr['lhshift'];
        $lvshift = $banns_arr['lvshift'];
        $rhshift = $banns_arr['rhshift'];
        $rvshift = $banns_arr['rvshift'];
        list($iYearStart, $iMonthStart, $iDayStart) = explode('-', $banns_arr['campaign_start']);
        //$start_date = "{$iDayStart}/{$iMonthStart}/{$iYearStart}";
        $start_date = "{$iYearStart}-{$iMonthStart}-{$iDayStart} 00:00:00";
        list($iYearEnd, $iMonthEnd, $iDayEnd) = explode('-', $banns_arr['campaign_end']);
        //$end_date = "{$iDayEnd}/{$iMonthEnd}/{$iYearEnd}";
        $end_date = "{$iYearEnd}-{$iMonthEnd}-{$iDayEnd} 00:00:00";
    }
    $sFormTitle = htmlspecialchars($Title);
    $sFormUrl = htmlspecialchars($Url);
    $sFormActiveState = $Active ? 'checked="checked"' : '';
    $sFormActiveStateVal = $Active ? 'yes' : '';
    $sFormActiveStateChk = $Active ? true : false;
    $sFormBannerText = $Text;
    $sFormStartDate = $start_date;
    $sFormStartDateDef = $start_date_default;
    $sFormEndDate = $end_date;
    $sFormEndDateDef = $end_date_default;
    $sTopPosState = substr_count($Position, "1") > 0 ? 'checked="checked"' : '';
    $sLeftPosState = substr_count($Position, "2") > 0 ? 'checked="checked"' : '';
    $sRightPosState = substr_count($Position, "3") > 0 ? 'checked="checked"' : '';
    $sBottomPosState = substr_count($Position, "4") > 0 ? 'checked="checked"' : '';
    $sTopShift = substr_count($Position, "2") > 0 ? $lhshift : '';
    $sLeftShift = substr_count($Position, "2") > 0 ? $lvshift : '';
    $sRightShift = substr_count($Position, "3") > 0 ? $rhshift : '';
    $sBottomShift = substr_count($Position, "3") > 0 ? $rvshift : '';
    $sActionAdd = $action == "modify" ? $sAsNew . '&nbsp;<input type=checkbox name=as_new />' : '';
    $sCustomPositions = <<<EOF
<table border=0 width=100% cellspacing=10 cellpading=20>
\t<tr>
\t\t<td colspan=5 align=center><input type=checkbox name="pos_top" {$sTopPosState} />{$sTopC}</td>
\t</tr>
\t<tr>
\t\t<td colspan=2 align=center><input type=checkbox name="pos_left" {$sLeftPosState} />{$sLeftC}</td>
\t\t<td>&nbsp;</td>
\t\t<td colspan=2 align=center><input type=checkbox name="pos_right" {$sRightPosState} />{$sRightC}</td>
\t</tr>
\t<tr>
\t\t<td>{$sHShiftC}</td>
\t\t<td>{$sVShiftC}</td>
\t\t<td>&nbsp;</td>
\t\t<td>{$sHShiftC}</td>
\t\t<td>{$sVShiftC}</td>
\t</tr>
\t<tr>
\t\t<td><input name="lhshift" type=input size=5 value={$sTopShift} /></td>
\t\t<td><input name="lvshift" type=input size=5 value={$sLeftShift} /></td>
\t\t<td>&nbsp;</td>
\t\t<td><input name="rhshift" type=input size=5 value={$sRightShift} /></td>
\t\t<td><input name="rvshift" type=input size=5 value={$sBottomShift} /></td>
\t</tr>
\t<tr>
\t\t<td colspan=5 align=center><input type=checkbox name="pos_bottom" {$sBottomPosState} />{$sBottomC}</td>
\t</tr>
</table>
{$sActionAdd}
EOF;
    $aForm = array('form_attrs' => array('name' => 'apply_ip_list_form', 'action' => $GLOBALS['site']['url_admin'] . 'banners.php', 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_banners', 'key' => 'ID', 'submit_name' => 'add_button')), 'inputs' => array('BannerTitle' => array('type' => 'text', 'name' => 'Title', 'value' => $sFormTitle, 'caption' => $sTitleC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(2, 128), 'error' => _t('_chars_to_chars', 2, 128)), 'db' => array('pass' => 'Xss')), 'BannerUrl' => array('type' => 'text', 'name' => 'Url', 'value' => $sFormUrl, 'caption' => $sUrlC, 'required' => false, 'db' => array('pass' => 'Xss')), 'BannerActive' => array('type' => 'checkbox', 'name' => 'Active', 'caption' => $sActiveC, 'value' => 1, 'checked' => $sFormActiveStateChk), 'BannerText' => array('type' => 'textarea', 'name' => 'Text', 'value' => $sFormBannerText, 'caption' => $sTextC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(10, 32000), 'error' => _t('_chars_to_chars', 10, 32000)), 'db' => array('pass' => 'All')), 'StartDate' => array('type' => 'datetime', 'name' => 'start_date', 'value' => $sFormStartDate, 'caption' => $sStartDateC, 'label' => "{$sDefaultC}: {$sFormStartDateDef}", 'required' => true, 'checker' => array('func' => 'DateTime', 'error' => $sErrorC), 'display' => 'filterDate'), 'EndDate' => array('type' => 'datetime', 'name' => 'end_date', 'value' => $sFormEndDate, 'caption' => $sEndDateC, 'label' => "{$sDefaultC}: {$sFormEndDateDef}", 'required' => true, 'checker' => array('func' => 'DateTime', 'error' => $sErrorC), 'display' => 'filterDate'), 'Positions' => array('type' => 'custom', 'name' => 'Position', 'caption' => $sPositionOnPageC, 'content' => $sCustomPositions), 'ID' => array('type' => 'hidden', 'name' => 'banner_id', 'value' => $iBannerID), 'Action' => array('type' => 'hidden', 'name' => 'action', 'value' => $action), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sApplyChangesC)));
    $sResult = '';
    $oForm = new BxTemplFormView($aForm);
    $oForm->initChecker();
    if ($oForm->isSubmittedAndValid()) {
        list($iYearStart, $iMonthStart, $iDayStart) = explode('-', $oForm->getCleanValue('start_date'));
        $sDateStart = "{$iYearStart}-{$iMonthStart}-{$iDayStart}";
        list($iYearEnd, $iMonthEnd, $iDayEnd) = explode('-', $oForm->getCleanValue('end_date'));
        $sDateEnd = "{$iYearEnd}-{$iMonthEnd}-{$iDayEnd}";
        $sCurTime = date("Y-m-d");
        // 2010-12-31
        $iLastId = (int) $oForm->getCleanValue('banner_id');
        $banner_pos = "";
        if ($oForm->getCleanValue('pos_top') == "on") {
            $banner_pos .= '1';
        }
        if ($oForm->getCleanValue('pos_left') == "on") {
            $banner_pos .= '2';
        }
        if ($oForm->getCleanValue('pos_right') == "on") {
            $banner_pos .= '3';
        }
        if ($oForm->getCleanValue('pos_bottom') == "on") {
            $banner_pos .= '4';
        }
        $banner_pos = (int) $banner_pos;
        $banner_lhshift = (int) $oForm->getCleanValue('lhshift');
        $banner_lvshift = (int) $oForm->getCleanValue('lvshift');
        $banner_rhshift = (int) $oForm->getCleanValue('rhshift');
        $banner_rvshift = (int) $oForm->getCleanValue('rvshift');
        $aValsAdd = array('Position' => $banner_pos, 'Active' => '' != $oForm->getCleanValue('Active') ? 1 : 0, 'Created' => $sCurTime, 'campaign_start' => $sDateStart, 'campaign_end' => $sDateEnd, 'lhshift' => $banner_lhshift, 'lvshift' => $banner_lvshift, 'rhshift' => $banner_rhshift, 'rvshift' => $banner_rvshift);
        if ($oForm->getCleanValue('action') == 'modify' && $oForm->getCleanValue('as_new') != "on" && $iLastId > 0) {
            $oForm->update($iLastId, $aValsAdd);
        }
        if ($oForm->getCleanValue('action') == 'new' || $oForm->getCleanValue('as_new') == "on" && $oForm->getCleanValue('action') == 'modify') {
            $iLastId = $oForm->insert($aValsAdd);
        }
        $sResult = $iLastId > 0 ? MsgBox(_t('_Success'), 3) : MsgBox($sErrorC);
    }
    return DesignBoxContent(_t('_adm_bann_title'), $sResult . $oForm->getCode(), 1);
}
 /**
  * 'recheck' action handler
  */
 public function performActionAdd()
 {
     bx_import('BxTemplFormView');
     $aForm = array('form_attrs' => array('id' => 'bx_antispam_form_dnsbl_add', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=bx_antispam_grid_dnsbl&a=add', 'method' => 'post'), 'params' => array('db' => array('table' => 'bx_antispam_dnsbl_rules', 'key' => 'id', 'submit_name' => 'do_submit')), 'inputs' => array('country' => array('type' => 'select', 'name' => 'country', 'caption' => _t('_bx_antispam_field_country'), 'values' => BxDolForm::getDataItems('Country')), 'chain' => array('type' => 'radio_set', 'name' => 'chain', 'caption' => _t('_bx_antispam_field_action'), 'values' => array('spammers' => _t('_bx_antispam_chain_spammers'), 'whitelist' => _t('_bx_antispam_chain_whitelist')), 'value' => 'spammers'), 'submit' => array('type' => 'input_set', 0 => array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_sys_submit')), 1 => array('type' => 'reset', 'name' => 'close', 'value' => _t('_sys_close'), 'attrs' => array('class' => 'bx-def-margin-sec-left', 'onclick' => '$(\'.bx-popup-applied:visible\').dolPopupHide();')))));
     $oForm = new BxTemplFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         // if form is submitted and all fields are valid
         $aCustomValues = array('chain' => $oForm->getCleanValue('chain'), 'zonedomain' => sprintf("%s.countries.nerd.dk.", strtolower($oForm->getCleanValue('country'))), 'postvresp' => '127.0.0.2', 'url' => 'http://countries.nerd.dk/', 'comment' => '_bx_antispam_rule_note_country', 'added' => time(), 'active' => 1);
         $iRecentId = $oForm->insert($aCustomValues, true);
         // insert new record
         if ($iRecentId) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iRecentId);
         } else {
             $aRes = array('msg' => _t('_sys_txt_error_occured'));
         }
         // if record adding failed, display error message
         $this->_echoResultJson($aRes, true);
     } else {
         // if form is not submitted or some fields are invalid, display popup with form
         bx_import('BxTemplFunctions');
         $s = BxTemplFunctions::getInstance()->popupBox($oForm->getId() . '_form', _t('_bx_antispam_popup_dnsbl_add'), $oForm->getCode() . '
             <script>
                 $(document).ready(function () {
                     $("#' . $oForm->getId() . '").ajaxForm({
                         dataType: "json",
                         beforeSubmit: function (formData, jqForm, options) {
                             bx_loading($("#' . $oForm->getId() . '"), true);
                         },
                         success: function (data) {
                             $(".bx-popup-applied:visible").dolPopupHide();
                             glGrids.' . $this->_sObject . '.processJson(data, "add");
                         }
                     });
                 });
             </script>');
         $this->_echoResultJson(array('popup' => array('html' => $s, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Example #3
0
 function getEditForm($aValues, $aAddFields = array())
 {
     $oCategories = new BxDolCategories();
     if (isset($this->_aForm['inputs']['categories'])) {
         //--- convert post form to edit one ---//
         $this->_aForm['inputs']['categories'] = $oCategories->getGroupChooser($this->_oModule->_oConfig->getCategoriesSystemName(), $this->_iOwnerId, true, $aValues['categories']);
     }
     if (!empty($aValues) && is_array($aValues)) {
         foreach ($aValues as $sKey => $sValue) {
             if (array_key_exists($sKey, $this->_aForm['inputs'])) {
                 if ($this->_aForm['inputs'][$sKey]['type'] == 'checkbox') {
                     $this->_aForm['inputs'][$sKey]['checked'] = (int) $sValue == 1 ? true : false;
                 } else {
                     if ($this->_aForm['inputs'][$sKey]['type'] == 'select_box' && $this->_aForm['inputs'][$sKey]['name'] == 'Categories') {
                         $aCategories = preg_split('/[' . $oCategories->sTagsDivider . ']/', $sValue, 0, PREG_SPLIT_NO_EMPTY);
                         $this->_aForm['inputs'][$sKey]['value'] = $aCategories;
                     } else {
                         $this->_aForm['inputs'][$sKey]['value'] = $sValue;
                     }
                 }
             }
         }
         unset($this->_aForm['inputs']['author_id']);
         $this->_aForm['inputs']['id'] = array('type' => 'hidden', 'name' => 'id', 'value' => $aValues['id'], 'db' => array('pass' => 'Int'));
         $this->_aForm['inputs']['post']['value'] = _t("_td_edit");
     }
     $oForm = new BxTemplFormView($this->_aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $iDateNow = mktime();
         $iDatePublish = $oForm->getCleanValue('when');
         if ($iDatePublish > $iDateNow) {
             $iStatus = BX_TD_STATUS_PENDING;
         } else {
             if ($iDatePublish <= $iDateNow && $this->_oModule->_oConfig->isAutoapprove()) {
                 $iStatus = BX_TD_STATUS_ACTIVE;
             } else {
                 $iStatus = BX_TD_STATUS_INACTIVE;
             }
         }
         $aDefFields = array('date' => $iDateNow, 'status' => $iStatus);
         $oForm->update($aValues['id'], array_merge($aDefFields, $aAddFields));
         //--- 'System' -> Edit for Alerts Engine ---//
         bx_import('BxDolAlerts');
         $oAlert = new BxDolAlerts($this->_oModule->_oConfig->getAlertsSystemName(), 'edit', $aValues['id'], $this->_iOwnerId);
         $oAlert->alert();
         //--- 'System' -> Edit for Alerts Engine ---//
         //--- Reparse Global Tags ---//
         $oTags = new BxDolTags();
         $oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(), $aValues['id']);
         //--- Reparse Global Tags ---//
         //--- Reparse Global Categories ---//
         $oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(), $aValues['id']);
         //--- Reparse Global Categories ---//
         header('Location: ' . $oForm->aFormAttrs['action']);
     } else {
         return $oForm->getCode();
     }
 }
Example #4
0
function _getLevelsCreateForm($iLevelId, $bActive = false)
{
    $sSubmitUrl = BX_DOL_URL_ADMIN . 'memb_levels.php';
    $aLevel = array();
    if (($bEdit = $iLevelId != 0) === true) {
        $aLevel = $GLOBALS['MySQL']->getRow("SELECT `Name` AS `Name`, `Description` AS `Description`, `Order` AS `Order` FROM `sys_acl_levels` WHERE `ID`='" . $iLevelId . "' LIMIT 1");
    }
    $aForm = array('form_attrs' => array('id' => 'adm-mlevels-create', 'action' => $sSubmitUrl . '?tab=levels_add', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'sys_acl_levels', 'key' => 'ID', 'uri' => '', 'uri_title' => '', 'submit_name' => 'Submit')), 'inputs' => array('Active' => array('type' => 'hidden', 'name' => 'Active', 'value' => 'no', 'db' => array('pass' => 'Xss')), 'Purchasable' => array('type' => 'hidden', 'name' => 'Purchasable', 'value' => 'yes', 'db' => array('pass' => 'Xss')), 'Removable' => array('type' => 'hidden', 'name' => 'Removable', 'value' => 'yes', 'db' => array('pass' => 'Xss')), 'Name' => array('type' => 'text', 'name' => 'Name', 'caption' => _t('_adm_txt_mlevels_name'), 'value' => isset($aLevel['Name']) ? $aLevel['Name'] : '', 'required' => true, 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_adm_txt_mlevels_name_err'))), 'Icon' => array('type' => 'file', 'name' => 'Icon', 'caption' => _t('_adm_txt_mlevels_icon'), 'required' => true, 'checker' => array('func' => '', 'params' => '', 'error' => _t('_adm_txt_mlevels_icon_err'))), 'Description' => array('type' => 'textarea', 'name' => 'Description', 'caption' => _t('_adm_txt_mlevels_description'), 'value' => isset($aLevel['Description']) ? $aLevel['Description'] : '', 'db' => array('pass' => 'XssHtml')), 'Order' => array('type' => 'text', 'name' => 'Order', 'caption' => _t('_adm_txt_mlevels_order'), 'value' => isset($aLevel['Order']) ? $aLevel['Order'] : 0, 'required' => true, 'db' => array('pass' => 'Int'), 'checker' => array('func' => 'preg', 'params' => array('/^[1-9][0-9]*$/'), 'error' => _t('_adm_txt_mlevels_order_err'))), 'Submit' => array('type' => 'submit', 'name' => 'Submit', 'value' => _t('_adm_btn_mlevels_add'))));
    //--- Convert Add to Edit
    if ($bEdit) {
        unset($aForm['inputs']['Active']);
        unset($aForm['inputs']['Purchasable']);
        unset($aForm['inputs']['Removable']);
        unset($aForm['inputs']['Icon']);
        $aForm['form_attrs']['action'] = $sSubmitUrl . '?action=edit&level=' . $iLevelId;
        $aForm['inputs']['Submit']['value'] = _t('_adm_btn_mlevels_save');
        $aForm['inputs']['ID'] = array('type' => 'hidden', 'name' => 'ID', 'value' => $iLevelId, 'db' => array('pass' => 'Int'));
    }
    $oForm = new BxTemplFormView($aForm);
    $oForm->initChecker();
    if ($oForm->isSubmittedAndValid()) {
        //--- Add new level
        if (!$bEdit) {
            $sFilePath = BX_DIRECTORY_PATH_ROOT . 'media/images/membership/';
            $sFileName = time();
            $sFileExt = '';
            if ($GLOBALS['MySQL']->getOne("SELECT `Name` FROM `sys_acl_levels` WHERE `Name`='" . $oForm->getCleanValue('Name') . "' LIMIT 1")) {
                $oForm->aInputs['Name']['error'] = _t('_adm_txt_mlevels_name_err_non_uniq');
            } elseif (isImage($_FILES['Icon']['type'], $sFileExt) && !empty($_FILES['Icon']['tmp_name']) && move_uploaded_file($_FILES['Icon']['tmp_name'], $sFilePath . $sFileName . '.' . $sFileExt)) {
                $sPath = $sFilePath . $sFileName . '.' . $sFileExt;
                imageResize($sPath, $sPath, 110, 110);
                $iId = (int) $oForm->insert(array('Icon' => $sFileName . '.' . $sFileExt));
                if ($iId != 0) {
                    $sName = $oForm->getCleanValue('Name');
                    addStringToLanguage('_adm_txt_mp_' . strtolower($sName), $sName);
                }
                header('Location: ' . $sSubmitUrl);
                exit;
            } else {
                $oForm->aInputs['Icon']['error'] = $oForm->aInputs['Icon']['checker']['error'];
            }
        } else {
            $bResult = $oForm->update($iLevelId);
            if ($bResult !== false) {
                deleteStringFromLanguage('_adm_txt_mp_' . strtolower($aLevel['Name']));
                $sName = $oForm->getCleanValue('Name');
                addStringToLanguage('_adm_txt_mp_' . strtolower($sName), $sName);
            }
            header('Location: ' . $sSubmitUrl);
            exit;
        }
    }
    return $GLOBALS['oAdmTemplate']->parseHtmlByName('mlevels_create.html', array('display' => $bActive ? 'block' : 'none', 'form' => $oForm->getCode()));
}
Example #5
0
    function getBlockCode_Membership()
    {
        if (!isAdmin()) {
            return;
        }
        $sUnlimited = process_line_output(_t('_pfm_unlimited'));
        $this->aFormMembership = array('form_attrs' => array('id' => 'profile_edit_membership', 'name' => 'profile_edit_membership', 'action' => BX_DOL_URL_ROOT . 'pedit.php?ID=' . $this->iProfileID, 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => '', 'key' => '', 'uri' => '', 'uri_title' => '', 'submit_name' => 'save_membership')), 'inputs' => array('doSetMembership' => array('type' => 'hidden', 'name' => 'doSetMembership', 'value' => 'yes'), 'MembershipInfo' => array('type' => 'custom', 'caption' => _t('_Membership_current'), 'content' => ''), 'MembershipID' => array('type' => 'select', 'name' => 'MembershipID', 'caption' => _t('_Membership_name'), 'value' => '', 'values' => array(), 'required' => 0, 'attrs' => array('onchange' => 'checkStandard()'), 'checker' => array('func' => 'avail', 'params' => array(), 'error' => _t('_Membership_name_err_empty')), 'db' => array('pass' => 'Int')), 'MembershipDays' => array('type' => 'text', 'name' => 'MembershipDays', 'caption' => _t('_Membership_days'), 'value' => $sUnlimited, 'required' => 0, 'attrs' => array('onfocus' => "if(MembershipDays.value == '" . $sUnlimited . "') MembershipDays.value = ''", 'onblur' => "if(MembershipDays.value == '') MembershipDays.value = '" . $sUnlimited . "'"), 'info' => _t('_Membership_days_info'), 'db' => array('pass' => 'Xss')), 'MembershipImmediately' => array('type' => 'checkbox', 'name' => 'MembershipImmediately', 'caption' => _t('_Membership_starts'), 'value' => 'on', 'required' => 0, 'db' => array('pass' => 'Xss')), 'save_membership' => array('type' => 'submit', 'name' => 'save_membership', 'value' => _t('_Membership_save'))));
        $aMemberships = getMemberships();
        foreach ($aMemberships as $iId => $sName) {
            if ($iId != MEMBERSHIP_ID_NON_MEMBER) {
                $this->aFormMembership['inputs']['MembershipID']['values'][] = array('key' => $iId, 'value' => $sName);
            }
        }
        $oForm = new BxTemplFormView($this->aFormMembership);
        $oForm->initChecker();
        $sContent = "";
        if ($oForm->isSubmittedAndValid()) {
            $iMshipID = (int) $oForm->getCleanValue('MembershipID');
            $iMshipDays = (int) $oForm->getCleanValue('MembershipDays');
            //0 = unlim
            $bStartsNow = $oForm->getCleanValue('MembershipImmediately') == 'on';
            $bSave = setMembership($this->iProfileID, $iMshipID, $iMshipDays, $bStartsNow);
            $sContent .= MsgBox(_t($bSave ? '_Membership_save_msg_saved' : '_Membership_save_err_saved'), 3);
        }
        /**
         * Retrieve current membership info.
         */
        $aMembershipCurrent = getMemberMembershipInfo($this->iProfileID);
        $sMembershipCurrent = $aMembershipCurrent['Name'];
        if ($aMembershipCurrent['ID'] != MEMBERSHIP_ID_STANDARD) {
            $sMembershipCurrent .= ', ' . (!isset($aMembershipCurrent['DateExpires']) ? _t('_MEMBERSHIP_EXPIRES_NEVER') : _t('_MEMBERSHIP_EXPIRES', defineTimeInterval($aMembershipCurrent['DateExpires'])));
        }
        $oForm->aInputs['MembershipInfo']['content'] = $sMembershipCurrent;
        ob_start();
        ?>
        <script type="text/javascript">
        <!--
        function checkStandard()
        {
            var iId = parseInt($("[name='MembershipID']").val());
            if(iId == <?php 
        echo MEMBERSHIP_ID_STANDARD;
        ?>
) {
                $("[name='MembershipDays']").attr('disabled', 'disabled');
                $("[name='MembershipImmediately']").attr('disabled', 'disabled');
            } else {
                $("[name='MembershipDays']").removeAttr('disabled');
                $("[name='MembershipImmediately']").removeAttr('disabled');
            }
        }
        $(document).ready(function() {
            checkStandard();
        });
        -->
        </script>
<?php 
        $sContent .= ob_get_clean();
        return array($sContent . $oForm->getCode(), array(), array(), false);
    }
Example #6
0
/**
 * Change member's menu position ;
 *
 * @param $iProfileId integer
 * @param $sMenuPosition string
 * @param $sAction string
 * @return text - html presentation data
 */
function PageListMemberMenuSettings($iProfileId, $sAction)
{
    $iProfileId = (int) $iProfileId;
    // define default menu position;
    if (isset($_COOKIE['menu_position'])) {
        $sDefaultValue = clear_xss($_COOKIE['menu_position']);
    } else {
        $sDefaultValue = getParam('ext_nav_menu_top_position');
    }
    //get form
    $aForm = array('form_attrs' => array('action' => BX_DOL_URL_ROOT . 'list_pop.php?action=' . clear_xss($sAction), 'method' => 'post', 'name' => 'menu_position_form'), 'params' => array('db' => array('submit_name' => 'do_submit')), 'inputs' => array(array('type' => 'radio_set', 'name' => 'menu_settings', 'caption' => 'Position', 'dv' => '<br />', 'values' => array('top' => _t('_Top'), 'bottom' => _t('_Bottom'), 'static' => _t('_Static')), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 6), 'error' => _t('_Error occured')), 'value' => $sDefaultValue, 'db' => array('pass' => 'Xss')), array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_Save Changes'))));
    $oForm = new BxTemplFormView($aForm);
    $oForm->initChecker();
    if ($oForm->isSubmittedAndValid()) {
        $sCode = MsgBox(_t('_Saved'));
        $sCode .= '
            <script type="text/javascript">
                opener.location.reload();
                window.close();
            </script>
        ';
        //change menu position
        setcookie("menu_position", $oForm->getCleanValue('menu_settings'), time() + 60 * 60 * 24 * 180);
        //clear member menu cache
        bx_import('BxDolMemberMenu');
        $oMemberMenu = new BxDolMemberMenu();
        $oMemberMenu->deleteMemberMenuKeyFile($iProfileId);
    } else {
        $sCode = $oForm->getCode();
    }
    return $sCode;
}