403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  D:/wamp/www/sipapbd_2021_sekolah/update/application/modules/auth/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : D:/wamp/www/sipapbd_2021_sekolah/update/application/modules/auth/models/group_model.php
<?php
class Group_model extends Base_Model {

  var $fieldmap_daftar;
  var $fieldmap_filter;
  var $fieldmap_group;
  var $data;
  var $menu_akses;

   function __construct()
   {
    parent::__construct();

    $this->fieldmap_daftar = array(
      'ID',
      'NAME',
      'DESCRIPTION',
      'STATUS',
    );

    $this->fieldmap_filter = array(
      'nama' => 'a.name',
      'ket' => 'a.description',
    );

    $this->fieldmap_group = array(
      'id' => 'ID',
      'nama' => 'NAME',
      'deskripsi' => 'DESCRIPTION',
      'status'  => 'STATUS',
    );
  }

function recurse_fill($menu, $id_parent)
  {
    $data = array();
    $child = array();
    for ($i = 0; $i < count($menu); $i++)
    {
      if ($menu[$i]->aksi > 0)
      {
        $data[] = array(
          'ID' => $menu[$i]->id,
          'AKSI' => $menu[$i]->aksi,
        );      
      }

      if (isset($menu[$i]->children) && count($menu[$i]->children) > 0)
      {
        $child = $this->recurse_fill($menu[$i]->children, $menu[$i]->id);
        foreach($child as $child_menu)
        {
          array_push($data, $child_menu);
        }
      }
    }
    return $data;
  }

  function fill_data()
  {
    foreach($this->fieldmap_group as $key => $value){
      switch ($key){
        case 'status' : $$key = $this->input->post($key)  == 'true' ? 1 : 0; break;
        default : $$key = $this->input->post($key) ? $this->input->post($key) : NULL;
      }
      if(isset($$key))
        $this->data[$value] = $$key;
    }
    
    $menu = $this->input->post('menu');
    if ($menu)
    {
      $menu = json_decode($menu);
      $this->menu_akses = $this->recurse_fill($menu, 0);
    }
  }

  function get_grid_model()
  {
    $grid = array(
        'colNames' => array('Nama', 'Deskripsi', 'Aktif'),
        'colModel' => array(
          array('name' => 'name', 'width' => 200, 'sortable' => true),
          array('name' => 'ket', 'width' => 600, 'sortable' => true),
          array('name' => 'status', 'width' => 30, 'sortable' => true, 'edittype' => 'checkbox', 'formatter' => 'checkbox', 'editoptions' => '{value:"1:0"}', 'formatoptions' => '{disabled:true}', 'align' => 'center'),
        ),
    );
    return $grid;
  }

  // ----- search advance ---- >>
  function get_data_fields()
  {
    $fields = array(
          'nama' => array('name' => 'Nama', 'kategori'=>'string'),
          'ket' => array('name' => 'Deskripsi', 'kategori'=>'string'),
     );

    return $fields;
  }

  // Nama Group hanya boleh dipakai sekali
  function check_duplikasi_nama()
  {
    $id = $this->input->post('id') ? $this->input->post('id') : 0;
    $nama = $this->input->post('nama') ? $this->input->post('nama') : '';

    $this->db->select('count(1) dup')
        ->from('groups a')
        ->where('a.id <>', $id)
        ->where('a.name', $nama)
        ->where('a.appid', $this->app_id);
    $rs = $this->db->get()->row_array();

    return (integer) $rs['DUP'] < 1;
  }

  /* Simpan data Group */
  function insert_group()
  {
    $id = isset($this->data['ID']) ? $this->data['ID'] : 0;
    
    $this->db->select('1')->from('groups')->where('id', $id);
    $rs = $this->db->get()->row_array();

    if ($rs)
    {
      $this->db->where('id', $id);
      $this->db->where('appid', $this->app_id);
      $this->db->update('groups', $this->data);
      $this->id = $this->data['ID'];
    }
    else
    {
      unset($this->data['ID']);
      $this->data['APPID'] = $this->app_id;
      $this->db->insert('groups', $this->data);
      $this->db->select_max('id')->from('groups');
      $rs = $this->db->get()->row_array();
      $this->id = $rs['ID'];
    }
  }

  function insert_akses()
  {
    /* hapus dulu akses menu yang ada */
    $this->db->where('a.group_id', $this->id);
    $this->db->delete('m_privilege a');

    /* simpan semua akses menu */
    foreach($this->menu_akses as $akses)
    {
      $akses['GROUP_ID'] = $this->id;
      $this->db->insert('m_privilege', $akses);
    }
  }

  function save_detail()
  {
    $this->insert_group();
    $this->insert_akses();
  }

  /* query hapus */
  function build_query_hapus($id=0)
  {
    $total = count($id);

    for($i = 0;$i < $total;$i++){
      $this->db->where('id', $id[$i])->delete('groups');
    }

    for($i = 0;$i < $total;$i++){
      $this->db->where('GROUP_ID', $id[$i])->delete('m_privilege');
    }
  }

  /* Query daftar */
  function build_query_daftar()
  {
    $this->db->select("
        a.id,
        a.name,
        a.description,
        a.status,
    ");
    $this->db->from('groups a');
    $this->db->where('a.appid', $this->app_id);
  }

  function build_query_form($id=0)
  {
    $this->db->select("
        a.id,
        a.name,
        a.description,
        a.status, 
    ");
    $this->db->from('groups a');
    $this->db->where('a.id', $id);
  }

  function get_menu($id_parent = 0, $id_group = 0)
  {
    $this->db->select('a.id, a.title, coalesce(b.aksi, 0) aksi');
    $this->db->from('menu a');
    $this->db->join('m_privilege b', 'b.id = a.id and b.group_id = '.$id_group, 'left');
    $this->db->where('a.parent_id', $id_parent);
    $this->db->where('a.id <>','1');
    $this->db->where('a.aktif', '1');
    $this->db->where('a.appid', $this->app_id);
    $this->db->order_by('a.order_by');
    $result = $this->db->get();

    $x = 0;
    $menu = array();
    $res_menu   = $result->result();
    foreach($res_menu as $hasil){
      $menu[$x]['ID'] = $hasil->ID;
      $menu[$x]['TITLE'] = $hasil->TITLE;
      $menu[$x]['AKSI'] = $hasil->AKSI;
      $menu[$x]['child'] = $this->get_menu($hasil->ID, $id_group); //ambil menu anak
      $x++;
    }
    return $menu;
  }

  function get_prev_id($id)
  {
    $this->db->select('coalesce(max(a.id), 0) id')
      ->from('groups a')
      ->where('a.appid', $this->app_id)
      ->where('a.id < ', $id);
    $result = $this->db->get()->row_array();

    return $result['ID'];
  }

  function get_next_id($id)
  {
    $this->db->select('coalesce(min(a.id), 0) id')
      ->from('groups a')
      ->where('a.appid', $this->app_id)
      ->where('a.id > ', $id);
    $result = $this->db->get()->row_array();

    return $result['ID'];
  }

  function check_dependency($id)
  {
    // group tidak boleh dihapus jika sudah dipakai user
    $this->db->select('count(id) USER_PAKAI');
    $this->db->from('users');
    if ($this->app_id == 'SIPKD')
      $this->db->where_in('group_id', $id);
    else if ($this->app_id == 'APBD')
      $this->db->where_in('group_id2', $id);
    $result = $this->db->get()->row_array();

    return  !($result['USER_PAKAI'] > 0);
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit