public function performActionDelete($aParams = array())
 {
     $CNF =& $this->_oModule->_oConfig->CNF;
     //TODO: remove this check when 'delete with content' feature will be realized in onDelete method.
     if (isset($aParams['with_content']) && $aParams['with_content'] === true) {
         $this->_echoResultJson(array('msg' => 'TODO: delete with content'));
         return;
     }
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     bx_import('FormsEntryHelper', $this->_oModule->_aModule);
     $sClass = $this->_oModule->_oConfig->getClassPrefix() . 'FormsEntryHelper';
     $oFormsHelper = new $sClass($this->_oModule);
     $aIdsAffected = array();
     foreach ($aIds as $iId) {
         $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iId);
         if ($this->_oModule->checkAllowedDelete($aContentInfo) !== CHECK_ACTION_RESULT_ALLOWED) {
             continue;
         }
         if ($oFormsHelper->deleteData($iId) != '') {
             continue;
         }
         if (!$this->_onDelete($iId, $aParams)) {
             continue;
         }
         $this->_oModule->checkAllowedDelete($aContentInfo, true);
         $aIdsAffected[] = $iId;
         $iAffected++;
     }
     $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t($CNF['T']['grid_action_err_delete'])));
 }
 function init()
 {
     if (($sAction = bx_get('bp_action')) === false) {
         return;
     }
     $sAction = bx_process_input($sAction);
     $aResult = array('code' => 1, 'message' => _t('_adm_bp_err_cannot_process_action'));
     switch ($sAction) {
         case 'reorder':
             if (empty($this->aPageRebuild) || !is_array($this->aPageRebuild)) {
                 break;
             }
             $bResult = false;
             for ($i = 1; $i <= $this->aPageRebuild['layout_cells_number']; $i++) {
                 $aItems = bx_get('bp_items_' . $i);
                 $iItems = count($aItems);
                 for ($j = 0; $j < $iItems; $j++) {
                     $bResult |= $this->oDb->updateBlock((int) $aItems[$j], array('cell_id' => $i, 'order' => $j));
                 }
             }
             $aResult = $bResult ? array('code' => 0, 'message' => _t('_adm_bp_scs_save')) : array('code' => 1, 'message' => _t('_adm_bp_err_nothing_changed'));
             break;
         default:
             $sMethod = 'action' . $this->getClassName($sAction);
             if (method_exists($this, $sMethod)) {
                 $aResult = $this->{$sMethod}();
             }
     }
     echo json_encode($aResult);
     exit;
 }
Esempio n. 3
0
 public function init()
 {
     //--- Check Actions ---//
     if (($sAction = bx_get('mod_action')) !== false) {
         $sAction = bx_process_input($sAction);
         $aResult = array('code' => 1, 'message' => _t('_adm_mod_err_cannot_process_action'));
         switch ($sAction) {
             case 'activate':
                 $sValue = bx_process_input(bx_get('mod_value'));
                 if (empty($sValue)) {
                     break;
                 }
                 $aResult = $this->activate($sValue);
                 break;
         }
         echo json_encode($aResult);
         exit;
     }
     $this->aModule = $this->oDb->getModuleByName($this->sModule);
     if (empty($this->aModule) || !is_array($this->aModule)) {
         BxDolStudioTemplate::getInstance()->displayPageNotFound();
     }
     $this->sPageRssHelpUrl = $this->aModule['help_url'];
     $this->sPageRssHelpId = $this->aModule['name'];
     $this->addMarkers(array('module_name' => $this->aModule['name'], 'module_uri' => $this->aModule['uri'], 'module_title' => $this->aModule['title']));
     $this->addAction(array('type' => 'switcher', 'name' => 'activate', 'caption' => '_adm_txt_pca_active', 'checked' => (int) $this->aModule['enabled'] == 1, 'onchange' => "javascript:" . $this->getPageJsObject() . ".activate('" . $this->sModule . "', this)"), false);
 }
Esempio n. 4
0
/**
 * page code function
 */
