本文整理汇总了PHP中Goteo\Library\Message::Error方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::Error方法的具体用法?PHP Message::Error怎么用?PHP Message::Error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Goteo\Library\Message
的用法示例。
在下文中一共展示了Message::Error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public static function process($action = 'list', $id = null, $filters = array())
{
$groups = Model\Icon::groups();
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// instancia
$icon = new Model\Icon(array('id' => $_POST['id'], 'name' => $_POST['name'], 'description' => $_POST['description'], 'order' => $_POST['order'], 'group' => empty($_POST['group']) ? null : $_POST['group']));
if ($icon->save($errors)) {
switch ($_POST['action']) {
case 'add':
Message::Info('Nuevo tipo añadido correctamente');
break;
case 'edit':
Message::Info('Tipo editado correctamente');
// Evento Feed
$log = new Feed();
$log->populate('modificacion de tipo de retorno/recompensa (admin)', '/admin/icons', \vsprintf("El admin %s ha %s el tipo de retorno/recompensa %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);
break;
}
} else {
Message::Error(implode('<br />', $errors));
return new View('view/admin/index.html.php', array('folder' => 'icons', 'file' => 'edit', 'action' => $_POST['action'], 'icon' => $icon, 'groups' => $groups));
}
}
switch ($action) {
case 'edit':
$icon = Model\Icon::get($id);
return new View('view/admin/index.html.php', array('folder' => 'icons', 'file' => 'edit', 'action' => 'edit', 'icon' => $icon, 'groups' => $groups));
break;
}
$icons = Model\Icon::getAll($filters['group']);
return new View('view/admin/index.html.php', array('folder' => 'icons', 'file' => 'list', 'icons' => $icons, 'groups' => $groups, 'filters' => $filters));
}
示例2: process
public static function process($action = 'list', $id = null)
{
$model = 'Goteo\\Model\\Blog\\Post\\Tag';
$url = '/admin/tags';
$errors = array();
switch ($action) {
case 'add':
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'edit', 'data' => (object) array(), 'form' => array('action' => "{$url}/edit/", 'submit' => array('name' => 'update', 'label' => Text::_('Añadir')), 'fields' => array('id' => array('label' => '', 'name' => 'id', 'type' => 'hidden'), 'name' => array('label' => Text::_('Tag'), 'name' => 'name', 'type' => 'text')))));
break;
case 'edit':
// gestionar post
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update'])) {
$errors = array();
// instancia
$item = new $model(array('id' => $_POST['id'], 'name' => $_POST['name']));
if ($item->save($errors)) {
Message::Info(Text::get('admin-tags-info-udate'));
throw new Redirection($url);
} else {
Message::Error(Text::get('admin-tags-error-save-fail') . implode('<br />', $errors));
}
} else {
$item = $model::get($id);
}
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'edit', 'data' => $item, 'form' => array('action' => "{$url}/edit/{$id}", 'submit' => array('name' => 'update', 'label' => Text::get('regular-save')), 'fields' => array('id' => array('label' => '', 'name' => 'id', 'type' => 'hidden'), 'name' => array('label' => Text::_('Tag'), 'name' => 'name', 'type' => 'text')))));
break;
case 'remove':
if ($model::delete($id)) {
throw new Redirection($url);
}
break;
}
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'list', 'model' => 'tag', 'addbutton' => Text::_('Nuevo tag'), 'data' => $model::getList(1), 'columns' => array('edit' => '', 'name' => Text::_('Tag'), 'used' => Text::_('Entradas'), 'translate' => '', 'remove' => ''), 'url' => "{$url}"));
}
示例3: process
public static function process($action = 'list', $id = null, $filters = array())
{
$errors = array();
// valores de filtro
$groups = Template::groups();
switch ($action) {
case 'edit':
// si estamos editando una plantilla
$template = Template::get($id);
// si llega post, vamos a guardar los cambios
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$template->title = $_POST['title'];
$template->text = $_POST['text'];
if ($template->save($errors)) {
//Message::Info(Text::_('La plantilla se ha actualizado correctamente'));
throw new Redirection("/admin/templates");
} else {
Message::Error(Text::get('admin-templates-error-record-fail') . implode('<br />', $errors));
}
}
// sino, mostramos para editar
return new View('view/admin/index.html.php', array('folder' => 'templates', 'file' => 'edit', 'template' => $template));
break;
case 'list':
// si estamos en la lista de páginas
$templates = Template::getAll($filters);
return new View('view/admin/index.html.php', array('folder' => 'templates', 'file' => 'list', 'templates' => $templates, 'groups' => $groups, 'filters' => $filters));
break;
}
}
示例4: index
/**
* Suplantando al usuario
* @param string $id user->id
*/
public function index()
{
$admin = $_SESSION['user'];
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['id']) && !empty($_POST['impersonate'])) {
$impersonator = $_SESSION['user']->id;
session_unset();
$_SESSION['user'] = User::get($_POST['id']);
$_SESSION['impersonating'] = true;
$_SESSION['impersonator'] = $impersonator;
unset($_SESSION['admin_menu']);
/*
* Evento Feed
*/
// Evento Feed
$log = new Feed();
$log->setTarget($_SESSION['user']->id, 'user');
$log->populate('Suplantación usuario (admin)', '/admin/users', \vsprintf('El admin %s ha %s al usuario %s', array(Feed::item('user', $admin->name, $admin->id), Feed::item('relevant', 'Suplantado'), Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id))));
$log->doAdmin('user');
unset($log);
throw new Redirection('/dashboard');
} else {
Message::Error('Ha ocurrido un error');
throw new Redirection('/dashboard');
}
}
示例5: process
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));
}
示例6: process
public static function process($action = 'list', $id = null, $filters = array(), $type = 'main')
{
//@NODESYS
$node = \GOTEO_NODE;
$type = 'main';
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// instancia
$item = new Model\Home(array('item' => $_POST['item'], 'type' => $_POST['type'], 'node' => $node, 'order' => $_POST['order'], 'move' => 'down'));
if ($item->save($errors)) {
} else {
Message::Error(implode('<br />', $errors));
}
}
switch ($action) {
case 'remove':
Model\Home::delete($id, $node, $type);
throw new Redirection('/admin/home');
break;
case 'up':
Model\Home::up($id, $node, $type);
throw new Redirection('/admin/home');
break;
case 'down':
Model\Home::down($id, $node, $type);
throw new Redirection('/admin/home');
break;
case 'add':
$next = Model\Home::next($node, 'main');
$availables = Model\Home::available($node);
if (empty($availables)) {
Message::Info(Text::_('Todos los elementos disponibles ya estan en portada'));
throw new Redirection('/admin/home');
break;
}
return new View('view/admin/index.html.php', array('folder' => 'home', 'file' => 'add', 'action' => 'add', 'home' => (object) array('node' => $node, 'order' => $next, 'type' => 'main'), 'availables' => $availables));
break;
case 'addside':
$next = Model\Home::next($node, 'side');
$availables = Model\Home::availableSide($node);
if (empty($availables)) {
Message::Info(Text::_('Todos los elementos laterales disponibles ya estan en portada'));
throw new Redirection('/admin/home');
break;
}
return new View('view/admin/index.html.php', array('folder' => 'home', 'file' => 'add', 'action' => 'add', 'home' => (object) array('node' => $node, 'order' => $next, 'type' => 'side'), 'availables' => $availables));
break;
}
$viewData = array('folder' => 'home', 'file' => 'list');
$viewData['items'] = Model\Home::getAll($node);
/* Para añadir nuevos desde la lista */
$viewData['availables'] = Model\Home::available($node);
$viewData['new'] = (object) array('node' => $node, 'order' => Model\Home::next($node, 'main'), 'type' => 'main');
// laterales
$viewData['side_items'] = Model\Home::getAllSide($node);
$viewData['side_availables'] = Model\Home::availableSide($node);
$viewData['side_new'] = (object) array('node' => $node, 'order' => Model\Home::next($node, 'side'), 'type' => 'side');
return new View('view/admin/index.html.php', $viewData);
}
示例7: process
public static function process($action = 'list', $id = null)
{
$node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE;
$model = 'Goteo\\Model\\Sponsor';
$url = '/admin/sponsors';
$errors = array();
switch ($action) {
case 'add':
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'edit', 'data' => (object) array('order' => $model::next($node), 'node' => $node), 'form' => array('action' => "{$url}/edit/", 'submit' => array('name' => 'update', 'label' => Text::_('Añadir')), 'fields' => array('id' => array('label' => '', 'name' => 'id', 'type' => 'hidden'), 'node' => array('label' => '', 'name' => 'node', 'type' => 'hidden'), 'name' => array('label' => Text::_('Patrocinador'), 'name' => 'name', 'type' => 'text'), 'url' => array('label' => Text::_('Enlace'), 'name' => 'url', 'type' => 'text', 'properties' => 'size=100'), 'image' => array('label' => Text::_('Logo'), 'name' => 'image', 'type' => 'image'), 'order' => array('label' => Text::_('Posición'), 'name' => 'order', 'type' => 'text')))));
break;
case 'edit':
// gestionar post
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// instancia
$item = new $model(array('id' => $_POST['id'], 'name' => $_POST['name'], 'node' => $_POST['node'], 'image' => $_POST['image'], 'url' => $_POST['url'], 'order' => $_POST['order']));
// tratar si quitan la imagen
$current = $_POST['image'];
// la actual
if (isset($_POST['image-' . $current . '-remove'])) {
$image = Model\Image::get($current);
$image->remove('sponsor');
$item->image = '';
$removed = true;
}
// tratar la imagen y ponerla en la propiedad image
if (!empty($_FILES['image']['name'])) {
$item->image = $_FILES['image'];
}
if ($item->save($errors)) {
Message::Info(Text::_('Datos grabados correctamente'));
throw new Redirection($url);
} else {
Message::Error(Text::_('No se ha grabado correctamente. ') . implode(', ', $errors));
}
} else {
$item = $model::get($id);
}
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'edit', 'data' => $item, 'form' => array('action' => "{$url}/edit/{$id}", 'submit' => array('name' => 'update', 'label' => Text::get('regular-save')), 'fields' => array('id' => array('label' => '', 'name' => 'id', 'type' => 'hidden'), 'node' => array('label' => '', 'name' => 'node', 'type' => 'hidden'), 'name' => array('label' => Text::_('Patrocinador'), 'name' => 'name', 'type' => 'text'), 'url' => array('label' => Text::_('Enlace'), 'name' => 'url', 'type' => 'text', 'properties' => 'size=100'), 'image' => array('label' => Text::_('Logo'), 'name' => 'image', 'type' => 'image'), 'order' => array('label' => Text::_('Posición'), 'name' => 'order', 'type' => 'text')))));
break;
case 'up':
$model::up($id, $node);
throw new Redirection($url);
break;
case 'down':
$model::down($id, $node);
throw new Redirection($url);
break;
case 'remove':
if ($model::delete($id)) {
Message::Info(Text::_('Se ha eliminado el registro'));
throw new Redirection($url);
} else {
Message::Info(Text::_('No se ha podido eliminar el registro'));
}
break;
}
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'list', 'addbutton' => Text::_('Nuevo patrocinador'), 'data' => $model::getAll($node), 'columns' => array('edit' => '', 'name' => Text::_('Patrocinador'), 'url' => Text::_('Enlace'), 'image' => Text::_('Imagen'), 'order' => Text::_('Posición'), 'up' => '', 'down' => '', 'remove' => ''), 'url' => "{$url}"));
}
示例8: process
public static function process($action = 'list', $id = null)
{
$node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE;
$errors = array();
switch ($action) {
case 'add':
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$page = new Page();
$page->id = $_POST['id'];
$page->name = $_POST['name'];
if ($page->add($errors)) {
Message::Info('La página <strong>' . $page->name . '</strong> se ha creado correctamente, se puede editar ahora.');
throw new Redirection("/admin/pages/edit/{$page->id}");
} else {
Message::Error('No se ha creado bien ' . implode('<br />', $errors));
throw new Redirection("/admin/pages/add");
}
}
return new View('view/admin/index.html.php', array('folder' => 'pages', 'file' => 'add'));
break;
case 'edit':
if ($node != \GOTEO_NODE && !in_array($id, static::_node_pages())) {
Message::Info('No puedes gestionar la página <strong>' . $id . '</strong>');
throw new Redirection("/admin/pages");
}
// si estamos editando una página
$page = Page::get($id, $node, \GOTEO_DEFAULT_LANG);
// si llega post, vamos a guardar los cambios
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$page->name = $_POST['name'];
$page->description = $_POST['description'];
$page->content = $_POST['content'];
if ($page->save($errors)) {
// Evento Feed
$log = new Feed();
if ($node != \GOTEO_NODE && in_array($id, static::_node_pages())) {
$log->setTarget($node, 'node');
}
$log->populate(Text::_('modificacion de página institucional (admin)'), '/admin/pages', \vsprintf("El admin %s ha %s la página institucional %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Modificado'), Feed::item('relevant', $page->name, $page->url))));
$log->doAdmin('admin');
unset($log);
Message::Info('La página ' . $page->name . ' se ha actualizado correctamente');
throw new Redirection("/admin/pages");
} else {
Message::Error(implode('<br />', $errors));
}
}
// sino, mostramos para editar
return new View('view/admin/index.html.php', array('folder' => 'pages', 'file' => 'edit', 'page' => $page));
break;
case 'list':
// si estamos en la lista de páginas
$pages = Page::getList($node);
return new View('view/admin/index.html.php', array('folder' => 'pages', 'file' => 'list', 'pages' => $pages, 'node' => $node));
break;
}
}
示例9: process
public static function process($action = 'list', $id = null, $filters = array())
{
// agrupaciones de mas a menos abertas
$groups = Model\License::groups();
// tipos de retorno para asociar
$icons = Model\Icon::getAll('social');
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// objeto
$license = new Model\License(array('id' => $_POST['id'], 'name' => $_POST['name'], 'description' => $_POST['description'], 'url' => $_POST['url'], 'group' => $_POST['group'], 'order' => $_POST['order'], 'icons' => $_POST['icons']));
if ($license->save($errors)) {
switch ($_POST['action']) {
case 'add':
Message::Info(Text::get('admin-licenses-info-add'));
break;
case 'edit':
Message::Info(Text::get('admin-licenses-info-edit'));
// Evento Feed
$log = new Feed();
$log->populate('modificacion de licencia (admin)', '/admin/licenses', \vsprintf("El admin %s ha %s la licencia %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Modificado'), Feed::item('project', $license->name))));
$log->doAdmin('admin');
unset($log);
break;
}
} else {
Message::Error(implode('<br />', $errors));
return new View('view/admin/index.html.php', array('folder' => 'licenses', 'file' => 'edit', 'action' => $_POST['action'], 'license' => $license, 'icons' => $icons, 'groups' => $groups));
}
}
switch ($action) {
case 'up':
Model\License::up($id);
break;
case 'down':
Model\License::down($id);
break;
case 'add':
$next = Model\License::next();
return new View('view/admin/index.html.php', array('folder' => 'licenses', 'file' => 'edit', 'action' => 'add', 'license' => (object) array('order' => $next, 'icons' => array()), 'icons' => $icons, 'groups' => $groups));
break;
case 'edit':
$license = Model\License::get($id);
return new View('view/admin/index.html.php', array('folder' => 'licenses', 'file' => 'edit', 'action' => 'edit', 'license' => $license, 'icons' => $icons, 'groups' => $groups));
break;
case 'remove':
// Model\License::delete($id);
break;
}
$licenses = Model\License::getAll($filters['icon'], $filters['group']);
return new View('view/admin/index.html.php', array('folder' => 'licenses', 'file' => 'list', 'licenses' => $licenses, 'filters' => $filters, 'groups' => $groups, 'icons' => $icons));
}
示例10: process
public static function process($action = 'list', $id = null, $filters = array())
{
$sections = Model\Faq::sections();
if (!isset($sections[$filters['section']])) {
unset($filters['section']);
}
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// instancia
$faq = new Model\Faq(array('id' => $_POST['id'], 'node' => \GOTEO_NODE, 'section' => $_POST['section'], 'title' => $_POST['title'], 'description' => $_POST['description'], 'order' => $_POST['order'], 'move' => $_POST['move']));
if ($faq->save($errors)) {
switch ($_POST['action']) {
case 'add':
Message::Info('Pregunta añadida correctamente');
break;
case 'edit':
Message::Info('Pregunta editado correctamente');
break;
}
} else {
Message::Error(implode('<br />', $errors));
return new View('view/admin/index.html.php', array('folder' => 'faq', 'file' => 'edit', 'action' => $_POST['action'], 'faq' => $faq, 'filter' => $filter, 'sections' => $sections));
}
}
switch ($action) {
case 'up':
Model\Faq::up($id);
throw new Redirection('/admin/faq');
break;
case 'down':
Model\Faq::down($id);
throw new Redirection('/admin/faq');
break;
case 'add':
$next = Model\Faq::next($filters['section']);
return new View('view/admin/index.html.php', array('folder' => 'faq', 'file' => 'edit', 'action' => 'add', 'faq' => (object) array('section' => $filters['section'], 'order' => $next, 'cuantos' => $next), 'sections' => $sections));
break;
case 'edit':
$faq = Model\Faq::get($id);
$cuantos = Model\Faq::next($faq->section);
$faq->cuantos = $cuantos - 1;
return new View('view/admin/index.html.php', array('folder' => 'faq', 'file' => 'edit', 'action' => 'edit', 'faq' => $faq, 'sections' => $sections));
break;
case 'remove':
Model\Faq::delete($id);
break;
}
$faqs = Model\Faq::getAll($filters['section']);
return new View('view/admin/index.html.php', array('folder' => 'faq', 'file' => 'list', 'faqs' => $faqs, 'sections' => $sections, 'filters' => $filters));
}
示例11: process
public static function process($action = 'list', $id = null, $filters = array())
{
$sections = Model\Criteria::sections();
if (!isset($sections[$filters['section']])) {
unset($filters['section']);
}
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// instancia
$criteria = new Model\Criteria(array('id' => $_POST['id'], 'section' => $_POST['section'], 'title' => $_POST['title'], 'description' => $_POST['description'], 'order' => $_POST['order'], 'move' => $_POST['move']));
if ($criteria->save($errors)) {
switch ($_POST['action']) {
case 'add':
Message::Info(Text::get('criteria-info-add-correctly'));
break;
case 'edit':
Message::Info(Text::get('criteria-info-edit-correctly'));
break;
}
} else {
Message::Error(implode('<br />', $errors));
return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'edit', 'action' => $_POST['action'], 'criteria' => $criteria, 'sections' => $sections));
}
}
switch ($action) {
case 'up':
Model\Criteria::up($id);
break;
case 'down':
Model\Criteria::down($id);
break;
case 'add':
$next = Model\Criteria::next($filters['section']);
return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'edit', 'action' => 'add', 'criteria' => (object) array('section' => $filters['section'], 'order' => $next, 'cuantos' => $next), 'sections' => $sections));
break;
case 'edit':
$criteria = Model\Criteria::get($id);
$cuantos = Model\Criteria::next($criteria->section);
$criteria->cuantos = $cuantos - 1;
return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'edit', 'action' => 'edit', 'criteria' => $criteria, 'sections' => $sections));
break;
case 'remove':
Model\Criteria::delete($id);
break;
}
$criterias = Model\Criteria::getAll($filters['section']);
return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'list', 'criterias' => $criterias, 'sections' => $sections, 'filters' => $filters));
}
示例12: process
public static function process($action = 'list', $id = null, $filters = array())
{
// valores de filtro
$groups = Text::groups();
// metemos el todos
\array_unshift($groups, Text::_('Todas las agrupaciones'));
//@fixme temporal hasta pasar las agrupaciones a tabal o arreglar en el list.html.php
// I dont know if this must serve in default lang or in current navigation lang
$data = Text::getAll($filters, 'original');
foreach ($data as $key => $item) {
$data[$key]->group = $groups[$item->group];
}
switch ($action) {
case 'list':
return new View('view/admin/index.html.php', array('folder' => 'texts', 'file' => 'list', 'data' => $data, 'columns' => array('edit' => '', 'text' => Text::_('Texto'), 'group' => Text::_('Agrupación')), 'url' => '/admin/texts', 'filters' => array('filtered' => $filters['filtered'], 'group' => array('label' => Text::_('Filtrar por agrupación:'), 'type' => 'select', 'options' => $groups, 'value' => $filters['group']), 'text' => array('label' => Text::_('Buscar texto:'), 'type' => 'input', 'options' => null, 'value' => $filters['text']))));
break;
case 'edit':
// gestionar post
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update'])) {
$errors = array();
$id = $_POST['id'];
$text = $_POST['text'];
$data = array('id' => $id, 'text' => $_POST['text']);
if (Text::update($data, $errors)) {
Message::Info(Text::_('El texto ha sido actualizado'));
throw new Redirection("/admin/texts");
} else {
Message::Error(implode('<br />', $errors));
}
} else {
//@TODO: this must get the text in the GOTEO_DEFAULT_LANG or it will be overwrited
$text = Text::getPurpose($id);
// Julian Canaves 23 nov 2013
// right now getPurpose gets the spanish text.
// In future this spanish text will be moved to the `Text` table
// and the `Purpose` table will distribute to database text or to gettext
// and there will be no hardcoded strings
// and will be all happy, fun and joy
}
return new View('view/admin/index.html.php', array('folder' => 'texts', 'file' => 'edit', 'data' => (object) array('id' => $id, 'text' => $text), 'form' => array('action' => '/admin/texts/edit/' . $id, 'submit' => array('name' => 'update', 'label' => Text::_('Aplicar')), 'fields' => array('idtext' => array('label' => '', 'name' => 'id', 'type' => 'hidden', 'properties' => ''), 'newtext' => array('label' => Text::_('Texto'), 'name' => 'text', 'type' => 'textarea', 'properties' => 'cols="100" rows="6"')))));
break;
default:
throw new Redirection("/admin");
}
}
示例13: process
public static function process($action = 'list', $id = null, $filters = array())
{
$errors = array();
// reubicando aporte,
if ($action == 'move') {
// el aporte original
$original = Model\Invest::get($id);
$userData = Model\User::getMini($original->user);
$projectData = Model\Project::getMini($original->project);
//el original tiene que ser de tpv o cash y estar como 'cargo ejecutado'
if ($original->method == 'paypal' || $original->status != 1) {
Message::Error('No se puede reubicar este aporte!');
throw new Redirection('/admin/accounts');
}
// generar aporte manual y caducar el original
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['move'])) {
// si falta proyecto, error
$projectNew = $_POST['project'];
// @TODO a saber si le toca dinero de alguna convocatoria
$campaign = null;
$invest = new Model\Invest(array('amount' => $original->amount, 'user' => $original->user, 'project' => $projectNew, 'account' => $userData->email, 'method' => 'cash', 'status' => '1', 'invested' => date('Y-m-d'), 'charged' => $original->charged, 'anonymous' => $original->anonymous, 'resign' => $original->resign, 'admin' => $_SESSION['user']->id, 'campaign' => $campaign));
//@TODO si el proyecto seleccionado
if ($invest->save($errors)) {
//recompensas que le tocan (si no era resign)
if (!$original->resign) {
// sacar recompensas
$rewards = Model\Project\Reward::getAll($projectNew, 'individual');
foreach ($rewards as $rewId => $rewData) {
$invest->setReward($rewId);
//asignar
}
}
// cambio estado del aporte original a 'Reubicado' (no aparece en cofinanciadores)
// si tuviera que aparecer lo marcaríamos como caducado
if ($original->setStatus('5')) {
// Evento Feed
$log = new Feed();
$log->setTarget($projectData->id);
$log->populate('Aporte reubicado', '/admin/accounts', \vsprintf("%s ha aportado %s al proyecto %s en nombre de %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('money', $_POST['amount'] . ' €'), Feed::item('project', $projectData->name, $projectData->id), Feed::item('user', $userData->name, $userData->id))));
$log->doAdmin('money');
unset($log);
Message::Info('Aporte reubicado correctamente');
throw new Redirection('/admin/accounts');
} else {
$errors[] = 'A fallado al cambiar el estado del aporte original (' . $original->id . ')';
}
} else {
$errors[] = 'Ha fallado algo al reubicar el aporte';
}
}
$viewData = array('folder' => 'accounts', 'file' => 'move', 'original' => $original, 'user' => $userData, 'project' => $projectData);
return new View('view/admin/index.html.php', $viewData);
// fin de la historia dereubicar
}
// cambiando estado del aporte aporte,
if ($action == 'update') {
// el aporte original
$invest = Model\Invest::get($id);
if (!$invest instanceof Model\Invest) {
Message::Error('No tenemos registro del aporte ' . $id);
throw new Redirection('/admin/accounts');
}
$status = Model\Invest::status();
$new = isset($_POST['status']) ? $_POST['status'] : null;
if ($invest->issue && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update']) && $_POST['resolve'] == 1) {
Model\Invest::unsetIssue($id);
Model\Invest::setDetail($id, 'issue-solved', 'La incidencia se ha dado por resuelta por el usuario ' . $_SESSION['user']->name);
Message::Info('La incidencia se ha dado por resuelta');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update']) && isset($new) && isset($status[$new])) {
if ($new != $invest->status) {
if (Model\Invest::query("UPDATE invest SET status=:status WHERE id=:id", array(':id' => $id, ':status' => $new))) {
Model\Invest::setDetail($id, 'status-change' . rand(0, 9999), 'El admin ' . $_SESSION['user']->name . ' ha cambiado el estado del apote a ' . $status[$new]);
Message::Info('Se ha actualizado el estado del aporte');
} else {
Message::Error('Ha fallado al actualizar el estado del aporte');
}
} else {
Message::Error('No se ha cambiado el estado');
}
throw new Redirection('/admin/accounts/details/' . $id);
}
return new View('view/admin/index.html.php', array('folder' => 'accounts', 'file' => 'update', 'invest' => $invest, 'status' => $status));
// fin de la historia actualizar estado
}
// resolviendo incidencias
if ($action == 'solve') {
// el aporte original
$invest = Model\Invest::get($id);
if (!$invest instanceof Model\Invest) {
Message::Error('No tenemos registro del aporte ' . $id);
throw new Redirection('/admin/accounts');
}
$projectData = Model\Project::getMini($invest->project);
$errors = array();
// primero cancelar
switch ($invest->method) {
case 'paypal':
$err = array();
if (Paypal::cancelPreapproval($invest, $err)) {
//.........这里部分代码省略.........
示例14: login
/**
* Validación de usuario.
*
* @param string $username Nombre de usuario
* @param string $password Contraseña
* @return obj|false Objeto del usuario, en caso contrario devolverá 'false'.
*/
public static function login($username, $password)
{
$ok = false;
$query = self::query("\r\n SELECT\r\n password\r\n FROM user\r\n WHERE BINARY id = :username", array(':username' => trim($username)));
if ($row = $query->fetch(\PDO::FETCH_OBJ)) {
if (version_compare(phpversion(), '5.5.0', '>=')) {
$ok = password_verify($password, $row->password);
} else {
$ok = crypt($password, $row->password) == $row->password;
}
if ($ok) {
$user = static::get(trim($username));
if (empty($user) || $user->active) {
return $user;
} else {
Message::Error(Text::get('user-account-inactive'));
}
} else {
return false;
}
}
return false;
}
示例15: menu
public static function menu($BC = array())
{
$admin_label = Text::_('Admin');
$options = static::_options();
$supervisors = static::_supervisors();
// El menu del panel admin dependerá del rol del usuario que accede
// Superadmin = todo
// Admin = contenidos de Nodo
// Supervisor = menus especiales
if (isset($supervisors[$_SESSION['user']->id])) {
$menu = self::setMenu('supervisor', $_SESSION['user']->id);
} elseif (isset($_SESSION['user']->roles['admin'])) {
$menu = self::setMenu('admin', $_SESSION['user']->id);
} else {
$menu = self::setMenu('superadmin', $_SESSION['user']->id);
}
// si el breadcrumbs no es un array vacio,
// devolveremos el contenido html para pintar el camino de migas de pan
// con enlaces a lo anterior
if (empty($BC)) {
return $menu;
} else {
// a ver si puede estar aqui!
if ($BC['option'] != 'index') {
$puede = false;
foreach ($menu as $sCode => $section) {
if (isset($section['options'][$BC['option']])) {
$puede = true;
break;
}
}
if (!$puede) {
Message::Error(Text::get('admin-no_permission', $options[$BC['option']]['label']));
throw new Redirection('/admin');
}
}
// Los últimos serán los primeros
$path = '';
// si el BC tiene Id, accion sobre ese registro
// si el BC tiene Action
if (!empty($BC['action']) && $BC['action'] != 'list') {
// si es una accion no catalogada, mostramos la lista
if (!in_array($BC['action'], array_keys($options[$BC['option']]['actions']))) {
$BC['action'] = '';
$BC['id'] = null;
}
$action = $options[$BC['option']]['actions'][$BC['action']];
// si es de item , añadir el id (si viene)
if ($action['item'] && !empty($BC['id'])) {
$path = " > <strong>{$action['label']}</strong> {$BC['id']}";
} else {
$path = " > <strong>{$action['label']}</strong>";
}
}
// si el BC tiene Option, enlace a la portada de esa gestión (a menos que sea laaccion por defecto)
if (!empty($BC['option']) && isset($options[$BC['option']])) {
$option = $options[$BC['option']];
if ($BC['action'] == 'list') {
$path = " > <strong>{$option['label']}</strong>";
} else {
$path = ' > <a href="/admin/' . $BC['option'] . '">' . $option['label'] . '</a>' . $path;
}
}
// si el BC tiene section, facil, enlace al admin
if ($BC['option'] == 'index') {
$path = "<strong>{$admin_label}</strong>";
} else {
$path = '<a href="/admin">' . $admin_label . '</a>' . $path;
}
return $path;
}
}