示例#1
0
 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::_('No se ha grabado correctamente. ') . 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;
     }
 }
示例#2
0
文件: worth.php 项目: anvnguyen/Goteo
 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));
 }
示例#3
0
文件: home.php 项目: isbkch/Goteo
 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);
 }
示例#4
0
 /**
  * Quitar una palabra clave de un proyecto
  *
  * @param varchar(50) $user 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(':user' => $this->user, ':id' => $this->id);
     try {
         self::query("DELETE FROM user_web WHERE id = :id AND user = :user", $values);
         return true;
     } catch (\PDOException $e) {
         $errors[] = Text::_('No se ha podido quitar la web ') . $this->id . Text::_(' del usuario ') . $this->user . ' ' . $e->getMessage();
         return false;
     }
 }
示例#5
0
文件: review.php 项目: isbkch/Goteo
 public function save(&$errors = array())
 {
     if (!$this->validate($errors)) {
         return false;
     }
     $values = array(':user' => $this->user, ':review' => $this->id);
     try {
         $sql = "REPLACE INTO user_review (user, review) VALUES(:user, :review)";
         self::query($sql, $values);
         return true;
     } catch (\PDOException $e) {
         $errors[] = Text::_("No se ha guardado correctamente. ") . $e->getMessage();
         return false;
     }
 }
示例#6
0
 function showRows()
 {
     $order = !$_GET['order'] ? 'id' : $_GET['order'];
     $orderdir = strtoupper($_GET['orderdir']) == 'DESC' ? 'DESC' : 'ASC';
     $ordering = ' ORDER BY ' . $order . ' ' . $orderdir;
     $query = 'SELECT count(*) AS count FROM ' . $this->table->_tbl;
     $this->db->setQuery($query);
     $row = $this->db->LoadObject();
     if ($row->count > 0) {
         $query = 'SELECT prices.*,apps.name AS app' . ' FROM ' . $this->table->_tbl . ' LEFT JOIN apps ON prices.appid=apps.id' . $ordering;
         $pagination =& Factory::getPagination();
         $pagination->pager($row->count, 20, 6);
         $this->db->setQuery($query, $pagination->limiStart, $pagination->pageRows);
         $rows = $this->db->LoadObjectList();
         $this->assign('pagination', $pagination);
         $this->assign('rows', $rows);
     } else {
         $this->assign('noRows', Text::_('No Data Found'));
     }
     $this->display('prices.tpl');
 }
示例#7
0
 function customInit()
 {
     parent::customInit();
     if (count($_POST) > 0) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         if ($username && $password) {
             $this->db->setQuery('SELECT * FROM users WHERE username='******' AND password='******'admin', (object) array('username' => $username, 'password' => md5($password)));
                 $this->setRedirect('index.php');
             } else {
                 $msg = Text::_('Wrong Username or Password');
             }
         } else {
             $msg = Text::_('Please Enter Username and Password');
         }
     }
     $_SESSION['msg'] = $msg;
     $this->display('login.tpl');
     die;
 }
示例#8
0
 function showRows()
 {
     $html =& Factory::getHtml();
     $order = !$_GET['order'] ? 'id' : $_GET['order'];
     $orderdir = strtoupper($_GET['orderdir']) == 'DESC' ? 'DESC' : 'ASC';
     $ordering = ' ORDER BY ' . $order . ' ' . $orderdir;
     $query = 'SELECT count(*) AS count FROM ' . $this->table->_tbl;
     $this->db->setQuery($query);
     $row = $this->db->LoadObject();
     if ($row->count > 0) {
         $query = 'SELECT *' . ' FROM ' . $this->table->_tbl . $ordering;
         $pagination =& Factory::getPagination();
         $pagination->pager($row->count, 20, 6);
         $this->db->setQuery($query, $pagination->limiStart, $pagination->pageRows);
         $rows = $this->db->LoadObjectList();
         $this->assign('pagination', $pagination);
         $this->assign('rows', $rows);
         $this->assign('orderDis', $orderDis);
         $this->assign('html', $html);
     } else {
         $this->assign('noRows', Text::_('No Data Found'));
     }
     $this->display('reports.tpl');
 }
示例#9
0
 function showRows()
 {
     $order = !$_GET['order'] ? 'id' : $_GET['order'];
     $orderdir = strtoupper($_GET['orderdir']) == 'DESC' ? 'DESC' : 'ASC';
     $ordering = ' ORDER BY ' . $order . ' ' . $orderdir;
     $where = '';
     if (!$this->user->admin) {
         if (!empty($this->user->permissions['groups'])) {
             $where[] = 'EXISTS (SELECT expenses_groups.expenseid FROM expenses_groups WHERE expenses_groups.groupid IN (' . implode(',', $this->user->permissions['groups']) . ')' . ' AND expenses.id=expenses_groups.expenseid AND expenses_groups.share>0)';
         } else {
             $where[] = '0';
         }
         if (!empty($this->user->permissions['markets'])) {
             $where[] = 'EXISTS (SELECT expenses_markets.expenseid FROM expenses_markets WHERE expenses_markets.marketid IN (' . implode(',', $this->user->permissions['markets']) . ')' . ' AND expenses.id=expenses_markets.expenseid)';
         } else {
             $where[] = '0';
         }
     }
     if (!empty($where)) {
         $where = ' WHERE ' . implode(' AND ', $where);
     }
     $query = 'SELECT count(*) AS count FROM expenses' . $where;
     $this->db->setQuery($query);
     $row = $this->db->LoadObject();
     if ($row->count > 0) {
         $query = 'SELECT expenses.*' . ' FROM expenses' . $join4where . $where . $ordering;
         $pagination =& Factory::getPagination();
         $pagination->pager($row->count, 20, 6);
         $this->db->setQuery($query, $pagination->limiStart, $pagination->pageRows);
         $rows = $this->db->LoadObjectList();
         $this->assign('pagination', $pagination);
         $this->assign('rows', $rows);
     } else {
         $this->assign('noRows', Text::_('No Data Found'));
     }
     $this->display('expenses.tpl');
 }
示例#10
0
文件: post.php 项目: anvnguyen/Goteo
 public function update(&$errors = array())
 {
     if (!$this->id) {
         return false;
     }
     $fields = array('order', 'home', 'footer');
     $set = '';
     $values = array(':id' => $this->id);
     foreach ($fields as $field) {
         if (!isset($this->{$field})) {
             continue;
         }
         if ($set != '') {
             $set .= ", ";
         }
         $set .= "`{$field}` = :{$field} ";
         $values[":{$field}"] = $this->{$field};
     }
     if ($set == '') {
         $errors[] = Text::_('Sin datos');
         return false;
     }
     try {
         $sql = "UPDATE post SET " . $set . " WHERE post.id = :id";
         self::query($sql, $values);
         return true;
     } catch (\PDOException $e) {
         $errors[] = Text::_("No se ha guardado correctamente. ") . $e->getMessage();
         return false;
     }
 }
示例#11
0
 public static function process($action = 'list', $id = null, $filters = array())
 {
     $node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE;
     $errors = array();
     switch ($action) {
         case 'add':
             // proyectos que están más allá de edición y con traducción deshabilitada
             $availables = Model\User\Translate::getAvailables('project', $_SESSION['admin_node']);
             if (empty($availables)) {
                 Message::Error(Text::_('No hay más proyectos disponibles para traducir'));
                 throw new Redirection('/admin/translates');
             }
         case 'edit':
         case 'assign':
         case 'unassign':
         case 'send':
             // a ver si tenemos proyecto
             if (empty($id) && !empty($_POST['project'])) {
                 $id = $_POST['project'];
             }
             if (!empty($id)) {
                 $project = Model\Project::getMini($id);
             } elseif ($action != 'add') {
                 Message::Error(Text::_('No hay proyecto sobre el que operar'));
                 throw new Redirection('/admin/translates');
             }
             // asignar o desasignar
             // la id de revision llega en $id
             // la id del usuario llega por get
             $user = $_GET['user'];
             if (!empty($user)) {
                 $userData = Model\User::getMini($user);
                 $assignation = new Model\User\Translate(array('item' => $project->id, 'type' => 'project', 'user' => $user));
                 switch ($action) {
                     case 'assign':
                         // se la ponemos
                         $what = Text::_('Asignado');
                         if ($assignation->save($errors)) {
                             Message::Info(Text::_('Traducción asignada correctamente'));
                             throw new Redirection('/admin/translates/edit/' . $project->id);
                         } else {
                             Message::Error(Text::_('No se ha guardado correctamente. ') . implode(', ', $errors));
                         }
                         break;
                     case 'unassign':
                         // se la quitamos
                         $what = Text::_('Desasignado');
                         if ($assignation->remove($errors)) {
                             Message::Info(Text::_('Traducción desasignada correctamente'));
                             throw new Redirection('/admin/translates/edit/' . $project->id);
                         } else {
                             Message::Error(Text::_('No se ha guardado correctamente. ') . implode(', ', $errors));
                         }
                         break;
                 }
                 if (empty($errors)) {
                     // Evento Feed
                     $log = new Feed();
                     $log->setTarget($userData->id, 'user');
                     $log->populate($what . ' traduccion (admin)', '/admin/translates', \vsprintf('El admin %s ha %s a %s la traducción del proyecto %s', array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', $what), Feed::item('user', $userData->name, $userData->id), Feed::item('project', $project->name, $project->id))));
                     $log->doAdmin('admin');
                     unset($log);
                 }
                 $action = 'edit';
             }
             // fin asignar o desasignar
             // añadir o actualizar
             // se guarda el idioma original y si la traducción está abierta o cerrada
             if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['save'])) {
                 if (empty($id)) {
                     Message::Error(Text::_('Hemos perdido de vista el proyecto'));
                     throw new Redirection('/admin/translates');
                 }
                 // ponemos los datos que llegan
                 $sql = "UPDATE project SET lang = :lang, translate = 1 WHERE id = :id";
                 if (Model\Project::query($sql, array(':lang' => $_POST['lang'], ':id' => $id))) {
                     if ($action == 'add') {
                         Message::Info('El proyecto ' . $project->name . ' se ha habilitado para traducir');
                     } else {
                         Message::Info(Text::_('Datos de traducción actualizados'));
                     }
                     if ($action == 'add') {
                         // Evento Feed
                         $log = new Feed();
                         $log->setTarget($project->id);
                         $log->populate(Text::_('proyecto habilitado para traducirse (admin)'), '/admin/translates', \vsprintf('El admin %s ha %s la traducción del proyecto %s', array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Habilitado'), Feed::item('project', $project->name, $project->id))));
                         $log->doAdmin('admin');
                         unset($log);
                         throw new Redirection('/admin/translates/edit/' . $project->id);
                     } else {
                         throw new Redirection('/admin/translates');
                     }
                 } else {
                     if ($action == 'add') {
                         Message::Error(Text::_('Ha fallado al habilitar la traducción del proyecto ') . $project->name);
                     } else {
                         Message::Error(Text::_('Ha fallado al actualizar los datos de la traducción'));
                     }
                 }
             }
             if ($action == 'send') {
                 // Informar al autor de que la traduccion está habilitada
                 // Obtenemos la plantilla para asunto y contenido
                 $template = Template::get(26);
                 // Sustituimos los datos
                 $subject = str_replace('%PROJECTNAME%', $project->name, $template->title);
                 $search = array('%OWNERNAME%', '%PROJECTNAME%', '%SITEURL%');
                 $replace = array($project->user->name, $project->name, SITE_URL);
                 $content = \str_replace($search, $replace, $template->text);
                 // iniciamos mail
                 $mailHandler = new Mail();
                 $mailHandler->to = $project->user->email;
                 $mailHandler->toName = $project->user->name;
                 // blind copy a goteo desactivado durante las verificaciones
                 //              $mailHandler->bcc = '*****@*****.**';
                 $mailHandler->subject = $subject;
                 $mailHandler->content = $content;
                 $mailHandler->html = true;
                 $mailHandler->template = $template->id;
                 if ($mailHandler->send()) {
                     Message::Info('Se ha enviado un email a <strong>' . $project->user->name . '</strong> a la dirección <strong>' . $project->user->email . '</strong>');
                 } else {
                     Message::Error('Ha fallado al enviar el mail a <strong>' . $project->user->name . '</strong> a la dirección <strong>' . $project->user->email . '</strong>');
                 }
                 unset($mailHandler);
                 $action = 'edit';
             }
             $project->translators = Model\User\Translate::translators($id);
             $translators = Model\User::getAll(array('role' => 'translator'));
             // añadimos al dueño del proyecto en el array de traductores
             array_unshift($translators, $project->user);
             return new View('view/admin/index.html.php', array('folder' => 'translates', 'file' => 'edit', 'action' => $action, 'availables' => $availables, 'translators' => $translators, 'project' => $project));
             break;
         case 'close':
             // la sentencia aqui mismo
             // el campo translate del proyecto $id a false
             $sql = "UPDATE project SET translate = 0 WHERE id = :id";
             if (Model\Project::query($sql, array(':id' => $id))) {
                 Message::Info('La traducción del proyecto ' . $project->name . ' se ha finalizado');
                 Model\Project::query("DELETE FROM user_translate WHERE type = 'project' AND item = :id", array(':id' => $id));
                 // Evento Feed
                 $log = new Feed();
                 $log->setTarget($project->id);
                 $log->populate(Text::_('traducción finalizada (admin)'), '/admin/translates', \vsprintf('El admin %s ha dado por %s la traducción del proyecto %s', array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Finalizada'), Feed::item('project', $project->name, $project->id))));
                 $log->doAdmin('admin');
                 unset($log);
             } else {
                 Message::Error(Text::_('Falló al finalizar la traducción'));
             }
             break;
     }
     $projects = Model\Project::getTranslates($filters, $node);
     $owners = Model\User::getOwners();
     $translators = Model\User::getAll(array('role' => 'translator'));
     return new View('view/admin/index.html.php', array('folder' => 'translates', 'file' => 'list', 'projects' => $projects, 'filters' => $filters, 'fields' => array('owner', 'translator'), 'owners' => $owners, 'translators' => $translators));
 }
示例#12
0
文件: sponsor.php 项目: isbkch/Goteo
 public function save(&$errors = array())
 {
     if (!$this->validate($errors)) {
         return false;
     }
     // Primero la imagenImagen
     if (is_array($this->image) && !empty($this->image['name'])) {
         $image = new Image($this->image);
         if ($image->save($errors)) {
             $this->image = $image->id;
         } else {
             \Goteo\Library\Message::Error(Text::get('image-upload-fail') . implode(', ', $errors));
             $this->image = '';
         }
     }
     $fields = array('id', 'name', 'url', 'image', 'order');
     $set = '';
     $values = array();
     foreach ($fields as $field) {
         if ($set != '') {
             $set .= ", ";
         }
         $set .= "`{$field}` = :{$field} ";
         $values[":{$field}"] = $this->{$field};
     }
     try {
         $sql = "REPLACE INTO sponsor SET " . $set;
         self::query($sql, $values);
         if (empty($this->id)) {
             $this->id = self::insertId();
         }
         Check::reorder($this->id, 'up', 'sponsor');
         return true;
     } catch (\PDOException $e) {
         $errors[] = Text::_("No se ha guardado correctamente. ") . $e->getMessage();
         return false;
     }
 }
示例#13
0
 function import()
 {
     JRequest::checkToken('request') || die('Invalid Token');
     $function = JRequest::getCmd('importfrom');
     $this->helper->addTemplate(JRequest::getInt('template_product', 0));
     switch ($function) {
         case 'file':
             $this->_file();
             break;
         case 'textarea':
             $this->_textarea();
             break;
         case 'folder':
             if (hikashop_level(2)) {
                 $this->_folder();
             } else {
                 $app =& JFactory::getApplication();
                 $app->enqueueMessage(Text::_('ONLY_FROM_HIKASHOP_BUSINESS'), 'error');
             }
             break;
         case 'vm':
             $query = 'SHOW TABLES LIKE ' . $this->db->Quote($this->db->getPrefix() . substr(hikashop_table('virtuemart_products', false), 3));
             $this->db->setQuery($query);
             $table = $this->db->loadResult();
             if (empty($table)) {
                 $query = 'SHOW TABLES LIKE ' . $this->db->Quote($this->db->getPrefix() . substr(hikashop_table('vm_product', false), 3));
                 $this->db->setQuery($query);
                 $table = $this->db->loadResult();
                 if (empty($table)) {
                     $app =& JFactory::getApplication();
                     $app->enqueueMessage('VirtueMart has not been found in the database', 'error');
                 } else {
                     $this->helperImport = hikashop_get('helper.import-vm1', $this);
                     $this->_vm();
                 }
             } else {
                 $this->helperImport = hikashop_get('helper.import-vm2', $this);
                 $this->_vm();
             }
             break;
         case 'mijo':
             $this->helperImport = hikashop_get('helper.import-mijo', $this);
             $query = 'SHOW TABLES LIKE ' . $this->db->Quote($this->db->getPrefix() . substr(hikashop_table('mijoshop_product', false), 3));
             $this->db->setQuery($query);
             $table = $this->db->loadResult();
             if (empty($table)) {
                 $app =& JFactory::getApplication();
                 $app->enqueueMessage('Mijoshop has not been found in the database', 'error');
             } else {
                 $this->_mijo();
             }
             break;
         case 'redshop':
             $this->helperImport = hikashop_get('helper.import-reds', $this);
             $query = 'SHOW TABLES LIKE ' . $this->db->Quote($this->db->getPrefix() . substr(hikashop_table('redshop_product', false), 3));
             $this->db->setQuery($query);
             $table = $this->db->loadResult();
             if (empty($table)) {
                 $app =& JFactory::getApplication();
                 $app->enqueueMessage('Redshop has not been found in the database', 'error');
             } else {
                 $this->_redshop();
             }
             break;
         case 'openc':
             $this->helperImport = hikashop_get('helper.import-openc', $this);
             $this->_opencart();
             break;
         default:
             $plugin = hikashop_import('hikashop', $function);
             if ($plugin) {
                 $plugin->onImportRun();
             }
             break;
     }
     return $this->show();
 }
示例#14
0
文件: tag.php 项目: anvnguyen/Goteo
 public function assign(&$errors = array())
 {
     $fields = array('tag', 'post');
     $set = '';
     $values = array();
     foreach ($fields as $field) {
         if ($set != '') {
             $set .= ", ";
         }
         $set .= "`{$field}` = :{$field} ";
         $values[":{$field}"] = $this->{$field};
     }
     try {
         $sql = "REPLACE INTO post_tag 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;
     }
 }
示例#15
0
 /**
  * Quitarle una traducción al usuario
  *
  * @param varchar(50) $user id del usuario
  * @param INT(12) $id  identificador de la tabla project
  * @param array $errors 
  * @return boolean
  */
 public function remove(&$errors = array())
 {
     $values = array(':user' => $this->user, ':type' => $this->type, ':item' => $this->item);
     try {
         if (self::query("DELETE FROM user_translate WHERE type = :type AND item = :item AND user = :user", $values)) {
             ACL::deny('/translate/' . $this->type . '/' . $this->item . '/*', '*', 'translator', $this->user);
             return true;
         } else {
             return false;
         }
     } catch (\PDOException $e) {
         $errors[] = Text::_('No se ha guardado correctamente. ') . $e->getMessage();
         return false;
     }
 }
