/** * Generate a fake topic post * * @param \IPS\Content\Item $topic The topic * @param array $values Generator form values * @param bool $first Indicates this is the first post in a topic * @return string|\IPS\Content\Comment Progress message or comment object if first comment */ public function generateSingle(\IPS\Content\Item $topic, array $values, $first = FALSE) { $commentClass = static::$commentClass; /* Generate the author */ if ($first) { $member = $topic->author(); } elseif ($values['author']) { $member = $values['author']; } elseif ($values['author_type'] == 'random_fake') { $member = $this->generator->fakeMember(); } else { $member = $this->generator->guest(); } /* Create and save the post */ $obj = $commentClass::create($topic, $this->generator->comment(), $first, !$member->name ? NULL : $member->name, $topic->hidden() ? FALSE : NULL, $member); $obj->ip_address = $this->generator->ipAddress(); $obj->save(); if (!$first) { $this->map($commentClass, $obj->pid); } // Only map if this is NOT the first comment $itemClass = static::$itemClass; call_user_func_array(array('IPS\\File', 'claimAttachments'), array_merge(array('newContentItem-' . $topic::$application . '/' . $itemClass::$module . '-' . 0), $obj->attachmentIds())); return $first ? $obj : \IPS\Member::loggedIn()->language()->addToStack(static::$message, TRUE, array('sprintf' => array($topic->mapped('title')))); }
/** * Delete data * * @return void */ public function delete() { parent::delete(); $this->container()->setLastComment(); $this->container()->save(); \IPS\membermap\Map::i()->invalidateJsonCache(); }