Пример #1
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     $iRsvp = $this->request()->get('rsvp', 1);
     $iPage = $this->request()->getInt('page');
     $sModule = $this->request()->get('module', false);
     $iItem = $this->request()->getInt('item', false);
     $aCallback = $this->getParam('aCallback', false);
     $iPageSize = 6;
     if (PHPFOX_IS_AJAX) {
         $aCallback = false;
         if ($sModule && $iItem && Phpfox::hasCallback($sModule, 'getEventInvites')) {
             $aCallback = Phpfox::callback($sModule . '.getEventInvites', $iItem);
         }
         $aEvent = Phpfox::getService('event')->callback($aCallback)->getEvent($this->request()->get('id'), true);
         $this->template()->assign('aEvent', $aEvent);
     } else {
         $aEvent = $this->getParam('aEvent');
         $this->template()->assign('aEvent', $aEvent);
     }
     if ($aCallback !== false) {
         $sModule = $aCallback['module'];
         $iItem = $aCallback['item'];
     }
     list($iCnt, $aInvites) = Phpfox::getService('event')->getInvites($aEvent['event_id'], $iRsvp, $iPage, $iPageSize);
     Phpfox::getLib('pager')->set(array('ajax' => 'event.listGuests', 'page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt, 'aParams' => array('id' => $aEvent['event_id'], 'module' => $sModule, 'item' => $iItem, 'rsvp' => $iRsvp)));
     $this->template()->assign(array('aInvites' => $aInvites, 'iRsvp' => $iRsvp));
     if (!PHPFOX_IS_AJAX) {
         $sExtra = '';
         if ($aCallback !== false) {
             $sExtra .= '&module=' . $aCallback['module'] . '&item=' . $aCallback['item'];
         }
         $this->template()->assign(array('sHeader' => Phpfox::getPhrase('event.event_guests'), 'aMenu' => array(Phpfox::getPhrase('event.attending') => '#event.listGuests?rsvp=1&id=' . $aEvent['event_id'] . $sExtra, Phpfox::getPhrase('event.maybe') => '#event.listGuests?rsvp=2&id=' . $aEvent['event_id'] . $sExtra, Phpfox::getPhrase('event.can_t_make_it') => '#event.listGuests?rsvp=3&id=' . $aEvent['event_id'] . $sExtra, Phpfox::getPhrase('event.not_responded') => '#event.listGuests?rsvp=0&id=' . $aEvent['event_id'] . $sExtra), 'sBoxJsId' => 'event_guests'));
         return 'block';
     }
 }
Пример #2
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::getUserParam('comment.can_moderate_comments', true);
     $iPage = $this->request()->getInt('page');
     $aPages = array(20, 30, 40, 50);
     $aDisplays = array();
     foreach ($aPages as $iPageCnt) {
         $aDisplays[$iPageCnt] = Phpfox::getPhrase('core.per_page', array('total' => $iPageCnt));
     }
     $aFilters = array('search' => array('type' => 'input:text', 'search' => "AND ls.name LIKE '%[VALUE]%'"), 'display' => array('type' => 'select', 'options' => $aDisplays, 'default' => '20'), 'sort' => array('type' => 'select', 'options' => array('time_stamp' => Phpfox::getPhrase('comment.last_activity'), 'rating ' => Phpfox::getPhrase('comment.rating')), 'default' => 'time_stamp', 'alias' => 'cmt'), 'sort_by' => array('type' => 'select', 'options' => array('DESC' => Phpfox::getPhrase('core.descending'), 'ASC' => Phpfox::getPhrase('core.ascending')), 'default' => 'DESC'));
     $oSearch = Phpfox_Search::instance()->set(array('type' => 'comments', 'filters' => $aFilters, 'search' => 'search'));
     if ($this->request()->get('view') == 'approval') {
         $oSearch->setCondition('AND cmt.view_id = 1');
     } else {
         $oSearch->setCondition('AND cmt.view_id = 9');
     }
     list($iCnt, $aComments) = Phpfox::getService('comment')->get('cmt.*', $oSearch->getConditions(), $oSearch->getSort(), $oSearch->getPage(), $oSearch->getDisplay(), null, true);
     foreach ($aComments as $iKey => $aComment) {
         if (Phpfox::hasCallback($aComment['type_id'], 'getItemName')) {
             $aComments[$iKey]['item_name'] = Phpfox::callback($aComment['type_id'] . '.getItemName', $aComment['comment_id'], $aComment['owner_full_name']);
         }
     }
     Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $oSearch->getDisplay(), 'count' => $oSearch->getSearchTotal($iCnt)));
     $this->template()->setTitle(Phpfox::getPhrase('comment.comment_title'))->setBreadcrumb(Phpfox::getPhrase('comment.comment_title'), $this->url()->makeUrl('admincp.comment'))->setHeader('cache', array('comment.css' => 'style_css', 'pager.css' => 'style_css'))->assign(array('aComments' => $aComments, 'bIsCommentAdminPanel' => true));
 }
Пример #3
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;
 }
Пример #4
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::isUser(true);
     if ($this->request()->getInt('forum')) {
         $aForum = Phpfox::getService('forum')->id($this->request()->getInt('forum'))->getForum();
         if (!isset($aForum['forum_id'])) {
             return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_forum'));
         }
         if (Phpfox::getService('forum.thread.process')->markRead($aForum['forum_id'])) {
             $this->url()->send('forum', array($aForum['name_url'] . '-' . $aForum['forum_id']), Phpfox::getPhrase('forum.forum_successfully_marked_as_read'));
         }
     } elseif (($sModule = $this->request()->get('module')) && ($iItemId = $this->request()->getInt('item'))) {
         $aCallback = Phpfox::callback($sModule . '.addForum', $iItemId);
         if (isset($aCallback['module'])) {
             if (Phpfox::getService('forum.thread.process')->markRead(0, $aCallback['item'])) {
                 $this->url()->send($aCallback['url_home'], array('forum'), Phpfox::getPhrase('forum.forum_successfully_marked_as_read'));
             }
         }
     } else {
         $aForums = Phpfox::getService('forum')->live()->getForums();
         foreach ($aForums as $aForum) {
             Phpfox::getService('forum.thread.process')->markRead($aForum['forum_id']);
             $aChildrens = Phpfox::getService('forum')->id($aForum['forum_id'])->getChildren();
             if (!is_array($aChildrens)) {
                 continue;
             }
             foreach ($aChildrens as $iForumid) {
                 Phpfox::getService('forum.thread.process')->markRead($iForumid);
             }
         }
         $this->url()->send('forum', null, Phpfox::getPhrase('forum.forum_successfully_marked_as_read'));
     }
 }
Пример #5
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;
	}
Пример #6
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;
	}
Пример #7
0
 /**
  * Controller
  */
 public function process()
 {
     if ($iCommentId = $this->request()->getInt('req3')) {
         $aComment = Phpfox::getService('comment')->getComment($iCommentId);
         if (!isset($aComment['comment_id'])) {
             return Phpfox_Error::display(Phpfox::getPhrase('comment.comment_does_not_exist'));
         }
         if (Phpfox::hasCallback('comment', 'getRedirectRequest')) {
             $this->url()->forward(Phpfox::callback('comment.getRedirectRequest', $aComment['comment_id']));
         }
         if (Phpfox::hasCallback($aComment['type_id'], 'getParentItemCommentUrl')) {
             $sNewUrl = Phpfox::callback($aComment['type_id'] . '.getParentItemCommentUrl', $aComment);
             if ($sNewUrl !== false) {
                 $aComment['callback_url'] = $sNewUrl;
             }
         }
         $this->template()->setTitle(Phpfox::getPhrase('comment.viewing_comment'))->setHeader(array('view.css' => 'module_comment'))->setBreadcrumb(Phpfox::getPhrase('comment.viewing_comment'))->assign(array('aComment' => $aComment));
     } else {
         $aComment = Phpfox::getService('comment')->getComment($this->request()->getInt('id'));
         if (!isset($aComment['comment_id'])) {
             return Phpfox_Error::display(Phpfox::getPhrase('comment.comment_does_not_exist'));
         }
         $this->url()->forward(Phpfox::callback('comment.getRedirectRequest', $aComment['comment_id']));
     }
 }
