CloudTheWolf

Untitled

Jun 11th, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.50 KB | None | 0 0
  1. <?
  2. /**
  3. *          Network Studios Dashboard
  4. *      Developed By CloudTheWolf (Michael Howard)
  5. **/
  6.  
  7.  
  8. //Call Required Files From Community
  9.  
  10. define('BX_MEMBER_PAGE', 1);
  11.  
  12. require_once( 'inc/header.inc.php');
  13. require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
  14. require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
  15. require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
  16.  
  17. //Import Components
  18. bx_import('BxDolMemberMenu');
  19. bx_import('BxDolPageView');
  20.  
  21. //--------------------------------------- member account class ------------------------------------------//
  22. class BxDolMember extends BxDolPageView
  23. {
  24.     var $iMember;
  25.     var $aMemberInfo;
  26.     var $aConfSite;
  27.     var $aConfDir;
  28.  
  29.     function BxDolMember($iMember, &$aSite, &$aDir)
  30.     {
  31.         $this->iMember = (int)$iMember;
  32.         $this->aMemberInfo = getProfileInfo($this->iMember);
  33.  
  34.         $this->aConfSite = $aSite;
  35.         $this->aConfDir  = $aDir;
  36.  
  37.         parent::BxDolPageView('member');
  38.     }
  39.  
  40.     function getBlockCode_FriendRequests()
  41.     {
  42.         global $oSysTemplate;
  43.  
  44.         bx_import('BxTemplCommunicator');
  45.         $oCommunicator = new BxTemplCommunicator(array('member_id' => $this->iMember));
  46.  
  47.         $oSysTemplate->addCss($oCommunicator->getCss());
  48.         $oSysTemplate->addJs($oCommunicator->getJs());
  49.         return $oCommunicator->getBlockCode_FriendRequests(false);
  50.     }
  51.  
  52.     function getBlockCode_NewMessages()
  53.     {
  54.         global $oSysTemplate;
  55.  
  56.         bx_import('BxTemplMailBox');
  57.         $aSettings = array(
  58.             'member_id' => $this->iMember,
  59.             'recipient_id' => $this->iMember,
  60.             'mailbox_mode' => 'inbox_new'
  61.         );
  62.         $oMailBox = new BxTemplMailBox('mail_page', $aSettings);
  63.  
  64.         $oSysTemplate->addCss($oMailBox->getCss());
  65.         $oSysTemplate->addJs($oMailBox->getJs());
  66.         return $oMailBox->getBlockCode_NewMessages(false);
  67.     }
  68.  
  69.     function getBlockCode_AccountControl()
  70.     {
  71.         global $oTemplConfig, $aPreValues;
  72.  
  73.         //Labels
  74.         $sProfileStatusC = _t('_Profile status');
  75.         $sPresenceC = _t('_Presence');
  76.         $sMembershipC = _t('_Membership2');
  77.         $sLastLoginC = _t('_Last login');
  78.         $sRegistrationC = _t('_Registration');
  79.         $sEmailC = _t('_Email');
  80.         $sMembersC = ' ' . _t('_Members');
  81.         $sProfileC = _t('_Profile');
  82.         $sContentC = _t('_Content');
  83.  
  84.         //--- General Info block ---//
  85.         $sProfileStatus = _t( "__{$this->aMemberInfo['Status']}" );
  86.         $sProfileStatusMess = '';
  87.         switch ( $this->aMemberInfo['Status'] ) {
  88.             case 'Unconfirmed':
  89.                 $sProfileStatusMess = _t( "_ATT_UNCONFIRMED", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight );
  90.                 break;
  91.             case 'Approval':
  92.                 $sProfileStatusMess = _t( "_ATT_APPROVAL", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight );
  93.                 break;
  94.             case 'Active':
  95.                 $sProfileStatusMess = _t( "_ATT_ACTIVE", $this->aMemberInfo['ID'], $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight );
  96.                 break;
  97.             case 'Rejected':
  98.                 $sProfileStatusMess = _t( "_ATT_REJECTED", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight );
  99.                 break;
  100.             case 'Suspended':
  101.                 $sProfileStatusMess = _t( "_ATT_SUSPENDED", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight );
  102.                 break;
  103.         }
  104.  
  105.         $oForm = bx_instance('BxDolFormCheckerHelper');
  106.         $sMembStatus = GetMembershipStatus($this->aMemberInfo['ID']);
  107.  
  108.         $sLastLogin = 'never';
  109.         if (!empty($this->aMemberInfo['DateLastLogin']) && $this->aMemberInfo['DateLastLogin'] != "0000-00-00 00:00:00") {
  110.             $sLastLoginTS = $oForm->_passDateTime($this->aMemberInfo['DateLastLogin']);
  111.             $sLastLogin = getLocaleDate($sLastLoginTS, BX_DOL_LOCALE_DATE);
  112.         }
  113.  
  114.         $sRegistration = 'never';
  115.         if(!empty($this->aMemberInfo['DateReg']) && $this->aMemberInfo['DateReg'] != "0000-00-00 00:00:00" ) {
  116.             $sRegistrationTS = $oForm->_passDateTime($this->aMemberInfo['DateReg']);
  117.             $sRegistration = getLocaleDate($sRegistrationTS, BX_DOL_LOCALE_DATE);
  118.         }
  119.  
  120.         //--- Presence block ---//
  121.         require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolUserStatusView.php' );
  122.         $oStatusView = new BxDolUserStatusView();
  123.         $sUserStatus = $oStatusView->getMemberMenuStatuses();
  124.  
  125.         //--- Content block ---//
  126.         $aAccountCustomStatElements = $GLOBALS['MySQL']->fromCache('sys_account_custom_stat_elements', 'getAllWithKey', 'SELECT * FROM `sys_account_custom_stat_elements`', 'ID');
  127.         $aPQStatisticsElements = $GLOBALS['MySQL']->fromCache('sys_stat_member', 'getAllWithKey', 'SELECT * FROM `sys_stat_member`', 'Type');
  128.  
  129.         $aCustomElements = array();
  130.         foreach($aAccountCustomStatElements as $iID => $aMemberStats) {
  131.             $sUnparsedLabel = $aMemberStats['Label'];
  132.             $sUnparsedValue = $aMemberStats['Value'];
  133.  
  134.             $sLabel = _t($sUnparsedLabel);
  135.             $sUnparsedValue = str_replace('__site_url__', BX_DOL_URL_ROOT, $sUnparsedValue);
  136.  
  137.             //step 1 - replacements of keys
  138.             $sLblTmpl = '__l_';
  139.             $sTmpl = '__';
  140.             while(($iStartPos = strpos($sUnparsedValue, $sLblTmpl)) !== false) {
  141.                 $iEndPos = strpos($sUnparsedValue, $sTmpl, $iStartPos + 1);
  142.                 if($iEndPos <= $iStartPos)
  143.                     break;
  144.  
  145.                 $sSubstr = substr($sUnparsedValue, $iStartPos + strlen($sLblTmpl), $iEndPos-$iStartPos - strlen($sLblTmpl));
  146.                 $sKeyValue = mb_strtolower(_t('_' . $sSubstr));
  147.                 $sUnparsedValue = str_replace($sLblTmpl.$sSubstr.$sTmpl, $sKeyValue, $sUnparsedValue);
  148.             }
  149.  
  150.             //step 2 - replacements of Stat keys
  151.             while(($iStartPos = strpos($sUnparsedValue, $sTmpl, 0)) !== false) {
  152.                 $iEndPos = strpos($sUnparsedValue, $sTmpl, $iStartPos + 1);
  153.                 if($iEndPos <= $iStartPos)
  154.                     break;
  155.  
  156.                 $iCustomCnt = 0;
  157.                 $sSubstr = process_db_input( substr($sUnparsedValue, $iStartPos + strlen($sTmpl), $iEndPos-$iStartPos - strlen($sTmpl)), BX_TAGS_STRIP);
  158.                 if ($sSubstr) {
  159.                     $sCustomSQL = $aPQStatisticsElements[$sSubstr]['SQL'];
  160.                     $sCustomSQL = str_replace('__member_id__', $this->aMemberInfo['ID'], $sCustomSQL);
  161.                     $sCustomSQL = str_replace('__profile_media_define_photo__', _t('_ProfilePhotos'), $sCustomSQL);
  162.                     $sCustomSQL = str_replace('__profile_media_define_music__', _t('_ProfileMusic'), $sCustomSQL);
  163.                     $sCustomSQL = str_replace('__profile_media_define_video__', _t('_ProfileVideos'), $sCustomSQL);
  164.                     $sCustomSQL = str_replace('__member_nick__', process_db_input($this->aMemberInfo['NickName'], BX_TAGS_NO_ACTION, BX_SLASHES_NO_ACTION), $sCustomSQL);
  165.                     $iCustomCnt = ($sCustomSQL!='') ? (int)db_value($sCustomSQL) : '';
  166.                 }
  167.                 $sUnparsedValue = str_replace($sTmpl . $sSubstr . $sTmpl, $iCustomCnt, $sUnparsedValue);
  168.             }
  169.  
  170.             $sTrimmedLabel = trim($sUnparsedLabel, '_');
  171.             $aCustomElements[$sTrimmedLabel] = array(
  172.                 'type' => 'custom',
  173.                 'name' => $sTrimmedLabel,
  174.                 'content' => '<b>' . $sLabel . ':</b> ' . $sUnparsedValue,
  175.                 'colspan' => true
  176.             );
  177.         }
  178.         $aForm = array(
  179.             'form_attrs' => array(
  180.                 'action' => '',
  181.                 'method' => 'post',
  182.             ),
  183.             'params' => array(
  184.                 'remove_form' => true,
  185.             ),
  186.             'inputs' => array(
  187.                 'header1' => array(
  188.                     'type' => 'block_header',
  189.                     'caption' => $sProfileC,
  190.                     'collapsable' => true
  191.                 ),
  192.                 'Info' => array(
  193.                     'type' => 'custom',
  194.                     'name' => 'Info',
  195.                     'content' => get_member_thumbnail($this->aMemberInfo['ID'], 'none', true),
  196.                     'colspan' => true
  197.                 ),
  198.                 'Status' => array(
  199.                     'type' => 'custom',
  200.                     'name' => 'Status',
  201.                     'content' => '<b>' . $sProfileStatusC . ':</b> ' . $sProfileStatus . '<br />' . $sProfileStatusMess,
  202.                     'colspan' => true
  203.                 ),
  204.                 'Email' => array(
  205.                     'type' => 'custom',
  206.                     'name' => 'Email',
  207.                     'content' => '<b>' . $sEmailC . ':</b> ' . $this->aMemberInfo['Email'] . '<br />' . _t('_sys_txt_ac_manage_subscriptions'),
  208.                     'colspan' => true
  209.                 ),
  210.                 'Membership' => array(
  211.                     'type' => 'custom',
  212.                     'name' => 'Membership',
  213.                     'content' => '<b>' . $sMembershipC . ':</b> ' . $sMembStatus,
  214.                     'colspan' => true
  215.                 ),
  216.                 'LastLogin' => array(
  217.                     'type' => 'custom',
  218.                     'name' => 'LastLogin',
  219.                     'content' => '<b>' . $sLastLoginC . ':</b> ' . $sLastLogin,
  220.                     'colspan' => true
  221.                 ),
  222.                 'Registration' => array(
  223.                     'type' => 'custom',
  224.                     'name' => 'Registration',
  225.                     'content' => '<b>' . $sRegistrationC . ':</b> ' . $sRegistration,
  226.                     'colspan' => true
  227.                 ),
  228.                 'header1_end' => array(
  229.                     'type' => 'block_end'
  230.                 ),
  231.                 'header2' => array(
  232.                     'type' => 'block_header',
  233.                     'caption' => $sPresenceC,
  234.                     'collapsable' => true,
  235.                     'collapsed' => true,
  236.                     'attrs' => array (
  237.                         'id' => 'user_status_ac',
  238.                     ),
  239.                 ),
  240.                 'UserStatus' => array(
  241.                     'type' => 'custom',
  242.                     'name' => 'Info',
  243.                     'content' => $sUserStatus,
  244.                     'colspan' => true
  245.                 ),
  246.                 'header2_end' => array(
  247.                     'type' => 'block_end'
  248.                 )
  249.              ),
  250.         );
  251.  
  252.         //custom
  253.         if(!empty($aCustomElements)) {
  254.             $aForm['inputs'] = array_merge(
  255.                 $aForm['inputs'],
  256.                 array('header5' => array(
  257.                     'type' => 'block_header',
  258.                     'caption' => $sContentC,
  259.                     'collapsable' => true,
  260.                     'collapsed' => true
  261.                 )),
  262.                 $aCustomElements,
  263.                 array('header5_end' => array(
  264.                     'type' => 'block_end'
  265.                 ))
  266.             );
  267.         }
  268.  
  269.         $oForm = new BxTemplFormView($aForm);
  270.         $sContent = $GLOBALS['oSysTemplate']->parseHtmlByName('member_account_control.html', array(
  271.             'content' => $oForm->getCode()
  272.         ));
  273.  
  274.         return array($sContent, array(), array(), false);
  275.     }
  276.  
  277.     function getBlockCode_Friends()
  278.     {
  279.         $iLimit = 10;
  280.         $sContent = $sPaginate = '';
  281.  
  282.         $sAllFriends = 'viewFriends.php?iUser=' . $this->iMember;
  283.  
  284.         // count all friends ;
  285.         $iCount = getFriendNumber($this->iMember);
  286.         if($iCount == 0)
  287.             return;
  288.  
  289.         $iPages = ceil($iCount/$iLimit);
  290.         $iPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
  291.  
  292.         if($iPage < 1)
  293.             $iPage = 1;
  294.  
  295.         if($iPage > $iPages)
  296.             $iPage = $iPages;
  297.  
  298.         $sSqlFrom = ($iPage - 1) * $iLimit;
  299.         $sSqlLimit = "LIMIT {$sSqlFrom}, {$iLimit}";
  300.         $aFriends = getMyFriendsEx($this->iMember, '', 'image', $sSqlLimit);
  301.  
  302.         $aTmplParams['bx_repeat:friends'] = array();
  303.         foreach ($aFriends as $iId => $aFriend)
  304.             $aTmplParams['bx_repeat:friends'][] = array(
  305.                 'content' => get_member_thumbnail( $iId, 'none', true, 'visitor', array('is_online' => $aFriend[5]))
  306.             );
  307.         $sContent = $GLOBALS['oSysTemplate']->parseHtmlByName('member_friends.html', $aTmplParams);
  308.  
  309.         $oPaginate = new BxDolPaginate(array(
  310.             'page_url' => BX_DOL_URL_ROOT . 'member.php',
  311.             'count' => $iCount,
  312.             'per_page' => $iLimit,
  313.             'page' => $iPage,
  314.             'per_page_changer' => true,
  315.             'page_reloader' => true,
  316.             'on_change_page' => 'return !loadDynamicBlock({id}, \'member.php?page={page}&per_page={per_page}\');',
  317.             'on_change_per_page' => ''
  318.         ));
  319.         $sPaginate = $oPaginate->getSimplePaginate($sAllFriends);
  320.  
  321.         return array($sContent, array(), $sPaginate);
  322.     }
  323.  
  324.     function getBlockCode_QuickLinks()
  325.     {
  326.         bx_import('BxTemplMenuQlinks2');
  327.         $oMenu = new BxTemplMenuQlinks2();
  328.         $sCodeBlock = $oMenu->getCode();
  329.         return $sCodeBlock;
  330.     }
  331. }
  332. //-------------------------------------------------------------------------------------------------------//
  333.  
  334.  
  335.  
  336.  
  337. // --------------- page components functions
  338.  
  339. // this is dynamic page -  send headers to do not cache this page
  340. send_headers_page_changed();
  341. $oMember = new BxDolMember($member['ID'], $site, $dir);
  342.  
  343. ?>
Advertisement
Add Comment
Please, Sign In to add comment