Пример #1
0
 public function performActionDelete($aParams = array())
 {
     $iProfileId = $this->_oModule->getProfileId();
     $mixedAllowed = $this->_oModule->isAllowedDeleteRequest($iProfileId);
     if ($mixedAllowed !== true) {
         $this->_echoResultJson(array('msg' => $mixedAllowed));
         exit;
     }
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($this->_oModule->_oConfig->getObject('form_request'), $this->_oModule->_oConfig->getObject('form_display_request_send'));
     $aIdsAffected = array();
     foreach ($aIds as $iId) {
         if (!$oForm->delete($iId)) {
             continue;
         }
         $this->_oModule->isAllowedDeleteRequest($iProfileId, true);
         $aIdsAffected[] = $iId;
         $iAffected++;
     }
     $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_bx_invites_err_delete_request')));
 }
Пример #2
0
 public function serviceLoginForm($sParams = '', $sForceRelocate = '')
 {
     if (isLogged()) {
         return false;
     }
     // get all auth types
     $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`');
     $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login');
     $sCustomHtmlBefore = '';
     $sCustomHtmlAfter = '';
     bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes));
     if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT)) {
         $oForm->aInputs['relocate']['value'] = $sForceRelocate;
     } elseif ('homepage' == $sForceRelocate) {
         $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT;
     }
     $sFormCode = $oForm->getCode();
     $sJoinText = '';
     if (strpos($sParams, 'no_join_text') === false) {
         $sJoinText = '<hr class="bx-def-hr bx-def-margin-sec-topbottom" /><div class="bx-def-font-align-center">' . _t('_sys_txt_login_description', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account')) . '</div>';
     }
     BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js'));
     $sAuth = $this->serviceMemberAuthCode($aAuthTypes);
     return $sCustomHtmlBefore . $sAuth . $sFormCode . $sCustomHtmlAfter . $sJoinText;
 }
Пример #3
0
 public function deleteConvo($iConversationId, $iProfileId = 0)
 {
     $aContentInfo = $this->getContentInfoById($iConversationId);
     if (!$aContentInfo) {
         return true;
     }
     // delete convo
     $sWhere = '';
     if ($iProfileId) {
         $sWhere = $this->prepare(" AND `collaborator` = ?", $iProfileId);
     }
     $sQuery = $this->prepare("DELETE FROM `" . $this->getPrefix() . "conv2folder` WHERE `conv_id` = ?", $iConversationId);
     if (!$this->query($sQuery . $sWhere)) {
         return false;
     }
     // delete whole conversation if there is no refencences to the conversation in conv2folder table
     $sQuery = $this->prepare("SELECT `id` FROM `" . $this->getPrefix() . "conv2folder` WHERE `conv_id` = ?", $iConversationId);
     if (!$this->getOne($sQuery)) {
         $CNF =& $this->_oConfig->CNF;
         bx_import('BxDolForm');
         $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']);
         return $oForm->delete((int) $iConversationId, $aContentInfo);
     }
     return true;
 }
Пример #4
0
 public function performActionEdit()
 {
     $sAction = 'edit';
     $sFormObject = $this->oModule->_oConfig->getObject('form_forms_prelist');
     $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_forms_prelist_edit');
     $aList = $this->_getItem('getLists');
     if ($aList === false) {
         $this->_echoResultJson(array());
         exit;
     }
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
     $oForm->aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_frm_txt_select_module')), BxDolStudioUtils::getModules());
     $oForm->aInputs['controls'][0]['value'] = _t('_bx_dev_frm_btn_prelists_save');
     $oForm->initChecker($aList);
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->update($aList['id']) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $aList['id']);
         } else {
             $aRes = array('msg' => _t('_bx_dev_frm_err_prelists_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-frm-prelist-edit-popup', _t('_bx_dev_frm_txt_prelists_edit_popup', _t($aList['title'])), $this->oModule->_oTemplate->parseHtmlByName('form_add_list.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Пример #5
0
 public function performActionEdit($bUpdateGrid = false)
 {
     $sAction = 'edit';
     $sFormObject = $this->oModule->_oConfig->getObject('form_nav_item');
     $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_nav_item_edit');
     $aItem = $this->_getItem('getItems');
     if ($aItem === false) {
         $this->_echoResultJson(array());
         exit;
     }
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&set=' . $this->sSet;
     $oForm->aInputs['controls'][0]['value'] = _t('_bx_dev_nav_btn_items_save');
     $this->fillInSelects($oForm->aInputs);
     $oForm->initChecker($aItem);
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->update($aItem['id']) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $aItem['id']);
         } else {
             $aRes = array('msg' => _t('_bx_dev_nav_err_items_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-item-edit-popup', _t('_bx_dev_nav_txt_items_edit_popup', _t($aItem['title_system'])), $this->oModule->_oTemplate->parseHtmlByName('nav_add_item.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Пример #6
0
 public function serviceLoginForm($sParams = '', $sForceRelocate = '')
 {
     if (isLogged()) {
         return false;
     }
     // get all auth types
     $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`');
     // define additional auth types
     if ($aAuthTypes) {
         $aAddInputEl[''] = _t('_Basic');
         // procces all additional menu's items
         foreach ($aAuthTypes as $iKey => $aItems) {
             $aAddInputEl[$aItems['Link']] = _t($aItems['Title']);
         }
         $aAuthTypes = array('type' => 'select', 'caption' => _t('_Auth type'), 'values' => $aAddInputEl, 'value' => '', 'attrs' => array('onchange' => 'if (this.value) { location.href = "' . BX_DOL_URL_ROOT . '" + this.value }'));
     } else {
         $aAuthTypes = array('type' => 'hidden');
     }
     $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login');
     $sCustomHtmlBefore = '';
     $sCustomHtmlAfter = '';
     bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes));
     if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT)) {
         $oForm->aInputs['relocate']['value'] = $sForceRelocate;
     } elseif ('homepage' == $sForceRelocate) {
         $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT;
     }
     $sFormCode = $oForm->getCode();
     $sJoinText = '';
     if (strpos($sParams, 'no_join_text') === false) {
         $sJoinText = '<hr class="bx-def-hr bx-def-margin-sec-topbottom" /><div>' . _t('_sys_txt_login_description', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account')) . '</div>';
     }
     BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js'));
     return $sCustomHtmlBefore . $sFormCode . $sCustomHtmlAfter . $sJoinText;
 }
