7Cav / project-items

Blank repo for main S6 github projects
0 stars 0 forks source link

Set IMOBOT as Submitter for Calendar Events #25

Closed uaon closed 3 years ago

uaon commented 3 years ago

This is Post-change, filling in as for documentation for changes done.

xenforo/src/addons/NF/Calendar/Pub/Controller/Calendar.php Line 150

    protected function setupEventCreate(CalendarEntity $calendar)
    {
        /** @var \NF\Calendar\Service\Event\Creator $creator */
        $IMO_BOT_ID = 598;
        $user = \XF::finder('XF:User')->where('user_id', $IMO_BOT_ID )->fetchOne();
        $creator = \XF::asVisitor($user, function() use ($calendar)
        {
            return $this->service('NF\Calendar:Event\Creator', $calendar);
        });

xenforo/src/addons/NF/Calendar/Service/Event/Creator.php Line 294

    protected function setupEventThreadCreation(\XF\Entity\Forum $forum)
    {
        $IMO_BOT_ID = 598;
        $user = \XF::finder('XF:User')->where('user_id', $IMO_BOT_ID )->fetchOne();

        $title = $this->event->getExpectedThreadTitle();
        $message = $this->getThreadMessage();
        $prefix = $this->calendar->thread_prefix_id;

        $creator = \XF::asVisitor($user, function() use ($forum, $title, $message, $prefix)
        {
            $creator = \XF::service('XF:Thread\Creator', $forum);
            $creator->setContent($title, $message, false);
            $creator->setPrefix($prefix);

            $creator->setDiscussionTypeAndDataRaw('nf_calendar_event');
            $creator->setIsAutomated();
            return $creator;
        });