Пример #8
0
 public function add($aRating)
 {
     Phpfox::isUser(true);
     if (!is_array($aRating)) {
         return Phpfox_Error::set(Phpfox::getPhrase('rate.not_a_valid_post'));
     }
     $sModule = $aRating['type'];
     $sExtra = '';
     if (strpos($aRating['type'], '_')) {
         $aParts = explode('_', $aRating['type']);
         $sModule = $aParts[0];
         $sExtra = ucfirst($aParts[1]);
     }
     $aCallback = Phpfox::callback($sModule . '.getRatingData' . $sExtra, $aRating['item_id']);
     $aRow = $this->database()->select($aCallback['field'] . ', user_id')->from(Phpfox::getT(isset($aCallback['check_table']) ? $aCallback['check_table'] : $aCallback['table']))->where($aCallback['field'] . ' = ' . (int) $aRating['item_id'])->execute('getSlaveRow');
     if (!isset($aRow[$aCallback['field']])) {
         return Phpfox_Error::set(Phpfox::getPhrase('rate.not_a_valid_item_to_rate'));
     }
     if ($aRow['user_id'] == Phpfox::getUserId()) {
         return Phpfox_Error::set(Phpfox::getPhrase('rate.sorry_you_are_not_able_to_rate_your_own_item'));
     }
     $iIsRated = $this->database()->select('COUNT(*)')->from(Phpfox::getT($aCallback['table_rating']))->where('item_id = ' . (int) $aRating['item_id'] . ' AND user_id = ' . Phpfox::getUserId())->execute('getSlaveField');
     if (!$iIsRated) {
         $aParts = explode('|', $aRating['star']);
         $iId = $this->database()->insert(Phpfox::getT($aCallback['table_rating']), array('item_id' => $aRating['item_id'], 'user_id' => Phpfox::getUserId(), 'rating' => (int) $aParts[0], 'time_stamp' => PHPFOX_TIME));
         $aAverage = $this->database()->select('COUNT(*) AS count, AVG(rating) AS average_rating')->from(Phpfox::getT($aCallback['table_rating']))->where('item_id = ' . (int) $aRating['item_id'])->execute('getRow');
         $this->database()->update(Phpfox::getT($aCallback['table']), array('total_score' => round($aAverage['average_rating']), 'total_rating' => $aAverage['count']), $aCallback['field'] . ' = ' . (int) $aRating['item_id']);
         return $iId;
     }
     return Phpfox_Error::set(Phpfox::getPhrase('rate.you_have_already_voted_on_this_item'));
 }
Пример #9
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     $sUrl = Phpfox::callback($this->request()->get('req3') . '.getRedirectRequest', $this->request()->get('id'));
     if ($sUrl === false) {
         return Phpfox_Error::display(Phpfox::getPhrase('request.invalid_request_redirect'));
     }
     $this->url()->forward($sUrl);
 }
Пример #10
0
	public function delete($sType, $iItemId)
	{
		$this->database()->delete(Phpfox::getT('like'), 'type_id = \'' . $this->database()->escape($sType) . '\' AND item_id = ' . (int) $iItemId . ' AND user_id = ' . Phpfox::getUserId());
		
		Phpfox::callback($sType . '.deleteLike', $iItemId);
		
		return true;	
	}
Пример #11
0
 /**
  * Handles API callback for payment gateways.
  *
  * @param array $aParams ARRAY of params passed from the payment gateway after a payment has been made.
  * @return bool|null FALSE if payment is not valid|Nothing returned if everything went well.
  */
 public function paymentApiCallback($aParams)
 {
     Phpfox::log('Module callback recieved: ' . var_export($aParams, true));
     Phpfox::log('Attempting to retrieve purchase from the database');
     define('PHPFOX_API_CALLBACK', true);
     // used to override security checks in the processes
     if (preg_match('/sponsor/i', $aParams['item_number'])) {
         // we get the sponsored ad
         $iId = preg_replace("/[^0-9]/", '', $aParams['item_number']);
         Phpfox::log('Ad is sponsored');
         $aInvoice = $this->database()->select('*')->from(Phpfox::getT('ad_invoice'))->where('invoice_id = ' . $iId . ' AND is_sponsor = 1')->execute('getSlaveRow');
         $aAd = Phpfox::getService('ad')->getSponsor($aInvoice['ad_id']);
     } else {
         $aAd = Phpfox::getService('ad')->getForEdit($aParams['item_number']);
         $aInvoice = Phpfox::getService('ad')->getInvoice($aAd['ad_id']);
     }
     if (empty($aAd) || $aAd === false) {
         Phpfox::log('Purchase is not valid');
         return false;
     }
     if (empty($aInvoice) || $aInvoice === false) {
         Phpfox::log('Not a valid invoice');
         return false;
     }
     Phpfox::log('Purchase is valid: ' . var_export($aInvoice, true));
     if ($aParams['status'] == 'completed') {
         if ($aParams['total_paid'] == $aInvoice['price']) {
             Phpfox::log('Paid correct price');
         } else {
             Phpfox::log('Paid incorrect price');
             return false;
         }
     } else {
         Phpfox::log('Payment is not marked as "completed".');
         return false;
     }
     Phpfox::log('Handling purchase');
     $this->database()->update(Phpfox::getT('ad_invoice'), array('status' => $aParams['status'], 'time_stamp_paid' => PHPFOX_TIME), 'invoice_id = ' . $aInvoice['invoice_id']);
     if (isset($aAd['auto_publish'])) {
         // its a sponsor ad
         $this->database()->update(Phpfox::getT('ad_sponsor'), array('is_custom' => $aAd['auto_publish'] == 1 ? '3' : '2', 'is_active' => $aAd['auto_publish'] == 1 ? '1' : '0'), 'sponsor_id = ' . $aAd['sponsor_id']);
         if ($aAd['auto_publish'] == 1) {
             $sModule = $aAd['module_id'];
             $sSection = '';
             if (strpos($sModule, '-') !== false) {
                 $aModule = explode('-', $sModule);
                 $sModule = $aModule[0];
                 $sSection = $aModule[1];
             }
             Phpfox::callback($sModule . '.enableSponsor', array('item_id' => $aAd['item_id'], 'section' => $sSection));
         }
     } else {
         $this->database()->update(Phpfox::getT('ad'), array('is_custom' => '2'), 'ad_id = ' . $aAd['ad_id']);
     }
     $this->cache()->remove('ad', 'substr');
     Phpfox::log('Handling complete');
 }