function PageCompMainCode()
{
    ob_start();
    $oAccount = BxDolAccount::getInstance();
    $aAccountInfo = $oAccount ? $oAccount->getInfo() : false;
    if (!$aAccountInfo) {
        return DesignBoxContent("Send Email example", 'Please login first', BX_DB_PADDING_DEF);
    }
    echo "<h2>Account info</h2>";
    echo "Email: " . $aAccountInfo['email'] . '<br />';
    echo "Email Confirmed: " . ($aAccountInfo['email_confirmed'] ? 'yes' : 'no') . '<br />';
    echo "Receive site updates: " . ($aAccountInfo['receive_updates'] ? 'yes' : 'no') . '<br />';
    echo "Receive site newsletters: " . ($aAccountInfo['receive_news'] ? 'yes' : 'no') . '<br />';
    echo "Site emails are sent from: " . getParam('site_email_notify') . '<br />';
    $a = array('sys' => array('title' => "Send me system email", 'type' => BX_EMAIL_SYSTEM, 'subj' => 'System Email', 'body' => 'This is system email <br /> {unsubscribe}'), 'notif' => array('title' => "Send me notification", 'type' => BX_EMAIL_NOTIFY, 'subj' => 'Notification Email', 'body' => 'This is notification email<br /> {unsubscribe}'), 'mass' => array('title' => "Send me bulk email", 'type' => BX_EMAIL_MASS, 'subj' => 'Bulk Email', 'body' => 'This is bulk email<br /> {unsubscribe}'));
    $sSendMail = bx_get('send');
    if ($sSendMail && isset($a[$sSendMail])) {
        echo "<h2>Send Email Result</h2>";
        $r = $a[$sSendMail];
        if (sendMail($aAccountInfo['email'], $r['subj'], $r['body'], 0, array(), $r['type'])) {
            echo MsgBox($r['subj'] . ' - successfully sent');
        } else {
            echo MsgBox($r['subj'] . ' - sent failed');
        }
    }
    echo "<h2>Send email</h2>";
    foreach ($a as $k => $r) {
        echo '<a href="samples/email.php?send=' . $k . '">' . $r['title'] . '</a><br />';
    }
    return DesignBoxContent("Send Email Example", ob_get_clean(), BX_DB_PADDING_DEF);
}
Esempio n. 5
0
 function service($aToken)
 {
     if (!isAdmin($aToken['user_id'])) {
         $this->errorOutput(403, 'access_denied', 'Only admin can access service endpoint');
         return false;
     }
     bx_login($aToken['user_id'], false, false);
     $sUri = bx_get('uri');
     $sMethod = bx_get('method');
     if (!($aParams = bx_get('params'))) {
         $aParams = array();
     } elseif (is_string($aParams) && preg_match('/^a:[\\d+]:\\{/', $aParams)) {
         $aParams = @unserialize($aParams);
     }
     if (!is_array($aParams)) {
         $aParams = array($aParams);
     }
     if (!($sClass = bx_get('class'))) {
         $sClass = 'Module';
     }
     if (!BxDolRequest::serviceExists($sUri, $sMethod, $sClass)) {
         $this->errorOutput(404, 'not_found', 'Service was not found');
         return false;
     }
     $mixedRet = BxDolService::call($sUri, $sMethod, $aParams, $sClass);
     $this->output(array('uri' => $sUri, 'method' => $sMethod, 'data' => $mixedRet));
 }
Esempio n. 6
0
 public function init()
 {
     if (($sAction = bx_get('nav_action')) === false) {
         return;
     }
     $sAction = bx_process_input($sAction);
     $aResult = array('code' => 1, 'message' => _t('_adm_nav_err_cannot_process_action'));
     switch ($sAction) {
         case 'get-page-by-type':
             $sValue = bx_process_input(bx_get('nav_value'));
             if (empty($sValue)) {
                 break;
             }
             $this->sPage = $sValue;
             $aResult = array('code' => 0, 'content' => $this->getPageCode());
             break;
         default:
             $sMethod = 'action' . $this->getClassName($sAction);
             if (method_exists($this, $sMethod)) {
                 $aResult = $this->{$sMethod}();
             }
     }
     echo json_encode($aResult);
     exit;
 }
 public function performActionDelete()
 {
     $sAction = 'delete';
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aIdsAffected = array();
     foreach ($aIds as $iId) {
         $aList = array();
         $this->oDb->getLists(array('type' => 'by_id', 'value' => (int) $iId), $aList, false);
         if (!is_array($aList) || empty($aList)) {
             continue;
         }
         if (!$this->_canDelete($aList)) {
             continue;
         }
         if (!$this->oDb->deleteValues(array('type' => 'by_key', 'value' => $aList['key'])) || (int) $this->_delete($iId) <= 0) {
             continue;
         }
         bx_import('BxDolStudioLanguagesUtils');
         BxDolStudioLanguagesUtils::getInstance()->deleteLanguageString($aList['title']);
         $aIdsAffected[] = $iId;
         $iAffected++;
     }
     $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_from_err_pre_lists_delete')));
 }
Esempio n. 8
0
 function __construct()
 {
     parent::__construct(BX_DOL_STUDIO_PAGE_HOME);
     $aClasses = array('BxTemplStudioModules', 'BxTemplStudioDesigns', 'BxTemplStudioLanguages');
     //--- Check actions ---//
     if (($sAction = bx_get('action')) !== false) {
         $sAction = bx_process_input($sAction);
         $aResult = array('code' => 1, 'message' => _t('_adm_err_operation_failed'));
         switch ($sAction) {
             case 'launcher-update-cache':
                 $aResult = $this->updateCache();
                 break;
             case 'launcher-reorder':
                 $sPage = bx_process_input(bx_get('page'));
                 $aItems = bx_process_input(bx_get('items'));
                 BxDolStudioWidgetsQuery::getInstance()->reorder($sPage, $aItems);
                 $aResult = array('code' => 0, 'message' => _t('_adm_scs_operation_done'));
                 break;
         }
         echo json_encode($aResult);
         exit;
     }
     $this->aIncludes = array();
     foreach ($aClasses as $sClass) {
         $this->aIncludes[] = new $sClass();
     }
 }
