Exemplo n.º 1
0
 public function serviceManageTools($sType = 'common')
 {
     $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->getGridObject($sType));
     if (!$oGrid) {
         return '';
     }
     $CNF =& $this->_oConfig->CNF;
     $sMenu = '';
     if (BxDolAcl::getInstance()->isMemberLevelInSet(192)) {
         $oPermalink = BxDolPermalinks::getInstance();
         $aMenuItems = array();
         if (!empty($CNF['OBJECT_GRID_COMMON']) && !empty($CNF['T']['menu_item_manage_my'])) {
             $aMenuItems[] = array('id' => 'manage-common', 'name' => 'manage-common', 'class' => '', 'link' => $oPermalink->permalink($CNF['URL_MANAGE_COMMON']), 'target' => '_self', 'title' => _t($CNF['T']['menu_item_manage_my']), 'active' => 1);
         }
         if (!empty($CNF['OBJECT_GRID_ADMINISTRATION']) && !empty($CNF['T']['menu_item_manage_all'])) {
             $aMenuItems[] = array('id' => 'manage-administration', 'name' => 'manage-administration', 'class' => '', 'link' => $oPermalink->permalink($CNF['URL_MANAGE_ADMINISTRATION']), 'target' => '_self', 'title' => _t($CNF['T']['menu_item_manage_all']), 'active' => 1);
         }
         if (count($aMenuItems) > 1) {
             $oMenu = new BxTemplMenu(array('template' => 'menu_vertical.html', 'menu_items' => $aMenuItems), $this->_oTemplate);
             $oMenu->setSelected($this->_aModule['name'], 'manage-' . $sType);
             $sMenu = $oMenu->getCode();
         }
     }
     if (!empty($CNF['OBJECT_MENU_SUBMENU'])) {
         BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SUBMENU'])->setSelected($this->_aModule['name'], $CNF['URI_MANAGE_COMMON']);
     }
     $this->_oTemplate->addCss(array('manage_tools.css'));
     $this->_oTemplate->addJs(array('manage_tools.js'));
     $this->_oTemplate->addJsTranslation(array('_sys_grid_search'));
     return array('content' => $this->_oTemplate->getJsCode('manage_tools', array('sObjNameGrid' => $this->_oConfig->getGridObject($sType))) . $oGrid->getCode(), 'menu' => $sMenu);
 }
