Exemplo n.º 1
0
 /**
  * Gets the Latest relation status of $iUser
  * @param int $iUserId user_id
  * @param int $iBeforeId Used to get the second to newest. relation_data_id
  * @return array 
  */
 public function getLatestForUser($iUserId, $iBeforeId = null, $bStarted = false)
 {
     $sWhere = '';
     if ($iBeforeId != null) {
         $sWhere .= 'crd.relation_data_id < ' . (int) $iBeforeId;
     }
     if ($bStarted == true) {
         $sWhere .= '(crd.user_id = ' . (int) $iUserId . ')';
     } else {
         $sWhere = '(crd.user_id = ' . (int) $iUserId . ') OR crd.with_user_id = ' . (int) $iUserId . '';
     }
     $aRelation = $this->database()->select('*')->from(Phpfox::getT('custom_relation_data'), 'crd')->where($sWhere)->join(Phpfox::getT('custom_relation'), 'cr', 'cr.relation_id = crd.relation_id')->order('crd.relation_data_id DESC')->limit(1)->execute('getSlaveRow');
     /* we dont need the phrase or do we...? */
     if (empty($aRelation)) {
         return array();
     }
     /* get the other user's full_name and image */
     $this->database()->select(Phpfox::getUserField())->from(Phpfox::getT('user'), 'u');
     if ($aRelation['with_user_id'] == $iUserId) {
         $this->database()->where('user_id = ' . $aRelation['user_id']);
     } else {
         $this->database()->where('user_id = ' . $aRelation['with_user_id']);
     }
     $aWith = $this->database()->execute('getSlaveRow');
     $aRelation['with_user'] = array_merge($aRelation, $aWith);
     return $aRelation;
 }
Exemplo n.º 2
0
 public function get($iUserId = null)
 {
     if ($iUserId === null) {
         $iUserId = Phpfox::getUserId();
     }
     return $this->database()->select('ub.block_user_id, ' . Phpfox::getUserField())->from($this->_sTable, 'ub')->join(Phpfox::getT('user'), 'u', 'u.user_id = ub.block_user_id')->where('ub.user_id = ' . (int) $iUserId)->execute('getSlaveRows');
 }
Exemplo n.º 3
0
 public function get($sCategory = null)
 {
     $sSelect = 'p.photo_id, p.server_id, p.destination, p.time_stamp, ' . Phpfox::getUserField();
     $aConds = array();
     $aConds[] = 'AND p.privacy = 0 AND p.allow_rate = 1';
     if ($sCategory !== null) {
         $sCategoryIds = Phpfox::getService('photo.category')->getAllCategories($sCategory);
         if (!empty($sCategoryIds)) {
             $aConds[] = ' AND pcd.category_id IN (' . $sCategoryIds . ')';
             $this->database()->innerJoin(Phpfox::getT('photo_category_data'), 'pcd', 'pcd.photo_id = p.photo_id');
         }
     }
     $aRows = $this->database()->select($sSelect)->from($this->_sTable, 'p')->join(Phpfox::getT('user'), 'u', 'u.user_id = p.user_id')->where($aConds)->order('RAND()')->limit(2)->execute('getSlaveRows');
     if (!count($aRows)) {
         return false;
     }
     if (count($aRows) < 2) {
         return false;
     }
     $sMode = Phpfox::getLib('request')->get('mode') == 'full' ? 'full' : '';
     $aPhotos = array();
     foreach ($aRows as $iKey => $aRow) {
         if ($iKey === 0) {
             $aRow['link'] = Phpfox::getLib('url')->makeUrl('photo.battle', array('w' => $aRow['photo_id'], 'l' => $aRows[1]['photo_id'], 'mode' => $sMode));
         } else {
             $aRow['link'] = Phpfox::getLib('url')->makeUrl('photo.battle', array('w' => $aRow['photo_id'], 'l' => $aRows[0]['photo_id'], 'mode' => $sMode));
         }
         $aPhotos[$iKey === 0 ? 'one' : 'two'] = $aRow;
     }
     return $aPhotos;
 }
Exemplo n.º 4
0
 public function getJavascript($iPhotoId)
 {
     $aTags = $this->database()->select('p.user_id AS photo_owner_id, pt.tag_id, pt.user_id AS post_user_id, pt.content, pt.position_x, pt.position_y, pt.width, pt.height, ' . Phpfox::getUserField())->from($this->_sTable, 'pt')->leftJoin(Phpfox::getT('user'), 'u', 'u.user_id = pt.tag_user_id')->join(Phpfox::getT('photo'), 'p', 'p.photo_id = pt.photo_id')->where('pt.photo_id = ' . (int) $iPhotoId)->execute('getSlaveRows');
     if (!count($aTags)) {
         return false;
     }
     $sNotes = '[';
     foreach ($aTags as $aTag) {
         $sNotes .= '{';
         $sNotes .= 'note_id: ' . $aTag['tag_id'] . ', ';
         $sNotes .= 'x1: ' . $aTag['position_x'] . ', ';
         $sNotes .= 'y1: ' . $aTag['position_y'] . ', ';
         $sNotes .= 'width: ' . $aTag['width'] . ', ';
         $sNotes .= 'height: ' . $aTag['height'] . ', ';
         $sRemove = $aTag['post_user_id'] == Phpfox::getUserId() || $aTag['photo_owner_id'] == Phpfox::getUserId() || $aTag['user_id'] == Phpfox::getUserId() ? ' <a href="#" onclick="if (confirm(\\\'' . Phpfox::getPhrase('photo.are_you_sure') . '\\\')) { $(\\\'#noteform\\\').hide(); $(\\\'#js_photo_view_image\\\').imgAreaSelect({ hide: true }); $(this).parent(\\\'span:first\\\').remove();$(\\\'.notep#notep_' . $aTag['tag_id'] . '\\\').remove();$.ajaxCall(\\\'photo.removePhotoTag\\\', \\\'tag_id=' . $aTag['tag_id'] . '\\\'); } return false;"><i class="fa fa-remove"></i></a>' : '';
         if (!empty($aTag['user_id'])) {
             $sNotes .= 'note: \'<a href="' . Phpfox_Url::instance()->makeUrl($aTag['user_name']) . '" id="js_photo_tag_user_id_' . $aTag['user_id'] . '">' . $aTag['full_name'] . '</a>' . $sRemove . '\'';
         } else {
             $sNotes .= 'note: \'' . str_replace("'", "\\'", Phpfox::getLib('parse.output')->clean($aTag['content'])) . $sRemove . '\'';
         }
         $sNotes .= '},';
     }
     $sNotes = rtrim($sNotes, ',');
     $sNotes .= ']';
     return $sNotes;
 }
