コード例 #1
0
ファイル: Comment.php プロジェクト: nurmanhabib/elearning
 public function store()
 {
     $article = Model\Article::findOrFail(set_value('article_id'));
     $this->form_validation->set_rules('name', 'Name', 'required');
     $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
     $this->form_validation->set_rules('content', 'Komentar', 'required');
     $this->form_validation->set_rules('article_id', 'Artikel', 'required');
     if ($this->form_validation->run() == FALSE) {
         if ($this->request->isXmlHttpRequest()) {
             $response = new Response();
             $response->setContent(json_encode(['status' => 'error', 'data' => $this->form_validation->error_array()]));
             $response->headers->set('Content-Type', 'application/json');
         } else {
             keepValidationErrors();
             redirect($article->link . '#comment-title', 'refresh');
         }
     } else {
         $data = array('content' => set_value('content'), 'nama' => set_value('name'), 'email' => set_value('email'), 'artikel_id' => set_value('article_id'), 'parent' => set_value('parent', 0), 'date' => Carbon::now());
         $comment = Model\Comment::create($data);
         if (auth()->loginCheck()) {
             $comment->user()->associate(auth()->user()->id);
             $comment->save();
         }
         if ($this->request->isXmlHttpRequest()) {
             $response = new Response();
             $response->setContent(json_encode(['status' => 'success', 'data' => $comment]));
             $response->headers->set('Content-Type', 'application/json');
         } else {
             redirect($article->link . '#comment-' . $comment->id, 'refresh');
         }
     }
 }
コード例 #2
0
ファイル: Category.php プロジェクト: ruly1992/elearning
 public function create()
 {
     $this->form_validation->set_rules('name', 'Nama', 'required');
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
         redirect('forum/category', 'refresh');
     } else {
         $name = $this->input->post('name');
         $users = $this->input->post('tenagaahli', []);
         $same = FALSE;
         $categories = Model\Forum\Category::all();
         foreach ($categories as $cat) {
             if ($cat->category_name == $name) {
                 $same = TRUE;
             }
         }
         if ($same == FALSE) {
             $category = new Model\Forum\Category();
             $category->name = $name;
             $category->save();
             $category->users()->attach($users);
             set_message_success('Kategori forum berhasil ditambahkan.');
         } else {
             set_message_error('Kategori ' . $name . ' sudah ada.');
         }
         redirect('forum/category', 'refresh');
     }
 }
コード例 #3
0
ファイル: Category.php プロジェクト: singgihsap/elearning
 public function add()
 {
     $this->form_validation->set_rules('name', 'Nama Kategori', 'required|callback_category_name_check[0]');
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
         redirect('elibrary/category', 'refresh');
     } else {
         $name = set_value('name');
         $description = set_value('description');
         $this->medialib->createCategory($name, $description);
         $category = $this->medialib->getCategory();
         set_message_success('Kategori berhasil dibuat.');
         redirect('elibrary/category', 'refresh');
     }
 }
コード例 #4
0
ファイル: Category.php プロジェクト: singgihsap/elearning
 public function create()
 {
     $this->form_validation->set_rules('name', 'Nama', 'required');
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
         redirect('forum/category', 'refresh');
     } else {
         $name = $this->input->post('name');
         $users = $this->input->post('tenagaahli', []);
         $category = new Model\Forum\Category();
         $category->name = $name;
         $category->save();
         $category->users()->attach($users);
         set_message_success('Kategori forum berhasil ditambahkan.');
         redirect('forum/category', 'refresh');
     }
 }
コード例 #5
0
 public function index()
 {
     $data = array('links' => $this->Mod_link->read(), 'desa_lists' => ['Wilayah 1', 'Wilayah 2', 'Wilayah 3']);
     $this->form_validation->set_rules('nama', 'Nama Lengkap', 'required');
     $this->form_validation->set_rules('email', 'Alamat Email', 'required|valid_email');
     $this->form_validation->set_rules('title', 'Title', 'required');
     $this->form_validation->set_rules('content', 'Content', 'required');
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
         $this->template->build('create', $data);
     } else {
         $data = array('title' => set_value('title'), 'content' => set_value('content', '', FALSE));
         $article = new Library\Article\Article();
         $article->submit($data, set_value('nama'), set_value('email'), set_value('desa'), $this->input->post('featured'), $this->input->post('custom_avatar'));
         set_message_success('Artikel Anda sudah diterima dan akan dilakukan moderasi terlebih dahulu.');
         redirect('submitarticle', 'refresh');
     }
 }
