public function authenticate()
 {
     $user=StudentReg::model()->findByAttributes(array('email'=>$this->username));
     if($user===null)
         $this->errorCode=self::ERROR_USERNAME_INVALID;
     else
     {
         $this->_id=$user->id;
         $this->setState('email', $user->email);
         $this->errorCode=self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
    public static function getUserName($id,$dp)
    {

        $teacher = Teacher::model()->find("user_id=:user_id", array(':user_id'=>$id));

        if($teacher){
            $result=StudentReg::model()->findByPk($dp->user_id)->firstName." ".StudentReg::model()->findByPk($dp->user_id)->secondName;
            if($result==' ')
                $result=StudentReg::model()->findByPk($dp->user_id)->email;
        }
        else
            $result=Teacher::model()->findByPk($dp->teacher_id)->first_name." ".Teacher::model()->findByPk($dp->teacher_id)->last_name;

        return $result;
    }
    /**
     * Creates a new model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     */
    public function actionCreate()
    {
        $model=new Teacher;
        // Uncomment the following line if AJAX validation is needed
        // $this->performAjaxValidation($model);
        if(isset($_POST['Teacher']))
        {
            $_POST['Teacher']['foto_url']=$_FILES['Teacher']['name']['foto_url'];
            $model->attributes=$_POST['Teacher'];
            $model->avatar=$_FILES['Teacher'];

            if($model->save()) {
                StudentReg::model()->updateByPk($_POST['Teacher']['user_id'], array('role'=>1));
                $this->redirect(array('view', 'id' => $model->teacher_id));
            }
        }
        $this->render('create',array(
            'model'=>$model,
        ));
    }
Example #4
0
<?php
/* @var $this LettersController */
/* @var $model Letters */
/* @var $form CActiveForm */
?>
<?php
$models = StudentReg::model()->findAll(
array('condition'=>'role<>0', 'order' => 'id'));

// format models as $key=>$value with listData
$list = CHtml::listData($models,
'id', 'email');
?>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'letters-form',
    'action'=> Yii::app()->createUrl('letters/sendletter'),
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
    'enableClientValidation'=>true,
    'enableAjaxValidation'=>true,
    'clientOptions'=>array('validateOnSubmit'=>true,'validateOnChange'=>false),
)); ?>

	<div class="row">
		<?php echo $form->hiddenField($model,'sender_id',array('value'=>Yii::app()->user->getId())); ?>
	</div>
 public function actionAddTeacher(){
     $user = Yii::app()->request->getPost('user');
     $role = StudentReg::model()->findByPk($user)->role;
     switch($role){
         case '0':
             StudentReg::model()->updateByPk($user, array('role' => 1));
             break;
         case '1':
             Yii::app()->user->setFlash('warning', "Користувач з таким email вже є викладачем.");
             break;
         case '2':
             Yii::app()->user->setFlash('warning', "Користувач з таким email вже є модератором.");
             break;
         case '3':
             Yii::app()->user->setFlash('warning', "Користувач з таким email вже є адміністратором.");
             break;
         default:
             StudentReg::model()->updateByPk($user, array('role' => 1));
             break;
         }
     $this->redirect(Yii::app()->request->urlReferrer);
 }
Example #6
0
<?php
/**
 * Created by PhpStorm.
 * User: Ivanna
 * Date: 24.04.2015
 * Time: 23:47
 */
$teacherRat=Response::model()->find('who=:whoID and about=:aboutID', array(':whoID'=>$data['who'],':aboutID'=>$teacher->user_id));
$user=StudentReg::model()->findByPk($data['who']);
if($teacherRat){
    $rat= $teacherRat->rate;
} else{
    $rat= Null;
}
?>
<div class="TeacherProfiletitles">
    <?php echo $user->firstName." ".$user->secondName; ?>
</div>
<div class="sm">
    <?php
    $num = $data['who_ip'];
    echo $data['date']." IP:".Teacher::getHideIp($data['who_ip']);
?>
</div>