Esempio n. 9
0
 function __construct()
 {
     global $logged;
     $this->aProfiles = array(0 => array(), 1 => array());
     // double arrays (for couples)
     $this->aValues = array(0 => array(), 1 => array());
     $this->aErrors = array(0 => array(), 1 => array());
     $iId = bx_get('ID');
     $this->iProfileID = (int) $iId;
     // basic checks
     if ($logged['member']) {
         $iMemberID = getLoggedId();
         if (!$this->iProfileID) {
             //if profile id is not set by request, edit own profile
             $this->iProfileID = $iMemberID;
             $this->iArea = 2;
         } else {
             // check if this member is owner
             if ($this->iProfileID == $iMemberID) {
                 $this->iArea = 2;
             }
         }
     } elseif ($logged['admin']) {
         $this->iArea = 3;
     } elseif ($logged['moderator']) {
         $this->iArea = 4;
     }
     $this->bAjaxMode = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');
     $this->bForceAjaxSave = bx_get('force_ajax_save');
     parent::__construct('pedit');
 }
Esempio n. 10
0
 /**
  * Get page code with automatic caching, adding necessary css/js files and system template vars.
  * @return string.
  */
 public function getCode()
 {
     if (bx_get('dynamic') && ($iBlockId = (int) bx_get('pageBlock'))) {
         if (!$this->_isVisiblePage($this->_aObject)) {
             header('HTTP/1.0 403 Forbidden');
             exit;
         }
         bx_alert('system', 'page_output_block', 0, false, array('page_name' => $this->_sObject, 'page_object' => $this, 'page_query' => $this->_oQuery, 'block_id' => (int) $iBlockId));
         header('Content-type:text/html;charset=utf-8');
         echo $this->_getBlockOnlyCode($iBlockId);
         exit;
     }
     if (!$this->_isVisiblePage($this->_aObject)) {
         return $this->_getPageAccessDeniedMsg();
     }
     $this->_addJsCss();
     $this->_addSysTemplateVars();
     $this->_selectMenu();
     if (!getParam('sys_page_cache_enable') || !$this->_aObject['cache_lifetime']) {
         return $this->_getPageCode();
     }
     $oCache = $this->_getPageCacheObject();
     $sKey = $this->_getPageCacheKey();
     $mixedRet = $oCache->getData($sKey, $this->_aObject['cache_lifetime']);
     if ($mixedRet !== null) {
         return $mixedRet;
     } else {
         $sPageCode = $this->_getPageCode();
         $oCache->setData($sKey, $sPageCode, $this->_aObject['cache_lifetime']);
     }
     bx_alert('system', 'page_output', 0, false, array('page_name' => $this->_sObject, 'page_object' => $this, 'page_query' => $this->_oQuery, 'page_code' => &$sPageCode));
     return $sPageCode;
 }
 public function performActionSetAclLevel()
 {
     $oMenu = BxDolMenu::getObjectInstance('sys_set_acl_level');
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds) || !$oMenu) {
         $this->_echoResultJson(array());
         return;
     }
     $aIdsResult = array();
     foreach ($aIds as $iId) {
         $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iId);
         if ($this->_oModule->checkAllowedSetMembership($aContentInfo) !== CHECK_ACTION_RESULT_ALLOWED) {
             continue;
         }
         $aIdsResult[] = $this->_getProfileId($iId);
     }
     if (empty($aIdsResult)) {
         $this->_echoResultJson(array());
         return;
     }
     if (count($aIdsResult) == 1) {
         $aIdsResult = $aIdsResult[0];
     }
     $sContent = $this->_oTemplate->parseHtmlByName('set_acl_popup.html', array('content' => $oMenu->getCode($aIdsResult)));
     $sContent = BxTemplFunctions::getInstance()->transBox($this->_oModule->_oConfig->getName() . 'set_acl_level_popup', $sContent);
     $this->_echoResultJson(array('popup' => $sContent), true);
 }