コード例 #6
0
ファイル: Comment.php プロジェクト: ruly1992/elearning
 public function store()
 {
     $article = Model\Portal\Article::withPrivate()->findOrFail(set_value('article_id'));
     $this->form_validation->set_rules('name', 'Name', 'required');
     $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
     $this->form_validation->set_rules('content', 'Komentar', 'required');
     $this->form_validation->set_rules('article_id', 'Artikel', 'required');
     if ($this->form_validation->run() == FALSE) {
         if ($this->request->isXmlHttpRequest()) {
             $response = new Response();
             $response->setContent(json_encode(['status' => 'error', 'data' => $this->form_validation->error_array()]));
             $response->headers->set('Content-Type', 'application/json');
         } else {
             keepValidationErrors();
             redirect($article->link . '#comments', 'refresh');
         }
     } else {
         $data = array('content' => set_value('content'), 'nama' => set_value('name'), 'email' => set_value('email'), 'artikel_id' => set_value('article_id'), 'parent' => set_value('parent', 0), 'status' => 'draft', 'date' => Carbon::now());
         $comment = Model\Portal\Comment::create($data);
         if ($user = auth()->check()) {
             $comment->user()->associate($user->id);
             if ($user->inRole(['su', 'adm', 'edt', 'ins', 'mdr'])) {
                 $comment->status = 'publish';
             } else {
                 $comment->status = 'draft';
             }
             $comment->save();
         }
         if ($this->request->isXmlHttpRequest()) {
             $response = new Response();
             $response->setContent(json_encode(['status' => 'success', 'data' => $comment]));
             $response->headers->set('Content-Type', 'application/json');
         } else {
             if ($comment->status == 'publish') {
                 set_message_success('Komentar Anda sudah ditampilkan.');
                 redirect($article->link . '#comment-' . $comment->id, 'refresh');
             } else {
                 set_message_success('Komentar Anda akan tampil setelah dimoderasi.');
                 redirect($article->link . '#comments', 'refresh');
             }
         }
     }
 }
コード例 #7
0
ファイル: Comment.php プロジェクト: amteknologi/elearning
 public function storechapter()
 {
     $chapter = Model\Kelas\Chapter::findOrFail(set_value('chapter_id'));
     $this->form_validation->set_rules('name', 'Name', 'required');
     $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
     $this->form_validation->set_rules('content', 'Komentar', 'required');
     $this->form_validation->set_rules('chapter_id', '', 'required');
     if ($this->form_validation->run() == FALSE) {
         if ($this->request->isXmlHttpRequest()) {
             $response = new Response();
             $response->setContent(json_encode(['status' => 'error', 'data' => $this->form_validation->error_array()]));
             $response->headers->set('Content-Type', 'application/json');
         } else {
             keepValidationErrors();
             redirect('course/showchapter/' . $chapter->course->slug . '/chapter-' . $chapter->order . '#comment-' . $comment->id, 'refresh');
         }
     } else {
         $data = array('content' => set_value('content'), 'name' => set_value('name'), 'email' => set_value('email'), 'chapter_id' => set_value('chapter_id'), 'parent' => set_value('parent', 0), 'status' => 'draft');
         $comment = Model\Kelas\ChapterComment::create($data);
         if ($user = auth()->check()) {
             $comment->user()->associate($user->id);
             if ($user->inRole(['su', 'adm', 'edt', 'ins', 'mdr'])) {
                 $comment->status = 'publish';
             } else {
                 $comment->status = 'draft';
             }
             $comment->save();
         }
         if ($this->input->is_ajax_request()) {
             $response = new Response();
             $response->setContent(json_encode(['status' => 'success', 'data' => $comment]));
             $response->headers->set('Content-Type', 'application/json');
         } else {
             if ($comment->status == 'publish') {
                 set_message_success('Komentar Anda sudah ditampilkan.');
                 redirect('course/showchapter/' . $chapter->course->slug . '/chapter-' . $chapter->order . '#comment-' . $comment->id, 'refresh');
             } else {
                 set_message_success('Komentar Anda akan tampil setelah dimoderasi.');
                 redirect('course/showchapter/' . $chapter->course->slug . '/chapter-' . $chapter->order . '#form-comment', 'refresh');
             }
         }
     }
 }
コード例 #8
0
ファイル: Login.php プロジェクト: nurmanhabib/elearning
 public function index()
 {
     $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
     $this->form_validation->set_rules('password', 'Password', 'required');
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
         $this->template->set_layout('login');
         $this->template->build('login');
     } else {
         $credentials = ['email' => set_value('email'), 'password' => set_value('password')];
         if (sentinel()->authenticate($credentials)) {
             $redirect_url = dashboard_url();
             redirect($redirect_url, 'refresh');
         } else {
             set_message_error('Email atau password Anda salah.');
             redirect(login_url(), 'refresh');
         }
     }
 }
コード例 #9
0
ファイル: Kategori.php プロジェクト: singgihsap/elearning
 public function add()
 {
     $this->form_validation->set_rules('name', 'Kategori', 'required|is_unique[kategori.name]');
     if ($this->form_validation->run() == FALSE) {
         $data['kategori'] = $this->model->getLists();
         keepValidationErrors();
         redirect('kategori');
     } else {
         $kategori['name'] = set_value('name');
         $kategori['description'] = set_value('description');
         $kategori['parent'] = $this->input->post('parent');
         $editor = set_value('editor', []);
         $category = Model\Portal\Category::create($kategori);
         if ($editor) {
             $category->editors()->attach($editor);
         }
         set_message_success('Kategori berhasil ditambahkan.');
         redirect('kategori');
     }
 }
コード例 #10
0
ファイル: Submitarticle.php プロジェクト: fajarekos/elearning
 public function index()
 {
     $data = array('links' => $this->Mod_link->read(), 'category_lists' => (new Model\Portal\Category())->generateCheckbox());
     $this->form_validation->set_rules('nama', 'Nama Lengkap', 'required', array('required' => '<div class="alert alert-danger">Nama Wajib diisi</div>'));
     $this->form_validation->set_rules('email', 'Alamat Email', 'required|valid_email', array('required' => '<div class="alert alert-danger">Email Wajib diisi</div>'));
     $this->form_validation->set_rules('title', 'Title', 'required', array('required' => '<div class="alert alert-danger">Judul Artikel Wajib diisi</div>'));
     $this->form_validation->set_rules('content', 'Content', 'required', array('required' => '<div class="alert alert-danger">Content Artikel Wajib diisi</div>'));
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
         $this->template->build('create', $data);
     } else {
         $data = array('title' => set_value('title'), 'content' => set_value('content', '', FALSE));
         $article = new Library\Article\Article();
         $article->submit($data, set_value('nama'), set_value('email'), set_value('desa'), set_value('categories[]'), null, $this->input->post('customavatar[src]'));
         if ($this->input->post('featured[src]')) {
             $article->setFeaturedImage($this->input->post('featured[src]'), $this->input->post('featured[description]'));
         }
         set_message_success('Artikel Anda sudah diterima dan akan dilakukan moderasi terlebih dahulu.');
         redirect('submitarticle', 'refresh');
     }
 }
コード例 #11
0
 public function index()
 {
     $data = array('links' => $this->Mod_link->read());
     $this->form_validation->set_rules('nama', 'Nama Lengkap', 'required');
     $this->form_validation->set_rules('email', 'Alamat Email', 'required|valid_email');
     $this->form_validation->set_rules('title', 'Title', 'required');
     $this->form_validation->set_rules('content', 'Content', 'required');
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
         $this->template->build('create', $data);
     } else {
         $data = array('nama' => set_value('nama'), 'email' => set_value('email'), 'title' => set_value('title'), 'content' => set_value('content', '', FALSE));
         if (isset($_FILES['featured']) && $_FILES['featured']['tmp_name']) {
             $featured_image = $_FILES['featured'];
         } else {
             $featured_image = null;
         }
         $id = $this->Mod_sendarticle->send($data, 'draft', 'public', $featured_image, []);
         // $this->Mod_sendarticle->send($data);
         set_message_success('Artikel Anda sudah diterima dan akan dilakukan review terlebih dahulu.');
         redirect('submitarticle', 'refresh');
     }
 }
コード例 #12
0
ファイル: Dashboard.php プロジェクト: ruly1992/elearning
 public function changepassword()
 {
     $user_id = auth()->getUser()->id;
     $this->form_validation->set_rules('password', 'New Password', 'required|min_length[6]');
     $this->form_validation->set_rules('password_confirmation', 'New Password Confirmation', 'required|min_length[6]|matches[password]');
     $this->form_validation->set_rules('password_old', 'Old Password', 'required');
     if ($this->form_validation->run() == FALSE) {
         $data['user'] = auth()->findById($user_id);
         keepValidationErrors();
         $this->template->set('sidebar');
         $this->template->set_layout('privatepage');
         $this->template->build('changePassword', $data);
     } else {
         $password = set_value('password');
         $password_old = set_value('password_old');
         $changed = $this->model->changePassword($user_id, $password, $password_old);
         if ($changed) {
             set_message_success('Password berhasil diperbarui.');
             redirect('dashboard/profile/' . $user_id, 'refresh');
         } else {
             set_message_error('Password lama tidak sesuai.');
             redirect('dashboard/profile/' . $user_id, 'refresh');
         }
     }
 }