Exemplo n.º 5
0
 /**
  * Gets the featured members according to Phpfox::getParam('user.how_many_featured_members').
  * Uses cache to save a query (stores a cache if none found)
  * @return array( array of users, int total featured users )
  */
 public function get()
 {
     if ($sPlugin = Phpfox_Plugin::get('user.service_featured_get_1')) {
         eval($sPlugin);
         if (isset($mPluginReturn)) {
             return $mPluginReturn;
         }
     }
     $iTotal = Phpfox::getParam('user.how_many_featured_members');
     // the random will be done with php logic
     $sCacheId = $this->cache()->set('featured_users');
     if (!($aUsers = $this->cache()->get($sCacheId))) {
         $aUsers = $this->database()->select(Phpfox::getUserField() . ', uf.ordering')->from(Phpfox::getT('user'), 'u')->join($this->_sTable, 'uf', 'uf.user_id = u.user_id')->order('ordering DESC')->execute('getSlaveRows');
         if (Phpfox::getParam('user.cache_featured_users')) {
             $this->cache()->save($sCacheId, $aUsers);
         }
     }
     if (!is_array($aUsers)) {
         return array(array(), 0);
     }
     $aOut = array();
     if (Phpfox::getParam('user.randomize_featured_members')) {
         shuffle($aUsers);
     }
     $iCount = count($aUsers);
     // using count instead of $this->database()->limit to measure the real value
     for ($i = 0; $i <= $iTotal; $i++) {
         if (!isset($aUsers[$iCount - $i])) {
             continue;
         }
         // availability check
         $aOut[] = $aUsers[$iCount - $i];
     }
     return array($aOut, count($aUsers));
 }
Exemplo n.º 6
0
 /**
  * Get the latest shoutouts.
  *
  * @param int $iLimit Define the limit so we don't return all the shoutouts.
  * @return array Array of shoutouts.
  */
 public function getMessages($iLimit = 5)
 {
     if (isset($this->_aCallback['module'])) {
         if (Phpfox::hasCallback($this->_aCallback['module'], 'getShoutboxData')) {
             $aCallback = Phpfox::callback($this->_aCallback['module'] . '.getShoutboxData');
             if (isset($aCallback['table'])) {
                 $this->_sTable = Phpfox::getT($aCallback['table']);
                 $this->database()->where('item_id = ' . (int) $this->_aCallback['item']);
             }
         }
     }
     $aMessages = $this->database()->select('s.shout_id, s.text, s.time_stamp, ' . Phpfox::getUserField())->from($this->_sTable, 's')->join(Phpfox::getT('user'), 'u', 'u.user_id = s.user_id')->limit($iLimit)->order('s.time_stamp DESC')->execute('getSlaveRows');
     foreach ($aMessages as $iKey => $aMessage) {
         $aMessage['text'] = Phpfox::getLib('parse.output')->replaceHashTags(Phpfox::getLib('parse.output')->split(Phpfox::getLib('parse.output')->clean($aMessage['text']), Phpfox::getParam('shoutbox.shoutbox_wordwrap')));
         if (Phpfox::isModule('emoticon')) {
             $aMessages[$iKey]['text'] = Phpfox::getService('emoticon')->parse($aMessage['text']);
         }
         $aMessages[$iKey]['module'] = isset($this->_aCallback['module']) ? $this->_aCallback['module'] : '';
     }
     // FUDGE Lovinity January 5, 2016: Filter shouts by users who have been blocked or are blocking
     $bIsBlocked = Phpfox::getService('user.block')->isBlocked($aMessages[$iKey]['user_id'], Phpfox::getUserId());
     $bIsBlocked2 = Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $aMessages[$iKey]['user_id']);
     if ($bIsBlocked || $bIsBlocked2) {
         $aMessages[$iKey]['text'] = '<img src="file/public/blocked.png">';
     }
     // END FUDGE
     return $aMessages;
 }
Exemplo n.º 7
0
	public function query($sQuery, $iPage, $iTotalShow, $sView = null)
	{
		if ($sView !== null && Phpfox::isModule($sView))
		{
			$aModuleResults = Phpfox::callback($sView . '.globalUnionSearch', $this->preParse()->clean($sQuery));
		}
		else 
		{
			$aModuleResults = Phpfox::massCallback('globalUnionSearch', $this->preParse()->clean($sQuery));
		}
		
		$iOffset = ($iPage * $iTotalShow);
		
		$aRows = $this->database()->select('item.*, ' . Phpfox::getUserField())
				->unionFrom('item')		
				->join(Phpfox::getT('user'), 'u', 'u.user_id = item.item_user_id')
				->limit($iOffset, $iTotalShow)
				->order('item_time_stamp DESC')				
				->execute('getSlaveRows');

		$aResults = array();
		foreach ($aRows as $iKey => $aRow)
		{
			$aResults[] = array_merge($aRow, (array) Phpfox::callback($aRow['item_type_id'] . '.getSearchInfo', $aRow));
		}
		
		return $aResults;
	}
