diff --git a/application/admin/controllers/HeiheController.php b/application/admin/controllers/HeiheController.php index 982d7323..be7a29da 100644 --- a/application/admin/controllers/HeiheController.php +++ b/application/admin/controllers/HeiheController.php @@ -119,9 +119,13 @@ class Admin_HeiheController extends Zend_Controller_Action $expert_name = $this->getArray($row['expert_name']); $expert_email = $this->getArray($row['expert_email']); + $expert_validation = $this->getArray($row['expert_validation']); + $expert_created = $this->getArray($row['expert_created']); $name_list = array(); $email_list = array(); + $validation_list = array(); + $created_list = array(); if(is_array($expert_name) && count($expert_name)>0) { @@ -144,16 +148,27 @@ class Admin_HeiheController extends Zend_Controller_Action $expert_name[] = $name; $expert_email[] = $email; + $code = substr(md5($email),5,12); + $expert_validation[] = $code; + $expert_created[] = date("Y-m-d H:i:s",time()); + $name_list = $this->mkArray($expert_name); $email_list = $this->mkArray($expert_email); + $validation_list = $this->mkArray($expert_validation); + $created_list = $this->mkArray($expert_created); - $update = array("expert_name"=>$name_list,"expert_email"=>$email_list); + $update = array( + "expert_name"=>$name_list, + "expert_email"=>$email_list, + "expert_validation"=>$validation_list, + "expert_created"=>$created_list + ); $where = "id=$pid"; if($this->db->update($projectTable,$update,$where)) { - $this->sendMailToExpert($email); + $this->sendMailToExpert($pid,$name,$email,$code); $this->jsonexit(array("msg"=>"专家邀请成功!","invited"=>1)); return true; }else{ @@ -200,12 +215,20 @@ class Admin_HeiheController extends Zend_Controller_Action $names = $this->getArray($row['expert_name']); $emails = $this->getArray($row['expert_email']); + $validations = $this->getArray($row['expert_validation']); + $created = $this->getArray($row['expert_created']); $experts = array(); foreach($names as $k=>$v) { - $experts[$k] = array("name"=>$names[$k],"email"=>$emails[$k]); + $experts[$k] = array( + "name"=>$names[$k], + "email"=>$emails[$k], + "validation"=>$validations[$k], + "created"=>$created[$k], + "url"=>$this->makeInviteLink($pid,$validations[$k]) + ); } $this->view->experts = $experts; @@ -223,10 +246,14 @@ class Admin_HeiheController extends Zend_Controller_Action unset($names[$del]); unset($emails[$del]); + unset($validations[$del]); + unset($created[$del]); $update = array( "expert_name"=>$this->mkArray($names), - "expert_email"=>$this->mkArray($emails) + "expert_email"=>$this->mkArray($emails), + "expert_validation"=>$this->mkArray($validations), + "expert_created"=>$this->mkArray($created), ); $where = "id=$pid"; @@ -309,55 +336,51 @@ class Admin_HeiheController extends Zend_Controller_Action } //发送邀请专家的邮件 - function sendMailToExpert($name,$email) + function sendMailToExpert($pid,$name,$email,$code) { - $http_base = "http://".$_SERVER ['HTTP_HOST']; - $code = substr(md5($email),5,12); - $url = $http_base."/heihe/projects/invite/".$code; - + $url = $this->makeInviteLink($pid,$code); + include_once("EmailText.php"); - $mailtp=new EmailText($this->db,"expert_invite",array( + $mailtp=new EmailText($this->db,"expert-invite",array( 'name' => $name, 'url' => $url, )); - //Email test code + /* $mail_config = array( 'ssl' => 'ssl', 'port' => 465, 'auth' => 'login', - 'username' => 'liujin834@gmail.com', - 'password' => 'hhagecysbgispqoz' + 'username' => 'la5c@qq.com', + 'password' => '' ); - $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $mail_config); + $transport = new Zend_Mail_Transport_Smtp('smtp.qq.com', $mail_config); Zend_Mail::setDefaultTransport($transport); $mail=new Zend_Mail(); - $body="aaa"; - $mail->setBodyText($body); - $mail->setFrom('liujin834@gmail.com','liujin834'); + $mail->setBodyText($mailtp->getBody()); + $mail->setFrom('la5c@qq.com','Jack'); $mail->addTo($email); - $mail->setSubject('数据跟踪专家邀请'); + $mail->setSubject($mailtp->getSubject()); $mail->send(); - - /* - include_once("EmailText.php"); - $mail=new WestdcMailer($this->view->config->smtp); - $mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); - $mailtp=new EmailText($this->db,"author-new",array( - 'user' => $row['realname'], - 'uuid' => $row['uuid'], - 'title'=> $row['title'], - 'email'=> $row['email'], - )); - $mail->setBodyText($mailtp->getBody()); - $mail->setSubject($mailtp->getSubject()); - $mail->addTo($this->debug_email); - $mail->send(); */ - } + $mail=new WestdcMailer($this->view->config->smtp); + $mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); + $mail->setBodyText($mailtp->getBody()); + $mail->setSubject($mailtp->getSubject()); + $mail->addTo($email); + $mail->send(); + }//发送邀请邮件 + + //生成邀请连接 + function makeInviteLink($pid,$code) + { + $http_base = "http://".$_SERVER ['HTTP_HOST']; + $url = $http_base."/heihe/projects/invite/".$code.'/pid/'.$pid; + return $url; + }//生成邀请连接 public function jsonexit($data){ $this->getResponse() diff --git a/application/admin/views/scripts/heihe/project-showexpert.phtml b/application/admin/views/scripts/heihe/project-showexpert.phtml index b78c2cef..450a64e2 100644 --- a/application/admin/views/scripts/heihe/project-showexpert.phtml +++ b/application/admin/views/scripts/heihe/project-showexpert.phtml @@ -24,7 +24,14 @@ if(!empty($this->error)) experts as $k=>$v) { - echo '
'.$v['name'] ." - ".
+ $v['email'].' - '.
+ $v['validation'].' - '.
+ str_replace("\"","",$v['created']) .'
+
邀请链接:'.$v['url'].'
+