Example #1
0
 /**
  * Constructor
  * @param string $sType     - system type
  * @param string $sAction   - system action
  * @param int    $iObjectId - object id
  * @param int    $iSenderId - sender (action's author) profile id, if it is false - then currectly logged in profile id is used
  */
 public function __construct($sUnit, $sAction, $iObjectId, $iSender = false, $aExtras = array())
 {
     parent::__construct();
     if (getParam('sys_db_cache_enable')) {
         $oDb = BxDolDb::getInstance();
         $oCache = $oDb->getDbCacheObject();
         $sCacheKey = $oDb->genDbCacheKey('sys_alerts');
         $aData = $oCache->getData($sCacheKey);
         if (null === $aData) {
             $aData = $this->getAlertsData();
             $oCache->setData($sCacheKey, $aData);
         }
     } else {
         $aData = $this->getAlertsData();
     }
     $this->_aAlerts = $aData['alerts'];
     $this->_aHandlers = $aData['handlers'];
     $this->sUnit = $sUnit;
     $this->sAction = $sAction;
     $this->iObject = (int) $iObjectId;
     $this->aExtras = $aExtras;
     if (false === $iSender) {
         $oProfile = BxDolProfile::getInstance();
         $this->iSender = $oProfile ? $oProfile->id() : 0;
     } else {
         $this->iSender = (int) $iSender;
     }
 }
 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'])));
             }
         }
     }
 }
Example #3
0
 function entryMediaView($iMediaId, $mixedContext = false)
 {
     $oModule = BxDolModule::getInstance($this->MODULE);
     $CNF =& $oModule->_oConfig->CNF;
     if (!($aMediaInfo = $oModule->_oDb->getMediaInfoById($iMediaId))) {
         return '';
     }
     if (!($aAlbumInfo = $oModule->_oDb->getContentInfoById($aMediaInfo['content_id']))) {
         return '';
     }
     $sUrlAlbum = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aAlbumInfo[$CNF['FIELD_ID']]);
     $sText = $this->getMediaTitle($aMediaInfo);
     $iProfileId = $aAlbumInfo[$CNF['FIELD_AUTHOR']];
     $oProfile = BxDolProfile::getInstance($iProfileId);
     if (!$oProfile) {
         $oProfile = BxDolProfileUndefined::getInstance();
     }
     $aVars = array('title' => $sText, 'album' => _t('_bx_albums_txt_media_album_link', $sUrlAlbum, bx_process_output($aAlbumInfo[$CNF['FIELD_TITLE']]), $oProfile->getUrl(), $oProfile->getDisplayName()));
     $aNextPrev = array('next' => $this->getNextPrevMedia($aMediaInfo, true, $mixedContext), 'prev' => $this->getNextPrevMedia($aMediaInfo, false, $mixedContext));
     foreach ($aNextPrev as $k => $a) {
         $aVars['bx_if:' . $k] = array('condition' => $a, 'content' => $a);
         $aVars['bx_if:' . $k . '-na'] = array('condition' => !$a, 'content' => array());
     }
     $aVars = array_merge($aVars, $this->mediaVars($aMediaInfo, $CNF['OBJECT_IMAGES_TRANSCODER_BIG'], $CNF['OBJECT_VIDEOS_TRANSCODERS']['poster'], array('context' => $mixedContext)));
     return $this->parseHtmlByName('media-view.html', $aVars);
 }
 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
 }
