/**
  * Test for hit method - should always return true if there is no hits column.
  *
  * @return  void
  *
  * @since   12.3
  */
 public function testHit()
 {
     $this->object->load(array('id1' => 25, 'id2' => 50));
     $this->assertTrue($this->object->hit());
     $object2 = new TableDbTestComposite(TestCaseDatabase::$driver);
     $object2->load(array('id1' => 25, 'id2' => 50));
     $this->assertEquals(6, $object2->hits);
 }
Exemplo n.º 2
0
 /**
  * Override parent's behavior as we need to assign badge history when a post is being read.
  *
  **/
 public function hit($pk = null)
 {
     $ip = JRequest::getVar('REMOTE_ADDR', '', 'SERVER');
     $my = JFactory::getUser();
     if (!empty($ip) && !empty($this->id)) {
         $token = md5($ip . $this->id);
         $session = JFactory::getSession();
         $exists = $session->get($token, false);
         if ($exists) {
             return true;
         }
         $session->set($token, 1);
     }
     $state = parent::hit();
     if ($this->published == DISCUSS_ID_PUBLISHED && $my->id != $this->user_id) {
         // @task: Assign badge
         DiscussHelper::getHelper('Badges')->assign('easydiscuss.read.discussion', $my->id, JText::sprintf('COM_EASYDISCUSS_BADGES_HISTORY_READ_POST', $this->title));
         // EasySocial integrations
         DiscussHelper::getHelper('EasySocial')->assignBadge('read.question', $my->id, JText::sprintf('COM_EASYDISCUSS_BADGES_HISTORY_READ_POST', $this->title));
         // AUP Integrations
         DiscussHelper::getHelper('Aup')->assign(DISCUSS_POINTS_VIEW_DISCUSSION, $my->id, $this->title);
     }
     return $state;
 }
Exemplo n.º 3
0
 /**
  * Make sure hits are user and session sensitive
  */
 public function hit($pk = null)
 {
     $session = JFactory::getSession();
     if ($session->get('view-video-' . $this->id, false) == false) {
         parent::hit();
         //@since 4.1 we dump the info into video stats
         $statsModel = CFactory::getModel('stats');
         $statsModel->addVideoStats($this->id, 'view');
     }
     $session->set('view-video-' . $this->id, true);
 }
Exemplo n.º 4
0
 /**
  * Override parent's hit method as we don't really want to
  * carefully increment it every time a photo is viewed.
  * */
 public function hit($pk = null)
 {
     $session = JFactory::getSession();
     if ($session->get('photo-view-' . $this->id, false) == false) {
         parent::hit();
         $session->set('photo-view-' . $this->id, true);
         //@rule: We need to test if the album for this photo also has the hits.
         // otherwise it would not tally when photo has large hits but not the album.
         // The album hit() will take care of the album hits session correctly.
         $album = JTable::getInstance('Album', 'CTable');
         $album->load($this->albumid);
         $album->hit();
     }
 }
Exemplo n.º 5
0
 /**
  * Override parent's hit method as we don't really want to
  * carefully increment it every time a photo is viewed.
  * */
 public function hit($pk = null)
 {
     $session = JFactory::getSession();
     if ($session->get('album-view-' . $this->id, false) == false) {
         parent::hit();
         $session->set('album-view-' . $this->id, true);
     }
 }
Exemplo n.º 6
0
 /**
  * Override parent's hit behavior
  *
  * @since   1.0
  * @access  public
  * @return  boolean
  */
 public function addHit()
 {
     $ip = JRequest::getVar('REMOTE_ADDR', '', 'SERVER');
     if (!empty($ip) && !empty($this->id)) {
         $token = md5($ip . $this->id . $this->_tbl);
         $session = JFactory::getSession();
         $exists = $session->get($token, false);
         if ($exists) {
             return true;
         }
         $session->set($token, 1);
     }
     return parent::hit();
 }
Exemplo n.º 7
0
 /**
  * Make sure hits are user and session sensitive
  */
 public function hit($pk = null)
 {
     $session = JFactory::getSession();
     if ($session->get('view-event-' . $this->id, false) == false) {
         parent::hit();
         //@since 4.1 when a there is a new view in event, dump the data into event stats
         $statsModel = CFactory::getModel('stats');
         $statsModel->addEventStats($this->id, 'view');
     }
     $session->set('view-event-' . $this->id, true);
 }