Merge branch 'templates' into 3.6

This commit is contained in:
Romain Neutron
2012-01-06 18:14:22 +01:00
3 changed files with 35 additions and 39 deletions

View File

@@ -405,14 +405,14 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{ {
if (trim($email) == '') if (trim($email) == '')
$email = null; $email = null;
$test_user = User_Adapter::get_usr_id_from_email($email); $test_user = User_Adapter::get_usr_id_from_email($email);
if($test_user && $test_user != $this->get_id()) if ($test_user && $test_user != $this->get_id())
{ {
throw new Exception_InvalidArgument (sprintf(_('A user already exists with email addres %s'), $email)); throw new Exception_InvalidArgument(sprintf(_('A user already exists with email addres %s'), $email));
} }
$sql = 'UPDATE usr SET usr_mail = :new_email WHERE usr_id = :usr_id'; $sql = 'UPDATE usr SET usr_mail = :new_email WHERE usr_id = :usr_id';
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':new_email' => $email, ':usr_id' => $this->get_id())); $stmt->execute(array(':new_email' => $email, ':usr_id' => $this->get_id()));
@@ -593,7 +593,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this; return $this;
} }
/** /**
* *
* @param boolean $boolean * @param boolean $boolean
* @return User_Adapter * @return User_Adapter
@@ -861,7 +861,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id())); $stmt->execute(array(':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$this->set_ftp_address('') $this->set_ftp_address('')
->set_activeftp(false) ->set_activeftp(false)
->set_city('') ->set_city('')
@@ -893,10 +893,10 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{ {
return $this->is_template; return $this->is_template;
} }
public function is_special() public function is_special()
{ {
return in_array($this->login, array('invite', 'autoregister')); return in_array($this->login, array('invite', 'autoregister'));
} }
public function get_template_owner() public function get_template_owner()
@@ -906,9 +906,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public static function get_usr_id_from_email($email) public static function get_usr_id_from_email($email)
{ {
if(is_null($email)) if (is_null($email))
return false; return false;
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection();
$sql = 'SELECT usr_id FROM usr $sql = 'SELECT usr_id FROM usr
WHERE usr_mail = :email WHERE usr_mail = :email
@@ -1069,7 +1069,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$this->id = (int) $row['usr_id']; $this->id = (int) $row['usr_id'];
$this->email = $row['usr_mail']; $this->email = $row['usr_mail'];
$this->login = $row['usr_login']; $this->login = $row['usr_login'];
$this->ldap_created = $row['ldap_created']; $this->ldap_created = $row['ldap_created'];
$this->defaultftpdatas = $row['defaultftpdatasent']; $this->defaultftpdatas = $row['defaultftpdatasent'];
@@ -1117,8 +1117,14 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public function set_last_template(User_Interface $template) public function set_last_template(User_Interface $template)
{ {
$sql = 'UPDATE usr SET lastModel = :template_id WHERE usr_id = :usr_id'; $sql = 'UPDATE usr SET lastModel = :template_id WHERE usr_id = :usr_id';
$params = array(
':usr_id' => $this->get_id()
, ':template_id' => $template->get_login()
);
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $this->get_id(), ':template_id' => $template->get_id())); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
$this->delete_data_from_cache(); $this->delete_data_from_cache();
@@ -1249,18 +1255,8 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public function get_applied_template() public function get_applied_template()
{ {
$template = '';
if ($this->applied_template) return $this->applied_template;
{
$sql = 'SELECT usr_login FROM usr WHERE usr_login = :login';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':login' => $this->applied_template));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$template = $row['usr_login'];
}
return $template;
} }
public function get_creation_date() public function get_creation_date()
@@ -1281,7 +1277,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
protected function load_preferences() protected function load_preferences()
{ {
if ($this->_prefs) if ($this->_prefs)
return $this; return $this;
$sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id'; $sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id';
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
@@ -1376,32 +1371,32 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return $this; return $this;
} }
public function get_cache_key($option=null) public function get_cache_key($option = null)
{ {
return '_user_' . $this->get_id() . ($option ? '_' . $option : ''); return '_user_' . $this->get_id() . ($option ? '_' . $option : '');
} }
public function delete_data_from_cache($option=null) public function delete_data_from_cache($option = null)
{ {
$this->appbox->delete_data_from_cache($this->get_cache_key($option)); $this->appbox->delete_data_from_cache($this->get_cache_key($option));
return $this; return $this;
} }
public function get_data_from_cache($option=null) public function get_data_from_cache($option = null)
{ {
$this->appbox->get_data_from_cache($this->get_cache_key($option)); $this->appbox->get_data_from_cache($this->get_cache_key($option));
return $this; return $this;
} }
public function set_data_to_cache($value, $option=null, $duration = 0) public function set_data_to_cache($value, $option = null, $duration = 0)
{ {
$this->appbox->set_data_to_cache($value, $this->get_cache_key($option), $duration); $this->appbox->set_data_to_cache($value, $this->get_cache_key($option), $duration);
@@ -1519,7 +1514,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
if (!$session->is_authenticated()) if (!$session->is_authenticated())
return; return;
$ses_id = $session->get_ses_id(); $ses_id = $session->get_ses_id();
@@ -1578,7 +1572,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
} }
@@ -1642,7 +1636,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return false; return false;
@@ -1728,7 +1722,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return $locale; return $locale;
@@ -1794,7 +1788,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public function get_nonce() public function get_nonce()
{ {
if ($this->nonce) if ($this->nonce)
return $this->nonce; return $this->nonce;
$nonce = false; $nonce = false;
@@ -1812,7 +1805,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this->nonce; return $this->nonce;
} }
public function __sleep() public function __sleep()
{ {
$vars = array(); $vars = array();

View File

@@ -151,10 +151,14 @@
{% for usr in users.get_results %} {% for usr in users.get_results %}
<tr class="{% if loop.index is odd %}odd{% else %}even{% endif %}" id="user_{{usr.get_id()}}"> <tr class="{% if loop.index is odd %}odd{% else %}even{% endif %}" id="user_{{usr.get_id()}}">
<td style="text-align: center;"> <td style="text-align: center;">
{% if usr.ACL().is_phantom() %} {% if usr.is_template() %}
<img src="/skins/admin/ghost.png"/> <img title="{% trans 'This is a template' %}" src="/skins/icons/template.png"/>
{% else %}
{% if usr.ACL().is_phantom() %}
<img title="{% trans 'This user has no rights' %}" src="/skins/admin/ghost.png"/>
{% endif %}
{{usr.get_id()}}
{% endif %} {% endif %}
{{usr.get_id()}}
</td> </td>
<td> <td>
{{usr.get_login()}} {{usr.get_login()}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB