Merge branch '3.6' of github.com:alchemy-fr/Phraseanet into 3.6

This commit is contained in:
jygaulier
2012-01-02 11:59:07 +01:00
418 changed files with 10286 additions and 9531 deletions

View File

@@ -894,6 +894,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this->is_template;
}
public function get_template_owner()
{
return $this->template_owner;
}
public static function get_usr_id_from_email($email)
{
if(is_null($email))
@@ -1298,7 +1303,8 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
protected function load_notifications_preferences()
{
$evt_mngr = eventsmanager_broker::getInstance($this->appbox);
$Core = bootstrap::getCore();
$evt_mngr = eventsmanager_broker::getInstance($this->appbox, $Core);
$notifications = $evt_mngr->list_notifications_available($this->id);
foreach ($notifications as $notification_group => $nots)
@@ -1401,7 +1407,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$lngs = array();
$path = dirname(__FILE__) . "/../../../locale";
$path = __DIR__ . "/../../../locale";
if ($hdir = opendir($path))
{
while (false !== ($file = readdir($hdir)))
@@ -1423,95 +1429,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $lngs;
}
public static function detectLanguage(registryInterface $registry, $setLng = null)
{
$avLanguages = self::avLanguages();
$sel = $askLng = $askLocale = '';
if ($setLng !== null)
{
$askLng = substr($setLng, 0, 2);
$askLocale = $setLng;
}
elseif (Session_Handler::isset_cookie('locale'))
{
$askLng = substr(Session_Handler::get_cookie('locale'), 0, 2);
$askLocale = Session_Handler::get_cookie('locale');
}
elseif (strlen($registry->get('GV_default_lng')) > 2)
{
$askLng = substr($registry->get('GV_default_lng'), 0, 2);
$askLocale = $registry->get('GV_default_lng');
}
if ($askLng != '' && isset($avLanguages[$askLng]) && isset($avLanguages[$askLng][$askLocale]))
{
$avLanguages[$askLng][$askLocale]['selected'] = true;
$sel = $askLocale;
}
if ($sel === '' && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
$languages = explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$found = false;
foreach ($languages as $language)
{
$language = explode(',', strtolower($language));
if (count($language) != 2)
continue;
foreach ($language as $lang)
{
if (strpos($lang, '-') == 2 && strlen($lang) == 5)
{
$l = explode('-', $lang);
$l[0] = strtolower($l[0]);
$l[1] = strtoupper($l[1]);
if ($sel != '')
{
$found = true;
break;
}
$lang = implode('_', $l);
if (isset($avLanguages[$l[0]]))
{
if (!isset($avLanguages[$l[0]][$lang]))
{
$lang = end(array_keys($avLanguages[$l[0]]));
}
$avLanguages[$l[0]][$lang]['selected'] = true;
$sel = $lang;
$found = true;
break;
}
}
}
if ($found)
break;
}
if (!$found && array_key_exists(substr($registry->get('GV_default_lng'), 0, 2), $avLanguages))
{
$avLanguages[substr($registry->get('GV_default_lng'), 0, 2)][$registry->get('GV_default_lng')]['selected'] = true;
$sel = $registry->get('GV_default_lng');
}
}
if ($sel == '')
{
$key = end(array_keys($avLanguages));
$lang = end(array_keys($avLanguages[$key]));
$avLanguages[$key][$lang]['selected'] = true;
$sel = $lang;
}
Session_Handler::set_locale($sel);
$sel = explode('_', $sel);
return $avLanguages;
}
public static function get_wrong_email_users(appbox $appbox)
{

View File

@@ -147,8 +147,6 @@ interface User_Interface
public static function avLanguages();
public static function detectLanguage(registryInterface $registry, $setLng = null);
public function setPrefs($prop, $value);
public function getPrefs($prop);

View File

@@ -88,6 +88,11 @@ class User_Query implements User_QueryInterface
* @var boolean
*/
protected $include_templates = false;
/**
*
* @var boolean
*/
protected $only_templates = false;
/**
*
* @var Array
@@ -123,10 +128,10 @@ class User_Query implements User_QueryInterface
const SORT_FIRSTNAME= 'usr_prenom';
const SORT_LASTNAME= 'usr_nom';
const SORT_COMPANY = 'societe';
const SORT_LOGIN = 'login';
const SORT_LOGIN = 'usr_login';
const SORT_EMAIL = 'usr_mail';
const SORT_ID = 'usr_id';
const SORT_CREATIONDATE = 'creationdate';
const SORT_CREATIONDATE = 'usr_creationdate';
const SORT_COUNTRY = 'pays';
const SORT_LASTMODEL = 'lastModel';
@@ -191,18 +196,22 @@ class User_Query implements User_QueryInterface
$sql .= ' AND usr_login NOT LIKE "(#deleted_%" ';
if ($this->include_invite)
if (!$this->include_invite)
{
$sql .= ' AND usr.invite=0 ';
}
if ($this->include_templates === false)
if ($this->only_templates === true)
{
$sql .= ' AND model_of = ' . $session->get_usr_id();
}
elseif ($this->include_templates === false)
{
$sql .= ' AND model_of=0';
}
else
{
$sql .= ' AND (model_of=0 OR model_of= ' . $session->get_usr_id() . ' ) ';
$sql .= ' AND (model_of=0 OR model_of = ' . $session->get_usr_id() . ' ) ';
}
$baslist = array();
@@ -355,6 +364,17 @@ class User_Query implements User_QueryInterface
return $this;
}
/**
*
* @param boolean $boolean
* @return User_Query
*/
public function only_templates($boolean)
{
$this->only_templates = !!$boolean;
return $this;
}
/**
*
@@ -390,6 +410,8 @@ class User_Query implements User_QueryInterface
case self::SORT_COMPANY:
case self::SORT_LOGIN:
case self::SORT_EMAIL:
$sorter[$k] = ' usr.`' . $sort . '` COLLATE utf8_unicode_ci ';
break;
case self::SORT_ID:
case self::SORT_CREATIONDATE:
case self::SORT_COUNTRY:
@@ -410,7 +432,7 @@ class User_Query implements User_QueryInterface
$sorter[$k] .= ' ASC ';
break;
case self::ORD_DESC:
$sorter[$k] .= ' ASC ';
$sorter[$k] .= ' DESC ';
break;
}
}