示例#16
0
 function showRows()
 {
     $html =& Factory::getHtml();
     $order = !$_GET['order'] ? 'id' : $_GET['order'];
     $orderdir = strtoupper($_GET['orderdir']) == 'DESC' ? 'DESC' : 'ASC';
     $ordering = ' ORDER BY ' . $order . ' ' . $orderdir;
     $query = 'SELECT count(*) AS count FROM ' . $this->table->_tbl;
     $this->db->setQuery($query);
     $row = $this->db->LoadObject();
     if ($row->count > 0) {
         $query = 'SELECT apps.*,' . '(SELECT GROUP_CONCAT(platforms.name," ") FROM platforms INNER JOIN app_platforms ON platforms.id=app_platforms.platformid WHERE app_platforms.appid=apps.id) AS platforms,' . '(SELECT GROUP_CONCAT(apptypes.name," ") FROM apptypes INNER JOIN app_types ON apptypes.id=app_types.typeid WHERE app_types.appid=apps.id) AS apptypes,' . '(SELECT GROUP_CONCAT(groups.name," ") FROM groups INNER JOIN app_groups ON groups.id=app_groups.groupid WHERE app_groups.appid=apps.id) AS groups,' . '(SELECT GROUP_CONCAT(markets.name," ") FROM markets INNER JOIN app_markets ON markets.id=app_markets.marketid WHERE app_markets.appid=apps.id) AS markets' . ' FROM ' . $this->table->_tbl . $ordering;
         $pagination =& Factory::getPagination();
         $pagination->pager($row->count, 20, 6);
         $this->db->setQuery($query, $pagination->limiStart, $pagination->pageRows);
         $rows = $this->db->LoadObjectList();
         $this->assign('pagination', $pagination);
         $this->assign('rows', $rows);
         $this->assign('orderDis', $orderDis);
         $this->assign('html', $html);
     } else {
         $this->assign('noRows', Text::_('No Data Found'));
     }
     $this->display('apps.tpl');
 }
