public function actionGetRequestInfo()
    {
        if (Yii::app()->request->isAjaxRequest && isset($_POST['request_id']) ) {


            //get support_request info
            $sup_req = SupportRequests::model()->findByPk(intval($_POST['request_id']));


            //get user questions
            $user = Users::model()->findByAttributes(array(
                'User_Login'=>strval($_POST['login']),
            ));
            $user_id = $user->User_ID;
            $users_questions =   UsersQuestions::getUserQuestions($user_id);

            $users_settings = UsersSettings::model()->findByAttributes(array(
                'User_ID'=>$user_id
            ));


            $device= UsersDevices::model()->findByAttributes(array(
                'Device_ID'=>$sup_req->User_Device_ID,
                'Remote_Login'=>1
            ));

            //return json to js

            $this->renderPartial('admin_side_view',array(
                'sup_req'=>$sup_req,
                'users_questions'=>$users_questions,
                'device'=>$device,
                'users_settings'=>$users_settings,
                'user_id'=>$user_id
            ));


        }

    }
Example #2
0
            <div style="text-align: left;">
                <?echo $form->checkBox($user_settings,'Use_Device_Checking',array('checked'=>$user_settings->Use_Device_Checking ? 'checked' : ''));?>
                Strengthen user authentication by device checking
                <?php echo $form->error($user_settings,'Use_Device_Checking'); ?>
            </div>

            <div id="three_questions" style="padding-left: 30px;padding: 5px ;margin-bottom:10px; border: 1px solid #d3d3d3; display: none;">
                Your three "Question-Answer" pairs which allow you to login from new devices:
                <?
                if (count($users_questions)>0) {
                    $i=1;
                    foreach ($users_questions as $question) {

                        echo '<div class="row" style="padding-left: 10px;margin-bottom:15px;margin-top: 9px; ">';
                        //echo $i.') ';
                        echo CHtml::dropDownList('question','',UsersQuestions::getAllQuestions(),array(
                            'options'=>array(
                                $question['Question_ID']=>array('selected'=>'selected')),
                                'class'=>'questions_dropdown',
                                'id'=>false
                        ));
                        echo '<br/>';
                        echo '<input type="text" class="answer" name=answers['.$question['Question_ID'].'] value="'.$question['Hint'].'" autocomplete="off" >';
                        echo '<div class="input_error" style="display: none;color: #ff0000;font-size: 10px;">Value can\'t be empty! Value can contain only literal symbols and digits! </div>';
                        echo '<br/>';
                        $i++;
                        echo '</div>';
                    }
                }
                ?>
                <button class="not_active_button" href="#" id="save_questions" style="padding:0px 6px;"> Save security questions </button>
Example #3
0
    public static function getAllQuestionsWithEmpty (){
        $questions = UsersQuestions::model()->findAll();
        $result[-1] = 'Select question';
        foreach ($questions as $question) {
            $result[$question->Question_ID]= $question->Text;
        }

        return $result;

    }
    /**
     * Lists all models.
     */
    public function actionIndex()
    {
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $id = intval($_POST["id"]);
            $question = UsersQuestions::model()->findByPk($id);
            if ($question) {

                $error_string= '';


                $question->Text = $_POST['Text'] ? $_POST["Text"] : ' ';


                if ($question->validate() && $error_string == '') {
                    $question->save();
                    echo "video\n";
                } else {
                    die($error_string);
                }
            }

            die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'add') {

           // var_dump($_POST);die;
            $error_string= '';
            $question = new UsersQuestions();
            $question->Text = $_POST['Text'] ? $_POST["Text"] : ' ';

            if ($question->validate() && $error_string == '') {
                $question->save();
                echo "video\n";
            } else {
                die($error_string);
            }

        die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {

            $id = intval($_POST["id"]);
            $question = UsersQuestions::model()->findByPk($id);
            if ($question) {
                    $question->delete();
            }

            die;


        }

        $conn = mysql_connect(Yii::app()->params->dbhost, Yii::app()->params->dbuser, Yii::app()->params->dbpassword);
        mysql_select_db(Yii::app()->params->dbname);
        mysql_query("SET NAMES 'utf8'");

        Yii::import('ext.phpgrid.inc.jqgrid');

        // set columns
        $col = array();
        $col["title"] = "Question_ID"; // caption of column
        $col["name"] = "Question_ID";
        $col["dbname"] = "Question_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Text"; // caption of column
        $col["name"] = "Text";
        $col["dbname"] = "Text"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $g = new jqgrid();

        $grid["caption"] = "Security questions";
        // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'Question_ID';
        $grid["sortorder"] = "ASC";
        $grid["add_options"] = array(
            'width'=>'420',
            "closeAfterEdit"=>true, // close dialog after add/edit
            "top"=>"200", // absolute top position of dialog
            "left"=>"200" // absolute left position of dialog
        );

        $g->set_options($grid);

        $g->set_actions(array(
                "add"=>true, // allow/disallow add
                "edit"=>true, // allow/disallow edit
                "delete"=>true, // allow/disallow delete
                "rowactions"=>true, // show/hide row wise edit/del/save option
                "export"=>true, // show/hide export to excel option
                "autofilter" => true, // show/hide autofilter for search
                "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
            )
        );

        $g->select_command = "SELECT users_questions.*
                              FROM users_questions";

        // set database table for CRUD operations
        $g->table = "users_questions";

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Question_ID', // group starts from this column
                        "numberOfColumns"=>2, // group span to next 2 columns
                        "titleText"=>'Questions' // caption of group header
                    ),
                )
            )
        );

        // render grid and get html/js output
        $out = $g->render("Questions");

        $this->render('index',array(
            'out'=>$out,
        ));
    }