Ticket #187 增加了评审专家管理功能

email发送部分不能正常工作,尚未解决
This commit is contained in:
Li Jianxuan 2011-09-28 07:24:09 +00:00
parent d7d3270699
commit 900f321e33
4 changed files with 390 additions and 21 deletions

View File

@ -1,21 +1,206 @@
<?php
class Admin_ReviewController extends Zend_Controller_Action
{
function preDispatch()
{
$this->db=Zend_Registry::get('db');
$this->view->config = Zend_Registry::get('config');
$this->messenger=$this->_helper->getHelper('FlashMessenger');
$this->view->messages = $this->messenger->getMessages();
}
function postDispatch()
{
$this->view->messages = $this->messenger->getMessages();
}
function indexAction()
{
}//indexAction
}
<?php
class Admin_ReviewController extends Zend_Controller_Action
{
function preDispatch()
{
$this->db=Zend_Registry::get('db');
$this->view->config = Zend_Registry::get('config');
$this->messenger=$this->_helper->getHelper('FlashMessenger');
$this->view->messages = $this->messenger->getMessages();
}
function postDispatch()
{
$this->view->messages = $this->messenger->getMessages();
}
function indexAction()
{
}//indexAction
function acceptAction()
{
}//acceptAction 待评审的元数据
function expertsAction()
{
$search = $this->_request->getParam('search');
$keyword= $this->_request->getParam('keyword');
$submit = $this->_request->getParam('submit');
$edit = $this->_request->getParam('edit');
$del = $this->_request->getParam('del');
$add = $this->_request->getParam('add');
if($add)
{
if(!empty($submit))
{
foreach($_POST as $k=>$v)
{
$$k=$v;
}
$speciality = $_POST['speciality'];
$chars = array(
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
"w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
"3", "4", "5", "6", "7", "8", "9"
);
$charsLen = count($chars) - 1;
shuffle($chars);
$output = "";
for ($i=0; $i<8; $i++)
{
$output .= $chars[mt_rand(0, $charsLen)];
}
$password=$output;
$testsql="select id from users where username='$username' or email='$email'";
$re=$this->db->query($testsql);
$test=$re->fetch();
if(!empty($test['id']))
{
$this->messenger->addMessage('用户名或邮箱重复');
$this->_redirect("/admin/review/experts");
}
else
{
$data = array(
'username' => $username,
'realname' => $realname,
'email' => $email,
'unit' => $unit,
'address' => $address,
'phone' => $phone,
'project' => $project,
'password' => md5($password)
);
if($this->db->insert('users',$data))
{
$mail=new WestdcMailer($this->view->config->smtp);
$body="尊敬的西部数据中心用户:
您已经成功注册,请妥善保管您的账号信息
用户名:$username
密码: $password
感谢您的注册
西部数据中心服务组";
$body.="";
$mail->setBodyText($body);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->addTo($email);
$mail->setSubject('欢迎注册成为西部数据中心用户');
$mail->send();
$sql="select id from users where username='{$data['username']}'";
$re=$this->db->query($sql);
$row = $re->fetch();
$sql="insert into mdexperts (id,speciality) values ('{$row['id']}','$speciality')";
if($this->db->exec($sql)>0)
{
$this->messenger->addMessage('成功添加评审专家');
$this->_redirect("/admin/review/experts");
}
}
}
}
else
{
$this->_helper->viewRenderer('expertsadd');
}
}
if($del>0)
{
$sql="delete from mdexperts where id='$del'";
if($this->db->exec($sql)>0)
{
$this->messenger->addMessage('删除成功!');
$this->_redirect('/admin/review/experts');
}
}
if($edit>0)
{
if(!empty($submit))
{
$speciality = $this->_request->getParam('speciality');
$sql = "update mdexperts set speciality='$speciality',ts_modified='".date("Y-m-d H:i:s",time())."' where id='$edit'";
if($this->db->exec($sql)>0)
{
$this->messenger->addMessage('编辑成功!');
$this->_redirect('/admin/review/experts');
}
}
else
{
$sql = "select m.*,m.id as mid,u.* from mdexperts m left join users u on u.id=m.id
where m.id='$edit'";
$re = $this->db->query($sql);
$row = $re->fetch();
$this->view->infos = $row;
$this->view->id=$edit;
$this->_helper->viewRenderer('expertsedit');
}
}//编辑
if($search)
{
$sql = "select m.*,m.id as mid,u.* from mdexperts m left join users u on u.id=m.id
where u.realname like '%$keyword%' or m.speciality like '%$keyword%' or u.unit like '%$keyword%'";
$re = $this->db->query($sql);
$rows = $re->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage($this->view->config->page->max);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}//搜索
else
{
$sql="select m.*,m.id as mid,u.* from mdexperts m left join users u on u.id=m.id";
$re = $this->db->query($sql);
$rows = $re->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage($this->view->config->page->max);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$this->view->paginator=$paginator;
}//列表
}//expertsAction 专家库
}