コード例 #13
0
ファイル: Article.php プロジェクト: fajarekos/elearning
 public function edit($id)
 {
     $this->form_validation->set_rules('title', 'Title', 'trim|required');
     $this->form_validation->set_rules('content', 'Content', 'required');
     $this->form_validation->set_rules('categories[]', 'Category', 'required');
     if ($this->form_validation->run() == FALSE) {
         $artikel = Model\Portal\Article::withDrafts()->withPrivate()->findOrFail($id);
         keepValidationErrors();
         $cat_ids = array_map(function ($cat) {
             return $cat->kategori_id;
         }, $this->M_kategori->getByArticle($id));
         $tag_ids = array();
         foreach ($this->M_tags->getByArticle($id) as $row) {
             $tag_ids[$row->tag] = $row->tag;
         }
         $data['artikel'] = $artikel;
         $data['categories_checkbox'] = $this->M_kategori->generateCheckbox(0, $cat_ids);
         $data['tags'] = $tag_ids;
         $data['status'] = $this->status;
         $this->template->build('edit', $data);
     } else {
         $artikel = array('title' => set_value('title'), 'content' => set_value('content', '', FALSE), 'status' => set_value('status'));
         $article = Model\Portal\Article::withDrafts()->withPrivate()->find($id);
         if ($article->editor_id == 0) {
             $artikel['editor_id'] = auth()->getUser()->id;
         }
         if (set_value('with_schedule', 0)) {
             $artikel['published'] = set_value('published');
         } else {
             $artikel['published'] = '0000-00-00 00:00:00';
         }
         $categories = set_value('categories', array());
         $tags = set_value('tags', array());
         $repo_library = new Library\Article\Article();
         $repo_library->set($article);
         if ($this->input->post('featured[src]') && $this->input->post('featured[action]') == 'upload') {
             $repo_library->setFeaturedImage($this->input->post('featured[src]'), $this->input->post('featured[description]'));
         } elseif ($this->input->post('featured[action]') == 'remove') {
             $repo_library->removeFeaturedImage();
         }
         if ($this->input->post('slider[src]') && $this->input->post('slider[action]') == 'upload') {
             $repo_library->setSliderImage($this->input->post('slider[src]'));
         } elseif ($this->input->post('slider[action]') == 'remove') {
             $repo_library->removeSliderImage();
         }
         $id = $this->Mod_artikel->update($id, $artikel, $categories, $tags);
         set_message_success('Artikel berhasil diperbarui.');
         redirect('article/edit/' . $id, 'refresh');
     }
 }
コード例 #14
0
ファイル: Elibrary.php プロジェクト: amteknologi/elearning
 public function pengampu_tambah()
 {
     $this->form_validation->set_rules('user_id', 'Pustakawan', 'required');
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
     } else {
         $users = $this->input->post('user_id');
         $category = $this->input->post('category_id');
         $temp = FALSE;
         $data = $this->category_model->getPengampu();
         foreach ($data as $row) {
             if ($row->user_id == $users && $row->category_id == $category) {
                 $temp = TRUE;
             }
         }
         if ($temp == FALSE) {
             $data = array('user_id' => $users, 'category_id' => $category);
             $save = $this->category_model->addPengampu($data);
             set_message_success('data berhasil ditambahkan.');
         } else {
             set_message_error('Data sudah ada.');
         }
         redirect('elibrary/pengampu', 'refresh');
     }
 }
コード例 #15
0
ファイル: Konsultasi.php プロジェクト: singgihsap/elearning
 public function pengampu_tambah()
 {
     $this->form_validation->set_rules('user_id', 'Tenaga Ahli', 'trim|required');
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
     } else {
         $users = $this->input->post('user_id');
         $kategori_list = $this->input->post('id_kategori');
         $data = array('user_id' => $users, 'id_kategori' => $kategori_list);
         $save = $this->model->addPengampu($data);
         set_message_success('data berhasil ditambahkan.');
         redirect('konsultasi/pengampu', 'refresh');
     }
 }
