Exemplo n.º 1
0
 function view($args)
 {
     $id = array_shift($args);
     $permission = R::load('permission', $id);
     if (!is_numeric($id) && !$permission->getID()) {
         $this->redirect(PACKAGE_URL);
     }
     $allgroups = R::findAll('group');
     foreach ($allgroups as $key => $group) {
         foreach ($permission->sharedGroup as $group_c) {
             if ($group->id == $group_c->id) {
                 $allgroups[$key]->checked = true;
             }
         }
     }
     //		echo $permission->name;exit;
     $view = new G2_TwigView('pages/view');
     $view->permission = $permission;
     $view->allGroups = $allgroups;
     $form = new G2_FormMagic($view->get_render());
     if ($form->is_posted()) {
         $groups = R::loadAll('group', array_keys($form->data()['groups']));
         $permission->sharedGroup = $groups;
         R::store($permission);
         Admin_Alert::add_message("\"{$permission->name}\" permission was updated");
         $this->redirect(PACKAGE_URL);
     }
     echo $form->parse();
 }
Exemplo n.º 2
0
 /**
  *
  * @param \RedBeanPHP\OODBBean $old_object
  * @param \RedBeanPHP\OODBBean $new_object
  * @param type $message
  */
 public static function create($old_object, $new_object, $message, $entity = false)
 {
     //Determine the current user
     $audit = R::dispense('audit');
     $audit->message = $message;
     $audit->date_logged = date('Y-m-d H:i:s');
     $audit->table = $new_object ? $new_object->getMeta('type') : null;
     $audit->entity = $entity ? $entity : $audit->table;
     $aidit->tableId = $new_object ? $new_object->id : $old_object->id;
     $audit->old_obj = serialize($old_object);
     $audit->new_obj = serialize($new_object);
     $audit->user = G()->get_user();
     R::store($audit);
     //		$user->ownAudit[] = $audit;
     //		R::store($user);
     Admin_Alert::add_message($message . ' <a href="' . ADMIN_URL . "package/audit/changes/{$audit->id}" . '">View Change</a>');
 }