本文整理汇总了PHP中BxTemplFormView::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP BxTemplFormView::insert方法的具体用法?PHP BxTemplFormView::insert怎么用?PHP BxTemplFormView::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BxTemplFormView
的用法示例。
在下文中一共展示了BxTemplFormView::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFormCode
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();
}
}
示例2: getPostForm
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);
}
示例3: insert
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);
}
示例4: insert
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);
}
示例5: getPostForm
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();
}
}
示例6: performActionAdd
/**
* '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);
}
}
示例7: getEmailMessage
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);
}
示例8: GenCreateBlogForm
/**
* 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;
}
示例9: getAddSubcatForm
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);
}
示例10: getManagingForm
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();
}
示例11: insert
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);
}
示例12: PageCodeCreate
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())));
}
}
示例13: _getLevelsCreateForm
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()));
}
示例14: insert
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);
}
示例15: array
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);
}