コード例 #16
0
ファイル: Reset.php プロジェクト: fajarekos/elearning
    public function index()
    {
        $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
        if ($this->form_validation->run() == FALSE) {
            keepValidationErrors();
            $this->template->set_layout('reset');
            $this->template->build('reset');
        } else {
            $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
            $credentials = ['email' => set_value('email')];
            $user = sentinel()->findUserByCredentials($credentials);
            if ($user) {
                $code = (new Reminder())->createCode($user);
                $mail = new PHPMailer();
                $mail->isSMTP();
                // Set mailer to use SMTP
                $mail->Host = 'smtp.gmail.com';
                // Specify main and backup SMTP servers
                $mail->SMTPAuth = true;
                // Enable SMTP authentication
                $mail->Username = getenv('EMAIL_USERNAME');
                // SMTP username
                $mail->Password = getenv('EMAIL_PASSWORD');
                // SMTP password
                $mail->SMTPSecure = 'tls';
                // Enable TLS encryption, `ssl` also accepted
                $mail->Port = 587;
                // TCP port to connect to
                $mail->setFrom('*****@*****.**', 'Admin Desa Membangun');
                $mail->addAddress($email);
                // Add a recipient
                $mail->isHTML(true);
                $mail->Subject = 'Reset Password Aku Desa Membangun';
                $mail->Body = '<center>
							        <table cellspacing="0" cellpadding="0" border="0" style="border-radius:4px;margin:0;padding:0;width:100%;max-width:664px;border:1px solid #dadedf">
							                <tbody>
							                        <tr>
							                                <td style="padding:20px 20px 17px 40px;background-color:#f5f6f7;border-bottom:1px solid #dadedf">
							                                        <table cellspacing="0" cellpadding="0" border="0" style="padding:0;width:100%;margin:0;text-align:left">
							                                                <tbody>
							                                                        <tr>
							                                                                <td style="width:80px">
							                                                                        <img height="50" src="http://122.200.145.178/public/images/logo.png" class="CToWUd">
							                                                                </td>
							                                                        </tr>
							                                                </tbody>
							                                        </table>
							                                </td>
							                        </tr>
							                        <tr>
							                                <td style="padding:36px 40px 40px 40px;font-size:18px;color:#47515d;border-bottom:1px solid #dadedf;font-family:Arial,Verdana,sans-serif;text-align:left">
							                                        Hi ' . $email . '<br><br>                                                        
							                                        Anda menerima email ini karena ada permintaan untuk memperbarui kata sandi anda.
							                                        Klik tautan dibawah.
							                                        <br><br>
							                                        <a href =' . site_url("reset/check_user/" . $code->user_id . "/" . $code->code . "") . '>Reset Password</a>
							                                        <br><br>
							                                        Jika anda tidak meminta ini, abaikan.
							                                        <br><br>
							                                       -Admin Desa Membangun-
							                                </td>
							                        </tr>
							                </tbody>
							        </table>
							</center>';
                if (!$mail->send()) {
                    set_message_error('Email gagal dikirim');
                    $this->template->set_layout('reset');
                    $this->template->build('reset');
                } else {
                    set_message_success('Silahkan cek email anda untuk reset password');
                    $this->template->set_layout('reset');
                    $this->template->build('reset');
                }
            } else {
                set_message_error('Maaf email tidak terdaftar');
                $this->template->set_layout('reset');
                $this->template->build('reset');
            }
        }
    }
コード例 #17
0
ファイル: Course.php プロジェクト: fajarekos/elearning
 public function editIndex($id)
 {
     $this->form_validation->set_rules('name', 'Name', 'required');
     $this->form_validation->set_rules('category_id', 'Category', 'required');
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
         $this->template->build('course/edit');
     } else {
         $course = Model\Kelas\Course::withDrafts()->findOrFail($id);
         $course->name = set_value('name');
         $course->description = set_value('description', '', FALSE);
         $course->category_id = set_value('category_id');
         $course->save();
         set_message_success('Informasi kelas berhasil diperbarui.');
         redirect('dashboard/course/edit/' . $course->id, 'refresh');
     }
 }
コード例 #18
0
ファイル: Konsultasi.php プロジェクト: ruly1992/elearning
 public function pengampu_tambah()
 {
     $this->form_validation->set_rules('user_id', 'Tenaga Ahli', 'required');
     if ($this->form_validation->run() == FALSE) {
         keepValidationErrors();
     } else {
         $users = $this->input->post('user_id');
         $kategori_list = $this->input->post('id_kategori');
         $temp = FALSE;
         $data = $this->model->getPengampu();
         foreach ($data as $row) {
             if ($row->user_id == $users && $row->id_kategori == $kategori_list) {
                 $temp = TRUE;
             }
         }
         if ($temp == FALSE) {
             $data = array('user_id' => $users, 'id_kategori' => $kategori_list);
             $save = $this->model->addPengampu($data);
             set_message_success('data berhasil ditambahkan.');
         } else {
             set_message_error('Data sudah ada.');
         }
         redirect('konsultasi/pengampu', 'refresh');
     }
 }