Esempio n. 12
0
 public function getForm($iDesignBoxTemplate = BX_DB_PADDING_DEF, $sTitle = false)
 {
     if ($this->_sMetaType) {
         return '';
     }
     if (false === $sTitle) {
         $sTitle = _t("_Search");
     }
     $aValues = $this->getKeyTitlesPairs();
     $aValue = isset($_GET['type']) ? bx_process_input($_GET['type']) : array_keys($aValues);
     $sIdForm = $this->_sIdForm . ($this->_bLiveSearch ? $this->_sSuffixLiveSearch : '');
     $sIdResults = $this->_sIdResults . ($this->_bLiveSearch ? $this->_sSuffixLiveSearch : '');
     $sIdLoadingContainer = $this->_bLiveSearch ? $sIdResults : $sIdForm;
     $sJsParams = "5, '#{$sIdForm}', '#{$sIdResults}', '#{$sIdLoadingContainer}', '{$this->_bLiveSearch}'";
     $aForm = array('form_attrs' => array('id' => $sIdForm, 'action' => BX_DOL_URL_ROOT . 'searchKeyword.php', 'method' => 'post'), 'csrf' => array('disable' => true), 'inputs' => array('live_search' => array('type' => 'hidden', 'name' => 'live_search', 'value' => $this->_bLiveSearch ? 1 : 0), 'section' => array('type' => 'checkbox_set', 'name' => 'section', 'caption' => _t('_Section'), 'values' => $aValues, 'value' => $aValue), 'keyword' => array('type' => 'text', 'name' => 'keyword', 'caption' => _t('_Keyword'), 'value' => bx_get('keyword') ? bx_process_input(bx_get('keyword')) : ''), 'search' => array('type' => 'submit', 'name' => 'search', 'value' => _t('_Search'))));
     if ($this->_bLiveSearch) {
         unset($aForm['inputs']['section']);
         unset($aForm['inputs']['search']);
         unset($aForm['inputs']['keyword']['caption']);
         $aForm['inputs']['keyword']['attrs']['placeholder'] = _t('_sys_search_placeholder');
         $aForm['inputs']['keyword']['attrs']['onkeypress'] = "return bx_search_on_type(event, {$sJsParams});";
         $aForm['inputs']['keyword']['attrs']['onpaste'] = $aForm['inputs']['keyword']['attrs']['onkeypress'];
     }
     bx_import('BxTemplFormView');
     $oForm = new BxTemplFormView($aForm);
     $sForm = $oForm->getCode();
     if (!$this->_bLiveSearch) {
         bx_import('BxTemplPaginate');
         $o = new BxTemplPaginate(array());
         $o->addCssJs();
     }
     return DesignBoxContent($sTitle, $sForm, $iDesignBoxTemplate);
 }
