Example #1
0
 /**
  * Overwritten method of parent class.
  *
  * @param BxDolAlerts $oAlert an instance of alert.
  */
 public function response($oAlert)
 {
     $iObjectPrivacyView = $this->_getObjectPrivacyView($oAlert->aExtras);
     if ($iObjectPrivacyView == BX_DOL_PG_HIDDEN) {
         return;
     }
     $aHandler = $this->_oModule->_oConfig->getHandlers($oAlert->sUnit . '_' . $oAlert->sAction);
     switch ($aHandler['type']) {
         case BX_BASE_MOD_NTFS_HANDLER_TYPE_INSERT:
             $sMethod = 'getInsertData' . bx_gen_method_name($oAlert->sUnit . '_' . $oAlert->sAction);
             if (!method_exists($this, $sMethod)) {
                 $sMethod = 'getInsertData';
             }
             $iId = $this->_oModule->_oDb->insertEvent($this->{$sMethod}($oAlert));
             if (!empty($iId)) {
                 $this->_oModule->onPost($iId);
             }
             break;
         case BX_BASE_MOD_NTFS_HANDLER_TYPE_UPDATE:
             $this->_oModule->_oDb->updateEvent(array('object_privacy_view' => $iObjectPrivacyView), array('type' => $oAlert->sUnit, 'object_id' => $oAlert->iObject));
             break;
         case BX_BASE_MOD_NTFS_HANDLER_TYPE_DELETE:
             if ($oAlert->sUnit == 'profile' && $oAlert->sAction == 'delete') {
                 $this->_oModule->_oDb->deleteEvent(array('owner_id' => $oAlert->iObject));
                 break;
             }
             $aHandlers = $this->_oModule->_oDb->getHandlers(array('type' => 'by_group_key_type', 'group' => $aHandler['group']));
             $this->_oModule->_oDb->deleteEvent(array('type' => $oAlert->sUnit, 'action' => $aHandlers[BX_BASE_MOD_NTFS_HANDLER_TYPE_INSERT]['alert_action'], 'object_id' => $oAlert->iObject, 'subobject_id' => $this->_getSubObjectId($oAlert->aExtras)));
             break;
     }
 }
Example #2
0
 /**
  * Overwtire the method of parent class.
  *
  * @param BxDolAlerts $oAlert an instance of alert.
  */
 public function response($oAlert)
 {
     $sMethod = '_process' . bx_gen_method_name($oAlert->sUnit . '_' . $oAlert->sAction);
     if (!method_exists($this, $sMethod)) {
         return;
     }
     return $this->{$sMethod}($oAlert);
 }
 function run($sAction = '')
 {
     $sMethod = 'action' . bx_gen_method_name($sAction);
     if ($sAction && method_exists($this, $sMethod)) {
         $this->{$sMethod}();
     } else {
         $this->actionInitial();
     }
 }
Example #4
0
 function __construct($sSystem, $iId, $iInit = 1)
 {
     parent::__construct($sSystem, $iId, $iInit);
     if (empty($sSystem)) {
         return;
     }
     $this->_sJsObjName = 'oCmts' . bx_gen_method_name($sSystem, array('_', '-')) . $iId;
     $this->_sStylePrefix = isset($this->_aSystem['root_style_prefix']) ? $this->_aSystem['root_style_prefix'] : 'cmt';
     BxDolTemplate::getInstance()->addJsTranslation('_sys_txt_cmt_loading');
 }
Example #5
0
 public function __construct($sSystem, $iId, $iInit = 1)
 {
     parent::__construct($sSystem, $iId, $iInit);
     $this->_sJsObjName = 'oVote' . bx_gen_method_name($sSystem, array('_', '-')) . $iId;
     $this->_sStylePrefix = 'bx-vote';
     $sHtmlId = str_replace(array('_', ' '), array('-', '-'), $sSystem) . '-' . $iId;
     $this->_aHtmlIds = array('main_stars' => 'bx-vote-stars-' . $sHtmlId, 'main_likes' => 'bx-vote-likes-' . $sHtmlId, 'counter' => 'bx-vote-counter-' . $sHtmlId, 'by_popup' => 'bx-vote-by-popup-' . $sHtmlId);
     $this->_aElementDefaults = array('stars' => array('show_do_vote_legend' => false, 'show_counter' => true), 'likes' => array('show_do_vote_as_button' => false, 'show_do_vote_as_button_small' => false, 'show_do_vote_icon' => true, 'show_do_vote_label' => false, 'show_counter' => true));
     $this->_sTmplNameCounter = 'vote_counter.html';
     $this->_sTmplNameDoVoteLikes = 'vote_do_vote_likes.html';
     $this->_sTmplNameDoVoteStars = 'vote_do_vote_stars.html';
 }
Example #6
0
 protected function _getContent(&$aEvent)
 {
     $sHandler = $aEvent['type'] . '_' . $aEvent['action'];
     if (!$this->_oConfig->isHandler($sHandler)) {
         return array();
     }
     $aHandler = $this->_oConfig->getHandlers($sHandler);
     if (!empty($aHandler['module_name']) && !empty($aHandler['module_class']) && !empty($aHandler['module_method'])) {
         return BxDolService::call($aHandler['module_name'], $aHandler['module_method'], array($aEvent), $aHandler['module_class']);
     }
     $sMethod = 'display' . bx_gen_method_name($aHandler['alert_unit'] . '_' . $aHandler['alert_action']);
     if (!method_exists($this, $sMethod)) {
         return array();
     }
     return $this->{$sMethod}($aEvent);
 }
Example #7
0
 function getVoting($sType, $iObjectId = 0, $aParams = array())
 {
     $iMax = $this->getMaxVote();
     list($iSizeX, $iSizeY) = $this->_getSizeByType($sType);
     $iWidth = $iSizeX * $iMax;
     if (empty($iObjectId)) {
         $iObjectId = $this->getId();
     }
     $sHtmlId = $this->_sSystem . '_voting_' . $sType . '_' . $iObjectId;
     $sJsObject = bx_gen_method_name($sHtmlId);
     $sRet = '<div class="votes_' . $sType . '" id="' . $sHtmlId . '">';
     $iCanRate = !empty($aParams['can_rate']);
     if ($iCanRate) {
         $aJsParams = array('sSystem' => $this->_sSystem, 'iObjId' => $iObjectId, 'sBaseUrl' => BX_DOL_URL_ROOT, 'iSize' => $iSizeX, 'iMax' => $iMax, 'sHtmlId' => $sHtmlId);
         $sRet .= $GLOBALS['oSysTemplate']->_wrapInTagJsCode('var ' . $sJsObject . ' = new BxDolVoting(' . json_encode($aJsParams) . ');');
     }
     $sRet .= '<div class="votes_gray_' . $sType . '" style="width:' . $iWidth . 'px;">';
     // clickable/hoverable vote buttons
     if ($iCanRate) {
         $sRet .= '<div class="votes_buttons">';
         for ($i = 1; $i <= $iMax; ++$i) {
             $sRet .= '<a href="javascript:void(0);" onmouseover="' . $sJsObject . '.over(' . $i . ');" onmouseout="' . $sJsObject . '.out();" onclick="' . $sJsObject . '.vote(' . $i . ')"><i class="votes_button_' . $sType . ' sys-icon">&#61446;</i></a>';
         }
         $sRet .= '</div>';
     }
     // gray stars
     $sRet .= '<div class="votes_gray_' . $sType . '" style="width:' . $iWidth . 'px;">';
     for ($i = 1; $i <= $iMax; ++$i) {
         $sRet .= '<i class="votes_button_' . $sType . ' sys-icon star-o"></i>';
     }
     $sRet .= '</div>';
     // active stars
     $iVoteRate = !empty($aParams['override_rate']) ? (int) $aParams['override_rate'] : $this->getVoteRate();
     $sRet .= '<div class="votes_slider votes_active_' . $sType . '" style="width:' . round($iVoteRate * ($iMax ? $iWidth / $iMax : 0)) . 'px;">';
     for ($i = 1; $i <= $iMax; ++$i) {
         $sRet .= '<i class="votes_button_' . $sType . ' sys-icon star"></i>';
     }
     $sRet .= '</div>';
     $sRet .= '</div>';
     // vot count
     if (!empty($aParams['show_count'])) {
         $sRet .= '<span class="votes_count">' . _t('_n_votes', $this->getVoteCount()) . '</span>';
     }
     $sRet .= '<div class="clear_both"></div>';
     $sRet .= '</div>';
     return $sRet;
 }