Exemplo n.º 8
0
	public function getRecentLoggedInUsers()
	{
		$iFriendsOnly = (int) Phpfox::getComponentSetting(Phpfox::getUserId(), 'log.user_login_display_limit', 0);
		$iLimit = 10;
		if ($iFriendsOnly === 1)
		{
			$aUsers = $this->database()->select(Phpfox::getUserField())
				->from(Phpfox::getT('friend'), 'f')
				->join(Phpfox::getT('user'), 'u', 'u.user_id = f.friend_user_id')
				->where('f.user_id = ' . Phpfox::getUserId() . ' AND is_invisible != 1')
				->order('u.last_login DESC')
				->limit($iLimit)
				->execute('getSlaveRows');
		}
		else 
		{
			$aUsers = $this->database()->select(Phpfox::getUserField())
				->from(Phpfox::getT('user'), 'u')
				->order('u.last_login DESC')
				->where('u.user_id != ' . Phpfox::getUserId() .' AND is_invisible != 1 AND u.status_id = 0 AND u.view_id = 0')
				->limit($iLimit)
				->execute('getSlaveRows');
		}
			
		return $aUsers;
	}
Exemplo n.º 9
0
	public function getFilters($sType)
	{
		$aFilters = $this->database()->select('b.*, ' . Phpfox::getUserField())
						->from($this->_sTable, 'b')
						->leftJoin(Phpfox::getT('user'), 'u', 'u.user_id = b.user_id')
						->where('b.type_id = \'' . $this->database()->escape($sType) . '\'')
						->execute('getRows');

		foreach ($aFilters as $iKey => $aFilter)
		{
			if (!empty($aFilter['user_groups_affected']))
			{
				$aUserGroups = unserialize($aFilter['user_groups_affected']);
				$aFilters[$iKey]['user_groups_affected'] = array();
				
				$sWhere = '';
				foreach ($aUserGroups as $iUserGroup)
				{
					$sWhere .= 'user_group_id = ' . $iUserGroup . ' OR ';
				}
				$sWhere = rtrim($sWhere, ' OR ');
				$aFilters[$iKey]['user_groups_affected'] = Phpfox::getService('user.group')->get($sWhere);
			}
		}
		return $aFilters;
	}
Exemplo n.º 10
0
	/**
	 * Get the latest shoutouts.
	 *
	 * @param int $iLimit Define the limit so we don't return all the shoutouts.
	 * @return array Array of shoutouts.
	 */
	public function getMessages($iLimit = 5)
	{
		if (isset($this->_aCallback['module']))
		{
			if (Phpfox::hasCallback($this->_aCallback['module'], 'getShoutboxData'))
			{
				$aCallback = Phpfox::callback($this->_aCallback['module'] . '.getShoutboxData');		
				if (isset($aCallback['table']))
				{
					$this->_sTable = Phpfox::getT($aCallback['table']);
					
					$this->database()->where('item_id = ' . (int) $this->_aCallback['item']);
				}
			}
		}				
		
		$aMessages = $this->database()->select('s.shout_id, s.text, s.time_stamp, ' . Phpfox::getUserField())
			->from($this->_sTable, 's')
			->join(Phpfox::getT('user'), 'u', 'u.user_id = s.user_id')
			->limit($iLimit)
			->order('s.time_stamp DESC')
			->execute('getSlaveRows');

		foreach ($aMessages as $iKey => $aMessage)
		{
			$aMessage['text'] = Phpfox::getLib('parse.output')->split(Phpfox::getLib('parse.output')->clean($aMessage['text']), Phpfox::getParam('shoutbox.shoutbox_wordwrap'));
			
			$aMessages[$iKey]['text'] = Phpfox::getService('emoticon')->parse($aMessage['text']);
			$aMessages[$iKey]['module'] = (isset($this->_aCallback['module']) ? $this->_aCallback['module'] : '');
		}
			
		return $aMessages;
	}
Exemplo n.º 11
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     //Set How many records to return
     $iLimit = 9;
     $aUsers = Phpfox::getLib('database')->select('u.user_id, ua.activity_points, ' . Phpfox::getUserField())->from(Phpfox::getT('user'), 'u')->join(Phpfox::getT('user_activity'), 'ua', 'u.user_id = ua.user_id')->order('ua.activity_points DESC')->limit($iLimit)->execute('getSlaveRows');
     $this->template()->assign(array('sHeader' => Phpfox::getPhrase('user.point_title'), 'aUsers' => $aUsers));
     return 'block';
 }
