コード例 #1
0
 public function actionIndex()
 {
     Yii::app()->getModule('aud');
     Yii::app()->getModule('group');
     Yii::app()->getModule('lesson');
     Yii::app()->getModule('sch');
     Yii::app()->getModule('spec');
     Yii::app()->getModule('teacher');
     $schs = Sch::model()->findAll(array('order' => 'modified_time DESC', 'limit' => 100));
     $auds = Aud::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $specs = Spec::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $groups = Group::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $lessons = Lesson::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $teachers = Teacher::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $entries = $this->addEntries(array($auds, $specs, $groups, $lessons, $teachers));
     foreach ($schs as $value) {
         $entries[] = array('id' => $value->group_id, 'module' => strtolower(get_class($value)), 'time' => $value->modified_time . rand(100000, 999999), 'time' => $value->modified_time, 'user' => $value->modified_by, 'action' => 'update');
     }
     $entriesNew = array();
     foreach ($entries as $value) {
         $entriesNew[$value['time'] . rand(10000, 99999)] = $value;
     }
     krsort($entriesNew);
     $this->render('index', array('entries' => $entriesNew));
 }
コード例 #2
0
 public function name($module = null, $id = null)
 {
     Yii::app()->getModule('aud');
     Yii::app()->getModule('group');
     Yii::app()->getModule('lesson');
     Yii::app()->getModule('sch');
     Yii::app()->getModule('spec');
     Yii::app()->getModule('teacher');
     $item = '';
     switch ($module) {
         case 'aud':
             if ($aud = Aud::model()->findByPk($id)) {
                 $item = $aud->name . ' (' . Yii::app()->params['aud_types'][$aud->type] . ')';
             }
             break;
         case 'group':
             if ($group = Group::model()->findByPk($id)) {
                 $item = $group->group_spec->code . '-' . $group->year . '-0' . $group->number . ' (' . $group->group_spec->name . ', ' . Yii::app()->sch->course($group->year) . ' курс)';
             }
             break;
         case 'lesson':
             if ($lesson = Lesson::model()->findByPk($id)) {
                 $item = isset($lesson->fullname) ? $lesson->fullname : $lesson->name;
             }
             break;
         case 'sch':
             if ($sch = Sch::model()->findByPk($id)) {
                 $item = $sch->group->groupName() . ' (' . $sch->group->group_spec->name . ', ' . Yii::app()->sch->course($sch->group->year) . ' курс)';
             }
             break;
         case 'spec':
             if ($spec = Spec::model()->findByPk($id)) {
                 $item = $spec->name;
             }
             break;
         case 'teacher':
             if ($teacher = Teacher::model()->findByPk($id)) {
                 $item = $teacher->surname . ' ' . $teacher->initials;
             }
             break;
         default:
             $item = '';
             break;
     }
     return $item;
 }
コード例 #3
0
    public function actionAddReviewSpec($id)
    {

        $id = (int)$id;
        $review = Spec::model()->active()->findByPk($id);
        if(!$review)
            Yii::app()->end();
        if(isset($_POST['CommentSpec'])) {

            $model = new CommentSpec;
            $model->scenario = 'subcomment';
            $model->object_pk = $review->id;

            if(!Yii::app()->user->isGuest)
            {
                $model->user_id = Yii::app()->user->id;

            } else {

                 Yii::app()->end();
            }
            $model->setAttribute('status', CommentSpec::STATUS_APPROVED);
            $this->performAjaxValidation($model, 'comments-form');
                $model->attributes=$_POST['CommentSpec'];
            if(empty($model->id_parent))
                $model->id_parent = null;

            

            if($model->validate()){
                
                if($model->save()){
                    if(isset($_POST['type']) && $_POST['type']==1){
                        $this->renderPartial('_comment_super',array('model'=>$model,'supermodel'=>$review));
                    } else{
                        // $this->renderPartial('_comment',array('model'=>$model));
                    }
                    
                } 
                
            } 

        }
        Yii::app()->end();
    }
コード例 #4
0
ファイル: SpecController.php プロジェクト: BigMacckk/kepsch
 /**
  * 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 Spec the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Spec::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #5
0
ファイル: SchComponent.php プロジェクト: BigMacckk/kepsch
 public function activeSpecs()
 {
     $specs_array[] = '-';
     Yii::app()->getModule('spec');
     $specs = Spec::model()->findAllByAttributes(array('status' => '1'));
     foreach ($specs as $spec) {
         $specs_array[$spec['id']] = $spec->code;
     }
     return $specs_array;
 }