Example #8
0
 function saveChanges(&$oForm)
 {
     $aCategories = explode(',', $oForm->getCleanValue('categories'));
     foreach ($aCategories as $sCategory) {
         $aOptions = array();
         $iOptions = $this->oDb->getOptions(array('type' => 'by_category_name_full', 'value' => $sCategory), $aOptions);
         $aData = array();
         foreach ($aOptions as $aOption) {
             $aData[$aOption['name']] = $oForm->getCleanValue($aOption['name']);
             if (!empty($aOption['check'])) {
                 $sCheckerHelper = '';
                 if (!empty($aOption['type_name']) && BxDolRequest::serviceExists($aOption['type_name'], 'get_settings_checker_helper')) {
                     $sCheckerHelper = BxDolService::call($aOption['type_name'], 'get_settings_checker_helper');
                 }
                 if ($sCheckerHelper == '') {
                     bx_import('BxDolStudioForm');
                     $sCheckerHelper = 'BxDolStudioFormCheckerHelper';
                 }
                 $oChecker = new $sCheckerHelper();
                 $aCheckFunction = array($oChecker, 'check' . bx_gen_method_name($aOption['check']));
                 $aCheckFunctionParams = array($aData[$aOption['name']]);
                 if (!empty($aOption['check_params'])) {
                     $aCheckFunctionParams = array_merge($aCheckFunctionParams, unserialize($aOption['check_params']));
                 }
                 if (is_callable($aCheckFunction) && !call_user_func_array($aCheckFunction, $aCheckFunctionParams)) {
                     $this->sCategory = $sCategory;
                     return $this->getJsResult(_t('_adm_stg_err_save_error_message', _t($aOption['caption']), _t($aOption['check_error'])), false);
                 }
             }
             if (isset($aData[$aOption['name']])) {
                 $aData[$aOption['name']] = $this->getProcessedValue($aOption, $aData[$aOption['name']]);
             } else {
                 $aData[$aOption['name']] = $this->getEmptyValue($aOption);
             }
             if ($this->oDb->setParam($aOption['name'], $aData[$aOption['name']])) {
                 $aCategoryInfo = array();
                 $this->oDb->getCategories(array('type' => 'by_name', 'value' => $sCategory), $aCategoryInfo, false);
                 bx_alert('system', 'save_setting', 0, 0, array('category' => $aCategoryInfo, 'option' => $aOption['name'], 'value' => $aData[$aOption['name']]));
             }
         }
     }
     return $this->getJsResult('_adm_stg_scs_save');
 }
 function _getSystemData(&$aEvent, $sDisplayType = BX_WALL_VIEW_TIMELINE)
 {
     $sHandler = $aEvent['type'] . '_' . $aEvent['action'];
     if (!$this->_oConfig->isHandler($sHandler)) {
         return array();
     }
     $aHandler = $this->_oConfig->getHandlers($sHandler);
     if (empty($aHandler['module_uri']) && empty($aHandler['module_class']) && empty($aHandler['module_method'])) {
         $sMethod = 'display' . bx_gen_method_name($aHandler['alert_unit'] . '_' . $aHandler['alert_action']);
         if (!method_exists($this, $sMethod)) {
             return array();
         }
         $aResult = $this->{$sMethod}($aEvent, $sDisplayType);
     } else {
         $aEvent['js_mode'] = $this->_oConfig->getJsMode();
         $aResult = $this->_oConfig->getSystemData($aEvent, $sDisplayType);
         if (isset($aResult['save'])) {
             $this->_oDb->updateEvent($aResult['save'], $aEvent['id']);
         }
     }
     return $aResult;
 }