Exemplo n.º 12
0
 public function getReports($iId)
 {
     $aReport = $this->database()->select('item_id')->from($this->_sTable)->where('data_id = ' . (int) $iId)->execute('getRow');
     if (!isset($aReport['item_id']) && !isset($aReport['feedback'])) {
         return false;
     }
     $aReports = $this->database()->select('rd.*, r.message, ' . Phpfox::getUserField())->from($this->_sTable, 'rd')->join(Phpfox::getT('user'), 'u', 'u.user_id = rd.user_id')->join(Phpfox::getT('report'), 'r', 'r.report_id = rd.report_id')->where('item_id = \'' . $aReport['item_id'] . '\'')->execute('getRows');
     return $aReports;
 }
 public function getAppById($iId, $iUserId)
 {
     $aApp = $this->database()->select('a.*, p.page_id, p.total_like, au.install_id as is_installed, ac.category_id, ac.name as category_name, ' . Phpfox::getUserField())->from(Phpfox::getT('app'), 'a')->join(Phpfox::getT('user'), 'u', 'u.user_id = a.user_id')->leftjoin(Phpfox::getT('app_installed'), 'au', 'au.app_id = a.app_id AND au.user_id = ' . $iUserId)->leftjoin(Phpfox::getT('app_category_data'), 'acd', 'acd.app_id = a.app_id')->leftjoin(Phpfox::getT('app_category'), 'ac', 'ac.category_id = acd.category_id')->leftjoin(Phpfox::getT('pages'), 'p', 'p.app_id = a.app_id')->where('a.public_key = \'' . $iId . '\'')->execute('getSlaveRow');
     if (empty($aApp)) {
         return Phpfox_Error::display(Phpfox::getPhrase('apps.this_app_does_not_exist'));
     }
     $aApp['category_name'] = Phpfox::getLib('locale')->convert($aApp['category_name']);
     return $aApp;
 }
Exemplo n.º 14
0
 public function getPage($iPage)
 {
     $aPage = Phpfox::getService('pages')->getForView($iPage);
     $aUser = $this->database()->select(Phpfox::getUserField('u'))->from(Phpfox::getT('user'), 'u')->where('u.user_id = ' . $aPage['user_id'])->execute('getRow');
     $aPage = array_merge($aPage, $aUser);
     $aPage['profile_page_id'] = $this->database()->select('u.user_id')->from(Phpfox::getT('user'), 'u')->where('u.profile_page_id = ' . $aPage['page_id'])->execute('getField');
     $aPage = $this->processPage($aPage);
     return $aPage;
 }
Exemplo n.º 15
0
 public function getList($iPage, $iPageSize)
 {
     $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable)->execute('getSlaveField');
     $aReceivedList = $this->database()->select('ki.*, ' . Phpfox::getUserField('u', 'u_'))->from($this->_sTable, 'ki')->join(Phpfox::getT('user'), 'u', 'u.user_id = ki.user_id')->order('ki.koinfractions_id DESC')->limit($iPage, $iPageSize, $iCnt)->execute('getRows');
     foreach ($aReceivedList as $iKey => $aInfraction) {
         $aReceivedList[$iKey]['admin_user'] = $this->database()->select(Phpfox::getUserField())->from(Phpfox::getT('user'), 'u')->where('u.user_id =' . $aInfraction['admin_user_id'])->execute('getRow');
     }
     return array($iCnt, $aReceivedList);
 }
Exemplo n.º 16
0
 public function process()
 {
     if ($_POST['poke_user'] and $_POST['poke_userid'] and $_POST['poke_type_id']) {
         # Check User Privacy Settings
         if (!Phpfox::getService('user.privacy')->hasAccess($_POST['poke_userid'], 'megapoke.who_can_poke')) {
             $this->url()->send($_POST['poke_user'], null, Phpfox::getPhrase('megapoke.user_turned_off_megapoke'));
             exit;
         }
         if (Phpfox::getUserId() == $_POST['poke_userid']) {
             $this->url()->send($_POST['poke_user'], null, Phpfox::getPhrase('megapoke.you_can_not_send_yourself_a_megapoke'));
             exit;
         }
         # Flood Control: 2 mins
         $time = time() - 120;
         $aFlood = phpfox::getLib('phpfox.database')->select('*')->from(Phpfox::getT('feed'))->where("type_id = 'megapoke' and user_id = '" . Phpfox::getUserId() . "' and  time_stamp > '" . $time . "' ")->execute('getSlaveRow');
         if (isset($aFlood['feed_id'])) {
             $this->url()->send($_POST['poke_user'], null, Phpfox::getPhrase('megapoke.too_many_megapokes'));
             exit;
         }
         # Get Poke Type
         $aPoke = phpfox::getLib('phpfox.database')->select('*')->from(Phpfox::getT('megapoke'))->where("poke_type_id = '" . Phpfox::getLib('phpfox.database')->escape($_POST['poke_type_id']) . "' ")->execute('getSlaveRow');
         $d = array();
         $d['content'] = $aPoke['poke_text'];
         $oUrl = Phpfox::getLib('url');
         $oParseOutput = Phpfox::getLib('parse.output');
         #Insert into Feed
         if (Phpfox::getUserParam('megapoke.showpokesinfeed')) {
             $d['type_id'] = 'megapoke';
             $d['user_id'] = Phpfox::getUserId();
             $d['item_user_id'] = Phpfox::getLib('phpfox.database')->escape($_POST['poke_userid']);
             $d['time_stamp'] = time();
             phpfox::getLib('phpfox.database')->insert(Phpfox::getT('feed'), $d);
             if (Phpfox::isModule('modsfox')) {
                 $ryansFeedStatus = Phpfox::getPhrase('megapoke.ryans_feed_status', array('viewer_link' => $oUrl->makeUrl('') . "" . $_POST['poke_user'], 'viewer_full_name' => Phpfox::getLib('parse.output')->clean($_POST['poke_user_full_name']), 'content' => $aPoke['poke_text']));
                 $sType = 'status';
                 $js_user = Phpfox::getUserId();
                 $js_mood = "";
                 Phpfox::getService('modsfox.status')->add($sType, $ryansFeedStatus, $js_mood, $js_user);
             }
         }
         # Add Notification
         if (Phpfox::isModule('notification')) {
             Phpfox::getService('notification.process')->add('megapoke', $aPoke['poke_type_id'], $_POST['poke_userid'], Phpfox::getUserId());
         }
         # Get User Info
         $aUserFrom = Phpfox::getLib('phpfox.database')->select(str_replace("u.", "", Phpfox::getUserField()))->from(Phpfox::getT('user'))->where("user_id = '" . Phpfox::getUserId() . "'")->execute('getSlaveRow');
         $d['user_link'] = $oUrl->makeUrl('') . "" . $aUserFrom['user_name'];
         $d['owner_full_name'] = $aUserFrom['full_name'];
         # Send Email
         Phpfox::getLib('mail')->to($_POST['poke_userid'])->subject(array('megapoke.newpoke_subject', $d))->message(array('megapoke.newpoke_message', $d))->notification('megapoke.new_poke_email')->send();
         # Redirect User
         $this->url()->send($_POST['poke_user'], null, Phpfox::getPhrase('megapoke.poke_sent'));
         exit;
     }
     exit;
 }
