public function actionCreate()
 {
     $model = new Topics();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemple #2
0
 public function sendMessage($recipients, $messageId, $topicId, Topics &$topics)
 {
     $this->addTo($recipients)->addFrom('*****@*****.**', 'Fireside App');
     $topic = $topics->findFirst()->where($topicId);
     $this->setSubject($topic['name']);
     // form a link
     $url = 'http://' . $_SERVER['HTTP_HOST'] . WWW_DIR . '/messages/show/' . $topicId . '/' . $messageId;
     $url = "<p><a href='{$url}'>{$url}</a></p>";
     $this->setBody($url . implode("\n", $this->message));
     $this->send();
 }
Exemple #3
0
/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2075 $
 */
require "../libraries/common.inc.php";
uses("topic", "attachment");
require LIB_PATH . 'page.class.php';
require "session_cp.inc.php";
$page = new Pages();
$attachment = new Attachment('pic');
$conditions = array();
$tpl_file = "newstopic";
$topic = new Topics();
if (isset($_POST['del']) && is_array($_POST['id'])) {
    $deleted = $topic->del($_POST['id']);
    if (!$deleted) {
        flash();
    }
}
if (isset($_POST['save']) && !empty($_POST['newstopic']['title'])) {
    $vals = array();
    $vals = $_POST['newstopic'];
    if (isset($_POST['id'])) {
        $id = intval($_POST['id']);
    }
    if (!empty($_FILES['pic']['name'])) {
        $attachment->rename_file = "newstopic-" . $time_stamp;
        $attachment->insert_new = false;
Exemple #4
0
 /**
  * Lists all models.
  */
 public function actionIndex($order = null)
 {
     $model = new Topics('search');
     $orderStr = $model->getOrder($order);
     $dataProvider = new CActiveDataProvider('Topics', array('criteria' => array('select' => 't.*, (SELECT COUNT(id) FROM x2_topic_replies WHERE topicId = t.id) AS replyCount, min(lastPost.createDate) as minCreateDate', 'with' => array('lastPost'), 'order' => $orderStr, 'group' => 'lastPost.topicId'), 'pagination' => array('pageSize' => Profile::getResultsPerPage())));
     $this->render('index', array('model' => $model, 'dataProvider' => $dataProvider, 'order' => $order));
 }
Exemple #5
0
/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2075 $
 */
function smarty_block_topic($params, $content, &$smarty, &$repeat)
{
    $conditions = array();
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "topic";
    }
    if (class_exists("Topics")) {
        $topic = new Topics();
        $topic_controller = new Topic();
    } else {
        uses("topic");
        $topic = new Topics();
        $topic_controller = new Topic();
    }
    if (isset($params['id'])) {
        $conditions[] = "id=" . $params['id'];
    }
    if (isset($params['type'])) {
        $type = explode(",", $params['type']);
        $type = array_unique($type);
        foreach ($type as $val) {
            switch ($val) {
                case 'image':
                    $conditions[] = "picture!=''";
                    break;
                case 'news':
                    $url_fix = "news/list.php?";
                default:
                    break;
            }
        }
    }
    $orderby = null;
    if (isset($params['orderby'])) {
        $orderby = " ORDER BY " . trim($params['orderby']) . " ";
    } else {
        $orderby = " ORDER BY id DESC";
    }
    $topic->setCondition($conditions);
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    $topic->setLimitOffset($offset, $limit);
    $sql = "SELECT * FROM {$topic->table_prefix}topics " . $topic->getCondition() . "{$orderby}" . $topic->getLimitOffset() . "";
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $topic->GetArray($sql);
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        //Todo:news/topic/topic-name.html
        //$item['url'] = $url_fix."topicid=".$item['id'];
        if (!empty($item['alias_name'])) {
            $name = trim($item['alias_name']);
        } else {
            $name = trim($item['title']);
        }
        $item['url'] = smarty_function_the_url(array("module" => "special", "type" => "topic", "name" => urlencode($name)));
        if (isset($params['titlelen'])) {
            $item['title'] = mb_substr(strip_tags($item['title']), 0, $params['titlelen']);
        }
        $item['thumb'] = $item['src'] = pb_get_attachmenturl($item['picture'], '', 'small');
        $item['link'] = '<a title="' . $item['title'] . '" href="' . $item['url'] . '">' . $item['title'] . '</a>';
        $smarty->assign($params['name'], $item);
    } else {
        $repeat = false;
        reset($smarty->blockvars[$param_count]);
    }
    if (!is_null($content)) {
        print $content;
    }
    if (!$repeat) {
        $smarty->blockvars[$param_count] = array();
    }
}
Exemple #6
0
 * 
 * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
 * California 95067, USA. or at email address contact@x2engine.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * X2Engine" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by X2Engine".
 *****************************************************************************************/
$menuOptions = array('index', 'create');
$this->insertMenu($menuOptions);
Yii::app()->clientScript->registerCssFile(Yii::app()->controller->module->assetsUrl . '/css/index.css');
Yii::app()->clientScript->registerScript('topics-sort', '
    $(document).on("click","#topics-sort-toggle",function(){
        if($("#topics-sort-buttons").is(":visible")){
            $("#topics-sort-buttons").slideUp(200);
        }else{
            $("#topics-sort-buttons").slideDown(200);
        }
        return false;
    });
', CClientScript::POS_READY);
echo "<div class='form'>";
//$folderViewHeader = FileSystemObject::getListViewHeader();
$this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_viewTopic', 'id' => 'topic-list', 'htmlOptions' => array('class' => 'x2-list-view list-view'), 'baseScriptUrl' => Yii::app()->request->baseUrl . '/themes/' . Yii::app()->theme->name . '/css/listview', 'template' => '<div class="page-title rounded-top icon topics"><h2>' . Modules::displayName() . ' </h2>' . '{summary}' . Topics::getSortLinks($order) . '</div>' . '{items}{pager}'));
echo "</div>";
Exemple #7
0
/**
 * get all system generated tags by nid
 */
function get_all_system_tags_by_nid($nid)
{
    $full_path = get_full_path_by_nid($nid);
    $topics = new Topics();
    $text = decode_entities(strip_tags($full_path));
    $params = array('link' => $text);
    $results = $topics->tagByLink($params);
    return $results;
}
Exemple #8
0
 /**
  * Executes any command triggered on the admin page.
  */
 protected function processAdminCommand()
 {
     if (isset($_POST['command'], $_POST['id']) && $_POST['command'] === 'delete') {
         if (Yii::app()->user->isGuest) {
             Yii::app()->user->loginRequired();
         }
         if (($topics = Topics::model()->findbyPk($_POST['id'])) !== null) {
             $topics->delete();
             // reload the current page to avoid duplicated delete actions
             $this->refresh();
         } else {
             throw new CHttpException(500, 'The requested topics does not exist.');
         }
     }
 }
Exemple #9
0
 /**
  * 初始化数据库redis
  *
  * @return void
  */
 private function initDbRedis()
 {
     $redis = $this->redis;
     $tablePre = $this->controller->getTablePre();
     // 清空当前数据库
     $redis->flushDB();
     // 计数器
     $redis->hMset($tablePre . 'counter', array('uid' => 0, 'topicid' => 0, 'replyid' => 0, 'bkid' => 0, 'linkid' => 0));
     // 创建默认节点
     $bkM = new BkModel($this->controller);
     $bkid = $bkM->createBk(0, '默认节点');
     //将默认节点加入首页导航
     $bkM->addBk2Index($bkid);
     // 发表一篇默认帖子
     $topicModel = new Topics($this->controller);
     $topicModel->postTopic(0, $bkid, '你好世界', '你好,这是一个测试帖子');
     // 网站配置信息
     $redis->hMset($tablePre . 'site_conf', array('sitename' => '流光论坛', 'create_time' => time(), 'notice_on' => 1, 'notice_text' => '流光论坛安装成功', 'open_compress' => 1));
     //添加链接
     $linksArr = array(array('name' => '关于', 'url' => '/about'), array('name' => 'FAQ', 'url' => '/faq'), array('name' => 'API', 'url' => '/api'), array('name' => '我们的愿景', 'url' => '/mission'), array('name' => 'IP查询', 'url' => '/ip'), array('name' => '工作空间', 'url' => '/workspace'), array('name' => '广告投放', 'url' => '/advertise'), array('name' => '博客', 'url' => '/blog'), array('name' => '上网首页', 'url' => '/start'));
     $urlM = new SiteUrl($this->controller);
     foreach ($linksArr as $linkNode) {
         $urlM->addUrl($linkNode['name'], $linkNode['url']);
     }
 }