mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
move controllers
This commit is contained in:
73
lib/Alchemy/Phrasea/Controller/Admin/Fields.php
Normal file
73
lib/Alchemy/Phrasea/Controller/Admin/Fields.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ControllerProviderInterface;
|
||||||
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class Fields implements ControllerProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function connect(Application $app)
|
||||||
|
{
|
||||||
|
$appbox = \appbox::get_instance();
|
||||||
|
$session = $appbox->get_session();
|
||||||
|
// $session->close_storage();
|
||||||
|
|
||||||
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->get('/checkmulti/', function() use ($app, $appbox)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$multi = ($request->get('multi') === 'true');
|
||||||
|
|
||||||
|
$metadata = \databox_field::load_class_from_xpath($request->get('source'));
|
||||||
|
|
||||||
|
$datas = array(
|
||||||
|
'result' => ($multi === $metadata->is_multi())
|
||||||
|
, 'is_multi' => $metadata->is_multi()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Response(\p4string::jsonencode($datas));
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/checkreadonly/', function() use ($app, $appbox)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$readonly = ($request->get('readonly') === 'true');
|
||||||
|
|
||||||
|
$metadata = \databox_field::load_class_from_xpath($request->get('source'));
|
||||||
|
|
||||||
|
$datas = array(
|
||||||
|
'result' => ($readonly === $metadata->is_readonly())
|
||||||
|
, 'is_readonly' => $metadata->is_readonly()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Response(\p4string::jsonencode($datas));
|
||||||
|
});
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
201
lib/Alchemy/Phrasea/Controller/Admin/Publications.php
Normal file
201
lib/Alchemy/Phrasea/Controller/Admin/Publications.php
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ControllerProviderInterface;
|
||||||
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class Publications implements ControllerProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function connect(Application $app)
|
||||||
|
{
|
||||||
|
$appbox = \appbox::get_instance();
|
||||||
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
|
$controllers->get('/list/', function() use ($app, $appbox)
|
||||||
|
{
|
||||||
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||||
|
|
||||||
|
$template = 'admin/publications/list.html';
|
||||||
|
|
||||||
|
$twig = new \supertwig();
|
||||||
|
$twig->addFilter(array('formatdate' => 'phraseadate::getDate'));
|
||||||
|
|
||||||
|
return $twig->render($template, array('feeds' => $feeds));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->post('/create/', function() use ($app, $appbox)
|
||||||
|
{
|
||||||
|
|
||||||
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
$feed = \Feed_Adapter::create($appbox, $user, $request->get('title'), $request->get('subtitle'));
|
||||||
|
|
||||||
|
if($request->get('public') == '1')
|
||||||
|
$feed->set_public (true);
|
||||||
|
elseif ($request->get('base_id'))
|
||||||
|
$feed->set_collection(\collection::get_from_base_id($request->get('base_id')));
|
||||||
|
|
||||||
|
return $app->redirect('/admin/publications/list/');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->get('/feed/{id}/', function($id) use ($app, $appbox)
|
||||||
|
{
|
||||||
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
|
|
||||||
|
$template = 'admin/publications/fiche.html';
|
||||||
|
|
||||||
|
$twig = new \supertwig();
|
||||||
|
$twig->addFilter(
|
||||||
|
array(
|
||||||
|
'formatdate' => 'phraseadate::getDate'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $twig->render($template
|
||||||
|
, array(
|
||||||
|
'feed' => $feed
|
||||||
|
, 'error' => $app['request']->get('error')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->post('/feed/{id}/update/', function($id) use ($app, $appbox)
|
||||||
|
{
|
||||||
|
|
||||||
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
|
||||||
|
if (!$feed->is_owner($user))
|
||||||
|
return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
|
||||||
|
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$collection = \collection::get_from_base_id($request->get('base_id'));
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$collection = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$feed->set_title($request->get('title'));
|
||||||
|
$feed->set_subtitle($request->get('subtitle'));
|
||||||
|
$feed->set_collection($collection);
|
||||||
|
$feed->set_public($request->get('public'));
|
||||||
|
|
||||||
|
return $app->redirect('/admin/publications/list/');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->post('/feed/{id}/iconupload/', function($id) use ($app, $appbox)
|
||||||
|
{
|
||||||
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
|
||||||
|
if (!$feed->is_owner($user))
|
||||||
|
return new Response('ERROR:you are not allowed');
|
||||||
|
|
||||||
|
if ($_FILES['Filedata']['error'] !== 0)
|
||||||
|
return new Response('ERROR:error while upload');
|
||||||
|
|
||||||
|
$file = new \system_file($_FILES['Filedata']['tmp_name']);
|
||||||
|
if (!in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif')))
|
||||||
|
return new Response('ERROR:bad filetype');
|
||||||
|
|
||||||
|
if ($file->getSize() > 200000)
|
||||||
|
return new Response('ERROR:file too large');
|
||||||
|
|
||||||
|
$datas = $file->get_technical_datas();
|
||||||
|
if (!isset($datas[\system_file::TC_DATAS_WIDTH]) || !isset($datas[\system_file::TC_DATAS_HEIGHT]))
|
||||||
|
return new Response('ERROR:file is not square');
|
||||||
|
|
||||||
|
if ($datas[\system_file::TC_DATAS_WIDTH] != $datas[\system_file::TC_DATAS_HEIGHT])
|
||||||
|
return new Response('ERROR:file is not square');
|
||||||
|
|
||||||
|
$feed->set_icon($file);
|
||||||
|
unlink($file->getPathname());
|
||||||
|
|
||||||
|
return new Response('FILEHREF:' . $feed->get_icon_url() . '?' . mt_rand(100000, 999999));
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->post('/feed/{id}/addpublisher/', function($id) use ($app, $appbox)
|
||||||
|
{
|
||||||
|
$error = '';
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$user = \User_Adapter::getInstance($request->get('usr_id'), $appbox);
|
||||||
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
|
$feed->add_publisher($user);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$error = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $app->redirect('/admin/publications/feed/' . $id . '/');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->post('/feed/{id}/removepublisher/', function($id) use ($app, $appbox)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
|
$publisher = new \Feed_Publisher_Adapter($appbox, $request->get('publisher_id'));
|
||||||
|
$user = $publisher->get_user();
|
||||||
|
if ($feed->is_publisher($user) === true && $feed->is_owner($user) === false)
|
||||||
|
$publisher->delete();
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$error = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $app->redirect('/admin/publications/feed/' . $id . '/?err=' . $error);
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->post('/feed/{id}/delete/', function($id) use ($app, $appbox)
|
||||||
|
{
|
||||||
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
|
$feed->delete();
|
||||||
|
|
||||||
|
return $app->redirect('/admin/publications/list/');
|
||||||
|
})->assert('id', '\d+');
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
142
lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php
Normal file
142
lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class Subdefs
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var databox
|
||||||
|
*/
|
||||||
|
protected $databox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param http_request $request
|
||||||
|
* @param databox $databox
|
||||||
|
* @return controller_admin_subdefs
|
||||||
|
*/
|
||||||
|
public function __construct(\http_request $request, \databox &$databox)
|
||||||
|
{
|
||||||
|
$this->databox = $databox;
|
||||||
|
if ($request->has_post_datas())
|
||||||
|
{
|
||||||
|
$parm = $request->get_parms('delete_subdef', 'add_subdef', 'subdefs');
|
||||||
|
|
||||||
|
$add_subdef = array('class' => null, 'name' => null, 'group' => null);
|
||||||
|
foreach ($add_subdef as $k => $v)
|
||||||
|
{
|
||||||
|
if (!isset($parm['add_subdef'][$k]) || trim($parm['add_subdef'][$k]) === '')
|
||||||
|
unset($add_subdef[$k]);
|
||||||
|
else
|
||||||
|
$add_subdef[$k] = $parm['add_subdef'][$k];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($parm['delete_subdef'])
|
||||||
|
{
|
||||||
|
$delete_subef = explode('_', $parm['delete_subdef']);
|
||||||
|
$group = $delete_subef[0];
|
||||||
|
$name = $delete_subef[1];
|
||||||
|
|
||||||
|
$subdefs = $this->databox->get_subdef_structure();
|
||||||
|
$subdefs->delete_subdef($group, $name);
|
||||||
|
}
|
||||||
|
elseif (count($add_subdef) === 3)
|
||||||
|
{
|
||||||
|
$subdefs = $this->databox->get_subdef_structure();
|
||||||
|
|
||||||
|
$group = $add_subdef['group'];
|
||||||
|
$name = $add_subdef['name'];
|
||||||
|
$class = $add_subdef['class'];
|
||||||
|
|
||||||
|
$subdefs->add_subdef($group, $name, $class);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$subdefs = $this->databox->get_subdef_structure();
|
||||||
|
|
||||||
|
$options = array();
|
||||||
|
|
||||||
|
foreach ($parm['subdefs'] as $post_sub)
|
||||||
|
{
|
||||||
|
$post_sub_ex = explode('_', $post_sub);
|
||||||
|
$group = $post_sub_ex[0];
|
||||||
|
$name = $post_sub_ex[1];
|
||||||
|
|
||||||
|
$parm_loc = $request->get_parms($post_sub . '_class', $post_sub . '_downloadable');
|
||||||
|
|
||||||
|
$class = $parm_loc[$post_sub . '_class'];
|
||||||
|
$downloadable = $parm_loc[$post_sub . '_downloadable'];
|
||||||
|
|
||||||
|
$defaults = array('path', 'baseurl', 'meta', 'mediatype');
|
||||||
|
foreach ($defaults as $def)
|
||||||
|
{
|
||||||
|
$parm_loc = $request->get_parms($post_sub . '_' . $def);
|
||||||
|
|
||||||
|
if ($def == 'meta' && !$parm_loc[$post_sub . '_' . $def])
|
||||||
|
{
|
||||||
|
$parm_loc[$post_sub . '_' . $def] = "no";
|
||||||
|
}
|
||||||
|
|
||||||
|
$options[$def] = $parm_loc[$post_sub . '_' . $def];
|
||||||
|
}
|
||||||
|
|
||||||
|
$parm_loc = $request->get_parms($post_sub . '_mediatype');
|
||||||
|
$mediatype = $parm_loc[$post_sub . '_mediatype'];
|
||||||
|
$parm_loc = $request->get_parms($post_sub . '_' . $mediatype);
|
||||||
|
|
||||||
|
if (isset($parm_loc[$post_sub . '_' . $mediatype]))
|
||||||
|
{
|
||||||
|
foreach ($parm_loc[$post_sub . '_' . $mediatype] as $option => $value)
|
||||||
|
{
|
||||||
|
if ($option == 'resolution' && $mediatype == 'image')
|
||||||
|
$option = 'dpi';
|
||||||
|
$options[$option] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$subdefs->set_subdef($group, $name, $class, $downloadable, $options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return \phrasea::redirect('/admin/subdefs.php?p0=' . $databox->get_sbas_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return controller_admin_subdefs
|
||||||
|
*/
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
|
||||||
|
$twig = new supertwig();
|
||||||
|
$twig->display(
|
||||||
|
'admin/subdefs.twig',
|
||||||
|
array(
|
||||||
|
'databox' => $this->databox,
|
||||||
|
'subdefs' => $this->databox->get_subdef_structure()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
371
lib/Alchemy/Phrasea/Controller/Admin/Users.php
Normal file
371
lib/Alchemy/Phrasea/Controller/Admin/Users.php
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ControllerProviderInterface;
|
||||||
|
use Silex\ControllerCollection;
|
||||||
|
use Alchemy\Phrasea\RequestHandler\User as RequestHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class Users implements ControllerProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function connect(Application $app)
|
||||||
|
{
|
||||||
|
$appbox = \appbox::get_instance();
|
||||||
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->post('/rights/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
|
||||||
|
$template = 'admin/editusers.twig';
|
||||||
|
$twig = new \supertwig();
|
||||||
|
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
||||||
|
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
||||||
|
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
||||||
|
$twig->addFilter(array('geoname_name_from_id' => 'geonames::name_from_id'));
|
||||||
|
|
||||||
|
return $twig->render($template, $rights->get_users_rights());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->get('/rights/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
|
||||||
|
$template = 'admin/editusers.twig';
|
||||||
|
$twig = new \supertwig();
|
||||||
|
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
||||||
|
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
||||||
|
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
||||||
|
$twig->addFilter(array('geoname_name_from_id' => 'geonames::name_from_id'));
|
||||||
|
|
||||||
|
return $twig->render($template, $rights->get_users_rights());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->post('/delete/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$module = new RequestHandler\Edit($request);
|
||||||
|
$module->delete_users();
|
||||||
|
|
||||||
|
return $app->redirect('/admin/users/search/');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->post('/rights/apply/', function() use ($app)
|
||||||
|
{
|
||||||
|
$datas = array('error' => true);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
$rights->apply_rights();
|
||||||
|
$rights->apply_infos();
|
||||||
|
|
||||||
|
$datas = array('error' => false);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$datas['message'] = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
\p4string::jsonencode($datas)
|
||||||
|
, 200
|
||||||
|
, array('Content-Type' => 'application/json')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->post('/rights/quotas/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
|
||||||
|
$template = 'admin/editusers_quotas.twig';
|
||||||
|
$twig = new \supertwig();
|
||||||
|
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
||||||
|
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
||||||
|
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
||||||
|
|
||||||
|
return $twig->render($template, $rights->get_quotas());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->post('/rights/quotas/apply/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
$rights->apply_quotas();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->post('/rights/time/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
|
||||||
|
$template = 'admin/editusers_timelimit.twig';
|
||||||
|
$twig = new \supertwig();
|
||||||
|
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
||||||
|
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
||||||
|
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
||||||
|
|
||||||
|
return $twig->render($template, $rights->get_time());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->post('/rights/time/apply/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
$rights->apply_time();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->post('/rights/masks/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
|
||||||
|
$template = 'admin/editusers_masks.twig';
|
||||||
|
$twig = new \supertwig();
|
||||||
|
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
||||||
|
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
||||||
|
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
||||||
|
|
||||||
|
return $twig->render($template, $rights->get_masks());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->post('/rights/masks/apply/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
$rights->apply_masks();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->post('/search/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$users = new RequestHandler\Manage($request);
|
||||||
|
$template = 'admin/users.html';
|
||||||
|
|
||||||
|
$twig = new \supertwig();
|
||||||
|
$twig->addFilter(array('floor' => 'floor'));
|
||||||
|
$twig->addFilter(array('getDate' => 'phraseadate::getDate'));
|
||||||
|
|
||||||
|
return $twig->render($template, $users->search($request));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->get('/search/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$users = new RequestHandler\Manage($request);
|
||||||
|
$template = 'admin/users.html';
|
||||||
|
|
||||||
|
$twig = new \supertwig();
|
||||||
|
$twig->addFilter(array('floor' => 'floor'));
|
||||||
|
$twig->addFilter(array('getDate' => 'phraseadate::getDate'));
|
||||||
|
|
||||||
|
return $twig->render($template, $users->search($request));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->get('/typeahead/search/', function() use ($app, $appbox)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$user_query = new User_Query($appbox);
|
||||||
|
|
||||||
|
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
$like_value = $request->get('term');
|
||||||
|
$rights = $request->get('filter_rights') ? : array();
|
||||||
|
$have_right = $request->get('have_right') ? : array();
|
||||||
|
$have_not_right = $request->get('have_not_right') ? : array();
|
||||||
|
$on_base = $request->get('on_base') ? : array();
|
||||||
|
|
||||||
|
|
||||||
|
$elligible_users = $user_query->on_sbas_where_i_am($user->ACL(), $rights)
|
||||||
|
->like(\User_Query::LIKE_EMAIL, $like_value)
|
||||||
|
->like(\User_Query::LIKE_FIRSTNAME, $like_value)
|
||||||
|
->like(\User_Query::LIKE_LASTNAME, $like_value)
|
||||||
|
->like(\User_Query::LIKE_LOGIN, $like_value)
|
||||||
|
->like_match(\User_Query::LIKE_MATCH_OR)
|
||||||
|
->who_have_right($have_right)
|
||||||
|
->who_have_not_right($have_not_right)
|
||||||
|
->on_base_ids($on_base)
|
||||||
|
->execute()->get_results();
|
||||||
|
|
||||||
|
$datas = array();
|
||||||
|
|
||||||
|
foreach ($elligible_users as $user)
|
||||||
|
{
|
||||||
|
$datas[] = array(
|
||||||
|
'email' => $user->get_email() ? : ''
|
||||||
|
, 'login' => $user->get_login() ? : ''
|
||||||
|
, 'name' => $user->get_display_name() ? : ''
|
||||||
|
, 'id' => $user->get_id()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(\p4string::jsonencode($datas), 200, array('Content-type' => 'application/json'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->post('/create/', function() use ($app)
|
||||||
|
{
|
||||||
|
|
||||||
|
$datas = array('error' => false, 'message' => '', 'data' => null);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$module = new RequestHandler\Manage($request);
|
||||||
|
if ($request->get('template') == '1')
|
||||||
|
{
|
||||||
|
$user = $module->create_template();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$user = $module->create_newuser();
|
||||||
|
}
|
||||||
|
if (!($user instanceof \User_Adapter))
|
||||||
|
throw new \Exception('Unknown error');
|
||||||
|
|
||||||
|
$datas['data'] = $user->get_id();
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$datas['error'] = true;
|
||||||
|
$datas['message'] = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(\p4string::jsonencode($datas));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$controllers->post('/export/csv/', function() use ($appbox, $app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$user_query = new \User_Query($appbox);
|
||||||
|
|
||||||
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
$like_value = $request->get('like_value');
|
||||||
|
$like_field = $request->get('like_field');
|
||||||
|
$on_base = $request->get('base_id') ? : null;
|
||||||
|
$on_sbas = $request->get('sbas_id') ? : null;
|
||||||
|
|
||||||
|
$elligible_users = $user_query->on_bases_where_i_am($user->ACL(), array('canadmin'))
|
||||||
|
->like($like_field, $like_value)
|
||||||
|
->on_base_ids($on_base)
|
||||||
|
->on_sbas_ids($on_sbas);
|
||||||
|
|
||||||
|
$offset = 0;
|
||||||
|
$geoname = new \geonames();
|
||||||
|
$buffer = array();
|
||||||
|
|
||||||
|
$buffer[] = array(
|
||||||
|
'ID'
|
||||||
|
, 'Login'
|
||||||
|
, _('admin::compte-utilisateur nom')
|
||||||
|
, _('admin::compte-utilisateur prenom')
|
||||||
|
, _('admin::compte-utilisateur email')
|
||||||
|
, 'CreationDate'
|
||||||
|
, 'ModificationDate'
|
||||||
|
, _('admin::compte-utilisateur adresse')
|
||||||
|
, _('admin::compte-utilisateur ville')
|
||||||
|
, _('admin::compte-utilisateur code postal')
|
||||||
|
, _('admin::compte-utilisateur pays')
|
||||||
|
, _('admin::compte-utilisateur telephone')
|
||||||
|
, _('admin::compte-utilisateur fax')
|
||||||
|
, _('admin::compte-utilisateur poste')
|
||||||
|
, _('admin::compte-utilisateur societe')
|
||||||
|
, _('admin::compte-utilisateur activite')
|
||||||
|
);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
$elligible_users->limit($offset, 20);
|
||||||
|
$offset += 20;
|
||||||
|
|
||||||
|
$results = $elligible_users->execute()->get_results();
|
||||||
|
|
||||||
|
foreach ($results as $user)
|
||||||
|
{
|
||||||
|
$buffer[] = array(
|
||||||
|
$user->get_id()
|
||||||
|
, $user->get_login()
|
||||||
|
, $user->get_lastname()
|
||||||
|
, $user->get_firstname()
|
||||||
|
, $user->get_email()
|
||||||
|
, \phraseadate::format_mysql($user->get_creation_date())
|
||||||
|
, \phraseadate::format_mysql($user->get_modification_date())
|
||||||
|
, $user->get_address()
|
||||||
|
, $user->get_city()
|
||||||
|
, $user->get_zipcode()
|
||||||
|
, $geoname->get_country($user->get_geonameid())
|
||||||
|
, $user->get_tel()
|
||||||
|
, $user->get_fax()
|
||||||
|
, $user->get_job()
|
||||||
|
, $user->get_company()
|
||||||
|
, $user->get_position()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (count($results) > 0);
|
||||||
|
|
||||||
|
$out = \format::arr_to_csv($buffer);
|
||||||
|
|
||||||
|
$headers = array(
|
||||||
|
'Content-type' => 'text/csv'
|
||||||
|
, 'Content-Disposition' => 'attachment; filename=export.txt;'
|
||||||
|
);
|
||||||
|
$response = new Response($out, 200, $headers);
|
||||||
|
$response->setCharset('UTF-8');
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
170
lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php
Normal file
170
lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Root;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ControllerProviderInterface;
|
||||||
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class RSSFeeds implements ControllerProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function connect(Application $app)
|
||||||
|
{
|
||||||
|
$appbox = \appbox::get_instance();
|
||||||
|
|
||||||
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
|
$display_feed = function($feed, $format, $page, $user = null)
|
||||||
|
{
|
||||||
|
$total = $feed->get_count_total_entries();
|
||||||
|
$perPage = 5;
|
||||||
|
$entries = $feed->get_entries((($page - 1) * $perPage), $perPage);
|
||||||
|
|
||||||
|
$registry = \registry::get_instance();
|
||||||
|
|
||||||
|
if ($format == 'rss')
|
||||||
|
{
|
||||||
|
$content = new \Feed_XML_RSS();
|
||||||
|
}
|
||||||
|
if ($format == 'atom')
|
||||||
|
{
|
||||||
|
$content = new \Feed_XML_Atom();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user instanceof \User_Adapter)
|
||||||
|
$link = $feed->get_user_link($registry, $user, $format, $page);
|
||||||
|
else
|
||||||
|
$link = $feed->get_homepage_link($registry, $format, $page);
|
||||||
|
|
||||||
|
$content->set_updated_on(new \DateTime());
|
||||||
|
$content->set_title($feed->get_title());
|
||||||
|
$content->set_subtitle($feed->get_subtitle());
|
||||||
|
$content->set_generator('Phraseanet');
|
||||||
|
$content->set_link($link);
|
||||||
|
|
||||||
|
if ($user instanceof \User_Adapter)
|
||||||
|
{
|
||||||
|
if ($page > 1)
|
||||||
|
$content->set_previous_page($feed->get_user_link($registry, $user, $format, ($page - 1)));
|
||||||
|
if ($total > ($page * $perPage))
|
||||||
|
$content->set_next_page($feed->get_user_link($registry, $user, $format, ($page + 1)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($page > 1)
|
||||||
|
$content->set_previous_page($feed->get_homepage_link($registry, $format, ($page - 1)));
|
||||||
|
if ($total > ($page * $perPage))
|
||||||
|
$content->set_next_page($feed->get_homepage_link($registry, $format, ($page + 1)));
|
||||||
|
}
|
||||||
|
foreach ($entries->get_entries() as $entry)
|
||||||
|
$content->set_item($entry);
|
||||||
|
|
||||||
|
$render = $content->render();
|
||||||
|
$response = new Response($render, 200, array('Content-Type' => $content->get_mimetype()));
|
||||||
|
$response->setCharset('UTF-8');
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->get('/feed/{id}/{format}/', function($id, $format) use ($app, $appbox, $display_feed)
|
||||||
|
{
|
||||||
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
|
|
||||||
|
if (!$feed->is_public())
|
||||||
|
{
|
||||||
|
return new Response('Forbidden', 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
$page = (int) $request->get('page');
|
||||||
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
|
return $display_feed($feed, $format, $page);
|
||||||
|
})->assert('id', '\d+')->assert('format', '(rss|atom)');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->get('/userfeed/{token}/{id}/{format}/', function($token, $id, $format) use ($app, $appbox, $display_feed)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$token = new \Feed_Token($appbox, $token, $id);
|
||||||
|
$feed = $token->get_feed();
|
||||||
|
}
|
||||||
|
catch (\Exception_FeedNotFound $e)
|
||||||
|
{
|
||||||
|
return new Response('Not Found', 404);
|
||||||
|
}
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
$page = (int) $request->get('page');
|
||||||
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
|
return $display_feed($feed, $format, $page, $token->get_user());
|
||||||
|
})->assert('id', '\d+')->assert('format', '(rss|atom)');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->get('/userfeed/aggregated/{token}/{format}/', function($token, $format) use ($app, $appbox, $display_feed)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$token = new \Feed_TokenAggregate($appbox, $token);
|
||||||
|
$feed = $token->get_feed();
|
||||||
|
}
|
||||||
|
catch (\Exception_FeedNotFound $e)
|
||||||
|
{
|
||||||
|
return new Response('', 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
$page = (int) $request->get('page');
|
||||||
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
|
return $display_feed($feed, $format, $page, $token->get_user());
|
||||||
|
})->assert('id', '\d+')->assert('format', '(rss|atom)');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$controllers->get('/aggregated/{format}/', function($format) use ($app, $appbox, $display_feed)
|
||||||
|
{
|
||||||
|
$feeds = \Feed_Collection::load_public_feeds($appbox);
|
||||||
|
$feed = $feeds->get_aggregate();
|
||||||
|
|
||||||
|
$request = $app['request'];
|
||||||
|
$page = (int) $request->get('page');
|
||||||
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
|
return $display_feed($feed, $format, $page);
|
||||||
|
})->assert('format', '(rss|atom)');
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
305
lib/Alchemy/Phrasea/Controller/Setup/Installer.php
Normal file
305
lib/Alchemy/Phrasea/Controller/Setup/Installer.php
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Setup;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ControllerProviderInterface;
|
||||||
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
|
date_default_timezone_set('Europe/Berlin');
|
||||||
|
require_once dirname(__FILE__) . '/../../../../version.inc';
|
||||||
|
require_once dirname(__FILE__) . '/../../../../classes/phrasea.class.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../../../classes/bootstrap.class.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../../../classes/cache/cacheableInterface.class.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../../../classes/cache/interface.class.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../../../classes/cache/nocache.class.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../../../classes/cache/adapter.class.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../../../classes/User/Interface.class.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../../../classes/User/Adapter.class.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class Installer implements ControllerProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function connect(Application $app)
|
||||||
|
{
|
||||||
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
|
$app['available_languages'] = \User_Adapter::detectLanguage(new \Setup_Registry());
|
||||||
|
|
||||||
|
$controllers->get('/', function() use ($app)
|
||||||
|
{
|
||||||
|
$request = $app['request'];
|
||||||
|
$servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
|
||||||
|
\setup::write_config($servername);
|
||||||
|
|
||||||
|
|
||||||
|
$php_constraint = \setup::check_php_version();
|
||||||
|
$writability_constraints = \setup::check_writability(new \Setup_Registry());
|
||||||
|
$extension_constraints = \setup::check_php_extension();
|
||||||
|
$opcode_constraints = \setup::check_cache_opcode();
|
||||||
|
$php_conf_constraints = \setup::check_php_configuration();
|
||||||
|
$locales_constraints = \setup::check_system_locales();
|
||||||
|
|
||||||
|
$constraints_coll = array(
|
||||||
|
'php_constraint' => $php_constraint
|
||||||
|
, 'writability_constraints' => $writability_constraints
|
||||||
|
, 'extension_constraints' => $extension_constraints
|
||||||
|
, 'opcode_constraints' => $opcode_constraints
|
||||||
|
, 'php_conf_constraints' => $php_conf_constraints
|
||||||
|
, 'locales_constraints' => $locales_constraints
|
||||||
|
);
|
||||||
|
$redirect = true;
|
||||||
|
|
||||||
|
foreach ($constraints_coll as $key => $constraints)
|
||||||
|
{
|
||||||
|
$unset = true;
|
||||||
|
foreach ($constraints as $constraint)
|
||||||
|
{
|
||||||
|
if (!$constraint->is_ok() && $constraint->is_blocker())
|
||||||
|
$redirect = $unset = false;
|
||||||
|
}
|
||||||
|
if ($unset === true)
|
||||||
|
{
|
||||||
|
unset($constraints_coll[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($redirect)
|
||||||
|
{
|
||||||
|
return $app->redirect('/setup/installer/step2/');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$ld_path = array(dirname(__FILE__) . '/../../../../templates/web');
|
||||||
|
$loader = new Twig_Loader_Filesystem($ld_path);
|
||||||
|
$twig = new Twig_Environment($loader);
|
||||||
|
|
||||||
|
$html = $twig->render(
|
||||||
|
'/setup/index.twig'
|
||||||
|
, array_merge($constraints_coll, array(
|
||||||
|
'locale' => Session_Handler::get_locale()
|
||||||
|
, 'available_locales' => $app['available_languages']
|
||||||
|
, 'version_number' => GV_version
|
||||||
|
, 'version_name' => GV_version_name
|
||||||
|
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Response($html);
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/step2/', function() use ($app)
|
||||||
|
{
|
||||||
|
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||||
|
|
||||||
|
$ld_path = array(dirname(__FILE__) . '/../../../../templates/web');
|
||||||
|
|
||||||
|
$loader = new Twig_Loader_Filesystem($ld_path);
|
||||||
|
$twig = new Twig_Environment($loader);
|
||||||
|
|
||||||
|
$twig->addExtension(new Twig_Extensions_Extension_I18n());
|
||||||
|
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
$warnings = array();
|
||||||
|
if ($request->getScheme() == 'http')
|
||||||
|
{
|
||||||
|
$warnings[] = _('It is not recommended to install Phraseanet without HTTPS support');
|
||||||
|
}
|
||||||
|
$html = $twig->render(
|
||||||
|
'/setup/step2.twig'
|
||||||
|
, array(
|
||||||
|
'locale' => \Session_Handler::get_locale()
|
||||||
|
, 'available_locales' => $app['available_languages']
|
||||||
|
, 'available_templates' => \appbox::list_databox_templates()
|
||||||
|
, 'version_number' => GV_version
|
||||||
|
, 'version_name' => GV_version_name
|
||||||
|
, 'warnings' => $warnings
|
||||||
|
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
||||||
|
, 'discovered_binaries' => \setup::discover_binaries()
|
||||||
|
, 'rootpath' => dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Response($html);
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->post('/install/', function() use ($app)
|
||||||
|
{
|
||||||
|
set_time_limit(360);
|
||||||
|
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
$conn = $connbas = null;
|
||||||
|
|
||||||
|
$hostname = $request->get('ab_hostname');
|
||||||
|
$port = $request->get('ab_port');
|
||||||
|
$user_ab = $request->get('ab_user');
|
||||||
|
$password = $request->get('ab_password');
|
||||||
|
|
||||||
|
$appbox_name = $request->get('ab_name');
|
||||||
|
$databox_name = $request->get('db_name');
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$conn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $password, $appbox_name);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return $app->redirect('/setup/installer/step2/?error=' . _('Appbox is unreachable'));
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ($databox_name)
|
||||||
|
{
|
||||||
|
$connbas = new \connection_pdo('databox', $hostname, $port, $user_ab, $password, $databox_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return $app->redirect('/setup/installer/step2/?error=' . _('Databox is unreachable'));
|
||||||
|
}
|
||||||
|
\setup::rollback($conn, $connbas);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$appbox = \appbox::create(new \Setup_Registry(), $conn, $appbox_name, true);
|
||||||
|
|
||||||
|
|
||||||
|
$registry = \registry::get_instance();
|
||||||
|
\setup::create_global_values($registry);
|
||||||
|
|
||||||
|
$appbox->set_registry($registry);
|
||||||
|
|
||||||
|
$registry->set('GV_base_datapath_noweb', \p4string::addEndSlash($request->get('datapath_noweb')));
|
||||||
|
$registry->set('GV_base_datapath_web', \p4string::addEndSlash($request->get('datapath_web')));
|
||||||
|
$registry->set('GV_base_dataurl', \p4string::addEndSlash($request->get('mount_point_web')));
|
||||||
|
|
||||||
|
$registry->set('GV_cli', $request->get('binary_php'));
|
||||||
|
$registry->set('GV_imagick', $request->get('binary_convert'));
|
||||||
|
$registry->set('GV_pathcomposite', $request->get('binary_composite'));
|
||||||
|
$registry->set('GV_exiftool', $request->get('binary_exiftool'));
|
||||||
|
$registry->set('GV_swf_extract', $request->get('binary_swfextract'));
|
||||||
|
$registry->set('GV_pdf2swf', $request->get('binary_pdf2swf'));
|
||||||
|
$registry->set('GV_swf_render', $request->get('binary_swfrender'));
|
||||||
|
$registry->set('GV_unoconv', $request->get('binary_unoconv'));
|
||||||
|
$registry->set('GV_ffmpeg', $request->get('binary_ffmpeg'));
|
||||||
|
$registry->set('GV_mp4box', $request->get('binary_MP4Box'));
|
||||||
|
$registry->set('GV_mplayer', $request->get('binary_mplayer'));
|
||||||
|
$registry->set('GV_pdftotext', $request->get('binary_xpdf'));
|
||||||
|
|
||||||
|
$user = \User_Adapter::create($appbox, $request->get('email'), $request->get('password'), $request->get('email'), true);
|
||||||
|
|
||||||
|
if (!\p4string::hasAccent($databox_name))
|
||||||
|
{
|
||||||
|
if ($databox_name)
|
||||||
|
{
|
||||||
|
|
||||||
|
$template = new \system_file(dirname(__FILE__) . '/../../../conf.d/data_templates/' . $request->get('db_template') . '.xml');
|
||||||
|
$databox = \databox::create($appbox, $connbas, $template, $registry);
|
||||||
|
$user->ACL()
|
||||||
|
->give_access_to_sbas(array($databox->get_sbas_id()))
|
||||||
|
->update_rights_to_sbas(
|
||||||
|
$databox->get_sbas_id(), array(
|
||||||
|
'bas_manage' => 1, 'bas_modify_struct' => 1,
|
||||||
|
'bas_modif_th' => 1, 'bas_chupub' => 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$a = \collection::create($databox, $appbox, 'test', $user);
|
||||||
|
|
||||||
|
$user->ACL()->give_access_to_base(array($a->get_base_id()));
|
||||||
|
$user->ACL()->update_rights_to_base($a->get_base_id(), array(
|
||||||
|
'canpush' => 1, 'cancmd' => 1
|
||||||
|
, 'canputinalbum' => 1, 'candwnldhd' => 1, 'candwnldpreview' => 1, 'canadmin' => 1
|
||||||
|
, 'actif' => 1, 'canreport' => 1, 'canaddrecord' => 1, 'canmodifrecord' => 1
|
||||||
|
, 'candeleterecord' => 1, 'chgstatus' => 1, 'imgtools' => 1, 'manage' => 1
|
||||||
|
, 'modify_struct' => 1, 'nowatermark' => 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$tasks = $request->get('create_task', array());
|
||||||
|
foreach ($tasks as $task)
|
||||||
|
{
|
||||||
|
switch ($task)
|
||||||
|
{
|
||||||
|
case 'cindexer';
|
||||||
|
case 'subdef';
|
||||||
|
case 'writemeta';
|
||||||
|
$class_name = sprintf('task_period_%s', $task);
|
||||||
|
if ($task === 'cindexer')
|
||||||
|
{
|
||||||
|
$credentials = $databox->get_connection()->get_credentials();
|
||||||
|
|
||||||
|
$host = $credentials['hostname'];
|
||||||
|
$port = $credentials['port'];
|
||||||
|
$user_ab = $credentials['user'];
|
||||||
|
$password = $credentials['password'];
|
||||||
|
|
||||||
|
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<binpath>"
|
||||||
|
. str_replace('/phraseanet_indexer', '', $request->get('binary_phraseanet_indexer'))
|
||||||
|
. "</binpath><host>" . $host . "</host><port>"
|
||||||
|
. $port . "</port><base>"
|
||||||
|
. $appbox_name . "</base><user>"
|
||||||
|
. $user_ab . "</user><password>"
|
||||||
|
. $password . "</password><socket>25200</socket>"
|
||||||
|
. "<use_sbas>1</use_sbas><nolog>0</nolog><clng></clng>"
|
||||||
|
. "<winsvc_run>0</winsvc_run><charset>utf8</charset></tasksettings>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$settings = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
\task_abstract::create($appbox, $class_name, $settings);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
\phrasea::start();
|
||||||
|
|
||||||
|
$auth = new \Session_Authentication_None($user);
|
||||||
|
|
||||||
|
$appbox->get_session()->authenticate($auth);
|
||||||
|
|
||||||
|
$redirection = '/admin/?section=taskmanager¬ice=install_success';
|
||||||
|
|
||||||
|
return $app->redirect($redirection);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
\setup::rollback($conn, $connbas);
|
||||||
|
exit($e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getLine());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $app->redirect('/setup/installer/step2/?error=' . sprintf(_('an error occured : %s'), $e->getMessage()));
|
||||||
|
});
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
92
lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php
Normal file
92
lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Setup;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ControllerProviderInterface;
|
||||||
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Upgrader implements ControllerProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function connect(Application $app)
|
||||||
|
{
|
||||||
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
|
$app['registry'] = new \Setup_Registry();
|
||||||
|
$app['available_languages'] = \User_Adapter::detectLanguage($app['registry']);
|
||||||
|
$app['twig'] = function()
|
||||||
|
{
|
||||||
|
return new \supertwig();
|
||||||
|
};
|
||||||
|
|
||||||
|
$controllers->get('/', function() use ($app)
|
||||||
|
{
|
||||||
|
require_once dirname(__FILE__) . '/../../../../bootstrap.php';
|
||||||
|
$upgrade_status = \Setup_Upgrade::get_status();
|
||||||
|
|
||||||
|
ini_set('display_errors', 'on');
|
||||||
|
$html = $app['twig']->render(
|
||||||
|
'/setup/upgrader.twig'
|
||||||
|
, array(
|
||||||
|
'locale' => \Session_Handler::get_locale()
|
||||||
|
, 'upgrade_status' => $upgrade_status
|
||||||
|
, 'available_locales' => $app['available_languages']
|
||||||
|
, 'bad_users' => \User_Adapter::get_wrong_email_users(\appbox::get_instance())
|
||||||
|
, 'version_number' => GV_version
|
||||||
|
, 'version_name' => GV_version_name)
|
||||||
|
);
|
||||||
|
ini_set('display_errors', 'on');
|
||||||
|
|
||||||
|
return new Response($html);
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/status/', function() use ($app)
|
||||||
|
{
|
||||||
|
require_once dirname(__FILE__) . '/../../../../bootstrap.php';
|
||||||
|
ini_set('display_errors', 'on');
|
||||||
|
|
||||||
|
$datas = \Setup_Upgrade::get_status();
|
||||||
|
|
||||||
|
return new Response(\p4string::jsonencode($datas), 200, array('Content-Type: application/json'));
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->post('/execute/', function() use ($app)
|
||||||
|
{
|
||||||
|
require_once dirname(__FILE__) . '/../../../../bootstrap.php';
|
||||||
|
ini_set('display_errors', 'on');
|
||||||
|
set_time_limit(0);
|
||||||
|
session_write_close();
|
||||||
|
ignore_user_abort(true);
|
||||||
|
|
||||||
|
$appbox = \appbox::get_instance();
|
||||||
|
$upgrader = new \Setup_Upgrade($appbox);
|
||||||
|
$appbox->forceUpgrade($upgrader);
|
||||||
|
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
106
lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php
Normal file
106
lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Utils;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ControllerProviderInterface;
|
||||||
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ConnectionTest implements ControllerProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function connect(Application $app)
|
||||||
|
{
|
||||||
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
|
$controllers->get('/mysql/', function() use ($app)
|
||||||
|
{
|
||||||
|
require_once __DIR__ . '/../../../../classes/connection/pdo.class.php';
|
||||||
|
|
||||||
|
$request = $app['request'];
|
||||||
|
$hostname = $request->get('hostname', '127.0.0.1');
|
||||||
|
$port = (int) $request->get('port', 3306);
|
||||||
|
$user = $request->get('user');
|
||||||
|
$password = $request->get('password');
|
||||||
|
$dbname = $request->get('dbname');
|
||||||
|
|
||||||
|
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$conn = new \connection_pdo('test', $hostname, $port, $user, $password);
|
||||||
|
$connection_ok = true;
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($dbname && $connection_ok === true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname);
|
||||||
|
$db_ok = true;
|
||||||
|
|
||||||
|
$sql = "SHOW TABLE STATUS";
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
$empty = $stmt->rowCount() === 0;
|
||||||
|
|
||||||
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
foreach ($rs as $row)
|
||||||
|
{
|
||||||
|
if ($row["Name"] === 'sitepreff')
|
||||||
|
{
|
||||||
|
$is_appbox = true;
|
||||||
|
}
|
||||||
|
if ($row["Name"] === 'pref')
|
||||||
|
{
|
||||||
|
$is_databox = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(\p4string::jsonencode(array(
|
||||||
|
'connection' => $connection_ok
|
||||||
|
, 'database' => $db_ok
|
||||||
|
, 'is_empty' => $empty
|
||||||
|
, 'is_appbox' => $is_appbox
|
||||||
|
, 'is_databox' => $is_databox
|
||||||
|
)), 200, array('application/json'));
|
||||||
|
});
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
62
lib/Alchemy/Phrasea/Controller/Utils/PathFileTest.php
Normal file
62
lib/Alchemy/Phrasea/Controller/Utils/PathFileTest.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Utils;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ControllerProviderInterface;
|
||||||
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class PathFileTest implements ControllerProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function connect(Application $app)
|
||||||
|
{
|
||||||
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
|
$controllers->get('/path/', function() use ($app)
|
||||||
|
{
|
||||||
|
$path = $app['request']->get('path');
|
||||||
|
|
||||||
|
return new Response(\p4string::jsonencode(array(
|
||||||
|
'exists' => file_exists($path)
|
||||||
|
, 'file' => is_file($path)
|
||||||
|
, 'dir' => is_dir($path)
|
||||||
|
, 'readable' => is_readable($path)
|
||||||
|
, 'writeable' => is_writable($path)
|
||||||
|
, 'executable' => is_executable($path)
|
||||||
|
)), 200, array('application/json'));
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/url/', function() use ($app)
|
||||||
|
{
|
||||||
|
$url = $app['request']->get('url');
|
||||||
|
|
||||||
|
return new Response(\p4string::jsonencode(array(
|
||||||
|
'code' => \http_query::getHttpCodeFromUrl($url)
|
||||||
|
)), 200, array('application/json'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user