Example #5
0
 public function getProfilesByAccount($aContentInfo, $iMaxVisible = 2)
 {
     $oProfilesQuery = BxDolProfileQuery::getInstance();
     $aProfiles = $oProfilesQuery->getProfilesByAccount($aContentInfo['id']);
     $iProfiles = count($aProfiles);
     $aTmplVars = array('class_cnt' => '', 'bx_repeat:profiles' => array(), 'bx_if:profiles_more' => array('condition' => $iProfiles > $iMaxVisible, 'content' => array('html_id' => $this->_oConfig->getHtmlIds('profile_more_popup') . $aContentInfo['id'], 'more' => _t('_bx_accnt_txt_more', $iProfiles - $iMaxVisible), 'more_attr' => bx_html_attribute(_t('_bx_accnt_txt_see_more')), 'popup' => '')));
     $aTmplVarsPopup = array('class_cnt' => ' bx-def-padding', 'bx_repeat:profiles' => array(), 'bx_if:profiles_more' => array('condition' => false, 'content' => array()));
     $i = 0;
     foreach ($aProfiles as $iProfileId => $aProfile) {
         $oProfile = BxDolProfile::getInstance($iProfileId);
         if (!$oProfile) {
             continue;
         }
         $sName = $oProfile->getDisplayName();
         $aTmplVarsProfile = array('html_id' => $this->_oConfig->getHtmlIds('profile') . $aProfile['id'], 'id' => $oProfile->id(), 'url' => $oProfile->getUrl(), 'name' => $sName, 'name_attr' => bx_html_attribute($sName));
         if ($i < $iMaxVisible) {
             $aTmplVars['bx_repeat:profiles'][] = $aTmplVarsProfile;
         }
         if ($i >= $iMaxVisible) {
             $aTmplVarsPopup['bx_repeat:profiles'][] = $aTmplVarsProfile;
         }
         ++$i;
     }
     if ($aTmplVarsPopup['bx_repeat:profiles']) {
         $aTmplVars['bx_if:profiles_more']['content']['popup'] = BxTemplFunctions::getInstance()->transBox('', $this->parseHtmlByName('profiles.html', $aTmplVarsPopup));
     }
     return $this->parseHtmlByName('profiles.html', $aTmplVars);
 }
 public function getUserInfo($iUserId = 0)
 {
     $oProfile = BxDolProfile::getInstance($iUserId);
     if (!$oProfile) {
         $oProfile = BxDolProfileUndefined::getInstance();
     }
     return array($oProfile->getDisplayName(), $oProfile->getUrl(), $oProfile->getThumb(), $oProfile->getUnit());
 }
 protected function _getCellProfileId($mixedValue, $sKey, $aField, $aRow)
 {
     $s = '<span class="bx-def-font-grayed">' . _t('_undefined') . '</span>';
     if ($mixedValue && ($oProfile = BxDolProfile::getInstance((int) $mixedValue))) {
         $s = '<a href="' . $oProfile->getUrl() . '">' . $oProfile->getDisplayName() . '</span>';
     }
     return parent::_getCellDefault($s, $sKey, $aField, $aRow);
 }
 public function serviceGetNotificationsPost($aEvent)
 {
     $iProfile = (int) $aEvent['object_id'];
     $oProfile = BxDolProfile::getInstance($iProfile);
     if (!$oProfile) {
         return array();
     }
     return array('entry_sample' => _t('_sys_profile_sample_single'), 'entry_url' => $oProfile->getUrl(), 'entry_caption' => $oProfile->getDisplayName(), 'entry_author' => $oProfile->id(), 'lang_key' => '_sys_profile_subscription_added');
 }
 protected function _getProfileObject($iId)
 {
     bx_import('BxDolProfile');
     $oProfile = BxDolProfile::getInstance($iId);
     if (!$oProfile) {
         bx_import('BxDolProfileUndefined');
         $oProfile = BxDolProfileUndefined::getInstance();
     }
     return $oProfile;
 }
 protected function _getTemplateVars()
 {
     $aVars = parent::_getTemplateVars();
     $aVars['bx_repeat:menu_items'] = array(true);
     $aVars['profile_display_name'] = BxDolProfile::getInstance()->getDisplayName();
     $aVars['url_switch_profile'] = BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher');
     $aVars['menu_account'] = BxDolMenu::getObjectInstance('sys_account')->getCode();
     $aVars['menu_notifications'] = BxDolMenu::getObjectInstance('sys_account_notifications')->getCode();
     return $aVars;
 }
 public function __construct($aObject, $oTemplate = false)
 {
     parent::__construct($aObject, $oTemplate);
     $CNF =& $this->_oModule->_oConfig->CNF;
     $aInformers = array();
     // get profile info
     $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']);
     }
     if (!$this->_aContentInfo || !$this->_oProfile) {
         return;
     }
     // select view profile submenu
     $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
     $oMenuSubmenu->setObjectSubmenu($CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'], array('title' => $this->_oProfile->getDisplayName(), 'link' => $this->_oProfile->getUrl(), 'icon' => $CNF['ICON']));
     // add replaceable markers
     $this->addMarkers($this->_aProfileInfo);
     // every content field can be used as marker
     $this->addMarkers(array('profile_id' => $this->_oProfile->id()));
     // profile id field
     $this->addMarkers(array('display_name' => $this->_oProfile->getDisplayName()));
     // profile display name
     $this->addMarkers(array('profile_link' => $this->_oProfile->getUrl()));
     // profile link
     // display message if profile isn't active
     if (bx_get_logged_profile_id() == $this->_oProfile->id() && !empty($CNF['INFORMERS']['status'])) {
         $sStatus = $this->_aContentInfo['profile_status'];
         if (isset($CNF['INFORMERS']['status']['map'][$sStatus])) {
             $aInformers[] = array('name' => $CNF['INFORMERS']['status']['name'], 'msg' => _t($CNF['INFORMERS']['status']['map'][$sStatus]), 'type' => BX_INFORMER_ALERT);
         }
     }
     // display message if it is possible to switch to this profile
     $oProfile = $this->_aContentInfo ? BxDolProfile::getInstanceByContentTypeAccount($this->_aContentInfo['id'], $this->MODULE) : false;
     if ($oProfile) {
         $oProfile->checkSwitchToProfile($this->_oTemplate);
     }
     // add informers
     if ($aInformers) {
         $oInformer = BxDolInformer::getInstance($this->_oTemplate);
         if ($oInformer) {
             foreach ($aInformers as $a) {
                 $oInformer->add($a['name'], $this->_replaceMarkers($a['msg']), $a['type']);
             }
         }
     }
 }
