Skip to content

Commit

Permalink
Only show signatures if the user has at least one
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 15, 2013
1 parent 9c182f7 commit 80ba2f7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion imp/lib/Basic/Compose.php
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ protected function _init()
$view->identity_text = $select_list[0];
}
}
$view->signature = $prefs->getValue('signature_show_compose');
$view->signature = $identity->hasSignature(true);

$addr_array = array(
'to' => _("_To"),
Expand Down
6 changes: 4 additions & 2 deletions imp/lib/Compose/Ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ public function passphraseDialog($type, $cacheid = null)
*/
public function addIdentityJs()
{
global $injector, $page_output, $prefs;
global $injector, $page_output;

$identities = array();
$identity = $injector->getInstance('IMP_Identity');
$filter = $injector->getInstance('Horde_Core_Factory_TextFilter');

$sigs = $identity->hasSignature(true);

foreach (array_keys($identity->getAll('id')) as $ident) {
$sm = $identity->getValue(IMP_Mailbox::MBOX_SENT, $ident);

Expand All @@ -143,7 +145,7 @@ public function addIdentityJs()
'bcc' => strval($identity->getBccAddresses($ident))
);

if ($prefs->getValue('signature_show_compose')) {
if ($sigs) {
$sig = $identity->getSignature('text', $ident);
$html_sig = $identity->getSignature('html', $ident);
if (!strlen($html_sig) && strlen($sig)) {
Expand Down
2 changes: 1 addition & 1 deletion imp/lib/Dynamic/Compose/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected function _compose($base, $view, $args)
}
$view->select_list = $select_list;

$view->signature = $prefs->getValue('signature_show_compose');
$view->signature = $identity->hasSignature(true);
}

/**
Expand Down
24 changes: 24 additions & 0 deletions imp/lib/Prefs/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,30 @@ public function getAllSignatures($type = 'text')
return $list;
}

/**
* Does the user have any signatures (either text or HTML)?
*
* @param boolean $compose_page If true, checks for signatures as used on
* the compose pages.
*
* @return boolean True if the user has at least one signature.
*/
public function hasSignature($compose_page = false)
{
global $prefs;

if (!$compose_page || $prefs->getValue('signature_show_compose')) {
foreach (array_keys($this->_identities) as $key) {
if (strlen(trim($this->getValue('signature_html', $key))) ||
strlen(trim($this->getValue('signature', $key)))) {
return true;
}
}
}

return false;
}

/**
* Returns a property from one of the identities.
*
Expand Down

0 comments on commit 80ba2f7

Please sign in to comment.