Exemplo n.º 1
0
 /**
  * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
  * using two-column layout. See 'protected/views/layouts/column2.php'.
  */
 public function loadSemester($semId)
 {
     if ($this->_semester === null) {
         $this->_semester = Semester::model()->findbyPk($semId);
         if ($this->_semester === null) {
             throw new CHttpException(404, 'The requested Semester does not exist.');
         }
     }
     return $this->_semester;
 }
Exemplo n.º 2
0
 public static function getSemesterOptions()
 {
     return CHtml::listData(Semester::model()->findAll(), 'ID', 'Name');
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'review' page.
  */
 public function actionCreate($programId = null, $semesterId = null)
 {
     $this->areaSmall = 'New Post';
     Yii::log($this->module->basePath);
     $college = College::getUserCollege();
     $this->forumBreadcrumb = array('Programs' => array('forum/index'));
     if ($programId) {
         $program = Program::model()->findByPk($programId);
         $this->programId = $programId;
         $this->forumBreadcrumb = array_merge($this->forumBreadcrumb, array($program->program_name => array('forum/programView', 'programId' => $programId)));
     }
     if ($semesterId) {
         $semester = Semester::model()->findByPk($semesterId);
         $this->semesterId = $semesterId;
         $this->forumBreadcrumb = array_merge($this->forumBreadcrumb, array($semester->semester_name => array('forum/viewTopics', 'programId' => $programId, 'semesterId' => $semesterId)));
     }
     $this->forumBreadcrumb = array_merge($this->forumBreadcrumb, array('New Post'));
     $model = new ThreadForm($college->college_id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['PostItem'])) {
         $model->postItem->attributes = $_POST['PostItem'];
         $model->thread->attributes = $_POST['Thread'];
         $fileUpload = CUploadedFile::getInstance($model->thread, 'attachment');
         Yii::log(CVarDumper::dumpAsString($fileUpload));
         if ($fileUpload !== null) {
             $model->thread->attachment = $fileUpload;
         }
         if ($model->validate()) {
             if ($model->save()) {
                 if ($fileUpload !== null) {
                     $model->thread->attachment->saveAs($this->module->basePath . '/files/' . $model->thread->attachment . "_" . $model->thread->getPrimaryKey());
                 }
                 //$model->thread->attachment->saveAs(Yii::app()->basePath . '/../files/' . $model->thread->attachment);
                 $this->redirect(array('review', 'id' => $model->postItem->post_item_id));
                 exit;
             } else {
                 Yii::app()->user->setFlash('error', 'Unable to post your thread.');
             }
         }
     }
     $this->render('create', array('model' => $model, 'collegeId' => $college->college_id));
 }
 public function actionSearchTopics($string, $progId = null, $semesterId = null)
 {
     $college = College::getUserCollege();
     $this->areaLarge = $college->college_name;
     $this->areaSmall = Yii::t('forum', 'forum.area.search');
     if (!empty($progId)) {
         $this->areaSmall .= " (In " . Program::model()->findByPk($progId)->program_name;
         if (!empty($semesterId)) {
             $this->areaSmall .= " / " . Semester::model()->findByPk($semesterId)->semester_name;
         }
         $this->areaSmall .= " )";
     }
     $this->canPost = false;
     Yii::log($string);
     $threads = Thread::model()->searchTopics($string, $college->college_id, $progId, $semesterId);
     Yii::log(CVarDumper::dumpAsString($threads));
     $topicRows = array();
     foreach ($threads as $i => $thread) {
         $row = array('id' => $thread['thread_id'], 'topic' => $thread['title'], 'program_name' => $thread['program_name'], 'program' => $thread['program_id'], 'semester' => CHtml::link($thread['semester_name'], array('viewTopics', 'programId' => $thread['program_id'], 'semesterId' => $thread['semester_id'])), 'progCode' => $thread['program_code'], 'postDate' => $thread['date_created'], 'numReplies' => $thread['reply_count']);
         $topicRows[] = $row;
     }
     $gridColumns = array(array('name' => 'topic', 'header' => 'Topic', 'type' => 'raw', 'value' => 'CHtml::link($data["topic"], array("post/readTopic", "id" => $data["id"]));'), array('name' => 'program_name', 'header' => 'Program', 'type' => 'raw', 'value' => 'CHtml::link($data["program_name"], array("programView", "programId" => $data["program"]));'), array('name' => 'semester', 'header' => 'Semester', 'type' => 'raw'), array('name' => 'postDate', 'header' => 'Post Date', 'filter' => false, 'value' => 'Yii::app()->timeagoFormat->timeago(new DateTime($data["postDate"]))'), array('name' => 'numReplies', 'header' => 'Replies', 'filter' => false));
     $filtersForm = new FiltersForm();
     if (isset($_GET['FiltersForm'])) {
         $filtersForm->filters = $_GET['FiltersForm'];
     }
     $filteredData = $filtersForm->filter($topicRows);
     $forumGridData = new CommunityArrayDataProvider(array_values($filteredData), array('sort' => array('attributes' => array('topic', 'program', 'postDate', 'numReplies')), 'pagination' => array('pageSize' => Yii::app()->params['forum_pageSize'])));
     $forumGridData->setPagination(false);
     $this->emptyText = "No topics could be found";
     $this->render('topics', array('gridColumns' => $gridColumns, 'forumGridData' => $forumGridData, 'filtersForm' => $filtersForm));
 }
Exemplo n.º 5
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.
  * @param integer $id the ID of the model to be loaded
  * @return Semester the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Semester::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 6
0
		<?php 
echo Yii::t('forum', 'forum.post.postIn');
?>
 
            </legend>
            
        <?php 
echo $form->textFieldRow($model, 'collegeName', array('disabled' => true));
?>
            
        <?php 
echo $form->dropDownListRow($model->thread, 'program_id', CHtml::listData(College::getProgramsByCollege($collegeId), 'program_id', 'program_name'), array('options' => array($this->programId => array('selected' => 'selected'))));
?>
            
        <?php 
echo $form->dropDownListRow($model->thread, 'semester_id', CHtml::listData(Semester::model()->findAll(), 'semester_id', 'semester_name'), array('options' => array($this->semesterId => array('selected' => 'selected'))));
?>
            
            <?php 
echo $form->textFieldRow($model->thread, 'program_code');
?>
            
            <legend>
		<?php 
echo Yii::t('forum', 'forum.post.details');
?>
 
            </legend>
            
        <?php 
echo $form->textFieldRow($model->postItem, 'title');