Example #12
0
 function __construct($sMode = '', $aParams = array())
 {
     $this->aUnitViews = array('extended' => 'unit.html');
     if (empty($aParams['unit_view'])) {
         $aParams['unit_view'] = 'extended';
     }
     parent::__construct($sMode, $aParams);
     $this->aCurrent = array('name' => 'bx_albums', 'module_name' => 'bx_albums', 'object_metatags' => 'bx_albums', 'title' => _t('_bx_albums_page_title_browse'), 'table' => 'bx_albums_albums', 'ownFields' => array('id', 'title', 'text', 'thumb', 'author', 'added'), 'searchFields' => array('title', 'text'), 'restriction' => array('author' => array('value' => '', 'field' => 'author', 'operator' => '='), 'status' => array('value' => 'active', 'field' => 'status', 'operator' => '=')), 'paginate' => array('perPage' => getParam('bx_albums_per_page_browse'), 'start' => 0), 'sorting' => 'last', 'rss' => array('title' => '', 'link' => '', 'image' => '', 'profile' => 0, 'fields' => array('Guid' => 'link', 'Link' => 'link', 'Title' => 'title', 'DateTimeUTS' => 'added', 'Desc' => 'text')), 'ident' => 'id');
     $this->sFilterName = 'bx_albums_filter';
     $this->oModule = $this->getMain();
     $oProfileAuthor = null;
     $CNF =& $this->oModule->_oConfig->CNF;
     switch ($sMode) {
         case 'author':
             $oProfileAuthor = BxDolProfile::getInstance((int) $aParams['author']);
             if (!$oProfileAuthor) {
                 $this->isError = true;
                 break;
             }
             $this->aCurrent['restriction']['author']['value'] = $oProfileAuthor->id();
             $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id={profile_id}';
             $this->aCurrent['title'] = _t('_bx_albums_page_title_browse_by_author');
             $this->aCurrent['rss']['link'] = 'modules/?r=albums/rss/' . $sMode . '/' . $oProfileAuthor->id();
             break;
         case 'public':
             $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
             $this->aCurrent['title'] = _t('_bx_albums_page_title_browse_recent');
             $this->aCurrent['rss']['link'] = 'modules/?r=albums/rss/' . $sMode;
             break;
         case 'popular':
             $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_POPULAR']);
             $this->aCurrent['title'] = _t('_bx_albums_page_title_browse_popular');
             $this->aCurrent['rss']['link'] = 'modules/?r=albums/rss/' . $sMode;
             $this->aCurrent['sorting'] = 'popular';
             break;
         case 'updated':
             $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_UPDATED']);
             $this->aCurrent['title'] = _t('_bx_albums_page_title_browse_updated');
             $this->aCurrent['rss']['link'] = 'modules/?r=albums/rss/' . $sMode;
             $this->aCurrent['sorting'] = 'updated';
             break;
         case '':
             // search results
             $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
             $this->aCurrent['title'] = _t('_bx_albums');
             $this->aCurrent['paginate']['perPage'] = 3;
             unset($this->aCurrent['rss']);
             break;
         default:
             $sMode = '';
             $this->isError = true;
     }
     $this->processReplaceableMarkers($oProfileAuthor);
     $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
 }
 public function serviceProfileStats($iProfileId = 0)
 {
     if (!$iProfileId) {
         $iProfileId = bx_get_logged_profile_id();
     }
     $oMenu = BxDolMenu::getObjectInstance('sys_profile_stats');
     $oProfile = BxDolProfile::getInstance($iProfileId);
     $aVars = array('profile_id' => $oProfile->id(), 'profile_url' => $oProfile->getUrl(), 'profile_edit_url' => $oProfile->getEditUrl(), 'profile_title' => $oProfile->getDisplayName(), 'profile_title_attr' => bx_html_attribute($oProfile->getDisplayName()), 'profile_ava_url' => $oProfile->getAvatar(), 'menu' => $oMenu->getCode());
     $oTemplate = BxDolTemplate::getInstance();
     return $oTemplate->parseHtmlByName('profile_stats.html', $aVars);
 }
Example #14
0
 public function __construct($iAccoutId = 0)
 {
     parent::__construct();
     $sKey = getParam('bx_antispam_akismet_api_key');
     if ($sKey && ($oAccount = BxDolAccount::getInstance((int) $iAccoutId))) {
         require_once BX_DIRECTORY_PATH_PLUGINS . 'akismet/Akismet.class.php';
         $this->oAkismet = new Akismet(BX_DOL_URL_ROOT, $sKey);
         $oProfile = BxDolProfile::getInstanceByAccount((int) $iAccoutId);
         $this->oAkismet->setCommentAuthorEmail($oAccount->getEmail());
         $this->oAkismet->setCommentAuthor($oProfile->getDisplayName());
         $this->oAkismet->setCommentAuthorURL($oProfile->getUrl());
     }
 }
 function __construct($sMode = '', $aParams = array())
 {
     $this->sCenterContentUnitSelector = '.bx-albums-unit-size';
     $this->aUnitViews = array('gallery' => 'unit_media.html');
     $this->sUnitTemplateLiveSearch = 'unit_media_live_search.html';
     if (empty($aParams['unit_view'])) {
         $aParams['unit_view'] = 'gallery';
     }
     parent::__construct($sMode, $aParams);
     $this->aCurrent = array('name' => 'bx_albums_media', 'module_name' => 'bx_albums', 'object_metatags' => 'bx_albums_media', 'title' => _t('_bx_albums_media'), 'table' => 'bx_albums_files2albums', 'ownFields' => array('id', 'title', 'data', 'content_id', 'file_id', 'order', 'views'), 'searchFields' => array('title'), 'restriction_sql' => '', 'restriction' => array('author' => array('value' => '', 'field' => 'author', 'operator' => '='), 'album' => array('value' => '', 'field' => 'content_id', 'operator' => '=')), 'join' => array('albums' => array('type' => 'INNER', 'table' => 'bx_albums_albums', 'mainField' => 'content_id', 'onField' => 'id', 'joinFields' => array()), 'files' => array('type' => 'INNER', 'table' => 'bx_albums_files', 'table_alias' => 'f', 'mainField' => 'file_id', 'onField' => 'id', 'joinFields' => array('added'))), 'paginate' => array('perPage' => getParam('bx_albums_per_page_browse'), 'start' => 0), 'sorting' => 'last', 'rss' => array('title' => '', 'link' => '', 'image' => '', 'profile' => 0, 'fields' => array('Guid' => 'link', 'Link' => 'link', 'Title' => 'title', 'DateTimeUTS' => 'added', 'Desc' => 'title')), 'ident' => 'id');
     $this->sFilterName = 'bx_albums_filter';
     $this->oModule = $this->getMain();
     $oProfileAuthor = isset($aParams['author']) ? BxDolProfile::getInstance((int) $aParams['author']) : null;
     $CNF =& $this->oModule->_oConfig->CNF;
     switch ($sMode) {
         case 'album':
             $this->aCurrent['restriction']['album']['value'] = (int) $aParams['album_id'];
             $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . (int) $aParams['album_id']);
             $this->aCurrent['title'] = _t('_bx_albums_page_title_browse_media_in_album');
             $this->aCurrent['rss']['link'] = 'modules/?r=albums/rss_media/' . $sMode . '/' . (int) $aParams['album_id'];
             $this->aCurrent['sorting'] = 'order';
             $this->sOrderDirection = 'ASC';
             break;
         case 'recent':
             $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_RECENT_MEDIA']);
             $this->aCurrent['title'] = _t('_bx_albums_page_title_browse_recent_media');
             $this->aCurrent['rss']['link'] = 'modules/?r=albums/rss_media/' . $sMode;
             $this->aCurrent['sorting'] = 'last';
             break;
         case 'popular':
             $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_POPULAR_MEDIA']);
             $this->aCurrent['title'] = _t('_bx_albums_page_title_browse_popular_media');
             $this->aCurrent['rss']['link'] = BxDolPermalinks::getInstance()->permalink('modules/?r=albums/rss_media/' . $sMode);
             $this->aCurrent['sorting'] = 'popular';
             break;
         case '':
             // search results
             $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
             $this->aCurrent['paginate']['perPage'] = 3;
             unset($this->aCurrent['rss']);
             break;
         default:
             $sMode = '';
             $this->isError = true;
     }
     $this->sBrowseUrl = $this->_replaceMarkers($this->sBrowseUrl);
     $this->aCurrent['title'] = $this->_replaceMarkers($this->aCurrent['title']);
     $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
 }
