예제 #1
0
 /**
  * Displays the login page
  */
 public function actionLogin($sh = '', $t = '')
 {
     $this->model = new LoginForm();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
         echo CActiveForm::validate($this->model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $this->model->attributes = $_POST['LoginForm'];
         // validate user input and redirect to the previous page if valid
         if ($this->model->validate() && $this->model->login()) {
             //Assign the subject to the new user if he/she registered after adding a subject
             if ($sh and $t) {
                 //Allow asignment only within 15 minutes since subject added
                 if (SiteLibrary::utc_time() - $t < 900) {
                     Subject::model()->updateAll(array('user_id' => Yii::app()->user->id), 'time_submitted=:time_submitted AND hash=:hash', array(':time_submitted' => $t, ':hash' => $sh));
                 }
                 $this->redirect(array('mysub/' . Yii::app()->user->name));
             } else {
                 $this->redirect(Yii::app()->user->returnUrl);
             }
         }
     }
     // display the login form
     $this->render('login', array('model' => $this->model));
 }
예제 #2
0
 public function register($attr, $image)
 {
     $check = User::model()->findByAttributes(array('email' => $attr['email']));
     if ($check) {
         return 'USER_EXIST';
     } else {
         $model = new User();
         $model->setAttributes($attr);
         $model->password = md5($attr['password']);
         if ($model->save(FALSE)) {
             $image_url = NULL;
             if (isset($image)) {
                 $image_url = $image;
             }
             $model->avatar = $image_url;
             $model->save(FALSE);
             $subjects = Subject::model()->findAll();
             foreach ($subjects as $subject) {
                 $user_subject = new UserSubject();
                 $user_subject->subject_id = $subject->subject_id;
                 $user_subject->user_id = $model->userid;
                 $user_subject->save(FALSE);
             }
             return 'SUCCESS';
         }
         return 'SERVER_ERROR';
     }
 }
예제 #3
0
 public function actionTeacher()
 {
     if (isset($_GET["id"])) {
         $id = StringHelper::filterString($_GET["id"]);
         $spCriteria = new CDbCriteria();
         $spCriteria->select = "*";
         $spCriteria->condition = "teacher_id = :teacher_id";
         $spCriteria->params = array(':teacher_id' => $id);
         $teacher_current_id = Teacher::model()->findAll($spCriteria);
         $subject_teacher = Subject::model()->with(array('subject_teacher' => array('select' => false, 'condition' => 'teacher_id = :teacher_id', 'params' => array(':teacher_id' => $id))))->findAll();
         $ratingCriteria = new CDbCriteria();
         $ratingCriteria->select = "*";
         $ratingCriteria->condition = "teacher_id = :teacher_id";
         $ratingCriteria->params = array(":teacher_id" => $id);
         $rating = Votes::model()->findAll($ratingCriteria);
         $count = count($rating);
         if ($teacher_current_id) {
             foreach ($teacher_current_id as $detail) {
                 $title = $detail->teacher_acadamic_title . " " . $detail->teacher_name . "| Bluebee - UET";
                 $image = $detail->teacher_avatar;
                 $des = $detail->teacher_description;
                 $this->pageTitle = $title;
                 Yii::app()->clientScript->registerLinkTag("image_src", "image/jpeg", $image);
                 Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title'));
                 Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image'));
                 Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description'));
             }
             $this->render('teacher', array('teacher_detail_info' => Teacher::model()->findAll($spCriteria), 'subject_teacher' => $subject_teacher, 'countVote' => $count));
         }
     }
 }
예제 #4
0
 public function actionMore()
 {
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/enjoy.css');
     $city_id = Yii::app()->request->getQuery('city', 0);
     $time_sort = Yii::app()->request->getQuery('time_sort', 'DESC');
     $price_sort = Yii::app()->request->getQuery('lp_dol');
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     if (!empty($city_id)) {
         $criteria->addCondition('city_id=' . $city_id);
     }
     if (!empty($time_sort)) {
         $criteria->order = 'accessDate ' . $time_sort;
     }
     if (!empty($price_sort)) {
         $criteria->order = 'lp_dol ' . $price_sort;
     }
     $criteria->addCondition('lp_dol>3000000');
     $count = House::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = 10;
     $pager->applyLimit($criteria);
     $house_list = House::model()->findAll($criteria);
     $subject_list = Subject::model()->findAll(array('order' => 'id DESC'));
     $cur_city = City::model()->findByPk($city_id);
     $data = array('house_list' => $house_list, 'subject_list' => $subject_list, 'cur_city' => $cur_city, 'count' => $count, 'time_sort' => $time_sort, 'price_sort' => $price_sort, 'pages' => $pager);
     $this->render('more', $data);
 }
 public function actionViewDocument()
 {
     if (isset($_GET['doc_id'])) {
         $doc_id = StringHelper::filterString($_GET['doc_id']);
         $detail_doc = Doc::model()->findAll(array("select" => "*", "condition" => "doc_id = :doc_id", "params" => array(':doc_id' => $doc_id)));
         $spCriteria = new CDbCriteria();
         $spCriteria->select = "*";
         $spCriteria->condition = "doc_id = :doc_id";
         $spCriteria->params = array(':doc_id' => $doc_id);
         $subject_doc = SubjectDoc::model()->find($spCriteria);
         $spjCriteria = new CDbCriteria();
         $spjCriteria->select = "*";
         $spjCriteria->condition = "subject_id = :subject_id";
         $spjCriteria->params = array(':subject_id' => $subject_doc->subject_id);
         $subject = Subject::model()->find($spjCriteria);
         $related_doc = Doc::model()->findAll(array("select" => "*", "limit" => "3", "order" => "RAND()"));
         foreach ($detail_doc as $detail) {
             $title = $detail->doc_name . " | Bluebee - UET";
             $this->pageTitle = $title;
             if ($detail->doc_type == 3) {
                 $image = Yii::app()->getBaseUrl(true) . $detail->doc_url;
             } else {
                 $image = $detail->doc_url;
             }
             $des = $detail->doc_description;
             Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title'));
             Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image'));
             Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:width'));
             Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:height'));
             Yii::app()->clientScript->registerMetaTag("website", null, null, array('property' => 'og:type'));
             Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description'));
         }
         $this->render('viewDocument', array('detail_doc' => $detail_doc, 'related_doc' => $related_doc, 'subject' => $subject));
     }
 }
예제 #6
0
 public function searchSubject($subject_name)
 {
     $subCriteria = new CDbCriteria();
     $subCriteria->select = "*";
     $subCriteria->addSearchCondition('subject_name', $subject_name);
     $subject_result = Subject::model()->findAll($subCriteria);
     return $subject_result;
 }
예제 #7
0
 /**
  * Kilstázza az adott tantárgyhoz tartozó fájlokat.
  * @param int $id A tantárgy azonosítója
  */
 public function actionList($id)
 {
     $model = Subject::model()->findByPk((int) $id);
     if ($model == null) {
         throw new CHttpException(404, "A kért elem nem található");
     }
     $this->render('list', array('data' => $model));
 }
예제 #8
0
파일: Subject.php 프로젝트: std66/de-pti
 public function GetDependencyTree()
 {
     $Tree = array();
     foreach ($this->dependencies as $CurrentDependency) {
         $Tree[$CurrentDependency->dependent_subject_id] = Subject::model()->findByPk($CurrentDependency->dependent_subject_id)->GetDependencyTree();
     }
     return count($Tree) == 0 ? null : $Tree;
 }