Пример #7
0
 /**
  * Add comments CSS/JS
  */
 public function addCssJs()
 {
     $this->_oTemplate->addCss(array('cmts.css'));
     $this->_oTemplate->addJs(array('jquery.anim.js', 'jquery.form.min.js', 'BxDolCmts.js'));
     $oForm = BxDolForm::getObjectInstance($this->_sFormObject, $this->_sFormDisplayPost);
     $oForm->addCssJs();
 }
Пример #8
0
 protected function _performAction($sAction, $sDisplay, $iId = 0)
 {
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance('bx_antispam_ip_table_form', $sDisplay);
     // get form instance for specified form object and display
     if (!$oForm) {
         $this->_echoResultJson(array('msg' => _t('_sys_txt_error_occured')), true);
         exit;
     }
     $oForm->addMarkers(array('grid_object' => $this->_sObject, 'grid_action' => $sAction));
     $aIpTableDirective = array();
     if ($iId) {
         bx_import('BxDolModule');
         $oModule = BxDolModule::getInstance('bx_antispam');
         $oAntispamIp = bx_instance('BxAntispamIP', array(), $oModule->_aModule);
         $aIpTableDirective = $oAntispamIp->getIpTableDirective($iId);
         $aIpTableDirective['From'] = long2ip($aIpTableDirective['From']);
         $aIpTableDirective['To'] = long2ip($aIpTableDirective['To']);
     }
     $oForm->initChecker($aIpTableDirective);
     if ($oForm->isSubmittedAndValid()) {
         // if form is submitted and all fields are valid
         $aCustomValues = array('From' => sprintf("%u", ip2long($oForm->getCleanValue('From'))), 'To' => sprintf("%u", ip2long($oForm->getCleanValue('To'))));
         if ($iId) {
             if ($oForm->update($iId, $aCustomValues)) {
                 // update record
                 $iRecentId = $iId;
             }
         } else {
             $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_form_ip_table_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, "' . $sAction . '");
                         }
                     });
                 });
             </script>');
         $this->_echoResultJson(array('popup' => array('html' => $s, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Пример #9
0
 public function performActionEdit()
 {
     $sAction = 'edit';
     $sFormObject = $this->oModule->_oConfig->getObject('form_forms_prevalue');
     $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_forms_prevalue_edit');
     $aValue = $this->_getItem('getValues');
     if ($aValue === false) {
         $this->_echoResultJson(array());
         exit;
     }
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&list=' . $this->sList;
     $this->onLoad($oForm->aInputs);
     $oForm->initChecker($aValue);
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->update($aValue['id']) !== false) {
             $this->onSave($oForm);
             $aRes = array('grid' => $this->getCode(false), 'blink' => $aValue['id']);
         } else {
             $aRes = array('msg' => _t('_bx_dev_frm_err_prevalues_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-frm-prevalue-edit-popup', _t('_bx_dev_frm_txt_prevalues_edit_popup', _t($aValue['lkey'])), $this->oModule->_oTemplate->parseHtmlByName('form_add_value.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Пример #10
0
 public function performActionAdd()
 {
     $sAction = 'add';
     $sMsg = $this->_oModule->isAllowedAdd();
     if ($sMsg !== CHECK_ACTION_RESULT_ALLOWED) {
         $this->_echoResultJson(array('msg' => $sMsg), true);
         return;
     }
     $oForm = BxDolForm::getObjectInstance('bx_sites', 'bx_sites_site_add');
     if (!$oForm) {
         $this->_echoResultJson(array('msg' => _t('_sys_txt_error_occured')), true);
         return;
     }
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
     $oForm->initChecker();
     if (!$oForm->isSubmittedAndValid()) {
         $sContent = BxTemplFunctions::getInstance()->popupBox('bx-sites-site-create-popup', _t('_bx_sites_grid_browse_popup_create'), $this->_oModule->_oTemplate->parseHtmlByName('block_create.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
         return;
     }
     $sDomain = $oForm->getCleanValue('domain');
     if ($this->_oModule->_oDb->isAccount(array('domain' => $sDomain))) {
         $this->_echoResultJson(array('msg' => _t('_bx_sites_txt_err_site_exists')), true);
         return;
     }
     $iAccountId = $oForm->insert(array('owner_id' => bx_get_logged_profile_id(), 'created' => time(), 'status' => BX_SITES_ACCOUNT_STATUS_UNCONFIRMED));
     if (!$iAccountId) {
         $this->_echoResultJson(array('msg' => _t('_bx_sites_txt_err_site_creation')), true);
         return;
     }
     $oAccount = $this->_oModule->getObject('Account');
     $oAccount->onAccountCreated($iAccountId);
     $sUrl = $this->_oModule->startSubscription($iAccountId);
     $this->_echoResultJson(array('eval' => 'window.open(\'' . $sUrl . '\', \'_self\');', 'popup_not_hide' => 1), true);
 }
Пример #11
0
 public function performActionEdit()
 {
     $sAction = 'edit';
     $sFormObject = $this->oModule->_oConfig->getObject('form_forms_form');
     $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_forms_form_edit');
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $iId = (int) bx_get('id');
         if (!$iId) {
             $this->_echoResultJson(array());
             exit;
         }
         $aIds = array($iId);
     }
     $iId = $aIds[0];
     $aForm = array();
     $this->oDb->getForms(array('type' => 'by_id', 'value' => $iId), $aForm, false);
     if (empty($aForm) || !is_array($aForm)) {
         $this->_echoResultJson(array());
         exit;
     }
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
     $oForm->aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_frm_txt_select_module')), BxDolStudioUtils::getModules());
     $oForm->aInputs['controls'][0]['value'] = _t('_bx_dev_frm_btn_forms_save');
     $aForm['form_attrs'] = BxDevFunctions::unserializeString($aForm['form_attrs']);
     $aForm['params'] = BxDevFunctions::unserializeString($aForm['params']);
     $oForm->initChecker($aForm);
     if ($oForm->isSubmittedAndValid()) {
         $sValue = BxDolForm::getSubmittedValue('form_attrs', $oForm->aFormAttrs['method']);
         $sValue = BxDevFunctions::serializeString($sValue);
         BxDolForm::setSubmittedValue('form_attrs', $sValue, $oForm->aFormAttrs['method']);
         $sValue = BxDolForm::getSubmittedValue('params', $oForm->aFormAttrs['method']);
         $sValue = BxDevFunctions::serializeString($sValue);
         BxDolForm::setSubmittedValue('params', $sValue, $oForm->aFormAttrs['method']);
         if ($oForm->update($iId) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_bx_dev_frm_err_forms_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-frm-form-edit-popup', _t('_bx_dev_frm_txt_forms_edit_popup', _t($aForm['title'])), $this->oModule->_oTemplate->parseHtmlByName('form_add_form.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Пример #12
0
 public function actionDeleteProfileImg($iFileId, $iContentId, $sFieldPicture)
 {
     $aResult = array();
     $CNF =& $this->_oConfig->CNF;
     $oSrorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
     if (!($aFile = $oSrorage->getFile((int) $iFileId)) || !($aContentInfo = $this->_oDb->getContentInfoById($iContentId)) || $aContentInfo[$sFieldPicture] != (int) $iFileId) {
         $aResult = array('error' => 1, 'msg' => _t('_sys_storage_err_file_not_found'));
     }
     if (!$aResult && !isLogged() || !$aResult && $aFile['profile_id'] != bx_get_logged_profile_id() && !$this->_isModerator()) {
         $aResult = array('error' => 2, 'msg' => _t('_Access denied'));
     }
     $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate);
     if (!$aResult && !$oForm->_deleteFile($iContentId, $sFieldPicture, (int) $iFileId, true)) {
         $aResult = array('error' => 3, 'msg' => _t('_Failed'));
     } elseif (!$aResult) {
         $aResult = array('error' => 0, 'msg' => '');
     }
     header('Content-Type: application/json; charset=utf-8');
     echo json_encode($aResult);
 }
Пример #13
0
 public function performActionEdit()
 {
     $sAction = 'edit';
     $sFormObject = $this->oModule->_oConfig->getObject('form_nav_set');
     $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_nav_set_edit');
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $sId = bx_get('set_name');
         if (!$sId) {
             $this->_echoResultJson(array());
             exit;
         }
         $aIds = array($sId);
     }
     $sId = bx_process_input($aIds[0]);
     $aSet = array();
     $this->oDb->getSets(array('type' => 'by_name', 'value' => $sId), $aSet, false);
     if (empty($aSet) || !is_array($aSet)) {
         $this->_echoResultJson(array());
         exit;
     }
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
     $oForm->aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_frm_txt_select_module')), BxDolStudioUtils::getModules());
     $oForm->aInputs['controls'][0]['value'] = _t('_bx_dev_frm_btn_displays_save');
     $oForm->initChecker($aSet);
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->update($sId) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $sId);
         } else {
             $aRes = array('msg' => _t('_bx_dev_nav_err_sets_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-set-edit-popup', _t('_bx_dev_nav_txt_sets_edit_popup', _t($aSet['title'])), $this->_oTemplate->parseHtmlByName('nav_add_set.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Пример #14
0
 /**
  * SERVICE METHODS
  */
 public function serviceGetBlockForm()
 {
     $aDefaultFields = array('name', 'email', 'subject', 'body', 'do_submit');
     $mixedAllowed = $this->isAllowedContact();
     if ($mixedAllowed !== true) {
         return array('content' => MsgBox($mixedAllowed));
     }
     $sResult = '';
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_contact'), $this->_oConfig->getObject('form_display_contact_send'), $this->_oTemplate);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $iId = $oForm->insert(array('uri' => $oForm->generateUri(), 'date' => time()));
         if ($iId !== false) {
             $sCustomFields = '';
             $aCustomFields = array();
             foreach ($oForm->aInputs as $aInput) {
                 if (in_array($aInput['name'], $aDefaultFields)) {
                     continue;
                 }
                 $aCustomFields[$aInput['name']] = bx_process_output($oForm->getCleanValue($aInput['name']));
                 $sCustomFields .= $aInput['caption'] . ': ' . $aCustomFields[$aInput['name']] . '<br />';
             }
             $aTemplateKeys = array('SenderName' => bx_process_output($oForm->getCleanValue('name')), 'SenderEmail' => bx_process_output($oForm->getCleanValue('email')), 'MessageSubject' => bx_process_output($oForm->getCleanValue('subject')), 'MessageBody' => bx_process_output(nl2br($oForm->getCleanValue('body')), BX_DATA_TEXT_MULTILINE), 'CustomFields' => $sCustomFields);
             $aTemplateKeys = array_merge($aTemplateKeys, $aCustomFields);
             bx_import('BxDolEmailTemplates');
             $aMessage = BxDolEmailTemplates::getInstance()->parseTemplate('bx_contact_contact_form_message', $aTemplateKeys);
             $sResult = '';
             $sRecipientEmail = $this->_oConfig->getEmail();
             if (sendMail($sRecipientEmail, $aMessage['Subject'], $aMessage['Body'], 0, array(), BX_EMAIL_SYSTEM)) {
                 $this->onContact();
                 $sResult = '_ADM_PROFILE_SEND_MSG';
             } else {
                 $sResult = '_Email sent failed';
             }
             $sResult = MsgBox(_t($sResult));
         }
     }
     return array('content' => $sResult . $oForm->getCode());
 }
Пример #15
0
 public function performActionEdit()
 {
     $sAction = 'edit';
     $sFormObject = $this->oModule->_oConfig->getObject('form_forms_display');
     $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_forms_display_edit');
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $iId = (int) bx_get('id');
         if (!$iId) {
             $this->_echoResultJson(array());
             exit;
         }
         $aIds = array($iId);
     }
     $iId = $aIds[0];
     $aDisplay = array();
     $iDisplay = $this->oDb->getDisplays(array('type' => 'by_id', 'value' => $iId), $aDisplay);
     if ($iDisplay != 1 || empty($aDisplay)) {
         $this->_echoResultJson(array());
         exit;
     }
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
     $this->_fillDisplayForm($oForm, $sAction);
     $oForm->aInputs['controls'][0]['value'] = _t('_bx_dev_frm_btn_displays_save');
     $oForm->initChecker($aDisplay);
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->update($iId) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_bx_dev_frm_err_displays_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-frm-display-edit-popup', _t('_bx_dev_frm_txt_displays_edit_popup', _t($aDisplay['title'])), $this->_oTemplate->parseHtmlByName('form_add_display.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Пример #16
0
 protected function actionBlockEdit()
 {
     $iId = (int) bx_get('id');
     if (!$iId) {
         return array();
     }
     $aBlock = array();
     $this->oDb->getBlocks(array('type' => 'by_id', 'value' => $iId), $aBlock, false);
     if (empty($aBlock) || !is_array($aBlock)) {
         return array('msg' => _t('_bx_dev_bp_err_block_not_found'));
     }
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance('mod_dev_bp_block', 'mod_dev_bp_block_edit');
     $this->onLoadBlock($oForm, $aBlock);
     $oForm->initChecker($aBlock);
     if ($oForm->isSubmittedAndValid()) {
         $this->onSaveBlock($oForm, $aBlock);
         if ($oForm->update($iId) !== false) {
             return array('eval' => $this->getPageJsObject() . '.onEditBlock(oData)');
         } else {
             return array('msg' => _t('_bx_dev_bp_err_block_edit'));
         }
     }
     bx_import('BxTemplStudioFunctions');
     $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['edit_block_popup_id'], _t('_bx_dev_bp_txt_block_edit_popup', _t($aBlock['title'])), $this->oModule->_oTemplate->parseHtmlByName('bp_add_block.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true))));
     return array('popup' => $sContent);
 }
Пример #17
0
 /**
  * Display forgot password form, if reset password key is provided then reset password
  */
 public function serviceForgotPassword()
 {
     if (bx_get('key')) {
         return $this->resetPassword();
     }
     $oForm = BxDolForm::getObjectInstance('sys_forgot_password', 'sys_forgot_password');
     if (!$oForm) {
         return '';
     }
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $oKey = BxDolKey::getInstance();
         if (!$oKey) {
             $sResultMsg = MsgBox(_t("_sys_txt_forgot_pasword_error_occured"));
         } else {
             $sEmail = $oForm->getCleanValue('email');
             $iAccountId = $this->_oAccountQuery->getIdByEmail($sEmail);
             $aPlus['key'] = $oKey->getNewKey(array('email' => $sEmail));
             $aPlus['forgot_password_url'] = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password') . '&key=' . $aPlus['key'];
             $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_Forgot', $aPlus, $iAccountId);
             if ($aTemplate && sendMail($sEmail, $aTemplate['Subject'], $aTemplate['Body'], 0, $aPlus, BX_EMAIL_SYSTEM)) {
                 $sResultMsg = MsgBox(_t("_sys_txt_forgot_pasword_check_email"));
             } else {
                 $sResultMsg = MsgBox(_t("_sys_txt_forgot_pasword_email_send_failed"));
             }
             $sForm = '';
         }
     } else {
         $sResultMsg = _t("_sys_txt_forgot_pasword_desc");
         $sForm = $oForm->getCode();
     }
     return '<div class="bx-def-padding-sec-bottom">' . $sResultMsg . '</div>' . $sForm;
 }
Пример #18
0
 protected function getFormObjectInvite($sDisplay = '')
 {
     if (empty($sDisplay)) {
         $sDisplay = $this->_oConfig->getObject('form_display_invite_send');
     }
     bx_import('FormCheckerHelper', $this->_aModule);
     return BxDolForm::getObjectInstance($this->_oConfig->getObject('form_invite'), $sDisplay);
 }
Пример #19
0
 /**
  * @return delete data html
  */
 public function deleteDataForm($aAccount, $sDisplay = 'bx_sites_site_delete')
 {
     $sMsg = $this->_oModule->isAllowedDelete($aAccount);
     if ($sMsg !== CHECK_ACTION_RESULT_ALLOWED) {
         return MsgBox($sMsg);
     }
     // check and display form
     $oForm = BxDolForm::getObjectInstance('bx_sites', $sDisplay);
     if (!$oForm) {
         return MsgBox(_t('_sys_txt_error_occured'));
     }
     $oForm->initChecker($aAccount);
     if (!$oForm->isSubmittedAndValid()) {
         return $oForm->getCode();
     }
     if (!$oForm->delete($aAccount['id'], $aAccount)) {
         return MsgBox(_t('_bx_sites_txt_err_site_delete'));
     }
     //delete payment details and history
     if (!empty($aAccount['id'])) {
         $this->_oModule->_oDb->deletePaymentDetails(array('account_id' => $aAccount['id']));
         $this->_oModule->_oDb->deletePaymentHistory(array('account_id' => $aAccount['id']));
     }
     // cancel subscription
     if (!empty($aAccount['pd_profile_id'])) {
         bx_import('Paypal', $this->_oModule->_aModule);
         $oPaypal = new BxSitesPaypal($this->_oModule);
         $oPaypal->performAction($aAccount['pd_profile_id']);
     }
     // perform action
     $this->_oModule->isAllowedDelete($aAccount, true);
     // create an alert
     bx_alert($this->_oModule->getName(), 'deleted', $aAccount['id']);
     // redirect
     $this->_redirectAndExit('page.php?i=sites-home');
 }
Пример #20
0
 protected function _editAccountForm($iAccountId, $sDisplayName)
 {
     $oAccount = BxDolAccount::getInstance($iAccountId);
     $aAccountInfo = $oAccount ? $oAccount->getInfo() : false;
     if (!$aAccountInfo) {
         return MsgBox(_t('_sys_txt_error_account_is_not_defined'));
     }
     // check access
     if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = BxDolAccount::isAllowedEdit($this->_iProfileId, $aAccountInfo))) {
         return MsgBox($sMsg);
     }
     // check and display form
     $oForm = BxDolForm::getObjectInstance('sys_account', $sDisplayName);
     if (!$oForm) {
         return MsgBox(_t('_sys_txt_error_occured'));
     }
     if (!$oForm->isSubmitted()) {
         unset($aAccountInfo['password']);
     }
     $oForm->initChecker($aAccountInfo);
     if (!$oForm->isSubmittedAndValid()) {
         return $oForm->getCode();
     }
     $aTrackTextFieldsChanges = array();
     // track text fields changes, not-null(for example empty array) - means track, null - means don't track
     // update email and email setting in DB
     if (!$oForm->update($aAccountInfo['id'], array(), $aTrackTextFieldsChanges)) {
         if (!$oForm->isValid()) {
             return $oForm->getCode();
         } else {
             return MsgBox(_t('_sys_txt_error_account_update'));
         }
     }
     // check if email was changed
     if (!empty($aTrackTextFieldsChanges['changed_fields']) && in_array('email', $aTrackTextFieldsChanges['changed_fields'])) {
         $oAccount->updateEmailConfirmed(false);
     }
     // mark email as unconfirmed
     // check if password was changed
     if ($oForm->getCleanValue('password')) {
         // relogin with new password
         bx_logout();
         bx_login($aAccountInfo['id']);
     }
     // check if other text info was changed - if auto-appproval is off
     $isAutoApprove = $oForm->isSetPendingApproval() ? false : true;
     if (!$isAutoApprove) {
         bx_import('BxDolProfile');
         $oProfile = BxDolProfile::getInstanceAccountProfile($aAccountInfo['id']);
         // get profile associated with account, not current porfile
         $aProfileInfo = $oProfile->getInfo();
         unset($aTrackTextFieldsChanges['changed_fields']['email']);
         // email confirmation is automatic and separate, don't need to deactivate whole profile if email is changed
         if (BX_PROFILE_STATUS_ACTIVE == $aProfileInfo['status'] && !empty($aTrackTextFieldsChanges['changed_fields'])) {
             $oProfile->disapprove(BX_PROFILE_ACTION_AUTO);
         }
         // change profile to 'pending' only if some text fields were changed and profile is active
     }
     // create an alert
     bx_alert('account', 'edited', $aAccountInfo['id'], $aAccountInfo['id'], array('display' => $sDisplayName));
     // display result message
     $sMsg = MsgBox(_t('_sys_txt_data_successfully_submitted'));
     return $sMsg . $oForm->getCode();
 }
Пример #21
0
<?php

/**
 * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
 * CC-BY License - http://creativecommons.org/licenses/by/3.0/
 *
 * @defgroup    DolphinCore Dolphin Core
 * @{
 */
require_once './inc/header.inc.php';
require_once BX_DIRECTORY_PATH_INC . "design.inc.php";
bx_import('BxDolLanguages');
if (isset($_POST['ID'])) {
    // login form is submitted
    bx_import('BxDolForm');
    $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login');
    bx_alert('account', 'before_login', 0, 0, array('form' => $oForm));
    $oForm->initChecker();
    $oForm->setRole(bx_get('role'));
    $bLoginSuccess = $oForm->isSubmittedAndValid();
    $bAjxMode = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ? true : false;
    if ($bAjxMode) {
        header('Content-type: text/html; charset=utf-8');
        echo $bLoginSuccess ? 'OK' : $oForm->getLoginError();
        exit;
    } elseif ($bLoginSuccess) {
        bx_import('BxDolAccount');
        $oAccount = BxDolAccount::getInstance($oForm->getCleanValue('ID'));
        $aAccount = bx_login($oAccount->id(), $oForm->getCleanValue('rememberMe') ? true : false);
        $sUrlRelocate = $oForm->getCleanValue('relocate');
        if (!$sUrlRelocate || 0 != strncmp($sUrlRelocate, BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT))) {
Пример #22
0
 public function getFormPost()
 {
     $iUserId = $this->getUserId();
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance('mod_tml_post', 'mod_tml_post_add');
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'post/';
     $oForm->aInputs['owner_id']['value'] = $this->_iOwnerId;
     if (isset($oForm->aInputs['link'])) {
         $oForm->aInputs['link']['content'] = $this->_oTemplate->getAttachLinkField($iUserId);
     }
     if (isset($oForm->aInputs['photo'])) {
         $aFormNested = array('params' => array('nested_form_template' => 'uploader_nfw.html'), 'inputs' => array());
         bx_import('BxDolFormNested');
         $oFormNested = new BxDolFormNested('photo', $aFormNested, 'do_submit', $this->_oTemplate);
         $oForm->aInputs['photo']['storage_object'] = $this->_oConfig->getObject('storage');
         $oForm->aInputs['photo']['images_transcoder'] = $this->_oConfig->getObject('transcoder_preview');
         $oForm->aInputs['photo']['uploaders'] = $this->_oConfig->getUploaders('image');
         $oForm->aInputs['photo']['upload_buttons_titles'] = array('Simple' => 'camera');
         $oForm->aInputs['photo']['multiple'] = true;
         $oForm->aInputs['photo']['ghost_template'] = $oFormNested;
     }
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         list($sUserName) = $this->getUserInfo($iUserId);
         $sType = $oForm->getCleanValue('type');
         $sType = $this->_oConfig->getPrefix('common_post') . $sType;
         BxDolForm::setSubmittedValue('type', $sType, $oForm->aFormAttrs['method']);
         $aContent = array();
         //--- Process Text ---//
         $sText = $oForm->getCleanValue('text');
         unset($oForm->aInputs['text']);
         $aContent['text'] = $this->_prepareTextForSave($sText);
         //--- Process Link ---//
         $aLinkIds = $oForm->getCleanValue('link');
         unset($oForm->aInputs['link']);
         //--- Process Photos ---//
         $aPhotoIds = $oForm->getCleanValue('photo');
         unset($oForm->aInputs['photo']);
         $sTitle = _t('_bx_timeline_txt_user_added_sample', $sUserName, _t('_bx_timeline_txt_sample'));
         $sDescription = !empty($aContent['text']) ? $aContent['text'] : '';
         $iId = $oForm->insert(array('object_id' => $iUserId, 'object_privacy_view' => $this->_oConfig->getPrivacyViewDefault(), 'content' => serialize($aContent), 'title' => $sTitle, 'description' => $sDescription, 'date' => time()));
         if (!empty($iId)) {
             if (!empty($aLinkIds) && is_array($aLinkIds)) {
                 foreach ($aLinkIds as $iLinkId) {
                     $this->_oDb->saveLink($iId, $iLinkId);
                 }
             }
             if (!empty($aPhotoIds) && is_array($aPhotoIds)) {
                 bx_import('BxDolStorage');
                 $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage'));
                 foreach ($aPhotoIds as $iPhotoId) {
                     if ($this->_oDb->savePhoto($iId, $iPhotoId)) {
                         $oStorage->afterUploadCleanup($iPhotoId, $iUserId);
                     }
                 }
             }
             $this->onPost($iId);
             return array('id' => $iId);
         }
         return array('msg' => _t('_bx_timeline_txt_err_cannot_perform_action'));
     }
     return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
 }
 public function viewDataForm($iContentId, $sDisplay = false)
 {
     $CNF =& $this->_oModule->_oConfig->CNF;
     if (false === $sDisplay) {
         $sDisplay = $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW'];
     }
     // get content data and profile info
     list($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
     if (!$aContentInfo) {
         return MsgBox(_t('_sys_txt_error_entry_is_not_defined'));
     }
     // check access
     if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($aContentInfo))) {
         return MsgBox($sMsg);
     }
     // get form
     $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $sDisplay);
     if (!$oForm) {
         return MsgBox(_t('_sys_txt_error_occured'));
     }
     // display profile
     $oForm->initChecker($aContentInfo);
     return $oForm->getCode();
 }
Пример #24
0
 protected function _getFormObject($sAction, $iId)
 {
     $sActionCap = ucfirst($sAction);
     $sDisplayName = '_sFormDisplay' . $sActionCap;
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($this->_sFormObject, $this->{$sDisplayName});
     $oForm->setId(sprintf($oForm->aFormAttrs['id'], $sAction, $this->_sSystem, $iId));
     $oForm->setName(sprintf($oForm->aFormAttrs['name'], $sAction, $this->_sSystem, $iId));
     $oForm->aParams['db']['table'] = $this->_aSystem['table'];
     $oForm->aInputs['sys']['value'] = $this->_sSystem;
     $oForm->aInputs['id']['value'] = $this->_iId;
     $oForm->aInputs['action']['value'] = 'Submit' . $sActionCap . 'Form';
     if (!$this->isAttachImageEnabled()) {
         unset($oForm->aInputs['cmt_image']);
     }
     if (isset($oForm->aInputs['cmt_image'])) {
         $aFormNested = array('params' => array('nested_form_template' => 'comments_uploader_nfw.html'), 'inputs' => array());
         bx_import('BxDolFormNested');
         $oFormNested = new BxDolFormNested('cmt_image', $aFormNested, 'cmt_submit');
         $oForm->aInputs['cmt_image']['storage_object'] = $this->_sStorageObject;
         $oForm->aInputs['cmt_image']['images_transcoder'] = $this->_sTranscoderPreview;
         $oForm->aInputs['cmt_image']['uploaders'] = $this->_aImageUploaders;
         $oForm->aInputs['cmt_image']['upload_buttons_titles'] = array('Simple' => 'camera');
         $oForm->aInputs['cmt_image']['multiple'] = true;
         $oForm->aInputs['cmt_image']['ghost_template'] = $oFormNested;
     }
     if (isset($oForm->aInputs['cmt_text'])) {
         $iCmtTextMin = (int) $this->_aSystem['chars_post_min'];
         $iCmtTextMax = (int) $this->_aSystem['chars_post_max'];
         $oForm->aInputs['cmt_text']['checker']['params'] = array($iCmtTextMin, $iCmtTextMax);
         $oForm->aInputs['cmt_text']['checker']['error'] = _t('_Please enter n1-n2 characters', $iCmtTextMin, $iCmtTextMax);
     }
     return $oForm;
 }
Пример #25
0
 public function performActionSuspended()
 {
     $sAction = 'suspended';
     $oForm = BxDolForm::getObjectInstance('bx_sites', 'bx_sites_site_suspended');
     if (!$oForm) {
         $this->_echoResultJson(array('msg' => _t('_sys_txt_error_occured')), true);
         return;
     }
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&_r=' . time();
     $this->_performAction($oForm, $sAction, false);
     //Note: Place onSubmit code here if it's needed.
 }
 public function viewDataForm($iContentId, $sDisplay = false)
 {
     $CNF =& $this->_oModule->_oConfig->CNF;
     if (false === $sDisplay) {
         $sDisplay = $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW'];
     }
     // get content data and profile info
     list($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
     if (!$aContentInfo) {
         return MsgBox(_t('_sys_txt_error_entry_is_not_defined'));
     }
     // check access
     if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($aContentInfo))) {
         return MsgBox($sMsg);
     }
     // get form
     $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $sDisplay, $this->_oModule->_oTemplate);
     if (!$oForm) {
         return MsgBox(_t('_sys_txt_error_occured'));
     }
     // process metatags
     if (!empty($CNF['OBJECT_METATAGS'])) {
         $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
         if ($oMetatags->keywordsIsEnabled()) {
             $aFields = $oMetatags->keywordsFields($aContentInfo, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW']);
             $oForm->setMetatagsKeywordsData($iContentId, $aFields, $oMetatags);
         }
     }
     // display profile
     $oForm->initChecker($aContentInfo);
     return $oForm->getCode();
 }
Пример #27
0
 /**
  * Get field names which are subject to parse keywords
  */
 public function keywordsFields($aContentInfo, $CNF, $sFormDisplay)
 {
     $aFields = array();
     if (empty($CNF['FIELDS_WITH_KEYWORDS'])) {
         return array();
     } elseif (is_string($CNF['FIELDS_WITH_KEYWORDS']) && 'auto' == $CNF['FIELDS_WITH_KEYWORDS']) {
         if (!($oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $sFormDisplay))) {
             return array();
         }
         foreach ($oForm->aInputs as $k => $a) {
             if ('textarea' == $a['type']) {
                 $aFields[] = $a['name'];
             }
         }
     } elseif (is_array($CNF['FIELDS_WITH_KEYWORDS'])) {
         $aFields = $CNF['FIELDS_WITH_KEYWORDS'];
     } elseif (is_string($CNF['FIELDS_WITH_KEYWORDS'])) {
         $aFields = explode(',', $CNF['FIELDS_WITH_KEYWORDS']);
     }
     return $aFields;
 }
Пример #28
0
/**
 * page code function
 */
function PageCompMainCode()
{
    // get database object
    $oDb = BxDolDb::getInstance();
    // get id of edited data
    $iEditId = bx_process_input(bx_get('id'), BX_DATA_INT);
    // display existing data
    ob_start();
    echo '<a href="' . BX_DOL_URL_ROOT . 'samples/form_objects.php">Add new</a> or edit:<hr class="bx-def-hr" />';
    $a = $oDb->getAllWithKey("SELECT * FROM `sample_input_types`", 'id');
    foreach ($a as $r) {
        if ($iEditId == $r['id']) {
            echo $r['text'] . '<br />';
        } else {
            echo '<a href="' . BX_DOL_URL_ROOT . 'samples/form_objects.php?id=' . $r['id'] . '">' . $r['text'] . '</a><br />';
        }
        // data with link to edit it
    }
    $ss = ob_get_clean();
    ob_start();
    if ($iEditId) {
        // display edit form
        $oForm = BxDolForm::getObjectInstance('sample_form_objects', 'sample_form_objects_edit');
        // get form instance for specified form object and display
        if (!$oForm) {
            die('"sample_form_objects_edit" form object or "sample_form_objects_edit" display is not defined');
        }
        $oForm->initChecker($a[$iEditId]);
        // init form checker with edited data
        if ($oForm->isSubmittedAndValid()) {
            if ($oForm->update($iEditId)) {
                // update database
                echo MsgBox('Data has been updated');
            } else {
                echo MsgBox('Data update failed');
            }
        } else {
            echo $oForm->getCode();
            // display form
        }
    } else {
        // display add form
        $oForm = BxDolForm::getObjectInstance('sample_form_objects', 'sample_form_objects_add');
        // get form instance for specified form object and display
        if (!$oForm) {
            die('"sample_form_objects_add" form object or "sample_form_objects_add" display is not defined');
        }
        $oForm->initChecker();
        // init form checker witout any data - adding new record
        if ($oForm->isSubmittedAndValid()) {
            if ($oForm->insert()) {
                // add new record to the database
                echo MsgBox('Data has been added');
            } else {
                echo MsgBox('Data add failed');
            }
        } else {
            echo $oForm->getCode();
            // display form
        }
    }
    $s = ob_get_clean();
    return DesignBoxContent("Sample Form Object", $ss, BX_DB_PADDING_DEF) . DesignBoxContent($iEditId ? "Edit" : "Add New", $s, BX_DB_PADDING_DEF);
}
Пример #29
0
 protected function _getFormObject($sAction = BX_CMT_ACTION_POST)
 {
     $sDisplayName = '_sFormDisplay' . ucfirst($sAction);
     return BxDolForm::getObjectInstance($this->_sFormObject, $this->{$sDisplayName});
 }
Пример #30
0
 public function getFormPost()
 {
     $iUserId = $this->getUserId();
     $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_post'), $this->_oConfig->getObject('form_display_post_add'), $this->_oTemplate);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         list($sUserName) = $this->getUserInfo($iUserId);
         $sType = $oForm->getCleanValue('type');
         $sType = $this->_oConfig->getPrefix('common_post') . $sType;
         BxDolForm::setSubmittedValue('type', $sType, $oForm->aFormAttrs['method']);
         $aContent = array();
         //--- Process Text ---//
         $sText = $oForm->getCleanValue('text');
         unset($oForm->aInputs['text']);
         $aContent['text'] = $this->_prepareTextForSave($sText);
         //--- Process Link ---//
         $aLinkIds = $oForm->getCleanValue('link');
         //--- Process Media ---//
         $aPhotoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_PHOTO);
         $aVideoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_VIDEO);
         $sTitle = _t('_bx_timeline_txt_user_added_sample', $sUserName, _t('_bx_timeline_txt_sample'));
         $sDescription = !empty($aContent['text']) ? $aContent['text'] : '';
         $iId = $oForm->insert(array('object_id' => $iUserId, 'object_privacy_view' => $this->_oConfig->getPrivacyViewDefault(), 'content' => serialize($aContent), 'title' => $sTitle, 'description' => $sDescription, 'date' => time()));
         if (!empty($iId)) {
             $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
             $oMetatags->keywordsAdd($iId, $aContent['text']);
             $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
             //--- Process Link ---//
             if (!empty($aLinkIds) && is_array($aLinkIds)) {
                 foreach ($aLinkIds as $iLinkId) {
                     $this->_oDb->saveLink($iId, $iLinkId);
                 }
             }
             //--- Process Media ---//
             $this->_saveMedia(BX_TIMELINE_MEDIA_PHOTO, $iId, $aPhotoIds);
             $this->_saveMedia(BX_TIMELINE_MEDIA_VIDEO, $iId, $aVideoIds);
             $this->onPost($iId);
             return array('id' => $iId);
         }
         return array('msg' => _t('_bx_timeline_txt_err_cannot_perform_action'));
     }
     return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
 }