@ -20,17 +20,19 @@ class Author extends CI_Controller {
$this->load->model('Infoauthors_model');
$this->load->model('InfoSMS_model');
}
public function index($loadexcel = 'notexcel', $page = 1) {
$this->load->library('accesscheck');
$this->accesscheck->check_access();
//获取任务状态
$request_form = 'get';
if($loadexcel=='loadexcel')$request_form='post';
if ($loadexcel == 'loadexcel')
$request_form = 'post';
$t_status = $this->input->$request_form('taskstatus');
if($t_status=="-")$t_status=false;
if ($t_status == "-")
$t_status = false;
//根据任务状态加载视图模板
switch (trim($t_status))
{
switch (trim($t_status)) {
case 'edit':
$this->in_edit_tasks($loadexcel);
break;
@ -167,15 +169,21 @@ class Author extends CI_Controller {
public function _get_tasks_list($t_status = false, $loadexcel = false, $page = false, $pageurl = false) {
//异步获取任务列表时数据提交方式为get, 导出数据时则为post
$request_form = 'get';
if($loadexcel=='loadexcel')$request_form='post';
if ($loadexcel == 'loadexcel')
$request_form = 'post';
//任务过滤参数初始化
$t_a_id = $t_td_type = $start_date = $tasktitle = false;
$end_date = date('Y-m-d');
if($this->input->$request_form('author') & & $this->input->$request_form('author')!=0) $t_a_id=$this->input->$request_form('author');
if($this->input->$request_form('tasktype') & & $this->input->$request_form('tasktype')!='-') $t_td_type=$this->input->$request_form('tasktype');
if($this->input->$request_form('startdate') & & $this->input->$request_form('startdate')!='') $start_date=$this->input->$request_form('startdate');
if($this->input->$request_form('enddate') & & $this->input->$request_form('enddate')!='') $end_date=$this->input->$request_form('enddate');
if($this->input->$request_form('tasktitle') & & $this->input->$request_form('tasktitle')!='') $tasktitle=$this->input->$request_form('tasktitle');
if ($this->input->$request_form('author') & & $this->input->$request_form('author') != 0)
$t_a_id = $this->input->$request_form('author');
if ($this->input->$request_form('tasktype') & & $this->input->$request_form('tasktype') != '-')
$t_td_type = $this->input->$request_form('tasktype');
if ($this->input->$request_form('startdate') & & $this->input->$request_form('startdate') != '')
$start_date = $this->input->$request_form('startdate');
if ($this->input->$request_form('enddate') & & $this->input->$request_form('enddate') != '')
$end_date = $this->input->$request_form('enddate');
if ($this->input->$request_form('tasktitle') & & $this->input->$request_form('tasktitle') != '')
$tasktitle = $this->input->$request_form('tasktitle');
$admin_info = $this->session->userdata('session_admin');
//获取任务列表
if ($loadexcel == 'loadexcel') {
@ -193,12 +201,14 @@ class Author extends CI_Controller {
//获取任务列表
$task_id_str = 0;
if($page) $page_task=array_slice($page_task,$pages['pageSize']*($page-1),$pages['pageSize']);
if ($page)
$page_task = array_slice($page_task, $pages['pageSize'] * ($page - 1), $pages['pageSize']);
foreach ($page_task as $v) {
$task_id_str.=',' . $v->t_id;
}
$flag = false;
if($t_status=='reviewed') $flag=TRUE;
if ($t_status == 'reviewed')
$flag = TRUE;
$task_list['task_list'] = $this->Infotasks_model->get_list_by_taskids($task_id_str, $flag);
return $task_list;
}
@ -272,8 +282,7 @@ class Author extends CI_Controller {
return false;
} else {
$flag = false;
if ($this->input->post('ispublish')==1)
{
if ($this->input->post('ispublish') == 1) {
$ispublished = $this->publish_task($task);
$flag = $ispublished;
//发布失败
@ -286,12 +295,12 @@ class Author extends CI_Controller {
$this->Infotasks_model->reviwed($t_id, $reviewed, $t_rating, $t_rating_total);
//保存审核字数和金额
if($reviewed=='reviewed')
{
if ($reviewed == 'reviewed') {
$this->Infotaskarticles_model->update_review($t_id, $this->input->post('ta_count'), $this->input->post('ta_charge'));
}
$msg = '';
if($flag!=false) $msg = ' < a target = "_blank" href = "'.$flag.'" > 跳转到信息平台发布页< / a > ';
if ($flag != false)
$msg = ' < a target = "_blank" href = "' . $flag . '" > 跳转到信息平台发布页< / a > ';
$data[] = array('name' => 'ok_modal', 'value' => $this->lang->line('task_review_submit') . $msg);
$data[] = array('name' => 'ok_go', 'value' => site_url('author/in_review_tasks'));
echo json_encode($data);
@ -300,12 +309,9 @@ class Author extends CI_Controller {
$admin_info = $this->session->userdata('session_admin');
$author = $this->Infoauthors_model->detail_by_id($task->t_a_id);
//通过审核
if($reviewed=='reviewed')
{
if ($reviewed == 'reviewed') {
$this->InfoSMS_model->send_mail('gavin', 'gavin@chinahighlights.com', $author->a_name, $author->a_email, sprintf($this->lang->line('author_email_review_task_success_subject'), $task->t_title), $this->lang->line('author_email_review_task_success_body'));
}
else
{
} else {
$this->Infotasks_model->reviwed($t_id, 'unreviewed', $t_rating, $t_rating_total);
$this->InfoSMS_model->send_mail('gavin', 'gavin@chinahighlights.com', $author->a_name, $author->a_email, sprintf($this->lang->line('author_email_review_task_failed_subject'), $task->t_title), $this->lang->line('author_email_review_task_failed_body'));
}
@ -372,7 +378,8 @@ class Author extends CI_Controller {
$task_last_version = $this->Infotaskarticles_model->version_last($task->t_id);
$information = false;
if (!empty($task_last_version->ta_ic_id)) $information = $this->Information_model->detail_by_ic_id($task_last_version->ta_ic_id);
if (!empty($task_last_version->ta_ic_id))
$information = $this->Information_model->detail_by_ic_id($task_last_version->ta_ic_id);
if (empty($task_last_version->ta_ic_id) or ! $information) {
$selected_name = $this->input->post('selected_is_ic_name');
$is_id = mb_substr($selected_name, strpos($selected_name, '{') + 1, -1);
@ -444,9 +451,7 @@ class Author extends CI_Controller {
//设置月度活跃作者
if ($this->input->post('isset_active_author') == 0) {
$this->Infotasks_model->set_active_author(
$this->input->post('active_t_id'),
date('Y-m-d H:i:s'),
$this->input->post('active_ta_id')
$this->input->post('active_t_id'), date('Y-m-d H:i:s'), $this->input->post('active_ta_id')
);
}
$data[] = array('name' => 'ok', 'value' => $this->lang->line('task_complete_success'));
@ -510,8 +515,7 @@ class Author extends CI_Controller {
//获取该任务审核次数并计算奖励的百分比
$review_count = $this->Infotaskarticles_model->get_review_count($t_id);
switch ($review_count)
{
switch ($review_count) {
case 1:
$data['discount'] = array('1.1', '110%');
break;
@ -538,14 +542,7 @@ class Author extends CI_Controller {
//修改任务详细信息
public function save_task_datailinfo() {
$result = $this->Infotaskarticles_model->update(
$this->input->post('ta_id'),
$this->input->post('ta_title'),
$this->input->post('ta_content'),
$this->input->post('ta_summary'),
$this->input->post('ta_seo_title'),
$this->input->post('ta_seo_description'),
$this->input->post('ta_seo_keywords'),
$this->input->post('ta_photo'));
$this->input->post('ta_id'), $this->input->post('ta_title'), $this->input->post('ta_content'), $this->input->post('ta_summary'), $this->input->post('ta_seo_title'), $this->input->post('ta_seo_description'), $this->input->post('ta_seo_keywords'), $this->input->post('ta_photo'));
if ($result) {
$data[] = array('name' => 'ok', 'value' => 'success!');
} else {
@ -564,16 +561,14 @@ class Author extends CI_Controller {
$admin_info = $this->session->userdata('session_admin');
$author = $this->Infoauthors_model->detail_by_id($t_a_id);
if ($t_status == 'edit' & & $this->Infotasks_model->reviwed($t_id, $t_status)) {
if(!empty($author))
{
if (!empty($author)) {
$this->InfoSMS_model->add('task', $t_id, $t_a_id, $admin_info['OPI_Code'], 'Your proposal has been approved! ');
$this->InfoSMS_model->send_mail('gavin', 'gavin@chinahighlights.com', $author->a_name, $author->a_email, 'Your proposal has been approved.', 'Your proposal has been approved! Please log in at < a href = "http://a.cdnch.com/author.php" target = "_blank" > http://a.cdnch.com/author.php< / a > ');
}
$data[] = array('name' => 'ok', 'value' => 'success');
} elseif ($t_status == 'refuse' & & $this->Infotasks_model->reviwed($t_id, $t_status)) {
//如果指定用户则发送邮件通知
if(!empty($author))
{
if (!empty($author)) {
$this->InfoSMS_model->add('task', $t_id, $t_a_id, $admin_info['OPI_Code'], $refuse_msg);
$this->InfoSMS_model->send_mail('gavin', 'gavin@chinahighlights.com', $author->a_name, $author->a_email, 'Your proposal has been rejected.', 'Your proposal has been rejected: ' . $refuse_msg . ' Please log in at < a href = "http://a.cdnch.com/author.php" target = "_blank" > http://a.cdnch.com/author.php< / a > ');
}
@ -601,25 +596,14 @@ class Author extends CI_Controller {
//$t_id 查找一次任务详细,用来判断当前用户是否有权限修改,暂时省略
$this->Infotasks_model->update(
$t_id,
$this->input->post('t_title'),
$this->input->post('t_content'),
$this->input->post('t_a_id'),
$this->input->post('t_td_type'),
$this->input->post('t_expires')
$t_id, $this->input->post('t_title'), $this->input->post('t_content'), $this->input->post('t_a_id'), $this->input->post('t_td_type'), $this->input->post('t_expires')
);
$data[] = array('name' => 'ok', 'value' => $this->lang->line('task_success_submit'));
echo json_encode($data);
} else {
$admin_info = $this->session->userdata('session_admin');
$this->Infotasks_model->add(
$this->input->post('t_title'),
$this->input->post('t_content'),
$this->input->post('t_a_id'),
$admin_info['OPI_Code'],
$this->input->post('t_td_type'),
$this->input->post('t_expires'),
$this->config->item('site_code')
$this->input->post('t_title'), $this->input->post('t_content'), $this->input->post('t_a_id'), $admin_info['OPI_Code'], $this->input->post('t_td_type'), $this->input->post('t_expires'), $this->config->item('site_code')
);
//新建
$is_id = $this->input->post('is_id');
@ -641,7 +625,8 @@ class Author extends CI_Controller {
add_meta($this->Infotasks_model->insert_id, 'meta_author_related_info', $meta_related_info);
}
if(empty($information->ic_summary))$information->ic_summary='';
if (empty($information->ic_summary))
$information->ic_summary = '';
$this->Infotaskarticles_model->add($this->Infotasks_model->insert_id, $information->ic_id, $information->ic_title
, $information->ic_content, $information->ic_summary, $information->ic_seo_title, $information->ic_seo_description
, $information->ic_seo_keywords, $information->ic_photo);
@ -659,17 +644,29 @@ class Author extends CI_Controller {
}
//如果指定用户则发送邮件通知
$t_a_id = $this->input->post('t_a_id');
$author=$this->Infoauthors_model->detail_by_id($t_a_id);
if(!empty($author))
{
$this->InfoSMS_model->send_mail('gavin', 'gavin@chinahighlights.com', $author->a_name, $author->a_email, sprintf($this->lang->line('author_email_new_task_subject'),$this->input->post('t_title')), $this->lang->line('author_email_new_task_body'));
}else{
//给所有作者发送一封邮件
//所有作者
$author_list = $this->Infoauthors_model->active_list();
switch ($t_a_id) {
case 0://cht所有用户
foreach ($author_list as $a) {
if ($a->a_sitecode == 'cht' || empty($a->a_sitecode)) {
$this->InfoSMS_model->send_mail('gavin', 'gavin@chinahighlights.com', $a->a_name, $a->a_email, sprintf($this->lang->line('author_email_new_task_subject'), $this->input->post('t_title')), $this->lang->line('author_email_new_task_body2'));
}
}
break;
case -1://ah所有用户
foreach ($author_list as $a) {
if ($a->a_sitecode == 'ah') {
$this->InfoSMS_model->send_mail('gavin', 'gavin@chinahighlights.com', $a->a_name, $a->a_email, sprintf($this->lang->line('author_email_new_task_subject'), $this->input->post('t_title')), $this->lang->line('author_email_new_task_body2'));
}
}
break;
default://指定用户
$author = $this->Infoauthors_model->detail_by_id($t_a_id);
if (!empty($author)) {
$this->InfoSMS_model->send_mail('gavin', 'gavin@chinahighlights.com', $author->a_name, $author->a_email, sprintf($this->lang->line('author_email_new_task_subject'), $this->input->post('t_title')), $this->lang->line('author_email_new_task_body'));
}
}
$data[] = array('name' => 'ok', 'value' => $this->lang->line('task_success_submit'));
$data[] = array('name' => 'ok_go', 'value' => site_url('author'));
@ -734,8 +731,7 @@ class Author extends CI_Controller {
echo json_encode($data);
$admin_info = $this->session->userdata('session_admin');
$author = $this->Infoauthors_model->detail_by_id($task->t_a_id);
if(!empty($author))
{
if (!empty($author)) {
$this->InfoSMS_model->send_mail($admin_info['OPI_Name'], $admin_info['OPI_Email'], $author->a_name, $author->a_email, sprintf($this->lang->line('author_email_message_subject'), $task->t_title), $this->lang->line('author_email_message_body'));
}
return true;
@ -756,8 +752,7 @@ class Author extends CI_Controller {
}
//编辑作者资料
public function profile_submit()
{
public function profile_submit() {
$a_id = $this->input->post('a_id');
if (empty($a_id)) {
show_404();
@ -767,18 +762,14 @@ class Author extends CI_Controller {
$this->form_validation->set_rules('a_name', 'lang:signup_a_name', 'required');
$this->form_validation->set_rules('a_bank', 'lang:a_bank', 'required');
$this->form_validation->set_rules('a_bank_card', 'lang:a_bank_card', 'required');
if ($this->form_validation->run() == FALSE)
{
if ($this->form_validation->run() == FALSE) {
$data = array();
foreach ($this->form_validation->_error_array as $key => $value)
{
foreach ($this->form_validation->_error_array as $key => $value) {
$data[] = array('name' => $key, 'value' => $value);
}
echo json_encode($data);
return FALSE;
}
else
{
} else {
//头像处理
$a_photo = $this->input->post('a_photo');
if ($this->input->post('profile_url') != '') {
@ -787,7 +778,8 @@ class Author extends CI_Controller {
$profile_array = explode('.', $profile_url);
$profile_ext = 'jpg'; //end($profile_array);
$new_profile = $profile_file_path . '/profile_' . $this->input->post('a_email') . '.' . $profile_ext;
if(file_exists($new_profile))unlink($new_profile);
if (file_exists($new_profile))
unlink($new_profile);
rename($profile_file_path . '/' . $profile_url, $new_profile);
rename($profile_file_path . '/' . str_replace('_thumb', '', $profile_url), $profile_file_path . '/profile_' . $this->input->post('a_email') . '_org.' . $profile_ext);
$a_photo = 'profile_' . $this->input->post('a_email') . '.' . $profile_ext;
@ -800,17 +792,14 @@ class Author extends CI_Controller {
$file_array = explode('.', $a_id_file);
$ext = 'jpg'; //end($file_array);
$new_file = $ID_file_path . '/id_card_' . $this->input->post('a_email') . '.' . $ext;
if(file_exists($new_file))unlink($new_file);
if (file_exists($new_file))
unlink($new_file);
rename($ID_file_path . '/' . $a_id_file, $new_file);
}
$a_name = trim($this->input->post('a_name'));
$a_name_cn = trim($this->input->post('a_name_cn'));
$this->Infoauthors_model->update($a_id, $this->input->post('a_email'),
$a_name, $a_name_cn, $a_photo,
$this->input->post('a_mobile_phone'),$this->input->post('a_phone'), $this->input->post('a_id_card'),
$this->input->post('a_gender'),$this->input->post('a_address'), $this->input->post('a_school'),
$this->input->post('a_bank'),$this->input->post('a_bank_card'), $this->input->post('a_resume'));
$this->Infoauthors_model->update($a_id, $this->input->post('a_email'), $a_name, $a_name_cn, $a_photo, $this->input->post('a_mobile_phone'), $this->input->post('a_phone'), $this->input->post('a_id_card'), $this->input->post('a_gender'), $this->input->post('a_address'), $this->input->post('a_school'), $this->input->post('a_bank'), $this->input->post('a_bank_card'), $this->input->post('a_resume'));
$this->Infoauthors_model->set_title($a_id, $this->input->post('a_title'));
@ -836,13 +825,10 @@ class Author extends CI_Controller {
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
if (!$this->upload->do_upload($upload_id))
{
if (!$this->upload->do_upload($upload_id)) {
$error = array('error' => $this->upload->display_errors());
var_dump($error);
}
else
{
} else {
$data = array('upload_data' => $this->upload->data());
$file_name = $data['upload_data']['file_name'];
if ($profile) {
@ -864,8 +850,7 @@ class Author extends CI_Controller {
}
//修改职称
public function submit_author_title()
{
public function submit_author_title() {
$a_id = $this->input->post('a_id');
if (empty($a_id)) {
show_404();
@ -884,6 +869,7 @@ class Author extends CI_Controller {
$this->load->view('bootstrap/author/announce_list');
$this->load->view('bootstrap/footer');
}
//公告详情
public function announce_detail($announce_id, $type = 'notice') {
$announce = $this->Infotaskarticles_model->get_announce($announce_id, $type);
@ -893,6 +879,7 @@ class Author extends CI_Controller {
$this->load->view('bootstrap/author/announce_list');
$this->load->view('bootstrap/footer');
}
//编辑公告
public function announce_edit($announce_id = "", $type = 'notice') {
if ($announce_id != "") {
@ -904,6 +891,7 @@ class Author extends CI_Controller {
$this->load->view('bootstrap/author/announce_edit');
$this->load->view('bootstrap/footer');
}
//公告更新
public function add_announce() {
$title = $this->input->post('title');
@ -1014,7 +1002,8 @@ class Author extends CI_Controller {
$excel_str.="\n"; //添加行结束符
}
$filetype = $this->input->post('filetype');
if($filetype==2) $excel_str=iconv('UTF-8','GB2312',$excel_str);//excel简体中文版使用gb2312编码
if ($filetype == 2)
$excel_str = iconv('UTF-8', 'GB2312', $excel_str); //excel简体中文版使用gb2312编码
echo "$excel_str";
}
@ -1043,7 +1032,8 @@ class Author extends CI_Controller {
$enddate = strtotime($enddate);
}
if ($startdate > $enddate) {
echo "请选择正确的日期";die();
echo "请选择正确的日期";
die();
}
//查取google分析数据
$data['analytics_list'] = $this->Infotaskarticles_model->get_analytics_list($pagepath, $sitecode, 50, $startdate, $enddate);
@ -1065,5 +1055,5 @@ class Author extends CI_Controller {
$this->load->view('bootstrap/author/analytics', $data);
}
}
}