Jump to content

Вывод аватарки на сайт с Ibp 3.4.5


Recommended Posts

Здравствуйте форумчане.

Столкнулся с такой проблемой, не могу вывести на сайт с форума аватарку профиля.

Подскажите что нужно дописать ???  Вот скрипт .

 

<?php 
 
class ForumThreads extends CWidget
{
    /**
     * @var CDbConnection
     */
    private $db;



    public function init()
    {
        $data = array(
            'content' => array(),
            'error'   => Yii::t('main', 'Модуль отключен.'),
        );


        if(config('forum_threads.allow') == 1)
        {
            $data = cache()->get(CacheNames::FORUM_THREADS);

            if($data === FALSE)
            {
                $data = array();

                try
                {
                    // Подключаюсь к БД
                    $this->db = Yii::createComponent(array(
                        'class' => 'CDbConnection',
                        'connectionString' => 'mysql:host=' . config('forum_threads.db_host') . ';port=' . config('forum_threads.db_port') . ';dbname=' . config('forum_threads.db_name'),
                        'enableProfiling' => YII_DEBUG,
                        'enableParamLogging' => TRUE,
                        'username' => config('forum_threads.db_user'),
                        'password' => config('forum_threads.db_pass'),
                        'charset' => 'utf8',
                        'emulatePrepare' => TRUE,
                        'tablePrefix' => config('forum_threads.prefix'),
                    ));

                    app()->setComponent('ForumThreadsDb', $this->db);

                    $forumType = config('forum_threads.type');

                    if(method_exists($this, $forumType))
                    {
                        $data['content'] = $this->$forumType();

                        foreach($data['content'] as $k => $v)
                        {
                            $data['content'][$k]['user_link']  = $this->getUserLink($v['starter_id'], $v['starter_name']);
                            $data['content'][$k]['theme_link'] = $this->getForumLink($v['id_topic'], $v['title'], $v['id_forum']);
                            $data['content'][$k]['start_date'] = $this->getStartDate($v['start_date']);
                        }

                        if(config('forum_threads.cache'))
                        {
                            cache()->set(CacheNames::FORUM_THREADS, $data, config('forum_threads.cache') * 60);
                        }
                    }
                    else
                    {
                        $data['error'] = Yii::t('main', 'Метод для обработки форума: :type не найден.', array(':type' => '<b>' . $forumType . '</b>'));
                    }
                }
                catch(Exception $e)
                {
                    $data['error'] = $e->getMessage();
                }
            }
        }

        app()->controller->renderPartial('//forum-threads', $data);
    }

    /**
     * Ссылка на форум
     *
     * @param int $id_topic
     * @param string $title
     * @param int $id_forum
     *
     * @return string
     */
    private function getForumLink($id_topic, $title, $id_forum)
    {
        $link = rtrim(config('forum_threads.link'), '/') . '/';

        switch(config('forum_threads.type'))
        {
            case 'ipb':
                $link .= 'index.php?/topic/' . $id_topic . '-' . $title . '/';
                break;

        }

        return $link;
    }

	
    /**
     * Ссылка на автора темы
     *
     * @param int $user_id
     * @param string $user_name
     *
     * @return string
     */
    private function getUserLink($user_id, $user_name)
    {
        $link = rtrim(config('forum_threads.link'), '/') . '/';

        switch(config('forum_threads.type'))
        {
            case 'ipb':
                $link .= 'index.php?/user/' . $user_id . '-' . $user_name . '/';
                break;
        }

        return $link;
    }

    /**
     * Форматирует дату
     *
     * @param int|string $time
     *
     * @return string
     */
    private function getStartDate($time)
    {
        if(!is_numeric($time))
        {
            $time = strtotime($time);
        }

        return date(config('forum_threads.date_format'), $time);
    }


    /**
     * Запросы к форуму Ipb
     *
     * @return array
     */
    private function ipb()
    {
        $limit = (int) config('forum_threads.limit');

        $command = $this->db->createCommand()
            ->select('tid AS id_topic,start_date,starter_name,starter_id,forum_id AS id_forum,title')
            ->where('tdelete_time = 0 AND approved = 1')
            ->from('{{topics}}')
            ->order('start_date DESC')
            ->limit($limit);

        if(config('forum_threads.id_deny') != '')
        {
            $ids = explode(',', config('forum_threads.id_deny'));
            $ids = $this->filterIds($ids);

            $command->where(array('not in', 'forum_id', $ids));
        }

        return $command->queryAll();
    }

}
 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...