Exemplo n.º 17
0
 public function getNotificationFeed($aRow)
 {
     $oUrl = Phpfox::getLib('url');
     $oParseOutput = Phpfox::getLib('parse.output');
     $aPoke = phpfox::getLib('phpfox.database')->select('*')->from(Phpfox::getT('megapoke'))->where("poke_type_id = '" . $aRow['item_id'] . "' ")->execute('getSlaveRow');
     $aUserFrom = Phpfox::getLib('phpfox.database')->select(str_replace("u.", "", Phpfox::getUserField()))->from(Phpfox::getT('user'))->where("user_id = '" . Phpfox::getUserId() . "'")->execute('getSlaveRow');
     $aRow['link'] = $oUrl->makeUrl('feed.user', array('id' => $aRow['user_id']));
     $aRow['message'] = Phpfox::getPhrase('megapoke.notification', array('user_link' => $oUrl->makeUrl('feed.user', array('id' => $aRow['user_id'])), 'owner_full_name' => Phpfox::getLib('parse.output')->clean($aRow['full_name']), 'content' => $aPoke['poke_text']));
     return $aRow;
 }
Exemplo n.º 18
0
 public function getNew()
 {
     ($sPlugin = Phpfox_Plugin::get('blog.component_service_blog_getnew__start')) ? eval($sPlugin) : false;
     return $this->database()->select('b.blog_id, b.time_stamp, b.title, bt.text_parsed, ' . Phpfox::getUserField())->from($this->_sTable, 'b')->join(Phpfox::getT('user'), 'u', 'u.user_id = b.user_id')->join(Phpfox::getT('blog_text'), 'bt', 'bt.blog_id = b.blog_id')->where('b.is_approved = 1 AND b.privacy = 0 AND b.post_status = 1')->limit((int) Phpfox::getParam('stnewblogs.how_many_nblogs'))->order('b.time_stamp DESC')->execute('getSlaveRows');
     foreach ($aRows as $iKey => $aRow) {
         $aRows[$iKey]['posted_on'] = Phpfox::getPhrase('blog.posted_on_post_time_by_user_link', array('post_time' => Phpfox::getTime(Phpfox::getParam('blog.blog_time_stamp'), $aRow['time_stamp']), 'user' => $aRow));
     }
     ($sPlugin = Phpfox_Plugin::get('blog.component_service_blog_getnew__end')) ? eval($sPlugin) : false;
     return $aRows;
 }
Exemplo n.º 19
0
 public function getSearch($aConditions, $sSort = null, $iPage = null, $iPageSize)
 {
     $aPurchases = array();
     $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'sp')->where($aConditions)->execute('getSlaveField');
     if ($iCnt) {
         $aPurchases = $this->database()->select('sp.*, spack.*, ' . Phpfox::getUserField())->from($this->_sTable, 'sp')->join(Phpfox::getT('subscribe_package'), 'spack', 'spack.package_id = sp.package_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = sp.user_id')->where($aConditions)->limit($iPage, $iPageSize, $iCnt)->order($sSort)->execute('getSlaveRows');
         $this->_build($aPurchases);
     }
     return array($iCnt, $aPurchases);
 }
