Example #1
0
 public function activityAddAct()
 {
     //表单处理
     if (IS_POST) {
         $id = I('post.id');
         $name = I('post.name');
         $imgurl = I('post.logo');
         if ($id) {
             $resp = D('Activity')->where(array('id' => $id))->save(array('name' => $name, 'pic' => $imgurl));
             if ($resp) {
                 $this->success("修改成功!", UC('Activity/index'));
             } else {
                 $this->error('修改失败');
             }
         } else {
             $resp = D('Activity')->createActivity($name, $imgurl);
             if ($resp) {
                 $this->success("添加成功!", UC('Activity/index'));
             } else {
                 $this->error('添加失败');
             }
         }
     }
     $id = I('get.id');
     if ($id) {
         $info = D('Activity')->where(array('id' => $id))->find();
         $this->assign('info', $info);
         $img_upload = unifile_upload(array('name' => 'logo', 'content' => $info['pic'], 'table' => 'CourseTeacher', 'p_key' => 'id', 'field_name' => 'logo', 'module' => 'course'));
         $this->assign('img_upload', $img_upload);
         $this->assign('headline', '修改活动');
     } else {
         $img_upload = unifile_upload(array('name' => 'logo', 'content' => '', 'module' => 'course'));
         $this->assign('img_upload', $img_upload);
         $this->assign('headline', '添加活动');
     }
     $this->display();
 }
 /**
  * 编辑
  */
 public function editAct()
 {
     $id = intval(I("id"));
     if (IS_POST) {
         $sort = D('WstSort')->where(array('sortid' => $_POST['sortid']))->find();
         $_POST['ldid'] = $_POST['leader'] ? implode(',', $_POST['leader']) : 0;
         $_POST['pid'] = $sort['parentid'];
         $_POST['tid'] = $sort['treedid'];
         $data = D("WstContent")->create();
         if ($data) {
             $data = string_utf8_to_gb2312($data);
             if (D("WstContent")->save($data) !== false) {
                 $this->success("修改成功!");
             } else {
                 $this->error("修改失败!");
             }
         } else {
             $this->error('"修改失败!"');
         }
     } else {
         if (!$id) {
             $this->error("非法操作!");
         }
         $data = D("WstContent")->getObject($id);
         if (!$data) {
             $this->error("该角色不存在!");
         }
         //树状栏目
         $result = D("WstSort")->field('sortid as id,sortname as name,parentid')->order(array("sortid" => "ASC"))->select();
         $result = string_gb2312_to_utf8($result);
         $tree = new p\Tree();
         foreach ($result as $r) {
             $r['selected'] = $r['id'] == $data['sortid'] ? 'selected' : '';
             $array[] = $r;
         }
         $str = "<option value='\$id' \$selected>\$spacer \$name</option>";
         $tree->init($array);
         $select_categorys = $tree->get_tree(0, $str);
         $this->assign("select_categorys", $select_categorys);
         //上传图片
         $img_upload = unifile_upload(array('name' => 'picture', 'content' => $data['picture'], 'table' => 'WstContent', 'p_key' => 'articleid', 'field_name' => 'picture'));
         $this->assign('img_upload', $img_upload);
         //编辑器
         $keditor = keditor(array('name' => 'content', 'content' => $data['content']));
         $this->assign('keditor', $keditor);
         //领导
         $leader = D('WstLd')->getContent($data['ldid']);
         $this->assign('leader', $leader);
         //领导子站
         $leaderSort = D('WstLdSort')->getContent();
         $this->assign('leaderSort', $leaderSort);
         //获取处室
         $chushi = D('WstScks')->getNewChushi();
         $this->assign('chushi', $chushi);
         //处室栏目
         $cslanmu = D('WstSort')->getChushiSort($data['scks']);
         $this->assign('cslanmu', $cslanmu);
         $this->assign('actionName', ACTION_NAME);
         $this->assign("info", $data);
         $this->display("Article:add");
     }
 }
 /**
  * 录入领导
  */
 public function addAct()
 {
     if (IS_POST) {
         $name = string_utf8_to_gb2312($_POST['zjmc']);
         $check = D('WstLd')->where(array('zjmc' => $name))->find();
         if ($check) {
             $this->error('此领导已存在哦');
         }
         $_POST['uptime'] = date('Y-m-d H:i:s', time());
         $_POST['yyld'] = 1;
         $data = string_utf8_to_gb2312($_POST);
         if ($data) {
             $id = D("WstLd")->add($data);
             if ($id) {
                 $this->success("成功");
             } else {
                 $this->error("失败!");
             }
         } else {
             $this->error('失败');
         }
     }
     $img_upload = unifile_upload(array('name' => 'zjtp', 'content' => ''));
     $this->assign('img_upload', $img_upload);
     $this->assign('actionName', ACTION_NAME);
     $this->display();
 }