Ejemplo n.º 1
0
 public function save()
 {
     $group = AuthGroupModel::getUserGroup(UID);
     if ($group[0]['group_id'] == 1) {
         $_POST['uid'] = 1;
     }
     $id = I('param.id');
     if ($id) {
         $Music = M('Muisc');
         $gdlist = $Music->field('id')->where('ggid=' . $id)->select();
         if (!empty($gdlist)) {
             foreach ($gdlist as $gd) {
                 $Music->where('id=' . $gd['id'])->setField('del_flag', '2');
             }
         }
         $_POST['update_date'] = NOW_TIME;
         if ($this->Notice->create() && $this->Notice->save()) {
         } else {
             $this->error('Err: ' . $this->Notice->getDbError());
         }
         if ($this->Ndetail->create() && $this->Ndetail > save()) {
             $this->success('公告更新成功', U('index'));
         } else {
             $this->Notice->where('id=' . I('param.id'))->delete();
             $this->error('Err: ' . $this->Notice->getDbError());
         }
     } else {
         $_POST['update_date'] = NOW_TIME;
         $_POST['create_date'] = NOW_TIME;
         if ($this->Ndetail->create() && $this->Ndetail > add()) {
             $this->success('公告更新成功', U('index'));
         } else {
             $this->error('Err: ' . $this->Ndetail->getDbError());
         }
         if ($this->Notice->create() && $this->Notice->add()) {
             $this->success('公告更新成功', U('index'));
         } else {
             $this->error('Err: ' . $this->Notice->getDbError());
         }
     }
 }
Ejemplo n.º 2
0
 public function index()
 {
     $group = AuthGroupModel::getUserGroup(UID);
     if ($group[0]['group_id'] == 2) {
         $map['uid'] = UID;
     }
     $id = I('param.id');
     if (!empty($id)) {
         $map['id'] = $id;
     }
     $title = I('param.title');
     if (!empty($title)) {
         $map['title'] = array('like', '%' . $title . '%');
     }
     $uid = I('param.uid');
     if (!empty($uid)) {
         $map['uid'] = $uid;
     }
     $list = $this->lists($this->Youpin, $map, 'create_time desc', true);
     $this->assign('list', $list);
     $this->assign('meta_title', '有品管理');
     $this->display();
 }
 /**
  * 删除状态为-1的数据(包含扩展模型)
  * @return true 删除成功, false 删除失败
  * @author huajie <*****@*****.**>
  */
 public function remove()
 {
     //查询假删除的基础数据
     if (is_administrator()) {
         $map = array('status' => -1);
     } else {
         $cate_ids = AuthGroupModel::getAuthCategories(UID);
         $map = array('status' => -1, 'category_id' => array('IN', trim(implode(',', $cate_ids), ',')));
     }
     $base_list = $this->where($map)->field('id,model_id')->select();
     //删除扩展模型数据
     $base_ids = array_column($base_list, 'id');
     //孤儿数据
     $orphan = get_stemma($base_ids, $this, 'id,model_id');
     $all_list = array_merge($base_list, $orphan);
     foreach ($all_list as $key => $value) {
         $logic = $this->logic($value['model_id']);
         $logic->delete($value['id']);
     }
     //删除基础数据
     $ids = array_merge($base_ids, (array) array_column($orphan, 'id'));
     if (!empty($ids)) {
         $res = $this->where(array('id' => array('IN', trim(implode(',', $ids), ','))))->delete();
     }
     return $res;
 }
 /**
  * 将用户添加到用户组的编辑页面
  * @author 朱亚杰 <*****@*****.**>
  */
 public function group()
 {
     $uid = I('uid');
     $auth_groups = D('AuthGroup')->getGroups();
     $user_groups = AuthGroupModel::getUserGroup($uid);
     $ids = array();
     foreach ($user_groups as $value) {
         $ids[] = $value['group_id'];
     }
     $nickname = D('Member')->getNickName($uid);
     $this->assign('nickname', $nickname);
     $this->assign('auth_groups', $auth_groups);
     $this->assign('user_groups', implode(',', $ids));
     $this->display();
 }