Пример #12
0
 public function process()
 {
     Phpfox::getLib('setting')->setParam(array('profiles.url_image' => Phpfox::getParam('core.url_pic') . 'profiles/'));
     $mUser = $this->request()->get('req2');
     $sSection = $this->request()->get('req3');
     $bIsPublicItemView = false;
     if (Phpfox::isPublicView()) {
         if (!empty($sSection) && Phpfox::isModule($sSection) && $sSection != 'designer' && Phpfox::hasCallback($sSection, 'getItemView') && Phpfox::callback($sSection . '.getItemView') === true) {
             $bIsPublicItemView = true;
         }
     }
     if (!$mUser) {
         if (Phpfox::isUser()) {
             $this->url()->send('profile');
         } else {
             Phpfox::isUser(true);
         }
     }
     // If we are unable to find a user lets make sure we return a 404 page not found error
     $aExtraProfile = Phpfox::getService('profiles')->getProfile($mUser);
     if (count($aExtraProfile) == 0) {
         return Phpfox::getLib('module')->setController('error.404');
     }
     $aUser = Phpfox::getService('user')->get($aExtraProfile['user_id']);
     $this->setParam('aExtraProfile', $aExtraProfile);
     $this->template()->assign(array('aExtraProfile' => $aExtraProfile));
     if (Phpfox::getService('user.block')->isBlocked($aExtraProfile['user_id'], Phpfox::getUserId()) && !Phpfox::getUserParam('user.can_override_user_privacy')) {
         $this->url()->send($aUser['user_name']);
     }
     if (!Phpfox::getService('user.privacy')->hasAccess($aExtraProfile['user_id'], 'profile.view_profile')) {
         $this->url()->send($aUser['user_name']);
     }
     //This is where I want to add $this->request()->get('req3') == gallery
     if (!empty($sSection) && $sSection == 'photo') {
         Phpfox::getLib('module')->setController('profiles.view');
     }
     Phpfox::getUserParam('profile.can_view_users_profile', true);
     $this->template()->setHeader('cache', array('profile.css' => 'style_css', 'feed.js' => 'module_feed'));
     $this->template()->setMeta('description', Phpfox::getPhrase('profiles.meta_description', array('extra_name' => $aExtraProfile['title'], 'site_title' => Phpfox::getParam('core.site_title'), 'meta_description_profile' => Phpfox::getParam('core.meta_description_profile'))));
     $sPageTitle = $aExtraProfile['title'];
     $this->setParam('aFeed', array('comment_type_id' => 'profiles', 'privacy' => 0, 'comment_privacy' => 0, 'item_id' => $aExtraProfile['extra_id'], 'like_type_id' => 'profiles', 'feed_is_liked' => isset($aExtraProfile['is_liked']) ? $aExtraProfile['is_liked'] : false, 'user_id' => $aExtraProfile['user_id'], 'total_comment' => $aExtraProfile['total_comment'], 'total_like' => 0, 'feed_link' => $this->url()->makeUrl('profiles', $aExtraProfile['title_url']), 'feed_title' => $aExtraProfile['title'], 'feed_display' => 'view', 'report_module' => 'profiles', 'report_phrase' => Phpfox::getPhrase('profiles.report_this_profile')));
     if ($this->request()->get('req3') != 'photo') {
         $this->template()->setBreadcrumb($sPageTitle, Phpfox::getLib('url')->makeUrl('profiles.browse'));
     } elseif ($this->request()->get('req3') == '') {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('profiles.extra_profiles'), Phpfox::getLib('url')->makeUrl('profiles.browse'));
     }
     $this->template()->setTitle($sPageTitle)->setEditor(array('load' => 'simple', 'wysiwyg' => Phpfox::isModule('comment') && Phpfox::getParam('comment.wysiwyg_comments') && Phpfox::getUserParam('comment.wysiwyg_on_comments')))->setUrl('profiles')->setHeader('cache', array('comment.css' => 'style_css', 'pager.css' => 'style_css', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script'));
     if ($this->request()->get('update')) {
         $this->template()->setHeader('<script type="text/javascript">window.parent.tb_remove();</script>');
     }
     if ($sPlugin = Phpfox_Plugin::get('profiles.component_controller_index_end')) {
         eval($sPlugin);
         if (isset($mReturnFromPlugin)) {
             return $mReturnFromPlugin;
         }
     }
 }
Пример #13
0
 public function getRedirect($iId)
 {
     $aReport = $this->database()->select('data_id, item_id')->from(Phpfox::getT('report_data'))->where('data_id = ' . (int) $iId)->execute('getRow');
     if (!isset($aReport['data_id'])) {
         return Phpfox_Error::set(Phpfox::getPhrase('report.not_a_valid_report'));
     }
     $aParts = explode('_', $aReport['item_id']);
     return Phpfox::callback($aParts[0] . '.getReportRedirect' . (isset($aParts[2]) ? ucfirst($aParts[1]) : ''), $aParts[count($aParts) - 1]);
 }
Пример #14
0
 public function add($aVals, $aCallback = false, $aExtra = array())
 {
     $aThread = $this->database()->select('*')->from(Phpfox::getT('forum_thread'))->where('thread_id = ' . (int) $aVals['thread_id'])->execute('getSlaveRow');
     if ($aThread['group_id'] > 0) {
         $aCallback = Phpfox::callback('pages.addForum', $aThread['group_id']);
     }
     $oParseInput = Phpfox::getLib('parse.input');
     $bHasAttachments = Phpfox::getUserParam('forum.can_add_forum_attachments') && Phpfox::isModule('attachment') && isset($aVals['attachment']) && !empty($aVals['attachment']);
     $bApprovePost = Phpfox::getUserParam('forum.approve_forum_post') && $aCallback === false ? true : false;
     Phpfox::getService('ban')->checkAutomaticBan((isset($aVals['title']) && !empty($aVals['title']) ? $aVals['title'] : '') . ' ' . $aVals['text']);
     $iId = $this->database()->insert(Phpfox::getT('forum_post'), array('thread_id' => $aVals['thread_id'], 'view_id' => $bApprovePost ? '1' : '0', 'user_id' => isset($aExtra['user_id']) ? $aExtra['user_id'] : Phpfox::getUserId(), 'title' => empty($aVals['title']) ? '' : $oParseInput->clean($aVals['title'], 255), 'total_attachment' => $bHasAttachments ? Phpfox::getService('attachment')->getCount($aVals['attachment']) : 0, 'time_stamp' => isset($aExtra['user_id']) ? $aExtra['time_stamp'] : PHPFOX_TIME));
     $this->database()->insert(Phpfox::getT('forum_post_text'), array('post_id' => $iId, 'text' => $oParseInput->clean($aVals['text']), 'text_parsed' => $oParseInput->prepare($aVals['text'])));
     if (!$bApprovePost) {
         if ($aCallback === false) {
             if (empty($aVals['forum_id'])) {
                 $aVals['forum_id'] = $aThread['forum_id'];
             }
             foreach (Phpfox::getService('forum')->id($aVals['forum_id'])->getParents() as $iForumid) {
                 $this->database()->update(Phpfox::getT('forum'), array('thread_id' => $aVals['thread_id'], 'post_id' => $iId, 'last_user_id' => isset($aExtra['user_id']) ? $aExtra['user_id'] : Phpfox::getUserId()), 'forum_id = ' . $iForumid);
                 Phpfox::getService('forum.process')->updateCounter($iForumid, 'total_post');
             }
         }
         $this->database()->update(Phpfox::getT('forum_thread'), array('total_post' => array('= total_post +', 1), 'post_id' => $iId, 'time_update' => isset($aExtra['user_id']) ? $aExtra['time_stamp'] : PHPFOX_TIME, 'last_user_id' => isset($aExtra['user_id']) ? $aExtra['user_id'] : Phpfox::getUserId()), 'thread_id = ' . (int) $aVals['thread_id']);
         if ($this->_bUpdateCounter) {
             Phpfox::getService('user.field.process')->updateCounter(Phpfox::getUserId(), 'total_post');
         }
     }
     // If we uploaded any attachments make sure we update the 'item_id'
     if ($bHasAttachments) {
         Phpfox::getService('attachment.process')->updateItemId($aVals['attachment'], isset($aExtra['user_id']) ? $aExtra['user_id'] : Phpfox::getUserId(), $iId);
     }
     if (!$bApprovePost) {
         // Update user activity
         Phpfox::getService('user.activity')->update(isset($aExtra['user_id']) ? $aExtra['user_id'] : Phpfox::getUserId(), 'forum');
     }
     if (isset($aVals['is_subscribed']) && $aVals['is_subscribed']) {
         Phpfox::getService('forum.subscribe.process')->add($aVals['thread_id'], isset($aExtra['user_id']) ? $aExtra['user_id'] : Phpfox::getUserId());
     } else {
         Phpfox::getService('forum.subscribe.process')->delete($aVals['thread_id'], isset($aExtra['user_id']) ? $aExtra['user_id'] : Phpfox::getUserId());
     }
     if (empty($aExtra) && !$bApprovePost) {
         Phpfox::getService('forum.subscribe')->sendEmails($aVals['thread_id'], $iId);
         $aThread = Phpfox::getService('forum.thread')->getActualThread($aVals['thread_id']);
         if (!Phpfox::getService('forum')->isPrivateForum($aThread['forum_id'])) {
             if (Phpfox::isModule('feed') && !defined('PHPFOX_SKIP_FEED_ENTRY')) {
                 Phpfox::getService('feed.process')->callback($aCallback)->add('forum_post', $iId, 0, 0, $aCallback === false ? 0 : $aCallback['item']);
             }
         }
     }
     if ($sPlugin = Phpfox_Plugin::get('forum.service_post_process_add_1')) {
         eval($sPlugin);
     }
     if ($bApprovePost) {
         return false;
     }
     return $iId;
 }
Пример #15
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     if (Phpfox::getParam('video.convert_servers_secret') != $this->request()->get('_v_secret')) {
         $this->p('Secret does not match', true);
     } else {
         if ($this->request()->get('_v_action')) {
             switch ($this->request()->get('_v_action')) {
                 case 'completed':
                     $iCnt = 0;
                     foreach (Phpfox::getParam('video.convert_servers') as $sServer) {
                         $iCnt++;
                         if (md5($sServer) == $this->request()->get('url')) {
                             break;
                         }
                     }
                     $sDest = '{' . $iCnt . '}' . $this->request()->get('name');
                     $aVideo = Phpfox::getLib('database')->select('*')->from(Phpfox::getT('video'))->where('custom_v_id = ' . (int) $this->request()->get('id'))->execute('getSlaveRow');
                     if (isset($aVideo['video_id'])) {
                         $aCallback = null;
                         if ($aVideo['module_id'] != 'video' && Phpfox::hasCallback($aVideo['module_id'], 'convertVideo')) {
                             $aCallback = Phpfox::callback($aVideo['module_id'] . '.convertVideo', $aVideo);
                         }
                         Phpfox::isModule('feed') ? Phpfox::getService('feed.process')->callback($aCallback)->allowGuest()->add('video', $aVideo['video_id'], $aVideo['privacy'], $aVideo['privacy_comment'], $aVideo['item_id'], $aVideo['user_id']) : null;
                         Phpfox::getLib('database')->update(Phpfox::getT('video'), array('in_process' => '0', 'destination' => $sDest, 'image_path' => $sDest . '.jpg'), 'custom_v_id = ' . (int) $this->request()->get('id'));
                         $bUpdatePoints = $aVideo['module_id'] == 'video' ? Phpfox::getUserParam('video.approve_video_before_display') ? false : true : true;
                         if ($bUpdatePoints === true) {
                             // Update user activity
                             Phpfox::getService('user.activity')->update($aVideo['user_id'], 'video');
                         }
                     }
                     break;
                 case 'canUpload':
                     // Will add security checks later
                     if (Phpfox::getService('video')->checkCustomHash($this->request()->get('hash_id'))) {
                         $this->p('All is good.');
                     } else {
                         $this->p('No token set for this upload.', true);
                     }
                     break;
                 case 'getSettings':
                     $aSettings = array();
                     $aParams = array('video.covert_mp4_exec', 'video.covert_webm_exec', 'video.covert_ogg_exec', 'video.covert_mp4_image');
                     foreach ($aParams as $sParam) {
                         $aSettings[$sParam] = Phpfox::getParam($sParam);
                     }
                     $this->p($aSettings);
                     break;
             }
         } else {
             $this->p('No action provided', true);
         }
     }
     $this->output();
     exit;
 }
