function getFormCode() { $oForm = new BxTemplFormView($this->aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $aValsAdd = array('Date' => time(), 'Uri' => $oForm->generateUri(), 'Status' => 'active', 'Owner' => $this->iOwnerId); if ($this->iAlbumId > 0 && $this->aInfo['Owner'] == $this->iOwnerId) { $aValsAdd = array('Date' => time()); if (!$oForm->update($this->iAlbumId, $aValsAdd)) { return MsgBox(_t('_sys_album_save_error')); } else { return MsgBox(_t('_sys_album_save_succ')); } } else { $iAlbumId = $oForm->insert($aValsAdd); if (!$iAlbumId) { return MsgBox(_t('_sys_album_save_error')); } else { return MsgBox(_t('_sys_album_save_succ')); } } } else { return $oForm->getCode(); } }
function getPostForm($iUnitID = 0) { $sAddNewC = _t('_bx_quotes_add_new'); $sAction = 'add'; $sQText = $sQText = ''; if ($iUnitID) { $aQinfo = $this->_oDb->getQuote($iUnitID); $sQText = $aQinfo['Text']; $sQAuthor = $aQinfo['Author']; $sAction = 'edit'; } $aForm = array('form_attrs' => array('name' => 'create_quotes_form', 'action' => BX_DOL_URL_ROOT . 'modules/?r=quotes/administration/', 'method' => 'post'), 'params' => array('db' => array('table' => 'bx_quotes_units', 'key' => 'ID', 'submit_name' => 'add_button')), 'inputs' => array('action' => array('type' => 'hidden', 'name' => 'action', 'value' => $sAction), 'Text' => array('type' => 'textarea', 'name' => 'Text', 'caption' => _t('_bx_quotes_text'), 'required' => true, 'value' => $sQText, 'checker' => array('func' => 'length', 'params' => array(3, 1024), 'error' => _t('_bx_quotes_text_err', 1024)), 'db' => array('pass' => 'Xss')), 'Author' => array('type' => 'text', 'name' => 'Author', 'caption' => _t('_bx_quotes_author'), 'required' => true, 'value' => $sQAuthor, 'checker' => array('func' => 'length', 'params' => array(3, 128), 'error' => _t('_bx_quotes_author_err', 128)), 'db' => array('pass' => 'Xss')), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => _t('_Submit')))); if ($iUnitID) { $aForm['inputs']['hidden_unitid'] = array('type' => 'hidden', 'name' => 'ID', 'value' => $iUnitID); } $sCode = ''; $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $sCode = MsgBox(_t('_bx_quotes_fail'), 1); $aValsAdd = array(); $iLastId = -1; if ($iUnitID > 0) { $oForm->update($iUnitID, $aValsAdd); $iLastId = $iUnitID; $sCode = MsgBox(_t('_bx_quotes_edited_success'), 1); } else { $iLastId = $oForm->insert($aValsAdd); $sCode = MsgBox(_t('_bx_quotes_success'), 1); } } return DesignBoxAdmin($sAddNewC, $sCode . $oForm->getCode(), '', '', 11); }
function insert($aValsToAdd = array()) { $aValsToAdd['client_id'] = strtolower(genRndPwd(self::$LENGTH_ID, false)); $aValsToAdd['client_secret'] = strtolower(genRndPwd(self::$LENGTH_SECRET, false)); $aValsToAdd['scope'] = 'basic'; $aValsToAdd['user_id'] = getLoggedId(); return parent::insert($aValsToAdd); }
public function insert($aValsToAdd = array(), $isIgnore = false) { $CNF =& $this->_oModule->_oConfig->CNF; if (isset($CNF['FIELD_AUTHOR']) && empty($aValsToAdd[$CNF['FIELD_AUTHOR']])) { $aValsToAdd[$CNF['FIELD_AUTHOR']] = bx_get_logged_profile_id(); } if (isset($CNF['FIELD_ADDED']) && empty($aValsToAdd[$CNF['FIELD_ADDED']])) { $aValsToAdd[$CNF['FIELD_ADDED']] = time(); } if (isset($CNF['FIELD_CHANGED']) && empty($aValsToAdd[$CNF['FIELD_CHANGED']])) { $aValsToAdd[$CNF['FIELD_CHANGED']] = time(); } return parent::insert($aValsToAdd, $isIgnore); }
function getPostForm($aAddFields = array()) { $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('uri' => $oForm->generateUri(), 'date' => $iDateNow, 'status' => $iStatus); $iId = $oForm->insert(array_merge($aDefFields, $aAddFields)); //--- 'System' -> Post for Alerts Engine ---// bx_import('BxDolAlerts'); $oAlert = new BxDolAlerts($this->_oModule->_oConfig->getAlertsSystemName(), 'post', $iId, $this->_iOwnerId); $oAlert->alert(); //--- 'System' -> Post for Alerts Engine ---// //--- Reparse Global Tags ---// $oTags = new BxDolTags(); $oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(), $iId); //--- Reparse Global Tags ---// //--- Reparse Global Categories ---// $oCategories = new BxDolCategories(); $oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(), $iId); //--- Reparse Global Categories ---// header('Location: ' . $oForm->aFormAttrs['action']); } else { return $oForm->getCode(); } }
/** * '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); } }
function getEmailMessage($sAction) { $sErrorC = _t('_Error Occured'); $sApplyChangesC = _t('_Save'); $sSubjectC = _t('_Subject'); $sBodyC = _t('_adm_mmail_Body'); $sTextBodyC = _t('_adm_mmail_Text_email_body'); $sPreviewMessageC = _t('_Preview'); $sDeleteC = _t('_Delete'); $sMessageID = (int) $_POST['msgs_id']; $sSubject = $sBody = ""; if ($_POST['body'] && $_POST['action'] != 'delete') { $sSubject = process_pass_data($_POST['subject']); $sBody = process_pass_data($_POST['body']); } elseif ($sMessageID) { list($sSubject, $sBody) = $GLOBALS['MySQL']->getRow("SELECT `subject`, `body` FROM `sys_sbs_messages` WHERE `id`='" . $sMessageID . "' LIMIT 1", MYSQL_NUM); } $sSubject = htmlspecialchars($sSubject); $aForm = array('form_attrs' => array('name' => 'sys_sbs_messages', 'action' => $GLOBALS['site']['url_admin'] . 'notifies.php', 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_sbs_messages', 'key' => 'ID', 'submit_name' => 'add_message')), 'inputs' => array('subject' => array('type' => 'text', 'name' => 'subject', 'value' => $sSubject, 'caption' => $sSubjectC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(2, 128), 'error' => $sErrorC), 'db' => array('pass' => 'Xss')), 'body' => array('type' => 'textarea', 'name' => 'body', 'value' => $sBody, 'caption' => $sBodyC, 'required' => true, 'html' => 2, 'attrs' => array('style' => "height:400px;"), 'checker' => array('func' => 'length', 'params' => array(10, 32000), 'error' => $sErrorC), 'db' => array('pass' => 'XssHtml')), 'msgs_id' => array('type' => 'hidden', 'name' => 'msgs_id', 'value' => $sMessageID), 'control' => array('type' => 'input_set', array('type' => 'submit', 'name' => 'add_message', 'caption' => $sApplyChangesC, 'value' => $sApplyChangesC), array('type' => 'submit', 'name' => 'preview_message', 'caption' => $sPreviewMessageC, 'value' => $sPreviewMessageC)))); if ($sMessageID) { $aForm['inputs']['control'][] = array('type' => 'submit', 'name' => 'delete_message', 'caption' => $sDeleteC, 'value' => $sDeleteC); } $sResult = ''; $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { if ($sAction == 'add') { if ($sMessageID > 0) { $oForm->update($sMessageID); } else { $sMessageID = $oForm->insert(); } } $sResult = $sMessageID > 0 ? MsgBox(_t('_Success'), 3) : MsgBox($sErrorC); } return DesignBoxContent(_t('_adm_mmail_Email_message'), $sResult . $oForm->getCode(), 11); }
/** * Generate a Form to Create Blog * * @return HTML presentation of data */ function GenCreateBlogForm($bBox = true) { $this->CheckLogged(); if (!$this->isAllowedPostAdd()) { return $this->_oTemplate->displayAccessDenied(); } $sRetHtml = $sCreateForm = ''; $sActionsC = _t('_Actions'); $sPleaseCreateBlogC = _t('_bx_blog_Please_create_blog'); $sNoBlogC = _t('_bx_blog_No_blogs_available'); $sMyBlogC = _t('_bx_blog_My_blog'); $sNewBlogDescC = _t('_bx_blog_description'); $sErrorC = _t('_bx_blog_create_blog_form_error'); $sSubmitC = _t('_Submit'); $sRetHtml .= MsgBox($sNoBlogC); if ($this->_iVisitorID || $this->isAdmin()) { $sRetHtml = MsgBox($sPleaseCreateBlogC); $sLink = $this->genBlogFormUrl(); $sAddingForm = ''; //adding form $aForm = array('form_attrs' => array('name' => 'CreateBlogForm', 'action' => $sLink, 'method' => 'post'), 'params' => array('db' => array('table' => $this->_oConfig->sSQLBlogsTable, 'key' => 'ID', 'submit_name' => 'add_button')), 'inputs' => array('header1' => array('type' => 'block_header', 'caption' => $sPleaseCreateBlogC), 'Description' => array('type' => 'textarea', 'html' => 0, 'name' => 'Description', 'caption' => $sNewBlogDescC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 255), 'error' => $sErrorC), 'db' => array('pass' => 'XssHtml')), 'hidden_action' => array('type' => 'hidden', 'name' => 'action', 'value' => 'create_blog'), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sSubmitC))); $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $this->CheckLogged(); $iOwnID = $this->_iVisitorID; $aBlogsRes = $this->_oDb->getBlogInfo($iOwnID); if (!$aBlogsRes) { $aValsAdd = array('OwnerID' => $iOwnID); $iBlogID = $oForm->insert($aValsAdd); //return $this->GenMemberBlog($iOwnID, false); $bUseFriendlyLinks = $this->isPermalinkEnabled(); $sBlogAddLink = $bUseFriendlyLinks ? BX_DOL_URL_ROOT . 'blogs/my_page/add/' : $this->genBlogFormUrl() . '?action=my_page&mode=add'; header('Location:' . $sBlogAddLink); return $this->GenMyPageAdmin('add'); } else { return MsgBox($sErrorC); } } else { $sAddingForm = $oForm->getCode(); } $aVars = array('content' => $sAddingForm); $sAddingForm = $this->_oTemplate->parseHtmlByName('default_padding.html', $aVars); $sCreateForm = $bBox ? DesignBoxContent($sActionsC, $sAddingForm, 1) : $sAddingForm; } $sMyBlogResult = $bBox ? DesignBoxContent($sMyBlogC, $sRetHtml, 1) : $sRetHtml; return $sMyBlogResult . $sCreateForm; }
function getAddSubcatForm($iSubCategoryID = 0, $bOnlyForm = false) { //admin side only $sSubmitC = _t('_bx_ads_add_subcategory'); $sAction = 'add_sub_category'; $aParentCategories = array(); $vParentValues = $this->_oDb->getAllCatsInfo(); while ($aCategInfo = mysql_fetch_assoc($vParentValues)) { $iID = $aCategInfo['ID']; $sName = $aCategInfo['Name']; $aParentCategories[$iID] = $sName; } $sTitle = $sDescription = ''; $iParentID = 0; if ($iSubCategoryID) { $aSubcatInfos = $this->_oDb->getSubcatInfo($iSubCategoryID); $sTitle = $aSubcatInfos[0]['NameSub']; $sDescription = $aSubcatInfos[0]['Description']; $iParentID = (int) $aSubcatInfos[0]['IDClassified']; } //adding form $aForm = array('form_attrs' => array('name' => 'create_sub_cats_form', 'action' => 'javascript: void(0)', 'method' => 'post'), 'params' => array('db' => array('table' => $this->_oConfig->sSQLSubcatTable, 'key' => 'ID', 'submit_name' => 'add_button')), 'inputs' => array('action' => array('type' => 'hidden', 'name' => 'action', 'value' => $sAction), 'IDClassified' => array('type' => 'select', 'name' => 'IDClassified', 'caption' => _t('_bx_ads_parent_category'), 'values' => $aParentCategories, 'value' => $iParentID, 'db' => array('pass' => 'Int')), 'NameSub' => array('type' => 'text', 'name' => 'NameSub', 'caption' => _t('_Title'), 'required' => true, 'value' => $sTitle, 'checker' => array('func' => 'length', 'params' => array(3, 128), 'error' => _t('_bx_ads_title_error_desc', 128)), 'db' => array('pass' => 'Xss')), 'Description' => array('type' => 'text', 'name' => 'Description', 'caption' => _t('_Description'), 'value' => $sDescription, 'db' => array('pass' => 'Xss')), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sSubmitC, 'attrs' => array('onClick' => "AdmCreateSubcategory('{$this->sHomeUrl}{$this->sCurrBrowsedFile}'); return false;")))); if ($iSubCategoryID) { $aForm['inputs']['hidden_postid'] = array('type' => 'hidden', 'name' => 'id', 'value' => $iSubCategoryID); } $sCode = ''; $sJS = $this->_oTemplate->addJs('main.js', true); $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $aValsAdd = array(); if ($iSubCategoryID == 0) { $sCategUri = uriGenerate(bx_get('NameSub'), $this->_oConfig->sSQLSubcatTable, 'SEntryUri'); $aValsAdd['SEntryUri'] = $sCategUri; } $iLastId = -1; if ($iSubCategoryID > 0) { $oForm->update($iSubCategoryID, $aValsAdd); $iLastId = $iSubCategoryID; } else { $iLastId = $oForm->insert($aValsAdd); } if ($iLastId > 0) { $sCode = MsgBox(_t('_bx_ads_Sub_category_successfully_added'), 3); } else { $sCode = MsgBox(_t('_bx_ads_Sub_category_failed_add'), 3); } } if ($bOnlyForm) { return $sCode . $oForm->getCode(); } $sResult = $sJS . $sCode . $oForm->getCode(); if (bx_get('mode') == 'json') { require_once BX_DIRECTORY_PATH_PLUGINS . 'Services_JSON.php'; $oJson = new Services_JSON(); return $oJson->encode($sResult); exit; } $sResult = $this->_oTemplate->parseHtmlByName('default_margin.html', array('content' => $sResult)); return $GLOBALS['oFunctions']->popupBox('ads_add_sub_category', _t('_bx_ads_add_subcategory'), $sResult); }
function getManagingForm() { $sApplyChangesC = _t('_sys_admin_apply'); $sFromC = _t('_From'); $sToC = _t('_To'); $sSampleC = _t('_adm_ipbl_sample'); $sTypeC = _t('_adm_ipbl_IP_Role'); $sDescriptionC = _t('_Description'); $sDatatimeC = _t('_adm_ipbl_Date_of_finish'); $sErrorC = _t('_Error Occured'); $aForm = array('form_attrs' => array('name' => 'apply_ip_list_form', 'action' => $this->_sActionUrl, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_ip_list', 'key' => 'ID', 'submit_name' => 'add_button')), 'inputs' => array('FromIP' => array('type' => 'text', 'name' => 'from', 'caption' => $sFromC, 'info' => $sSampleC . ': 10.0.0.0', 'required' => true, 'checker' => array('func' => 'length', 'params' => array(7, 15), 'error' => $sErrorC)), 'ToIP' => array('type' => 'text', 'name' => 'to', 'caption' => $sToC, 'info' => $sSampleC . ': 10.0.0.100', 'required' => true, 'checker' => array('func' => 'length', 'params' => array(7, 15), 'error' => $sErrorC)), 'IPRole' => array('type' => 'select', 'name' => 'type', 'caption' => $sTypeC, 'values' => array('allow', 'deny'), 'required' => true), 'DateTime' => array('type' => 'datetime', 'name' => 'LastDT', 'caption' => $sDatatimeC, 'required' => true, 'checker' => array('func' => 'DateTime', 'error' => $sErrorC), 'db' => array('pass' => 'DateTime')), 'Desc' => array('type' => 'text', 'name' => 'desc', 'caption' => $sDescriptionC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(2, 128), 'error' => $sErrorC), 'db' => array('pass' => 'Xss')), 'ID' => array('type' => 'hidden', 'value' => '0', 'name' => 'id'), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sApplyChangesC))); $sResult = ''; $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { /*list($iDay, $iMonth, $iYear) = explode( '/', $_REQUEST['datatime']); $iDay = (int)$iDay; $iMonth = (int)$iMonth; $iYear = (int)$iYear; //$sCurTime = date("Y:m:d H:i:s");// 2012-06-20 15:46:21 $sCurTime = "{$iYear}:{$iMonth}:{$iDay} 12:00:00";*/ $sFrom = sprintf("%u", ip2long($_REQUEST['from'])); $sTo = sprintf("%u", ip2long($_REQUEST['to'])); $sType = (int) $_REQUEST['type'] == 1 ? 'deny' : 'allow'; $aValsAdd = array('From' => $sFrom, 'To' => $sTo, 'Type' => $sType); $iLastId = (int) $_REQUEST['id'] > 0 ? (int) $_REQUEST['id'] : -1; if ($iLastId > 0) { $oForm->update($iLastId, $aValsAdd); } else { $iLastId = $oForm->insert($aValsAdd); } $sResult = $iLastId > 0 ? MsgBox(_t('_Success'), 3) : MsgBox($sErrorC); } return $sResult . $oForm->getCode(); }
public function insert($aValsToAdd = array(), $isIgnore = false) { $sEmail = isset($aValsToAdd[self::$FIELD_EMAIL]) ? $aValsToAdd[self::$FIELD_EMAIL] : $this->getCleanValue(self::$FIELD_EMAIL); $sEmail = trim(strtolower($sEmail)); $sPwd = isset($aValsToAdd[self::$FIELD_PASSWORD]) ? $aValsToAdd[self::$FIELD_PASSWORD] : $this->getCleanValue(self::$FIELD_PASSWORD); $sSalt = genRndSalt(); $sPasswordHash = encryptUserPwd($sPwd, $sSalt); $aValsToAdd = array_merge($aValsToAdd, array(self::$FIELD_EMAIL => $sEmail, self::$FIELD_PASSWORD => $sPasswordHash, self::$FIELD_SALT => $sSalt, self::$FIELD_ADDED => time(), self::$FIELD_CHANGED => time())); return parent::insert($aValsToAdd, $isIgnore); }
function PageCodeCreate() { $aForm = array('form_attrs' => array('id' => 'adm-mlevels-create', 'action' => $GLOBALS['site']['url_admin'] . 'memb_levels.php', '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' => '', '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'), 'value' => '', 'checker' => array('func' => '', 'params' => '', 'error' => _t('_adm_txt_mlevels_icon_err'))), 'Description' => array('type' => 'textarea', 'name' => 'description', 'caption' => _t('_adm_txt_mlevels_description'), 'value' => '', 'db' => array('pass' => 'XssHtml')), 'submit' => array('type' => 'submit', 'name' => 'submit', 'value' => _t('_adm_btn_mlevels_add')))); $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); $bFile = true; $sFilePath = BX_DIRECTORY_PATH_ROOT . 'media/images/membership/'; $sFileName = time(); $sFileExt = ''; if ($oForm->isSubmittedAndValid() && ($bFile = 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) { addStringToLanguage("_adm_txt_mp_" . strtolower(bx_get('name')), bx_get('name')); } header('Location: ' . $oForm->aFormAttrs['action']); } else { if (!$bFile) { $oForm->aInputs['Icon']['error'] = $oForm->aInputs['Icon']['checker']['error']; } return DesignBoxAdmin(_t('_adm_box_cpt_mlevel_create'), $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode()))); } }
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())); }
public function insert($aValsToAdd = array(), $isIgnore = false) { $sPwd = $this->getCleanValue(self::$FIELD_PASSWORD); $sSalt = genRndSalt(); $sPasswordHash = encryptUserPwd($sPwd, $sSalt); $aValsToAdd = array_merge($aValsToAdd, array(self::$FIELD_PASSWORD => $sPasswordHash, self::$FIELD_SALT => $sSalt, self::$FIELD_ADDED => time(), self::$FIELD_CHANGED => time())); return parent::insert($aValsToAdd, $isIgnore); }
function getBlockCode_CreateGroup() { $sContent = ""; $aValues = array_merge(array('0' => _t('_ps_cpt_none')), $this->_getSelectItems(array('type' => 'extendable', 'owner_id' => $this->_iOwnerId))); $aForm = array('form_attrs' => array('id' => 'ps-create-group-form', 'name' => 'ps-create-group-form', 'action' => BX_DOL_URL_ROOT . 'member_privacy.php', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'sys_privacy_groups', 'key' => 'id', 'submit_name' => 'create')), 'inputs' => array('owner_id' => array('type' => 'hidden', 'name' => 'owner_id', 'value' => $this->_iOwnerId, 'db' => array('pass' => 'Int')), 'title' => array('type' => 'text', 'name' => 'title', 'caption' => _t("_ps_fcpt_title"), 'value' => '', 'checker' => array('func' => 'length', 'params' => array(3, 64), 'error' => _t('_ps_ferr_incorrect_length')), 'db' => array('pass' => 'Xss')), 'parent_id' => array('type' => 'select', 'name' => 'parent_id', 'caption' => _t("_ps_fcpt_extends"), 'value' => '', 'values' => $aValues, 'checker' => array('func' => 'length', 'params' => array(1, 4), 'error' => _t('_ps_ferr_incorrect_select')), 'db' => array('pass' => 'Int')), 'create' => array('type' => 'submit', 'name' => 'create', 'value' => _t("_ps_btncpt_create")))); $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $iId = $oForm->insert(); header('Location: ' . $oForm->aFormAttrs['action']); exit; } else { $sContent = $oForm->getCode(); } $sContent = $this->parseHtmlByName('ps_create_group.html', array('form' => !empty($sContent) ? $sContent : MsgBox(_t('_Empty')))); return DesignBoxContent(_t("_ps_bcpt_create_group"), $sContent, 1); }
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 . ' <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> </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> </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> </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); }
/** * 'add' action handler */ public function performActionAdd() { $sAction = 'add'; $aForm = array('form_attrs' => array('id' => 'sample-add-form', 'action' => 'grid.php?o=' . $this->_sObject . '&a=' . $sAction, 'method' => 'post'), 'params' => array('db' => array('table' => 'sample_grid_data', 'key' => 'ID', 'submit_name' => 'do_submit')), 'inputs' => array('NickName' => array('type' => 'text', 'name' => 'NickName', 'caption' => _t('Username'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(1, 150), 'error' => _t('Username is required')), 'db' => array('pass' => 'Xss')), 'Email' => array('type' => 'text', 'name' => 'Email', 'caption' => _t('Email'), 'required' => true, 'checker' => array('func' => 'email', 'error' => _t('_Incorrect Email')), 'db' => array('pass' => 'Xss')), 'City' => array('type' => 'text', 'name' => 'City', 'caption' => _t('City'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(1, 150), 'error' => _t('City is required')), 'db' => array('pass' => 'Xss')), 'submit' => array('type' => 'input_set', 0 => array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_Submit')), 1 => array('type' => 'reset', 'name' => 'close', 'value' => _t('Close'), 'attrs' => array('onclick' => "\$('.dolPopup:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left'))))); bx_import('BxTemplFormView'); $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { // if form is submitted and all fields are valid $iNewId = $oForm->insert(array(), true); // insert record to database if ($iNewId) { $aRes = array('grid' => $this->getCode(true), 'blink' => $iNewId); } else { $aRes = array('msg' => "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'); // we need to use 'transBox' function to properly display 'popup' $s = BxTemplFunctions::getInstance()->transBox('', ' <div class="bx-def-padding-top bx-def-padding-left bx-def-padding-right bx-def-color-bg-block" style="width:300px;">' . $oForm->getCode() . '</div> <script> $(document).ready(function () { $("#sample-add-form").ajaxForm({ dataType: "json", beforeSubmit: function (formData, jqForm, options) { bx_loading($("#' . $aForm['form_attrs']['id'] . '"), true); }, success: function (data) { $(".dolPopup:visible").dolPopupHide(); glGrids.' . $this->_sObject . '.processJson(data, "' . $sAction . '"); } }); }); </script>'); $this->_echoResultJson(array('popup' => array('html' => $s, 'options' => array('closeOnOuterClick' => false))), true); } }