예제 #9
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 loadSubject($subId)
 {
     if ($this->_subject === null) {
         $this->_subject = Subject::model()->findbyPk($subId);
         if ($this->_subject === null) {
             throw new CHttpException(404, 'The requested Subject does not exist.');
         }
     }
     return $this->_subject;
 }
 public function actionGetSubjectByUser()
 {
     $request = Yii::app()->request;
     try {
         $user_id = StringHelper::filterString($request->getQuery('user_id'));
         $data = Subject::model()->getSubjectByUser($user_id);
         ResponseHelper::JsonReturnSuccess($data, 'success');
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
예제 #11
0
function GetDepTree($ID, $Dependencies)
{
    $CurrentModel = Subject::model()->findByPk($ID);
    print "<li>\n";
    print CHtml::link($CurrentModel->name, array('subject/details', 'id' => $CurrentModel->subject_id));
    if ($Dependencies != null) {
        print "<ul>\n";
        foreach ($Dependencies as $Key => $Val) {
            GetDepTree($Key, $Val);
        }
        print "</ul>\n";
    }
    print "</li>\n";
}
 public function findSubjectBySubjectGroup($subject_group_id)
 {
     $subject = Subject::model()->findAllByAttributes(array('subject_group_id' => $subject_group_id));
     $returnArr = array();
     foreach ($subject as $item) {
         $itemArr = array();
         $itemArr['subject_id'] = $item->subject_id;
         $itemArr['subject_group_id'] = $item->subject_group_id;
         $itemArr['title'] = $item->title;
         $itemArr['description'] = $item->description;
         $itemArr['subject_group_name'] = $this->findSubjectGroupBySubject($item->subject_id);
         //var_dump($this->findSubjectGroupBySubject($item->subject_id)); die;
         $returnArr[] = $itemArr;
     }
     return $returnArr;
 }
예제 #13
0
 public function actionGetProjects()
 {
     $imghost = $this->imgHost;
     $results = array();
     $postParms = array();
     $_POST = (array) json_decode(file_get_contents('php://input'), true);
     //error_log("Parms:".$_POST['parms']['id']);
     $criteria = new CDbCriteria();
     $postParms = !empty($_POST['parms']) ? $_POST['parms'] : array();
     if (!empty($postParms['id'])) {
         //return single record for detail page
         $criteria->addCondition('id="' . $_POST['parms']['id'] . '"');
         //$subject = Subject::model()->find($criteria);
         $row = Subject::model()->find($criteria);
         //foreach($subject as $row){
         $result['id'] = $row["id"];
         $result['name'] = $row["name"];
         $result['summary'] = $row["summary"];
         $result['image_list'] = unserialize($row["image_list"]);
         $result['layout_list'] = unserialize($row["layout_list"]);
         $result['amenities'] = $row["amenities"];
         $result['point'] = $row["point"];
         $result['room_type_image'] = $row["room_type_image"];
         $result['developer_intro'] = $row["developer_intro"];
         $result['cityname'] = $row["cityname"];
         $result['replaceurl'] = $imghost . "tn_uploads";
         //$results[] = $result;
         //Return single Array object
         echo json_encode($result);
         //}
     } else {
         //Return all recommended project
         $criteria->addCondition('recommend=1');
         $subject = Subject::model()->findAll($criteria);
         foreach ($subject as $row) {
             $result['id'] = $row["id"];
             $result['name'] = $row["name"];
             $result['cityname'] = $row["cityname"];
             $result['room_type_image'] = str_replace("uploads", "tn_uploads", $imghost . $row["room_type_image"]);
             $results[] = $result;
         }
         //return object array with multiple elements.
         echo json_encode($results);
     }
 }
예제 #14
0
 /**
  * Szerkeszti a megadott azonosítójú hírt.
  * @param int $id A hír azonosítója.
  */
 public function actionEditNews($id)
 {
     $id = (int) $id;
     if (!Yii::app()->user->getId() || Yii::app()->user->level < 1) {
         throw new CHttpException(403, 'A funkció használatához be kell jelentkeznie és legalább 1-es szintű hozzáférésre van szüksége');
     }
     if (isset($_POST["saved"])) {
         $model = News::model()->findByPk($id);
         $model->title = $_POST["title"];
         $model->subject_id = $_POST["subject_id"];
         $model->contents = $_POST["contents"];
         $model->date_updated = new CDbExpression("NOW()");
         $model->save();
         $this->redirect(Yii::app()->createUrl("site/index"));
     }
     $model = News::model()->findByPk($id);
     $subjects = Subject::model()->findAll();
     $this->render("edit_news", array('data' => $model, 'subjects' => $subjects));
 }
예제 #15
0
<?php

return array("fields" => array("lesson_id" => array("label" => "ID"), "lesson_weeks" => array("label" => "Lesson week"), "lesson_subject" => array("label" => "Lesson of Subject", "type" => "_dropdown", "_list" => array("primary" => "subject_id", "displayAttr" => "subject_name", "src" => function () {
    $rows = Subject::model()->findAll();
    return $rows;
})), "lesson_doc" => array("label" => "Document of Lesson", "type" => "_dropdown", "_list" => array("primary" => "doc_id", "displayAttr" => "doc_name", "src" => function () {
    $rows = Doc::model()->findAll();
    return $rows;
}))), "columns" => array("lesson_id", "lesson_weeks", "lesson_subject", "lesson_doc"), "actions" => array("_view" => true, "_edit" => array("lesson_weeks", "lesson_subject", "lesson_doc"), "_delete" => true, "_new" => array("type" => "popup", "attr" => array("lesson_weeks", "lesson_subject", "lesson_doc")), "_search" => array("lesson_weeks", "lesson_subject", "lesson_doc"), "_search_advanced" => array("lesson_weeks", "lesson_subject", "lesson_doc"), "_customButtons" => array()), "default" => array("orderBy" => "lesson_id", "orderType" => "asc", "page" => 1, "per_page" => 10, "search" => "", "search_advanced" => ""), "tableAlias" => "lesson", "title" => "Lesson Manager", "condition" => false, "limit_values" => array(10, 20, 30, 40), "model" => "Lesson", "primary" => "lesson_id", "itemLabel" => "lesson", "additionalFiles" => array());
예제 #16
0
    <?php 
echo Yii::t('ListnerModule.listner', 'обязательны.');
?>
</div>

<?php 
echo $form->errorSummary($model);
?>

    <?php 
if (!isset($_GET['parent_id']) && !isset($_GET['parent_group'])) {
    ?>
    <div class="row">
        <div class="col-sm-7">
            <?php 
    echo $form->dropDownListGroup($model, 'subject_id', ['widgetOptions' => ['data' => CHtml::listData(Subject::model()->findAllBySql('SELECT * FROM spbp_subject_subject WHERE id <> ALL(SELECT t1.id FROM spbp_subject_subject t1
                                                            JOIN spbp_listner_position t2 ON t2.subject_id = t1.id
                                                                    WHERE t2.listner_id = ' . $_GET['id'] . '
                                                    )'), 'id', 'name'), 'htmlOptions' => ['empty' => '--выберите--', 'encode' => false]]]);
    ?>
        </div>
    </div>
<?php 
} elseif (isset($_GET['parent_group'])) {
    echo $form->hiddenField($model, 'subject_id', ['value' => Group::model()->findByPk($_GET['parent_group'])->subject_id, 'type' => 'hidden']);
} else {
    echo $form->hiddenField($model, 'subject_id', ['value' => Position::model()->findByPk($_GET['parent_id'])->subject_id, 'type' => 'hidden']);
}
?>

    <div class="row">
예제 #17
0
 public static function subjects()
 {
     $model = Subject::model()->findAll();
     return CHtml::listData($model, 'id', 'name');
 }
예제 #18
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionRegister($sh = '', $t = '')
 {
     $this->model = new User('register');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($this->model);
     if (isset($_POST['User'])) {
         $country_id = 1;
         if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
             Yii::import('ext.EGeoIP');
             $geoIp = new EGeoIP();
             $geoIp->locate($_SERVER['REMOTE_ADDR']);
             //http://www.iso.org/iso/english_country_names_and_code_elements
             $country = Country::model()->find('code=:code', array(':code' => $geoIp->countryCode));
             if ($country) {
                 $country_id = $country->id;
             }
         }
         $this->model->time_created = SiteLibrary::utc_time();
         $this->model->ip_created = $_SERVER['REMOTE_ADDR'];
         $this->model->country_id = $country_id;
         $this->model->country_id_created = $country_id;
         $this->model->attributes = $_POST['User'];
         if ($this->model->save()) {
             if ($sh and $t) {
                 //Allow asignment only within 15 minutes since subject added
                 if (SiteLibrary::utc_time() - $t < 900) {
                     Subject::model()->updateAll(array('user_id' => $this->model->id), 'time_submitted=:time_submitted AND hash=:hash', array(':time_submitted' => $t, ':hash' => $sh));
                 }
             }
             $mail_message = Yii::t('user', "Hi {username}, welcome to samesub!\n\nUsername:  {username}\nEmail: {email}\n\nThanks for registering.\n\nRemember that our mission:\nIs that there be a unique point of union on the internet where all users connected\nto it can interact with one 'Same Subject' synchronously, giving an impact in the way we stay in touch\nwith the world, a way in which everybody adapts to one thing in common, a subject in common:\nSamesub\n\nKnow that you can always help us to achive this goal in any of one of these ways:\nWith your visits.\nSharing to your friends.\nWith your submission of content.\nWith your code contribution.\n\nIf you want to become a moderator, authorizer, or help the samesub team in any way, please write to us\nwith the email you registered from.", array('{username}' => $this->model->username, '{email}' => $this->model->email));
             $mail_message .= "\n\n";
             $mail_message .= Yii::t('site', "Thanks\nSincerely\nSamesub Team\nwww.samesub.com");
             if (SiteLibrary::send_email($this->model->email, Yii::t('user', "Registration successful"), $mail_message)) {
                 $mail_sent = Yii::t('user', "An email has been sent to you.");
             } else {
                 $mail_sent = Yii::t('user', "Email could not be sent.");
             }
             $model2 = new LoginForm();
             $model2->username = $this->model->email;
             $model2->password = $_POST['User']['password'];
             // validate user input and redirect to the previous page if valid
             if ($model2->validate() && $model2->login()) {
                 Yii::app()->user->setFlash('layout_flash_success', Yii::t('user', 'Registration has been completed successfully. {mail_sent} You may now optionally add more information to your profile.', array('{mail_sent}' => $mail_sent)));
                 $this->redirect(array('update'));
             }
         } else {
             //Set back the password to its original as the view will receive it hashed
             $this->model->password = $_POST['User']['password'];
         }
     }
     $this->render('register', array('model' => $this->model, 'sh' => $sh, 't' => $t));
 }
예제 #19
0
 /**
  * 取用户组列表
  * @param $type
  */
 protected function _groupList($type = 'user')
 {
     switch ($type) {
         case 'user':
             return AdminGroup::model()->findAll();
             break;
         case 'subject':
             return Subject::model()->findAll();
             break;
         case 'city':
             return City::model()->findAll();
             break;
         case 'district':
             return District::model()->findAll();
             break;
         case 'investType':
             return InvestType::model()->findAll();
             break;
         case 'propertyType':
             return PropertyType::model()->findAll();
             break;
         case 'house':
             return House::model()->findAll();
             break;
         case 'match':
             return Match::model()->findAll();
             break;
     }
 }
 /**
  * Возвращает модель по указанному идентификатору
  * Если модель не будет найдена - возникнет HTTP-исключение.
  *
  * @param integer идентификатор нужной модели
  *
  * @return void
  */
 public function loadModel($id)
 {
     $model = Subject::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('SubjectModule.subject', 'Запрошенная страница не найдена.'));
     }
     return $model;
 }
예제 #21
0
 public function actionGetSubjectOptions()
 {
     $_SESSION['idClass'] = $_POST['id'];
     $result = '';
     if ($_SESSION['idClass'] != 0) {
         $sql = "SELECT sj.ID, sj.Name FROM tbl_subject AS sj INNER JOIN tbl_class_subject AS csj ON csj.ID_Subject = sj.ID WHERE csj.ID_Class = :ID_Class AND csj.ID_Facuty = :ID_Facuty";
         $options = Subject::model()->findAllBySql($sql, array('ID_Class' => $_SESSION['idClass'], 'ID_Facuty' => Yii::app()->user->getState('idUser')));
         if (empty($options)) {
             $result .= '<option value="0">Không có lớp học</option>';
         } else {
             $result .= '<option value="0">Chọn lớp học</option>';
             foreach ($options as $option) {
                 $result .= '<option value="' . $option->ID . '">' . $option->Name . '</option>';
             }
         }
         echo $result;
     } else {
         echo '<option value="0">Không có lớp học</option>';
     }
 }
 /**
  * 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 Subject the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Subject::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #23
0
 /**
  * Megjeleníti a megadott esemény részletes adatait.
  * @param int $id Az esemény azonosítója
  */
 public function actionDetails($id)
 {
     $EventModel = Events::model()->findByPk((int) $id);
     $SubjectModel = Subject::model()->findByPk($EventModel->subject_id);
     if ($EventModel == null || $SubjectModel == null) {
         throw new CHttpException(404, "A kért elem nem található");
     }
     $this->render('details', array('EventModel' => $EventModel, 'SubjectModel' => $SubjectModel));
 }
예제 #24
0
파일: index.php 프로젝트: std66/de-pti
		<?php 
if (Yii::app()->user->getId() && Yii::app()->user->level >= 1) {
    $URL = Yii::app()->createUrl("site/addnews");
    print '
				<div style="margin-bottom: 10px;">
					<button class="btn btn-md btn-success" onclick="ShowAddNews(\'' . $URL . '\')">
						<i class="fa fa-plus-circle"></i>
						Hír közzététele
					</button>
				</div>';
    ?>
			
		<script language="javascript">
			var Subjects = [
				<?php 
    foreach (Subject::model()->findAll(array('order' => 'name')) as $CurrentSubject) {
        print "{ id: " . $CurrentSubject->subject_id . ", name: '" . $CurrentSubject->name . "' },\n";
    }
    ?>
			];
		</script>
			
		<?php 
}
?>

		<ul class="timeline">
			<?php 
$i = 1;
foreach ($model as $Current) {
    $this->renderPartial('_news', array('data' => $Current, 'invert_timeline' => $i % 2 == 0));
예제 #25
0
 /**
  * This is a cron that sets the next subject to be showed 
  * and the next subject to be cached(subject_id and subject_id_2)
  * 
  */
 public function actionSetNextSubject()
 {
     if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
         die;
     }
     //Only allow to run this locally
     $command = Yii::app()->db->createCommand();
     //If the table its empty by any reason(initial import), insert something to make the UPDATE work
     if (!$command->select('count(*) as num')->from('live_subject')->queryScalar()) {
         $command->insert('live_subject', array('subject_id' => 0, 'subject_id_2' => 0));
     }
     //Position all subs on its time
     Subject::reschedule_positions();
     $round_utc_time = SiteLibrary::utc_time_interval();
     //Remote case: This update is just in case cron didn't run in x times of interva(s)
     //This frees up subs that never were used because they were fixed position but cron failed to run and time passed by
     Subject::model()->updateAll(array('position' => '0', 'user_position' => '0', 'manager_position' => '0'), 'position < ' . $round_utc_time . ' AND user_position < ' . $round_utc_time . ' AND manager_position < ' . $round_utc_time);
     $subject = Subject::model()->find(array('condition' => 'position >= ' . $round_utc_time . ' AND content_type_id <> 2 AND approved=1 AND authorized=1 AND disabled=0 AND deleted=0', 'order' => 'position ASC'));
     $live_subject = Yii::app()->db->createCommand()->select('*')->from('live_subject')->queryRow();
     $command->delete('live_comment');
     $command->update('live_subject', array('comment_id' => 0, 'comment_number' => 0));
     //TEMPORAL:Refill the live_comments table with old comments about this subject if this subject is repeated
     $past_comments = Yii::app()->db->createCommand()->select('t1.id,code,time,comment,comment_number,username,likes,dislikes')->from('comment t1')->where('subject_id =' . $subject->id)->leftJoin('country t2', 'country_id=t2.id')->leftJoin('user t3', 'user_id=t3.id')->order('time ASC')->queryAll();
     echo "<br>gggg";
     print_r($past_comments);
     $i = 0;
     foreach ($past_comments as $past_comment) {
         $i++;
         $country_code = $past_comment['code'] ? $past_comment['code'] : "WW";
         $command->insert('live_comment', array('comment_id' => $past_comment['id'], 'username' => $past_comment['username'], 'subject_id' => $subject->id, 'comment_country' => $country_code, 'comment_time' => $past_comment['time'], 'comment_text' => $past_comment['comment'], 'comment_number' => $i, 'likes' => $past_comment['likes'], 'dislikes' => $past_comment['dislikes']));
         //we neet to use our own sequence because there might be repeated numbers
         $comment_id = $past_comment['id'];
     }
     if ($i > 0) {
         $command->update('live_subject', array('comment_id' => $comment_id, 'comment_number' => $i));
     }
     $command->update('live_subject', array('subject_id' => $subject->id, 'scheduled_time' => SiteLibrary::utc_time_interval(), 'subject_data' => serialize($subject)));
     //Reset position as subject is going to live now
     Subject::model()->updateByPk($subject->id, array('show_time' => SiteLibrary::utc_time(), 'user_position' => 0, 'manager_position' => 0));
     //Notify subject owner via email that his subject its gonna get LIVE
     $user = User::model()->findByPk($subject->user_id);
     if ($user->id != 1 and $user->notify_subject_live == 1) {
         $mail_message = Yii::t('subject', "Hi {username}, \nWe are writing to notify you that your subject got approved and that it is\ngoing to be placed in the live stream(Homepage) in the next 5 minutes.\nDetails\nSubject Title: {title}\nUploaded time: {uploaded_time} UTC\nCurrent time: {current_time} UTC (time of this message)\nEstimated time: {estimated_time} UTC (about 5 minutes)\nIt is even more cool if you chat with your friends about your upcomming subject.\nSo, invite them to go to samesub.com now, you still have 4 minutes.\nIf you do not want to receive this type of notification you can update the settings in\nyour user profile anytime you want.", array('{username}' => $user->username, '{title}' => $subject->title, '{uploaded_time}' => date("Y/m/d H:i", $subject->time_submitted), '{current_time}' => date("Y/m/d H:i", SiteLibrary::utc_time()), '{estimated_time}' => date("Y/m/d H:i", SiteLibrary::utc_time() + 300)));
         $mail_message .= "\n\n";
         $mail_message .= Yii::t('site', "Thanks\nSincerely\nSamesub Team\nwww.samesub.com");
         if (SiteLibrary::send_email($user->email, "Your subject is going LIVE", $mail_message)) {
             echo "An email has been sent.";
         } else {
             echo "Email could not be sent.";
         }
     }
     echo 'Done setting next subject_id_2 : ' . $subject->id;
     //There are some pages that need to be refreshed from the cache such as /subject/index, so that it content reflects the updated data.
     $optional_prefix = "index.php";
     $cmd = Yii::app()->params['cache_refresher'] . ' "' . $optional_prefix . '/subject/index' . '"';
     if (Yii::app()->params['cache_refresher']) {
         exec($cmd);
     }
 }
예제 #26
0
 public function saveDoc($doc_name, $doc_description, $doc_url, $doc_author, $subject_id, $doc_scribd_id, $doc_type, $doc_path, $doc_author_name)
 {
     $doc_data = Subject::model()->findByAttributes(array('subject_id' => $subject_id));
     $doc_model = new Doc();
     $doc_model->doc_name = $doc_name;
     $doc_model->doc_description = $doc_description;
     $doc_model->doc_url = $doc_url;
     $doc_model->subject_type = $doc_data->subject_type;
     $doc_model->doc_path = $doc_path;
     $doc_model->subject_faculty = $doc_data->subject_faculty;
     $doc_model->subject_dept = $doc_data->subject_dept;
     $doc_model->subject_general_faculty_id = $doc_data->subject_general_faculty_id;
     $doc_model->doc_scribd_id = $doc_scribd_id;
     $doc_model->doc_type = $doc_type;
     $doc_model->doc_status = 1;
     $doc_model->doc_author_name = $doc_author_name;
     $doc_model->doc_author = $doc_author;
     $doc_model->save(FALSE);
     $doc_subject = new SubjectDoc();
     $doc_subject->doc_id = $doc_model->doc_id;
     $doc_subject->doc_type = $doc_model->doc_type;
     $doc_subject->subject_id = $subject_id;
     $doc_subject->active = 1;
     $doc_subject->save(FALSE);
 }
예제 #27
0
 /**
  * 首页
  */
 public function actionIndex()
 {
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/index.css');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/flowplayer-3.2.11.min.js');
     //Banner
     $criteria = new CDbCriteria();
     $criteria->select = 'title, url, image';
     $criteria->addCondition('status=1');
     $criteria->order = 'id ';
     $criteria->limit = 4;
     $banner = Banner::model()->findAll($criteria);
     //视频推荐
     $home_video = Video::model()->find('home=:home', array(':home' => 1));
     $criteria = new CDbCriteria();
     $criteria->select = 'id, title, date';
     $criteria->addCondition('chosen=1');
     $criteria->addCondition('home!=1');
     $criteria->order = 'id DESC';
     $criteria->limit = 3;
     $video = Video::model()->findAll($criteria);
     //热点推荐
     $criteria = new CDbCriteria();
     // $criteria->limit = 4;
     $criteria->order = 'id ASC';
     $city_list = City::model()->findAll($criteria);
     $hot = array();
     foreach ($city_list as $city) {
         $criteria = new CDbCriteria();
         $criteria->select = 'id, name, prepay, house_image, city_id,ml_num,county';
         $criteria->addCondition('city_id=' . $city->id);
         $criteria->addCondition('recommend=1');
         $criteria->order = 'id DESC';
         $criteria->limit = 1;
         $house = House::model()->findAll($criteria);
         if (!empty($house)) {
             if (count($hot) < 4) {
                 array_push($hot, $house[0]);
             } else {
                 break;
             }
         }
     }
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     $criteria->order = 'date DESC';
     $criteria->addCondition('homepage=1');
     $count = Subject::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = 6;
     $pager->applyLimit($criteria);
     $subject_list = Subject::model()->findAll($criteria);
     //豪宅鉴赏
     $criteria = new CDbCriteria();
     $criteria->select = 'id, name, prepay, house_image, introduction';
     $criteria->addCondition('total_price>=300');
     $criteria->order = 'id DESC';
     $criteria->limit = 3;
     $enjoy = House::model()->findAll($criteria);
     //学区专栏
     $criteria = new CDbCriteria();
     $criteria->select = 'id, name, prepay, house_image';
     $criteria->addCondition('investType_id=1');
     $criteria->order = 'id DESC';
     $criteria->limit = 10;
     $column = House::model()->findAll($criteria);
     //加国即时新闻
     $criteria = new CDbCriteria();
     $criteria->select = 'id, title, image';
     $criteria->addInCondition('catalog_id', array(6, 7, 8, 9));
     $criteria->addCondition('image<>""');
     $criteria->order = 'id DESC';
     $criteria->limit = 3;
     $instant = Post::model()->findAll($criteria);
     //加国新闻
     $canada_news = Post::model()->findAll(array('select' => 'id, title,create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 6), 'order' => 'id DESC', 'limit' => 10));
     //加国概况
     $summary = Post::model()->findAll(array('select' => 'id, title,create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 7), 'order' => 'id DESC', 'limit' => 5));
     //加国生活/经济
     $life = Post::model()->findAll(array('select' => 'id, title,create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 8), 'order' => 'id DESC', 'limit' => 5));
     //加国旅游
     $travel = Post::model()->findAll(array('select' => 'id, title,create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 9), 'order' => 'id DESC', 'limit' => 5));
     //房展会
     $exhibition = Post::model()->findAll(array('select' => 'id, title, image,create_time,last_update_time', 'condition' => 'catalog_id=:catalog_id AND image<>""', 'params' => array(':catalog_id' => 10), 'order' => 'id DESC', 'limit' => 5));
     //学区房新闻
     $school_distrcit_house_news = Post::model()->findAll(array('select' => 'id, title,create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 11), 'order' => 'id DESC', 'limit' => 5));
     //房产热点新闻
     $house_hotspots = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 12), 'order' => 'id DESC', 'limit' => 8));
     $house_property_special_news = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 13), 'order' => 'id DESC', 'limit' => 1));
     $house_property_special_id = $house_property_special_news[0]->id;
     //房产置业宝典
     $house_property = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 13, ':id' => $house_property_special_id), 'order' => 'id DESC', 'limit' => 10));
     //最新学区房
     $school_distrcit_house = House::model()->findAll(array('select' => 'id, name, house_image', 'condition' => 'investType_id = :investType_id', 'params' => array(':investType_id' => 1), 'order' => 'id DESC', 'limit' => 3));
     $studyabroad = Post::model()->findAll(array('select' => 'id, title, image, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 3), 'order' => 'id DESC', 'limit' => 10));
     //留学资讯 加拿大留学
     $news_lx_special_news[0] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 17), 'order' => 'id DESC', 'limit' => 1));
     $news_lx_special_id = $news_lx_special_news[0][0]->id;
     $news_lx[0] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 17, ':id' => $news_lx_special_id), 'order' => 'id DESC', 'limit' => 10));
     $news_lx[1] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id ', 'params' => array(':catalog_id' => 18), 'order' => 'id DESC', 'limit' => 8));
     $news_lx_special_news[1] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 23), 'order' => 'id DESC', 'limit' => 1));
     $news_lx_special_id = $news_lx_special_news[1][0]->id;
     $news_lx[2] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 23, ':id' => $news_lx_special_id), 'order' => 'id DESC', 'limit' => 10));
     //移民资讯 加拿大移民
     $news_ym_special_news[0] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 19), 'order' => 'id DESC', 'limit' => 1));
     $news_ym_special_id = $news_ym_special_news[0][0]->id;
     $news_ym[0] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 19, ':id' => $news_ym_special_id), 'order' => 'id DESC', 'limit' => 10));
     $news_ym[1] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id ', 'params' => array(':catalog_id' => 20), 'order' => 'id DESC', 'limit' => 8));
     $news_ym_special_news[1] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 24), 'order' => 'id DESC', 'limit' => 1));
     $news_ym_special_id = $news_ym_special_news[1][0]->id;
     $news_ym[2] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 24, ':id' => $news_ym_special_id), 'order' => 'id DESC', 'limit' => 10));
     //旅游资讯 加拿大旅游
     $news_ly_special_news[0] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 21), 'order' => 'id DESC', 'limit' => 1));
     $news_ly_special_id = $news_ly_special_news[0][0]->id;
     $news_ly[0] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 21, ':id' => $news_ly_special_id), 'order' => 'id DESC', 'limit' => 10));
     $news_ly[1] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id ', 'params' => array(':catalog_id' => 22), 'order' => 'id DESC', 'limit' => 8));
     $news_ly_special_news[1] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 25), 'order' => 'id DESC', 'limit' => 1));
     $news_ly_special_id = $news_ly_special_news[1][0]->id;
     $news_ly[2] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 25, ':id' => $news_ly_special_id), 'order' => 'id DESC', 'limit' => 10));
     $data = array('banner' => $banner, 'subject_list' => $subject_list, 'home_video' => $home_video, 'video' => $video, 'hot' => $hot, 'enjoy' => $enjoy, 'column' => $column, 'instant' => $instant, 'canada_news' => $canada_news, 'summary' => $summary, 'life' => $life, 'travel' => $travel, 'exhibition' => $exhibition, 'school_distrcit_house_news' => $school_distrcit_house_news, 'house_hotspots' => $house_hotspots, 'house_property_special_news' => $house_property_special_news[0], 'house_property' => $house_property, 'school_distrcit_house' => $school_distrcit_house, 'studyabroad' => $studyabroad, 'news_lx_special_news' => $news_lx_special_news, 'news_lx' => $news_lx, 'news_ym_special_news' => $news_ym_special_news, 'news_ym' => $news_ym, 'news_ly_special_news' => $news_ly_special_news, 'news_ly' => $news_ly);
     $this->render('index', $data);
 }