Example #10
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";
require_once BX_DIRECTORY_PATH_INC . "utils.inc.php";
bx_import('BxDolLanguages');
$sObject = bx_process_input(bx_get('o'));
if (!$sObject) {
    exit;
}
bx_import('BxDolGrid');
$oGrid = BxDolGrid::getObjectInstance($sObject);
if (!$oGrid) {
    // no such grid object available
    exit;
}
$sAction = 'performAction' . bx_gen_method_name(bx_process_input(bx_get('a')));
if (method_exists($oGrid, $sAction)) {
    $oGrid->{$sAction}();
}
/** @} */
Example #11
0
 public static function getClassName($sValue)
 {
     return bx_gen_method_name($sValue);
 }
Example #12
0
 protected function getCheckMethod($s)
 {
     if (substr($s, 0, 1) != '@') {
         return false;
     }
     return bx_gen_method_name(str_replace('@', 'check_', $s));
 }
Example #13
0
 protected function _perform($sOperationName, $aParams = array())
 {
     $bHtmlResponce = isset($aParams['html_response']) && (bool) $aParams['html_response'];
     if (!defined('BX_SKIP_INSTALL_CHECK') && !defined('BX_DOL_CRON_EXECUTE') && !$GLOBALS['logged']['admin']) {
         return array('message' => '_adm_mod_err_only_admin_can_perform_operations_with_modules', 'result' => false);
     }
     $sMessage = '';
     foreach ($this->_aConfig[$sOperationName] as $sAction => $iEnabled) {
         $sMethod = 'action' . bx_gen_method_name($sAction);
         if ($iEnabled == 0 || !method_exists($this, $sMethod)) {
             continue;
         }
         $mixedResult = $this->{$sMethod}($sOperationName);
         //--- On Success ---//
         if (is_int($mixedResult) && (int) $mixedResult == BX_DOL_STUDIO_INSTALLER_SUCCESS || isset($mixedResult['code']) && (int) $mixedResult['code'] == BX_DOL_STUDIO_INSTALLER_SUCCESS) {
             $sMessage .= $this->_displayResult($sAction, true, isset($mixedResult['content']) ? $mixedResult['content'] : '', $bHtmlResponce);
             continue;
         }
         //--- On Failed ---//
         $sMethodFailed = $sMethod . 'Failed';
         return array('message' => $this->_displayResult($sAction, false, method_exists($this, $sMethodFailed) ? $this->{$sMethodFailed}($mixedResult) : $this->actionOperationFailed($mixedResult), $bHtmlResponce), 'result' => false);
     }
     if ($this->_bShowOnSuccess) {
         $sMessage = $this->_aActions['perform_' . $sOperationName]['success'] . $sMessage;
     }
     return array('message' => $sMessage, 'result' => true);
 }
Example #14
0
 protected function _getSystemData(&$aEvent)
 {
     $mixedResult = $this->_oConfig->getSystemData($aEvent);
     if ($mixedResult !== false) {
         return $mixedResult;
     }
     $sMethod = 'display' . bx_gen_method_name($aEvent['type'] . '_' . $aEvent['action']);
     if (!method_exists($this, $sMethod)) {
         return '';
     }
     return $this->{$sMethod}($aEvent);
 }
Example #15
0
 protected static function _methodExists($mixedModule, $sMethodType, $sMethodName, $sClass = "Module")
 {
     $aModule = $mixedModule;
     if (is_string($mixedModule)) {
         bx_import('BxDolModuleQuery');
         $aModule = BxDolModuleQuery::getInstance()->getModuleByName($mixedModule);
     }
     if (!$aModule) {
         return false;
     }
     $sClass = $aModule['class_prefix'] . $sClass;
     if (($oModule = BxDolRequest::_require($aModule, $sClass)) === false) {
         return false;
     }
     $sMethod = $sMethodType . bx_gen_method_name($sMethodName);
     return method_exists($oModule, $sMethod);
 }
