示例#1
0
 public function initGroupRole()
 {
     $uid = Yii::app()->user->id;
     if (empty($uid)) {
         return false;
     }
     $gid = Yii::app()->request->getQuery('gid');
     $tid = Yii::app()->request->getQuery('tid');
     if (empty($gid) and !empty($tid)) {
         $topic = GroupTopic::model()->loadTopic($tid);
         $gid = $topic->gid;
     }
     if (!empty($gid)) {
         $model = new Group();
         $model->primaryKey = $gid;
         $member = $model->loadMember($uid);
         if (!empty($member)) {
             $status = $member->status;
             //申请加入 但未通过
             if ($status == 0) {
                 $this->isGroupApplicant = true;
             }
             //申请通过
             $level = $member->level;
             if ($level > 0) {
                 $this->isGroupMember = true;
             }
             if ($level > 1) {
                 $this->isGroupAdmin = true;
             }
             if ($level > 2) {
                 $this->isGroupBoss = true;
             }
         }
     }
 }
示例#2
0
<?php

if (!$thisgroup->HasMember($CurrentUser)) {
    System::Redirect("~/community/groups/" . $thisgroup->Name);
    return;
}
if ($_POST["attempt"] != null && $_POST["topic_name"] != null) {
    $validate_topic_name = GroupTopic::ValidateName($_POST["topic_name"]);
}
if ($validate_topic_name == null && $_POST["attempt"] != null && $_POST["topic_name"] != null && $_POST["topic_title"] != null) {
    $result = GroupTopic::Create($thisgroup, $_POST["topic_name"], $_POST["topic_title"], $_POST["topic_description"]);
    if (!$result) {
        $page = new PsychaticaErrorPage();
        $page->ErrorCode = mysql_errno();
        $page->ErrorDescription = mysql_error();
        $page->ReturnButtonURL = "~/community/groups/" . $thisgroup->Name . "/topics/create.mmo";
        $page->ReturnButtonText = "Return to Create Topic";
        $page->Render();
        return;
    }
    System::Redirect("~/community/groups/" . $thisgroup->Name . "/topics/" . $_POST["topic_name"]);
    return;
}
$page = new PsychaticaWebPage("Create Topic | " . $thisgroup->Title);
$page->BeginContent();
?>
<div class="Panel">
	<h3 class="PanelTitle">Topic Properties</h3>
	<div class="PanelContent">
		<form action="create.mmo" method="POST">
			<p>
示例#3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['tid'])) {
             $condition = '';
             $this->_model = GroupTopic::model()->findByPk($_GET['tid'], $condition);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
示例#4
0
 public function getGroupThreads(array $params = array(), $limit = 0)
 {
     $gid = $this->id;
     if (!empty($gid)) {
         $params['gid'] = $gid;
     }
     if (empty($params['is_del'])) {
         $params['is_del'] = 0;
     }
     $model = new GroupTopic();
     $criteria = new CDbCriteria();
     $criteria->condition .= " 1";
     $criteria->order = !empty($params['order']) ? $params['order'] : 't.ctime DESC';
     if (!empty($limit)) {
         $criteria->limit = $limit;
     }
     if (!empty($params)) {
         $array = array('uid', 'gid', 'dist', 'top', 'lock', 'is_del');
         foreach ($params as $key => $value) {
             if (in_array($key, $array)) {
                 $criteria->condition .= " and t.{$key}=:{$key}";
                 $criteria->params[':' . $key] = $value;
             }
         }
     }
     $pages = '';
     if (!empty($params['pageSize'])) {
         $pageSize = $params['pageSize'];
         $page = $params['page'];
         $_GET['page'] = $page;
         $total = $model->count($criteria);
         $pages = new CPagination($total);
         $pages->pageSize = $pageSize ? $pageSize : self::PAGE_SIZE;
         $pages->applyLimit($criteria);
     }
     $models = $model->with('user', 'group')->findAll($criteria);
     #$models=$model->findAll($criteria);
     $data = array('threads' => $models, 'pages' => $pages);
     return $data;
 }
示例#5
0
 /**
  * 删除话题/回复后业务处理
  */
 protected function afterDelete()
 {
     if ($this->istopic == '1') {
         GroupTopic::model()->deleteByPk($this->tid);
         //Group::model()->updateCounters(array('threadcount'=>-1), "id={$this->gid}");
     } else {
         GroupTopic::model()->updateCounters(array('postcount' => -1), "id={$this->tid}");
     }
 }
示例#6
0
<?php

$topic = GroupTopic::GetByIDOrName($thisgroup, $path[3]);
if (count($path) > 4 && $path[4] == "comment.mmo") {
    if ($_POST["comment_content"] !== null) {
        $topic->AddComment($_POST["comment_title"], $_POST["comment_content"]);
        System::Redirect("~/community/groups/" . $thisgroup->Name . "/topics/" . $topic->Name);
        return;
    }
}
$page = new PsychaticaWebPage($topic->Title . " | " . $thisgroup->Title);
$page->BeginContent();
?>
<div class="ProfilePage">
	<div class="ProfileTitle">
		<span class="ProfileUserName">
		<?php 
echo $thisgroup->Title;
?>
		</span>
		<span class="ProfileControlBox">
			<a href="<?php 
echo System::ExpandRelativePath("~/community/groups/" . $thisgroup->Name . "/topics");
?>
">Topic List</a>
			<?php 
if ($CurrentUser != null) {
    if ($thisgroup->HasMember($CurrentUser)) {
        ?>
				<span class="Disabled">Invite Friends</span> <?php 
        /* <a href="/community/groups/<?php echo($thisgroup->Name); ?>/invite">Invite Friends</a> */