<div class="txtMsg"><?php echo $data['text'];?></div>
<div class="border">
    <div class="TeacherProfiletitles">
        <?php
        if ($rat!==Null){
        echo Yii::t('teacher', '0186');
Example #7
0
 public static function canAddConsultation(){
     if (Yii::app()->user->isGuest){
         return false;
     }
     $user = Yii::app()->user->getId();
     if (StudentReg::model()->findByPk($user)->role == 0){
         return true;
     }
     return false;
 }
    public function actionTeacherLetter()
    {
        $model=StudentReg::model()->findByPk(Yii::app()->user->id);

        if($_POST['sendletter']) {
            if(!empty($_POST['textname'])) {
                $firstname = $_POST['firstname'];
                $lastname = $_POST['lastname'];
                $year = $_POST['yearname'];
                $educ = $_POST['educationname'];
                $phone = $_POST['phonename'];
                $from = $_POST['email'];
                $courses = $_POST['textname'];
                $title = "Teacher_Work ".$firstname." ".$lastname;
                $mess = "Ім'я: ".$firstname." ".$lastname."\r\n"."Дата народження: ".$year."\r\n"."Освіта: ".$educ."\r\n"."Телефон: ".$phone."\r\n"."Курси які готовий викладати: ".$courses;
                // $to - кому отправляем
                $to = Yii::app()->params['adminEmail'];

                // функция, которая отправляет наше письмо.
                mail($to, $title, $mess, "Content-type: text/plain; charset=utf-8 \r\n" . "From:" . $from . "\r\n");
                Yii::app()->user->setFlash('messagemail','Ваше повідомлення відправлено');
            }
            header('Location: '.$_SERVER['HTTP_REFERER']);
        }
    }
Example #9
0
    public static function getStudentsByTrainer($trainer){
        $students = Yii::app()->db->createCommand(array(
            'select' => array('student'),
            'from' => 'trainer_student',
            'where' => 'trainer=:id',
            'order' => 'student',
            'params' => array(':id' => $trainer),
        ))->queryAll();
        $count = count($students);

        for($i = 0;$i < $count;$i++){
            $students[$i]['id'] = $students[$i]["student"];
            $students[$i]['title'] = StudentReg::model()->findByPk($students[$i]["student"])->firstName." ".
                StudentReg::model()->findByPk($students[$i]["id"])->secondName;
        }

        return (!empty($students))?$students:[];
    }
    public function actionDeleteavatar()
    {
        $id=Yii::app()->user->id;
        $model=StudentReg::model()->findByPk(Yii::app()->user->id);
        if($model->avatar!=='noname.png'){
            unlink(Yii::getpathOfAlias('webroot').'/images/avatars/'.$model->avatar);
            $model->updateByPk($id, array('avatar' => 'noname.png'));
            $this->redirect(Yii::app()->createUrl('studentreg/edit'));
        } else {
            $this->redirect(Yii::app()->createUrl('studentreg/edit'));
        }

    }
<!-- studprofile style -->
<link type="text/css" rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css/studProfile.css" />
<!-- studprofile style -->
<!-- uploadInfo, jQuery -->
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/scripts/uploadInfo.js"></script>
<!-- uploadInfo, jQuery -->
<?php
/* @var $this StudentregController */
/* @var $model studentreg */
/* @var $form CActiveForm */
?>
<?php
$this->pageTitle = 'INTITA';
$post=StudentReg::model()->findByPk(Yii::app()->user->id);
if (!isset($tab)) $tab='';
?>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/scripts/inputmask/jquery.inputmask.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/scripts/inputmask/jquery.inputmask.extensions.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/scripts/inputmask/jquery.inputmask.date.extensions.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/scripts/inputmask/jquery.inputmask.phone.extensions.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/scripts/inputmask/jquery.inputmask.numeric.extensions.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/scripts/inputmask/jquery.inputmask.regex.extensions.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/scripts/inputmask/mask.js"></script>
<!--StyleForm Check and radio box-->
<link href="<?php echo Yii::app()->request->baseUrl; ?>/scripts/formstyler/jquery.formstyler.css" rel="stylesheet" />
<script src="<?php echo Yii::app()->request->baseUrl; ?>/scripts/formstyler/jquery.formstyler.js"></script>
<script src="<?php echo Yii::app()->request->baseUrl; ?>/scripts/formstyler/inputstyler.js"></script>
<!--StyleForm Check and radio box-->
<div class="formStudProfNav">
    <?php
    $this->breadcrumbs=array(
Example #12
0
    public static function getAdressYears ($birthday,$adress='')
    {
        $brthAdr = $adress;
        if(!empty($adress)&&!empty($birthday)) $brthAdr=$brthAdr.", ";

        $myAge = $birthday;
        $myAge = str_replace("/",".",$myAge);
        $date_a = new DateTime($myAge);
        $date_b = new DateTime();
        $interval = $date_b->diff($date_a);
        if($interval->format("%y")!=='0' ){
            $brthAdr=$brthAdr.$interval->format("%y").' '.StudentReg::getYearsTermination($interval->format("%Y"));
        }
        echo $brthAdr;
    }
Example #13
0
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starEmptyYellow.png"/>
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starEmptyYellow.png"/>
        </td></br>
    </tr>
    <tr>
        <td style="white-space: nowrap">
<p><span class="colorP"><?php echo Yii::t('profile', '0252'); ?></span></p>
        </td>
        <td style="white-space: nowrap">
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starFullYellow.png"/>
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starFullYellow.png"/>
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starFullYellow.png"/>
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starFullYellow.png"/>
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starFullYellow.png"/>
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starFullYellow.png"/>
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starEmptyYellow.png"/>
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starEmptyYellow.png"/>
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starEmptyYellow.png"/>
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/starEmptyYellow.png"/>
        </td>
        <td>
            <?php if(StudentReg::getRole(Yii::app()->user->id)==False){
                ?>
                <button class="ButtonRatting" style="margin-left: 200px"><?php echo Yii::t('profile', '0253'); ?></button>
            <?php
            }
            ?>
        </td>
        </tr>
    </table>
</div>
Example #14
0
 public function actionResetEmail()
 {
     if(!Yii::app()->user->isGuest){
         $model=StudentReg::model()->findByPk(Yii::app()->user->id);
         $modelReset = new StudentReg('resetemail');
         // if it is ajax validation request
         if(isset($_POST['ajax']) && $_POST['ajax']==='resetemail-form')
         {
             echo CActiveForm::validate($modelReset);
             Yii::app()->end();
         }
         // collect user input data
         $modelReset->attributes=Yii::app()->request->getPost('StudentReg');
         if(Yii::app()->request->getPost('StudentReg'))
         {
             $getToken=rand(0, 99999);
             $getTime=date("Y-m-d H:i:s");
             $model->token=sha1($getToken.$getTime);
         }
         if($model->validate())
         {
             $subject=Yii::t('recovery','0282');
             $headers="Content-type: text/plain; charset=utf-8 \r\n" . "From: IntITA";
             $text=Yii::t('recovery','0283').
                 " http://intita.itatests.com/index.php?r=site/veremail/view&token=".$model->token."&email=".$modelReset->email;
             $model->updateByPk($model->id, array('token' => $model->token,'activkey_lifetime' => $getTime));
             mail($modelReset->email,$subject,$text,$headers);
             $this->render('/site/changeemailinfo',array(
                 'model'=>$modelReset,
             ));
         }
     }
 }
Example #15
0
<?php
/**
 * Created by PhpStorm.
 * User: Wizlight
 * Date: 18.06.2015
 * Time: 22:05
 */
?>
<?php $addressee=StudentReg::model()->findByPk($data['addressee_id']);
if($data['status']==1) $style='completed'; else $style='';?>
<div class="letter">
    <span onclick="myLetterSpoiler(this)">
        <a>
            <div class="<?php if($data['status']==1) echo 'completed' ?>">
                <span class="addressee"><?php echo $addressee->email ?></span><span class="theme"><?php echo $data['theme'] ?></span><span class='timeletter'><?php echo $data['date'] ?></span>
            </div>
        </a>
    </span>
    <div class="spoilerBody">
        <img src="<?php echo StaticFilesHelper::createPath('image', 'avatars', $addressee->avatar); ?>"/>
        <table class="letterinfo">
            <tr>
                <td>
                    <div><?php echo $data['date'] ?></div>
                </td>
            </tr>
            <tr>
                <td>
                    <div><?php echo $addressee->email ?></div>
                </td>
            </tr>
Example #16
0
<?php
/**
 * Created by PhpStorm.
 * User: Wizlight
 * Date: 18.06.2015
 * Time: 22:05
 */
?>
<?php $sender=StudentReg::model()->findByPk($data['sender_id']);
if($data['status']==1) $style='completed'; else $style='';
?>
<div class="letter">
    <span onclick="letterSpoiler(this)">
    <?php
    echo CHtml::ajaxLink(
    "<div class='".$style."'><span class='addressee'>".$sender->email."</span><span class='theme'>".$data['theme']."</span><span class='timeletter'>".$data['date']."</span></div>",
    Yii::app()->createUrl('letters/StatusUpdate', array('id'=>$data['id'])),
    array(
    'update'=>'#statusLetter'
    )
    );
    ?>
    </span>
    <div class="spoilerBody">
        <img src="<?php echo StaticFilesHelper::createPath('image', 'avatars', $sender->avatar); ?>"/>
        <table class="letterinfo">
            <tr>
                <td>
                    <div><?php echo $data['date'] ?></div>
                </td>
            </tr>