Example #16
0
 public function getFeed($mixedId, $iUserId = 0)
 {
     $sUrl = $this->getUrl($mixedId);
     $aMarkers = array('SiteUrl' => BX_DOL_URL_ROOT);
     if ($iUserId) {
         $oProfile = BxDolProfile::getInstance($iUserId);
         if (!$oProfile) {
             $oProfile = BxDolProfileUndefined::getInstance();
         }
         $aMarkers['NickName'] = $oProfile->getDisplayName();
     }
     $sUrl = bx_replace_markers($sUrl, $aMarkers);
     header('Content-Type: text/xml; charset=utf-8');
     return bx_file_get_contents($sUrl . (defined('BX_PROFILER') && BX_PROFILER && 0 == strncmp(BX_DOL_URL_ROOT, $sUrl, strlen(BX_DOL_URL_ROOT)) ? '&bx_profiler_disable=1' : ''));
 }
 function entryAuthor($aData, $sTemplateName = 'author.html')
 {
     $oModule = BxDolModule::getInstance($this->MODULE);
     $CNF =& $oModule->_oConfig->CNF;
     $oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']]);
     if (!$oProfile) {
         bx_import('BxDolProfileUndefined');
         $oProfile = BxDolProfileUndefined::getInstance();
     }
     if (!$oProfile) {
         return '';
     }
     $aVars = array('author_url' => $oProfile->getUrl(), 'author_thumb_url' => $oProfile->getThumb(), 'author_title' => $oProfile->getDisplayName(), 'author_desc' => $this->getAuthorDesc($aData));
     return $this->parseHtmlByName($sTemplateName, $aVars);
 }
 /**
  * @return array of profile object and content info
  */
 protected function _getProfileAndContentData($iContentId)
 {
     $CNF =& $this->_oModule->_oConfig->CNF;
     $aContentInfo = array();
     $oProfile = false;
     $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
     if (!$aContentInfo) {
         return array(false, false);
     }
     $oProfile = BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_AUTHOR']]);
     if (!$oProfile) {
         $oProfile = BxDolProfileUndefined::getInstance();
     }
     return array($oProfile, $aContentInfo);
 }
 /**
  * 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;
 }
 function __construct($sMode = '', $aParams = false)
 {
     parent::__construct($sMode, $aParams);
     $this->aCurrent = array('name' => 'bx_persons', 'module_name' => 'bx_persons', 'object_metatags' => 'bx_persons', 'title' => _t('_bx_persons_page_title_browse'), 'table' => 'sys_profiles', 'tableSearch' => 'bx_persons_data', 'ownFields' => array(), 'searchFields' => array('fullname', 'description'), 'restriction' => array('account_id' => array('value' => '', 'field' => 'account_id', 'operator' => '='), 'perofileStatus' => array('value' => 'active', 'field' => 'status', 'operator' => '='), 'perofileType' => array('value' => 'bx_persons', 'field' => 'type', 'operator' => '='), 'owner' => array('value' => '', 'field' => 'author', 'operator' => '=', 'table' => 'bx_persons_data')), 'join' => array('profile' => array('type' => 'INNER', 'table' => 'bx_persons_data', 'mainField' => 'content_id', 'onField' => 'id', 'joinFields' => array('id', 'fullname', 'picture', 'added')), 'account' => array('type' => 'INNER', 'table' => 'sys_accounts', 'mainField' => 'account_id', 'onField' => 'id', 'joinFields' => array())), 'paginate' => array('perPage' => 20, 'start' => 0), 'sorting' => 'none', 'rss' => array('title' => '', 'link' => '', 'image' => '', 'profile' => 0, 'fields' => array('Guid' => 'link', 'Link' => 'link', 'Title' => 'fullname', 'DateTimeUTS' => 'added', 'Desc' => 'fullname', 'Picture' => 'picture')), 'ident' => 'id');
     $this->sFilterName = 'bx_persons_filter';
     $this->oModule = $this->getMain();
     switch ($sMode) {
         case 'connections':
             if ($this->_setConnectionsConditions($aParams)) {
                 $oProfile = BxDolProfile::getInstance($aParams['profile']);
                 $oProfile2 = isset($aParams['profile2']) ? BxDolProfile::getInstance($aParams['profile2']) : null;
                 if (isset($aParams['type']) && $aParams['type'] == 'common' && $oProfile && $oProfile2) {
                     $this->aCurrent['title'] = _t('_bx_persons_page_title_browse_connections_mutual', $oProfile->getDisplayName(), $oProfile2->getDisplayName());
                 } elseif ((!isset($aParams['type']) || $aParams['type'] != 'common') && $oProfile) {
                     $this->aCurrent['title'] = _t('_bx_persons_page_title_browse_connections', $oProfile->getDisplayName());
                 }
                 $this->aCurrent['rss']['link'] = 'modules/?r=persons/rss/' . $sMode . '/' . $aParams['object'] . '/' . $aParams['type'] . '/' . (int) $aParams['profile'] . '/' . (int) $aParams['profile2'] . '/' . (int) $aParams['mutual'];
             }
             break;
         case 'recent':
             $this->aCurrent['rss']['link'] = 'modules/?r=persons/rss/' . $sMode;
             $this->aCurrent['title'] = _t('_bx_persons_page_title_browse_recent');
             $this->aCurrent['sorting'] = 'last';
             $this->sBrowseUrl = 'page.php?i=persons-home';
             break;
         case 'active':
             $this->aCurrent['rss']['link'] = 'modules/?r=persons/rss/' . $sMode;
             $this->aCurrent['title'] = _t('_bx_persons_page_title_browse_active');
             $this->aCurrent['sorting'] = 'active';
             $this->sBrowseUrl = 'page.php?i=persons-active';
             break;
         case '':
             // search results
             $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
             $this->aCurrent['title'] = _t('_bx_persons');
             $this->aCurrent['paginate']['perPage'] = 5;
             unset($this->aCurrent['rss']);
             break;
         default:
             $this->isError = true;
     }
     parent::__construct();
 }
 /**
  * get number of received unconfirmed connections (friend requests)
  * @param $sConnectionsObject connections object to get unconfirmed connections from
  * @param $mixedId id to get connections for, if omitted then logged-in profile id is used
  * @return number
  */
 public function serviceGetUnconfirmedConnectionsNum($sConnectionsObject, $mixedId = 0)
 {
     $oConnection = BxDolConnection::getObjectInstance($sConnectionsObject);
     if (!$oConnection) {
         return 0;
     }
     if (!$mixedId) {
         $mixedId = bx_get_logged_profile_id();
     }
     $i = 0;
     $a = $oConnection->getConnectedInitiators($mixedId, 0);
     // get received friend requests
     foreach ($a as $iId) {
         if (BxDolProfile::getInstance($iId)) {
             ++$i;
         }
     }
     return $i;
 }
