Exemplo n.º 1
0
 protected function body()
 {
     $inputs = array('name' => array('isNotEmpty'), 'description' => 'isNotEmpty');
     if (!$this->isInputValid($inputs)) {
         return false;
     }
     $name = $this->getParams('name');
     $description = $this->getParams('description');
     $id = $this->getParams('id');
     $isIdSet = $id !== null && $id !== '';
     $user = User::instance();
     $userId = $user->getId();
     if (!$isIdSet) {
         if (!$this->userHasPrivileges(User::lecturesAdd)) {
             return false;
         }
         $lecture = new \Lecture();
         $lecture->setName($name);
         $lecture->setDescription($description);
         $lecture->setOwner(User::instance()->getEntity());
         Repositories::persistAndFlush($lecture);
     } else {
         if ($isIdSet) {
             $lecture = Repositories::findEntity(Repositories::Lecture, $id);
             if (!$user->hasPrivileges(User::lecturesManageAll) && (!$user->hasPrivileges(User::lecturesManageOwn) || $lecture->getOwner()->getId() != $userId)) {
                 return $this->death(StringID::InsufficientPrivileges);
             }
             $lecture->setDescription($description);
             Repositories::persistAndFlush($lecture);
         }
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Checks whether the active user is authorized to manage the specified lecture.
  * @param \Lecture $lecture The lecture the active user wants to manage.
  * @return bool True, if the user is authorized.
  */
 protected function authorizedToManageLecture(\Lecture $lecture)
 {
     $user = User::instance();
     if ($user->hasPrivileges(User::lecturesManageAll)) {
         return true;
     }
     if ($user->hasPrivileges(User::lecturesManageOwn && $lecture->getOwner()->getId() === User::instance()->getId())) {
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 public function loadEvent($id)
 {
     $squeeb = Lecture::where('id', '=', $id)->first();
     View::share('squeeb', $squeeb);
     view::share('model', 'Event');
     return View::make('guest.squeeb');
 }
Exemplo n.º 4
0
 public function run()
 {
     $params = array();
     $criteria = new CDbCriteria();
     $criteria->select = array('lecture_name,training_minute,id,lecture_type');
     if (isset($this->lecture_name) and $this->lecture_name != '') {
         $keyword = addcslashes($this->lecture_name, '%_');
         $criteria->addCondition('lecture_name LIKE :keyword');
         $params[':keyword'] = "%{$keyword}%";
     }
     if (isset($this->lecture_cat) and $this->lecture_cat != '') {
         $criteria->addCondition('lecture_cat_id=' . $this->lecture_cat);
     }
     if (isset($this->trainer) and $this->trainer != '') {
         $criteria->addCondition('created_by=' . $this->trainer);
     }
     if (!empty(Yii::app()->user->id) and Yii::app()->session['group_id'] == 1) {
         $criteria->addCondition('created_by=' . Yii::app()->user->id);
     }
     $criteria->params = $params;
     $criteria->order = 'created_date DESC';
     $total = Lecture::model()->count($criteria);
     $offset = $this->limit * ($this->page - 1);
     $criteria->limit = $this->limit;
     $criteria->offset = $offset;
     $data = Lecture::model()->findAll($criteria);
     if (!empty($data)) {
         $data = CJSON::decode(CJSON::encode($data));
     }
     $pages = new CPagination($total);
     $pages->pageSize = $this->limit;
     $pages->applyLimit($criteria);
     $this->render($this->view, array('data' => $data, 'pages' => $pages));
 }
Exemplo n.º 5
0
 public function facebookSqueeb($id)
 {
     //update the number of shared times
     $squeeb = Lecture::where('id', '=', $id);
     if ($squeeb->count()) {
         $squeeb = $squeeb->first();
         if ($squeeb->save()) {
             return Redirect::away('https://www.facebook.com/sharer.php?u={{URL::current()}}');
         }
     }
 }
Exemplo n.º 6
0
 public function attendEvent($id)
 {
     $squeeb = Lecture::where('id', '=', $id)->first();
     $capacity = $squeeb->Room()->first()->capacity;
     $attendance = $squeeb->attendance;
     if ($attendance <= $capacity - 1) {
         $squeeb->attendance = $squeeb->attendance + 1;
         $save = $squeeb->save;
         return View::make('delegate.attendsuccess');
     }
     return View::make('delegate.attendfail');
 }
Exemplo n.º 7
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $this->layout = 'site';
     $criteria = new CDbCriteria();
     $criteria->order = 'created_date DESC';
     $criteria->addCondition('id_category = ' . $id);
     $criteria->addCondition('is_active = 1');
     $count = Lecture::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     $pages->pageSize = Yii::app()->params['lecturesPerPage'];
     $pages->applyLimit($criteria);
     $lectures = Lecture::model()->findAll($criteria);
     $this->render('view', array('model' => $this->loadModel($id), 'pages' => $pages, 'lectures' => $lectures));
 }
Exemplo n.º 8
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     if (isset($_GET['idLanguage'])) {
         $idLanguage = $_GET['idLanguage'];
     }
     if (!isset($idLanguage)) {
         $defaultLanguage = Language::model()->findByAttributes(array('code' => Yii::app()->params['defaultLanguage']));
         $idLanguage = $defaultLanguage->getPrimaryKey();
     }
     $categories = Category::model()->findAllByAttributes(array('id_language' => $idLanguage, 'is_active' => 1));
     $arrLectures = array();
     foreach ($categories as $category) {
         $criteria = new CDbCriteria();
         $criteria->order = 'created_date DESC';
         $criteria->addCondition(array(sprintf('id_category = %d', $category->getPrimaryKey()), 'is_active= 1'));
         $criteria->limit = Yii::app()->params['numberOfLecturePerCategoryInIndexPage'];
         $arrLectures[$category->getPrimaryKey()] = Lecture::model()->findAll($criteria);
     }
     $this->render('index', array('categories' => $categories, 'arrLectures' => $arrLectures));
 }
Exemplo n.º 9
0
    public function actionIndex($id){
        $this->initialize($id);
        $editMode = $this->checkEditMode($id, Yii::app()->user->getId());

        $lecture = Lecture::model()->findByPk($id);

        $criteria = new CDbCriteria();
        $criteria->addCondition('id_lecture='.$id);

        $dataProvider = new CActiveDataProvider('LectureElement');
        $dataProvider->criteria = $criteria;
        $criteria->order = 'block_order ASC';
        $dataProvider->setPagination(array(
                'pageSize' => '200',
            )
        );

        $owners = [];

        $criteria1 = new CDbCriteria();
        $criteria1->alias='teacher_module';
        $criteria1->select = 'idTeacher';
        $criteria1->addCondition('idModule='.$lecture->idModule);
        $criteria1->toArray();
        $temp = TeacherModule::model()->findAll($criteria1); //info about owners
        for($i = 0; $i < count($temp);$i++){
            array_push($owners, $temp[$i]->idTeacher);
        }
        $teachers = Teacher::model()->findAllByPk($owners);

        $countBlocks = LectureElement::model()->count('id_lecture = :id', array(':id' => $id));

        $this->render('index', array(
            'dataProvider' => $dataProvider,
            'lecture' => $lecture,
            'editMode' => $editMode,
            'countBlocks' => $countBlocks,
            'teachers' => $teachers,
        ));
    }
 function testCreate_OneToMany()
 {
     $this->_createModelAndIncludeThem('lecture', 'Lecture');
     $this->_createModelAndIncludeThem('course', 'Course');
     $course = new Course();
     $course->setTitle($course_title = 'bar');
     $course->save();
     $lecture = new Lecture();
     $lecture->setTitle($lecture_title = 'foo');
     $lecture->setCourse($course);
     $lecture->save();
     $loaded_lecture = lmbActiveRecord::findById('Lecture', $lecture->getId());
     $this->assertEqual($loaded_lecture->getTitle(), $lecture_title);
     $this->assertEqual($loaded_lecture->getCourse()->getId(), $course->getId());
     $loaded_course = lmbActiveRecord::findById('Course', $course->getId());
     $this->assertEqual($loaded_course->getLectures()->at(0)->getId(), $lecture->getId());
 }
	/**
	 * Lists all models.
	 */
	public function actionIndex($lectureId)
	{
        $lecture = Lecture::model()->findByPk($lectureId);
        $teachersconsult = [];

        $criteria= new CDbCriteria;
        $criteria->alias = 'consultant_modules';
        $criteria->select = 'consultant';
        $criteria->addCondition('module='.$lecture->idModule);
        $temp = ConsultantModules::model()->findAll($criteria);
        for($i = 0; $i < count($temp);$i++){
            array_push($teachersconsult, $temp[$i]->consultant);
        }

        $criteriaData= new CDbCriteria;
        $criteriaData->alias = 'teacher';
        $criteriaData->addInCondition('teacher_id', $teachersconsult, 'OR');

        $dataProvider=new CActiveDataProvider('Teacher', array(
            'criteria' =>$criteriaData,
            'pagination'=>false,
    ));

		$this->render('index',array(
			'dataProvider'=>$dataProvider,
            'lecture'=>$lecture
		));
	}
Exemplo n.º 12
0
 public static function accesModule($id){
     $lectures = Lecture::model()->findAll('idModule=:id', array(':id'=>$id));
     $permission = new Permissions();
     foreach($lectures as $lecture){
         if ($permission->checkPermission(Yii::app()->user->getId(),  $lecture->id, array('read'))) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 13
0
            <a href="#newBlockForm">
                <img src="<?php echo StaticFilesHelper::createPath('image', 'editor', 'add_lesson.png');?>"
                     id="addTextBlock" title="Додати новий блок"/>
            </a>
        </div>
        <?php }?>


        <h1 class="lessonTheme"><?php echo $lecture['title']?></h1>
        <br>
        <?php if($countBlocks){?>
            <span class="listTheme"><?php echo Yii::t('lecture', '0321');?> </span><span class="spoilerLinks"><span class="spoilerClick">(показати)</span><span class="spoilerTriangle"> &#9660;</span></span>

            <div class="spoilerBody">
                <?php
                $summary =  Lecture::getLessonCont($lecture->id);
                for($i=0; $i<count($summary);$i++){
                ?>
                <p>
                    <a href="#<?php echo $summary[$i];?>">
                        <?php echo $summary[$i];?>
                    </a>
                </p>
                <?php
                }
                ?>
            </div>
        <?php }?>

        <!-- Lesson content-->
        <?php
Exemplo n.º 14
0
<?php $order = Lecture::model()->count("idModule=$newmodel->module_ID and `order`>0"); ?>
<form id="addLessonForm" action="<?php echo Yii::app()->createUrl('module/saveLesson');?>" method="post">
    <br>
    <span id="formLabel"><?php echo Yii::t('module', '0382'); ?></span>
    <br>
    <span><?php echo Yii::t('module', '0226')." ".($newmodel->lesson_count + 1)."."; ?></span>
    <input name="idModule" value="<?php echo $newmodel->module_ID;?>" hidden="hidden">
    <input name="order" value="<?php echo $order+1;?>" hidden="hidden">
    <input name="lang" value="<?php echo $newmodel->language;?>" hidden="hidden">
    <input type="text" name="newLectureName" id="newLectureName" required pattern="^[=а-яА-ЯёЁa-zA-Z0-9ЄєІі.,;: ()/+-]+$">
    <br><br>
    <input type="submit"  value=<?php echo Yii::t('module', '0383'); ?> id="submitButton" onclick="trimLectureName()">
</form>
<button id="cancelButton" onclick="hideForm('lessonForm', 'newLectureName');"><?php echo Yii::t('module', '0384'); ?></button>
<div style="margin-top: 75px">
    <?php if(Yii::app()->user->hasFlash('newLecture')):
        echo Yii::app()->user->getFlash('newLecture');
    endif; ?>
</div>
Exemplo n.º 15
0
 public function postEditEvent()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Id' => 'required', 'Title' => 'required|max:200', 'Description' => 'required', 'Date' => 'required', 'First_Name' => 'required|max:120', 'Last_Name' => 'required|max:120', 'Pic' => 'image|max:3000', 'Room' => 'required'));
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput()->with('global', 'Sorry!! Your Event was not edited, please retry.');
     } else {
         $id = Input::get('Id');
         $title = Input::get('Title');
         $description = Input::get('Description');
         $firstname = Input::get('First_Name');
         $lastname = Input::get('Last_Name');
         $date = Input::get('Date');
         $file = Input::file('Pic');
         $roomid = Input::get('Room');
         if (Auth::user()) {
             $organiserid = Auth::user()->id;
         } else {
             $organiserid = 0;
         }
         $eventedit = Lecture::where('id', '=', $id);
         $pic_id = 0;
         //post photo
         if ($file != null) {
             //photos validation
             $destinationPath = 'pics';
             $ext = $file->guessClientExtension();
             // Get real extension according to mime type
             $fullname = $file->getClientOriginalName();
             // Client file name, including the extension of the client
             $hashname = date('H.i.s') . '-' . md5($fullname) . '.' . $ext;
             // Hash processed file name, including the real extension
             $upload_success = $file->move($destinationPath, $hashname);
             //Set the photo path name to hashname
             $pic = Photo::create(array('path' => 'pics/' . $hashname));
             if ($pic) {
                 $pic_id = $pic->id;
             }
         }
         if ($eventedit->count()) {
             $eventedit = $eventedit->first();
             //edit the details
             $eventedit->organiser_id = $organiserid;
             $eventedit->room_id = $roomid;
             $eventedit->pic_id = $pic_id;
             $eventedit->title = $title;
             $eventedit->overview = $description;
             $eventedit->date = $date;
             $presenter_edit = Presenter::where('id', '=', $eventedit->presenter_id);
             if ($presenter_edit->count()) {
                 $presenter_edit = $presenter_edit->first();
             }
             $presenter_edit->firstname = $firstname;
             $presenter_edit->lastname = $lastname;
             $saved1 = $presenter_edit->save();
             $saved2 = $eventedit->save();
             return View::make('organiser.success');
         }
     }
     return Redirect::back()->withInput()->with('global', 'Sorry!! Your Event was not edited, please retry.');
 }
Exemplo n.º 16
0
<?php
$teacher=Teacher::model()->findByPk($data['teacher_id']);
$lecture=Lecture::model()->findByPk($data['lecture_id']);
?>
<tr>
    <td>
        <div><?php echo Yii::t('profile', '0132'); ?></div>
    </td>
    <td>
        <div><?php echo $data['date_cons'] ?></div>
    </td>
    <td>
        <div><?php echo $data['start_cons']."-".$data['end_cons'] ?></div>
    </td>
    <td>
        <div><?php echo $teacher->first_name.' '.$teacher->last_name ?></div>
    </td>
    <td>
        <div><?php echo $lecture->title ?></div>
    </td>
</tr>
Exemplo n.º 17
0
            <?php 
echo $form->dropDownList($model, 'id_category', CHtml::listData(Category::model()->findAll("id_language = {$model->id_language}"), 'id', 'name'), array('ajax' => array('type' => 'POST', 'url' => $this->createUrl('lecture/listByCategory'), 'update' => '#Lesson_id_lecture')));
?>
            <?php 
echo $form->error($model, 'id_category');
?>
        </div>
    </div>       
    
    <div class="row">
        <?php 
echo $form->label($model, 'id_lecture');
?>
        <div>
            <?php 
echo $form->dropDownList($model, 'id_lecture', CHtml::listData(Lecture::model()->findAll("id_category = {$model->id_category}"), 'id', 'title'));
//                echo CHtml::link($model->lecture->title, $model->lecture->href);
?>
        </div>
    </div>

    <div class="row">
        <?php 
echo $form->labelEx($model, 'title_vi');
?>
        <div>
            <?php 
echo $form->textField($model, 'title_vi', array('size' => 50, 'maxlength' => 50));
?>
            <?php 
echo $form->error($model, 'title_vi');
Exemplo n.º 18
0
 public function loadEvent($id)
 {
     $squeeb = Lecture::where('id', '=', $id)->first();
     View::share('squeeb', $squeeb);
     return View::make('organiser.squeeb');
 }
Exemplo n.º 19
0
 public function actionShowLectures(){
     $first = '<select size="1" name="lecture">';
     $criteria = new CDbCriteria();
     $criteria->select = 'id, title';
     $criteria->order = 'id ASC';
     $criteria->addCondition('idModule='.$_POST['module']);
     $rows = Lecture::model()->findAll($criteria);
     $result = $first.'<option value="">Всі лекції</option>
                <optgroup label="Виберіть лекцію">';
     if(!empty($rows)) {
         foreach ($rows as $numRow => $row) {
             $result = $result . '<option value="' . $row['id'] . '">' . $row['title'] . '</option>';
         };
     }
     $last = '</select>';
     echo $result.$last;
 }
Exemplo n.º 20
0
    public static function unableLecture($idLecture){

        Lecture::model()->updateByPk($idLecture, array('order' => 0));
    }
Exemplo n.º 21
0
 public static function getTheme($dp)
 {
     $result=Lecture::model()->findByPk($dp->lecture_id)->title;
     return $result;
 }
Exemplo n.º 22
0
<?php
/**
 * Created by PhpStorm.
 * User: Ivanna
 * Date: 30.04.2015
 * Time: 17:12
 */
if (Lecture::model()->addNewLesson($_POST['idModule'], $_POST['newLectureName'], $_POST['order'], $_POST['lang']))
{
    Module::model()->updateByPk($_POST['idModule'], array('lesson_count'=>$_POST['order']));
        ?>
        <br>
        <br>
        Нова лекція <?php echo "№".$_POST['order']." ".$_POST['newLectureName'];?>
        додана до модуля <?php echo $_POST['idModule'];?>.
        <br><a href="<?php echo Yii::app()->createUrl('module'); ?>">
        Повернутися на сторінку модуля.
        </a>
<?php
}
?>
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     if (empty(Yii::app()->user->id) || Yii::app()->session['group_id'] == 2) {
         $this->redirect(Yii::app()->createUrl(''));
     }
     $cs = Yii::app()->getClientScript();
     //$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/ckeditor/ckeditor.js');
     $cs->registerCssFile(Yii::app()->theme->baseUrl . '/js/jqueryUpload/jquery.fileupload.css');
     $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/bootstrap-datepicker/bootstrap-datetimepicker.js', CClientScript::POS_END);
     $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jqueryUpload/jquery.ui.widget.js', CClientScript::POS_END);
     $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jqueryUpload/jquery.fileupload.js', CClientScript::POS_END);
     $model = WCourse::model()->find('id=' . $id . ' AND created_by=' . Yii::app()->user->id);
     $nameSession = "";
     $nameSessionTrainee = "";
     if (!empty($model->id)) {
         $nameSession = "_" . $model->id;
         $nameSessionTrainee = $model->id;
     }
     if (empty($model)) {
         $this->redirect(Yii::app()->createUrl(''));
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $model->start_date = date('Y-m-d', strtotime($model->start_date));
     $model->end_date = date('Y-m-d', strtotime($model->end_date));
     if (isset($_POST['WCourse'])) {
         if (!empty($_POST['avatar'])) {
             $_POST['WCourse']['avatar'] = Common::createThumb('avatars/course', $_POST['avatar'], $_POST['WCourse']['course_name']);
             $name_avatar_old = $model->avatar;
             if (!empty($name_avatar_old) and file_exists(Yii::app()->params['upload_path'] . 'uploads/avatars/course/' . $name_avatar_old)) {
                 unlink(Yii::app()->params['upload_path'] . 'uploads/avatars/course/' . $name_avatar_old);
             }
         }
         $model->attributes = $_POST['WCourse'];
         $model->created_date = date('Y-m-d H:i:s');
         if (Yii::app()->session['group_id'] == 2) {
             $model->company_code = Yii::app()->session['company_code'];
         }
         $model->created_by = Yii::app()->user->id;
         $dataLecture = Yii::app()->session->get('dataLecture' . $nameSession) ? json_decode(Yii::app()->session->get('dataLecture' . $nameSession), true) : array();
         $listTrainee = Yii::app()->session->get('listTrainee_' . $nameSessionTrainee) ? json_decode(Yii::app()->session->get('listTrainee_' . $nameSessionTrainee), true) : array();
         $model->trainee_count = count($listTrainee);
         $model->lecture_count = count($dataLecture);
         if ($model->save()) {
             if (!empty($dataLecture)) {
                 foreach ($dataLecture as $item) {
                     $modelCourseLecture = CourseLecture::model()->find('course_id=' . $model->id . ' AND lecture_id=' . $item['id']);
                     if (empty($modelCourseLecture)) {
                         $modelCourseLecture = new CourseLecture();
                         $modelCourseLecture->course_id = $model->id;
                         $modelCourseLecture->lecture_id = $item['id'];
                         $modelCourseLecture->trainer_id = Yii::app()->user->id;
                     }
                     $modelCourseLecture->start_date = $item['start_date'];
                     $modelCourseLecture->end_date = $item['end_date'];
                     $modelCourseLecture->status = 1;
                     if ($modelCourseLecture->save()) {
                         unset($_SESSION['dataLecture' . $nameSession]);
                     }
                 }
             }
         }
         if (!empty($listTrainee)) {
             foreach ($listTrainee as $item) {
                 $modelCourseTrainee = WCourseTrainee::model()->find('course_id=' . $model->id . ' AND trainee_id=' . $item['id']);
                 if (empty($modelCourseTrainee)) {
                     $modelCourseTrainee = new WCourseTrainee();
                     $modelCourseTrainee->course_id = $model->id;
                     $modelCourseTrainee->trainee_id = $item['id'];
                     $modelCourseTrainee->status = 1;
                 }
                 if ($modelCourseTrainee->save()) {
                     unset($_SESSION['listTrainee_' . $nameSessionTrainee]);
                 }
             }
         }
         $this->redirect(array('update', 'id' => $model->id));
     }
     $dataCourseLecture = array();
     if (!empty($id)) {
         unset($_SESSION['dataLecture' . $nameSession]);
         unset($_SESSION['listTrainee_' . $nameSessionTrainee]);
         $data = CourseLecture::model()->findAll('course_id=' . $id . ' ORDER BY start_date ASC');
         $data = CJSON::decode(CJSON::encode($data));
         $dataCourseLecture = array();
         if (!empty($data)) {
             foreach ($data as $key => $item) {
                 if (!empty($item["lecture_id"])) {
                     $lectureDetails = Lecture::model()->find('id=' . $item['lecture_id']);
                     if (!empty($lectureDetails)) {
                         $lectureDetails = CJSON::decode(CJSON::encode($lectureDetails));
                         $dataCourseLecture[$item['lecture_id']]['id'] = $item['lecture_id'];
                         $dataCourseLecture[$item['lecture_id']]['start_date'] = date('Y-m-d H:i', strtotime($item['start_date']));
                         $dataCourseLecture[$item['lecture_id']]['end_date'] = date('Y-m-d H:i', strtotime($item['end_date']));
                         $dataCourseLecture[$item['lecture_id']]['lecture_name'] = $lectureDetails['lecture_name'];
                         $dataCourseLecture[$item['lecture_id']]['course_id'] = $item['course_id'];
                     }
                 }
             }
         }
         $dataTrainee = CourseTrainee::model()->findAll('course_id=' . $id . ' AND status=1');
         $dataTrainee = CJSON::decode(CJSON::encode($dataTrainee));
         $listTrainee = array();
         if (!empty($dataTrainee)) {
             foreach ($dataTrainee as $item) {
                 $traineeDetails = WUser::model()->find('id=' . $item['trainee_id']);
                 if (!empty($traineeDetails)) {
                     $traineeDetails = CJSON::decode(CJSON::encode($traineeDetails));
                     $listTrainee[$traineeDetails['id']]['id'] = $traineeDetails['id'];
                     $listTrainee[$traineeDetails['id']]['course_id'] = $id;
                     $listTrainee[$traineeDetails['id']]['fullname'] = $traineeDetails['fullname'];
                     $listTrainee[$traineeDetails['id']]['username'] = $traineeDetails['username'];
                 }
             }
         }
         Yii::app()->session->add('listTrainee_' . $nameSessionTrainee, json_encode($listTrainee));
         Yii::app()->session->add('dataLecture' . $nameSession, json_encode($dataCourseLecture));
     }
     $this->render('update', array('model' => $model, 'dataCourseLecture' => $dataCourseLecture));
 }
Exemplo n.º 24
0
 public function getIndex()
 {
     $events = Lecture::where('id', '>', 0)->get();
     View::share('events', $events);
     return View::make('admin.home');
 }
Exemplo n.º 25
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 Lecture the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Lecture::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 26
0
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return WLecture the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Exemplo n.º 27
0
echo CHtml::dropDownList('category_id', Yii::app()->request->getRequestUri(), $arrDataCategories);
$idCategory = Yii::app()->request->getQuery('category_id');
?>
</div>

<br />

<?php 
if ($idCategory) {
    $data = Lecture::model()->findAllByAttributes(array('id_category' => $idCategory));
} else {
    if ($idLanguage) {
        $criteria = new CDbCriteria();
        $criteria->join = 'JOIN category ON category.id = id_category';
        $criteria->condition = 'category.id_language = ' . $idLanguage;
        $data = Lecture::model()->findAll($criteria);
    } else {
        $data = Lecture::model()->findAll();
    }
}
$this->widget('zii.widgets.grid.CGridView', array('id' => 'lesson-grid', 'dataProvider' => $model->search($idCategory, $idLanguage), 'filter' => $model, 'columns' => array(array('header' => 'No', 'value' => '$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1', 'htmlOptions' => array('class' => 'number-column')), 'title_vi', 'title_en', 'title_ko', array('name' => 'id_lecture', 'value' => '$data->lecture->title', 'filter' => CHtml::listData($data, 'id', 'title')), array('name' => 'is_active', 'filter' => array('0' => 'No', '1' => 'Yes'), 'value' => '($data->is_active)?"Yes":"No"'), array('name' => 'owner_by', 'header' => Yii::t('flexiblearn', 'Owner by'), 'value' => '$data->ownerBy->username', 'filter' => false), array('class' => 'CButtonColumn'))));
?>
<script language="javascript" type="text/javascript">
    $('#language_id').change(function() {
        window.location.href = $(this).val();
    });
    
    $('#category_id').change(function() {
        window.location.href = $(this).val();
    });
</script>
Exemplo n.º 28
0
    public function actionDownLesson($idLecture){
        $idModule =Lecture::model()->findByPk($idLecture)->idModule;
        $count = Module::model()->findByPk($idModule)->lesson_count;
        $order = Lecture::model()->findByPk($idLecture)->order;

        if($order < $count) {
            $idNext = Lecture::model()->findByAttributes(array('idModule'=>$idModule, 'order' => $order + 1))->id;

            Lecture::model()->updateByPk($idLecture, array('order' => $order + 1));
            Lecture::model()->updateByPk($idNext, array('order' => $order));
        }
        // if AJAX request, we should not redirect the browser
        if(!isset($_GET['ajax']))
            $this->redirect(Yii::app()->request->urlReferrer);
    }
Exemplo n.º 29
0
<?php
/**
 * Created by PhpStorm.
 * User: Ivanna
 * Date: 02.05.2015
 * Time: 17:28
 */
$model = Lecture::model();
$editMode = ($canEdit)?'true':'';

?>

<div class="lessonModule" id="lectures">
    <?php
    if ($canEdit){
        ?>
        <div onclick="enableEdit();">
            <a href="#">
                <img src="<?php echo StaticFilesHelper::createPath('image', 'editor', 'edt_30px.png'); ?>"
                     id="editIco" title="<?php echo Yii::t('module', '0373'); ?>"/>
            </a>
        </div>
    <?php
    }?>
    <a name="list">
    </a>

    <div onclick="showForm();">
        <?php $form=$this->beginWidget('CActiveForm', array(
            'id'=>'ajaxaddlecture-form',
        )); ?>
Exemplo n.º 30
0
 public function actionListByCategory()
 {
     $params = $_POST;
     foreach ($params as $param) {
         if (isset($params) && is_array($param) && array_key_exists('id_category', $param)) {
             $idCategory = (int) $param['id_category'];
         }
     }
     if (isset($idCategory)) {
         $data = Lecture::model()->findAllByAttributes(array('id_category' => $idCategory));
         $data = CHtml::listData($data, 'id', 'title');
         foreach ($data as $value => $name) {
             echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
         }
     }
 }