Esempio n. 1
0
 public function getPost(&$aEvent, $aBrowseParams = array())
 {
     $oModule = $this->getModule();
     if ((int) $aEvent['processed'] == 0) {
         $aContent = $this->_getContent($aEvent);
         if (!empty($aContent) && is_array($aContent)) {
             $aSet = array();
             if (!empty($aContent['entry_author'])) {
                 $aSet['object_owner_id'] = (int) $aContent['entry_author'];
                 unset($aContent['entry_author']);
             }
             $aEvent['content'] = serialize($aContent);
             $aSet = array_merge($aSet, array('content' => $aEvent['content'], 'processed' => 1));
             $this->_oDb->updateEvent($aSet, array('id' => $aEvent['id']));
         }
     }
     list($sOwnerName, $sOwnerUrl, $sOwnerIcon) = $oModule->getUserInfo($aEvent['owner_id']);
     $bAuthorIcon = !empty($sOwnerIcon);
     $aEvent['content'] = unserialize($aEvent['content']);
     $aEvent['content']['owner_name'] = $sOwnerName;
     $aEvent['content']['owner_link'] = $sOwnerUrl;
     $sContent = _t(!empty($aEvent['content']['lang_key']) ? $aEvent['content']['lang_key'] : $this->_getLangKey($aEvent));
     $sContent = $this->parseHtmlByContent($sContent, $aEvent['content'], array('{', '}'));
     return $this->parseHtmlByName('event.html', array('html_id' => $this->_oConfig->getHtmlIds('view', 'event') . $aEvent['id'], 'style_prefix' => $this->_oConfig->getPrefix('style'), 'js_object' => $this->_oConfig->getJsObject('view'), 'id' => $aEvent['id'], 'bx_if:show_icon' => array('condition' => $bAuthorIcon, 'content' => array('author_icon' => $sOwnerIcon)), 'bx_if:show_icon_empty' => array('condition' => !$bAuthorIcon, 'content' => array()), 'content' => $sContent, 'date' => bx_time_js($aEvent['date'])));
 }
 function unit($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html')
 {
     $this->getCssJs();
     if ($sTemplateName == 'unit.html') {
         return $this->getPost($aData);
     }
     $oModule = $this->getModule();
     $CNF =& $this->_oConfig->CNF;
     if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->isAllowedView($aData))) {
         $aVars = array('summary' => $sMsg);
         return $this->parseHtmlByName('unit_private.html', $aVars);
     }
     list($sAuthorName, $sAuthorUrl, $sAuthorIcon) = $oModule->getUserInfo($aData['object_id']);
     $bAuthorIcon = !empty($sAuthorIcon);
     // generate html
     $aVars = array('id' => $aData['id'], 'author' => $sAuthorName, 'author_url' => $sAuthorUrl, 'title' => bx_process_output($aData['title']), 'item_url' => $this->_oConfig->getItemViewUrl($aData), 'item_date' => bx_time_js($aData['date'], BX_FORMAT_DATE), 'module_name' => _t($CNF['T']['txt_sample_single_ext']), 'ts' => $aData['date'], 'bx_if:show_icon' => array('condition' => $bAuthorIcon, 'content' => array('author_icon' => $sAuthorIcon)), 'bx_if:show_icon_empty' => array('condition' => !$bAuthorIcon, 'content' => array()));
     return $this->parseHtmlByName($sTemplateName, $aVars);
 }
Esempio n. 3
0
 protected function _getCellLastDT($mixedValue, $sKey, $aField, $aRow)
 {
     return parent::_getCellDefault(bx_time_js($mixedValue, BX_FORMAT_DATE), $sKey, $aField, $aRow);
 }
