本文整理汇总了PHP中Goteo\Model\Project类的典型用法代码示例。如果您正苦于以下问题:PHP Project类的具体用法?PHP Project怎么用?PHP Project使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: project
public function project($id)
{
$project = Project::getMedium($id, LANG);
if (!$project instanceof Project) {
throw new Redirection('/', Redirection::TEMPORARY);
}
return new View('view/widget/project.html.php', array('project' => $project, 'global' => true));
throw new Redirection('/fail', Redirection::TEMPORARY);
}
示例2: index
public function index()
{
if (isset($_GET['error'])) {
throw new \Goteo\Core\Error('418', Text::html('fatal-error-teapot'));
}
// orden de los elementos en portada
$order = Home::getAll();
// si estamos en easy mode, quitamos el feed
if (defined('GOTEO_EASY') && \GOTEO_EASY === true && isset($order['feed'])) {
unset($order['feed']);
}
// entradas de blog
if (isset($order['posts'])) {
// entradas en portada
$posts = Post::getAll();
}
// Proyectos destacados
if (isset($order['promotes'])) {
$promotes = Promote::getAll(true);
foreach ($promotes as $key => &$promo) {
try {
$promo->projectData = Project::getMedium($promo->project, LANG);
} catch (\Goteo\Core\Error $e) {
unset($promotes[$key]);
}
}
}
// actividad reciente
if (isset($order['feed'])) {
$feed = array();
$feed['goteo'] = Feed::getAll('goteo', 'public', 15);
$feed['projects'] = Feed::getAll('projects', 'public', 15);
$feed['community'] = Feed::getAll('community', 'public', 15);
}
// Banners siempre
/* $banners = Banner::getAll(true);
foreach ($banners as $id => &$banner) {
if (!empty($banner->project)) {
try {
$banner->project = Project::get($banner->project, LANG);
} catch (\Goteo\Core\Error $e) {
unset($banners[$id]);
}
}
}*/
$template = VIEW_PATH . '/index.html.php';
return new View($template, array('banners' => $banners, 'posts' => $posts, 'promotes' => $promotes, 'order' => $order));
}
示例3: getAll
public static function getAll($activeonly = false, $node = \GOTEO_NODE)
{
// estados
$status = Project::status();
$banners = array();
$sqlFilter = $activeonly ? " AND banner.active = 1" : '';
$query = static::query("\n SELECT\n banner.id as id,\n banner.node as node,\n banner.project as project,\n project.name as name,\n IFNULL(banner_lang.title, banner.title) as title,\n IFNULL(banner_lang.description, banner.description) as description,\n banner.url as url,\n project.status as status,\n banner.image as image,\n banner.order as `order`,\n banner.active as `active`\n FROM banner\n LEFT JOIN project\n ON project.id = banner.project\n LEFT JOIN banner_lang\n ON banner_lang.id = banner.id\n AND banner_lang.lang = :lang\n WHERE banner.node = :node\n {$sqlFilter}\n ORDER BY `order` ASC\n ", array(':node' => $node, ':lang' => \LANG));
foreach ($query->fetchAll(\PDO::FETCH_CLASS, __CLASS__) as $banner) {
$banner->image = !empty($banner->image) ? Image::get($banner->image) : null;
$banner->status = $status[$banner->status];
$banners[] = $banner;
}
return $banners;
}
示例4: getAll
public static function getAll($activeonly = false, $node = \GOTEO_NODE)
{
// estados
$status = Project::status();
$promos = array();
$sqlFilter = $activeonly ? " AND promote.active = 1" : '';
$query = static::query("\n SELECT\n promote.id as id,\n promote.project as project,\n project.name as name,\n project.status as status,\n IFNULL(promote_lang.title, promote.title) as title,\n IFNULL(promote_lang.description, promote.description) as description,\n promote.order as `order`,\n promote.active as `active`\n FROM promote\n LEFT JOIN promote_lang\n ON promote_lang.id = promote.id\n AND promote_lang.lang = :lang\n INNER JOIN project\n ON project.id = promote.project\n WHERE promote.node = :node\n {$sqlFilter}\n ORDER BY `order` ASC, title ASC\n ", array(':node' => $node, ':lang' => \LANG));
foreach ($query->fetchAll(\PDO::FETCH_CLASS, __CLASS__) as $promo) {
$promo->description = Text::recorta($promo->description, 100, false);
$promo->status = $status[$promo->status];
$promos[] = $promo;
}
return $promos;
}
示例5: projList
public static function projList($user)
{
$lists = array();
// mis proyectos
$projects = Model\Project::ofmine($user->id);
if (!empty($projects)) {
$lists['my_projects'] = Listing::get($projects);
}
// proyectos que cofinancio
$invested = Model\User::invested($user->id, false);
if (!empty($invested)) {
$lists['invest_on'] = Listing::get($invested);
}
return $lists;
}
示例6: getAll
public static function getAll($position = 'home', $node = \GOTEO_NODE)
{
if (!in_array($position, array('home', 'footer'))) {
$position = 'home';
}
$list = array();
$values = array(':lang' => \LANG);
if ($node == \GOTEO_NODE || empty($node)) {
// portada goteo, sacamos todas las de blogs tipo nodo
// que esten marcadas en la tabla post
$sqlFilter = " WHERE post.{$position} = 1\n AND post.publish = 1\n ";
$sqlField = "post.order as `order`,";
} else {
// portada nodo, igualmente las entradas de blogs tipo nodo
// perosolo la que esten en la tabla de entradas en portada de ese nodo
$sqlFilter = " WHERE post.id IN (SELECT post FROM post_node WHERE node = :node)\n AND post.publish = 1\n ";
$values[':node'] = $node;
$sqlField = "(SELECT `order` FROM post_node WHERE node = :node AND post = post.id) as `order`,";
}
$sql = "\n SELECT\n post.id as id,\n post.blog as blog,\n IFNULL(post_lang.title, post.title) as title,\n IFNULL(post_lang.text, post.text) as `text`,\n post.image as `image`,\n post.media as `media`,\n {$sqlField}\n DATE_FORMAT(post.date, '%d-%m-%Y') as date,\n DATE_FORMAT(post.date, '%d | %m | %Y') as fecha,\n post.publish as publish,\n post.author as author,\n post.home as home,\n post.footer as footer,\n blog.type as owner_type,\n blog.owner as owner_id\n FROM post\n INNER JOIN blog\n ON blog.id = post.blog\n LEFT JOIN post_lang\n ON post_lang.id = post.id\n AND post_lang.lang = :lang\n {$sqlFilter}\n ORDER BY `order` ASC, title ASC\n ";
$query = static::query($sql, $values);
foreach ($query->fetchAll(\PDO::FETCH_CLASS, __CLASS__) as $post) {
// galeria
$post->gallery = Image::getAll($post->id, 'post');
$post->image = $post->gallery[0];
$post->media = new Media($post->media);
$post->type = $post->home == 1 ? 'home' : 'footer';
// datos del autor
switch ($post->owner_type) {
case 'project':
$proj_blog = Project::getMini($post->owner_id);
$post->author = $proj_blog->owner;
$post->user = $proj_blog->user;
$post->owner_name = $proj_blog->name;
$sql = "UPDATE post SET author = '.{$proj_blog->owner}.' WHERE post.id = ?";
self::query($sql, array($post->id));
break;
case 'node':
$post->user = User::getMini($post->author);
// (Nodesys)
break;
}
$list[$post->id] = $post;
}
return $list;
}
示例7: process
public static function process($action = 'list', $id = null, $filters = array())
{
$node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE;
// métodos de pago
$methods = Model\Invest::methods();
// estados del proyecto
$status = Model\Project::status();
// estados de aporte
$investStatus = Model\Invest::status();
// listado de proyectos
$projects = Model\Invest::projects(false, $node);
// usuarios cofinanciadores
$users = Model\Invest::users(true);
// campañas que tienen aportes
$calls = Model\Invest::calls();
// extras
$types = array('donative' => 'Solo los donativos', 'anonymous' => 'Solo los anónimos', 'manual' => 'Solo los manuales', 'campaign' => 'Solo con riego');
// detalles del aporte
if ($action == 'details') {
$invest = Model\Invest::get($id);
$project = Model\Project::get($invest->project);
$userData = Model\User::get($invest->user);
if (!empty($invest->droped)) {
$droped = Model\Invest::get($invest->droped);
} else {
$droped = null;
}
if ($project->node != $node) {
throw new Redirection('/admin/invests');
}
return new View('view/admin/index.html.php', array('folder' => 'invests', 'file' => 'details', 'invest' => $invest, 'project' => $project, 'user' => $userData, 'status' => $status, 'investStatus' => $investStatus, 'droped' => $droped, 'calls' => $calls));
}
// listado de aportes
if ($filters['filtered'] == 'yes') {
if (!empty($filters['calls'])) {
$filters['types'] = '';
}
$list = Model\Invest::getList($filters, $node, 999);
} else {
$list = array();
}
$viewData = array('folder' => 'invests', 'file' => 'list', 'list' => $list, 'filters' => $filters, 'projects' => $projects, 'users' => $users, 'calls' => $calls, 'methods' => $methods, 'types' => $types, 'investStatus' => $investStatus);
return new View('view/admin/index.html.php', $viewData);
}
示例8: verifyProject
/**
* Verificación de proyecto de trabajo
*
* @param object $user instancia Model\User del convocador
* @param string $action por si es 'select'
* @return array(project, projects)
*/
public static function verifyProject($user, $action)
{
$projects = Model\Project::ofmine($user->id);
// sus proyectos
// si no tiene, no debería estar aquí
if (empty($projects) || !is_array($projects)) {
return array(null, null);
}
// comprobamos que tenga los permisos para editar y borrar
foreach ($projects as $proj) {
// comprueba que puede editar sus proyectos
if (!ACL::check('/project/edit/' . $proj->id)) {
ACL::allow('/project/edit/' . $proj->id . '/', '*', 'user', $user);
}
// y borrarlos
if (!ACL::check('/project/delete/' . $proj->id)) {
ACL::allow('/project/delete/' . $proj->id . '/', '*', 'user', $user);
}
}
// si está seleccionando otro proyecto
if ($action == 'select' && !empty($_POST['project'])) {
$project = Model\Project::get($_POST['project']);
} elseif (!empty($_SESSION['project']->id)) {
// mantener los datos del proyecto de trabajo
$project = Model\Project::get($_SESSION['project']->id);
}
// si aun no tiene proyecto de trabajo, coge el primero
if (empty($project)) {
$project = $projects[0];
}
// tiene que volver con un proyecto de trabajo
if ($project instanceof \Goteo\Model\Project) {
$_SESSION['project'] = $project;
// lo guardamos en sesión para la próxima verificación
} else {
Message::Error('No se puede trabajar con el proyecto seleccionado, contacta con nosotros');
$project = null;
}
// devolvemos lista de proyectos y proyecto de trabajo
return array($project, $projects);
}
示例9: __construct
/**
*
* @param type mixed $id Identificador
* @return type object Objeto
*/
public function __construct($id, $all_avatars = true, $with_title = true)
{
if ($this->project = Project::get($id)) {
$this->show_title = $with_title;
$this->investors = $this->project->agregateInvestors();
$avatars = array();
foreach ($this->investors as $i) {
if ($i->avatar->id != 1 || $all_avatars) {
$avatars[$i->user] = $i->amount;
}
}
$this->avatars = self::pondera($avatars, $this->max_multiplier);
//arsort($this->avatars);
$keys = array_keys($this->avatars);
shuffle($keys);
$this->avatars = array_merge(array_flip($keys), $this->avatars);
//print_r($this->project);die;
} else {
return false;
}
}
示例10: getList
/**
* Metodo para sacar las que hay en proyectos
* @return array strings
*/
public static function getList()
{
$results = array();
// $sql = "SELECT distinct(project_location) as location
// FROM project
// WHERE status > 2
// ORDER BY location ASC";
//
// try {
// $query = Model::query($sql);
// foreach ($query->fetchAll(\PDO::FETCH_CLASS) as $item) {
// $results[md5($item->location)] = $item->location;
// }
// return $results;
// } catch (\PDOException $e) {
// throw new Exception('Fallo la lista de localizaciones');
// }
$_locations = Project::yokohamaLocation();
foreach ($_locations as $_area) {
$results[md5($_area)] = $_area;
}
return $results;
}
示例11: pay
public static function pay($invest, &$errors = array())
{
if (\GOTEO_FREE) {
$errors[] = Text::_('Bank not implemented. Contact us for development services or make it work somehow');
return false;
}
try {
$project = Project::getMini($invest->project);
// preparo codigo y cantidad
$token = $invest->id . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9);
$amount = $invest->amount * 100;
// Guardar el codigo de preaproval en el registro de aporte (para confirmar o cancelar)
$invest->setPreapproval($token);
// mandarlo al tpv
$urlTPV = TPV_REDIRECT_URL;
$data = '';
$MsgStr = '';
foreach ($datos as $n => $v) {
$data .= '<input name="' . $n . '" type="hidden" value="' . $v . '" />';
$MsgStr .= "{$n}:'{$v}'; ";
}
$conf = array('mode' => 0600, 'timeFormat' => '%X %x');
$logger =& \Log::singleton('file', 'logs/' . date('Ymd') . '_invest.log', 'caller', $conf);
$logger->log('##### TPV [' . $invest->id . '] ' . date('d/m/Y') . ' User:' . $_SESSION['user']->id . '#####');
$logger->log("Charge request: {$MsgStr}");
$logger->close();
Invest::setDetail($invest->id, 'tpv-conection', 'Ha iniciado la comunicacion con el tpv, operacion numero ' . $token . '. Proceso libary/tpv::pay');
echo '<html><head><title>Goteo.org</title></head><body><form action="' . $urlTPV . '" method="post" id="form_tpv" enctype="application/x-www-form-urlencoded">' . $data . '</form><script type="text/javascript">document.getElementById("form_tpv").submit();</script></body></html>';
return true;
} catch (Exception $ex) {
Invest::setDetail($invest->id, 'tpv-conection-fail', 'Ha fallado la comunicacion con el tpv. Proceso libary/tpv::pay');
$errors[] = Text::_('Error fatal en la comunicacion con el TPV, se ha reportado la incidencia. Disculpe las molestias.');
@mail(\GOTEO_FAIL_MAIL, 'Error fatal en comunicacion TPV Sermepa', 'ERROR en ' . __FUNCTION__ . '<br />' . $ex->getMessage());
return false;
}
}
示例12: getMesseged
public static function getMesseged($user, $publicOnly = true)
{
$projects = array();
$sql = "SELECT project.id\n FROM project\n INNER JOIN message\n ON project.id = message.project\n AND message.user = ?\n WHERE project.status < 7\n ";
if ($publicOnly) {
$sql .= "AND project.status >= 3\n ";
}
$sql .= "GROUP BY project.id\n ORDER BY name ASC\n ";
$query = self::query($sql, array($user));
foreach ($query->fetchAll(\PDO::FETCH_CLASS) as $proj) {
$projects[] = \Goteo\Model\Project::getMedium($proj->id);
}
return $projects;
}
示例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: invested
public static function invested($user, $publicOnly = true)
{
$projects = array();
$sql = "SELECT project.id\r\n FROM project\r\n INNER JOIN invest\r\n ON project.id = invest.project\r\n AND invest.user = ?\r\n AND invest.status IN ('0', '1', '3', '4')\r\n WHERE project.status < 7\r\n ";
if ($publicOnly) {
$sql .= "AND project.status >= 3\r\n ";
}
$sql .= "GROUP BY project.id\r\n ORDER BY name ASC\r\n ";
/*
* Restriccion de que no aparecen los que cofinancio que esten en edicion
* solamente no sacamos los caducados
* project.status > 1 AND
*/
$query = self::query($sql, array($user));
foreach ($query->fetchAll(\PDO::FETCH_CLASS) as $proj) {
$projects[] = \Goteo\Model\Project::getMedium($proj->id);
}
return $projects;
}
示例15: isset
* Goteo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Goteo. If not, see <http://www.gnu.org/licenses/agpl.txt>.
*
*/
use Goteo\Library\Text, Goteo\Model;
$promo = $this['promo'];
$node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE;
// proyectos disponibles
// si tenemos ya proyecto seleccionado lo incluimos
$projects = Model\Promote::available($promo->project, $node);
$status = Model\Project::status();
?>
<form method="post" action="/admin/promote">
<input type="hidden" name="action" value="<?php
echo $this['action'];
?>
" />
<input type="hidden" name="order" value="<?php
echo $promo->order;
?>
" />
<input type="hidden" name="id" value="<?php
echo $promo->id;
?>
" />