From c010e54a23877c5e74f3bcf595f5e89971f8a57e Mon Sep 17 00:00:00 2001 From: Imran Hussain <imranh@sucs.org> Date: Sun, 23 Nov 2014 22:43:07 +0000 Subject: [PATCH] unread email status indicator --- lib/session.php | 7 +++++-- templates/login.tpl | 32 ++++++++++++-------------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/lib/session.php b/lib/session.php index f462039..49a124f 100644 --- a/lib/session.php +++ b/lib/session.php @@ -222,11 +222,14 @@ private $datahash=''; // hash of data field ldap_close($ldap); // Check the user's email status - $mailstat = @stat("/var/spool/mail/".$user); + /*$mailstat = @stat("/var/spool/mail/".$user); if ($mailstat[size]>0) { if ($mailstat[mtime]>$mailstat[atime]) $this->email = 2; else $this->email = 1; - } + }*/ + // a sure-fire way to check to see if the user has any unread email + // the bash script returns 0 for no and 1 for yes, takes one arg, username + $this->email = shell_exec("/home/member/imranh/bin/sucsunreadmail $user"); if (file_exists($info['homedirectory'][0]."/.forward")) { $forward = file($info['homedirectory'][0]."/.forward"); diff --git a/templates/login.tpl b/templates/login.tpl index 28635ad..f1fdfdd 100644 --- a/templates/login.tpl +++ b/templates/login.tpl @@ -2,27 +2,19 @@ <form method="post" action="{$ssl_url|escape:'htmlall'}{getparams gets=$gets}"> <div> {if $session->loggedin} -Logged in as <a href="{$baseurl}/Community/Members/{$session->username}">{$session->username}</a><br /> -<a href="{$baseurl}/Options">Membership Options</a><br /> + Logged in as <a href="{$baseurl}/Community/Members/{$session->username}">{$session->username}</a><br /> + <a href="{$baseurl}/Options">Membership Options</a><br /> + {if $session->email_forward} + Mail forwarded to {$session->email_forward}<br /> + {else} + {if $session->email=="0"} + No new email<br /> + {elseif $session->email=="1"} + <a href="https://sucs.org/webmail/">New email</a><br /> + {/if} -{if $session->email_forward} -Mail forwarded to {$session->email_forward}<br /> - - -{* Don't bother alerting users to new mail at present; it's all broken because of noatime -{else} -{if $session->email=="0"} -No email<br /> -{elseif $session->email=="1"} -No new email<br /> -{elseif $session->email=="2"} -<a href="https://sucs.org/webmail/">New email</a><br /> -{/if} -*} - -{/if} - - <input type="submit" class="button" name="Logout" id="Logout" value="Logout" /> + {/if} + <input type="submit" class="button" name="Logout" id="Logout" value="Logout" /> {else} <input type="text" class="text" name="session_user" id="session_user" placeholder="Username" /> <input type="password" class="text" name="session_pass" id="session_pass" placeholder="Password" /> -- GitLab