Exemplo n.º 2
0
 /**
  * Clean database by deleting some expired data
  */
 protected function cleanDatabase()
 {
     // clean expired membership levels
     bx_import('BxDolAcl');
     $oAcl = BxDolAcl::getInstance();
     $iDeleteMemLevels = $oAcl ? $oAcl->maintenance() : 0;
     //--- Clean sessions ---//
     bx_import('BxDolSession');
     $oSession = BxDolSession::getInstance();
     $iSessions = $oSession ? $oSession->maintenance() : 0;
     // clean old views
     bx_import('BxDolView');
     $iDeletedViews = BxDolView::maintenance();
     // clean storage engine expired private file tokens
     bx_import('BxDolStorage');
     $iDeletedExpiredTokens = BxDolStorage::pruning();
     // clean outdated transcoded images
     bx_import('BxDolImageTranscoder');
     $iDeletedTranscodedImages = BxDolImageTranscoder::pruning();
     // clean expired keys
     bx_import('BxDolKey');
     $oKey = BxDolKey::getInstance();
     $iDeletedKeys = $oKey ? $oKey->prune() : 0;
     // clean old votes
     bx_import('BxDolVote');
     $iDeletedVotes = BxDolVote::maintenance();
     echo _t('_sys_pruning_db', $iDeleteMemLevels, $iSessions, $iDeletedViews, $iDeletedVotes, $iDeletedKeys, $iDeletedExpiredTokens, $iDeletedTranscodedImages);
 }
 protected function _getCellAuthor($mixedValue, $sKey, $aField, $aRow)
 {
     $oProfile = $this->_getProfileObject($aRow['author']);
     $sProfile = $oProfile->getDisplayName();
     $oAcl = BxDolAcl::getInstance();
     $sAccountEmail = '';
     $sManageAccountUrl = '';
     if ($oProfile && $oProfile instanceof BxDolProfile && $oAcl->isMemberLevelInSet(128)) {
         $sAccountEmail = $oProfile->getAccountObject()->getEmail();
         $sManageAccountUrl = $this->_getManageAccountUrl($sAccountEmail);
     }
     $mixedValue = $this->_oTemplate->parseHtmlByName('author_link.html', array('href' => $oProfile->getUrl(), 'title' => $sProfile, 'content' => $sProfile, 'bx_if:show_account' => array('condition' => !empty($sManageAccountUrl), 'content' => array('href' => $sManageAccountUrl, 'title' => _t($this->_oModule->_oConfig->CNF['T']['grid_txt_account_manager']), 'content' => $sAccountEmail))));
     return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
 }
 /**
  * Check if menu items is visible with extended checking for friends notifications
  * @param $a menu item array
  * @return boolean
  */
 protected function _isVisible($a)
 {
     // default visible settings
     if (!BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels'])) {
         return false;
     }
     // show only friends for currently active profile for friend request notification
     if ('notifications-friend-requests' == $a['name'] || 'profile-stats-friend-requests' == $a['name']) {
         $oProfile = BxDolProfile::getInstance();
         $aInfo = $oProfile->getInfo();
         if ($a['module'] != $aInfo['type']) {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 5
0
 protected function loadData()
 {
     $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
     bx_import('BxDolAcl');
     $oAcl = BxDolAcl::getInstance();
     if (!$oAcl) {
         return;
     }
     $aProfileAclLevel = $oAcl->getMemberMembershipInfo($iProfileId);
     $aAclLevels = $oAcl->getMemberships(false, true);
     $this->setSelected('', $aProfileAclLevel['id']);
     $aItems = array();
     foreach ($aAclLevels as $iId => $sTitle) {
         $aItems[] = array('id' => $iId, 'name' => $iId, 'class' => '', 'title' => $sTitle, 'icon' => '', 'link' => 'javascript:void(0);', 'onclick' => "bx_set_acl_level({$iProfileId}, {$iId}, '#bx-popup-ajax-wrapper-sys_set_acl_level');");
     }
     $this->_aObject['menu_items'] = $aItems;
 }
Exemplo n.º 6
0
 /**
  * Check if menu items is visible with extended checking linked to "allow*" method of particular module
  * Associated "allow*" method with particular menu item is stored in module config in MENU_ITEM_TO_METHOD array.
  * @param $a menu item array
  * @return boolean
  */
 protected function _isVisible($a)
 {
     // default visible settings
     if (!BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels'])) {
         return false;
     }
     $CNF = $this->_oModule->_oConfig->CNF;
     // get custom function name to check menu item visibility
     $sFuncCheckAccess = false;
     if (isset($CNF['MENU_ITEM_TO_METHOD'][$this->_sObject][$a['name']])) {
         $sFuncCheckAccess = $CNF['MENU_ITEM_TO_METHOD'][$this->_sObject][$a['name']];
     }
     // check custom visibility settings defined in module config class
     if ($sFuncCheckAccess && CHECK_ACTION_RESULT_ALLOWED !== call_user_func_array(array($this->_oModule, $sFuncCheckAccess), isset($this->_aContentInfo) ? array(&$this->_aContentInfo) : array())) {
         return false;
     }
     return true;
 }
Exemplo n.º 7
0
 public function getUserQuota($iProfileId)
 {
     $sQuery = $this->prepare("SELECT `current_size`, `current_number`, 0 as `quota_size`, 0 as `quota_number`, 0 as `max_file_size` FROM `sys_storage_user_quotas` WHERE `profile_id` = ?", $iProfileId);
     $a = $this->getRow($sQuery);
     if (!is_array($a) || !$a) {
         $a = array('current_size' => 0, 'current_number' => 0, 'quota_size' => 0, 'quota_number' => 0, 'max_file_size' => 0);
     }
     // get quota_number and quota_size from user's acl/membership
     $aMembershipInfo = BxDolAcl::getInstance()->getMemberMembershipInfo($iProfileId);
     if ($aMembershipInfo) {
         if (isset($aMembershipInfo['quota_size'])) {
             $a['quota_size'] = $aMembershipInfo['quota_size'];
         }
         if (isset($aMembershipInfo['quota_number'])) {
             $a['quota_number'] = $aMembershipInfo['quota_number'];
         }
         if (isset($aMembershipInfo['quota_max_file_size'])) {
             $a['max_file_size'] = $aMembershipInfo['quota_max_file_size'];
         }
     }
     return $a;
 }
Exemplo n.º 8
0
 protected function setMembership($mixedProfileId, $iAclLevelId)
 {
     bx_import('BxDolAcl');
     if (!is_array($mixedProfileId)) {
         $mixedProfileId = array($mixedProfileId);
     }
     $iPerformerId = bx_get_logged_profile_id();
     $aCheck = checkActionModule($iPerformerId, 'set acl level', 'system', false);
     if (!isAdmin() && $aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED) {
         return $aCheck[CHECK_ACTION_MESSAGE];
     }
     $iSet = 0;
     $oAcl = BxDolAcl::getInstance();
     foreach ($mixedProfileId as $iProfileId) {
         if (!$oAcl->setMembership($iProfileId, $iAclLevelId, 0, true)) {
             continue;
         }
         $iSet += 1;
         checkActionModule($iPerformerId, 'set acl level', 'system', true);
         // perform action
     }
     return count($mixedProfileId) != $iSet ? _t('_error occured') : '';
 }
 protected function onDataAddAfter($iContentId)
 {
     $CNF =& $this->_oModule->_oConfig->CNF;
     // add account and content association
     $iProfileId = BxDolProfile::add(BX_PROFILE_ACTION_MANUAL, getLoggedId(), $iContentId, BX_PROFILE_STATUS_PENDING, $this->_oModule->getName());
     $oProfile = BxDolProfile::getInstance($iProfileId);
     // approve profile if auto-approval is enabled and profile status is 'pending'
     $sStatus = $oProfile->getStatus();
     $isAutoApprove = getParam($CNF['PARAM_AUTOAPPROVAL']) ? true : false;
     if ($sStatus == BX_PROFILE_STATUS_PENDING && $isAutoApprove) {
         $oProfile->approve(BX_PROFILE_ACTION_AUTO);
     }
     // set created profile some default membership
     bx_import('BxDolAcl');
     $iAclLevel = isAdmin() ? MEMBERSHIP_ID_ADMINISTRATOR : getParam($CNF['PARAM_DEFAULT_ACL_LEVEL']);
     BxDolAcl::getInstance()->setMembership($iProfileId, $iAclLevel, 0, true);
     // alert
     bx_alert($this->_oModule->getName(), 'added', $iContentId);
     // switch context to the created profile
     bx_import('BxDolAccount');
     $oAccount = BxDolAccount::getInstance();
     $oAccount->updateProfileContext($iProfileId);
     return '';
 }
Exemplo n.º 10
0
 /**
  * Delete profile.
  * @param $ID - optional profile id to delete
  * @param $bForceDelete - force deletetion is case of account profile deletion
  * @return false on error, or true on success
  */
 function delete($ID = false, $bForceDelete = false)
 {
     $ID = (int) $ID;
     if (!$ID) {
         $ID = $this->_iProfileID;
     }
     $aProfileInfo = $this->_oQuery->getInfoById($ID);
     if (!$aProfileInfo) {
         return false;
     }
     // delete system profiles (accounts) is not allowed, instead - delete whole account
     if (!$bForceDelete && 'system' == $aProfileInfo['type']) {
         return false;
     }
     // switch profile context if deleted profile is active profile context
     bx_import('BxDolAccount');
     $oAccount = BxDolAccount::getInstance($aProfileInfo['account_id']);
     $aAccountInfo = $oAccount->getInfo();
     if (!$bForceDelete && $ID == $aAccountInfo['profile_id']) {
         $oProfileAccount = BxDolProfile::getInstanceAccountProfile($aProfileInfo['account_id']);
         $oAccount->updateProfileContext($oProfileAccount->id());
     }
     // create system event before deletion
     $isStopDeletion = false;
     bx_alert('profile', 'before_delete', $ID, 0, array('stop_deletion' => &$isStopDeletion));
     if ($isStopDeletion) {
         return false;
     }
     // delete associated comments
     bx_import('BxDolCmts');
     BxDolCmts::onAuthorDelete($ID);
     // delete connections
     bx_import('BxDolConnection');
     $oConn = BxDolConnection::getObjectInstance('sys_profiles_friends');
     $oConn->onDeleteInitiatorAndContent($ID);
     $oConn = BxDolConnection::getObjectInstance('sys_profiles_subscriptions');
     $oConn->onDeleteInitiatorAndContent($ID);
     // delete profile's acl levels
     bx_import('BxDolAcl');
     BxDolAcl::getInstance()->onProfileDelete($ID);
     // delete profile
     if (!$this->_oQuery->delete($ID)) {
         return false;
     }
     // create system event
     bx_alert('profile', 'delete', $ID);
     // unset class instance to prevent creating the instance again
     $this->_iProfileID = 0;
     $sClass = get_class($this) . '_' . $ID;
     unset($GLOBALS['bxDolClasses'][$sClass]);
     return true;
 }
Exemplo n.º 11
0
 public function __construct()
 {
     parent::__construct();
 }
Exemplo n.º 12
0
 /**
  * Check if menu items is visible.
  * @param $a menu item array
  * @return boolean
  */
 protected function _isVisible($a)
 {
     return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
 }
Exemplo n.º 13
0
<?php

//========================================================================================================================
// - Membership check -
echo "\n- Membership expiration letters -\n";
$iExpireNotificationDays = (int) getParam("expire_notification_days");
$bExpireNotifyOnce = getParam("expire_notify_once") == 'on';
$iExpireLetters = 0;
bx_import('BxDolDb');
$oDb = BxDolDb::getInstance();
bx_import('BxDolAcl');
$oAcl = BxDolAcl::getInstance();
$aRow = $oDb->getFirstRow("SELECT `ID` FROM `Profiles`");
while (!empty($aRow)) {
    $aCurrentMem = getMemberMembershipInfo($aRow['ID']);
    // If expire_notification_days is -1 then notify after expiration
    if ($aCurrentMem['ID'] == MEMBERSHIP_ID_STANDARD && $iExpireNotificationDays == -1) {
        // Calculate last UNIX Timestamp
        $iLastTimestamp = time() - 24 * 3600;
        $aLastMem = getMemberMembershipInfo($aRow['ID'], $iLastTimestamp);
        if ($aCurrentMem['ID'] != $aLastMem['ID']) {
            $bMailResult = $oAcl->getExpirationLetter($aRow['ID'], $aLastMem['Name'], -1);
            if ($bMailResult) {
                $iExpireLetters++;
            }
        }
    } else {
        if ($aCurrentMem['ID'] != MEMBERSHIP_ID_STANDARD) {
            // Calculate further UNIX Timestamp
            $iFurtherTimestamp = time() + $iExpireNotificationDays * 24 * 3600;
            $aFurtherMem = getMemberMembershipInfo($aRow['ID'], $iFurtherTimestamp);
Exemplo n.º 14
0
 /**
  * Check if page is visible.
  */
 protected function _isVisiblePage($a)
 {
     bx_import('BxDolAcl');
     return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
 }
Exemplo n.º 15
0
 public function serviceGetMemberships($bPurchasableOnly = false, $bActiveOnly = false, $isTranslate = true)
 {
     bx_import('BxDolAcl');
     return BxDolAcl::getInstance()->getMemberships($bPurchasableOnly, $bActiveOnly, $isTranslate);
 }
Exemplo n.º 16
0
 /**
  * Check if form field is visible.
  * @param $aInput form field array
  * @return boolean
  */
 public static function isVisible($aInput)
 {
     return BxDolAcl::getInstance()->isMemberLevelInSet($aInput['visible_for_levels']);
 }
Exemplo n.º 17
0
 public static function getVisibilityValues($iValue, &$aValuesAll, &$aValuesSelected)
 {
     bx_import('BxDolAcl');
     $aLevels = BxDolAcl::getInstance()->getMemberships(false, true);
     foreach ($aLevels as $iKey => $sValue) {
         if (((int) $iValue & pow(2, (int) $iKey - 1)) != 0) {
             $aValuesSelected[] = $iKey;
         }
         $aValuesAll[$iKey] = _t($sValue);
     }
 }
Exemplo n.º 18
0
function checkActionModule($iProfileId, $sActionName, $sModuleName, $bPerformAction = false)
{
    $oACL = BxDolAcl::getInstance();
    $iActionId = $oACL->getMembershipActionId($sActionName, $sModuleName);
    return BxDolAcl::getInstance()->checkAction($iProfileId, $iActionId, $bPerformAction);
}
Exemplo n.º 19
0
 protected function _isVisibleGrid($a)
 {
     bx_import('BxDolAcl');
     if (!isset($a['visible_for_levels'])) {
         return true;
     }
     return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
 }