Example #22
0
 public function __construct($aObject, $oTemplate)
 {
     parent::__construct($aObject, $oTemplate);
     bx_import('BxDolProfile');
     $oProfile = BxDolProfile::getInstance();
     $aProfileInfo = $oProfile ? $oProfile->getInfo() : false;
     $this->addMarkers(array('account_id' => $aProfileInfo ? $aProfileInfo['account_id'] : 0, 'profile_id' => $aProfileInfo ? $aProfileInfo['id'] : 0, 'profile_type' => $aProfileInfo ? $aProfileInfo['type'] : 0, 'profile_content_id' => $aProfileInfo ? $aProfileInfo['content_id'] : 0));
     // set settings submenu
     bx_import('BxDolMenu');
     $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
     if ($oMenuSubmenu) {
         $oMenuSubmenu->setObjectSubmenu('sys_account_settings_submenu', array('title' => _t('_sys_menu_item_title_account_settings'), 'link' => BX_DOL_URL_ROOT . 'member.php', 'icon' => ''));
     }
     // display message if profile isn't active
     if ($oProfile) {
         $sStatus = $oProfile->getStatus();
         if (isset($this->_aMapStatus2LangKey[$sStatus])) {
             bx_import('BxDolInformer');
             $oInformer = BxDolInformer::getInstance($this->_oTemplate);
             if ($oInformer) {
                 $oInformer->add('sys-account-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
             }
         }
     }
     // switch profile context
     if ($iSwitchToProfileId = (int) bx_get('switch_to_profile')) {
         bx_import('BxDolInformer');
         $oInformer = BxDolInformer::getInstance($this->_oTemplate);
         $oProfile = BxDolProfile::getInstance($iSwitchToProfileId);
         $sInformerMsg = '';
         if ($oProfile && $oProfile->getAccountId() == getLoggedId()) {
             bx_import('BxDolProfile');
             $oAccount = BxDolAccount::getInstance();
             if ($oAccount->updateProfileContext($iSwitchToProfileId)) {
                 $sInformerMsg = _t('_sys_txt_account_profile_context_changed_success', $oProfile->getDisplayName());
             }
         }
         if ($oInformer) {
             $oInformer->add('sys-account-profile-context-change-result', $sInformerMsg ? $sInformerMsg : _t('_error occured'), $sInformerMsg ? BX_INFORMER_INFO : BX_INFORMER_ERROR);
         }
     }
 }
Example #23
0
 public function getMenuItems()
 {
     $a = parent::getMenuItems();
     if (!isLogged()) {
         return $a;
     }
     foreach ($a as $k => $r) {
         if ('account' != $r['name']) {
             continue;
         }
         $oProfile = BxDolProfile::getInstance(bx_get_logged_profile_id());
         $sUrlIcon = $oProfile->getThumb();
         if (!$sUrlIcon) {
             break;
         }
         $a[$k]['bx_if:image'] = array('condition' => true, 'content' => array('icon_url' => $sUrlIcon));
         $a[$k]['bx_if:icon']['condition'] = false;
     }
     return $a;
 }
Example #24
0
 /**
  * Check text for spam.
  * First it check if IP is whitelisted(or under cron execution or user is admin) - for whitelisted IPs check for spam isn't performed,
  * then it checks URLs found in text for DNSURI black lists (@see BxAntispamDNSURIBlacklists),
  * then it checks text in Akismet service (@see BxAntispamAkismet).
  * It can send report if spam is found or tries to inform caller to block the content (depending on configuration).
  *
  * @param $sContent content to check for spam
  * @param $sIp IP address of content poster
  * @param $isStripSlashes slashes parameter:
  *          BX_SLASHES_AUTO - automatically detect magic_quotes_gpc setting
  *          BX_SLASHES_NO_ACTION - do not perform any action with slashes
  * @return true if spam detected and content shouln't be recorded, false if content should be processed as usual.
  */
 public function serviceIsSpam($sContent, $sIp = '', $isStripSlashes = BX_SLASHES_AUTO)
 {
     if (defined('BX_DOL_CRON_EXECUTE') || isAdmin()) {
         return false;
     }
     if ($this->serviceIsIpWhitelisted($sIp)) {
         return false;
     }
     if (get_magic_quotes_gpc() && $isStripSlashes == BX_SLASHES_AUTO) {
         $sContent = stripslashes($sContent);
     }
     $bRet = false;
     if ('on' == $this->_oConfig->getAntispamOption('uridnsbl_enable')) {
         $oDNSURIBlacklists = bx_instance('BxAntispamDNSURIBlacklists', array(), $this->_aModule);
         if ($oDNSURIBlacklists->isSpam($sContent)) {
             $oDNSURIBlacklists->onPositiveDetection($sContent);
             $bRet = true;
         }
     }
     if (!$bRet && 'on' == $this->_oConfig->getAntispamOption('akismet_enable')) {
         $oAkismet = bx_instance('BxAntispamAkismet', array(), $this->_aModule);
         if ($oAkismet->isSpam($sContent)) {
             $oAkismet->onPositiveDetection($sContent);
             $bRet = true;
         }
     }
     if ($bRet && 'on' == $this->_oConfig->getAntispamOption('antispam_report')) {
         $oProfile = BxDolProfile::getInstance();
         $aPlus = array('SpammerUrl' => $oProfile->getUrl(), 'SpammerNickName' => $oProfile->getDisplayName(), 'Page' => htmlspecialchars_adv($_SERVER['PHP_SELF']), 'Get' => print_r($_GET, true), 'Post' => print_r($_POST, true), 'SpamContent' => htmlspecialchars_adv($sContent));
         bx_import('BxDolEmailTemplates');
         $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('bx_antispam_spam_report', $aPlus);
         if (!$aTemplate) {
             trigger_error('Email template or translation missing: bx_antispam_spam_report', E_USER_ERROR);
         }
         sendMail(getParam('site_email'), $aTemplate['Subject'], $aTemplate['Body']);
     }
     if ($bRet && 'on' == $this->_oConfig->getAntispamOption('antispam_block')) {
         return true;
     }
     return false;
 }
 public function __construct($aInfo, $oTemplate = false)
 {
     parent::__construct($aInfo, $oTemplate);
     $CNF =& $this->_oModule->_oConfig->CNF;
     if (!empty($CNF['FIELD_PICTURE'])) {
         $this->_aImageFields[$CNF['FIELD_PICTURE']] = array('storage_object' => $CNF['OBJECT_STORAGE'], 'images_transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_THUMB'], 'field_preview' => $CNF['FIELD_PICTURE_PREVIEW']);
     }
     if (!empty($CNF['FIELD_COVER'])) {
         $this->_aImageFields[$CNF['FIELD_COVER']] = array('storage_object' => $CNF['OBJECT_STORAGE_COVER'], 'images_transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_COVER_THUMB'], 'field_preview' => $CNF['FIELD_COVER_PREVIEW']);
     }
     if (!empty($CNF['FIELD_PICTURE_PREVIEW'])) {
         $this->_aImageFields[$CNF['FIELD_PICTURE_PREVIEW']] = $this->_aImageFields[$CNF['FIELD_PICTURE']];
     }
     if (!empty($CNF['FIELD_COVER_PREVIEW'])) {
         $this->_aImageFields[$CNF['FIELD_COVER_PREVIEW']] = $this->_aImageFields[$CNF['FIELD_COVER']];
     }
     $oAccountProfile = BxDolProfile::getInstanceAccountProfile();
     if ($oAccountProfile) {
         $this->_iAccountProfileId = $oAccountProfile->id();
     }
 }
 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
     $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
     $oAccount = BxDolAccount::getInstance();
     $oAccount->updateProfileContext($iProfileId);
     return '';
 }
 function BxDolProfileView($ID)
 {
     global $site;
     global $logged;
     BxDolProfile::BxDolProfile($ID, 0);
     //$this -> ID = $this -> _iProfileID;
     $this->oTemplConfig = new BxTemplConfig($site);
     $this->sColumnsOrder = getParam('profile_view_cols');
     if ($this->_iProfileID) {
         $this->getProfileData();
         if ($this->_aProfile) {
             if ($logged['member']) {
                 if ((int) $_COOKIE['memberID'] == $this->_iProfileID) {
                     $this->owner = true;
                 }
                 $iPFArea = 6;
             } elseif ($logged['admin']) {
                 $iPFArea = 5;
             } elseif ($logged['moderator']) {
                 $iPFArea = 7;
             } else {
                 $iPFArea = 8;
             }
             $this->oPF = new BxDolProfileFields($iPFArea);
             if (!$this->oPF->aBlocks) {
                 return false;
             }
             $this->aPFBlocks = $this->oPF->aBlocks;
             //echoDbg( $this -> aPFBlocks );
             if ($this->bCouple) {
                 $this->aCoupleMutualItems = $this->oPF->getCoupleMutualFields();
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 function BxDolProfileView($ID)
 {
     global $site;
     global $logged;
     BxDolProfile::BxDolProfile($ID, 0);
     //$this -> ID = $this -> _iProfileID;
     $this->oTemplConfig = new BxTemplConfig($site);
     $this->sColumnsOrder = getParam('profile_view_cols');
     if ($this->_iProfileID) {
         $this->getProfileData();
         if ($this->_aProfile) {
             if ($logged['member']) {
                 if ((int) $_COOKIE['memberID'] == $this->_iProfileID) {
                     $this->owner = true;
                 }
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #29
0
 protected function _getAuthorObject($iAuthorId = 0)
 {
     $oProfile = BxDolProfile::getInstance($iAuthorId);
     if (!$oProfile) {
         $oProfile = BxDolProfileUndefined::getInstance();
     }
     return $oProfile;
 }
 protected function _checkAllowedConnect(&$aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult, $isSwap = false)
 {
     if (!$this->_iProfileId) {
         return _t('_sys_txt_access_denied');
     }
     $CNF =& $this->_oConfig->CNF;
     $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->_aModule['name']);
     if (!$oProfile || $oProfile->id() == $this->_iProfileId) {
         return _t('_sys_txt_access_denied');
     }
     $oConn = BxDolConnection::getObjectInstance($sObjConnection);
     if ($isSwap) {
         $isConnected = $oConn->isConnected($oProfile->id(), $this->_iProfileId, $isMutual);
     } else {
         $isConnected = $oConn->isConnected($this->_iProfileId, $oProfile->id(), $isMutual);
     }
     if ($isInvertResult) {
         $isConnected = !$isConnected;
     }
     return $isConnected ? _t('_sys_txt_access_denied') : CHECK_ACTION_RESULT_ALLOWED;
 }