Пример #16
0
 /**
  * This function checks if a user is allowed to update the URL of a specific blog
  */
 public function canUpdateURL($sModule, $iUser, $iItemId)
 {
     // first the general permission
     if (!Phpfox::isModule($sModule) || Phpfox::getUserParam($sModule . '.can_update_url') == false || !Phpfox::hasCallback($sModule, 'getRedirectionTable')) {
         return false;
     }
     $iCnt = $this->database()->select('COUNT(*)')->from(Phpfox::callback($sModule . '.getRedirectionTable'))->where('item_id = ' . (int) $iItemId)->execute('getSlaveField');
     if ($iCnt >= Phpfox::getUserParam($sModule . '.how_many_url_updates') && $iCnt > 0 && Phpfox::getUserParam($sModule . '.how_many_url_updates') > 0) {
         return false;
     }
     return true;
 }
Пример #17
0
 public function loadProfileBlock()
 {
     die('sdsdg');
     exit;
     $sProfileUrl = str_replace('profile_', '', $this->get('url'));
     if ($this->get('url') == 'profile_info') {
         $sProfileUrl = 'profile';
     }
     if (!Phpfox::isModule($sProfileUrl)) {
         Phpfox_Error::set('Trying to load an invalid module.');
     } else {
         if (!Phpfox::hasCallback($sProfileUrl, 'getAjaxProfileController')) {
             Phpfox_Error::set('Unable to load the section you are looking for.');
         }
     }
     if (Phpfox_Error::isPassed()) {
         $oModule = Phpfox::getLib('module');
         $oTpl = Phpfox::getLib('template');
         $oTpl->assign(array('bIsAjaxLoader' => true));
         $aStyleInUse = $oTpl->getStyleInUse();
         $oModule->loadBlocks();
         $aUrlParams = array($this->get('user_name'));
         if ($this->get('url') != 'profile') {
             $aUrlParams[] = str_replace('profile_', '', $this->get('url'));
         }
         Phpfox::getLib('url')->setParam($aUrlParams);
         $oModule->setController(Phpfox::callback($sProfileUrl . '.getAjaxProfileController'));
         if ($aStyleInUse['total_column'] == '3') {
             $oTpl->assign(array('aBlocks1' => $oTpl->bIsSample ? true : Phpfox::getLib('module')->getModuleBlocks(1), 'aBlocks3' => $oTpl->bIsSample ? true : Phpfox::getLib('module')->getModuleBlocks(3), 'aAdBlocks1' => $oTpl->bIsSample ? true : (Phpfox::isModule('ad') ? Phpfox::getService('ad')->getForBlock(1) : null), 'aAdBlocks3' => $oTpl->bIsSample ? true : (Phpfox::isModule('ad') ? Phpfox::getService('ad')->getForBlock(3) : null)));
         } else {
             $oTpl->assign(array('aBlocks1' => array(), 'aBlocks3' => array(), 'aAdBlocks1' => array(), 'aAdBlocks3' => array()));
         }
         $oTpl->assign(array('sPublicMessage' => Phpfox::getMessage(), 'aErrors' => Phpfox_Error::getDisplay() ? Phpfox_Error::get() : array(), 'aStyleInUse' => $aStyleInUse));
         list($aBreadCrumbs, $aBreadCrumbTitle) = $oTpl->getBreadCrumb();
         $this->remove('#js_temp_breadcrumb');
         if (count($aBreadCrumbs)) {
             foreach ($aBreadCrumbs as $sLink => $sPhrase) {
                 $this->append('h1', '<span id="js_temp_breadcrumb"><span class="profile_breadcrumb">&#187;</span><a href="' . $sLink . '">' . $sPhrase . '</a></span>');
                 break;
             }
         }
         $oTpl->getLayout($oTpl->sDisplayLayout);
         $this->html($aStyleInUse['total_column'] == '3' ? '#content_load_data' : '#content', $this->getContent(false));
         if ($this->get('url') == 'profile_info') {
             $this->call('$Core.loadProfileInfo();');
         }
     } else {
         $this->html('#js_profile_block_view_data_' . $this->get('url'), implode('', Phpfox_Error::get()));
     }
     $this->call('$Core.loadInit();');
 }