示例#17
0
?>
</option>
            </select>
        </div>
        <div style="float:left;margin:5px;" id="hdate">
            <label for="hdate"><?php 
echo Text::_("Fecha del log");
?>
:</label><br />
            <?php 
echo new View('library/superform/view/element/datebox.html.php', array('value' => $date, 'id' => 'hdate', 'name' => 'date'));
?>
        </div>
        <div style="float:left;margin:5px;">
            <input type="submit" value="Ver" />
        </div>
    </form>
</div>

<?php 
if ($showlog) {
    echo '<strong>' . Text::_("archivo") . ':</strong> ' . $file . '<br /><br />';
}
if (!empty($content)) {
    echo nl2br($content);
} else {
    echo Text::_("No encontrado");
}
?>
<br /><br /><br />
示例#18
0
 public function save(&$errors = array())
 {
     if (!$this->validate($errors)) {
         return false;
     }
     $fields = array('id', 'name', 'description');
     $set = '';
     $values = array();
     foreach ($fields as $field) {
         if ($set != '') {
             $set .= ", ";
         }
         $set .= "`{$field}` = :{$field} ";
         $values[":{$field}"] = $this->{$field};
     }
     try {
         $sql = "REPLACE INTO category 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;
     }
 }
示例#19
0
文件: interest.php 项目: kenjs/Goteo
 /**
  * Quitar una palabra clave de un proyecto
  *
  * @param varchar(50) $user 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(':user' => $this->user, ':interest' => $this->id);
     try {
         self::query("DELETE FROM user_interest WHERE interest = :interest AND user = :user", $values);
         return true;
     } catch (\PDOException $e) {
         $errors[] = Text::_('No se ha podido quitar el interes ') . $this->id . Text::_(' del usuario ') . $this->user . ' ' . $e->getMessage();
         //Text::get('remove-interest-fail');
         return false;
     }
 }
示例#20
0
 /**
  * Checks required database tables for migration
  *
  * @param   array   $tables Array of database tables to search for
  * @return  boolean True if all tables are existent, false otherwise
  * @since   1.5.0
  */
 protected function checkTables($tables = array())
 {
     $displayData = new stdClass();
     $displayData->title = JText::_('COM_JOOMGALLERY_MIGMAN_DATABASETABLES');
     $ready = false;
     if (!$this->otherDatabase || is_null($this->_db2)) {
         $db = $this->_db;
     } else {
         $db = $this->_db2;
     }
     $displayData->checks = array();
     foreach ($tables as $table) {
         $check = array();
         try {
             $query = $db->getQuery(true)->select('COUNT(*)')->from($table);
             $db->setQuery($query);
             $count = $db->loadResult();
             if ($count == 0) {
                 $check['title'] = $table . ': <span style="color:#080; font-size:12px; font-weight:bold;">' . JText::_('COM_JOOMGALLERY_MIGMAN_EMPTY') . '</span>';
                 $check['state'] = true;
             } else {
                 $check['title'] = $table . ': <span style="color:#080; font-weight:bold;">' . $count . ' ' . JText::_('COM_JOOMGALLERY_MIGMAN_ROWS') . '</span>';
                 $check['state'] = true;
                 $ready = true;
             }
         } catch (Exception $e) {
             $check['title'] = $table . ': <span style="color:#f30; font-weight:bold;">' . $db->getErrorMsg() . '</span>';
             $check['state'] = false;
         }
         $displayData->checks[] = $check;
     }
     // Check JoomGallery tables
     $tables = array(_JOOM_TABLE_IMAGES, _JOOM_TABLE_CATEGORIES, _JOOM_TABLE_COMMENTS, _JOOM_TABLE_NAMESHIELDS, _JOOM_TABLE_USERS, _JOOM_TABLE_VOTES, _JOOM_TABLE_IMAGE_DETAILS, _JOOM_TABLE_CATEGORY_DETAILS);
     $prefix = $this->_mainframe->getCfg('dbprefix');
     foreach ($tables as $table) {
         $check = array();
         if ($table != _JOOM_TABLE_CATEGORIES) {
             $query = $this->_db->getQuery(true)->select('COUNT(*)')->from($this->_db->qn($table));
         } else {
             $query = $this->_db->getQuery(true)->select('COUNT(*)')->from($this->_db->qn(_JOOM_TABLE_CATEGORIES))->where('cid != 1');
         }
         $this->_db->setQuery($query);
         $count = $this->_db->loadResult();
         if (!is_null($count) && $count == 0) {
             $check['title'] = str_replace('#__', $prefix, $table) . ': <span style="color:#080; font-size:12px; font-weight:bold;">' . JText::_('COM_JOOMGALLERY_MIGMAN_EMPTY') . '</span>';
             $check['state'] = true;
         } else {
             $check['title'] = str_replace('#__', $prefix, $table) . ': <span style="color:#f30; font-weight:bold;">' . $count . ' ' . JText::_('COM_JOOMGALLERY_MIGMAN_ROWS') . '. ';
             $check['title'] .= JText::_('COM_JOOMGALLERY_MIGMAN_ONLY_IN_NEW_INSTALLATION') . '</span> ' . JText::_('COM_JOOMGALLERY_MIGMAN_PLEASE_REINSTALL');
             $check['state'] = false;
             $ready = false;
         }
         $displayData->checks[] = $check;
     }
     // Check whether ROOT category exists
     $check = array();
     $query = $this->_db->getQuery(true)->select('COUNT(*)')->from($this->_db->qn(_JOOM_TABLE_CATEGORIES))->where('cid = 1')->where('name = ' . $this->_db->q('ROOT'))->where('parent_id = 0');
     $this->_db->setQuery($query);
     if ($this->_db->loadResult()) {
         $check['title'] = JText::_('COM_JOOMGALLERY_MIGMAN_ROOT_CATEGORY_EXISTS');
         $check['state'] = true;
     } else {
         $check['title'] = '<span style="color:#f30; font-weight:bold;">' . JText::_('COM_JOOMGALLERY_MIGMAN_ROOT_CATEGORY_DOES_NOT_EXIST') . '</span> ' . JText::_('COM_JOOMGALLERY_MIGMAN_PLEASE_REINSTALL');
         $check['state'] = false;
         $ready = false;
     }
     $displayData->checks[] = $check;
     // Check whether ROOT asset exists
     $check = array();
     $query = $this->_db->getQuery(true)->select('COUNT(*)')->from($this->_db->qn('#__assets'))->where('name = ' . $this->_db->q(_JOOM_OPTION))->where('parent_id = 1');
     $this->_db->setQuery($query);
     if ($this->_db->loadResult()) {
         $check['title'] = JText::_('COM_JOOMGALLERY_MIGMAN_ROOT_ASSET_EXISTS');
         $check['state'] = true;
     } else {
         $check['title'] = '<span style="color:#f30; font-weight:bold;">' . Text::_('COM_JOOMGALLERY_MIGMAN_ROOT_ASSET_DOES_NOT_EXIST') . '</span> ' . JText::_('COM_JOOMGALLERY_MIGMAN_PLEASE_REINSTALL');
         $check['state'] = false;
         $ready = false;
     }
     $displayData->checks[] = $check;
     $layout = new JLayoutFile('joomgallery.migration.checksection', JPATH_COMPONENT . '/layouts');
     echo $layout->render($displayData);
     return $ready;
 }