Exemplo n.º 20
0
	public function getActivityFeed($aFeed)
	{
		$aCore = Phpfox::getLib('request')->get('core');
		
		$bForceUser = false;
		if (defined('PHPFOX_IS_USER_PROFILE') || isset($aCore['profile_user_id']))
		{
			$aUser = (array) (isset($aCore['profile_user_id']) ? Phpfox::getService('user')->get($aCore['profile_user_id']) : Phpfox::getService('user')->getUserObject(PHPFOX_CURRENT_USER_PROFILE));
			if (isset($aUser['user_id']))
			{
				if ($aUser['user_id'] == $aFeed['item_id'])
				{
					$aFeed['item_id'] = $aFeed['user_id'];
					$bForceUser = true;				
				}
			}
		}		
		
		$aRow = $this->database()->select(Phpfox::getUserField())
			->from(Phpfox::getT('user'), 'u')
			->where('u.user_id = ' . (int) $aFeed['item_id'])
			->execute('getSlaveRow');
		
		if (!isset($aRow['user_id']))
		{
			return false;
		}
		
		$aParams = array(
			'user' => $aRow,
			'suffix' => '_50_square',
			'max_width' => '50',
			'max_height' => '50',
			'js_hover_title' => true
		);
		
		$sImage = Phpfox::getLib('image.helper')->display($aParams);			
		
		$aReturn = array(
			'feed_title' => $aRow['full_name'],
			'feed_info' => Phpfox::getPhrase('feed.is_now_friends_with'),
			'feed_link' => Phpfox::getLib('url')->makeUrl($aRow['user_name']),
			'feed_icon' => Phpfox::getLib('image.helper')->display(array('theme' => 'misc/friend_added.png', 'return_url' => true)),
			'time_stamp' => $aFeed['time_stamp'],			
			'enable_like' => false,		
			'feed_image' => $sImage			
		);	
		
		if ($bForceUser)
		{
			$aReturn['force_user'] = $aUser;
		}
					
		return $aReturn;
	}
 public function _getNotification($iUserId)
 {
     $aGetRows = $this->database()->select('n.*, n.user_id as item_user_id, COUNT(n.notification_id) AS total_extra, ' . Phpfox::getUserField())->from($this->_sTable, 'n')->join(Phpfox::getT('user'), 'u', 'u.user_id = n.owner_user_id')->innerJoin('(SELECT * FROM ' . $this->_sTable . ' AS n WHERE n.user_id = ' . $iUserId . ' ORDER BY n.time_stamp DESC)', 'ninner', 'ninner.notification_id = n.notification_id')->where('n.user_id = ' . $iUserId . '')->group('n.type_id, n.item_id')->order('n.is_seen ASC, n.time_stamp DESC')->limit(5)->execute('getSlaveRows');
     $aRows = array();
     foreach ($aGetRows as $aGetRow) {
         $aRows[(int) $aGetRow['notification_id']] = $aGetRow;
     }
     arsort($aRows);
     $aNotifications = array();
     foreach ($aRows as $aRow) {
         $aParts1 = explode('.', $aRow['type_id']);
         $sModule = $aParts1[0];
         if (strpos($sModule, '_')) {
             $aParts = explode('_', $sModule);
             $sModule = $aParts[0];
         }
         if (Phpfox::isModule($sModule)) {
             if ((int) $aRow['total_extra'] > 1) {
                 $aExtra = $this->database()->select('n.owner_user_id, n.time_stamp, n.is_seen, u.full_name')->from($this->_sTable, 'n')->join(Phpfox::getT('user'), 'u', 'u.user_id = n.owner_user_id')->where('n.type_id = \'' . $this->database()->escape($aRow['type_id']) . '\' AND n.item_id = ' . (int) $aRow['item_id'])->group('u.user_id')->order('n.time_stamp DESC')->limit(10)->execute('getSlaveRows');
                 foreach ($aExtra as $iKey => $aExtraUser) {
                     if ($aExtraUser['owner_user_id'] == $aRow['user_id']) {
                         unset($aExtra[$iKey]);
                     }
                     if (!$aRow['is_seen'] && $aExtraUser['is_seen']) {
                         unset($aExtra[$iKey]);
                     }
                 }
                 if (count($aExtra)) {
                     $aRow['extra_users'] = $aExtra;
                 }
             }
             if (substr($aRow['type_id'], 0, 8) != 'comment_' && !Phpfox::hasCallback($aRow['type_id'], 'getNotification')) {
                 $aCallBack['link'] = '#';
                 $aCallBack['message'] = '2. Notification is missing a callback. [' . $aRow['type_id'] . '::getNotification]';
             } elseif (substr($aRow['type_id'], 0, 8) == 'comment_' && substr($aRow['type_id'], 0, 12) != 'comment_feed' && !Phpfox::hasCallback(substr_replace($aRow['type_id'], '', 0, 8), 'getCommentNotification')) {
                 $aCallBack['link'] = '#';
                 $aCallBack['message'] = 'Notification is missing a callback. [' . substr_replace($aRow['type_id'], '', 0, 8) . '::getCommentNotification]';
             } else {
                 // set wanted user id
                 Phpfox::getService('user.auth')->setUserId($iUserId);
                 $aCallBack = Phpfox::callback($aRow['type_id'] . '.getNotification', $aRow);
                 // reset current user id
                 Phpfox::getService('user.auth')->setUserId(null);
                 if ($aCallBack === false) {
                     $this->database()->delete($this->_sTable, 'notification_id = ' . (int) $aRow['notification_id']);
                     continue;
                 }
             }
             $aNotifications[] = array_merge($aRow, (array) $aCallBack);
         }
         //            $this->database()->update($this->_sTable, array('is_seen' => '1'), 'type_id = \'' . $this->database()->escape($aRow['type_id']) . '\' AND item_id = ' . (int) $aRow['item_id']);
     }
     return $aNotifications;
 }
Exemplo n.º 22
0
 /**
  *
  */
 public function get($iId = null)
 {
     if (is_int($iId)) {
         $this->database()->where('n.newsletter_id = ' . (int) $iId);
     }
     $aNewsletters = $this->database()->select('n.*, nt.*, ' . Phpfox::getUserField())->from($this->_sTable, 'n')->join(Phpfox::getT('user'), 'u', 'u.user_id = n.user_id')->join(Phpfox::getT('newsletter_text'), 'nt', 'nt.newsletter_id = n.newsletter_id')->order('time_stamp DESC')->execute('getSlaveRows');
     if ($iId !== null && !empty($aNewsletters)) {
         return reset($aNewsletters);
     }
     return $aNewsletters;
 }
Exemplo n.º 23
0
 /**
  * @param null $userId
  * @return User\Object|User\Object[]
  * @throws \Exception
  */
 public function get($userId = null)
 {
     $this->auth();
     $friends = [];
     // list($total, $users) = \Friend_Service_Friend::instance()->get(['friend.user_id' => user()->id]);
     $userId = user()->id;
     $users = $this->db->select(\Phpfox::getUserField())->from(':friend', 'f')->join(':user', 'u', 'u.user_id = f.friend_user_id')->where(['f.user_id' => $userId])->limit(20)->all();
     foreach ($users as $user) {
         $friends[$user['user_id']] = new User\Object($user);
     }
     return $friends;
 }