Пример #18
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     $aPage = $this->getParam('aPage');
     if (!isset($aPage['page_id'])) {
         return false;
     }
     if (isset($aPage['use_timeline']) && $aPage['use_timeline']) {
         return false;
     }
     if ($this->getParam('bIsPagesViewSection')) {
         $aMenus = Phpfox::callback($this->getParam('sCurrentPageModule') . '.getPageSubMenu', $aPage);
         $this->template()->assign(array('aSubPageMenus' => $aMenus));
     }
 }
Пример #19
0
 public function delete($iId, $sModule = '')
 {
     Phpfox::isUser(true);
     Phpfox::getUserParam('shoutbox.can_delete_all_shoutbox_messages', true);
     $sTable = 'shoutbox';
     if (!empty($sModule) && Phpfox::hasCallback($sModule, 'getShoutboxData')) {
         $aCallback = Phpfox::callback($sModule . '.getShoutboxData');
         if (isset($aCallback['table'])) {
             $sTable = $aCallback['table'];
         }
     }
     $this->database()->delete(Phpfox::getT($sTable), 'shout_id = ' . (int) $iId);
     return true;
 }
 public function testApiCallback2Checkout()
 {
     $aPackageVals = array('package_name' => 'Test', 'package_description' => 'Test des', 'package_price' => 100, 'package_benefit_number' => 100, 'package_benefit_type_id' => Phpfox::getService('socialad.helper')->getConst('package.benefit.click', 'id'), 'package_currency' => 'USD', 'package_last_edited_time' => PHPFOX_TIME, 'package_is_active' => 1);
     $iPackageId = Phpfox::getService('socialad.package.process')->handleSubmitForm($aPackageVals);
     $aAdVals = array('ad_id' => 1989, 'audience_gender' => 1, 'placement_block_id' => 3, 'ad_package_id' => $iPackageId);
     $iAdId = Phpfox::getService('unittest.test.socialad')->insertTestAd($aAdVals);
     $iMethodId = Phpfox::getService("socialad.helper")->getConst("transaction.method.paypal", "id");
     $aResult = Phpfox::getService('socialad.payment')->startPayment($iAdId, $iMethodId);
     $iTransactionId = $aResult['transaction_id'];
     $aVals = array('gateway' => 'paypal', 'status' => 'pending', 'total_paid' => 100, 'custom' => $iTransactionId);
     Phpfox::callback('socialad.paymentApiCallback', $aVals);
     $aTransaction = Phpfox::getService('socialad.payment')->getTransactionById($iTransactionId);
     $this->assertEquals($aTransaction['transaction_status_id'], Phpfox::getService('socialad.helper')->getConst("transaction.status.pending"));
 }
Пример #21
0
 /**
  * Add link
  * @param $aVals
  * @param $sUrl
  * @param $aLink
  * @return bool
  */
 public function add($aVals, $sUrl, $aLink)
 {
     $aCallback = null;
     if (isset($aVals['callback_module']) && Phpfox::hasCallback($aVals['callback_module'], 'addLink')) {
         $aCallback = Phpfox::callback($aVals['callback_module'] . '.addLink', $aVals);
     }
     $aVals['link'] = $aLink;
     $aVals['link']['url'] = $sUrl;
     $aVals['link']['image'] = $aLink['default_image'];
     if ($iId = Phpfox::getService('link.process')->add($aVals, false, $aCallback)) {
         return $iId;
     }
     return false;
 }
