public static function process($action = 'list', $id = null) { $errors = array(); if ($_SERVER['REQUEST_METHOD'] == 'POST' && $action == 'edit') { // instancia $data = array('id' => $_POST['id'], 'name' => $_POST['name'], 'amount' => $_POST['amount']); if (WorthLib::save($data, $errors)) { $action = 'list'; Message::Info(Text::_('Nivel de meritocracia modificado')); // Evento Feed $log = new Feed(); $log->populate(Text::_('Nivel de meritocracia modificado'), '/admin/worth', \vsprintf("El admin %s ha %s el nivel de meritocrácia %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Modificado'), Feed::item('project', $icon->name)))); $log->doAdmin('admin'); unset($log); } else { Message::Error(Text::_('No se ha guardado correctamente. ') . implode('<br />', $errors)); return new View('view/admin/index.html.php', array('folder' => 'worth', 'file' => 'edit', 'action' => 'edit', 'worth' => (object) $data)); } } switch ($action) { case 'edit': $worth = WorthLib::getAdmin($id); return new View('view/admin/index.html.php', array('folder' => 'worth', 'file' => 'edit', 'action' => 'edit', 'worth' => $worth)); break; } $worthcracy = WorthLib::getAll(); return new View('view/admin/index.html.php', array('folder' => 'worth', 'file' => 'list', 'worthcracy' => $worthcracy)); }