Exemplo n.º 24
0
 public function getPending($iPage = '', $sLimit = '')
 {
     $aRows = array();
     $sWhere = 'fr.friend_user_id = ' . Phpfox::getUserId();
     if (Phpfox::getParam('friend.hide_denied_requests_from_pending_list')) {
         $sWhere .= ' AND fr.is_ignore != 1';
     }
     $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'fr')->join(Phpfox::getT('user'), 'u', 'u.user_id = fr.user_id')->where($sWhere)->execute('getSlaveField');
     if ($iCnt) {
         $aRows = $this->database()->select('fr.request_id, ' . Phpfox::getUserField())->from($this->_sTable, 'fr')->join(Phpfox::getT('user'), 'u', 'u.user_id = fr.user_id')->where($sWhere)->limit($iPage, $sLimit, $iCnt)->order('fr.time_stamp DESC')->execute('getSlaveRows');
     }
     return array($iCnt, $aRows);
 }
Exemplo n.º 25
0
 public function execute()
 {
     $this->_iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'p')->leftjoin(Phpfox::getT('ko_profiles_field_values'), 'pfv', 'pfv.extra_id = p.extra_id')->where($this->_aConditions)->execute('getSlaveField');
     if ($this->_iCnt) {
         $aListings = $this->database()->select('p.*, pfv.*,p.extra_id AS extra_id, ' . Phpfox::getUserField('u', 'extra_'))->from($this->_sTable, 'p')->join(Phpfox::getT('user'), 'u', 'u.user_id = p.user_id')->leftJoin(Phpfox::getT('ko_profiles_field_values'), 'pfv', 'pfv.extra_id = p.extra_id')->where($this->_aConditions)->order($this->_sOrder)->limit($this->_iPage, $this->_iPageSize, $this->_iCnt)->execute('getSlaveRows');
         //echo '<pre>'; print_r($aListings); echo '</pre>'; exit;
         foreach ($aListings as $aListing) {
             $aListing['user_name_link'] = '<a href="' . Phpfox::getLib('url')->makeUrl($aListing['extra_user_name']) . '">' . Phpfox::getLib('parse.output')->clean($aListing['extra_full_name']) . '</a>';
             $aListing['time_stamp_phrase'] = Phpfox::getTime(Phpfox::getParam('profiles.profiles_browse_time_stamp'), $aListing['time_stamp']);
             $aListing['url'] = Phpfox::getLib('url')->makeUrl('profiles', $aListing['title_url']);
             $this->_aListings[] = $aListing;
         }
     }
 }
Exemplo n.º 26
0
 public function get($aConds, $sSort = 'c.added DESC', $iPage = '', $iLimit = '')
 {
     $iCnt = $this->database()->select('COUNT(DISTINCT rd.item_id)')->from(Phpfox::getT('report_data'), 'rd')->join(Phpfox::getT('user'), 'u', 'u.user_id = rd.user_id')->leftjoin(Phpfox::getT('report'), 'r', 'r.report_id = rd.report_id')->where($aConds)->order($sSort)->execute('getSlaveField');
     $aItems = array();
     if ($iCnt) {
         $aItems = $this->database()->select('COUNT(rd.item_id) AS total_report, rd.*, r.message, ' . Phpfox::getUserField())->from(Phpfox::getT('report_data'), 'rd')->join(Phpfox::getT('user'), 'u', 'u.user_id = rd.user_id')->leftjoin(Phpfox::getT('report'), 'r', 'r.report_id = rd.report_id')->where($aConds)->order($sSort)->group('rd.item_id')->limit($iPage, $iLimit, $iCnt)->execute('getSlaveRows');
         foreach ($aItems as $iKey => $aItem) {
             $aParts = explode('_', $aItem['item_id']);
             unset($aParts[count($aParts) - 1]);
             $aItems[$iKey]['module_id'] = implode(' ', $aParts);
         }
     }
     return array($iCnt, $aItems);
 }
 public function getFriends($iUserId, $sYear = null)
 {
     if ($sYear == null) {
         $sYear = date("Y");
     }
     $iTimeStartYear = phpfox::getLib('date')->mktime(0, 0, 0, 1, 1, $sYear);
     $iTimeEndYear = phpfox::getLib('date')->mktime(23, 59, 59, 12, 31, $sYear);
     $iCnt = $this->database()->select('count(u.user_id)')->from(phpfox::getT('friend'), 'friend')->join(phpfox::getT('user'), 'u', 'u.user_id = friend.friend_user_id')->where('friend.is_page = 0 AND friend.user_id = ' . (int) $iUserId . ' AND friend.time_stamp >= ' . $iTimeStartYear . ' AND friend.time_stamp <=' . $iTimeEndYear)->execute('getSlaveField');
     if (!$iCnt) {
         return array(0, array());
     }
     $aRows = $this->database()->select('uf.dob_setting, friend.friend_id, friend.friend_user_id, friend.is_top_friend, friend.time_stamp, ' . Phpfox::getUserField())->from(phpfox::getT('friend'), 'friend')->join(Phpfox::getT('user'), 'u', 'u.user_id = friend.friend_user_id')->join(Phpfox::getT('user_field'), 'uf', 'u.user_id = uf.user_id')->where('friend.is_page = 0 AND friend.user_id = ' . (int) $iUserId . ' AND friend.time_stamp >= ' . $iTimeStartYear . ' AND friend.time_stamp <=' . $iTimeEndYear)->limit(0, 29, $iCnt)->group('u.user_id')->execute('getSlaveRows');
     return array($iCnt, $aRows);
 }