Пример #22
0
 public function process()
 {
     Phpfox::getLib('setting')->setParam(array('profiles.url_image' => Phpfox::getParam('core.url_pic') . 'profiles/'));
     $mUser = $this->request()->get('req2');
     $sSection = $this->request()->get('req3');
     $bIsPublicItemView = false;
     if (Phpfox::isPublicView()) {
         if (!empty($sSection) && Phpfox::isModule($sSection) && $sSection != 'designer' && Phpfox::hasCallback($sSection, 'getItemView') && Phpfox::callback($sSection . '.getItemView') === true) {
             $bIsPublicItemView = true;
         }
     }
     if (!$mUser) {
         if (Phpfox::isUser()) {
             $this->url()->send('profile');
         } else {
             Phpfox::isUser(true);
         }
     }
     $aExtraProfile = Phpfox::getService('profiles')->getProfile($mUser);
     if (count($aExtraProfile) == 0) {
         return Phpfox::getLib('module')->setController('error.404');
     }
     $aUser = Phpfox::getService('user')->get($aExtraProfile['user_id']);
     $this->setParam('aExtraProfile', $aExtraProfile);
     $this->template()->assign(array('aExtraProfile' => $aExtraProfile));
     if (Phpfox::getService('user.block')->isBlocked($aExtraProfile['user_id'], Phpfox::getUserId()) && !Phpfox::getUserParam('user.can_override_user_privacy')) {
         $this->url()->send($aUser['user_name']);
     }
     if (!Phpfox::getService('user.privacy')->hasAccess($aExtraProfile['user_id'], 'profile.view_profile')) {
         $this->url()->send($aUser['user_name']);
     }
     if (!empty($sSection) && $sSection == 'photo') {
         $this->setParam('aParentModule', array('module_id' => 'profiles', 'item_id' => $aExtraProfile['extra_id'], 'url' => $this->url()->makeUrl('profiles', $aExtraProfile['title_url'])));
         $this->template()->setTitle($aExtraProfile['title'])->setBreadcrumb($aExtraProfile['title'], $this->url()->makeUrl('profiles', $aExtraProfile['title_url']));
         $this->url()->aRewrite['photo/add/'] = 'profiles/redirect/photo/add/' . $aExtraProfile['extra_id'];
         $this->url()->aReverseRewrite['profiles/redirect/photo/add/' . $aExtraProfile['extra_id']] = 'photo/add/';
     }
     Phpfox::getUserParam('profile.can_view_users_profile', true);
     $this->template()->setHeader('cache', array('profile.css' => 'style_css', 'feed.js' => 'module_feed'));
     $this->template()->setMeta('description', Phpfox::getPhrase('profiles.meta_description', array('extra_name' => $aExtraProfile['title'], 'site_title' => Phpfox::getParam('core.site_title'), 'meta_description_profile' => Phpfox::getParam('core.meta_description_profile'))));
     $sPageTitle = $aExtraProfile['title'];
     $this->setParam('aFeed', array('comment_type_id' => 'profiles', 'privacy' => 0, 'comment_privacy' => 0, 'item_id' => $aExtraProfile['extra_id'], 'like_type_id' => 'profiles', 'feed_is_liked' => isset($aExtraProfile['is_liked']) ? $aExtraProfile['is_liked'] : false, 'user_id' => $aExtraProfile['user_id'], 'total_comment' => $aExtraProfile['total_comment'], 'total_like' => 0, 'feed_link' => $this->url()->makeUrl('profiles', $aExtraProfile['title_url']), 'feed_title' => $aExtraProfile['title'], 'feed_display' => 'view', 'report_module' => 'profiles', 'report_phrase' => Phpfox::getPhrase('profiles.report_this_profile')));
     $this->template()->setTitle($sPageTitle)->setEditor(array('load' => 'simple', 'wysiwyg' => Phpfox::isModule('comment') && Phpfox::getParam('comment.wysiwyg_comments') && Phpfox::getUserParam('comment.wysiwyg_on_comments')))->setUrl('profiles')->setHeader('cache', array('comment.css' => 'style_css', 'pager.css' => 'style_css', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script'));
     if ($this->request()->get('update')) {
         $this->template()->setHeader('<script type="text/javascript">window.parent.tb_remove();</script>');
     }
     Phpfox::getComponent('photo.index', array('bNoTemplate' => true), 'controller');
     $this->setParam('global_moderation', array('name' => 'photo', 'ajax' => 'profiles.moderation', 'menu' => array(array('phrase' => Phpfox::getPhrase('photo.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('photo.approve'), 'action' => 'approve'))));
 }
Пример #23
0
 /**
  * Controller
  */
 public function process()
 {
     if (Phpfox::getParam('tag.enable_hashtag_support')) {
         return false;
     }
     if (!defined('PHPFOX_TAG_PARENT_MODULE')) {
         define('PHPFOX_TAG_PARENT_MODULE', $this->getParam('sTagListParentModule', null));
     }
     if (!defined('PHPFOX_TAG_PARENT_ID')) {
         define('PHPFOX_TAG_PARENT_ID', $this->getParam('iTagListParentId', 0));
     }
     $this->template()->assign('sMicroKeywords', $this->getParam('sMicroKeywords'));
     if ($sType = $this->getParam('type')) {
         $aUser = $this->getParam('aUser');
         $sLink = Phpfox::callback($sType . '.getTagLink', $aUser);
         $iItemId = $this->getParam('item_id');
         $sTags = '';
         $sTagsClean = '';
         $aMainTags = Tag_Service_Tag::instance()->getTagsById($sType, $iItemId);
         if (!isset($aMainTags[$iItemId])) {
             return false;
         }
         foreach ($aMainTags[$iItemId] as $iKey => $aTag) {
             $aMainTags[$iItemId][$iKey]['tag_url'] = $sLink . $aTag['tag_url'] . '/';
             $sTags .= ', <a href="' . $aMainTags[$iItemId][$iKey]['tag_url'] . '">' . $aTag['tag_text'] . '</a>';
             $sTagsClean .= ', ' . $aTag['tag_text'];
         }
         $sTags = ltrim($sTags, ',');
         $sTagsClean = ltrim($sTagsClean, ',');
         $this->template()->assign(array('sLink' => $sLink, 'sType' => Phpfox::callback($sType . '.getTagType'), 'sTags' => $sTags, 'sMainTags' => $sTagsClean, 'aTags' => $aMainTags[$iItemId], 'iItemId' => $this->getParam('iItemId'), 'iUserId' => $this->getParam('iUserId'), 'bIsInline' => $this->getParam('bIsInline'), 'bDontCleanTags' => $this->getParam('bDontCleanTags')));
     } else {
         if (!($sType = $this->getParam('sType'))) {
             return Phpfox_Error::trigger(Phpfox::getPhrase('tag.missing_param_stype'), E_USER_ERROR);
         }
         $aUser = $this->getParam('aUser');
         $sLink = Phpfox::callback($sType . '.getTagLink', $aUser);
         $aMainTags = $this->getParam('sTags');
         $sTags = '';
         $sTagsClean = '';
         foreach ($aMainTags as $iKey => $aTag) {
             $aMainTags[$iKey]['tag_url'] = $sLink . $aTag['tag_url'] . '/';
             $sTags .= ', <a href="' . $aMainTags[$iKey]['tag_url'] . '">' . $aTag['tag_text'] . '</a>';
             $sTagsClean .= ', ' . $aTag['tag_text'];
         }
         $sTags = ltrim($sTags, ',');
         $sTagsClean = ltrim($sTagsClean, ',');
         $this->template()->assign(array('sLink' => $sLink, 'sType' => Phpfox::callback($sType . '.getTagType'), 'sTags' => $sTags, 'sMainTags' => $sTagsClean, 'aTags' => $aMainTags, 'iItemId' => $this->getParam('iItemId'), 'iUserId' => $this->getParam('iUserId'), 'bIsInline' => $this->getParam('bIsInline'), 'bDontCleanTags' => $this->getParam('bDontCleanTags')));
     }
 }
Пример #24
0
 public function getLatestUsers($sType, $iId, $iUserId)
 {
     if (Phpfox::getParam('track.cache_recently_viewed_by_timeout') > 0) {
         $sCacheId = $this->cache()->set(array('track', $sType . '_' . $iId));
         if (!($aTracks = $this->cache()->get($sCacheId, Phpfox::getParam('track.cache_recently_viewed_by_timeout') * 60))) {
             $aTracks = Phpfox::callback($sType . '.getLatestTrackUsers', $iId, $iUserId);
             $this->cache()->save($sCacheId, $aTracks);
         }
         if (is_bool($aTracks)) {
             $aTracks = array();
         }
         return $aTracks;
     }
     return Phpfox::callback($sType . '.getLatestTrackUsers', $iId, $iUserId);
 }
Пример #25
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     Phpfox::getUserParam('music.can_access_music', true);
     if (Phpfox::isUser() && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('comment_music_album', $this->request()->getInt('req3'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('music_song_album', $this->request()->getInt('req3'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('music_album_like', $this->request()->getInt('req3'), Phpfox::getUserId());
     }
     $aAlbum = Phpfox::getService('music.album')->getAlbum($this->request()->getInt('req3'));
     if (!isset($aAlbum['album_id'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('music.unable_to_find_the_album_you_are_looking_for'));
     }
     $aCallback = false;
     if (!empty($aAlbum['module_id'])) {
         if ($aCallback = Phpfox::callback($aAlbum['module_id'] . '.getMusicDetails', $aAlbum)) {
             $this->template()->setBreadcrumb($aCallback['breadcrumb_title'], $aCallback['breadcrumb_home']);
             $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
             // FUDGE Lovinity October 18, 2015: Forbid viewing of album if user is blocked
             $bIsBlocked = Phpfox::getService('user.block')->isBlocked($aAlbum['user_id'], Phpfox::getUserId());
             $bIsBlocked2 = Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $aAlbum['user_id']);
             if ($aAlbum['module_id'] == 'pages' && (!Phpfox::getService('pages')->hasPerm($aCallback['item_id'], 'music.view_browse_music') || $bIsBlocked || $bIsBlocked2)) {
                 return Phpfox_Error::display(Phpfox::getPhrase('music.unable_to_view_this_item_due_to_privacy_settings'));
             }
             // END FUDGE
         }
     }
     Phpfox::getService('core.redirect')->check($aAlbum['name'], 'req4');
     if (Phpfox::isModule('privacy')) {
         Phpfox::getService('privacy')->check('music_album', $aAlbum['album_id'], $aAlbum['user_id'], $aAlbum['privacy'], $aAlbum['is_friend']);
     }
     $this->setParam('aAlbum', $aAlbum);
     $this->setParam('aRatingCallback', array('type' => 'music_album', 'total_rating' => Phpfox::getPhrase('music.total_rating_ratings', array('total_rating' => $aAlbum['total_rating'])), 'default_rating' => $aAlbum['total_score'], 'item_id' => $aAlbum['album_id'], 'stars' => array('2' => Phpfox::getPhrase('music.poor'), '4' => Phpfox::getPhrase('music.nothing_special'), '6' => Phpfox::getPhrase('music.worth_listening_too'), '8' => Phpfox::getPhrase('music.pretty_cool'), '10' => Phpfox::getPhrase('music.awesome'))));
     $this->setParam('aFeed', array('comment_type_id' => 'music_album', 'privacy' => $aAlbum['privacy'], 'comment_privacy' => $aAlbum['privacy_comment'], 'like_type_id' => 'music_album', 'feed_is_liked' => $aAlbum['is_liked'], 'feed_is_friend' => $aAlbum['is_friend'], 'item_id' => $aAlbum['album_id'], 'user_id' => $aAlbum['user_id'], 'total_comment' => $aAlbum['total_comment'], 'total_like' => $aAlbum['total_like'], 'feed_link' => $this->url()->permalink('music.album', $aAlbum['album_id'], $aAlbum['name']), 'feed_title' => $aAlbum['name'], 'feed_display' => 'view', 'feed_total_like' => $aAlbum['total_like'], 'report_module' => 'music_album', 'report_phrase' => Phpfox::getPhrase('music.report_this_album')));
     $this->setParam(array('album_user_id' => $aAlbum['user_id'], 'album_id' => $aAlbum['album_id']));
     $this->template()->setBreadcrumb(Phpfox::getPhrase('music.music'), $aCallback === false ? $this->url()->makeUrl('music') : $aCallback['url_home_photo']);
     if ($aCallback === false) {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('music.albums'), $this->url()->makeUrl('music.browse.album'));
     }
     define('PHPFOX_IS_ALBUM_VIEW', true);
     if (Phpfox::isModule('rate')) {
         $this->template()->setPhrase(array('rate.thanks_for_rating'))->setHeader('cache', array('rate.js' => 'module_rate', '<script type="text/javascript">$Behavior.rateMusicAlbum = function() { $Core.rate.init({module: \'music_album\', display: ' . ($aAlbum['has_rated'] ? 'false' : ($aAlbum['user_id'] == Phpfox::getUserId() ? 'false' : 'true')) . ', error_message: \'' . ($aAlbum['has_rated'] ? Phpfox::getPhrase('music.you_have_already_voted', array('phpfox_squote' => true)) : Phpfox::getPhrase('music.you_cannot_rate_your_own_album', array('phpfox_squote' => true))) . '\'}); }</script>'));
     }
     $this->template()->setTitle($aAlbum['name']);
     if (!empty($aAlbum['image_path'])) {
         $this->template()->setMeta('og:image', Phpfox::getLib('image.helper')->display(array('server_id' => $aAlbum['server_id'], 'path' => 'music.url_image', 'file' => $aAlbum['image_path'], 'suffix' => '_200', 'return_url' => true)));
     }
     $this->template()->setBreadcrumb($aAlbum['name'], $this->url()->permalink('music.album', $aAlbum['album_id'], $aAlbum['name']), true)->setMeta('description', $aAlbum['name'])->setHeader('cache', array('jquery/plugin/star/jquery.rating.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'jquery.rating.css' => 'style_css', 'quick_edit.js' => 'static_script', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'feed.js' => 'module_feed', 'album.js' => 'module_music', 'player/flowplayer/flowplayer.js' => 'static_script', 'player/' . Phpfox::getParam('core.default_music_player') . '/core.js' => 'static_script'))->setEditor(array('load' => 'simple'))->assign(array('aAlbum' => $aAlbum));
 }
Пример #26
0
 /**
  * Controller
  */
 public function process()
 {
     if ($playId = $this->request()->get('play')) {
         Music_Service_Process::instance()->play($this->request()->get('play'));
         return ['played' => true];
     }
     Phpfox::getUserParam('music.can_access_music', true);
     if (Phpfox::isUser() && Phpfox::isModule('notification')) {
         Phpfox::getService('notification.process')->delete('comment_music_song', $this->request()->getInt('req2'), Phpfox::getUserId());
         Phpfox::getService('notification.process')->delete('music_song_like', $this->request()->getInt('req2'), Phpfox::getUserId());
     }
     if (!($aSong = Phpfox::getService('music')->getSong($this->request()->get('req2')))) {
         return Phpfox_Error::display(Phpfox::getPhrase('music.the_song_you_are_looking_for_cannot_be_found'));
     }
     if (Phpfox::isModule('notification') && $aSong['user_id'] == Phpfox::getUserId()) {
         Phpfox::getService('notification.process')->delete('music_songapproved', $aSong['song_id'], Phpfox::getUserId());
     }
     $aCallback = false;
     if (!empty($aSong['module_id'])) {
         if ($aCallback = Phpfox::callback($aSong['module_id'] . '.getMusicDetails', $aSong)) {
             $this->template()->setBreadcrumb($aCallback['breadcrumb_title'], $aCallback['breadcrumb_home']);
             $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
             if ($aSong['module_id'] == 'pages' && !Phpfox::getService('pages')->hasPerm($aCallback['item_id'], 'music.view_browse_music')) {
                 return Phpfox_Error::display(Phpfox::getPhrase('music.unable_to_view_this_item_due_to_privacy_settings'));
             }
         }
     }
     Phpfox::getService('core.redirect')->check($aSong['title']);
     if (Phpfox::isModule('privacy')) {
         Privacy_Service_Privacy::instance()->check('music_song', $aSong['song_id'], $aSong['user_id'], $aSong['privacy'], $aSong['is_friend']);
     }
     $this->setParam('aSong', $aSong);
     $this->setParam('aRatingCallback', array('type' => 'music_song', 'total_rating' => Phpfox::getPhrase('music.total_rating_ratings', array('total_rating' => $aSong['total_rating'])), 'default_rating' => $aSong['total_score'], 'item_id' => $aSong['song_id'], 'stars' => array('2' => Phpfox::getPhrase('music.poor'), '4' => Phpfox::getPhrase('music.nothing_special'), '6' => Phpfox::getPhrase('music.worth_listening_too'), '8' => Phpfox::getPhrase('music.pretty_cool'), '10' => Phpfox::getPhrase('music.awesome'))));
     $this->template()->setBreadcrumb(Phpfox::getPhrase('music.music'), $aCallback === false ? $this->url()->makeUrl('music') : $aCallback['url_home_photo']);
     if (!empty($aSong['album_url'])) {
         $this->template()->setBreadcrumb($aSong['album_url'], $this->url()->permalink('music.album', $aSong['album_id'], $aSong['album_url']));
     }
     $this->template()->setBreadcrumb($aSong['title'], $this->url()->permalink('music', $aSong['song_id'], $aSong['title']), true);
     $this->setParam('aFeed', array('comment_type_id' => 'music_song', 'privacy' => $aSong['privacy'], 'comment_privacy' => $aSong['privacy_comment'], 'like_type_id' => 'music_song', 'feed_is_liked' => $aSong['is_liked'], 'feed_is_friend' => $aSong['is_friend'], 'item_id' => $aSong['song_id'], 'user_id' => $aSong['user_id'], 'total_comment' => $aSong['song_total_comment'], 'total_like' => $aSong['total_like'], 'feed_link' => $this->url()->permalink('music', $aSong['song_id'], $aSong['title']), 'feed_title' => $aSong['title'], 'feed_display' => 'view', 'feed_total_like' => $aSong['total_like'], 'report_module' => 'music_song', 'report_phrase' => Phpfox::getPhrase('music.report_this_song_lowercase')));
     if (Phpfox::isModule('rate')) {
         $this->template()->setPhrase(array('rate.thanks_for_rating'))->setHeader('cache', array('rate.js' => 'module_rate'))->setHeader(array('<script type="text/javascript">$Behavior.rateSong = function() {  $Core.rate.init({module: \'music_song\', display: ' . ($aSong['has_rated'] ? 'false' : ($aSong['user_id'] == Phpfox::getUserId() ? 'false' : 'true')) . ', error_message: \'' . ($aSong['has_rated'] ? Phpfox::getPhrase('music.you_have_already_voted', array('phpfox_squote' => true)) : Phpfox::getPhrase('music.you_cannot_rate_your_own_song', array('phpfox_squote' => true))) . '\'}); }</script>'));
     }
     $this->template()->setTitle($aSong['title'])->setMeta('og:image', Phpfox::getLib('image.helper')->display(array('user' => $aSong, 'suffix' => '_50', 'return_url' => true)))->setMeta('description', $aSong['title'])->setHeader('cache', array('jquery/plugin/star/jquery.rating.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'jquery.rating.css' => 'style_css', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'feed.js' => 'module_feed', 'view.css' => 'module_music'))->setHeader(array('<script type="text/javascript">var bLoadedMusicSong = false; $Behavior.playSongOnView = function() { bLoadedMusicSong = false; if ($(\'#js_music_player\').length > 0) { $Core.player.load({on_start: function() { if (!bLoadedMusicSong) {  bLoadedMusicSong = true; $.ajaxCall(\'music.play\', \'id=' . $aSong['song_id'] . '\', \'GET\'); } }, id: \'js_music_player\', type: \'music\', auto: true, play: \'' . $aSong['song_path'] . '\'}); } $Behavior.playSongOnView = function() {}; }</script>'))->setEditor(array('load' => 'simple'))->assign(array('aSong' => $aSong));
     if ($sPlugin = Phpfox_Plugin::get('music.component_controller_music_view')) {
         eval($sPlugin);
     }
 }
Пример #27
0
 /**
  * Controller
  */
 public function process()
 {
     $iId = $this->request()->get('id');
     $aRow = Phpfox::getService('attachment')->getForDownload($iId);
     if (!isset($aRow['destination'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('attachment.no_such_download_found'));
     }
     $sPath = Phpfox::getParam('core.dir_attachment') . sprintf($aRow['destination'], '');
     if (Phpfox::hasCallback($aRow['category_id'], 'attachmentControl')) {
         $bAllowed = Phpfox::callback($aRow['category_id'] . '.attachmentControl', $aRow['item_id']);
         if ($bAllowed == false) {
             return Phpfox_Error::display(Phpfox::getPhrase('attachment.you_are_not_allowed_to_download_this_attachment'));
         }
     }
     Phpfox::getService('attachment.process')->updateCounter($aRow['attachment_id']);
     Phpfox_File::instance()->forceDownload($sPath, $aRow['file_name'], $aRow['mime_type'], $aRow['file_size'], $aRow['server_id']);
     exit;
 }
Пример #28
0
 public function get($iUserId)
 {
     $aFavorites = $this->database()->select('f.*')->from($this->_sTable, 'f')->where('f.user_id = ' . (int) $iUserId)->order('f.time_stamp DESC')->execute('getSlaveRows');
     if (!count($aFavorites)) {
         return array(0, array());
     }
     $aGroups = array();
     $aCache = array();
     $aCacheFavorite = array();
     $iOwnerUserId = 0;
     foreach ($aFavorites as $aFavorite) {
         $aGroups[$aFavorite['type_id']][] = $aFavorite['item_id'];
         $aCacheFavorite[$aFavorite['type_id']][] = $aFavorite['favorite_id'];
         $iOwnerUserId = $aFavorite['user_id'];
     }
     unset($aFavorites, $aFavorite);
     foreach ($aGroups as $sType => $aFavorites) {
         $sModule = $sType;
         if (strpos($sModule, '_')) {
             $aParts = explode('_', $sModule);
             $sModule = $aParts[0];
         }
         if (!Phpfox::isModule($sModule)) {
             continue;
         }
         $aCallback = Phpfox::callback($sType . '.getFavorite', $aFavorites, $iUserId);
         foreach ($aCacheFavorite[$sType] as $iKey => $iCacheFavId) {
             if (isset($aCallback['items'][$iKey])) {
                 $aCallback['items'][$iKey]['favorite_id'] = $iCacheFavId;
             }
         }
         foreach ($aCallback as $sKey => $aCallbackItem) {
             if ($sKey != 'items') {
                 continue;
             }
             foreach ($aCallbackItem as $iItemKey => $aSub) {
                 $aCallback['items'][$iItemKey]['time_stamp_phrase'] = Phpfox::getTime(Phpfox::getParam('core.global_update_time'), $aSub['time_stamp']);
             }
         }
         $aCache[] = $aCallback;
     }
     return array($iOwnerUserId, $aCache);
 }
Пример #29
0
 public function add($sTypeId, $iItemId)
 {
     if (!$this->database()->select('COUNT(*)')->from($this->_sTable)->where('type_id = \'' . $this->database()->escape($sTypeId) . '\' AND item_id = ' . (int) $iItemId . ' AND user_id = ' . Phpfox::getUserId())->execute('getSlaveField')) {
         $sModule = $sTypeId;
         if (strpos($sModule, '_')) {
             $aParts = explode('_', $sModule);
             $sModule = $aParts[0];
         }
         if (!Phpfox::isModule($sModule)) {
             return Phpfox_Error::set(Phpfox::getPhrase('favorite.not_a_valid_module'));
         }
         if (!Phpfox::callback($sTypeId . '.verifyFavorite', $iItemId)) {
             return Phpfox_Error::set(Phpfox::getPhrase('favorite.unable_to_add_this_item_as_a_favorite_due_to_privacy'));
         }
         $this->database()->insert($this->_sTable, array('type_id' => $sTypeId, 'item_id' => (int) $iItemId, 'user_id' => Phpfox::getUserId(), 'time_stamp' => PHPFOX_TIME));
         return true;
     }
     return Phpfox_Error::set(Phpfox::getPhrase('favorite.this_item_is_already_in_your_favorites_list'));
 }
Пример #30
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::getUserParam('search.can_use_global_search', true);
     $this->template()->setHeader(array('search.css' => 'style_css'))->setTitle(Phpfox::getPhrase('search.results'))->setBreadcrumb(Phpfox::getPhrase('search.search'), $this->url()->makeUrl('search'));
     $sQuery = $this->request()->get('q', null);
     $sView = $this->request()->get('view', null);
     $sGetHistory = $this->request()->get('history');
     if ($this->request()->get('encode')) {
         $sQuery = urldecode($sQuery);
     }
     $iTotalShow = 10;
     $iPage = $this->request()->getInt('page');
     if ($sQuery !== null) {
         if (empty($sQuery)) {
             Phpfox_Error::set(Phpfox::getPhrase('search.provide_a_search_query'));
         } else {
             $aSearchResults = Phpfox::getService('search')->query($sQuery, $iPage, $iTotalShow, $sView);
             if (count($aSearchResults)) {
                 $aFilterMenu = array(Phpfox::getPhrase('search.all_results') => $this->url()->makeUrl('search', array('q' => urlencode($sQuery), 'encode' => '1')));
                 if (empty($sGetHistory)) {
                     $sHistory = '';
                     foreach ($aSearchResults as $aSearchResult) {
                         if (isset($aSearchTypes[$aSearchResult['item_type_id']])) {
                             continue;
                         }
                         $aSearchTypes[$aSearchResult['item_type_id']] = true;
                         $sHistory .= $aSearchResult['item_type_id'] . ',';
                     }
                     $sHistory = rtrim($sHistory, ',');
                 } else {
                     $sHistory = $sGetHistory;
                 }
                 $aHistoryParts = explode(',', $sHistory);
                 foreach ($aHistoryParts as $sHistoryPart) {
                     $aSearchInfo = Phpfox::callback($sHistoryPart . '.getSearchTitleInfo');
                     $aFilterMenu[$aSearchInfo['name']] = $this->url()->makeUrl('search', array('q' => urlencode($sQuery), 'view' => $sHistoryPart, 'encode' => '1', 'history' => $sHistory));
                 }
                 $this->template()->buildSectionMenu('search', $aFilterMenu);
                 $this->template()->setBreadcrumb(Phpfox::getPhrase('search.results_for') . ': ' . $sQuery, '', true)->assign(array('aSearchResults' => $aSearchResults, 'sQuery' => $sQuery, 'sNextPage' => 'q=' . urlencode($sQuery) . '&amp;encode=1&amp;view=' . $sView . '&amp;history=' . $sHistory . '&amp;page=' . ($iPage + 1)));
             }
         }
     }
 }