示例#21
0
 function showRows()
 {
     $html =& Factory::getHtml();
     $order = @(!$_GET['order']) ? 'id' : $_GET['order'];
     $orderDis = isset($order) && strtolower($order) != 'ordering' ? 'disabled="true"' : '';
     $orderdir = @strtoupper($_GET['orderdir']) == 'DESC' ? 'DESC' : 'ASC';
     $ordering = ' ORDER BY ' . $order . ' ' . $orderdir;
     $query = 'SELECT count(*) AS count FROM ' . $this->table->_tbl;
     $this->db->setQuery($query);
     $row = $this->db->LoadObject();
     if ($row->count > 0) {
         $query = 'SELECT fields.id, fields.name, fields.ordering,fields.tabid,tabs.name AS tab' . ' FROM ' . $this->table->_tbl . ' LEFT JOIN tabs ON fields.tabid=tabs.id' . $ordering;
         $pagination =& Factory::getPagination();
         $pagination->pager($row->count, 20, 6);
         $this->db->setQuery($query, $pagination->limiStart, $pagination->pageRows);
         $rows = $this->db->LoadObjectList();
         $this->assign('pagination', $pagination);
         $this->assign('rows', $rows);
         $this->assign('orderDis', $orderDis);
         $this->assign('html', $html);
     } else {
         $this->assign('noRows', Text::_('No Data Now'));
     }
     $this->display('fields.tpl');
 }