Example #16
0
 protected function _genMethodName($s)
 {
     return bx_gen_method_name($s);
 }
Example #17
0
    function _getFormBox($sType, $aCmt = array())
    {
        $iCmtId = !empty($aCmt['id']) ? (int) $aCmt['id'] : 0;
        $iCmtParentId = !empty($aCmt['parent_id']) ? (int) $aCmt['parent_id'] : 0;
        $sCmtText = !empty($aCmt['text']) ? $this->_prepareTextForEdit($aCmt['text']) : '';
        $sTextareaId = "cmt" . bx_gen_method_name($this->_sSystem . "_" . $sType) . "TextArea";
        switch ($sType) {
            case 'post':
                $sFunction = "submitComment(this)";
                $sTextareaId .= $iCmtParentId;
                break;
            case 'edit':
                $sFunction = "updateComment(this, '" . $iCmtId . "')";
                $sTextareaId .= $iCmtId;
                break;
        }
        if ($this->_aSystem['is_mood']) {
            $sMood = '
                    <div class="cmt-post-reply-mood">
                        <div class="cmt-post-mood-ctl"><input type="radio" name="CmtMood" value="1" id="' . $this->_sSystem . '-mood-positive" /></div>
                        <div class="cmt-post-mood-lbl"><label for="' . $this->_sSystem . '-mood-positive">' . _t('_Comment Positive') . '</label></div>
                        <div class="cmt-post-mood-ctl"><input type="radio" name="CmtMood" value="-1" id="' . $this->_sSystem . '-mood-negative" /></div>
                        <div class="cmt-post-mood-lbl"><label for="' . $this->_sSystem . '-mood-negative">' . _t('_Comment Negative') . '</label></div>
                        <div class="cmt-post-mood-ctl"><input type="radio" name="CmtMood" value="0" id="' . $this->_sSystem . '-mood-neutral" checked="checked" /></div>
                        <div class="cmt-post-mood-lbl"><label for="' . $this->_sSystem . '-mood-neutral">' . _t('_Comment Neutral') . '</label></div>
                        <div class="clear_both">&nbsp;</div>
                    </div>';
        }
        $sContent = '
			<form name="cmt-post-reply" onsubmit="' . $this->_sJsObjName . '.' . $sFunction . '; return false;">
				<input type="hidden" name="CmtParent" value="' . $iCmtParentId . '" />
				<input type="hidden" name="CmtType" value="text" />
				<div class="cmt-post-reply-text">
					<textarea class="cmt-text-' . $sType . ' bx-def-round-corners-with-border" id="' . $sTextareaId . '" name="CmtText">' . $sCmtText . '</textarea>
				</div>
				<div class="cmt-post-reply-video">' . getApplicationContent('video_comments', 'recorder', array('user' => $this->_getAuthorId(), 'password' => $this->_getAuthorPassword(), 'extra' => implode('_', array($this->_sSystem . '-' . $this->getId(), $iCmtParentId))), true) . '</div>
				<div class="cmt-post-reply-post"><button class="bx-btn bx-btn-small" type="submit">' . _t('_Submit Comment') . '</button></div>
				' . $sMood . '
			</form>';
        if ($this->iGlobAllowHtml == 1) {
            bx_import('BxDolEditor');
            $oEditor = BxDolEditor::getObjectInstance();
            $sContent .= $oEditor ? $oEditor->attachEditor('#' . $sTextareaId, BX_EDITOR_MINI, $this->bDynamic) : '';
        }
        return $sContent;
    }
Example #18
0
 private function getVarName($sVar)
 {
     return 'a' . bx_gen_method_name($sVar);
 }