View File

@ -0,0 +1,70 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('元数据评审');
$this->breadcrumb()->setSeparator(' > ');
$this->headScript()->appendFile('/js/jquery-1.6.4.min.js');
?>
<div id="divContent">
<div id="leftPanel">
<?= $this->partial('review/left.phtml'); ?>
</div>
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<div id="rightPanel">
<div class="right_title">评审专家</div>
<div><a href="experts/add/1">添加评审专家</a></div>
<div class="search">
<form action="" method="get">
<input type="hidden" name="search" value='1' />
<ul>
<li><label>搜索关键字</label><input type="text" name="keyword" value="<?php echo $this->keyword; ?>" /></li>
<li><input type="submit" class="searchbtn" value="搜索" /></li>
</ul>
</form>
</div><!-- search DIV -->
<table>
<tr style="color:#FFF;background:#0a3e68;line-height:30px;">
<td width='150'>姓名</td>
<td width='350'>特长</td>
<td width='150'>操作</td>
</tr>
<?php if (count($this->paginator)): ?>
<?php $autoindex=0;?>
<?php foreach ($this->paginator as $item): ?>
<?php $autoindex++;?>
<tr <?php if($autoindex%2 == 0) echo 'bgcolor="#CCCCCC"'; else echo 'bgcolor="#FFFFFF"'; ?>>
<td><img src="/images/user.gif" /><a href='/admin/user/show/id/<?= $item['id'];?>'><?= $item['realname']?></a></td>
<td><?php echo $item['speciality']; ?></td>
<td>
<a href='/admin/review/experts/edit/<?php echo $item['mid'];?>'>更改</a>
<a href='/admin/review/experts/del/<?php echo $item['mid'];?>' onclick="return confirm('是否确定删除该评审专家')">删除</a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</table>
<div style="width:50%;text-align:left;">
<?= $this->paginator; ?>
</div>
</div>
</div>

View File

@ -0,0 +1,66 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('元数据评审');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="divContent">
<div id="leftPanel">
<?= $this->partial('review/left.phtml'); ?>
</div>
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<div id="rightPanel">
<div class="right_title">评审专家</div>
<form method="post">
<input type="hidden" name="submit" value="1" />
<input type="hidden" name="add" value="1" />
<table>
<tr>
<td width="100">用户名</td><td width="300"><input type="text" name="username" /></td>
</tr>
<tr>
<td width="100">真实姓名</td><td width="300"><input type="text" name="realname" /></td>
</tr>
<tr>
<td width="100">电子邮箱</td><td width="300"><input type="text" name="email" /></td>
</tr>
<tr>
<td width="100">单位</td><td width="300"><input type="text" name="unit" /></td>
</tr>
<tr>
<td width="100">地址</td><td width="300"><input type="text" name="address" /></td>
</tr>
<tr>
<td width="100">项目</td><td width="300"><textarea name="project" style="width:300px;height:100px;"></textarea></td>
</tr>
<tr>
<td width="100">电话</td><td width="300"><input type="text" name="phone" /></td>
</tr>
<tr>
<td>特长</td><td><textarea name="speciality" style="width:300px;height:100px;"></textarea></td>
</tr>
</table>
<input type="submit" value="提交" />
</form>
</div>
</div>

View File

@ -0,0 +1,48 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('元数据评审');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="divContent">
<div id="leftPanel">
<?= $this->partial('review/left.phtml'); ?>
</div>
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<div id="rightPanel">
<div class="right_title">评审专家</div>
<form>
<input type="hidden" name="submit" value="1" />
<input type="hidden" name="edit" value="<?php echo $this->id;?>" />
<table>
<tr>
<td width="100">姓名</td><td width="300"><?php echo $this->infos['realname']; ?></td>
</tr>
<tr>
<td>特长</td><td><textarea name="speciality" style="width:300px;height:100px;"><?php echo $this->infos['speciality'];?></textarea></td>
</tr>
</table>
<input type="submit" value="提交" />
</form>
</div>
</div>