Esempio n. 13
0
 public function performActionExport()
 {
     $sContentInsert = $sContentDelete = "";
     $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];
     $aList = array();
     $this->oDb->getLists(array('type' => 'by_id', 'value' => $iId), $aList, false);
     if (!is_array($aList) || empty($aList)) {
         $this->_echoResultJson(array());
         exit;
     }
     $sContentInsert .= $this->oModule->_oDb->getQueryInsert('sys_form_pre_lists', array($aList), "Dumping data for '" . $aList['key'] . "' data list");
     $sContentDelete .= $this->oModule->_oDb->getQueryDelete('sys_form_pre_lists', 'key', array($aList), "Deleting data for '" . $aList['key'] . "' data list");
     $aValues = array();
     $this->oDb->getValues(array('type' => 'by_key', 'value' => $aList['key']), $aValues, false);
     $sContentInsert .= $this->oModule->_oDb->getQueryInsert('sys_form_pre_values', $aValues, false, array('id', 'key', 'value', 'lkey', 'lkey2', 'order'));
     $sContentDelete .= $this->oModule->_oDb->getQueryDelete('sys_form_pre_values', 'Key', array(array('Key' => $aList['key'])), false);
     $aFormStructure = array('form_attrs' => array(), 'inputs' => array('insert' => array('type' => 'textarea', 'name' => 'insert', 'caption' => _t('_bx_dev_frm_txt_prelists_export_insert'), 'value' => $sContentInsert), 'delete' => array('type' => 'textarea', 'name' => 'delete', 'caption' => _t('_bx_dev_frm_txt_prelists_export_delete'), 'value' => $sContentDelete), 'done' => array('type' => 'button', 'name' => 'done', 'value' => _t('_bx_dev_frm_btn_prelists_done'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()"))));
     $oForm = new BxTemplStudioFormView($aFormStructure);
     bx_import('BxTemplStudioFunctions');
     $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-frm-prelist-export-popup', _t('_bx_dev_frm_txt_prelists_export_popup', _t($aList['title'])), $this->oModule->_oTemplate->parseHtmlByName('form_export.html', array('content' => $oForm->getCode())));
     $this->_echoResultJson(array('popup' => $sContent), true);
 }
 function __construct($sPage = "")
 {
     parent::__construct('builder_permissions');
     $this->oDb = new BxDolStudioPermissionsQuery();
     $this->sPage = BX_DOL_STUDIO_PRM_TYPE_DEFAULT;
     if (is_string($sPage) && !empty($sPage)) {
         $this->sPage = $sPage;
     }
     //--- Check actions ---//
     if (($sAction = bx_get('pgt_action')) !== false) {
         $sAction = bx_process_input($sAction);
         $aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
         switch ($sAction) {
             case 'get-page-by-type':
                 $sValue = bx_process_input(bx_get('pgt_value'));
                 if (empty($sValue)) {
                     break;
                 }
                 $this->sPage = $sValue;
                 $aResult = array('code' => 0, 'content' => $this->getPageCode());
                 break;
         }
         echo json_encode($aResult);
         exit;
     }
 }
Esempio n. 15
0
 protected function authorize()
 {
     if ($this->isAuthorized()) {
         return true;
     }
     $oConsumer = $this->getServiceObject(false);
     try {
         $bToken = bx_get('oauth_token') !== false;
         $mixedSecret = $this->oSession->getValue('sys_oauth_secret');
         if (!$bToken && $mixedSecret !== false) {
             $this->oSession->unsetValue('sys_oauth_secret');
             $mixedSecret = false;
         }
         //--- Get request token and redirect to authorize.
         if (!$bToken && $mixedSecret === false) {
             return $this->getRequestToken($oConsumer);
         }
         //--- Get access token.
         if ($bToken && $mixedSecret !== false) {
             return $this->getAccessToken(bx_get('oauth_token'), $mixedSecret, bx_get('oauth_verifier'), (int) bx_get('oauth_user'), $oConsumer);
         }
     } catch (OAuthException $e) {
         return $this->getRequestToken();
     }
     return $this->getRequestToken();
 }
Esempio n. 16
0
 function process($aAddonFields = array())
 {
     if (!$this->oPF->aArea) {
         return 'Profile Fields cache not loaded. Cannot continue.';
     }
     $this->aPages = array_keys($this->oPF->aArea);
     $this->iPage = isset($_POST['join_page']) ? $_POST['join_page'] : 0;
     // get current working page from POST
     if ($this->iPage !== 'done') {
         $this->iPage = (int) $this->iPage;
     }
     $this->getCoupleOptions();
     $this->processPostValues();
     if ($this->bAjaxMode && bx_get('join_page_validate') !== false) {
         echo $this->showErrorsJson();
         exit;
     }
     $sContent = '';
     if ($this->iPage === 'done') {
         //if all pages are finished and no errors found
         list($iMemberId, $sStatus) = $this->registerMember();
         $sContent .= !$iMemberId ? $this->showFailPage() : $this->showFinishPage($iMemberId, $sStatus);
     } else {
         $sContent .= $this->showJoinForm($aAddonFields);
     }
     return $sContent;
 }
 public function __construct($aObject, $oTemplate = false)
 {
     parent::__construct($aObject, $oTemplate);
     $CNF = $this->_oModule->_oConfig->CNF;
     $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
     $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
     if ($iProfileId) {
         $this->_oProfile = BxDolProfile::getInstance($iProfileId);
     }
     if (!$this->_oProfile && $iContentId) {
         $this->_oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->MODULE);
     }
     if ($this->_oProfile) {
         $this->_aProfileInfo = $this->_oProfile->getInfo();
         $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_aProfileInfo['content_id']);
         $this->addMarkers($this->_aProfileInfo);
         $this->addMarkers(array('profile_id' => $this->_oProfile->id()));
         if (isLogged()) {
             $oConn = BxDolConnection::getObjectInstance('sys_profiles_friends');
             if ($oConn->isConnectedNotMutual(bx_get_logged_profile_id(), $this->_oProfile->id())) {
                 $this->addMarkers(array('title_add_friend' => _t($CNF['T']['menu_item_title_befriend_sent']), 'title_remove_friend' => _t($CNF['T']['menu_item_title_unfriend_cancel_request'])));
             } elseif ($oConn->isConnectedNotMutual($this->_oProfile->id(), bx_get_logged_profile_id())) {
                 $this->addMarkers(array('title_add_friend' => _t($CNF['T']['menu_item_title_befriend_confirm']), 'title_remove_friend' => _t($CNF['T']['menu_item_title_unfriend_reject_request'])));
             } else {
                 $this->addMarkers(array('title_add_friend' => _t($CNF['T']['menu_item_title_befriend']), 'title_remove_friend' => _t($CNF['T']['menu_item_title_unfriend'])));
             }
         }
     }
 }
Esempio n. 18
0
 /**
  * Get page code with automatic caching, adding necessary css/js files and system template vars.
  * @return string.
  */
 public function getCode()
 {
     if (bx_get('dynamic') && ($iBlockId = (int) bx_get('pageBlock'))) {
         if (!$this->_isVisiblePage($this->_aObject)) {
             header('HTTP/1.0 403 Forbidden');
             exit;
         }
         header('Content-type:text/html;charset=utf-8');
         echo $this->_getBlockOnlyCode($iBlockId);
         exit;
     }
     if (!$this->_isVisiblePage($this->_aObject)) {
         return $this->_getPageAccessDeniedMsg();
     }
     $this->_addJsCss();
     $this->_addSysTemplateVars();
     $this->_selectMenu();
     if (!getParam('sys_page_cache_enable') || !$this->_aObject['cache_lifetime']) {
         return $this->_getPageCode();
     }
     $oCache = $this->_getPageCacheObject();
     $sKey = $this->_getPageCacheKey();
     $mixedRet = $oCache->getData($sKey, $this->_aObject['cache_lifetime']);
     if ($mixedRet !== null) {
         return $mixedRet;
     } else {
         $sPageCode = $this->_getPageCode();
         $oCache->setData($sKey, $sPageCode, $this->_aObject['cache_lifetime']);
     }
     return $sPageCode;
 }
 public function performActionEdit()
 {
     $sAction = '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];
     $aEtemplate = array();
     $this->oDb->getEtemplates(array('type' => 'by_id', 'value' => $iId), $aEtemplate, false);
     if (empty($aEtemplate) || !is_array($aEtemplate)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aForm = array('form_attrs' => array('id' => 'adm-pgt-etemplate-edit', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction, 'method' => BX_DOL_STUDIO_METHOD_DEFAULT), 'params' => array('db' => array('table' => 'sys_email_templates', 'key' => 'ID', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('ID' => array('type' => 'hidden', 'name' => 'id', 'value' => $iId, 'db' => array('pass' => 'Int')), 'NameSystem' => array('type' => 'text_translatable', 'name' => 'NameSystem', 'caption' => _t('_adm_pgt_txt_etemplates_name_system'), 'info' => _t('_adm_pgt_dsc_etemplates_name_system'), 'value' => $aEtemplate['name_system'], 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'LengthTranslatable', 'params' => array(3, 100, 'NameSystem'), 'error' => _t('_adm_pgt_err_etemplates_name_system'))), 'Subject' => array('type' => 'text_translatable', 'name' => 'Subject', 'caption' => _t('_adm_pgt_txt_etemplates_subject'), 'info' => _t('_adm_pgt_dsc_etemplates_subject'), 'value' => $aEtemplate['subject'], 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'AvailTranslatable', 'params' => array('Subject'), 'error' => _t('_adm_pgt_err_etemplates_subject'))), 'Body' => array('type' => 'textarea_translatable', 'name' => 'Body', 'caption' => _t('_adm_pgt_txt_etemplates_body'), 'info' => _t('_adm_pgt_dsc_etemplates_body'), 'value' => $aEtemplate['body'], 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'AvailTranslatable', 'params' => array('Body'), 'error' => _t('_adm_pgt_err_etemplates_body'))), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_pgt_btn_etemplates_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_pgt_btn_etemplates_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->update($iId) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_adm_pgt_err_etemplates_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-pgt-etemplate-edit-popup', _t('_adm_pgt_txt_etemplates_edit_popup', _t($aEtemplate['name_system'])), $this->_oTemplate->parseHtmlByName('pgt_new_etemplate.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Esempio n. 20
0
 public function init()
 {
     if (($sAction = bx_get('pgt_action')) === false) {
         return;
     }
     $sAction = bx_process_input($sAction);
     $oLanguages = BxDolStudioLanguagesUtils::getInstance();
     $aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
     switch ($sAction) {
         case 'get-page-by-type':
             $sValue = bx_process_input(bx_get('pgt_value'));
             if (empty($sValue)) {
                 break;
             }
             $this->sPage = $sValue;
             $aResult = array('code' => 0, 'content' => $this->getPageCode());
             break;
             /*
              * Available URL params:
              * pgt_action = recompile - action name
              * pgt_language - ID or name(en, ru, etc) of language.
              */
         /*
          * Available URL params:
          * pgt_action = recompile - action name
          * pgt_language - ID or name(en, ru, etc) of language.
          */
         case 'recompile':
             $sLanguage = bx_process_input(bx_get('pgt_language'));
             if ($oLanguages->compileLanguage($sLanguage)) {
                 $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_recompiled'));
             } else {
                 $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_recompile_lang'));
             }
             break;
             /*
              * Available URL params:
              * pgt_action = restore - action name
              * pgt_language - ID or name(en, ru, etc) of language.
              * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
              */
         /*
          * Available URL params:
          * pgt_action = restore - action name
          * pgt_language - ID or name(en, ru, etc) of language.
          * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
          */
         case 'restore':
             $sLanguage = bx_process_input(bx_get('pgt_language'));
             $sModule = bx_process_input(bx_get('pgt_module'));
             if ($oLanguages->restoreLanguage($sLanguage, $sModule)) {
                 $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_restored'));
             } else {
                 $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_restore_lang'));
             }
             break;
     }
     echo json_encode($aResult);
     exit;
 }
Esempio n. 21
0
 function processActions()
 {
     if (($sAction = bx_get($this->sParamPrefix . '_action')) !== false) {
         $sAction = bx_process_input($sAction);
         $aResult = array('code' => 1, 'message' => _t('_adm_' . $this->sLangPrefix . '_err_cannot_process_action'));
         switch ($sAction) {
             case 'uninstall':
                 $sPageName = bx_process_input(bx_get($this->sParamPrefix . '_page_name'));
                 if (empty($sPageName)) {
                     break;
                 }
                 bx_import('BxDolModuleQuery');
                 $aModule = BxDolModuleQuery::getInstance()->getModuleByName($sPageName);
                 if (empty($aModule) || !is_array($aModule)) {
                     break;
                 }
                 if (($iWidgetId = (int) bx_get($this->sParamPrefix . '_widget_id')) != 0 && (int) bx_get($this->sParamPrefix . '_confirmed') != 1) {
                     $aResult['message'] = $this->getPopupConfirm($iWidgetId, $aModule);
                     break;
                 }
                 bx_import('BxDolStudioInstallerUtils');
                 $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall');
                 if (!empty($aResult['message'])) {
                     $aResult['message'] = $this->getPopupResult($aResult['message']);
                 }
                 break;
         }
         if (!empty($aResult['message'])) {
             bx_import('BxTemplStudioFunctions');
             $aResult['message'] = BxTemplStudioFunctions::getInstance()->transBox('', $aResult['message']);
         }
         echo json_encode($aResult);
         exit;
     }
 }
Esempio n. 22
0
/**
 * send "tell a friend" email
 */
function SendTellFriend($iSenderID = 0)
{
    global $profileID;
    $sSenderEmail = clear_xss(bx_get('sender_email'));
    if (strlen(trim($sSenderEmail)) <= 0) {
        return 0;
    }
    $sSenderName = clear_xss(bx_get('sender_name'));
    $sSenderLink = $iSenderID != 0 ? getProfileLink($iSenderID) : BX_DOL_URL_ROOT;
    $sRecipientEmail = clear_xss(bx_get('recipient_email'));
    if (strlen(trim($sRecipientEmail)) <= 0) {
        return 0;
    }
    $sLinkAdd = $iSenderID > 0 ? 'idFriend=' . $iSenderID : '';
    $rEmailTemplate = new BxDolEmailTemplates();
    if ($profileID) {
        $aTemplate = $rEmailTemplate->getTemplate('t_TellFriendProfile', getLoggedId());
        $Link = getProfileLink($profileID, $sLinkAdd);
    } else {
        $aTemplate = $rEmailTemplate->getTemplate('t_TellFriend', getLoggedId());
        $Link = BX_DOL_URL_ROOT;
        if (strlen($sLinkAdd) > 0) {
            $Link .= '?' . $sLinkAdd;
        }
    }
    return sendMail($sRecipientEmail, $aTemplate['Subject'], $aTemplate['Body'], '', array('Link' => $Link, 'SenderName' => $sSenderName, 'SenderLink' => $sSenderLink));
}
 function MlClonetwoPageEditProcessor($iId)
 {
     global $logged;
     $this->aPages = array(0 => array(), 1 => array());
     // double arrays (for couples)
     $this->aValues = array(0 => array(), 1 => array());
     $this->aErrors = array(0 => array(), 1 => array());
     //$iId = bx_get('ID');
     $this->iPageID = (int) $iId;
     $iPageInfo = db_arr("SELECT `uri`, `author_id` FROM `ml_clonetwo_main` WHERE `id` = {$this->iPageID} LIMIT 1");
     $this->sUri = $iPageInfo['uri'];
     //$this -> sSubCategory = $iPageInfo['SubCategory'];
     //$this -> sMainCategory = $iPageInfo['MainCategory'];
     // basic checks
     $iMemberID = getLoggedId();
     // check if this member is owner
     if ($iPageInfo['author_id'] == $iMemberID) {
         $this->iArea = 2;
     }
     $this->bAjaxMode = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');
     $this->bForceAjaxSave = bx_get('force_ajax_save');
     $this->aFormPrivacy['form_attrs']['action'] = BX_DOL_URL_ROOT . 'modules/modloaded/clonetwo/edit.php?page_id=' . $this->iPageID;
     $this->aFormPrivacy['inputs']['profile_id']['value'] = $this->iPageID;
     $this->aFormPrivacy['inputs']['save_privacy']['value'] = _t('_edit_profile_privacy_save');
     //parent::BxDolPageView('page_edit');
 }
Esempio n. 24
0
 /**
  * 
  * Is called via Ajax Requests only. 
  */
 public function perform()
 {
     $iIndex = (int) bx_get('index');
     $mixedSystemsActive = bx_get('systems_active');
     if ($mixedSystemsActive !== false) {
         $this->_aSystemsActive = $mixedSystemsActive;
     }
     $this->_aSystems = $this->_getCachedSystems();
     if (empty($this->_aSystems) || !is_array($this->_aSystems)) {
         return array();
     }
     $aCached = $this->_getCachedData();
     $aRequested = $this->_getRequestedData($iIndex, true, $aCached);
     $aResult = array();
     $bUpdateCache = false;
     foreach ($aRequested as $sName => $aData) {
         $bCached = isset($aCached[$sName]);
         if ($bCached && (int) $aCached[$sName] == (int) $aData['count']) {
             continue;
         }
         if ($bCached) {
             $aResultData = array('count_new' => $aData['count'], 'count_old' => $aCached[$sName]);
             if (isset($aData['data'])) {
                 $aResultData = array_merge($aResultData, $aData['data']);
             }
             $aResult[] = array('data' => $aResultData, 'method' => $aData['method']);
         }
         $aCached[$sName] = $aData['count'];
         $bUpdateCache = true;
     }
     if ($bUpdateCache) {
         $this->_updateCached('data', $aCached);
     }
     return $aResult;
 }
 function __construct($sPage = "")
 {
     parent::__construct('builder_menus');
     $this->oDb = new BxDolStudioNavigationQuery();
     $this->sPage = BX_DOL_STUDIO_NAV_TYPE_DEFAULT;
     if (is_string($sPage) && !empty($sPage)) {
         $this->sPage = $sPage;
     }
     //--- Check actions ---//
     if (($sAction = bx_get('nav_action')) !== false) {
         $sAction = bx_process_input($sAction);
         $aResult = array('code' => 1, 'message' => _t('_adm_nav_err_cannot_process_action'));
         switch ($sAction) {
             case 'get-page-by-type':
                 $sValue = bx_process_input(bx_get('nav_value'));
                 if (empty($sValue)) {
                     break;
                 }
                 $this->sPage = $sValue;
                 $aResult = array('code' => 0, 'content' => $this->getPageCode());
                 break;
             default:
                 $sMethod = 'action' . $this->getClassName($sAction);
                 if (method_exists($this, $sMethod)) {
                     $aResult = $this->{$sMethod}();
                 }
         }
         echo json_encode($aResult);
         exit;
     }
 }
 public function performActionDelete($aParams = array())
 {
     $CNF =& $this->_oModule->_oConfig->CNF;
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aIdsAffected = array();
     foreach ($aIds as $iId) {
         $aContentInfo = $this->_getContentInfo($iId);
         if ($this->_oModule->checkAllowedDelete($aContentInfo) !== CHECK_ACTION_RESULT_ALLOWED) {
             continue;
         }
         if (!$this->_doDelete($iId, $aParams)) {
             continue;
         }
         if (!$this->_onDelete($iId, $aParams)) {
             continue;
         }
         $this->_oModule->checkAllowedDelete($aContentInfo, true);
         $aIdsAffected[] = $iId;
         $iAffected++;
     }
     $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t($CNF['T']['grid_action_err_delete'])));
 }
Esempio n. 27
0
 public function __construct($aObject, $oTemplate = false)
 {
     parent::__construct($aObject, $oTemplate);
     // get profile info
     $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
     if ($iProfileId) {
         $this->_oProfile = BxDolProfile::getInstance($iProfileId);
         $this->_aProfileInfo = $this->_oProfile ? $this->_oProfile->getInfo() : false;
     }
     if (!$this->_aProfileInfo || !$this->_oProfile) {
         return;
     }
     // select view profile submenu
     $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
     if ($oMenuSubmenu) {
         $oMenuSubmenu->setObjectSubmenu('bx_persons_view_submenu', array('title' => $this->_oProfile->getDisplayName(), 'link' => $this->_oProfile->getUrl(), 'icon' => $this->_oProfile->getIcon()));
     }
     // add replaceable markers
     $this->addMarkers($this->_aProfileInfo);
     // every profile field can be used as marker
     $this->addMarkers(array('profile_id' => $this->_oProfile->id()));
     // profile id field is also suported
     $this->addMarkers(array('display_name' => $this->_oProfile->getDisplayName()));
     // profile display name is also suported
 }
Esempio n. 28
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')));
 }
Esempio n. 29
0
 /**
  * 'recheck' action handler
  */
 public function performActionRecheckItem()
 {
     bx_import('BxDolModule');
     $oModule = BxDolModule::getInstance('bx_antispam');
     $o = bx_instance('BxAntispamDNSBlacklists', array(), $oModule->_aModule);
     $aChain = $o->getRule((int) bx_get('id'));
     $iRet = BX_DOL_DNSBL_FAILURE;
     if ($aChain) {
         if (bx_get('chain') == 'dnsbl') {
             $iRet = $o->dnsbl_lookup_ip($aChain, bx_process_input(bx_get('test')));
         } elseif (bx_get('chain') == 'uridnsbl') {
             $sUrl = preg_replace('/^\\w+:\\/\\//', '', bx_process_input(bx_get('test')));
             $sUrl = preg_replace('/^www\\./', '', $sUrl);
             $oBxDolDNSURIBlacklists = bx_instance('BxAntispamDNSURIBlacklists', array(), $oModule->_aModule);
             $aUrls = $oBxDolDNSURIBlacklists->validateUrls(array($sUrl));
             if ($aUrls) {
                 $iRet = $o->dnsbl_lookup_uri($aUrls[0], $aChain);
             }
         }
     }
     $s = '';
     switch ($iRet) {
         case BX_DOL_DNSBL_POSITIVE:
             $s = 'LISTED';
             break;
         case BX_DOL_DNSBL_NEGATIVE:
             $s = 'NOT LISTED';
             break;
         default:
         case BX_DOL_DNSBL_FAILURE:
             $s = 'FAIL';
     }
     echo $s;
     exit;
 }
Esempio n. 30
0
 function __construct($sType = '', $sCategory = '')
 {
     parent::__construct('settings');
     $this->oDb = new BxDolStudioSettingsQuery();
     $this->sType = BX_DOL_STUDIO_STG_TYPE_DEFAULT;
     if (is_string($sType) && !empty($sType)) {
         $this->sType = $sType;
     }
     $this->sCategory = '';
     if (is_string($sCategory) && !empty($sCategory)) {
         $this->sCategory = $sCategory;
     }
     //--- Check actions ---//
     if (($sAction = bx_get('stg_action')) !== false && ($sValue = bx_get('stg_value')) !== false) {
         $sAction = bx_process_input($sAction);
         $sValue = bx_process_input($sValue);
         $aResult = array('code' => 0, 'message' => '');
         if (!empty($sAction) && !empty($sValue)) {
             switch ($sAction) {
                 case 'get-page-by-type':
                     $this->sType = $sValue;
                     $aResult['content'] = $this->getPageCode();
                     break;
             }
             echo json_encode($aResult);
         }
         exit;
     }
 }