示例#22
0
文件: daily.php 项目: kenjs/Goteo
 /**
  * Control diario de convocatorias
  * @param bool $debug
  */
 public static function Calls($debug = false)
 {
     // convocatorias con aplicación abierta
     $calls = Model\Call::getActive(3);
     foreach ($calls as $call) {
         // a ver cuantos días le quedan para que acabe la convocatoria
         $open = strtotime($call->opened);
         $until = mktime(0, 0, 0, date('m', $open), date('d', $open) + $call->days, date('Y', $open));
         $now = strtotime(date('Y-m-d'));
         $diference = $until - $now;
         $days = \round($diference / 24 / 60 / 60);
         $doFeed = false;
         switch ($days) {
             case 7:
                 $log_text = Text::_('Falta una semana para que acabe la convocatoria %s');
                 $log_text_public = 'Falta una semana para que se cierre la aplicación de proyectos';
                 $doFeed = true;
                 break;
             case 3:
                 $log_text = Text::_('Faltan 3 dias para que acabe la convocatoria %s');
                 $log_text_public = 'Faltan 3 dias para que se cierre la aplicación de proyectos';
                 $doFeed = true;
                 break;
             case 1:
                 $log_text = Text::_('Ultimo día para la convocatoria %s');
                 $log_text_public = 'Hoy es el último día para aplicar proyectos!';
                 $doFeed = true;
                 break;
         }
         // feed
         if ($doFeed) {
             $log = new Feed();
             $log->setTarget($call->id, 'call');
             $log->unique = true;
             $log->populate('Convocatoria terminando (cron)', '/admin/calls/' . $call->id . '?days=' . $days, \vsprintf($log_text, array(Feed::item('call', $call->name, $call->id))));
             $log->doAdmin('call');
             $log->populate('Convocatoria: ' . $call->name, '/call/' . $call->id . '?days=' . $days, $log_text_public, $call->logo);
             $log->doPublic('projects');
             unset($log);
             echo \vsprintf($log_text, array($call->name)) . '<br />';
         }
     }
     // campañas dando dinero
     $campaigns = Model\Call::getActive(4);
     foreach ($campaigns as $campaign) {
         $errors = array();
         // tiene que tener presupuesto
         if (empty($campaign->amount)) {
             continue;
         }
         // a ver cuanto le queda de capital riego
         $rest = $campaign->rest;
         $doFeed = false;
         if ($rest < 100) {
             $amount = 100;
             $doFeed = true;
         } elseif ($rest < 500) {
             $amount = 500;
             $doFeed = true;
         } elseif ($rest < 1000) {
             $amount = 1000;
             $doFeed = true;
         }
         // feed
         if ($doFeed) {
             $log = new Feed();
             $log->setTarget($campaign->id, 'call');
             $log->unique = true;
             $log->populate('Campaña terminando (cron)', '/admin/calls/' . $campaign->id . '?rest=' . $amount, \vsprintf('Quedan menos de %s en la campaña %s', array(Feed::item('money', $amount . ' &yen;') . ' de ' . Feed::item('drop', 'Capital Riego', '/service/resources'), Feed::item('call', $campaign->name, $campaign->id))));
             $log->doAdmin('call');
             $log->populate($campaign->name, '/call/' . $campaign->id . '?rest=' . $amount, \vsprintf('Quedan menos de %s en la campaña %s', array(Feed::item('money', $amount . ' &yen;') . ' de ' . Feed::item('drop', 'Capital Riego', '/service/resources'), Feed::item('call', $campaign->name, $campaign->id))), $call->logo);
             $log->doPublic('projects');
             unset($log);
         }
     }
     if ($debug) {
         echo "<br />Calls-control Listo!<hr />";
     }
     return;
 }