Example #19
0
 function check(&$aInputs)
 {
     $oChecker = $this->_oChecker;
     $iErrors = 0;
     // check CSRF token if it's needed.
     if (getParam('sys_security_form_token_enable') == 'on' && $this->_bFormCsrfChecking === true && ($mixedCsrfTokenSys = BxDolForm::getCsrfToken()) !== false) {
         $mixedCsrfTokenUsr = BxDolForm::getSubmittedValue('csrf_token', $this->_sFormMethod, $this->_aSpecificValues);
         unset($aInputs['csrf_token']);
         if ($mixedCsrfTokenUsr === false || $mixedCsrfTokenSys != $mixedCsrfTokenUsr) {
             return false;
         }
     }
     $sSubmitName = false;
     foreach ($aInputs as $k => $a) {
         if (empty($a['name']) || 'submit' == $a['type'] || 'reset' == $a['type'] || 'button' == $a['type'] || 'value' == $a['type']) {
             if (isset($a['type']) && 'submit' == $a['type']) {
                 $sSubmitName = $k;
             }
             continue;
         }
         if ('input_set' == $a['type']) {
             foreach ($a as $r) {
                 if (isset($r['type']) && 'submit' == $r['type']) {
                     $sSubmitName = $k;
                 }
             }
         }
         $a['name'] = str_replace('[]', '', $a['name']);
         $val = BxDolForm::getSubmittedValue($a['name'], $this->_sFormMethod, $this->_aSpecificValues);
         if (isset(BxDolForm::$TYPES_FILE[$a['type']])) {
             $val = isset($_FILES[$a['name']]['name']) ? $_FILES[$a['name']]['name'] : '';
         }
         if (!isset($a['checker'])) {
             if (isset(BxDolForm::$TYPES_CHECKBOX[$a['type']])) {
                 $aInputs[$k]['checked'] = isset($aInputs[$k]['value']) && $aInputs[$k]['value'] == $val;
             } elseif (!isset(BxDolForm::$TYPES_FILE[$a['type']])) {
                 $aInputs[$k]['value'] = bx_process_input($val);
             }
             continue;
         }
         $sCheckFunction = array($oChecker, 'check' . bx_gen_method_name($a['checker']['func']));
         if (is_callable($sCheckFunction)) {
             $bool = call_user_func_array($sCheckFunction, !empty($a['checker']['params']) ? array_merge(array($val), $a['checker']['params']) : array($val));
         } else {
             $bool = true;
         }
         if (is_string($bool)) {
             ++$iErrors;
             $aInputs[$k]['error'] = $bool;
         } elseif (!$bool) {
             ++$iErrors;
             $aInputs[$k]['error'] = $a['checker']['error'];
         }
         if (isset(BxDolForm::$TYPES_CHECKBOX[$a['type']])) {
             $aInputs[$k]['checked'] = $aInputs[$k]['value'] == $val;
         } elseif (!isset(BxDolForm::$TYPES_FILE[$a['type']])) {
             $aInputs[$k]['value'] = bx_process_input($val);
         }
     }
     // check for spam
     if (!$iErrors) {
         foreach ($aInputs as $k => $a) {
             if ($a['type'] != 'textarea') {
                 continue;
             }
             $a['name'] = str_replace('[]', '', $a['name']);
             $val = BxDolForm::getSubmittedValue($a['name'], $this->_sFormMethod, $this->_aSpecificValues);
             if (!$val) {
                 continue;
             }
             if (!$oChecker->checkIsSpam($val)) {
                 continue;
             }
             ++$iErrors;
             $sErr = _t('_sys_spam_detected');
             if (BxDolRequest::serviceExists('bx_contact', 'get_contact_page_url') && ($sUrl = BxDolService::call('bx_contact', 'get_contact_page_url'))) {
                 $sErr = _t('_sys_spam_detected_contact', $sUrl);
             }
             $aInputs[$k]['error'] = $sErr;
         }
     }
     // add error message near submit button
     if ($iErrors && $sSubmitName) {
         $aInputs[$sSubmitName]['error'] = _t('_sys_txt_form_submission_error');
     }
     return $iErrors ? false : true;
 }
Example #20
0
 protected function getClassName($sValue)
 {
     return bx_gen_method_name($sValue);
 }