public function save(&$errors = array()) { if (!$this->validate($errors)) { return false; } $fields = array('id', 'section', 'title', 'description', 'order'); $set = ''; $values = array(); foreach ($fields as $field) { if ($set != '') { $set .= ", "; } $set .= "`{$field}` = :{$field} "; $values[":{$field}"] = $this->{$field}; } try { $sql = "REPLACE INTO criteria SET " . $set; self::query($sql, $values); if (empty($this->id)) { $this->id = self::insertId(); } $extra = array('section' => $this->section); Check::reorder($this->id, $this->move, 'criteria', 'id', 'order', $extra); return true; } catch (\PDOException $e) { $errors[] = Text::_("No se ha guardado correctamente. ") . $e->getMessage(); return false; } }
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}")); }
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}")); }
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; } }
public function save(&$errors = array()) { if (!$this->validate($errors)) { return false; } try { $sql = "REPLACE INTO project_account (project, bank, bank_owner, paypal, paypal_owner, allowpp) VALUES(:project, :bank, :bank_owner, :paypal, :paypal_owner, :allowpp)"; $values = array(':project' => $this->project, ':bank' => $this->bank, ':bank_owner' => $this->bank_owner, ':paypal' => $this->paypal, ':paypal_owner' => $this->paypal_owner, ':allowpp' => $this->allowpp); self::query($sql, $values); return true; } catch (\PDOException $e) { $errors[] = Text::_("Las cuentas no se han asignado correctamente. Por favor, revise los datos.") . $e->getMessage(); return false; } }
public static function process($action = 'list', $id = null) { $model = 'Goteo\\Model\\Skill'; $url = '/admin/skills'; $errors = array(); switch ($action) { case 'add': if (isset($_GET['word'])) { $item = (object) array('name' => $_GET['word']); } else { $item = (object) array(); } $parent_skill = $model::getAllParent(); return new View('view/admin/index.html.php', array('folder' => 'skills', 'file' => 'edit', 'data' => $item, 'parent_skill' => $parent_skill, '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::_('Skill'), 'name' => 'name', 'type' => 'text'), 'description' => array('label' => Text::_('Descripción'), 'name' => 'description', 'type' => 'textarea', 'properties' => 'cols="100" rows="2"'))))); break; case 'edit': // gestionar post if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update'])) { // instancia $item = new $model(array('id' => $_POST['id'], 'name' => $_POST['name'], 'description' => $_POST['description'], 'parent_skill_id' => $_POST['parent_skill_id'])); if ($item->save($errors)) { throw new Redirection($url); } else { Message::Error(implode('<br />', $errors)); } } else { $item = $model::get($id); } $parent_skill = $model::getAllParent(); return new View('view/admin/index.html.php', array('folder' => 'skills', 'file' => 'edit', 'data' => $item, 'parent_skill' => $parent_skill, 'form' => array('action' => "{$url}/edit/{$id}", 'submit' => array('name' => 'update', 'label' => 'Guardar'), 'fields' => array('id' => array('label' => '', 'name' => 'id', 'type' => 'hidden'), 'name' => array('label' => 'Skill', 'name' => 'name', 'type' => 'text'), 'description' => array('label' => 'Descripción', 'name' => 'description', 'type' => 'textarea', 'properties' => 'cols="100" rows="2"'))))); break; case 'up': $model::up($id); break; case 'down': $model::down($id); break; case 'remove': if ($model::delete($id)) { throw new Redirection($url); } break; case 'keywords': return new View('view/admin/index.html.php', array('folder' => 'keywords', 'file' => 'list', 'skills' => $model::getList(), 'words' => $model::getKeyWords())); break; } return new View('view/admin/index.html.php', array('folder' => 'skills', 'file' => 'list', 'model' => 'skill', 'addbutton' => Text::_('New skill'), 'otherbutton' => '<a href="/admin/skills/keywords" class="button">' . Text::get('admin-skill_keyword') . '</a>', 'data' => $model::getAll(), 'columns' => array('edit' => '', 'name' => 'Skill', 'numProj' => 'Proyectos', 'numUser' => 'Usuarios', 'order' => 'Prioridad', 'translate' => '', 'up' => '', 'down' => '', 'translate' => '', 'remove' => ''), 'url' => "{$url}")); }
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"); } }
echo $filter; ?> " /> <input type="hidden" name="order" value="<?php echo $order; ?> " /> <p> <input type="checkbox" id="msg_all" name="msg_all" value="1" onclick="alert('全ての支援者に送信します');" /> <label for="msg_all">全ての支援者に送信</label> </p> <p> <?php echo Text::_('Send it to reward seekers'); _; ?> : <br /> <?php foreach ($rewards as $rewardId => $rewardData) { ?> <input type="checkbox" id="msg_reward-<?php echo $rewardId; ?> " name="msg_reward-<?php echo $rewardId; ?> " value="1" /> <label for="msg_reward-<?php echo $rewardId;
<input type="hidden" name="group" value="<?php echo $this['template']->group; ?> " /> <p> <label for="tpltitle"><?php echo Text::_('Título'); ?> :</label><br /> <input id="tpltitle" type="text" name="title" size="120" value="<?php echo $this['template']->title; ?> " /> </p> <p> <label for="tpltext"><?php echo Text::_('Contenido'); ?> :</label><br /> <textarea id="tpltext" name="text" cols="100" rows="20"><?php echo $this['template']->text; ?> </textarea> </p> <input type="submit" name="save" value="<?php echo Text::_('Guardar'); ?> " /> </form> </div>
public static function save($data, &$errors = array()) { if (empty($data)) { $errors[] = Text::_("Sin datos"); return false; } if (empty($data['name']) || empty($data['amount']) || empty($data['id'])) { $errors[] = Text::_("No se guardar sin nombre y cantidad"); return false; } try { $values = array(':id' => $data['id'], ':name' => $data['name'], ':amount' => $data['amount']); $sql = "REPLACE INTO worthcracy SET `id` = :id, `name` = :name, `amount` = :amount "; if (Model::query($sql, $values)) { return true; } else { $errors[] = Text::_("Ha fallado ") . $sql . Text::_('con') . " <pre>" . print_r($values, 1) . "</pre>"; return false; } } catch (\PDOException $e) { $errors[] = Text::_('Error sql al grabar el nivel de meritocracia. ') . $e->getMessage(); return false; } }
<?php foreach ($this['projects'] as $projectId => $projectName) { ?> <option value="<?php echo $projectId; ?> "><?php echo $projectName; ?> </option> <?php } ?> </select> </p> <p> <label for="invest-anonymous"><?php echo Text::_("Aporte anónimo:"); ?> </label><br /> <input id="invest-anonymous" type="checkbox" name="anonymous" value="1"> </p> <input type="submit" name="add" value="<?php echo Text::_("Generar aporte"); ?> " /> </form> </div>
</div> <div class="widget board"> <?php if (!empty($this['faqs'])) { ?> <table> <thead> <tr> <td><!-- Edit --></td> <th><?php echo Text::_("Título"); ?> </th> <!-- title --> <th><?php echo Text::_("Posición"); ?> </th> <!-- order --> <td><!-- Move up --></td> <td><!-- Move down --></td> <td><!-- Traducir--></td> <td><!-- Remove --></td> </tr> </thead> <tbody> <?php foreach ($this['faqs'] as $faq) { ?> <tr> <td><a href="/admin/faq/edit/<?php
/** * Quitar un retorno de un proyecto * * @param varchar(50) $project id de un proyecto * @param INT(12) $id identificador de la tabla reward * @param array $errors * @return boolean */ public function remove(&$errors = array()) { $values = array(':project' => $this->project, ':id' => $this->id); try { self::query("DELETE FROM reward WHERE id = :id AND project = :project", $values); return true; } catch (\PDOException $e) { $errors[] = Text::_('No se ha podido quitar el retorno ') . $this->id . '. ' . $e->getMessage(); //Text::get('remove-reward-fail'); return false; } }
public static function save($data, &$errors = array()) { $fields = static::_fields(); if (empty($data)) { $errors[] = Text::_("Sin datos"); return false; } if (empty($data['lang']) || $data['lang'] == 'original') { $errors[] = Text::_("No se peude traducir el contenido original, seleccionar un idioma para traducir"); return false; } try { // tenemos el id en $this->id (el campo id siempre se llama id) // tenemos el lang en $this->lang // tenemos el nombre de la tabla en $this->table // tenemos los campos en $fields[$table] y el contenido de cada uno en $this->$field $set = '`id` = :id, `lang` = :lang '; $values = array(':id' => $data['id'], ':lang' => $data['lang']); foreach ($fields[$data['table']] as $field => $fieldDesc) { if ($set != '') { $set .= ", "; } $set .= "`{$field}` = :{$field} "; $values[":{$field}"] = $data[$field]; } $sql = "REPLACE INTO {$data['table']}_lang SET {$set}"; if (Model::query($sql, $values)) { return true; } else { $errors[] = Text::_("Ha fallado ") . $sql . Text::_('con') . " <pre>" . print_r($values, 1) . "</pre>"; return false; } } catch (\PDOException $e) { $errors[] = Text::_('Error sql al grabar el contenido multiidioma. ') . $e->getMessage(); return false; } }
<td width="<?php echo round($per) - 5; ?> %"><?php echo is_object($item) ? $item->{$key} : $item[$key]; ?> </td> <?php } ?> <?php } ?> </tr> <?php } ?> </tbody> </table> <?php } else { ?> <p><?php echo Text::_("No se han encontrado registros"); ?> </p> <?php } ?> </div>
<p> <label for="faq-order"><?php echo Text::_("Posición"); ?> :</label><br /> <select name="move"> <option value="same" selected="selected" disabled><?php echo Text::_("Tal cual"); ?> </option> <option value="up"><?php echo Text::_("Antes de "); ?> </option> <option value="down"><?php echo Text::_("Después de "); ?> </option> </select> <input type="text" name="order" id="faq-order" value="<?php echo $this['faq']->order; ?> " size="4" /> de <span id="faq-num"><?php echo $this['faq']->cuantos; ?> </span> </p> <input type="submit" name="save" value="Guardar" />
public static function _types() { return array('description' => Text::_('Descripción'), 'url' => Text::_('Enlace'), 'name' => Text::_('Nombre'), 'text' => Text::_('Texto extenso'), 'legend' => Text::_('Leyenda'), 'title' => Text::_('Título')); }
public static function setMenu($role, $user = null) { $options = static::_options(); $supervisors = static::_supervisors(); $labels = array(); $labels['contents'] = Text::_('Contenidos'); $labels['projects'] = Text::_('Proyectos'); $labels['users'] = Text::_('Usuarios'); $labels['home'] = Text::_('Portada'); $labels['texts'] = Text::_('Textos y Traducciones'); $labels['services'] = Text::_('Servicios'); switch ($role) { case 'supervisor': $menu = array('contents' => array('label' => $labels['contents'], 'options' => array())); foreach ($supervisors[$user] as $opt) { $menu['contents']['options'][$opt] = $options[$opt]; } break; case 'admin': $menu = array('contents' => array('label' => $labels['contents'], 'options' => array('pages' => $options['pages'], 'blog' => $options['blog'], 'banners' => $options['banners'])), 'projects' => array('label' => $labels['projects'], 'options' => array('projects' => $options['projects'], 'reviews' => $options['reviews'], 'translates' => $options['translates'], 'invests' => $options['invests'])), 'users' => array('label' => $labels['users'], 'options' => array('users' => $options['users'], 'mailing' => $options['mailing'], 'sended' => $options['sended'], 'tasks' => $options['tasks'])), 'home' => array('label' => $labels['home'], 'options' => array('home' => $options['home'], 'promote' => $options['promote'], 'blog' => $options['blog'], 'sponsors' => $options['sponsors'], 'recent' => $options['recent']))); break; case 'superadmin': $menu = array('contents' => array('label' => $labels['texts'], 'options' => array('blog' => $options['blog'], 'texts' => $options['texts'], 'faq' => $options['faq'], 'pages' => $options['pages'], 'categories' => $options['categories'], 'licenses' => $options['licenses'], 'icons' => $options['icons'], 'tags' => $options['tags'], 'criteria' => $options['criteria'], 'templates' => $options['templates'], 'glossary' => $options['glossary'])), 'projects' => array('label' => $labels['projects'], 'options' => array('projects' => $options['projects'], 'accounts' => $options['accounts'], 'reviews' => $options['reviews'], 'translates' => $options['translates'], 'rewards' => $options['rewards'])), 'users' => array('label' => $labels['users'], 'options' => array('users' => $options['users'], 'worth' => $options['worth'], 'mailing' => $options['mailing'], 'sended' => $options['sended'], 'tasks' => $options['tasks'])), 'home' => array('label' => $labels['home'], 'options' => array('news' => $options['news'], 'banners' => $options['banners'], 'blog' => $options['blog'], 'promote' => $options['promote'], 'footer' => $options['footer'], 'recent' => $options['recent'], 'home' => $options['home'])), 'sponsors' => array('label' => $labels['services'], 'options' => array('newsletter' => $options['newsletter'], 'sponsors' => $options['sponsors'], 'tasks' => $options['tasks']))); break; } return $menu; }
$sections = Criteria::sections(); $criteria = array(); foreach ($sections as $sectionId=>$sectionName) { $criteria[$sectionId] = Criteria::getAll($sectionId); } ?> <div class="widget"> <?php echo Text::_('Puntuación de tu revisión: '); ?><span id="total-score"><?php echo $evaluation['score'] . '/' . $evaluation['max']; ?></span> </div> <?php foreach ($sections as $sectionId=>$sectionName) : ?> <div class="widget"> <h2 class="title"><?php echo $sectionName; ?></h2> <p> <?php echo Text::_('Otrogas puntos porque:'); ?><br /> <blockquote> <?php foreach ($criteria[$sectionId] as $crit) : if ($evaluation['criteria'][$crit->id] > 0) echo '· ' . $crit->title . '<br />'; endforeach; ?> </blockquote> </p> <p> <?php echo Text::_('Tu evaluación ') ?><?php echo strtolower($sectionName); ?>:<br /> <blockquote><?php echo nl2br($evaluation[$sectionId]['evaluation']); ?></blockquote> </p> <p> <?php echo Text::_('Las mejoras que harías '); ?><?php echo strtolower($sectionName); ?>:<br /> <blockquote><?php echo nl2br($evaluation[$sectionId]['recommendation']); ?></blockquote> </p> </div> <?php endforeach; ?>
echo Text::_('Cumplido'); ?> </td> <td><a href="<?php echo "/admin/rewards/unfill/{$reward->invest}"; ?> ">[<?php echo Text::_("Marcar pendiente"); ?> ]</a></td> <?php } ?> </tr> <?php } ?> </tbody> </table> <?php } else { ?> <p><?php echo Text::_('No hay aportes que cumplan con los filtros.'); ?> </p> <?php } ?> </div>
public function save(&$errors = array()) { if (!$this->validate($errors)) { return false; } $fields = array('id', 'title', 'text', 'legend', 'media'); $values = array(); foreach ($fields as $field) { if ($set != '') { $set .= ", "; } $set .= "`{$field}` = :{$field} "; $values[":{$field}"] = $this->{$field}; } try { $sql = "REPLACE INTO glossary SET " . $set; self::query($sql, $values); if (empty($this->id)) { $this->id = self::insertId(); } // Luego la imagen if (!empty($this->id) && is_array($this->image) && !empty($this->image['name'])) { $image = new Image($this->image); if ($image->save($errors)) { $this->gallery[] = $image; /** * Guarda la relación NM en la tabla 'glossary_image'. */ if (!empty($image->id)) { self::query("REPLACE glossary_image (glossary, image) VALUES (:glossary, :image)", array(':glossary' => $this->id, ':image' => $image->id)); } } else { Message::Error(Text::get('image-upload-fail') . implode(', ', $errors)); } } return true; } catch (\PDOException $e) { $errors[] = Text::_("No se ha guardado correctamente. ") . $e->getMessage(); return false; } }
public static function process($action = 'list', $id = null, $filters = array()) { switch ($action) { case 'fulfill': $sql = "UPDATE invest_reward SET fulfilled = 1 WHERE invest = ?"; if (Model\Invest::query($sql, array($id))) { Message::Info(Text::get('admin-rewards-info-status-completed')); } else { Message::Error(Text::get('admin-rewards-error-statuschage-fail')); } throw new Redirection('/admin/rewards'); break; case 'unfill': $sql = "UPDATE invest_reward SET fulfilled = 0 WHERE invest = ?"; if (Model\Invest::query($sql, array($id))) { Message::Info(Text::get('admin-rewards-info-status-completed-pending')); } else { message::Error('Ha fallado al desmarcar'); } throw new Redirection('/admin/rewards'); break; } // edicion if ($action == 'edit' && !empty($id)) { $invest = Model\Invest::get($id); $projectData = Model\Project::get($invest->project); $userData = Model\User::getMini($invest->user); $status = Model\Project::status(); // si tratando post if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update'])) { $errors = array(); // la recompensa: $chosen = $_POST['selected_reward']; if (empty($chosen)) { // renuncia a las recompensas, bien por el/ella! $invest->rewards = array(); } else { $invest->rewards = array($chosen); } $invest->anonymous = $_POST['anonymous']; // dirección de envio para la recompensa // y datos fiscales por si fuera donativo $invest->address = (object) array('name' => $_POST['name'], 'nif' => $_POST['nif'], 'address' => $_POST['address'], 'zipcode' => $_POST['zipcode'], 'location' => $_POST['location'], 'country' => $_POST['country']); if ($invest->update($errors)) { Message::Info(Text::get('admin-rewards-info-update')); throw new Redirection('/admin/rewards'); } else { Message::Error('No se han actualizado correctamente los datos del aporte. ERROR: ' . implode(', ', $errors)); } } return new View('view/admin/index.html.php', array('folder' => 'rewards', 'file' => 'edit', 'invest' => $invest, 'project' => $projectData, 'user' => $userData, 'status' => $status)); } // listado de proyectos $projects = Model\Invest::projects(); $status = array('nok' => Text::_("Pendiente"), 'ok' => Text::_("Cumplida")); // listado de aportes if ($filters['filtered'] == 'yes') { $list = Model\Project\Reward::getChossen($filters); } else { $list = array(); } return new View('view/admin/index.html.php', array('folder' => 'rewards', 'file' => 'list', 'list' => $list, 'filters' => $filters, 'projects' => $projects, 'status' => $status)); }
/** * Actualizar las preferencias de notificación * * @return type booblean */ public static function setPreferences($user, $data = array(), &$errors = array()) { $values = array(); $set = ''; foreach ($data as $key => $value) { $values[":{$key}"] = $value; if ($set != '') { $set .= ', '; } $set .= "{$key} = :{$key}"; } if (!empty($values) && $set != '') { $values[':user'] = $user; $sql = "REPLACE INTO user_prefer SET user = :user, " . $set; try { self::query($sql, $values); return true; } catch (\PDOException $e) { $errors[] = Text::_("No se ha guardado correctamente. ") . $e->getMessage(); return false; } } }
/** * Quitar una palabra clave de un proyecto * * @param varchar(50) $project id de un proyecto * @param INT(12) $id identificador de la tabla keyword * @param array $errors * @return boolean */ public function remove(&$errors = array()) { $values = array(':project' => $this->project, ':category' => $this->id); try { self::query("DELETE FROM project_category WHERE category = :category AND project = :project", $values); return true; } catch (\PDOException $e) { $errors[] = Text::_('No se ha podido quitar la categoria ') . $this->id . ' del proyecto ' . $this->project . ' ' . $e->getMessage(); //Text::get('remove-category-fail'); return false; } }
/** * Metodo para sacar los eventos relacionados con un usuario * * @param string $id id del usuario * @param string $filter para tipos de eventos que queremos obtener * @return array list of items (como getAll) */ public static function getUserItems($id, $filter = 'private') { $list = array(); try { $values = array(); $wheres = array(); if (!empty($filter)) { switch ($filter) { case 'private': // eventos que afecten al usuario $wheres[] = "feed.target_type = 'user'"; $wheres[] = "feed.target_id = :target_id"; $values[':target_id'] = $id; break; case 'supported': // eventos del proyectos que cofinancio (o he intentado cofinanciar) $wheres[] = "feed.target_type = 'project'"; $wheres[] = "feed.target_id IN (\n SELECT DISTINCT(invest.project) FROM invest WHERE invest.user = :id\n )"; $values[':id'] = $id; break; case 'comented': // eventos de proyectos en los que comento pero que no cofinancio $wheres[] = "feed.target_type = 'project'"; $wheres[] = "( feed.target_id IN (\n SELECT DISTINCT(message.project) FROM message WHERE message.user = :id\n ) OR feed.target_id IN (\n SELECT DISTINCT(blog.owner)\n FROM comment\n INNER JOIN post\n ON post.id = comment.post\n INNER JOIN blog\n ON blog.id = post.blog\n AND blog.type = 'project'\n WHERE comment.user = :id\n )\n )"; $wheres[] = "feed.target_id NOT IN (\n SELECT DISTINCT(invest.project) FROM invest WHERE invest.user = :id\n )"; $values[':id'] = $id; break; } } $sql = "SELECT\n feed.id as id,\n feed.title as title,\n feed.url as url,\n feed.image as image,\n DATE_FORMAT(feed.datetime, '%H:%i %d|%m|%Y') as date,\n feed.datetime as timer,\n feed.html as html\n FROM feed\n WHERE " . implode(' AND ', $wheres) . "\n ORDER BY datetime DESC\n LIMIT 99\n "; $query = Model::query($sql, $values); foreach ($query->fetchAll(\PDO::FETCH_CLASS, __CLASS__) as $item) { //hace tanto $item->timeago = self::time_ago($item->timer); $list[] = $item; } return $list; } catch (\PDOException $e) { return array(); @\mail(\GOTEO_MAIL, 'ERROR SQL en Feed::getItems', Text::_('No se ha guardado correctamente. ') . $e->getMessage() . "<br />{$sql}<br /><pre>" . print_r($values, 1) . "</pre>"); } }
public function save(&$errors = array()) { // if (!$this->validate($errors)) return false; $fields = array('id', 'node', 'project', 'title', 'description', 'order', 'active'); $set = ''; $values = array(); foreach ($fields as $field) { if ($set != '') { $set .= ", "; } $set .= "`{$field}` = :{$field} "; $values[":{$field}"] = $this->{$field}; } try { $sql = "REPLACE INTO promote SET " . $set; self::query($sql, $values); if (empty($this->id)) { $this->id = self::insertId(); } return true; } catch (\PDOException $e) { $errors[] = Text::_("No se ha guardado correctamente. ") . $e->getMessage(); return false; } }
<select id="orig-lang" name="lang"> <?php foreach ($langs as $item) { ?> <option value="<?php echo $item->id; ?> "<?php if ($project->lang == $item->id || empty($project->lang) && $item->id == 'es') { echo ' selected="selected"'; } ?> ><?php echo $item->name; ?> </option> <?php } ?> </select> </td> </tr> </table> <input type="submit" name="save" value="<?php echo Text::_("Guardar"); ?> " /> </form> </div>
echo $title[$detail]; ?> </h3> <div class="widget board"> <table> <tr> <th><?php echo Text::_('Email'); ?> </th> <th><?php echo Text::_('Alias'); ?> </th> <th><?php echo Text::_('Usuario'); ?> </th> </tr> <?php foreach ($list as $user) { ?> <tr> <?php echo "<td>{$user->email}</td><td>{$user->name}</td><td>{$user->user}</td>"; ?> </tr> <?php } ?> </table>
<?php } ?> <td><a href="/admin/criteria/remove/<?php echo $criteria->id; ?> " onclick="return confirm('<?php echo Text::_("Seguro que deseas eliminar este registro?"); ?> ');">[<?php echo Text::_("Quitar"); ?> ]</a></td> </tr> <?php } ?> </tbody> </table> <?php } else { ?> <p><?php echo Text::_('No se han encontrado registros'); ?> </p> <?php } ?> </div>
public static function getReportData($project, $status, $round, $passed) { $Data = array(); // segun estado, ronda y fecha de pase a segunda // el cash(1) es igual para todos switch ($status) { case 0: // descartado // descartado case 1: // edicion // edicion case 2: // revision // revision case 6: // caducado // Para estos cuatro estados es lo mismo: // - Solo finaciacion actual // (aunque hiciera una ronda, aunque se descartara en segunda ronda) // - Puede tener aportes en cash // - Puede tener aportes caducados (pero no los mostramos) // - Si tiene aportes de paypal(0,1) o tpv(1) es un problema // A ver si tiene cash // si hay aportes de cash activos no es incidencia porque puede venir de taller // a menos que sea de convocatoria (que deberian estar cancelados) $inv_cash = self::getList(array('methods' => 'cash', 'projects' => $project, 'investStatus' => '1')); if (!empty($inv_cash)) { $Data['cash']['total']['fail'] = 0; foreach ($inv_cash as $invId => $invest) { $Data['cash']['total']['users'][$invest->user] = $invest->user; $Data['cash']['total']['invests']++; $Data['cash']['total']['amount'] += $invest->amount; } } // A ver si tiene paypal // si estan pendientes, ejecutados o pagados al proyecto es una incidencia $inv_paypal = self::getList(array('methods' => 'paypal', 'projects' => $project)); if (!empty($inv_paypal)) { // $Data['note'][] = "Los aportes de paypal son incidencias si están activos"; foreach ($inv_paypal as $invId => $invest) { if (in_array($invest->investStatus, array(0, 1, 3))) { $Data['paypal']['total']['fail'] += $invest->amount; $Data['note'][] = Text::_("El aporte PayPal") . " {$invId} " . Text::_("no debería estar en estado '") . self::status($invest->investStatus) . "'"; } } } // A ver si tiene tpv // si estan pendientes, ejecutados o pagados al proyecto es una incidencia $inv_tpv = self::getList(array('methods' => 'tpv', 'projects' => $project)); if (!empty($inv_tpv)) { // $Data['note'][] = "Los aportes de tpv son incidencias si están activos"; foreach ($inv_tpv as $invId => $invest) { if ($invest->investStatus == 1) { $Data['tpv']['total']['fail'] += $invest->amount; $Data['note'][] = Text::_("El aporte TPV") . " {$invId} " . Text::_("no debería estar en estado '") . self::status($invest->investStatus) . "'"; } } } break; case 4: // financiado // financiado case 5: // exitoso // en etos dos estados paypal(0) es incidencia en cualquier ronda $p0 = (string) 'all'; case 3: // en marcha // si tiene fecha $project->passed de pase a segunda ronda: paypal(0) no es incidencia para los aportes de segunda ronda if (!empty($passed)) { if ($round == 1) { // esto es mal $Data['note'][] = "ATENCION! Está marcada la fecha de pase a segunda ronda (el {$passed}) pero sique en primera ronda!!!"; $act_eq = (string) 'first'; } else { // en segunda ronda if (!isset($p0)) { $p0 = (string) 'first'; // paypal(0) es incidencia paralos de primera ronda solamente } // si está en segunda ronda; la financiacion actual es un merge de usuarios y suma de aportes correctos, incidencias, correctos y cantidad total $act_eq = (string) 'sum'; } } else { // si no tiene fecha de pase y esta en ronda 2: es un problema se trata como solo financiacion actual y paypal(0) no son incidencias if ($round == 2) { $Data['note'][] = Text::_("ATENCION! En segunda ronda pero NO está marcada la fecha de pase a segunda ronda!"); $act_eq = (string) 'first'; } else { // ok, en primera ronda sin fecha marcada, informe solo actual = primera $act_eq = (string) 'first'; } } // si solamente financiacion actual=primera // simple: no filtramos fecha if ($act_eq === 'first') { // CASH $inv_cash = self::getList(array('methods' => 'cash', 'projects' => $project, 'investStatus' => '1')); if (!empty($inv_cash)) { $Data['cash']['first']['fail'] = 0; foreach ($inv_cash as $invId => $invest) { $Data['cash']['first']['users'][$invest->user] = $invest->user; $Data['cash']['first']['invests']++; $Data['cash']['first']['amount'] += $invest->amount; } $Data['cash']['total'] = $Data['cash']['first']; } // TPV $inv_tpv = self::getList(array('methods' => 'tpv', 'projects' => $project, 'investStatus' => '1')); if (!empty($inv_tpv)) { $Data['tpv']['first']['fail'] = 0; foreach ($inv_tpv as $invId => $invest) { $Data['tpv']['first']['users'][$invest->user] = $invest->user; $Data['tpv']['first']['invests']++; $Data['tpv']['first']['amount'] += $invest->amount; } $Data['tpv']['total'] = $Data['tpv']['first']; } // PAYPAL $inv_paypal = self::getList(array('methods' => 'paypal', 'projects' => $project)); if (!empty($inv_paypal)) { $Data['paypal']['first']['fail'] = 0; foreach ($inv_paypal as $invId => $invest) { if (in_array($invest->investStatus, array('0', '1', '3'))) { $Data['paypal']['first']['users'][$invest->user] = $invest->user; $Data['paypal']['first']['invests']++; $Data['paypal']['first']['amount'] += $invest->amount; } } $Data['paypal']['total'] = $Data['paypal']['first']; } } elseif ($act_eq === 'sum') { // complicado: primero los de primera ronda, luego los de segunda ronda sumando al total // calcular ultimo dia de primera ronda segun la fecha de pase $passtime = strtotime($passed); $last_day = date('Y-m-d', \mktime(0, 0, 0, date('m', $passtime), date('d', $passtime) - 1, date('Y', $passtime))); // CASH first $inv_cash = self::getList(array('methods' => 'cash', 'projects' => $project, 'investStatus' => '1', 'date_until' => $last_day)); if (!empty($inv_cash)) { $Data['cash']['first']['fail'] = 0; foreach ($inv_cash as $invId => $invest) { $Data['cash']['first']['users'][$invest->user] = $invest->user; $Data['cash']['first']['invests']++; $Data['cash']['first']['amount'] += $invest->amount; } $Data['cash']['total'] = $Data['cash']['first']; } // TPV first $inv_tpv = self::getList(array('methods' => 'tpv', 'projects' => $project, 'investStatus' => '1', 'date_until' => $last_day)); if (!empty($inv_tpv)) { $Data['tpv']['first']['fail'] = 0; foreach ($inv_tpv as $invId => $invest) { $Data['tpv']['first']['users'][$invest->user] = $invest->user; $Data['tpv']['first']['invests']++; $Data['tpv']['first']['amount'] += $invest->amount; } $Data['tpv']['total'] = $Data['tpv']['first']; } // PAYPAL first $inv_paypal = self::getList(array('methods' => 'paypal', 'projects' => $project, 'date_until' => $last_day)); if (!empty($inv_paypal)) { $Data['paypal']['first']['fail'] = 0; foreach ($inv_paypal as $invId => $invest) { if (in_array($invest->investStatus, array('0', '1', '3'))) { // a ver si cargo pendiente es incidencia... if ($invest->investStatus == 0 && ($p0 === 'first' || $p0 === 'all')) { $Data['paypal']['first']['fail'] += $invest->amount; $Data['note'][] = "El aporte paypal {$invId} no debería estar en estado '" . self::status($invest->investStatus) . "'. <a href=\"/admin/invests/details/{$invId}\" target=\"_blank\">Abrir detalles</a>"; continue; } $Data['paypal']['first']['users'][$invest->user] = $invest->user; $Data['paypal']['first']['invests']++; $Data['paypal']['first']['amount'] += $invest->amount; } } $Data['paypal']['total'] = $Data['paypal']['first']; } // CASH second $inv_cash = self::getList(array('methods' => 'cash', 'projects' => $project, 'investStatus' => '1', 'date_from' => $passed)); if (!empty($inv_cash)) { $Data['cash']['second']['fail'] = 0; foreach ($inv_cash as $invId => $invest) { $Data['cash']['second']['users'][$invest->user] = $invest->user; $Data['cash']['total']['users'][$invest->user] = $invest->user; $Data['cash']['second']['invests']++; $Data['cash']['total']['invests']++; $Data['cash']['second']['amount'] += $invest->amount; } $Data['cash']['total']['amount'] += $Data['cash']['second']['amount']; } // TPV second $inv_tpv = self::getList(array('methods' => 'tpv', 'projects' => $project, 'investStatus' => '1', 'date_from' => $passed)); if (!empty($inv_tpv)) { $Data['tpv']['second']['fail'] = 0; foreach ($inv_tpv as $invId => $invest) { $Data['tpv']['second']['users'][$invest->user] = $invest->user; $Data['tpv']['total']['users'][$invest->user] = $invest->user; $Data['tpv']['second']['invests']++; $Data['tpv']['total']['invests']++; $Data['tpv']['second']['amount'] += $invest->amount; } $Data['tpv']['total']['amount'] += $Data['tpv']['second']['amount']; } // PAYPAL second $inv_paypal = self::getList(array('methods' => 'paypal', 'projects' => $project, 'date_from' => $passed)); if (!empty($inv_paypal)) { $Data['paypal']['second']['fail'] = 0; foreach ($inv_paypal as $invId => $invest) { if (in_array($invest->investStatus, array('0', '1', '3'))) { // a ver si cargo pendiente es incidencia... if ($invest->investStatus == 0 && $p0 === 'all') { $Data['paypal']['second']['fail'] += $invest->amount; $Data['paypal']['total']['fail'] += $invest->amount; $Data['note'][] = "El aporte paypal {$invId} no debería estar en estado '" . self::status($invest->investStatus) . "'. <a href=\"/admin/invests/details/{$invId}\" target=\"_blank\">Abrir detalles</a>"; continue; } $Data['paypal']['second']['users'][$invest->user] = $invest->user; $Data['paypal']['total']['users'][$invest->user] = $invest->user; $Data['paypal']['second']['invests']++; $Data['paypal']['total']['invests']++; $Data['paypal']['second']['amount'] += $invest->amount; } } $Data['paypal']['total']['amount'] += $Data['paypal']['second']['amount']; } } else { $Data['note'][] = Text::_('No se ha calculado bien el parametro $act_eq'); } break; } // incidencias $Data['issues'] = self::getReportIssues($project); return $Data; }