示例#23
0
 public static function close($id, &$errors = array())
 {
     try {
         $values = array(':review' => $id);
         $sql = "UPDATE review SET status = 0 WHERE id = :review";
         self::query($sql, $values);
         return true;
     } catch (\PDOException $e) {
         $errors[] = Text::_("No se ha guardado correctamente. ") . $e->getMessage();
         return false;
     }
 }
示例#24
0
 public function save(&$errors = array())
 {
     if (!$this->validate($errors)) {
         return false;
     }
     $fields = array('id', 'name', 'description', 'url', 'group', 'order');
     $set = '';
     $values = array();
     foreach ($fields as $field) {
         if ($set != '') {
             $set .= ", ";
         }
         $set .= "`{$field}` = :{$field} ";
         $values[":{$field}"] = $this->{$field};
     }
     try {
         $sql = "REPLACE INTO license SET " . $set;
         self::query($sql, $values);
         if (empty($this->id)) {
             $this->id = self::insertId();
         }
         // y los iconos con los que está relacionada
         self::query("DELETE FROM icon_license WHERE license = ?", array($this->id));
         foreach ($this->icons as $icon) {
             self::query("INSERT INTO icon_license SET icon = :icon, license = :license", array(':icon' => $icon, ':license' => $this->id));
         }
         return true;
     } catch (\PDOException $e) {
         $errors[] = Text::_("No se ha guardado correctamente. ") . $e->getMessage();
         return false;
     }
 }