Exemplo n.º 28
0
 public function get($id = null)
 {
     if ($id) {
         $message = $this->db->select('t.*, ' . \Phpfox::getUserField())->from(':mail_thread_text', 't')->join(':user', 'u', 'u.user_id = t.user_id')->where(['t.message_id' => $id])->get();
         $object = new Message\Thread\Object($message);
     } else {
         $this->auth();
         $object = [];
         list($total, $messages, $inputs) = \Mail_Service_Mail::instance()->get();
         foreach ($messages as $message) {
             $object[] = new Message\Object($message);
         }
     }
     return $object;
 }
Exemplo n.º 29
0
 /**
  * Add a new shoutout
  *
  * @return boolean Return false if we ran into an error.
  */
 public function add()
 {
     // Only members allowed to add a shoutout
     Phpfox::isUser(true);
     // Make sure the user group adding a shoutout is allowed to do so
     Phpfox::getUserParam('shoutbox.can_add_shoutout', true);
     // Run last_post SPAM check
     if (Phpfox::getLib('spam')->check(array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('shoutbox'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => Phpfox::getParam('shoutbox.shoutbox_flood_limit'))))) {
         // Reset the shoutbox form
         $this->show('#js_shoutbox_form')->hide('#js_shoutbox_message')->focus('#js_shoutbox_input');
         // Send them a message that they failed the flood control
         $this->alert(Phpfox::getPhrase('shoutbox.please_wait_limit_seconds_before_adding_a_new_shoutout', array('limit' => Phpfox::getParam('shoutbox.shoutbox_flood_limit'))));
         return false;
     }
     if (Phpfox::getLib('parse.format')->isEmpty($this->get('shoutout'))) {
         $this->show('#js_shoutbox_form')->hide('#js_shoutbox_message')->val('#js_shoutbox_input', '')->focus('#js_shoutbox_input')->alert(Phpfox::getPhrase('shoutbox.enter_a_shoutout'));
         return false;
     }
     if ($this->get('module') == 'group' && !Phpfox::getService('group')->hasAccess($this->get('item'), 'can_use_shoutbox', true)) {
         $this->show('#js_shoutbox_form')->hide('#js_shoutbox_message')->val('#js_shoutbox_input', '')->focus('#js_shoutbox_input')->alert(Phpfox::getPhrase('shoutbox.only_members_of_this_group_can_leave_a_message'));
         return false;
     }
     // Add the shoutout
     if ($iId = Phpfox::getService('shoutbox.process')->add(Phpfox::getUserId(), $this->get('shoutout'), $this->get('module', null), $this->get('item', null))) {
         // Get all the default user fields we use
         $sFields = Phpfox::getUserField();
         // Create an array of the string fields
         $aFields = explode(',', $sFields);
         $aParams = array();
         foreach ($aFields as $sField) {
             // Replace database alias
             $sField = trim(str_replace('u.', '', $sField));
             // Cache the fields and get the current users actual value
             $aParams[$sField] = Phpfox::getUserBy($sField);
         }
         // Shorten the text
         // Clean the text, we don't allow HTML
         $sText = Phpfox::getLib('parse.output')->replaceHashTags(Phpfox::getLib('parse.output')->split(Phpfox::getLib('parse.output')->clean(Phpfox::getLib('parse.input')->clean($this->get('shoutout'), 255)), Phpfox::getParam('shoutbox.shoutbox_wordwrap')));
         // Parse emoticons
         $sText = Phpfox::getService('emoticon')->parse($sText);
         // Create the needed template variables not defined with $aParams
         $aShoutout = array('module' => $this->get('module'), 'shout_id' => $iId, 'time_stamp' => PHPFOX_TIME, 'text' => $sText);
         // Assign the variables for the template and get the template
         $this->template()->assign(array('bShoutboxAjax' => true, 'aShoutout' => array_merge($aShoutout, $aParams), 'iShoutoutWordWrap' => Phpfox::getParam('shoutbox.shoutbox_wordwrap')))->getTemplate('shoutbox.block.entry');
         // Add the message to the shoutbox and reset the shoutbox form
         $this->call('$(\'.js_shoutbox_messages\').removeClass(\'row_first\');')->prepend('#js_shoutbox_messages', $this->getContent(false))->show('#js_shoutbox_form')->hide('#js_shoutbox_message')->val('#js_shoutbox_input', '')->focus('#js_shoutbox_input');
     }
 }
Exemplo n.º 30
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     $sError = false;
     $iUserId = $this->getParam('user_id');
     $aUser = Phpfox::getService('user')->getUser($iUserId, Phpfox::getUserField());
     if (Phpfox::getUserId() === $aUser['user_id']) {
         $sError = 'same_user';
     } elseif (Phpfox::getService('friend.request')->isRequested(Phpfox::getUserId(), $aUser['user_id'])) {
         $sError = 'already_asked';
     } elseif (Phpfox::getService('friend.request')->isRequested($aUser['user_id'], Phpfox::getUserId())) {
         $sError = 'user_asked_already';
     } elseif (Phpfox::getService('friend')->isFriend($aUser['user_id'], Phpfox::getUserId())) {
         $sError = 'already_friends';
     }
     $this->template()->setPhrase(array('core.you_cannot_write_more_then_limit_characters', 'core.you_have_limit_character_s_left'))->setHeader(array())->assign(array('aUser' => $aUser, 'sError' => $sError, 'aOptions' => Phpfox::getService('friend.list')->get(), 'bSuggestion' => $this->request()->get('suggestion') ? true : false, 'bPageSuggestion' => $this->request()->get('suggestion_page') ? true : false, 'bInvite' => $this->request()->get('invite') ? true : false));
 }