예제 #28
0
파일: main.php 프로젝트: zywh/maplecity
echo Yii::app()->createUrl('site/index');
?>
"><img src="<?php 
echo Yii::app()->theme->baseUrl;
?>
/images/layout/logo.jpg" border="0" /></a></div>
                <div class="headright">
                    <span class="headrightone">加拿大房产 置业平台</span>
                    <span class="headrighttwo">400-9900-393</span>
                </div>
                <div class="cl"></div>
            </div>
            <!-- head结束 -->
            <?php 
$city_list = City::model()->findAll(array('condition' => 'avail=1', 'order' => 'id ASC'));
$subject_list = Subject::model()->findAll(array('condition' => 'recommend=1', 'order' => 'id DESC'));
?>
            
            <!-- nav开始 -->
            <div class="nav">
                <div class="navbox">
                    <div class="navleft">
                        <div class="navlist"><a class="nav_up <?php 
if (Yii::app()->controller->id == 'site') {
    echo 'nav_active';
}
?>
" href="<?php 
echo Yii::app()->createUrl('site/index');
?>
">首页</a></div>
예제 #29
0
 public static function getSubjectOptions()
 {
     return CHtml::listData(Subject::model()->findAll(), 'ID', 'Name');
 }
예제 #30
0
echo Yii::t('BalanceModule.balance', 'Поля, отмеченные');
?>
    <span class="required">*</span>
    <?php 
echo Yii::t('BalanceModule.balance', 'обязательны.');
?>
</div>

<?php 
echo $form->errorSummary($model);
?>

    <div class="row">
        <div class="col-sm-7">
            <?php 
echo $form->dropDownListGroup($model, 'subject_id', ['widgetOptions' => ['data' => CHtml::listData(Subject::model()->findAll(), 'id', 'name')]]);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-7">
            <?php 
echo $form->textFieldGroup($model, 'receiver', ['widgetOptions' => ['htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('receiver'), 'data-content' => $model->getAttributeDescription('receiver')]]]);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-7">
            <?php 
echo $form->dropDownListGroup($model, 'form_id', ['widgetOptions' => ['data' => CHtml::listData(Form::model()->findAll(), 'id', 'name')]]);
?>