示例#25
0
 function showRows()
 {
     $order = !$_GET['order'] ? 'id' : $_GET['order'];
     $orderdir = strtoupper($_GET['orderdir']) == 'DESC' ? 'DESC' : 'ASC';
     $ordering = ' ORDER BY ' . $order . ' ' . $orderdir;
     $_GET['date'] = empty($_GET['date']) ? date('Y-m-d') : $_GET['date'];
     $where = '';
     if (!$this->user->admin) {
         if (!empty($this->user->permissions['groups'])) {
             $where[] = 'EXISTS (SELECT app_groups.appid FROM app_groups WHERE app_groups.groupid IN (' . implode(',', $this->user->permissions['groups']) . ')' . ' AND sales.appid=app_groups.appid)';
         } else {
             $where[] = '0';
         }
         if (!empty($this->user->permissions['markets'])) {
             $where[] = 'EXISTS (SELECT app_markets.appid FROM app_markets WHERE app_markets.marketid IN (' . implode(',', $this->user->permissions['markets']) . ')' . ' AND sales.appid=app_markets.appid)';
         } else {
             $where[] = '0';
         }
     }
     $where[] = 'UNIX_TIMESTAMP(sales.`date`)=UNIX_TIMESTAMP(' . $this->db->getEscaped($_GET['date']) . ')';
     if (!empty($where)) {
         $where = ' WHERE ' . implode(' AND ', $where);
     }
     $query = 'SELECT sales.*,apps.name AS app FROM sales LEFT JOIN apps ON sales.appid=apps.id' . $where . $ordering;
     $this->db->setQuery($query);
     $rows = $this->db->LoadObjectList();
     if (count($rows) > 0) {
         $this->assign('rows', $rows);
     } else {
         $this->assign('noRows', Text::_('No Data Found'));
     }
     $this->display('sales.tpl');
 }