<?php
class MessageControlAction extends Action {
// function MailShow ($start) //显示邮箱
// {
// // echo "<br><hr>".$start ."<hr><br>";
// $mail = M('sysinfo');
// $where['parameter'] = 'mailPageNum';
// $mailListLength = $mail->where($where)->field('content')->select(); //获取系统设置里面单页显示的信息条数
// $message = M('message');
// $emailCount = $message->count(); //数据一共多少条
// $arruser = $message->order('date desc')->limit('5')->select(); //取出所有数据
// //这里总数减一,是因为邮箱第一个数据不做有效数据.
// $mailCount = (($emailCount - 1) / $mailListLength[0]['content']); //计算一共的页数, 用信息的条数, 除以每一页的条数.
// echo $mailCount;
// }
function index($start = 0) //第一次打开, 初始化
{
$mail = M('sysinfo');
$where['parameter'] = 'mailPageNum';
$mailListLength = $mail->where($where)->field('content')->select(); //获取系统设置里面单页显示的信息条数
$message = M('message');
$emailCount = $message->count();
$arruser = $message->order('date desc')->limit($mailListLength[0]['content'])->select(); //取出所有数据
//这里总数减一,是因为邮箱第一个数据不做有效数据.
$mailCount = ceil($emailCount / $mailListLength[0]['content']); //计算一共的页数, 用信息的条数, 除以每一页的条数.
if ($mailCount > 1) //有分页的情况
{
$this->assign('mailCount', '1/' . $mailCount);
$this->display("message");
$this->initMailList($arruser, $start, $mailListLength[0]['content'], $emailCount);
}
else //没有分页
{
$this->assign('mailCount', '0/' . $mailCount);
$this->display("message");
$this->initMailList($arruser, $start, count($arruser), $emailCount);
}
}
//判断字符串长度, 含utf8中文计算长度
function utf8_strlen($str) {
$count = 0;
for($i = 0; $i < strlen($str); $i++)
{
$value = ord($str[$i]);
if($value > 127)
{
$count++;
if($value >= 192 && $value <= 223){
$i++;
}
elseif($value >= 224 && $value <= 239)
{
$i = $i + 2;
}
elseif($value >= 240 && $value <= 247)
{
$i = $i + 3;
}
else die('Not a UTF-8 compatible string');
}
$count++;
}
return $count;
}
//初始化邮箱
function initMailList($arruser, $start, $offset, $mailLen)
{
//var_dump($arruser);
$this->PrintMail($arruser, $start, $offset);
if ($mailLen == 0) //没有邮件
{
return;
}
else if ($start == 0 && $mailLen > ($start + $offset)) //就一页, 数据小于分页显示的数量
{
$this->initMailPageControl(0, 1);
return;
}
else if ($start == 0 && ($start + $offset) > $mailLen) //显示第一页,并且邮件长度不足一页显示的
{
$this->initMailPageControl(0, 1); //第一页,没有上一页
return;
}
else //就是不需要显示分页,因为不足显示的类表长度,所有不需要上下分页.
{
// $this->initMailPageControl(1, 1);
return;
}
}
//初始化邮箱翻页操作,
function initMailPageControl($left, $right)
{
if ($left == true)
{
echo "<button class='proPage' style='background-color:#eee;color:#000; position: absolute;left: 300px; border-radius: 9px; top: 500px; margin:3px 0 3px 0; width: 82px; height: 30px;border: 1px solid #aaa;text-align:center;'><--上一页</button>";
}
else
{
echo "<button class='proPage' style='background-color:#fff;color:#999; position: absolute;left: 300px; border-radius: 9px; top: 500px; margin:3px 0 3px 0; width: 82px; height: 30px;border: 1px solid #aaa;text-align:center;'><--上一页</button>";
}
if ($right == true)
{
echo "<button class='nextPage' style='background-color:#eee;color:#000; position: absolute;left: 385px; border-radius: 9px; top: 500px; margin:3px 0 3px 0; width: 82px; height: 30px; border: 1px solid #aaa;text-align:center;'>下一页--></button></div>";
}
else
{
echo "<button class='nextPage' style='background-color:#fff;color:#999; position: absolute;left: 385px; border-radius: 9px; top: 500px; margin:3px 0 3px 0; width: 82px; height: 30px; border: 1px solid #aaa;text-align:center;'>下一页--></button></div>";
}
}
//打印邮件
function PrintMail($arruser, $start, $offset)
{
// echo "<br><br><br><br>".$start . " ===== ". $end;
$strShow = "<div class='mailSet' style='cursor: pointer;position:absolute; left:3px; top:50px;'><table class='mailTanle' border='0' cellpadding='0' cellspacing='0' width='730px'>";
if (0 >= $offset)
{
return;
}
$i = 1;
foreach ($arruser as $keyOne=>$value)
{
//初始化
$strOne = '';
$strTwo = '';
$strOne .= "<tr>";
$strOne .= "<td border='0'>";
$strOne .= "<div class='mailShow' style='border: 1px solid #6BC784; font-size: 17px; font-family:宋体; height:30px;";
//这里会添加 红旗字符串, 标红,
$strTwo .= "' id='mailShowId" . ($start + $i) . "'>";
$strTwo .= "<input type='checkbox' id='checkbox" . ($start + $i) . "'class='checkbox' style='position: relative; float:left; margin:10px 10px 0 10px; width:13px; height:13px; border:0px solid #369; border-color:red; background-color:#fff; color:red; ' value='" . ($start + $i) . "' name='email". $i . "'>";
foreach ($value as $k=>$var)
{
if ($k == 'isRead')
{
if($value['isRead'] == '0') //未读
{
$strTwo .= "<img style='position:relative; top: 10px; float:left;width:15px; height:12px; margin:0 10px 0 0; border-radius:3px;' class='Nread' id='isread" . ($start + $i) . "'>" ;
}
else if ($value['isRead'] == '1') //已读
{
$strTwo .= "<div style='position:relative; top: 10px; float:left;width:15px; height:12px; margin:0 10px 0 0; border-radius:3px;' class='Yread' id='isread" . ($start + $i) . "'>" . " " ."</div>";
}
}
if ($k == 'name')
{
$maxStr = 0;
$nameLength = $this->utf8_strlen($value["name"]); //计算名字长度,
if (preg_match("/[\x7f-\xff]/", $value["name"])) //判断是否有中文
{
$maxStr = 5; //有中文, 长度最大为6个汉字
}
else {
$maxStr = 10; //没有中文,为12个英文字符.
}
if ($nameLength <= $maxStr )
{
$strTwo .= "<div style='font-size:15px; font-weight: bold; top: 8px; width:110px; text-align:left; margin: 0 10px 0 5px; height:100%; position:relative; float:left;'>"
. $value['name'] . "</div>";
}
else {
$strTwo .= "<div style='font-size:15px; font-weight: bold; top: 8px; width:110px; text-align:left; margin: 0 10px 0 5px; height:100%; position:relative; float:left;'>"
. mb_substr($value['name'], 0, $maxStr, 'utf-8') . "...</div>"; //截取后显示
}
}
if ($k == 'isFlag')
{
if($value['isFlag'] == '0') //没标记
{
$falgStr = "color:#000";
}
else if ($value['isFlag'] == '1') //已标记
{
$falgStr = "color:red";
}
}
if ($k == 'message')
{
$strTwo .= "<div style='top: 6px; width:445px; position:relative; float:left;'>" .
"<img style='width:14px; height:14px; margin:0 10px 0 0; border-radius:30px;' class='message_img_del' id='message_img_del_" . ($start + $i) . "'>" .
"<img style='width:15px; height:15px; margin:0 20px 0 0; border-radius:30px;' class='message_img_flag' id='message_img_flag_" . ($start + $i) . "'>" ;
if (strlen($value['message']) < 20)
{
$strTwo .= $value['message'] . "...</div>";
}
else
{
//mb_substr防止中文乱码
$strTwo .= mb_substr($value['message'], 0, 20, 'utf-8') . "...</div>" ;
}
}
if ($k == 'date')
{
$date = substr(date('Y-m-d', $value['date']), 2);
$strTwo .= "<span style='position:relative; top:8px; float:right; font-size:14px; text-align:center;'>" . $date . "</span>";
}
}
$strTwo .= "</div>";
$strTwo .= "</td>";
$strTwo .= "</tr>";
$strShow .= $strOne . $falgStr . $strTwo;
$i++;
if ($i > $offset) //判断,然后跳出循环
{
break;
}
}
$strShow .= "</table>";
echo $strShow;
}
function mailNextPage() {
if (!$this->isPost()) //不是post提交
{
;
}
else //post提交
{
$start = $this->_post('pageEndMail');
$mail = M('sysinfo');
$where['parameter'] = 'mailPageNum';
$mailListLength = $mail->where($where)->field('content')->select(); //获取系统设置里面单页显示的信息条数
$message = M('message');
$emailCount = $message->count(); //取出所有数据
//这里总数减一,是因为邮箱第一个数据不做有效数据.
$mailCount = ceil(count($arruser) / $mailListLength[0]['content']); //计算一共的页数, 用信息的条数, 除以每一页的条数.
// echo $start. " ===== ". ($start + $mailListLength[0]['content']) . "=====".$emailCount;
//$maildata = $message->order('date desc')->limit($start. "," . $mailListLength[0]['content'])->select();
if (($emailCount - $mailListLength[0]['content']) >= $start)
{
$maildata = $message->order('date desc')->limit($start. "," . $mailListLength[0]['content'])->select();
$this->initMailList($maildata, $start, $mailListLength[0]['content'], $emailCount);
//var_dump($maildata);
}
else
{
// $this->assign('mailCount', '0/' . $mailCount);
// $this->display("message");
$maildata = $message->order('date desc')->limit($start . "," . ($emailCount - $start))->select();
$this->initMailList($maildata, $start, ($emailCount - $start), 0);
}
}
}
function mailProPage()
{
if (!$this->isPost()) //不是post提交
{
;
}
else //post提交
{
$start = $this->_post('pageEndMail') - 1;
$mail = M('sysinfo');
$where['parameter'] = 'mailPageNum';
$mailListLength = $mail->where($where)->field('content')->select(); //获取系统设置里面单页显示的信息条数
$message = M('message');
$emailCount = $message->count(); //数据一共多少条
//这里总数减一,是因为邮箱第一个数据不做有效数据.
$mailCount = ceil(count($arruser) / $mailListLength[0]['content']); //计算一共的页数, 用信息的条数, 除以每一页的条数.
// echo $start. " ===== ". ($start - $mailListLength[0]['content']) . "=====".$emailCount;
if ($start - $mailListLength[0]['content'] >= 0)
{
$maildata = $message->order('date desc')->limit(($start - $mailListLength[0]['content']). "," . $mailListLength[0]['content'])->select();
$this->initMailList($maildata, $start - $mailListLength[0]['content'], $mailListLength[0]['content'], $emailCount);
}
else
{
;
}
}
}
function mailControlPage()
{
if (!$this->isPost()) //不是post提交
{
;
}
else //post提交
{
$showPage = $this->_post('pageAim'); //将要显示的页面
$len = $this->_post('len'); //总共的页面数
$mail = M('sysinfo');
$where['parameter'] = 'mailPageNum';
$mailListLength = $mail->where($where)->field('content')->select(); //获取系统设置里面单页显示的信息条数
$message = M('message');
$emailCount = $message->count(); //数据一共多少条
$start = ($showPage - 1) * $mailListLength[0]['content'];
$offset = 0;
if ($emailCount - ($showPage - 1) * $mailListLength[0]['content'] > $mailListLength[0]['content'])
{
$offset = $mailListLength[0]['content'];
}
else
{
$offset = $emailCount - ($showPage - 1) * $mailListLength[0]['content'];
}
// echo $start . "===" . ($emailCount-1) . "===" . $offset;
$maildata = $message->order('date desc')->limit($start . "," . $offset)->select();
$this->initMailList($maildata, $start, $offset, $emailCount);
}
}
//查询倒序 第N个数据的id号 参数num 是邮件在所有邮件中的倒序位置
function findIdforNum($num)
{
$message = M('message');
$id = $message->order('date desc')->limit(($num - 1) . "," . $num)->field('id')->select();
return $id[0]['id'];
}
function mailLableRead()
{
if (!$this->isPost()) //不是post提交
{
;
}
else {
$mailId = $this->_post('mailId');
// $message = M('message');
$id = $this->findIdforNum($mailId);
$message = M('message');
$data['isRead'] = 1;
if (false == $message->where("id = " . $id)->save($data))
{
echo 0;
}
else {
echo "<div style='position:relative; top: 9px; float:left;width:15px; height:15px; margin:0 10px 0 0; border-radius:3px;' class='Yread' id='isread" . $mailId . "'>" . " " ."</div>";
}
}
}
function mailLableFlag()
{
if (!$this->isPost()) //不是post提交
{
;
}
else {
$flagId = $this->_post('flagId');
$isFlag = $this->_post('isFlag');
$message = M('message');
$id = $this->findIdforNum($flagId);
// echo $id;
if ($isFlag == 1) //为真, 就标记
{
$data['isFlag'] = 1;
if (false == $message->where("id = " . $id)->save($data))
{
echo 0;
}
else { //成功
echo 1;
}
}
else // 取消标记
{
$data['isFlag'] = 0;
if (false == $message->where("id = " . $id)->save($data))
{
echo 0;
}
else { //成功
echo 1;
}
}
}
}
function mailLableDel()
{
if (!$this->isPost()) //不是post提交
{
;
}
else
{
$mailId = $this->_post('mailId').trim(); //邮箱的倒序排列
$start = $this->_post('start').trim(); //是哪一页的第1个的启示id
$end = $this->_post('end').trim(); //是哪一页的第最一个id
$pagelable = $this->_post('pagelable').trim(); //分页显示的数据
$id = $this->findIdforNum($mailId);
$message = M('message');
$mailListLength = $this->getMailListLength();
if (false == $message->where("id = " . $id)->delete())
{
echo 0;
}
else
{
$emailCount = $message->count(); //数据一共多少条
if ($pagelable != 0) //如果等于 0 , 就意味着只有一页, 不等于0,就是超过一页
{
$lenPage = (int)substr($pagelable, stripos($pagelable,"/") + 1);
$showPage = (int)substr($pagelable, stripos($pagelable,"/") - 1, 1);
if ($showPage == $lenPage) //显示等于长度,就是最后一页
{
if ($start == $end) //最后一页只有一条数据, 就向前翻一页
{
// echo "$start == $end";
//echo (($lenPage - 1) * $mailListLength[0]['content']) . '===' . $mailListLength[0]['content'];
$maildata = $message->order('date desc')->limit((($lenPage - 2) * $mailListLength[0]['content']). "," . $mailListLength[0]['content'])->select();
$this->initMailList($maildata, (($lenPage - 2) * $mailListLength[0]['content']), $mailListLength[0]['content'], $emailCount);
}
else if ($start < $end) //不至一条
{
// echo (($lenPage - 1) * $mailListLength[0]['content']) . "====" . ($emailCount - ($lenPage - 1) * $mailListLength[0]['content']);
$maildata = $message->order('date desc')->limit((($lenPage - 1) * $mailListLength[0]['content']). ",". ($emailCount - ($lenPage - 1) * $mailListLength[0]['content']))->select();
$this->initMailList($maildata, ($lenPage - 1) * $mailListLength[0]['content'], $emailCount - ($lenPage - 1) * $mailListLength[0]['content'], $emailCount);
}
}
else if ($showPage < $lenPage) //显示 小于 总长度
{
if ($emailCount <= $mailListLength[0]['content']) //当只有2也的时候, 依然存在, 删除之后总数小于等于列表长度的可能
{
$maildata = $message->order('date desc')->select();
$this->initMailList($maildata, 0, $emailCount, $emailCount);
}
else
{
$maildata = $message->order('date desc')->limit((($showPage - 1) * $mailListLength[0]['content']). "," . $mailListLength[0]['content'])->select();
$this->initMailList($maildata, (($showPage - 1) * $mailListLength[0]['content']), $mailListLength[0]['content'], $emailCount);
}
}
}
else //$pagelable=0, 意味着就一页
{
if ($emailCount == 0) //邮箱空
{
echo "";
}
else if ($emailCount <= $mailListLength[0]['content'])
{
$maildata = $message->order('date desc')->select();
$this->initMailList($maildata, 0, $emailCount, $emailCount);
}
else
{
$maildata = $message->order('date desc')->limit(0 . "," . $mailListLength[0]['content'])->select();
$this->initMailList($maildata, 0, $mailListLength[0]['content'], $emailCount );
}
}
}
}
}
function mailPageChangeShow()
{
if (!$this->isPost()) //不是post提交
{
;
}
else
{
$mailId = (int)$this->_post('mailId').trim(); //邮箱的倒序排列
$mailListLength = $this->getMailListLength();
$message = M('message');
$emailCount = $message->count();
$arruser = $message->order('date desc')->limit($mailListLength[0]['content'])->select(); //取出所有数据
//这里总数减一,是因为邮箱第一个数据不做有效数据.
$maillength = ceil($emailCount / $mailListLength[0]['content']); //计算一共的页数, 用信息的条数, 除以每一页的条数.
$mailShow = ceil($mailId / $mailListLength[0]['content']); //计算一共的页数, 用信息的条数, 除以每一页的条数.
if ($emailCount <= $mailListLength[0]['content']) //只有一页
{
echo 0; //让page跳转隐藏, 因为只有一页
return;
}
else if ($maillength < $mailShow)
{
$mailShow = $maillength;
}
echo $mailShow . "/" . $maillength . "<lable style='font-size:10px;'>∨</lable>";
}
}
function mailDelPageChangeShow()
{
if (!$this->isPost()) //不是post提交
{
;
}
else
{
$mailId = (int)$this->_post('mailId').trim() - 1; //邮箱的倒序排列
$mailListLength = $this->getMailListLength();
$message = M('message');
$emailCount = $message->count();
$maillength = ceil($emailCount / $mailListLength[0]['content']); //计算一共的页数, 用信息的条数, 除以每一页的条数.
// echo $emailCount . " === " .$maillength;
if ($mailId > $emailCount)
{
$mailId -= $mailListLength[0]['content'];
}
$mailShow = ceil($mailId / $mailListLength[0]['content']); //计算一共的页数, 用信息的条数, 除以每一页的条数.
if ($mailId == 0)
{
$mailShow = 1;
}
if ($emailCount <= $mailListLength[0]['content']) //只有一页
{
echo '0'; //让page跳转隐藏, 因为只有一页
return;
}
else if ($maillength > $mailShow)
{
$mailShow = $maillength;
}
echo $mailShow . "/" . $maillength . "<lable style='font-size:10px;'>∨</lable>";
}
}
function delMailButton()
{
if (!$this->isPost()) //不是post提交
{
;
}
else
{
$pagelable = $this->_post('pagelable').trim(); //邮箱的倒序排列
$end = (int)$this->_post('end').trim(); //邮箱的倒序排列
$singal = $this->_post('singal'); //删除的数组标号
$start = (int)$this->_post('start'); //邮箱列表第一个ID标号
$message = M('message');
$signalLabel = false;
$deleteNum = 0;
for ($k = $start, $i = 0; $i < strlen($singal); $i++, $k++) //顺序删除,被选择的邮件
{
$id = $this->findIdforNum($k); //获取邮件真实id
if ($singal[$i] == '1') //如是1, 就删除
{
$idArr[$i] = $id;
$signalLabel = ture;
$deleteNum++;
}
}
if($signalLabel == false) //没有要删除的数据
{
echo "没有要删除的邮件";
return;
}
$where['id'] = array('in', $idArr);
// var_dump($where);
if (false == $message->where($where)->delete())
{
echo false;
return;
}
else
{
$mailListLength = $this->getMailListLength();
$emailCount = $message->count(); //数据一共多少条
if ($pagelable != 0) //如果等于 0 , 就意味着只有一页, 不等于0,就是超过一页
{
$lenPage = (int)substr($pagelable, stripos($pagelable,"/") + 1);
$showPage = (int)substr($pagelable, stripos($pagelable,"/") - 1, 1);
if ($showPage == $lenPage) //显示等于长度,就是最后一页
{
if (($start - 1 + $deleteNum) == $end) //最后一页全部删除, 就向前翻一页
{
$maildata = $message->order('date desc')->limit((($lenPage - 2) * $mailListLength[0]['content']). "," . $mailListLength[0]['content'])->select();
$this->initMailList($maildata, (($lenPage - 2) * $mailListLength[0]['content']), $mailListLength[0]['content'], $emailCount);
}
else if (($start - 1 + $deleteNum) < $end) //最后一页没有全部删除
{
$maildata = $message->order('date desc')->limit((($lenPage - 1) * $mailListLength[0]['content']). ",". ($emailCount - ($lenPage - 1) * $mailListLength[0]['content']))->select();
$this->initMailList($maildata, ($lenPage - 1) * $mailListLength[0]['content'], $emailCount - ($lenPage - 1) * $mailListLength[0]['content'], $emailCount);
}
}
else if ($showPage < $lenPage) //显示小于总长度
{
//如果剩余的数据多过这一页,就全部添加完整,
if (($start - 1 + $mailListLength[0]['content']) <= $emailCount)
{
// echo "如果剩余的数据多过这一页,就全部添加完整,";
$maildata = $message->order('date desc')->limit((($showPage - 1) * $mailListLength[0]['content']). "," . $mailListLength[0]['content'])->select();
$this->initMailList($maildata, (($showPage - 1) * $mailListLength[0]['content']), $mailListLength[0]['content'], $emailCount);
}
else //如果剩余的数据,不足添加完整的一页,就把剩下的数据输出
{
// echo "如果剩余的数据,不足添加完整的一页,就把剩下的数据输出";
$maildata = $message->order('date desc')->limit((($showPage - 1) * $mailListLength[0]['content']). "," . ($emailCount - ($start - 1)))->select();
$this->initMailList($maildata, (($showPage - 1) * $mailListLength[0]['content']), ($emailCount - ($start - 1)), $emailCount);
}
}
}
else //$pagelable=0, 意味着就一页
{
if ($emailCount == 0) //邮箱空
{
echo "没有邮件了";
}
else if ($emailCount <= $mailListLength[0]['content'])
{
$maildata = $message->order('date desc')->select();
$this->initMailList($maildata, 0, $emailCount, $emailCount);
}
else
{
$maildata = $message->order('date desc')->limit(0 . "," . $mailListLength[0]['content'])->select();
$this->initMailList($maildata, 0, $mailListLength[0]['content'], $emailCount );
}
}
}
}
}
function getMailListLength()
{
$mail = M('sysinfo');
$where['parameter'] = 'mailPageNum';
$mailListLength = $mail->where($where)->field('content')->select(); //获取系统设置里面单页显示的信息条数
return $mailListLength;
}
function markIsReadMail() //标记邮件为未读
{
if (!$this->isPost()) //不是post提交
{
;
}
else
{
$funArgument = (int)$this->_post('funArgument'); //修改已读或者未读的数据
$start = (int)$this->_post('start').trim(); //邮箱的第一个id
$end = (int)$this->_post('end').trim(); //邮箱的最后一个id
$singal = $this->_post('singal').trim(); //邮箱的倒序排列
$mailListLength = $this->getMailListLength(); //获取一页的长度
$message = M('message');
$signalLabel = false; //标记位, 如果为真,就执行
$markNum = 0;
for ($k = $start, $i = 0; $i < strlen($singal); $i++, $k++) //顺序删除,被选择的邮件
{
$id = $this->findIdforNum($k); //获取邮件真实id
if ($singal[$i] == '1') //如是1, 就标记为未读
{
$idArr[$i] = $id;
$signalLabel = ture;
$deleteNum++;
}
}
if($signalLabel == false) //没有要更新的数据
{
echo "没有要标记的邮件";
echo false;
return;
}
$where['id'] = array('in', $idArr);
$data['isRead'] = $funArgument;
if (false == $message->where($where)->save($data))
{
echo false;
return;
}
else
{
$start -= 1;
// echo $start . "=====" .$end;
$maildata = $message->order('date desc')->limit($start. "," . $end)->select();
//var_dump($maildata);
$this->initMailList($maildata, $start, $mailListLength[0]['content'], $emailCount);
}
}
}
function markFlagMail()
{
if (!$this->isPost()) //不是post提交
{
;
}
else
{
$funArgument = (int)$this->_post('funArgument'); //修改已读或者未读的数据
$start = (int)$this->_post('start').trim(); //邮箱的第一个id
$end = (int)$this->_post('end').trim(); //邮箱的最后一个id
$singal = $this->_post('singal').trim(); //邮箱的倒序排列
$mailListLength = $this->getMailListLength(); //获取一页的长度
$message = M('message');
$signalLabel = false; //标记位, 如果为真,就执行
$markNum = 0;
for ($k = $start, $i = 0; $i < strlen($singal); $i++, $k++) //顺序删除,被选择的邮件
{
$id = $this->findIdforNum($k); //获取邮件真实id
if ($singal[$i] == '1') //如是1, 就标记为未读
{
$idArr[$i] = $id;
$signalLabel = ture;
$deleteNum++;
}
}
if($signalLabel == false) //没有要更新的数据
{
// echo "没有要标记的邮件";
// echo false;
return;
}
$where['id'] = array('in', $idArr);
$data['isFlag'] = $funArgument;
if (false == $message->where($where)->save($data))
{
// echo 'false';
return;
}
else
{
// echo "true";
$start -= 1;
$maildata = $message->order('date desc')->limit($start. "," . $end)->select();
$this->initMailList($maildata, $start, $end, $emailCount);
}
}
}
//打开邮箱
function mailOpenMail()
{
$start = (int)$this->_get('start').trim(); //邮箱的第一个id
$end = (int)$this->_get('end').trim(); //邮箱的最后一个id
$mailId = (int)$this->_get('mailId').trim(); //邮箱的最后一个id
$isRead = (int)$this->_get('isRead').trim(); //邮箱的最后一个id
$message = M('message');
$id = $this->findIdforNum($mailId); //获取邮件真实id
if ($isRead == 1)
{
$data['isRead'] = 1;
$where['id'] = $id;
if (false == $message->where($where)->save($data))
{
//echo "更新为可读失败";
return;
}
}
$data = $message->where('id='.$id)->select();
$sender = $data[0]['name'];
$time = date('Y-m-d H:i:s', $data[0]['date']);
$content = $data[0]['message'];
if ($data[0]['email'] == '')
{
$email = " ";
}
else
{
$email = "《" . $data[0]['email'] . "》";
}
$this->assign('sender', $sender);
$this->assign('time', $time);
$this->assign('email', $email);
$this->assign('content', $content);
$this->display('mailShow');
}
}
?>