Beispiel #1
0
 public static function hasCredential($groupid, $cred)
 {
     $g = new groupsModel();
     $rs = $g->get($groupid);
     if (is_string($groupid)) {
         return in_array($cred, $rs->credentials);
     }
     foreach ($rs->credentials as $name) {
         $c = new credentialModel();
         $c->name = $name;
         $rc = $c->get(array('name'));
         if ($rc->id == $cred) {
             return true;
         }
     }
     return false;
 }
Beispiel #2
0
 public function get($userid = null)
 {
     if (empty($userid)) {
         $userid = $this->id;
     }
     $grm = new groupsModel();
     $sql = 'SELECT groupid FROM pfmuser_group WHERE userid=' . $userid;
     if ($GLOBALS['conf']->db_debug) {
         print $sql . '<br />';
     }
     $ds = $grm->rawQuery($sql);
     $resp = array();
     while ($row = mysqli_fetch_object($ds)) {
         $resp[] = $this->groups[] = $grm->get($row->groupid);
     }
     $user = parent::get($userid);
     $user->groups = $this->groups;
     return $user;
 }
<?php

$groupsModel = new groupsModel();
if (!empty($_POST)) {
    #Guardar formulario
    if ($_POST['act'] == 'save') {
        $groupsModel->cargarPorId($_POST['group_id']);
        $groupsModel->setValues($_POST);
        $groupsModel->save();
        die(json_encode(array('msg' => 'El registro fue guardado correctamente', 'type' => 'success')));
    }
    #Listar datatable
    if ($_POST['act'] == 'listar') {
        $pager = $groupsModel->getPager(array('group_id', 'group_name', 'group_description', 'is_disabled'));
        die($pager->getJSON());
    }
    #Eliminar registro
    if ($_POST['act'] == 'delete') {
        $groupsModel->cargarPorId($_POST['id']);
        $groupsModel->delete();
        die(json_encode(array('msg' => 'El registro fue eliminado correctamente', 'type' => 'success')));
    }
    #cargar para editar registro
    if ($_POST['act'] == 'edit') {
        die(json_encode(array('data' => $groupsModel->cargarPorId($_POST['id']))));
    }
} else {
    echo $engine->render('groups', $aParams);
    exit;
}