Esempio n. 1
0
 /**
  * @param array      $ids
  * @param KunenaUser $user
  */
 protected static function loadTopics(array $ids, KunenaUser $user)
 {
     foreach ($ids as $i => $id) {
         $id = intval($id);
         if (!$id || isset(self::$_instances[$user->userid][$id])) {
             unset($ids[$i]);
         }
     }
     if (empty($ids)) {
         return;
     }
     $idlist = implode(',', $ids);
     $db = JFactory::getDBO();
     $query = "SELECT * FROM #__kunena_user_topics WHERE user_id={$db->quote($user->userid)} AND topic_id IN ({$idlist})";
     $db->setQuery($query);
     $results = (array) $db->loadAssocList('topic_id');
     KunenaError::checkDatabaseError();
     foreach ($ids as $id) {
         if (isset($results[$id])) {
             $instance = new KunenaForumTopicUser();
             $instance->bind($results[$id]);
             $instance->exists(true);
             self::$_instances[$user->userid][$id] = self::$_topics[$id][$user->userid] = $instance;
         } else {
             self::$_instances[$user->userid][$id] = self::$_topics[$id][$user->userid] = new KunenaForumTopicUser($id, $user->userid);
         }
     }
     unset($results);
 }
 /**
  * Test delete()
  *
  * @param KunenaForumTopicUser $topicuser
  * @depends testGetInstance
  */
 public function testDelete(KunenaForumTopicUser $topicuser)
 {
     $this->assertTrue($topicuser->delete());
     $this->assertFalse($topicuser->exists());
     self::$topic = null;
 }