<commit_before><?php

class HomeController extends Controller
{
	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */
	public $layout='//layouts/column2';

	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
			'getStudentId + index', // get student id first on advanced search scenario
		);
	}

	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			array('allow', // allow authenticated user to list all files
				'actions'=>array('index', 'batchDelete', 'updateCourses'),
				'users'=>array('@'),
			),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}

	
	/**
	 * Lists all notes.
	 */
	public function actionIndex()
	{
		$model = new Note('search');
		if (isset($_POST['Note']))
		{
			$model->attributes = $_POST['Note'];
			$dataProvider = $model->search();
		}
		else
		{
			$dataProvider=new CActiveDataProvider('Note');
		}
		$dataProvider->setPagination(array(
			'pageSize' => 4,
		));
		
		$students = Student::model()->findAll();
		$usernames = array();
		foreach ($students as $student)
		{
			$usernames[] = $student->username;
		}

		$this->render('index',array(
			'model' => $model,
			'dataProvider'=>$dataProvider,
			'usernames' => $usernames,
		));
	}

	/**
	 * Deletes notes in batch mode.
	 */
	public function actionBatchDelete()
	{
		if (isset($_POST['deleteNote']))
		{
			foreach ($_POST['deleteNote'] as $id)
			{
				$model = Note::model()->findByPk($id);
				$model->delete();
			}

			Yii::app()->user->setFlash('message', 'Berkas-berkas berhasil dihapus.');
			Yii::app()->user->setFlash('messageType', 'success');
		}
		$this->redirect(array('index'));
	}

	/**
	 * Performs the AJAX validation.
	 * @param Note $model the model to be validated
	 */
	protected function performAjaxValidation($model)
	{<commit_msg>Membetulkan batch delete<commit_after><?php

class HomeController extends Controller
{
	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */
	public $layout='//layouts/column2';

	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
			'getStudentId + index', // get student id first on advanced search scenario
		);
	}

	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			array('allow', // allow authenticated user to list all files
				'actions'=>array('index', 'batchDelete', 'updateCourses'),
				'users'=>array('@'),
			),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}

	
	/**
	 * Lists all notes.
	 */
	public function actionIndex()
	{
		$model = new Note('search');
		if (isset($_POST['Note']))
		{
			$model->attributes = $_POST['Note'];
			$dataProvider = $model->search();
		}
		else
		{
			$dataProvider=new CActiveDataProvider('Note');
		}
		$dataProvider->setPagination(array(
			'pageSize' => 4,
		));
		
		$students = Student::model()->findAll();
		$usernames = array();
		foreach ($students as $student)
		{
			$usernames[] = $student->username;
		}

		$this->render('index',array(
			'model' => $model,
			'dataProvider'=>$dataProvider,
			'usernames' => $usernames,
		));
	}

	/**
	 * Deletes notes in batch mode.
	 */
	public function actionBatchDelete()
	{
		if (isset($_POST['deleteNote']))
		{
			foreach ($_POST['deleteNote'] as $id => $value)
			{
				$model = Note::model()->findByPk($id);
				$model->delete();
			}

			Yii::app()->user->setFlash('message', 'Berkas-berkas berhasil dihapus.');
			Yii::app()->user->setFlash('messageType', 'success');
		}
		$this->redirect(array('index'));
	}

	/**
	 * Performs the AJAX validation.
	 * @param Note $model the model to be validated
	 */
	protected function performAjaxValidation($model)
	{
{'fraction_non_alphanumeric': 0.17291133348848034, 'fraction_numerical': 0.0018617640214102862, 'mean_word_length': 3.5099685204616997, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '810331', 'n_tokens_mistral': 1587, 'n_tokens_neox': 1368, 'n_words': 335}