Esempio n. 4
0
 function entryMessagePreviewInGrid($r)
 {
     $oModule = BxDolModule::getInstance($this->MODULE);
     $oProfileLast = BxDolProfile::getInstance($r['last_reply_profile_id']);
     if (!$oProfileLast) {
         $oProfileLast = BxDolProfileUndefined::getInstance();
     }
     $sText = strmaxtextlen($r['text'], 100);
     $sTextCmt = strmaxtextlen($r['cmt_text'], 100);
     if (!isset($r['unread_messages'])) {
         $r['unread_messages'] = $r['comments'] - $r['read_comments'];
     }
     $aVars = array('url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $oModule->_oConfig->CNF['URI_VIEW_ENTRY'] . '&id=' . $r['id']), 'text' => $sText, 'cmt_text' => $sTextCmt, 'last_reply_time_and_replier' => _t('_bx_cnv_x_date_by_x_replier', bx_time_js($r['last_reply_timestamp'], BX_FORMAT_DATE), $oProfileLast->getDisplayName()), 'bx_if:unread_messages' => array('condition' => $r['unread_messages'] > 0, 'content' => array()));
     $aVars['bx_if:unread_messages2'] = $aVars['bx_if:unread_messages'];
     return $this->parseHtmlByName('message_preview_in_grid.html', $aVars);
 }
Esempio n. 5
0
 function getAuthorDesc($aData)
 {
     $oModule = BxDolModule::getInstance($this->MODULE);
     return bx_time_js($aData[$oModule->_oConfig->CNF['FIELD_ADDED']], BX_FORMAT_DATE);
 }
Esempio n. 6
0
 protected function _getPost($sType, $aEvent, $aBrowseParams = array())
 {
     $oModule = $this->getModule();
     $sStylePrefix = $this->_oConfig->getPrefix('style');
     $sJsObject = $this->_oConfig->getJsObject('view');
     list($sAuthorName, $sAuthorUrl, $sAuthorIcon) = $oModule->getUserInfo($aEvent['object_owner_id']);
     $bAuthorIcon = !empty($sAuthorIcon);
     $aTmplVarsMenuItemManage = $this->_getTmplVarsMenuItemManage($aEvent, $aBrowseParams);
     $aTmplVarsMenuItemActions = $this->_getTmplVarsMenuItemActions($aEvent, $aBrowseParams);
     $aTmplVarsTimelineOwner = array();
     if (isset($aBrowseParams['type']) && $aBrowseParams['type'] == BX_BASE_MOD_NTFS_TYPE_CONNECTIONS) {
         $aTmplVarsTimelineOwner = $this->_getTmplVarsTimelineOwner($aEvent);
     }
     $bBrowseItem = isset($aBrowseParams['type']) && $aBrowseParams['type'] == BX_TIMELINE_TYPE_ITEM;
     $aTmplVars = array('style_prefix' => $sStylePrefix, 'js_object' => $sJsObject, 'class' => $bBrowseItem ? 'bx-tl-view-sizer' : 'bx-tl-grid-sizer', 'id' => $aEvent['id'], 'bx_if:show_menu_item_manage' => array('condition' => !empty($aTmplVarsMenuItemManage), 'content' => $aTmplVarsMenuItemManage), 'bx_if:show_icon' => array('condition' => $bAuthorIcon, 'content' => array('author_icon' => $sAuthorIcon)), 'bx_if:show_icon_empty' => array('condition' => !$bAuthorIcon, 'content' => array()), 'item_owner_url' => $sAuthorUrl, 'item_owner_name' => $sAuthorName, 'bx_if:show_timeline_owner' => array('condition' => !empty($aTmplVarsTimelineOwner), 'content' => $aTmplVarsTimelineOwner), 'item_view_url' => $this->_oConfig->getItemViewUrl($aEvent), 'item_date' => bx_time_js($aEvent['date']), 'content' => is_string($aEvent['content']) ? $aEvent['content'] : $this->_getContent($sType, $aEvent['content'], $aBrowseParams), 'bx_if:show_menu_item_actions' => array('condition' => !empty($aTmplVarsMenuItemActions), 'content' => $aTmplVarsMenuItemActions), 'comments' => $bBrowseItem ? $this->_getComments($aEvent['comments']) : '', 'votes' => $this->_getVotes($aEvent['votes']));
     return $this->parseHtmlByName('item.html', $aTmplVars);
 }
Esempio n. 7
0
 /**
  * Generate value for view mode row
  *
  * @param  array  $aInput
  * @return string
  */
 function genViewRowValue(&$aInput)
 {
     switch ($aInput['type']) {
         case 'hidden':
             $sValue = null;
             break;
         case 'select':
         case 'radio_set':
             $sValue = isset($aInput['value']) && isset($aInput['values'][$aInput['value']]) ? $aInput['values'][$aInput['value']] : null;
             break;
         case 'datepicker':
             $iTime = bx_process_input($aInput['value'], BX_DATA_DATE_TS, false, false);
             $sValue = bx_time_js($iTime, BX_FORMAT_DATE);
             break;
         case 'date_time':
         case 'datetime':
             $iTime = bx_process_input($aInput['value'], BX_DATA_DATETIME_TS, false, false);
             $sValue = bx_time_js($iTime, BX_FORMAT_DATE_TIME);
             break;
         case 'checkbox_set':
         case 'select_multiple':
             $sValue = null;
             if (!empty($aInput['value']) && is_array($aInput['value'])) {
                 $sValue = '';
                 foreach ($aInput['value'] as $sVal) {
                     $sValue .= $aInput['values'][$sVal] . ', ';
                 }
                 $sValue = trim($sValue, ', ');
             }
             break;
         case 'checkbox':
         case 'switcher':
             $sValue = isset($aInput['checked']) && $aInput['checked'] ? _t('_sys_form_checkbox_value_on') : _t('_sys_form_checkbox_value_off');
             break;
         case 'textarea':
             $sValue = isset($aInput['value']) ? $aInput['value'] : null;
             break;
         default:
             $sValue = isset($aInput['value']) ? bx_process_output($aInput['value']) : null;
     }
     return $sValue;
 }
 protected function _getCellLogged($mixedValue, $sKey, $aField, $aRow)
 {
     return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
 }
Esempio n. 9
0
 * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
 * CC-BY License - http://creativecommons.org/licenses/by/3.0/
 *
 * @defgroup    TridentCore Samples
 * @{
 */
/**
 * @page samples
 * @section ajax AJAX loader
 */
$aPathInfo = pathinfo(__FILE__);
require_once $aPathInfo['dirname'] . '/../inc/header.inc.php';
require_once BX_DIRECTORY_PATH_INC . "design.inc.php";
if (bx_get('ajax') || isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
    sleep(3);
    echo '<div class="bx-def-padding bx-def-color-bg-block">AJAX content here: ' . bx_time_js(time(), BX_FORMAT_DATE_TIME, rand(0, 1)) . '</div>';
    exit;
}
$oTemplate = BxDolTemplate::getInstance();
$oTemplate->addJs('jquery.webForms.js');
$oTemplate->setPageNameIndex(BX_PAGE_DEFAULT);
$oTemplate->setPageHeader("AJAX");
$oTemplate->setPageContent('page_main_code', PageCompMainCode());
$oTemplate->getPageCode();
/**
 * page code function
 */
function PageCompMainCode()
{
    ob_start();
    ?>
Esempio n. 10
0
 /**
  * get one just posted comment
  *
  * @param  int    $iCmtId - comment id
  * @return string
  */
 function getComment($mixedCmt, $aBp = array(), $aDp = array())
 {
     $oTemplate = BxDolTemplate::getInstance();
     $iUserId = $this->_getAuthorId();
     $aCmt = !is_array($mixedCmt) ? $this->getCommentRow((int) $mixedCmt) : $mixedCmt;
     if (!$aCmt) {
         return '';
     }
     list($sAuthorName, $sAuthorLink, $sAuthorIcon) = $this->_getAuthorInfo($aCmt['cmt_author_id']);
     $sClass = '';
     if (isset($aCmt['vote_rate']) && (double) $aCmt['vote_rate'] < $this->_aSystem['viewing_threshold']) {
         $oTemplate->pareseHtmlByName('comment_hidden.html', array('js_object' => $this->_sJsObjName, 'id' => $aCmt['cmt_id'], 'title' => bx_process_output(_t('_hidden_comment', $sAuthorName)), 'bx_if:show_replies' => array('condition' => $aCmt['cmt_replies'] > 0, 'content' => array('replies' => _t('_Show N replies', $aCmt['cmt_replies'])))));
         $sClass = ' cmt-hidden';
     }
     if ($aCmt['cmt_author_id'] == $iUserId) {
         $sClass .= ' cmt-mine';
     }
     if (!empty($aDp['blink']) && in_array($aCmt['cmt_id'], $aDp['blink'])) {
         $sClass .= ' cmt-blink';
     }
     $sActions = $this->_getActionsBox($aCmt, $aDp);
     $aTmplReplyTo = array();
     if ((int) $aCmt['cmt_parent_id'] != 0) {
         $aParent = $this->getCommentRow($aCmt['cmt_parent_id']);
         list($sParAuthorName, $sParAuthorLink, $sParAuthorIcon) = $this->_getAuthorInfo($aParent['cmt_author_id']);
         $aTmplReplyTo = array('style_prefix' => $this->_sStylePrefix, 'par_cmt_link' => $this->getBaseUrl() . '#' . $this->_sSystem . $aCmt['cmt_parent_id'], 'par_cmt_title' => bx_html_attribute(_t('_in_reply_to', $sParAuthorName)), 'par_cmt_author' => $sParAuthorName);
     }
     $aTmplImages = array();
     if ($this->isAttachImageEnabled()) {
         $aImages = $this->_oQuery->getImages($this->_aSystem['system_id'], $aCmt['cmt_id']);
         if (!empty($aImages) && is_array($aImages)) {
             $oStorage = BxDolStorage::getObjectInstance($this->getStorageObjectName());
             $oTranscoder = BxDolTranscoderImage::getObjectInstance($this->getTranscoderPreviewName());
             foreach ($aImages as $aImage) {
                 $aTmplImages[] = array('style_prefix' => $this->_sStylePrefix, 'js_object' => $this->_sJsObjName, 'image' => $oTranscoder->getFileUrl($aImage['image_id']), 'image_orig' => $oStorage->getFileUrlById($aImage['image_id']));
             }
         }
     }
     $sReplies = '';
     if ((int) $aCmt['cmt_replies'] > 0 && !empty($aDp) && $aDp['type'] == BX_CMT_DISPLAY_THREADED) {
         $aDp['show_empty'] = false;
         $sReplies = $this->getComments(array('parent_id' => $aCmt['cmt_id'], 'vparent_id' => $aCmt['cmt_id'], 'type' => $aBp['type']), $aDp);
     }
     $sAgo = bx_time_js($aCmt['cmt_time']);
     $bObjectTitle = !empty($this->_aSystem['trigger_field_title']);
     return $oTemplate->parseHtmlByName('comment.html', array_merge(array('system' => $this->_sSystem, 'style_prefix' => $this->_sStylePrefix, 'js_object' => $this->_sJsObjName, 'id' => $aCmt['cmt_id'], 'class' => $sClass, 'bx_if:show_reply_to' => array('condition' => !empty($aTmplReplyTo), 'content' => $aTmplReplyTo), 'bx_if:show_ago_link' => array('condition' => $bObjectTitle, 'content' => array('style_prefix' => $this->_sStylePrefix, 'view_link' => $this->getViewUrl($aCmt['cmt_id']), 'ago' => $sAgo)), 'bx_if:show_ago_text' => array('condition' => !$bObjectTitle, 'content' => array('ago' => $sAgo)), 'bx_if:show_attached' => array('condition' => !empty($aTmplImages), 'content' => array('style_prefix' => $this->_sStylePrefix, 'bx_repeat:attached' => $aTmplImages)), 'actions' => $sActions, 'replies' => $sReplies), $this->_getTmplVarsAuthor($aCmt), $this->_getTmplVarsText($aCmt)));
 }
Esempio n. 11
0
 public function onPaymentReceived(&$aData, $fAmount)
 {
     $sProfileId = $aData['recurring_payment_id'];
     $aAccount = $this->_oModule->_oDb->getAccount(array('type' => 'profile_id', 'value' => $sProfileId));
     if (!empty($aAccount) && is_array($aAccount)) {
         $sTransaction = bx_process_input($aData['txn_id']);
         $iWhen = strtotime($aData['payment_date']);
         $iPaidUntil = strtotime($aData['next_payment_date']);
         $sActStatus = $sPmtType = '';
         if ($aData['period_type'] == BX_SITES_PP_PERIOD_TRIAL) {
             $sActStatus = BX_SITES_ACCOUNT_STATUS_TRIAL;
             $sPmtType = BX_SITES_TRANSACTION_TRIAL;
             $this->_oModule->_oDb->updateOwner(array('trials' => $aAccount['owner_trials'] + 1), array('id' => $aAccount['owner_id']));
         } else {
             if ($aData['period_type'] == BX_SITES_PP_PERIOD_REGULAR) {
                 $sActStatus = BX_SITES_ACCOUNT_STATUS_ACTIVE;
                 $sPmtType = BX_SITES_TRANSACTION_REGULAR;
             }
         }
         $this->_oModule->_oDb->insertPaymentHistory(array('account_id' => $aAccount['id'], 'type' => $sPmtType, 'transaction' => $sTransaction, 'amount' => $fAmount, 'when' => $iWhen, 'when_next' => $iPaidUntil));
         $this->_oModule->_oDb->updateAccount(array('paid' => $iPaidUntil, 'status' => $sActStatus), array('id' => $aAccount['id']));
         $aTemplate = array();
         $sFirstName = bx_process_input($aData['first_name']);
         $sLastName = bx_process_input($aData['last_name']);
         /*--- Site was created and paid ---*/
         if ($aAccount['status'] == BX_SITES_ACCOUNT_STATUS_PENDING && in_array($sActStatus, array(BX_SITES_ACCOUNT_STATUS_TRIAL, BX_SITES_ACCOUNT_STATUS_ACTIVE))) {
             bx_import('BxDolPermalinks');
             $oPermalinks = BxDolPermalinks::getInstance();
             bx_import('BxDolEmailTemplates');
             $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('bx_sites_site_created_and_paid', array('RealName' => $sFirstName . (!empty($sFirstName) && !empty($sLastName) ? ' ' . $sLastName : ''), 'Domain' => $this->_oModule->getDomain($aAccount['domain']), 'Email' => $aAccount['email'], 'Amount' => $fAmount . ' ' . $this->_oModule->_oConfig->getCurrencyCode(), 'Status' => _t('_bx_sites_txt_status_' . $sActStatus), 'NextPaymentDate' => bx_time_js($iPaidUntil), 'DetailsFormUrl' => BX_DOL_URL_ROOT . $oPermalinks->permalink('page.php?i=site-edit&sid=' . $aAccount['pd_profile_sid'])));
         } else {
             bx_import('BxDolEmailTemplates');
             $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('bx_sites_payment_received', array('RealName' => $sFirstName . (!empty($sFirstName) && !empty($sLastName) ? ' ' . $sLastName : ''), 'Amount' => $fAmount . ' ' . $this->_oModule->_oConfig->getCurrencyCode(), 'NextPaymentDate' => bx_time_js($iPaidUntil)));
         }
         if (!empty($aTemplate)) {
             sendMail($aAccount['email'], $aTemplate['Subject'], $aTemplate['Body']);
             $sLog = "---\n";
             $sLog .= "--- Send Email Notification: {date}\n";
             $sLog .= "--- Email: " . $aAccount['email'] . "\n";
             $sLog .= "--- Subject: " . $aTemplate['Subject'] . "\n";
             $sLog .= "--- Body: " . $aTemplate['Body'] . "\n";
             $sLog .= "---\n";
             $this->_logEmail($sLog);
         }
     }
 }
Esempio n. 12
0
 protected function _getDataArray($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
 {
     $this->_aOptions['source'] = array();
     $sCurrency = $this->_oModule->_oConfig->getCurrencyCode();
     $iNextPayment = $this->_aAccount['paid'];
     $aPayment = $this->_oModule->_oDb->getPaymentHistory(array('type' => 'account_id_last', 'value' => $this->_aAccount['id']));
     if (!empty($aPayment) && is_array($aPayment)) {
         $this->_aOptions['source'][] = array('id' => 'last', 'title' => '_bx_sites_grid_overview_txt_payment_last', 'type' => '_bx_sites_txt_payment_type_' . $aPayment['type'], 'transaction' => $aPayment['transaction'], 'when' => bx_time_js($aPayment['when']), 'amount' => number_format($aPayment['amount'], 2) . ' ' . $sCurrency);
     }
     if (!empty($iNextPayment)) {
         $aAmount = 0;
         $fAmountTrial = $this->_oModule->_oConfig->getPaymentPrice(BX_SITES_PP_PERIOD_TRIAL);
         $fAmountRegular = $this->_oModule->_oConfig->getPaymentPrice(BX_SITES_PP_PERIOD_REGULAR);
         switch ($this->_aAccount['status']) {
             case BX_SITES_ACCOUNT_STATUS_PENDING:
                 $aAmount = $fAmountTrial != 0 ? $fAmountTrial : $fAmountRegular;
                 break;
             case BX_SITES_ACCOUNT_STATUS_TRIAL:
                 $aAmount = $fAmountRegular;
                 break;
             case BX_SITES_ACCOUNT_STATUS_ACTIVE:
                 $aAmount = $fAmountRegular;
                 break;
         }
         $this->_aOptions['source'][] = array('id' => 'next', 'title' => '_bx_sites_grid_overview_txt_payment_next', 'type' => '', 'transaction' => '', 'when' => bx_time_js($iNextPayment), 'amount' => number_format($aAmount, 2) . ' ' . $sCurrency);
     }
     return parent::_getDataArray($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
 }
Esempio n. 13
0
 function getMediaDesc($aData)
 {
     return _t('_sys_txt_n_by', bx_time_js($aData['added'], BX_FORMAT_DATE));
 }
Esempio n. 14
0
 /**
  * Checks if a given action is allowed for a given profile and updates action information if the
  * action is performed.
  *
  * @param  int     $iProfileId     ID of a profile that is going to perform an action
  * @param  int     $iActionId      ID of the action itself
  * @param  boolean $bPerformAction if true, then action information is updated, i.e. action is 'performed'
  * @return array(
  *                                CHECK_ACTION_RESULT => CHECK_ACTION_RESULT_ constant,
  *                                CHECK_ACTION_MESSAGE => CHECK_ACTION_MESSAGE_ constant,
  *                                CHECK_ACTION_PARAMETER => additional action parameter (string)
  *                                )
  *
  * NOTES:
  *
  * $aResult[CHECK_ACTION_MESSAGE] contains a message with detailed information about the result,
  * already processed by the language file
  *
  * if $aResult[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED then this node contains
  * an empty string
  *
  * The error messages themselves are stored in the language file. Additional variables are
  * passed to the languages.inc.php function _t_ext() as an array and can be used there in the form of
  * {0}, {1}, {2} ...
  *
  * Additional variables passed to the lang. file on errors (can be used in error messages):
  *
  * 	For all errors:
  *
  * 		$arg0[CHECK_ACTION_LANG_FILE_ACTION]	= name of the action
  * 		$arg0[CHECK_ACTION_LANG_FILE_MEMBERSHIP]= name of the current membership
  *
  * 	CHECK_ACTION_RESULT_LIMIT_REACHED:
  *
  * 		$arg0[CHECK_ACTION_LANG_FILE_LIMIT]		= limit on number of actions allowed for the profile
  * 		$arg0[CHECK_ACTION_LANG_FILE_PERIOD]	= period that the limit is set for (in hours, 0 if unlimited)
  *
  * 	CHECK_ACTION_RESULT_NOT_ALLOWED_BEFORE:
  *
  * 		$arg0[CHECK_ACTION_LANG_FILE_BEFORE]	= date/time since when the action is allowed
  *
  * 	CHECK_ACTION_RESULT_NOT_ALLOWED_AFTER:
  *
  * 		$arg0[CHECK_ACTION_LANG_FILE_AFTER]		= date/time since when the action is not allowed
  *
  * $aResult[CHECK_ACTION_PARAMETER] contains an additional parameter that can be considered
  * when performing the action (like the number of profiles to show in search result)
  */
 function checkAction($iProfileId, $iActionId, $bPerformAction = false)
 {
     $aResult = array();
     $aLangFileParams = array();
     $iProfileId = (int) $iProfileId;
     $iActionId = (int) $iActionId;
     $bPerformAction = $bPerformAction ? true : false;
     $aMembership = $this->getMemberMembershipInfo($iProfileId);
     // get current profile's membership information
     $aLangFileParams[CHECK_ACTION_LANG_FILE_MEMBERSHIP] = _t($aMembership['name']);
     $aLangFileParams[CHECK_ACTION_LANG_FILE_SITE_EMAIL] = getParam('site_email');
     $aAction = $this->oDb->getAction($aMembership['id'], $iActionId);
     if (!$aAction) {
         bx_trigger_error('Unknown action ID: ' . $iActionId, 2);
     }
     $aResult[CHECK_ACTION_PARAMETER] = $aAction['additional_param_value'];
     $aLangFileParams[CHECK_ACTION_LANG_FILE_ACTION] = !empty($aAction['title']) ? _t($aAction['title']) : $aAction['name'];
     /**
      * Action is not allowed for the current membership
      */
     if (is_null($aAction['id'])) {
         $sLangKey = CHECK_ACTION_MESSAGE_NOT_ALLOWED;
         if (isset($this->_aLevel2MessageMap[$aMembership['id']])) {
             $sLangKey = $this->_aLevel2MessageMap[$aMembership['id']];
         }
         $aResult[CHECK_ACTION_RESULT] = CHECK_ACTION_RESULT_NOT_ALLOWED;
         $aResult[CHECK_ACTION_MESSAGE] = _t_ext($sLangKey, $aLangFileParams);
         return $aResult;
     }
     /**
      * Check fixed period limitations if present (also for non-members)
      */
     if ($aAction['allowed_period_start'] && time() < $aAction['allowed_period_start']) {
         $aLangFileParams[CHECK_ACTION_LANG_FILE_BEFORE] = bx_time_js($aAction['allowed_period_start'], BX_FORMAT_DATE_TIME);
         $aResult[CHECK_ACTION_RESULT] = CHECK_ACTION_RESULT_NOT_ALLOWED_BEFORE;
         $aResult[CHECK_ACTION_MESSAGE] = _t_ext(CHECK_ACTION_MESSAGE_NOT_ALLOWED_BEFORE, $aLangFileParams);
         return $aResult;
     }
     if ($aAction['allowed_period_end'] && time() > $aAction['allowed_period_end']) {
         $aLangFileParams[CHECK_ACTION_LANG_FILE_AFTER] = bx_time_js($aAction['allowed_period_end'], BX_FORMAT_DATE_TIME);
         $aResult[CHECK_ACTION_RESULT] = CHECK_ACTION_RESULT_NOT_ALLOWED_AFTER;
         $aResult[CHECK_ACTION_MESSAGE] = _t_ext(CHECK_ACTION_MESSAGE_NOT_ALLOWED_AFTER, $aLangFileParams);
         return $aResult;
     }
     /**
      * if non-member, allow action without performing further checks
      */
     if ($aMembership['id'] == MEMBERSHIP_ID_NON_MEMBER) {
         $aResult[CHECK_ACTION_RESULT] = CHECK_ACTION_RESULT_ALLOWED;
         return $aResult;
     }
     /**
      * Check other limitations (for members only)
      */
     $iAllowedCnt = (int) $aAction['allowed_count'];
     ///< Number of allowed actions. Unlimited if not specified or 0
     $iPeriodLen = (int) $aAction['allowed_period_len'];
     ///< Period for AllowedCount in hours. If not specified, AllowedCount is treated as total number of actions permitted.
     if ($iAllowedCnt > 0) {
         $aActionTrack = $this->oDb->getActionTrack($iActionId, $iProfileId);
         $iActionsLeft = $bPerformAction ? $iAllowedCnt - 1 : $iAllowedCnt;
         $iValidSince = time();
         /**
          * Member is requesting/performing this action for the first time,
          * and there is no corresponding record in sys_acl_actions_track table.
          */
         if (!$aActionTrack) {
             $this->oDb->insertActionTarck($iActionId, $iProfileId, $iActionsLeft, $iValidSince);
             $aResult[CHECK_ACTION_RESULT] = CHECK_ACTION_RESULT_ALLOWED;
             return $aResult;
         }
         /**
          * Action has been requested/performed at least once at this point and there is a corresponding record in sys_acl_actions_track table
          *
          * Action record in sys_acl_actions_track table is out of date.
          */
         $iPeriodEnd = (int) $aActionTrack['valid_since'] + $iPeriodLen * 3600;
         //ValidSince is in seconds, PeriodLen is in hours
         if ($iPeriodLen > 0 && $iPeriodEnd < time()) {
             $this->oDb->updateActionTrack($iActionId, $iProfileId, $iActionsLeft, $iValidSince);
             $aResult[CHECK_ACTION_RESULT] = CHECK_ACTION_RESULT_ALLOWED;
             return $aResult;
         }
         $iActionsLeft = (int) $aActionTrack['actions_left'];
         ///< Action record is up to date
         /**
          * Action limit reached for now
          */
         if ($iActionsLeft <= 0) {
             $aLangFileParams[CHECK_ACTION_LANG_FILE_LIMIT] = $iAllowedCnt;
             $aLangFileParams[CHECK_ACTION_LANG_FILE_PERIOD] = $iPeriodLen;
             $aResult[CHECK_ACTION_RESULT] = CHECK_ACTION_RESULT_LIMIT_REACHED;
             $aResult[CHECK_ACTION_MESSAGE] = '<div style="width: 80%">' . _t_ext(CHECK_ACTION_MESSAGE_LIMIT_REACHED, $aLangFileParams) . ($iPeriodLen > 0 ? _t_ext(CHECK_ACTION_MESSAGE_MESSAGE_EVERY_PERIOD, $aLangFileParams) : '') . '.</div>';
             return $aResult;
         }
         if ($bPerformAction) {
             $iActionsLeft--;
             $this->oDb->updateActionTrack($iActionId, $iProfileId, $iActionsLeft);
         }
     }
     $aResult[CHECK_ACTION_RESULT] = CHECK_ACTION_RESULT_ALLOWED;
     return $aResult;
 }
Esempio n. 15
0
 protected function _getActionsBox(&$aCmt, $aDp = array())
 {
     $oTemplate = BxDolTemplate::getInstance();
     //--- Actions Menu
     bx_import('BxDolMenu');
     $oMenuActions = BxDolMenu::getObjectInstance($this->_sMenuObjActions);
     $oMenuActions->setCmtsData($this, $aCmt['cmt_id']);
     $sMenuActions = $oMenuActions->getCode();
     $oVote = $this->getVoteObject($aCmt['cmt_id']);
     if ($oVote !== false) {
         $sMenuActions .= $oVote->getJsScript();
     }
     //--- Manage Menu
     $oMenuManage = BxDolMenu::getObjectInstance($this->_sMenuObjManage);
     $oMenuManage->setCmtsData($this, $aCmt['cmt_id']);
     $sMenuManage = $oMenuManage->getCode();
     $bMenuManage = !empty($sMenuManage);
     if ($bMenuManage) {
         $sMenuManage = $oTemplate->parseHtmlByName('comment_manage.html', array('style_prefix' => $this->_sStylePrefix, 'content' => $sMenuManage));
         bx_import('BxTemplFunctions');
         $sMenuManage = BxTemplFunctions::getInstance()->transBox($this->_sSystem . '-manage-' . $aCmt['cmt_id'], $sMenuManage, true);
     }
     $sAgo = bx_time_js($aCmt['cmt_time']);
     $bObjectTitle = !empty($this->_aSystem['trigger_field_title']);
     return $oTemplate->parseHtmlByName('comment_actions.html', array('id' => $aCmt['cmt_id'], 'js_object' => $this->_sJsObjName, 'style_prefix' => $this->_sStylePrefix, 'bx_if:show_ago_link' => array('condition' => $bObjectTitle, 'content' => array('style_prefix' => $this->_sStylePrefix, 'view_link' => bx_append_url_params($this->_sViewUrl, array('sys' => $this->_sSystem, 'id' => $this->_iId, 'cmt_id' => $aCmt['cmt_id'])), 'ago' => $sAgo)), 'bx_if:show_ago_text' => array('condition' => !$bObjectTitle, 'content' => array('ago' => $sAgo)), 'menu_actions' => $sMenuActions, 'bx_if:show_menu_manage' => array('condition' => $bMenuManage, 'content' => array('js_object' => $this->_sJsObjName, 'style_prefix' => $this->_sStylePrefix, 'id' => $aCmt['cmt_id'], 'popup_text' => $sMenuManage))));
 }
Esempio n. 16
0
 public function serviceGetBlockVersion()
 {
     $sJsObject = $this->getPageJsObject();
     $sContent = BxDolStudioTemplate::getInstance()->parseHtmlByName('dbd_versions.html', array('js_object' => $sJsObject, 'domain' => getParam('site_title'), 'version' => bx_get_ver(), 'installed' => bx_time_js(getParam('sys_install_time'))));
     return array('content' => $sContent);
 }
Esempio n. 17
0
 protected function _getCellCreated($mixedValue, $sKey, $aField, $aRow)
 {
     $mixedValue = bx_time_js((int) $mixedValue);
     return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
 }