/**
  * 退出功能
  * 清除session后,转向回登陆界面
  * @author 罗江涛
  */
 public function logout()
 {
     // 添加管理员日志
     $realName = M('admin')->where(array('adminId' => session("adminId")))->getField('realName');
     $content = "退出登录:" . $realName;
     \Admin\Service\LogService::addAdminLog(session("adminId"), 'logout', $content);
     // 清除session
     unset($_SESSION['username']);
     unset($_SESSION['adminId']);
     $this->redirect("Index/index");
 }
 /**
  * 删除用户反馈信息
  * @author 罗江涛
  * @DateTime 2016-01-08T11:21:14+0800
  */
 public function deleteFeedback()
 {
     // 接收ID
     $feedbackId = I('feedbackId');
     // 添加管理员日志
     $title = M('feedback')->where(array('feedbackId' => $feedbackId))->getField('content');
     $content = "删除:" . $title;
     \Admin\Service\LogService::addAdminLog($feedbackId, 'feedback', $content);
     // 删除
     if (M('feedback')->where(array('feedbackId' => $feedbackId))->delete()) {
         $this->redirect('Feedback/FeedbackList');
     } else {
         $this->error('删除失败');
     }
 }
 /**
  * 锁定,解锁用户
  * @author 罗江涛
  * @DateTime 2016-01-13T11:33:43+0800
  */
 public function lockUser()
 {
     $userId = I('userId');
     $status = I('status');
     $user = array('userId' => $userId, 'status' => $status);
     //修改用户信息
     if (M('user')->save($user)) {
         // 添加管理员日志
         $username = M('user')->where(array('userId' => $userId))->getField('username');
         if ($status == 1) {
             $content = "解锁:" . $username;
         } else {
             $content = "锁定:" . $username;
         }
         \Admin\Service\LogService::addAdminLog($userId, 'user', $content);
         $this->redirect("User/userList");
     } else {
         $this->error('锁定失败' . $db->getDbError());
     }
 }
 /**
  * 修改系统设置
  * @Author   罗江涛
  * @DateTime 2016-04-01T09:53:27+0800
  */
 public function editSystemConfig()
 {
     $webname = I("webname");
     $description = I("description");
     $keywords = I("keywords");
     $copy = I("copy");
     $record = I("record");
     systemConfig("webname", $webname);
     systemConfig("description", $description);
     systemConfig("keywords", $keywords);
     systemConfig("copy", $copy);
     systemConfig("record", $record);
     // 添加管理员日志
     $content = "修改系统设置";
     \Admin\Service\LogService::addAdminLog(session('adminId'), 'system', $content);
     $this->redirect('System/systemConfigForm');
     $this->display();
 }
 /**
  * 文章状态操作,将文章从微信列表移除
  * @author 罗江涛
  * @DateTime 2016-01-12T15:18:22+0800
  */
 public function deleteWeixinArticle()
 {
     // 接收参数
     $articleId = I('articleId');
     // 组合数据
     $data = array('articleId' => $articleId, 'weixin' => 0);
     // 更新
     $result = M('article')->save($data);
     if ($result) {
         $title = M('article')->where(array("article" => $articleId))->getField("title");
         // 日志组合内容
         $content = "移除微信列表:" . $title;
         // 添加日志
         \Admin\Service\LogService::addAdminLog($articleId, 'article', $content);
         // 更新成功,跳转到上一个页面
         redirect($_SERVER['HTTP_REFERER']);
     } else {
         $this->error('文章状态改变失败');
     }
 }
 /**
  * 删除分类
  * @author 罗江涛
  * @DateTime 2016-01-13T11:02:18+0800
  */
 public function deleteCategory()
 {
     // 接收传值,分类ID
     $categoryId = I('categoryId');
     //查看是否有文章与该分类关联
     $count = M('article')->where(array('categoryId' => $categoryId))->count();
     if ($count > 0) {
         // 如果该分类下有文章,不允许删除该分类
         $this->error('有文章属于该分类,请先删除该分类下全部文章才能删除该分类。。。');
     }
     // 添加管理员日志
     $categoryName = M('category')->where(array('categoryId' => $categoryId))->getField('categoryName');
     $content = "删除:" . $categoryName;
     \Admin\Service\LogService::addAdminLog($categoryId, 'category', $content);
     // 删除分类
     if (M('category')->where(array('categoryId' => $categoryId))->delete()) {
         // 删除成功
         $this->redirect('Category/categoryList');
     } else {
         $this->error('删除失败');
     }
 }
 /**
  * 修改标签推荐状态
  * @author 罗江涛
  * @DateTime 2016-01-13T10:31:32+0800
  */
 public function recommend()
 {
     $tagId = I('tagId');
     $recommend = I('recommend', 0);
     $tag = array('tagId' => $tagId, 'recommend' => $recommend);
     // 添加管理员日志
     $tagName = M('tag')->where(array('tagId' => $tagId))->getField('tagName');
     if ($recommend) {
         $content = "推荐标签:" . $tagName;
     } else {
         $content = "取消推荐标签:" . $tagName;
     }
     \Admin\Service\LogService::addAdminLog($tagId, 'tag', $content);
     // 保存后跳转到原来的页面
     M('tag')->save($tag);
     redirect($_SERVER['HTTP_REFERER']);
 }
 /**
  * 删除权限
  * @author 罗江涛
  * @DateTime 2016-01-13T10:31:32+0800
  */
 public function deletePermissions()
 {
     //接收参数
     $permissionsId = I('permissionsId');
     $children = M('permissions')->where(array('parentId' => $permissionsId))->count();
     //控制器下没有方法才能被删除
     if ($children > 0) {
         $this->error('该控制器下有子方法,请先删除所有子方法。删除失败');
     }
     $where = array('permissionsId' => $permissionsId);
     $permissionsName = M('permissions')->where($where)->getField('permissionsName');
     // 删除权限
     $result = M('permissions')->where($where)->delete();
     if ($result) {
         // 添加系统日志
         $content = "删除权限:" . $permissionsName;
         \Admin\Service\LogService::addAdminLog($permissionsId, 'permissions', $content);
         // 删除成功,随便把和组的关联关系也删除了
         M('group_permissions')->where($where)->delete();
         $this->redirect('Admin/permissionsList');
     } else {
         $this->error('删除失败');
     }
 }
 /**
  * 删除活动
  * @author 罗江涛
  * @DateTime 2016-01-13T10:57:34+0800
  */
 public function deletecampaign()
 {
     //并不是真的删除,只是将状态改为0,代表已删除
     $campaignId = I('campaignId');
     $campaign = array('campaignId' => $campaignId, 'status' => 0);
     // 修改成功
     if (M('campaign')->save($campaign)) {
         // 添加管理员日志
         $title = M('campaign')->where(array('campaignId' => $campaignId))->getField('title');
         $content = "放入回收站:" . $title;
         \Admin\Service\LogService::addAdminLog($campaignId, 'campaign', $content);
         $this->redirect('Campaign/campaignList');
     } else {
         // 修改失败
         $this->error('删除失败');
     }
 }